vendor: 4,545 bytes, lines 1-21
1"use strict"; 2var __extends = (this && this.__extends) || (function () { 3 var extendStatics = Object.setPrototypeOf || 4 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 5 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 6 return function (d, b) { 7 extendStatics(d, b); 8 function __() { this.constructor = d; } 9 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 10 }; 11})(); 12var TotalPoll; 13(function (TotalPoll) { 14 TotalPoll.Polls = {}; 15 /** 16 * Utils 17 */ 18 var Modal = /** @class */ (function () { 19 function Modal() { 20 var _this = this; 21 this.template = "\n<style type=\"text/css\">\n @-webkit-keyframes modalFadeIn {\n from {\n opacity: 0;\n } \n \n to {\n opacity: 1;\n } \n }\n \n @keyframes modalFadeIn {\n from {\n opacity: 0;\n } \n \n to {\n opacity: 1;\n } \n }\n \n @-webkit-keyframes modalFadeOut {\n from {\n opacity: 1;\n } \n \n to {\n opacity: 0;\n } \n }\n \n @keyframes modalFadeOut {\n from {\n opacity: 1;\n } \n \n to {\n opacity: 0;\n } \n }\n \n .totalpoll-modal {\n position:fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 999999999;\n width: 100%;\n height: 100%;\n background: rgba(0,0,0,0.9);\n display: none;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -webkit-flex-direction: column;\n -ms-flex-direction: column;\n flex-direction: column;\n -webkit-box-align: center;\n -webkit-align-items: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -webkit-justify-content: center;\n -ms-flex-pack: center;\n justify-content: center;\n }\n \n .totalpoll-modal.totalpoll-is-visible {\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n -webkit-animation: modalFadeIn 0.2s ease-in forwards;\n animation: modalFadeIn 0.2s ease-in forwards;\n } \n \n .totalpoll-modal.totalpoll-is-hiding {\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n -webkit-animation: modalFadeOut 0.2s ease-in forwards;\n animation: modalFadeOut 0.2s ease-in forwards;\n }\n \n .totalpoll-modal-content {\n position: relative;\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-flex: 1;\n -webkit-flex: 1;\n -ms-flex: 1;\n flex: 1;\n width: 100%;\n height: 100%;\n max-width: 100vh;\n max-width: 100%;\n max-height: 100vh;\n max-height: 100%;\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n -webkit-box-align: center;\n -webkit-align-items: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;\n -webkit-justify-content: center;\n -ms-flex-pack: center;\n justify-content: center;\n }\n \n @media (min-width:768px){\n .totalpoll-modal-content {\n max-width: 85vh;\n max-width: 85%;\n max-height: 85vh;\n max-height: 85%;\n padding: 2em;\n }\n }\n \n .totalpoll-modal-content img {\n max-width: 100%!important;\n max-height: 100%!important;\n width: auto!important;\n height: auto!important;\n }\n \n .totalpoll-modal-content .totalpoll-embed-type-image {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-align: center;\n -webkit-align-items: center;\n -ms-flex-align: center;\n align-items: center;\n -webkit-box-pack: center;
21\n -webkit-justify-content: center;\n -ms-flex-pack: center;\n justify-content: center;\n margin: auto;\n text-align: center;\n }\n \n .totalpoll-modal-content .totalpoll-embed-type-video {\n position: relative;\n padding-bottom: 56.25%;\n overflow: hidden;\n max-width: 100%;\n width: 100%;\n }\n \n .totalpoll-modal-content .totalpoll-embed-type-video iframe, .totalpoll-modal-content .totalpoll-embed-type-video object, .totalpoll-modal-content .totalpoll-embed-type-video embed,.totalpoll-modal-content .totalpoll-embed-type-video video, .totalpoll-modal-content .totalpoll-embed-type-video audio {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 100%;\n }\n \n .totalpoll-modal-close {\n position: absolute;\n top: 1em;\n right: 1em;\n width: 3em;\n height: 3em;\n padding: 1em;\n border: 1px solid rgba(255, 255, 255, 0.1);\n -webkit-border-radius: 50%;\n border-radius: 50%;\n fill: white;\n cursor: pointer;\n background: rgba(0, 0, 0, 0.5);\n -webkit-box-sizing: border-box;\n box-sizing: border-box;\n }\n \n .totalpoll-modal-close svg {\n vertical-align: top;\n opacity: 0.5;\n -webkit-transition: 0.2s all ease-out;\n -o-transition: 0.2s all ease-out;\n transition: 0.2s all ease-out;\n }\n \n .totalpoll-modal-close:hover svg {\n opacity: 1;\n -webkit-transform: scale(1.1);\n -ms-transform: scale(1.1);\n transform: scale(1.1);\n }\n \n .totalpoll-modal-close:active svg {\n -webkit-transform: scale(0.8);\n -ms-transform: scale(0.8);\n transform: scale(0.8);\n }\n \n</style>\n<div class=\"totalpoll-modal\">\n <div class=\"totalpoll-modal-content\"></div>\n <div class=\"totalpoll-modal-close\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"5 5 14 14\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M18.3 5.71c-.39-.39-1.02-.39-1.41 0L12 10.59 7.11 5.7c-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.02 0 1.41L10.59 12 5.7 16.89c-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0L12 13.41l4.89 4.89c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4z\"/></svg>\n </div>\n</div>"; 22 this.create(); 23 this.appendToBody(); 24 this.element.on('click', function (event) { 25 if (jQuery(event.srcElement).hasClass('totalpoll-modal') || jQuery(event.srcElement).hasClass('totalpoll-modal-content')) { 26 _this.hide(); 27 } 28 }); 29 this.element.find('.totalpoll-modal-close').on('click', function () { 30 _this.hide(); 31 }); 32 } 33 Modal.prototype.appendToBody = function () { 34 jQuery(document.body).append(this.element); 35 }; 36 Modal.prototype.create = function () { 37 this.element = jQuery(this.template); 38 }; 39 Modal.prototype.hide = function () { 40 var _this = this; 41 this.element.removeClass('totalpoll-is-visible'); 42 this.element.addClass('totalpoll-is-hiding'); 43 jQuery(document).unbind('keydown.totalpoll-modal'); 44 setTimeout(function () { 45 _this.element.removeClass('totalpoll-is-hiding'); 46 document.documentElement.style.overflowY = 'initial'; 47 _this.element.find('.totalpoll-modal-content').html(''); 48 }, 200); 49 }; 50 Modal.prototype.remove = function () { 51 this.element.remove(); 52 }; 53 Modal.prototype.setContent = function (content) { 54 this.element.find('.totalpoll-modal-content').html(content); 55 }; 56 Modal.prototype.show = function () { 57 var _this = this; 58 document.documentElement.style.overflowY = 'hidden'; 59 this.element.addClass('totalpoll-is-visible'); 60 jQuery(document).one('keydown.totalpoll-modal', function (event) { 61 if (event.which === 27) { 62 _this.hide(); 63 } 64 }); 65 }; 66 return Modal; 67 }()); 68 var AjaxBehaviour = /** @class */ (function () { 69 function AjaxBehaviour(poll) { 70 var _this = this; 71 this.poll = poll; 72 this.loader = jQuery("\n <style>\n .totalpoll-wrapper { \n position: relative; \n }\n \n @-webkit-keyframes totalpoll-fade-in {\n form {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n }\n \n @keyframes totalpoll-fade-in {\n form {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n }\n \n .totalpoll-form-loading {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n display: -webkit-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -webkit-flex-direction: column;\n -ms-flex-direction: column;\n flex-direction: column;\n -webkit-box-pack: center;
72\n -webkit-justify-content: center;\n -ms-flex-pack: center;\n justify-content: center;\n -webkit-box-align: center;\n -webkit-align-items: center;\n -ms-flex-align: center;\n align-items: center;\n background-color: rgba(255,255,255, 0.3);\n opacity: 0;\n -webkit-animation: totalpoll-fade-in 300ms ease-in forwards;\n animation: totalpoll-fade-in 300ms ease-in forwards;\n }\n </style>\n<div class=\"totalpoll-form-loading\">\n <svg width=\"38\" height=\"38\" viewBox=\"0 0 38 38\" xmlns=\"http://www.w3.org/2000/svg\" stroke=\"#000000\">\n <g fill=\"none\" fill-rule=\"evenodd\">\n <g transform=\"translate(1 1)\" stroke-width=\"2\">\n <circle stroke-opacity=\".5\" cx=\"18\" cy=\"18\" r=\"18\"/>\n <path d=\"M36 18c0-9.94-8.06-18-18-18\">\n <animateTransform\n attributeName=\"transform\"\n type=\"rotate\"\n from=\"0 18 18\"\n to=\"360 18 18\"\n dur=\"1s\"\n repeatCount=\"indefinite\"/>\n </path>\n </g>\n </g>\n</svg>\n</div>"); 73 poll.element.find('[type="submit"]').on('click', function (event) { 74 poll.element.find('[name="totalpoll[action]"]').val(this.value); 75 }); 76 poll.element.find('form').on('submit', function (event) { 77 _this.load(_this.poll.config.ajaxEndpoint, new FormData(event.currentTarget), 'POST'); 78 event.preventDefault(); 79 }); 80 } 81 AjaxBehaviour.prototype.destroy = function () { 82 }; 83 AjaxBehaviour.prototype.load = function (url, data, method) { 84 var _this = this; 85 if (data === void 0) { data = {}; } 86 if (method === void 0) { method = 'GET'; } 87 this.poll.element.css('pointer-events', 'none'); 88 this.poll.element.parent().css('min-height', this.poll.element.parent().outerHeight()); 89 this.poll.element.prepend(this.loader); 90 this.poll.transition.out(function () { 91 jQuery.ajax({ 92 url: url, 93 data: data, 94 processData: method != 'POST', 95 contentType: false, 96 type: method, 97 }) 98 .done(function (response) { 99 var $poll = jQuery(response); 100 $poll.find('.totalpoll-container').hide(); 101 _this.poll.transition.out(function () { 102 _this.poll.element.replaceWith($poll); 103 var poll = new TotalPoll.Poll($poll, true, _this.poll.config['behaviours']['async']); 104 poll.transition.in(function () { 105 poll.element.parent().css('min-height', 0); 106 }); 107 }); 108 }) 109 .fail(function (error) { 110 _this.poll.element.removeAttr('style'); 111 console.error(_this.poll.config['i18n']['Something went wrong! Please try again.'], error); 112 }); 113 }); 114 }; 115 return AjaxBehaviour; 116 }()); 117 var SliderBehaviour = /** @class */ (function () { 118 //@PRO 119 function SliderBehaviour(poll) { 120 this.poll = poll; 121 this.hasCustomFields = false; 122 this.currentSlide = 0; 123 if (poll.screen === 'vote' || poll.screen === 'results') { 124 poll.element.find('.totalpoll-form-custom-fields').attr('totalpoll-valid-selection', 'true'); 125 this.setupButtons(poll.element.find('.totalpoll-buttons'), poll.element.find('.totalpoll-button')); 126 this.setupSlides(poll.element.find('.totalpoll-question, .totalpoll-form-custom-fields:has(input)')); 127 } 128 } 129 SliderBehaviour.prototype.destroy = function () { 130 }; 131 SliderBehaviour.prototype.isFirstSlide = function () { 132 return this.currentSlide === 0; 133 }; 134 SliderBehaviour.prototype.isLastSlide = function () { 135 return this.$slides.length === this.currentSlide + 1; 136 }; 137 SliderBehaviour.prototype.isValidSelection = function () { 138 return this.$currentSlide.is('[totalpoll-valid-selection="true"]'); 139 }; 140 SliderBehaviour.prototype.nextSlide = function (event) { 141 if (this.isLastSlide()) { 142 return; 143 } 144 else { 145 event.preventDefault(); 146 this.setSlide(this.currentSlide + 1); 147 this.scroll(); 148 } 149 }; 150 SliderBehaviour.prototype.previousSlide = function (event) { 151 if (this.isFirstSlide()) { 152 return; 153 } 154 else { 155 event.preventDefault(); 156 this.setSlide(this.currentSlide - 1); 157 this.scroll(); 158 } 159 }; 160 SliderBehaviour.prototype.refreshButtons = function () { 161 this.$buttons.hide(); 162 this.$nextButton[this.isLastSlide() || (this.poll.behaviours['oneClick'] && this.poll.screen === 'vote') ? 'hide' : 'show'](); 163 this.$previousButton[this.isFirstSlide() || (this.poll.behaviours['oneClick'] && this.poll.screen === 'vote') ? 'hide' : 'show'](); 164 this.$buttons[this.isLastSlide() && (!this.poll.behaviours['oneClick'] || this.poll.screen === 'vote') ? 'show' : 'hide'](); 165 if (this.poll.screen === 'vote') { 166 this.$voteButton.prop('disabled', !this.isValidSelection()); 167 this.$nextButton.prop('disabled', !this.isValidSelection()); 168 if (this.poll.behaviours['oneClick']) { 169 this.$voteButton[this.hasCustomFields && this.isLastSlide() ? 'show' : 'hide'](); 170 this.$resultsButton.show(); 171 } 172 } 173 }; 174 SliderBehaviour.prototype.setSlide = function (index) { 175 var _this = this; 176 this.$slides.eq(this.currentSlide).fadeOut(500, function () { 177 _this.currentSlide = index; 178 _this.$currentSlide = _this.$slides.eq(_this.currentSlide); 179 _this.$currentSlide.fadeIn(); 180 _this.refreshButtons(); 181 if (_this.poll.config.scrollUp) { 182 jQuery('html, body').animate({ scrollTop: _this.poll.element.offset().top - 100 }, 1000); 183 } 184 }); 185 }; 186 SliderBehaviour.prototype.setupButtons = function (container, buttons) { 187 var _this = this; 188 this.$buttons = buttons; 189 this.$voteButton = this.$buttons.filter('button[value="vote"]'); 190 this.$resultsButton = this.$buttons.filter('button[value="results"]'); 191 this.$previousButton = jQuery("<button type=\"button\" class=\"totalpoll-button totalpoll-buttons-slider-previous\">" + this.poll.config['i18n']['Previous'] + "</button>"); 192 this.$nextButton = jQuery("<button type=\"button\" class=\"totalpoll-button totalpoll-buttons-slider-next\">" + this.poll.config['i18n']['Next'] + "</button>"); 193 container.prepend(this.$previousButton); 194 container.append(this.$nextButton); 195 if (this.poll.behaviours['oneClick'] && this.poll.screen === 'vote') { 196 if (this.$resultsButton) { 197 this.$resultsButton.show(); 198 } 199 this.$voteButton.hide(); 200 this.$previousButton.hide(); 201 this.$nextButton.hide(); 202 } 203 if (this.poll.screen === 'results' && !this.poll.element.find('.totalpoll-question').length) { 204 this.$previousButton.hide(); 205 this.$nextButton.hide(); 206 } 207 this.$voteButton.on('click', function (event) { return _this.nextSlide(event); }); 208 this.$previousButton.on('click', function (event) { return _this.previousSlide(event); }); 209 this.$nextButton.on('click', function (event) { return _this.nextSlide(event); }); 210 }; 211 SliderBehaviour.prototype.setupSlides = function (slides) { 212 var _this = this; 213 this.hasCustomFields = slides.is('.totalpoll-form-custom-fields'); 214 this.$slides = slides; 215 this.$slides.hide(); 216 var $questions = this.$slides.filter('.totalpoll-question'); 217 $questions.each(function (index, element) { 218 var $question = jQuery(element); 219 $question.append("<div class=\"totalpoll-question-number\">" + (index + 1) + " " + _this.poll.config['i18n']['of'] + " " + $questions.length + "</div>"); 220 $question.on('change', 'input[type="checkbox"], input[type="radio"]', function (event) { 221 _this.refreshButtons(); 222 }); 223 }); 224 this.setSlide(0); 225 // Move to custom fields if there are errors 226 if (this.$slides.last().find('.totalpoll-form-field-errors-item').length) { 227 this.setSlide(this.$slides.length - 1); 228 } 229 }; 230 SliderBehaviour.prototype.scroll = function () { 231 if (this.poll.config['behaviours']['scrollUp']) { 232 jQuery('html, body').animate({ scrollTop: this.poll.element.offset().top - 100 }, 1000); 233 } 234 }; 235 return SliderBehaviour; 236 }()); 237 var OneClickBehaviour = /** @class */ (function () { 238 //@PRO 239 function OneClickBehaviour(poll) { 240 var $voteButton = poll.element.find('.totalpoll-buttons-vote'); 241 $voteButton.hide(); 242 poll.element.find('.totalpoll-question input[type="checkbox"], .totalpoll-question input[type="radio"]').on('change', function (event) { 243 $voteButton.prop('disabled', false).trigger('click'); 244 }); 245 } 246 OneClickBehaviour.prototype.destroy = function () { 247 }; 248 return OneClickBehaviour; 249 }()); 250 var ScrollUpBehaviour = /** @class */ (function () { 251 function ScrollUpBehaviour(poll) { 252 if (poll.isViaAjax() && !poll.isViaAsync()) { 253 setTimeout(function () { 254 jQuery('html, body').animate({ scrollTop: poll.element.offset().top - 100 }, 1000); 255 }, 200); 256 } 257 } 258 ScrollUpBehaviour.prototype.destroy = function () { 259 }; 260 return ScrollUpBehaviour; 261 }()); 262 var EmbedResizingBehaviour = /** @class */ (function () { 263 function EmbedResizingBehaviour(poll) { 264 var _this = this; 265 this.poll = poll; 266 this.listener = function (event) { return _this.receiveRequest(event); }; 267 window.addEventListener("message", this.listener, false); 268 } 269 EmbedResizingBehaviour.prototype.destroy = function () { 270 window.removeEventListener("message", this.listener); 271 }; 272 EmbedResizingBehaviour.prototype.postHeight = function () { 273 top.postMessage({ 274 totalpoll: { 275 id: this.poll.id, 276 action: 'resizeHeight', 277 value: jQuery(document.body).height() 278 } 279 }, '*'); 280 }; 281 EmbedResizingBehaviour.prototype.receiveRequest = function (event) { 282 if (event.data.totalpoll && event.data.totalpoll.id === this.poll.id && event.data.totalpoll.action === 'requestHeight') { 283 this.postHeight(); 284 } 285 }; 286 return EmbedResizingBehaviour; 287 }()); 288 var SelectionBehaviour = /** @class */ (function () { 289 function SelectionBehaviour(poll) { 290 this.poll = poll; 291 poll.element.find('.totalpoll-question input[type="checkbox"], .totalpoll-question input[type="radio"]').on('change', function (event) {
292 var valid = false; 293 var $this = jQuery(this); 294 var $question = $this.closest('.totalpoll-question'); 295 var $otherChoice = $question.find('.totalpoll-question-choices-other'); 296 var $otherChoiceField = $otherChoice.find('input[type="text"]'); 297 var minSelection = parseInt($question.attr('totalpoll-min-selection')) || 0; 298 var maxSelection = parseInt($question.attr('totalpoll-max-selection')) || 1; 299 $question.find('.totalpoll-question-choices-item').removeClass('totalpoll-question-choices-item-checked'); 300 $question.find('.totalpoll-question-choices-item:has(input:checked)').addClass('totalpoll-question-choices-item-checked'); 301 var $checked = $question.find('input[type="checkbox"]:checked, input[type="radio"]:checked'); 302 var $unchecked = $question.find('input[type="checkbox"]:not(:checked), input[type="radio"]:not(:checked)'); 303 if (maxSelection == 1) { 304 valid = Boolean($checked.length) || minSelection == 0; 305 } 306 else if ($checked.length >= maxSelection) { 307 $unchecked.prop('disabled', true); 308 valid = true; 309 if ($otherChoiceField.length && !$otherChoiceField.val().trim() && !$this.parents('.totalpoll-question-choices-other').length) { 310 $otherChoice.hide(); 311 } 312 } 313 else { 314 $unchecked.prop('disabled', false); 315 valid = $checked.length >= minSelection; 316 if ($otherChoiceField.length && !$otherChoiceField.val().trim()) { 317 $otherChoice.show(); 318 } 319 } 320 $question.attr('totalpoll-valid-selection', valid ? 'true' : 'false'); 321 $question.find('.totalpoll-question-choices-item').removeClass('totalpoll-question-choices-item-disabled'); 322 $question.find('.totalpoll-question-choices-item:has(input:disabled)').addClass('totalpoll-question-choices-item-disabled'); 323 }); 324 poll.element.find('.totalpoll-question input[type="text"]').on('focus', function (event) { 325 jQuery(this).closest('label').find('input[type="checkbox"], input[type="radio"]').prop('checked', true).change(); 326 }); 327 poll.element.find('.totalpoll-question input[type="text"]').on('blur', function (event) { 328 jQuery(this).closest('label').find('input[type="checkbox"], input[type="radio"]').prop('checked', Boolean(this.value.trim())).change(); 329 }); 330 poll.element.find('.totalpoll-question input[type="checkbox"], .totalpoll-question input[type="radio"]').change(); 331 } 332 SelectionBehaviour.prototype.destroy = function () { 333 }; 334 return SelectionBehaviour; 335 }()); 336 var ModalBehaviour = /** @class */ (function () { 337 function ModalBehaviour(poll) { 338 var _this = this; 339 this.poll = poll; 340 this.modal = new Modal(); 341 jQuery(poll.element).on('click', '[totalpoll-modal]', function (event) { 342 var selector = jQuery(event.currentTarget).attr('totalpoll-modal'); 343 if (selector) { 344 _this.modal.setContent(jQuery(selector).clone()); 345 } 346 _this.modal.show(); 347 event.preventDefault(); 348 }); 349 } 350 ModalBehaviour.prototype.destroy = function () { 351 this.modal.remove(); 352 }; 353 return ModalBehaviour; 354 }()); 355 var reCaptchaBehaviour = /** @class */ (function () { 356 function reCaptchaBehaviour(poll) { 357 var _this = this; 358 this.poll = poll; 359 this.valid = false; 360 this.$recaptcha = poll.element.find('.g-recaptcha'); 361 this.$form = poll.element.find('form'); 362 this.invisible = this.$recaptcha.data('size') === 'invisible'; 363 this.widget = this.invisible ? this.$form.find('[type="submit"][value="vote"]').get(0) : this.$recaptcha.get(0); 364 // Invisible 365 if (this.invisible) { 366 this.$form.on('submit', function (event) { return _this.validate(event); }); 367 window['grecaptcha'].ready(function () { return _this.render(); }); 368 } 369 else if (this.poll.isViaAjax()) { 370 this.render(); 371 } 372 } 373 reCaptchaBehaviour.prototype.destroy = function () { 374 this.$recaptcha.remove(); 375 }; 376 reCaptchaBehaviour.prototype.render = function () { 377 var _this = this; 378 window['grecaptcha'].render(this.widget, { 379 sitekey: this.$recaptcha.data('sitekey'), 380 callback: function () { 381 _this.valid = true; 382 if (_this.invisible) { 383 _this.$form.trigger('submit'); 384 } 385 } 386 }); 387 }; 388 reCaptchaBehaviour.prototype.validate = function (event) { 389 if (!this.valid) { 390 event.preventDefault(); 391 } 392 }; 393 return reCaptchaBehaviour; 394 }()); 395 var CountUpBehaviour = /** @class */ (function () { 396 function CountUpBehaviour(poll) { 397 var _this = this; 398 this.poll = poll; 399 poll.element.find('[totalpoll-count-up]').each(function (index, element) { 400 // Prepare arguments 401 var $element = jQuery(element); 402 var countTo = Number($element.attr('totalpoll-count-up')); 403 var format = $element.attr('totalpoll-count-format') || "{counter}"; 404 var pad = Number($element.attr('totalpoll-count-pad')) || 2; 405 // Start 406 _this.start($element, countTo, format, pad); 407 }); 408 } 409 CountUpBehaviour.prototype.destroy = function () { 410 }; 411 CountUpBehaviour.prototype.start = function (el, countTo, format, pad) { 412 if (pad === void 0) { pad = 2; } 413 jQuery({ counter: 0, format: format, pad: pad, el: el }) 414 .animate({ counter: countTo }, { 415 duration: 900, 416 step: this.step, 417 complete: this.step 418 }); 419 }; 420 CountUpBehaviour.prototype.step = function () { 421 var formatedCounter = this['format'].replace('{counter}', CountUpBehaviour.padStart(Math.round(this['counter']), this['pad'])); 422 this['el'].text(formatedCounter); 423 }; 424 CountUpBehaviour.padStart = function (number, targetLength, padString) { 425 if (padString === void 0) { padString = "0"; } 426 targetLength = targetLength >> 0; //truncate if number, or convert non-number to 0; 427 padString = String(typeof padString !== 'undefined' ? padString : ' '); 428 if (number.length >= targetLength) { 429 return String(number); 430 } 431 else { 432 targetLength = targetLength - number.length; 433 if (targetLength > padString.length) { 434 padString += padString['repeat'](targetLength / padString.length); //append to original to ensure we are longer than needed 435 }
436 return padString.slice(0, targetLength) + String(number); 437 } 438 }; 439 return CountUpBehaviour; 440 }()); 441 var CustomFieldsPosition = /** @class */ (function () { 442 function CustomFieldsPosition(poll) { 443 this.poll = poll; 444 poll.element.find('.totalpoll-questions').before(poll.element.find('.totalpoll-form-custom-fields')); 445 } 446 CustomFieldsPosition.prototype.destroy = function () { 447 }; 448 return CustomFieldsPosition; 449 }()); 450 /** 451 * Transitions 452 */ 453 var Transition = /** @class */ (function () { 454 function Transition(element, duration) { 455 this.element = element; 456 this.duration = duration; 457 this.element = jQuery(element); 458 } 459 Transition.prototype.getDuration = function () { 460 return Number(this.duration); 461 }; 462 Transition.prototype.getElement = function () { 463 return this.element; 464 }; 465 return Transition; 466 }()); 467 var SimpleTransition = /** @class */ (function (_super) { 468 __extends(SimpleTransition, _super); 469 function SimpleTransition() { 470 return _super !== null && _super.apply(this, arguments) || this; 471 } 472 SimpleTransition.prototype.in = function (callback, duration) { 473 if (duration === void 0) { duration = this.getDuration(); } 474 this.getElement().css({ 'visibility': 'visible', 'display': 'inherit' }); 475 if (callback) { 476 callback(); 477 } 478 }; 479 SimpleTransition.prototype.out = function (callback, duration) { 480 if (duration === void 0) { duration = this.getDuration(); } 481 this.getElement().css('visibility', 'hidden'); 482 if (callback) { 483 callback(); 484 } 485 }; 486 return SimpleTransition; 487 }(Transition)); 488 var FadeTransition = /** @class */ (function (_super) { 489 __extends(FadeTransition, _super); 490 function FadeTransition() { 491 return _super !== null && _super.apply(this, arguments) || this; 492 } 493 FadeTransition.prototype.in = function (callback, duration) { 494 if (duration === void 0) { duration = this.getDuration(); } 495 this.getElement().fadeIn(duration, callback); 496 }; 497 FadeTransition.prototype.out = function (callback, duration) { 498 if (duration === void 0) { duration = this.getDuration(); } 499 this.getElement().fadeTo(duration, 0.2, callback); 500 }; 501 return FadeTransition; 502 }(Transition)); 503 var SlideTransition = /** @class */ (function (_super) { 504 __extends(SlideTransition, _super); 505 function SlideTransition() { 506 return _super !== null && _super.apply(this, arguments) || this; 507 } 508 SlideTransition.prototype.in = function (callback, duration) { 509 if (duration === void 0) { duration = this.getDuration(); } 510 this.getElement().slideDown(duration, callback); 511 }; 512 SlideTransition.prototype.out = function (callback, duration) { 513 if (duration === void 0) { duration = this.getDuration(); } 514 this.getElement().slideUp(duration, callback); 515 }; 516 return SlideTransition; 517 }(Transition)); 518 var Hooks = /** @class */ (function () { 519 function Hooks() { 520 } 521 Hooks.addAction = function (event, callback) { 522 jQuery(TotalPoll).on(event, function (event) { 523 var payload = [].slice.call(arguments).splice(1); 524 callback.apply(event, payload); 525 }); 526 }; 527 Hooks.doAction = function (event, payload) { 528 jQuery(TotalPoll).triggerHandler(event, payload); 529 }; 530 return Hooks; 531 }()); 532 TotalPoll.Hooks = Hooks; 533 /** 534 * Poll 535 */ 536 var Poll = /** @class */ (function () { 537 function Poll(element, viaAjax, viaAsync) { 538 if (viaAjax === void 0) { viaAjax = false; } 539 if (viaAsync === void 0) { viaAsync = false; } 540 this.element = element; 541 this.viaAjax = viaAjax; 542 this.viaAsync = viaAsync; 543 this.behaviours = {}; 544 this.config = {}; 545 this.screen = ''; 546 this.id = element.attr('totalpoll'); 547 this.config = JSON.parse(element.find('[totalpoll-config]').text()); 548 this.screen = element.attr('totalpoll-screen'); 549 if (TotalPoll.Polls[this.id]) { 550 // Destroy the old instance 551 TotalPoll.Polls[this.id].destroy(); 552 } 553 TotalPoll.Polls[this.id] = this; 554 element.data('poll', this); 555 // Selection 556 this.behaviours['selection'] = new SelectionBehaviour(this); 557 // Modal 558 if (this.config['behaviours']['disableModal']) { 559 this.element.find('[totalpoll-modal]').remove(); 560 this.element.find('.has-thumbnail').removeClass('has-thumbnail'); 561 } 562 else { 563 this.behaviours['modal'] = new ModalBehaviour(this); 564 } 565 // Scroll up 566 if (this.config['behaviours']['scrollUp']) { 567 this.behaviours['scrollUp'] = new ScrollUpBehaviour(this); 568 } 569 // One-click 570 if (this.config['behaviours']['oneClick']) { 571 this.behaviours['oneClick'] = new OneClickBehaviour(this); 572 } 573 // Questions slider 574 if (this.config['behaviours']['slider']) { 575 this.behaviours['slider'] = new SliderBehaviour(this); 576 } 577 // Count up 578 if (this.config['behaviours']['countUp']) { 579 this.behaviours['countUp'] = new CountUpBehaviour(this); 580 } 581 // Custom fields position 582 if (this.config['behaviours']['fieldsFirst']) { 583 this.behaviours['fieldsFirst'] = new CustomFieldsPosition(this); 584 } 585 // Transition 586 var transition = this.config['effects']['transition']; 587 var container = this.element.find('.totalpoll-container'); 588 if (transition == 'fade') { 589 this.transition = new FadeTransition(container, this.config['effects']['duration']); 590 } 591 else if (transition == 'slide') { 592 this.transition = new SlideTransition(container, this.config['effects']['duration']); 593 } 594 else { 595 this.transition = new SimpleTransition(container, this.config['effects']['duration']); 596 } 597 // reCaptcha 598 if (window['grecaptcha'] && element.find('.g-recaptcha').length) { 599 this.behaviours['recaptcha'] = new reCaptchaBehaviour(this); 600 } 601 // Ajax 602 if (this.config['behaviours']['async'] || this.config['behaviours']['ajax']) { 603 this.behaviours['ajax'] = new AjaxBehaviour(this); 604 } 605 // Async 606 if (this.config['behaviours']['async']) { 607 this.behaviours['ajax'].load(element.attr('totalpoll-ajax-url')); 608 } 609 // Embed 610 if (window.top !== window.self) { 611 this.behaviours['embed'] = new EmbedResizingBehaviour(this); 612 this.behaviours['embed'].postHeight(); 613 } 614 Hooks.doAction('totalpoll/init', this); 615 } 616 Poll.prototype.destroy = function () { 617 jQuery.each(this.behaviours, function (id, behaviour) { 618 behaviour.destroy(); 619 }); 620 Hooks.doAction('totalpoll/destroy', this); 621 // this.element.remove(); 622 }; 623 Poll.prototype.isViaAjax = function () { 624 return this.viaAjax; 625 }; 626 Poll.prototype.isViaAsync = function () { 627 return this.viaAsync; 628 }; 629 return Poll; 630 }()); 631 TotalPoll.Poll = Poll; 632})(TotalPoll || (TotalPoll = {})); 633jQuery(function ($) { 634 $('[totalpoll]').each(function () { 635 new TotalPoll.Poll($(this)); 636 }); 637}); 638 639//# sourceMappingURL=../maps/frontend/totalpoll.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.