PluginProbe
HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce / 2.6.2
HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce v2.6.2
2.15.0 trunk 1.0.0 1.0.1 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1.2 2.1.3 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 All 62 releases
hurrytimer / assets / js / admin.js

admin.js in HurryTimer – An Scarcity and Urgency Countdown Timer for WordPress & WooCommerce 2.6.2, at assets/js/admin.js

1,270 lines 51.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";
2
3 function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
4
5 function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
7 function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
9 function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
10
11 function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
12
13 function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
15 (function ($) {
16 'use strict';
17
18 var styles = {};
19 var campaignInnerPreviewRef = $('.hurrytimer-campaign');
20 var campaignPreviewRef = $('#hurrytimer-campaign-preview');
21 var headlinePreviewRef = campaignInnerPreviewRef.find('.hurrytimer-headline');
22 var timerPreviewRef = campaignInnerPreviewRef.find('.hurrytimer-timer');
23 var timerDigitPreviewRef = campaignInnerPreviewRef.find('.hurrytimer-timer-digit');
24 var timerLabelPreviewRef = campaignInnerPreviewRef.find('.hurrytimer-timer-label');
25 var timerBlockPreviewRef = campaignInnerPreviewRef.find('.hurrytimer-timer-block');
26 var timerSepPreviewRef = campaignInnerPreviewRef.find('.hurrytimer-timer-sep');
27 var campaignCTA = campaignInnerPreviewRef.find('.hurrytimer-button');
28 /**
29 * Toggle the given block visibility.
30 * @param {object} toggle
31 * @param {object} block
32 */
33
34 function toggleBlockVisibility(toggle, block) {
35 if (toggle.is(':checked')) {
36 block.removeClass('hidden');
37
38 if ($('input[name=block_separator_visibility]').is(':checked')) {
39 block.next().removeClass('hidden');
40 }
41 } else {
42 block.addClass('hidden');
43 block.next().addClass('hidden');
44 }
45 }
46 /**
47 * Change element color for the preview.
48 *
49 * @param {object} inputElement
50 * @param {string} color
51 */
52
53
54 function changeColor(inputElement) {
55 var color = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
56
57 if (typeof inputElement === 'string') {
58 inputElement = $('input[name="' + inputElement + '"]');
59 }
60
61 color = color || inputElement.val();
62
63 switch (inputElement.attr('name')) {
64 case 'digit_color':
65 setCSS('.hurrytimer-campaign .hurrytimer-timer-digit', timerDigitPreviewRef, 'color', color, false);
66 setCSS('.hurrytimer-campaign .hurrytimer-timer-sep', timerSepPreviewRef, 'color', color);
67 break;
68
69 case 'block_border_color':
70 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'border-color', color);
71 break;
72
73 case 'block_bg_color':
74 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'background-color', color);
75 break;
76
77 case 'label_color':
78 setCSS('.hurrytimer-campaign .hurrytimer-timer-label', timerLabelPreviewRef, 'color', color);
79 break;
80
81 case 'headline_color':
82 setCSS('.hurrytimer-campaign .hurrytimer-headline', headlinePreviewRef, 'color', color);
83 break;
84
85 case 'sticky_bar_bg_color':
86 setCSS('.hurrytimer-sticky', $('.hurrytimer-sticky'), 'background-color', color);
87 break;
88
89 case 'call_to_action[bg_color]':
90 setCSS('.hurrytimer-campaign .hurrytimer-button', campaignCTA, 'background-color', color);
91 break;
92
93 case 'call_to_action[text_color]':
94 setCSS('.hurrytimer-campaign .hurrytimer-button', campaignCTA, 'color', color);
95 break;
96
97 case 'sticky_bar_close_btn_color':
98 setCSS('.hurrytimer-sticky-close svg', $('.hurrytimer-sticky-close svg'), 'fill', color);
99 break;
100 }
101 }
102 /**
103 * Apply CSS for live preview.
104 *
105 * @param {object} element
106 * @param {string} property
107 * @param {string} value
108 * @param {boolean} apply
109 */
110
111
112 function setCSS(selector, element, property, value) {
113 var apply = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
114
115 var _selector = element.selector || selector;
116
117 styles = _objectSpread(_objectSpread({}, styles), {}, _defineProperty({}, _selector, _objectSpread(_objectSpread({}, styles[_selector]), {}, _defineProperty({}, property, value))));
118
119 if (apply) {
120 if ($('#hurryt-styles').length === 0) {
121 $('head').append('<style id="hurryt-styles"></style>');
122 }
123
124 var css = '';
125
126 for (var sel in styles) {
127 css += " ".concat(sel, "{ ").concat(Object.entries(styles[sel]).join(';').replace(/\,/g, ':'), "}");
128 }
129
130 $('#hurryt-styles').html(css);
131 }
132 }
133
134 function removeCSSProperty(element, property) {
135 for (var selector in styles) {
136 if (selector === element.selector) {
137 delete styles[selector][property];
138 }
139 }
140 } // ------------------------------------------------------------
141 // Initialize preview items color.
142 // ------------------------------------------------------------
143
144
145 changeColor('digit_color');
146 changeColor('label_color');
147 changeColor('block_border_color');
148 changeColor('block_bg_color');
149 changeColor('headline_color');
150 changeColor('sticky_bar_bg_color');
151 changeColor('sticky_bar_close_btn_color');
152 changeColor('call_to_action[bg_color]');
153 changeColor('call_to_action[text_color]'); // ------------------------------------------------------------
154 // Input toggle.
155 // ------------------------------------------------------------
156
157 $('.js-hurrytimer-input-toggle').each(function () {
158 var input = $(this);
159 input.hide();
160 var toggle = $("<input \n type=\"hidden\" \n name=\"".concat(input.attr('name'), "\" \n value=\"no\" />\n <span \n class=\"hurrytimer-input-toggle\">\n </span>"));
161 input.before(toggle);
162
163 if (input.prop('checked')) {
164 toggle.addClass('is-on');
165 }
166
167 toggle.on('click', function () {
168 toggle.toggleClass('is-on');
169 input.attr('checked', !input.prop('checked'));
170 input.trigger('change');
171 });
172 }); // ------------------------------------------------------------
173 // Datetime picker.
174 // ------------------------------------------------------------
175
176 $('.hurrytimer-datepicker').each(function () {
177 var $this = $(this);
178 $this.datetimepicker({
179 controlType: 'select',
180 dateFormat: 'yy-mm-dd',
181 timeFormat: 'hh:mm TT',
182 oneLine: true,
183 onSelect: function onSelect(value, instance) {
184 setMonthlyDayTypes($this);
185 }
186 });
187 setMonthlyDayTypes($this);
188 });
189
190 function setMonthlyDayTypes($input) {
191 if ($input.attr('name') === 'recurring_start_time') {
192 var _dayOfMonth = getDayOfMonth($input.datepicker('getDate'));
193
194 var _dayOfWeek = getDayOfWeek($input.datepicker('getDate'));
195
196 $('#recurDayOfMonth').text(_dayOfMonth);
197 $('#recurDayOfWeek').text(_dayOfWeek);
198 }
199 }
200
201 function getDayOfMonth(date) {
202 var dayOfMonth = false;
203 var day = $.datepicker.formatDate('d', date);
204
205 if (day == 1) {
206 dayOfMonth = '1st day';
207 } else if (day == 2) {
208 dayOfMonth = '2nd day';
209 } else if (day == 3) {
210 dayOfMonth = '3rd day';
211 } else {
212 dayOfMonth = day + 'th day';
213 }
214
215 return dayOfMonth;
216 }
217
218 function getDayOfWeek(date) {
219 var dayOfWeek = false;
220 var dayName = $.datepicker.formatDate('DD', date);
221 var day = $.datepicker.formatDate('d', date);
222 var dayIndex = Math.ceil(day / 7);
223
224 if (dayIndex == 1) {
225 dayOfWeek = '1st';
226 } else if (dayIndex == 2) {
227 dayOfWeek = '2nd';
228 } else if (dayIndex == 23) {
229 dayOfWeek = '3rd';
230 } else {
231 dayOfWeek = dayIndex + 'th';
232 }
233
234 dayOfWeek += ' ' + dayName;
235 return dayOfWeek;
236 }
237
238 $('.hurrytimer-timepicker').each(function () {
239 $(this).timepicker({
240 timeFormat: 'hh:mm TT',
241 controlType: 'select',
242 oneLine: true
243 });
244 }); // ------------------------------------------------------------
245 // Handle mode toggle.
246 // ------------------------------------------------------------
247
248 function handleMode(elementRef) {
249 document.querySelectorAll('.mode-settings[data-for^="hurrytMode"]').forEach(function (e) {
250 e.classList.add('hidden');
251 });
252 document.querySelectorAll(".mode-settings[data-for=\"".concat(elementRef.attr('id'), "\"]")).forEach(function (e) {
253 e.classList.remove('hidden');
254 });
255 }
256
257 var toggleRecurringUntil = function toggleRecurringUntil(value) {
258 if (value == 3) {
259 recurringUntilElement.classList.remove('hidden');
260 } else {
261 recurringUntilElement.classList.add('hidden');
262 }
263 };
264
265 var recurringUntilElement = document.querySelector('tr[data-for="hurrytRecurringUntil"]');
266 document.querySelectorAll('input[name="recurring_until"]').forEach(function (e) {
267 e.addEventListener('change', function (e) {
268 return toggleRecurringEndDate(e.target.value);
269 });
270 });
271 document.querySelectorAll('input[name="recurring_until"]:checked').forEach(function (e) {
272 return toggleRecurringUntil(e.value);
273 }); // Handle mode.
274
275 $('input[name=mode]').on('change', function () {
276 handleMode($(this));
277 });
278 handleMode($('input[name=mode]:checked')); // ------------------------------------------------------------
279 // Handle products type dropdown.
280 // ------------------------------------------------------------
281
282 $('#hurrytimer-wc-products-selection-type').on('change', function () {
283 var $this = $(this);
284 var $selectedOption = $this.find('option:selected');
285 var $label = $('.hurrytimer-products-selection-type-label');
286 var $autocompleteWrap = $label.closest('.form-field');
287
288 if ($selectedOption.data('show-autocomplete')) {
289 $label.text($selectedOption.text());
290 $autocompleteWrap.removeClass('hidden');
291 } else {
292 $autocompleteWrap.addClass('hidden');
293 }
294 }).change(); // Handle tabs
295 // ------------------------------------------------------------
296
297 $('.hurrytimer-tabbar a').on('click', function (e) {
298 e.preventDefault();
299 var $tab = $(this);
300 $('.hurrytimer-tabcontent').removeClass('active');
301 $($tab.attr('href')).addClass('active');
302 $tab.parent().siblings().removeClass('active');
303 $tab.parent().addClass('active');
304
305 if ($tab.attr('href').indexOf('appearance') >= 0 || $tab.attr('href').indexOf('styling') >= 0) {
306 $('.hurryt-fullscreen').removeClass('hidden');
307 } else {
308 $('.hurryt-fullscreen').addClass('hidden');
309 }
310 }); // ------------------------------------------------------------
311 // Search for products/Categories
312 // ------------------------------------------------------------
313
314 $('.hurryt-tags-input').select2({
315 tags: true,
316 placeholder: 'Example: http://www.example.com/page',
317 tokenSeparators: [',', ' ']
318 });
319 $('#hurrytimer-wc-products-selection').select2({
320 placeholder: 'Search...',
321 width: '500',
322 minimumInputLength: 2,
323 ajax: {
324 url: hurrytimer_ajax_object.ajax_url,
325 dataType: 'json',
326 data: function data(params) {
327 return {
328 action: 'wcSearchProducts',
329 search: params.term,
330 exclude: $(this).val(),
331 productsSelection: $('#hurrytimer-wc-products-selection-type').val(),
332 type: 'public'
333 };
334 }
335 }
336 }); // ------------------------------------------------------------
337 // Color picker
338 // ------------------------------------------------------------
339
340 $('.hurrytimer-color-input').each(function () {
341 var self = $(this);
342 self.wpColorPicker({
343 width: 220,
344 change: function change(event, ui) {
345 changeColor(self, ui.color.toString());
346 },
347 clear: function clear() {
348 changeColor(self, 'transparent');
349 }
350 });
351 }); // ------------------------------------------------------------
352 // CUSTOM CSS
353 // ------------------------------------------------------------
354 // ------------------------------------------------------------
355 // Handle sub tabbar.
356 // ------------------------------------------------------------
357
358
359 $('.hurrytimer-subtabbar a').on('click', function (e) {
360 e.preventDefault();
361 var self = $(this);
362 $('.hurrytimer-subtabcontent').each(function () {
363 $(this).removeClass('active');
364 });
365 $(self.attr('href')).addClass('active');
366 self.parent().siblings().removeClass('active');
367 self.parent().addClass('active');
368 if (cssEditor) cssEditor.refresh();
369 }); // ------------------------------------------------------------
370 // Accordion.
371 // ------------------------------------------------------------
372
373 $('.hurrytimer-accordion-heading').on('click', function () {
374 var self = $(this);
375 var containerElement = self.parent();
376
377 if (containerElement.hasClass('active')) {
378 containerElement.removeClass('active');
379 } else {
380 containerElement.addClass('active').siblings().removeClass('active');
381 }
382 }); // ------------------------------------------------------------
383 // Enable/disable sticky bar.
384 // ------------------------------------------------------------
385
386 $('input[name=enable_sticky]').on('change', function () {
387 if ($(this).is(':checked')) {
388 campaignPreviewRef.addClass('hurrytimer-sticky');
389 campaignInnerPreviewRef.wrap('<div class="hurrytimer-sticky-inner"></div>');
390
391 if (campaignPreviewRef.hasClass('hurryt-preview-fullscreen')) {
392 setCSS('#hurrytimer-campaign-preview', campaignPreviewRef, 'position', 'fixed', false);
393 setCSS('#hurrytimer-campaign-preview', campaignPreviewRef, 'top', 0);
394 }
395 } else {
396 campaignPreviewRef.removeClass('hurrytimer-sticky');
397 campaignInnerPreviewRef.unwrap('.hurrytimer-sticky-inner');
398 } // refresh dismiss button
399
400
401 if ($('input[name=sticky_bar_dismissible]').is(':checked')) {
402 campaignPreviewRef.find('.hurrytimer-sticky-close').show();
403 } else {
404 campaignPreviewRef.find('.hurrytimer-sticky-close').hide();
405 }
406 });
407 $('input[name=sticky_bar_dismissible]').on('change', function () {
408 if ($(this).is(':checked')) {
409 campaignPreviewRef.find('.hurrytimer-sticky-close').show();
410 } else {
411 campaignPreviewRef.find('.hurrytimer-sticky-close').hide();
412 }
413 }); // ------------------------------------------------------------
414 // Change block display.
415 // ------------------------------------------------------------
416
417 $('select[name=block_display]').on('change', function () {
418 var value = $(this).val();
419 var blockSize = $('input[name="block_size"]').val() + 'px';
420 setCSS('.hurrytimer-campaign .hurrytimer-timer-digit', timerDigitPreviewRef, 'display', value, false);
421 setCSS('.hurrytimer-campaign .hurrytimer-timer-label', timerLabelPreviewRef, 'display', value, false);
422 var blockSizeInput = $(this).closest('.hurrytimer-style-control-field').siblings('.hurrytimer-field-block-size');
423
424 if (value === 'inline') {
425 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'width', 'auto', false);
426 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'height', 'auto', false);
427 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'display', 'inline-block');
428 blockSizeInput.hide();
429 } else {
430 blockSizeInput.show();
431 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'width', blockSize, false);
432 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'height', blockSize, false);
433 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'display', 'flex');
434 }
435 }).change(); // ------------------------------------------------------------
436 // Set digit size.
437 // ------------------------------------------------------------
438
439 $('input[name=digit_size]').on('input keyup paste change', function () {
440 var fontSize = parseInt($(this).val()) + 'px';
441 setCSS('.hurrytimer-campaign .hurrytimer-timer-digit', timerDigitPreviewRef, 'font-size', fontSize, false);
442 setCSS('.hurrytimer-campaign .hurrytimer-timer-sep', timerSepPreviewRef, 'font-size', fontSize);
443 }).change(); // ------------------------------------------------------------
444 // Set CTA text size.
445 // ------------------------------------------------------------
446
447 $('input[name="call_to_action[text_size]"]').on('input keyup paste change', function () {
448 var fontSize = parseInt($(this).val()) + 'px';
449 setCSS('.hurrytimer-campaign .hurrytimer-button', campaignCTA, 'font-size', fontSize);
450 }).change(); // ------------------------------------------------------------
451 // Set block spacing.
452 // ------------------------------------------------------------
453
454 $('input[name=block_spacing]').on('input keyup paste change', function () {
455 var spacing = "".concat($(this).val(), "px");
456
457 if ($('select[name=display]').val() === 'inline') {
458 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'margin-bottom', spacing, false);
459 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'margin-top', spacing);
460 } else {
461 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'margin-left', spacing, false);
462 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'margin-right', spacing);
463 }
464 }).change(); // ------------------------------------------------------------
465 // Set block padding.
466 // ------------------------------------------------------------
467
468 $('input[name=block_padding]').on('input keyup paste change', function () {
469 var padding = parseInt($(this).val()) + 'px';
470 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'padding', padding);
471 }).change(); // ------------------------------------------------------------
472 // Sticky Bar Y padding.
473 // ------------------------------------------------------------
474
475 $('input[name=sticky_bar_padding]').on('input keyup paste change', function () {
476 var padding = "".concat($(this).val(), "px");
477 var stickyBarInner = campaignPreviewRef.find('.hurrytimer-sticky-inner');
478 setCSS('#hurrytimer-campaign-preview .hurrytimer-sticky-inner', stickyBarInner, 'padding-top', padding, false);
479 setCSS('#hurrytimer-campaign-preview .hurrytimer-sticky-inner', stickyBarInner, 'padding-bottom', padding);
480 }).change();
481 $('select[name=sticky_bar_position]').on('input keyup paste change', function () {
482 if ($(this).val() === 'top') {
483 removeCSSProperty(campaignPreviewRef, 'bottom');
484 setCSS('#hurrytimer-campaign-preview', campaignPreviewRef, 'top', 0);
485 } else {//removeCSSProperty(campaignPreviewRef, 'top');
486 // setCSS(campaignPreviewRef, 'bottom', 0);
487 }
488 }).change();
489 $('input[name=headline_spacing]').on('input keyup paste change', function () {
490 var spacing = "".concat($(this).val(), "px");
491
492 if ($('select[name=campaign_display]').val() === 'inline') {
493 if ($('select[name=headline_position]').val() === hurrytimer_ajax_object.headline_pos.above_timer) {
494 setCSS('.hurrytimer-campaign .hurrytimer-headline', headlinePreviewRef, 'margin-left', spacing);
495 setCSS('.hurrytimer-campaign .hurrytimer-headline', headlinePreviewRef, 'margin-top', 0);
496 } else {
497 setCSS('.hurrytimer-campaign .hurrytimer-headline', headlinePreviewRef, 'margin-right', spacing);
498 setCSS('.hurrytimer-campaign .hurrytimer-headline', headlinePreviewRef, 'margin-bottom', 0);
499 }
500 } else {
501 if ($('select[name=headline_position]').val() === hurrytimer_ajax_object.headline_pos.above_timer) {
502 setCSS('.hurrytimer-campaign .hurrytimer-headline', headlinePreviewRef, 'margin-left', 0);
503 setCSS('.hurrytimer-campaign .hurrytimer-headline', headlinePreviewRef, 'margin-top', spacing);
504 } else {
505 setCSS('.hurrytimer-campaign .hurrytimer-headline', headlinePreviewRef, 'margin-right', 0);
506 setCSS('.hurrytimer-campaign .hurrytimer-headline', headlinePreviewRef, 'margin-bottom', spacing);
507 }
508 }
509 }).change();
510 $('input[name="call_to_action[spacing]"]').on('input keyup paste change', function () {
511 var spacing = "".concat($(this).val(), "px");
512
513 if ($('select[name=campaign_display]').val() === 'inline') {
514 setCSS('.hurrytimer-campaign .hurrytimer-button', campaignCTA, 'margin-right', spacing, false);
515 setCSS('.hurrytimer-campaign .hurrytimer-button', campaignCTA, 'margin-left', spacing);
516 } else {
517 setCSS('.hurrytimer-campaign .hurrytimer-button', campaignCTA, 'margin-top', spacing, false);
518 setCSS('.hurrytimer-campaign .hurrytimer-button', campaignCTA, 'margin-bottom', spacing);
519 }
520 }).change(); // ------------------------------------------------------------
521 // Set label size.
522 // ------------------------------------------------------------
523
524 $('input[name=label_size]').on('input keyup paste change', function () {
525 setCSS('.hurrytimer-campaign .hurrytimer-timer-label', timerLabelPreviewRef, 'font-size', parseInt($(this).val()) + 'px');
526 }).change(); // ------------------------------------------------------------
527 // Set block border width.
528 // ------------------------------------------------------------
529
530 $('input[name=block_border_width]').on('input keyup paste change', function () {
531 var borderSize = parseInt($(this).val());
532 var borderColor = $('input[name=block_border_color]').val() || 'transparent';
533 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'border', borderColor + ' solid ' + borderSize + 'px');
534 }).change(); // ------------------------------------------------------------
535 // Set block border radius.
536 // ------------------------------------------------------------
537
538 $('input[name=block_border_radius]').on('input keyup paste change', function () {
539 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'border-radius', "".concat($(this).val(), "px"));
540 }).change(); // ------------------------------------------------------------
541 // Set block size.
542 // ------------------------------------------------------------
543
544 $('input[name=block_size]').on('input keyup paste change', function () {
545 var value = parseInt($(this).val());
546 var size = value + 'px';
547
548 if (value === 0 || $('select[name=block_display]').val() === 'inline') {
549 size = 'auto';
550 }
551
552 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'width', size, false);
553 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'height', size);
554 }).change(); // ------------------------------------------------------------
555 // Bind post title input (headline) to preview.
556 // ------------------------------------------------------------
557
558 var _loaded = false;
559 $('#hurryt-headline').on('input paste keyup change', function () {
560 if ($(this).val().length === 0 && !_loaded) {
561 $(this).val(headlinePreviewRef.text());
562 _loaded = true;
563 return;
564 }
565
566 headlinePreviewRef.html($(this).val());
567 }).change(); // ------------------------------------------------------------
568 // Change headline position.
569 // ------------------------------------------------------------
570
571 $('select[name=headline_position]').on('change', function () {
572 if (parseInt($(this).val()) === hurrytimer_ajax_object.headline_pos.above_timer) {
573 headlinePreviewRef.after(timerPreviewRef);
574 } else {
575 headlinePreviewRef.before(timerPreviewRef);
576 }
577 }).change(); // ------------------------------------------------------------
578 // Set headline size
579 // ------------------------------------------------------------
580
581 $('input[name=headline_size]').on('input keyup paste change', function () {
582 setCSS('.hurrytimer-campaign .hurrytimer-headline', headlinePreviewRef, 'font-size', parseInt($(this).val()) + 'px');
583 }).change(); // ------------------------------------------------------------
584 // Set label case.
585 // ------------------------------------------------------------
586
587 $('select[name=label_case]').on('change', function () {
588 setCSS('.hurrytimer-campaign .hurrytimer-timer-label', timerLabelPreviewRef, 'text-transform', $(this).val());
589 }).change(); // ------------------------------------------------------------
590 // Set CTA text.
591 // ------------------------------------------------------------
592
593 $('input[name="call_to_action[text]"]').on('change keyup paste input', function () {
594 campaignCTA.text($(this).val());
595 }).change(); // ------------------------------------------------------------
596 // Set CTA horizontal padding
597 // ------------------------------------------------------------
598
599 $('input[name="call_to_action[x_padding]"]').on('input keyup paste change', function () {
600 var padding = "".concat($(this).val(), "px");
601 setCSS('.hurrytimer-campaign .hurrytimer-button', campaignCTA, 'padding-left', padding, false);
602 setCSS('.hurrytimer-campaign .hurrytimer-button', campaignCTA, 'padding-right', padding);
603 }).change(); // ------------------------------------------------------------
604 // Set CTA border radius
605 // ------------------------------------------------------------
606
607 $('input[name="call_to_action[border_radius]"]').on('input keyup paste change', function () {
608 setCSS('.hurrytimer-campaign .hurrytimer-button', campaignCTA, 'border-radius', "".concat($(this).val(), "px"));
609 }).change(); // ------------------------------------------------------------
610 // Set CTA vertical padding
611 // ------------------------------------------------------------
612
613 $('input[name="call_to_action[y_padding]"]').on('input keyup paste change', function () {
614 var padding = parseInt($(this).val()) + 'px';
615 setCSS('.hurrytimer-campaign .hurrytimer-button', campaignCTA, 'padding-top', padding, false);
616 setCSS('.hurrytimer-campaign .hurrytimer-button', campaignCTA, 'padding-bottom', padding);
617 }).change(); // ------------------------------------------------------------
618 // Toggle block separator visibility.
619 // ------------------------------------------------------------
620
621 $('input[name=block_separator_visibility]').on('change', function () {
622 var self = $(this);
623
624 if (!self.is(':checked')) {
625 timerSepPreviewRef.addClass('hidden');
626 return;
627 }
628
629 timerBlockPreviewRef.each(function () {
630 if ($(this).hasClass('hidden')) {
631 $(this).next().addClass('hidden');
632 } else {
633 $(this).next().removeClass('hidden');
634 }
635 });
636 }).change();
637 $('#hurrytimer-months-visibility').on('change', function () {
638 toggleBlockVisibility($(this), campaignInnerPreviewRef.find('[data-block=months]'));
639 }).change(); // ------------------------------------------------------------
640 // Toggle "days" block visibility.
641 // ------------------------------------------------------------
642
643 $('#hurrytimer-days-visibility').on('change', function () {
644 toggleBlockVisibility($(this), campaignInnerPreviewRef.find('[data-block=days]'));
645 }).change(); // ------------------------------------------------------------
646 // Toggle "hours" block visibility
647 // ------------------------------------------------------------
648
649 $('#hurrytimer-hours-visibility').on('change', function () {
650 toggleBlockVisibility($(this), campaignInnerPreviewRef.find('[data-block=hours]'));
651 }).change(); // ---------------------------------------------------------------
652 // Toggle "minutes" block visibility
653 // ---------------------------------------------------------------
654
655 $('#hurrytimer-minutes-visibility').on('change', function () {
656 toggleBlockVisibility($(this), campaignInnerPreviewRef.find('[data-block=minutes]'));
657 }).change(); // ---------------------------------------------------------------
658 // Toggle "seconds" block visibility
659 // ---------------------------------------------------------------
660
661 $('#hurrytimer-seconds-visibility').on('change', function () {
662 toggleBlockVisibility($(this), campaignInnerPreviewRef.find('[data-block=seconds]'));
663 }).change(); // ---------------------------------------------------------------
664 // Toggle "headline" block visibility
665 // ---------------------------------------------------------------
666
667 $('#hurrytimer-headline-visibility').on('change', function () {
668 if ($(this).is(':checked')) {
669 headlinePreviewRef.removeClass('hidden');
670 } else {
671 headlinePreviewRef.addClass('hidden');
672 }
673 }).change(); // ---------------------------------------------------------------
674 // Toggle "labels" visibility.
675 //----------------------------------------------------------------
676
677 $('#hurrytimer-label-visibility').on('change', function () {
678 if ($(this).is(':checked')) {
679 timerLabelPreviewRef.removeClass('hidden');
680 } else {
681 timerLabelPreviewRef.addClass('hidden');
682 }
683 }).change(); // ---------------------------------------------------------------
684 // Toggle CTA visibility.
685 // ------------------------------------------------------------
686
687 $('#hurrytimer-cta-enabled').on('change', function () {
688 toggleBlockVisibility($(this), campaignInnerPreviewRef.find('.hurrytimer-button-wrap'));
689 }).change(); // ---------------------------------------------------------------
690 // Input slider.
691 // ------------------------------------------------------------
692
693 var blockSizeSliderElement;
694 var blockSizeInputElement;
695 $('.hurrytimer-input-slider').each(function () {
696 var self = $(this);
697 var boundInputElement = $('input[name="' + self.data('input-name') + '"]');
698 var min = parseInt(boundInputElement.attr('min')) || 0;
699 var max = parseInt(boundInputElement.attr('max')) || 100;
700
701 if (boundInputElement.attr('name') === 'block_size') {
702 min = parseInt($('input[name=digit_size]').val()) || min;
703 blockSizeSliderElement = self;
704 blockSizeInputElement = boundInputElement;
705 }
706
707 self.slider({
708 slide: function slide(_, ui) {
709 boundInputElement.val(ui.value);
710 boundInputElement.trigger('input');
711
712 if (boundInputElement.attr('name') === 'digit_size') {
713 $('input[name=block_size]').attr('min', ui.value);
714 blockSizeSliderElement.slider('option', 'min', ui.value);
715
716 if (blockSizeInputElement.val() < ui.value) {
717 blockSizeSliderElement.slider('option', 'value', ui.value);
718 blockSizeInputElement.val(ui.value);
719 blockSizeInputElement.trigger('input');
720 }
721 }
722 },
723 max: max,
724 min: min,
725 value: boundInputElement.val()
726 });
727 }); // ------------------------------------------------------------
728 // ------------------------------------------------------------
729 // Add new action
730 // ------------------------------------------------------------
731
732 $('#hurrytimer-new-action').on('click', function () {
733 //removeif(pro)
734 if ($('.hurrytimer-action-block').length === 1) {
735 return;
736 } // endremoveif(pro)
737
738
739 var action = $('.hurrytimer-action-block').last().clone(true, true);
740 action.find('.hurrytimer-action-block-subfields').addClass('hidden');
741 var fields = action.find(':input');
742
743 for (var i = 0; i < fields.length; i++) {
744 fields[i].name = fields[i].name.replace(/actions\[(\d+)\]\[(\w+)\]/, function (fm, i, name) {
745 return 'actions[' + ++i + '][' + name + ']';
746 });
747 }
748
749 $(this).parent().before(action);
750
751 if ($('.hurrytimer-action-block').length === 1) {
752 $('.hurrytimer-action-block').find('.hurrytimer-delete-action').addClass('hidden');
753 } else {
754 $('.hurrytimer-action-block').find('.hurrytimer-delete-action').removeClass('hidden');
755 }
756 }); // ------------------------------------------------------------
757 // Handle action selection
758 // ------------------------------------------------------------
759
760 $('#hurrytimer-actions').on('change', '.hurrytimer-action-select', function () {
761 handleActionChange($(this));
762 });
763 $('.hurrytimer-action-select').each(function () {
764 handleActionChange($(this));
765 });
766
767 function handleActionChange(element) {
768 // removeIf(pro)
769 if (element.find(':selected').data('pro-feat') !== undefined) {
770 $('.hurryt-pro-feat').removeClass('hidden');
771 return;
772 } else {
773 $('.hurryt-pro-feat').addClass('hidden');
774 } // endRemoveIf(pro)
775
776
777 var action = element.find('option:selected');
778
779 if (+action.val() === 4 && +$('.hurrytimer-mode:checked').val() === 2) {
780 element.next('.hurryt-compat-info').removeClass('hidden');
781 } else {
782 element.next('.hurryt-compat-info').addClass('hidden');
783 }
784
785 var block = element.closest('.hurrytimer-action-block');
786 block.find('.hurrytimer-action-block-subfields').addClass('hidden');
787 block.find('.' + action.data('subfields')).removeClass('hidden');
788 } // ------------------------------------------------------------
789 // Handle action deletion
790 // ------------------------------------------------------------
791
792
793 $('#hurrytimer-actions').on('click', '.hurrytimer-delete-action', function () {
794 if ($('.hurrytimer-action-block').length === 1) return;
795 $(this).closest('.hurrytimer-action-block').remove();
796
797 if ($('.hurrytimer-action-block').length === 1) {
798 $('.hurrytimer-action-block').find('.hurrytimer-delete-action').addClass('hidden');
799 } else {
800 $('.hurrytimer-action-block').find('.hurrytimer-delete-action').removeClass('hidden');
801 }
802 }); // ------------------------------------------------------------
803 // Set "days" label
804 // ------------------------------------------------------------
805
806 $('input[name="labels[days]"]').on('input keyup paste', function () {
807 campaignInnerPreviewRef.find('[data-block=days] .hurrytimer-timer-label').text($(this).val());
808 }).trigger('input');
809 $('input[name="labels[months]"]').on('input keyup paste', function () {
810 campaignInnerPreviewRef.find('[data-block=months] .hurrytimer-timer-label').text($(this).val());
811 }).trigger('input'); // ------------------------------------------------------------
812 // Set "hours" label
813 // ------------------------------------------------------------
814
815 $('input[name="labels[hours]"]').on('input keyup paste', function () {
816 campaignInnerPreviewRef.find('[data-block=hours] .hurrytimer-timer-label').text($(this).val());
817 }).trigger('input'); // ------------------------------------------------------------
818 // Set "minutes" label
819 // ------------------------------------------------------------
820
821 $('input[name="labels[minutes]"]').on('input keyup paste', function () {
822 campaignInnerPreviewRef.find('[data-block=minutes] .hurrytimer-timer-label').text($(this).val());
823 }).trigger('input'); // ------------------------------------------------------------
824 // Set "seconds" label
825 // ------------------------------------------------------------
826
827 $('input[name="labels[seconds]"]').on('input keyup paste', function () {
828 campaignInnerPreviewRef.find('[data-block=seconds] .hurrytimer-timer-label').text($(this).val());
829 }).trigger('input'); // ------------------------------------------------------------
830 // Compaign display
831 // ------------------------------------------------------------
832
833 $('select[name=campaign_display]').on('change', function () {
834 var blockMarginBottom = timerBlockPreviewRef.css('margin-bottom');
835
836 if ($(this).val() === 'inline') {
837 campaignInnerPreviewRef.addClass('hurrytimer-inline');
838 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'margin-bottom', '0');
839 } else {
840 campaignInnerPreviewRef.removeClass('hurrytimer-inline');
841 setCSS('.hurrytimer-campaign .hurrytimer-timer-block', timerBlockPreviewRef, 'margin-bottom', blockMarginBottom);
842 }
843
844 $('input[name="call_to_action[spacing]"]').change();
845 $('input[name="headline_spacing"]').change();
846 }).change(); // ------------------------------------------------------------
847 // Compaign alignment
848 // ------------------------------------------------------------
849
850 $('select[name=campaign_align]').on('change', function () {
851 var value = $(this).val();
852 setCSS('.hurrytimer-campaign', campaignInnerPreviewRef, 'text-align', value);
853
854 if ($('select[name=campaign_display]').val() === 'inline') {
855 return false;
856 }
857
858 switch (value) {
859 case 'left':
860 setCSS('.hurrytimer-campaign .hurrytimer-timer', timerPreviewRef, 'justify-content', 'flex-start');
861 break;
862
863 case 'right':
864 setCSS('.hurrytimer-campaign .hurrytimer-timer', timerPreviewRef, 'justify-content', 'flex-end');
865 break;
866
867 case 'center':
868 setCSS('.hurrytimer-campaign .hurrytimer-timer', timerPreviewRef, 'justify-content', 'center');
869 break;
870 }
871 }).change();
872 $('.hurryt-fullscreen').on('click', function (e) {
873 e.preventDefault();
874
875 if ($(this).hasClass('on')) {
876 campaignPreviewRef.removeClass('hurryt-preview-fullscreen');
877 $(this).removeClass('on');
878
879 if (campaignPreviewRef.hasClass('hurrytimer-sticky')) {
880 setCSS('#hurrytimer-campaign-preview', campaignPreviewRef, 'position', 'relative');
881 }
882 } else {
883 campaignPreviewRef.addClass('hurryt-preview-fullscreen');
884 $(this).addClass('on');
885 }
886 });
887 $('select[name="sticky_bar_pages[]"]').select2({
888 placeholder: 'Search...'
889 });
890 $('select[name="sticky_bar_pages[]"]').on('change', function () {
891 if ($(this).val() === null) {
892 $('input[name="sticky_bar_pages[]"]').val([]);
893 } else {
894 $('input[name="sticky_bar_pages[]"]').val("[".concat($(this).val(), "]"));
895 }
896 });
897 $('select[name="sticky_exclude_pages[]"]').select2({
898 placeholder: 'Search...'
899 });
900 $('select[name="sticky_exclude_pages[]"]').on('change', function () {
901 if ($(this).val() === null) {
902 $('input[name="sticky_exclude_pages[]"]').val([]);
903 } else {
904 $('input[name="sticky_exclude_pages[]"]').val("[".concat($(this).val(), "]"));
905 }
906 });
907 $('input[type="checkbox"][name="sticky_bar_show_on_all_pages"]').on('change', function () {
908 if ($('input[type="hidden"][name="sticky_bar_show_on_all_pages"]').length === 0) {
909 $(this).after('<input type="hidden" name="sticky_bar_show_on_all_pages" value="yes" />');
910 }
911
912 if ($(this).is(':checked')) {
913 $('input[type="hidden"][name="sticky_bar_show_on_all_pages"]').val('yes');
914 $('select[name="sticky_bar_pages[]"').attr('disabled', true);
915 } else {
916 $('input[type="hidden"][name="sticky_bar_show_on_all_pages"]').val('no');
917 $('select[name="sticky_bar_pages[]"').attr('disabled', false);
918 }
919 }).change();
920 $(document).on('change', '#hurrytimer-evergreen-restart', function () {
921 if ($(this).val() == 4) {
922 $('#hurrytimer-evergreen-restart-duration').removeClass('hidden'); // removeIf(pro)
923
924 $('#hurrytimer-restart-after-feature-unlock').removeClass('hidden'); // endRemoveIf(pro)
925 } else {
926 $('#hurrytimer-evergreen-restart-duration').addClass('hidden'); // removeIf(pro)
927
928 $('#hurrytimer-restart-after-feature-unlock').addClass('hidden'); // endRemoveIf(pro)
929 }
930 });
931 var $selectedEvergreenRestart = $('#hurrytimer-evergreen-restart').find('option:selected');
932
933 if ($selectedEvergreenRestart.val() == 4) {
934 $('#hurrytimer-evergreen-restart-duration').removeClass('hidden');
935 $('#hurrytimer-restart-after-feature-unlock').removeClass('hidden');
936 } else {
937 $('#hurrytimer-evergreen-restart-duration').addClass('hidden');
938 $('#hurrytimer-restart-after-feature-unlock').addClass('hidden');
939 } // Display tooltips
940
941
942 $('#hurrytimer-settings').tooltip({
943 tooltipClass: 'hurryt-tooltip',
944 content: function content() {
945 return $(this).prop('title');
946 },
947 position: {
948 my: 'center bottom-20',
949 at: 'center top',
950 using: function using(position, feedback) {
951 $(this).css(position);
952 $('<div>').addClass('arrow').addClass(feedback.vertical).addClass(feedback.horizontal).appendTo(this);
953 }
954 }
955 }); // Toggle display
956
957 $('.hurryt-sticky-bar-display-on').on('change', function () {
958 if ($(this).val() === 'specific_pages') {
959 $('.hurryt_sticky_bar_pages').removeClass('hidden');
960 $('.hurryt_sticky_exclude_pages').addClass('hidden');
961 } else if ($(this).val() === 'exclude_pages') {
962 $('.hurryt_sticky_bar_pages').addClass('hidden');
963 $('.hurryt_sticky_exclude_pages').removeClass('hidden');
964 } else {
965 $('.hurryt_sticky_bar_pages').addClass('hidden');
966 $('.hurryt_sticky_exclude_pages').addClass('hidden');
967 }
968 });
969
970 if ($('.hurryt-sticky-bar-display-on:checked').val() === 'specific_pages') {
971 $('.hurryt_sticky_bar_pages').removeClass('hidden');
972 $('.hurryt_sticky_exclude_pages').addClass('hidden');
973 } else if ($('.hurryt-sticky-bar-display-on:checked').val() === 'exclude_pages') {
974 $('.hurryt_sticky_bar_pages').addClass('hidden');
975 $('.hurryt_sticky_exclude_pages').removeClass('hidden');
976 } else {
977 $('.hurryt_sticky_bar_pages').addClass('hidden');
978 $('.hurryt_sticky_exclude_pages').addClass('hidden');
979 }
980
981 $('input[name="sticky_bar_dismissible"]').on('change', function () {
982 if ($(this).is(':checked')) {
983 $('input[name="sticky_bar_dismiss_timeout"]').prop('disabled', false);
984 } else {
985 $('input[name="sticky_bar_dismiss_timeout"]').prop('disabled', true);
986 }
987 }).trigger('change');
988 /**
989 * Reset evergreen countdown timers for all visitors
990 */
991
992 var resetAllButton = document.getElementById('hurrytResetAll');
993
994 if (resetAllButton) {
995 resetAllButton.addEventListener('click', function (e) {
996 e.preventDefault();
997
998 var _confirm = confirm('Are you sure?');
999
1000 if (_confirm) {
1001 window.location.href = resetAllButton.getAttribute('data-url');
1002 }
1003 });
1004 } // Failed to remove? retry with default options.
1005
1006
1007 var resetCurrentButton = document.getElementById('hurrytResetCurrent');
1008
1009 if (resetCurrentButton) {
1010 resetCurrentButton.addEventListener('click', function (e) {
1011 e.preventDefault();
1012 var options = {};
1013
1014 if (hurrytimer_ajax_object.COOKIEPATH) {
1015 options.path = hurrytimer_ajax_object.COOKIEPATH;
1016 }
1017
1018 if (hurrytimer_ajax_object.COOKIE_DOMAIN) {
1019 options.domain = hurrytimer_ajax_object.COOKIE_DOMAIN;
1020 }
1021
1022 var campaignCookieName = resetCurrentButton.getAttribute('data-cookie');
1023 Cookies.remove(campaignCookieName, options); // Failed to remove? retry with default options.
1024
1025 if (Cookies.get(campaignCookieName)) {
1026 Cookies.remove(campaignCookieName);
1027 }
1028
1029 Cookies.remove("_ht_CDT-".concat(resetCurrentButton.getAttribute('data-id'), "_dismissed"));
1030 window.location.href = resetCurrentButton.getAttribute('data-url');
1031 });
1032 }
1033
1034 var resetAllEvergreenCampaignsButtons = document.querySelectorAll('.hurrytResetAllEvergreenCampaigns');
1035
1036 if (resetAllEvergreenCampaignsButtons) {
1037 var _iterator = _createForOfIteratorHelper(resetAllEvergreenCampaignsButtons),
1038 _step;
1039
1040 try {
1041 var _loop = function _loop() {
1042 var button = _step.value;
1043 button.addEventListener('click', function (e) {
1044 e.preventDefault();
1045
1046 if (confirm('Are you sure?')) {
1047 var cookies = Cookies.get();
1048 var options = {};
1049
1050 if (hurrytimer_ajax_object.COOKIEPATH) {
1051 options.path = hurrytimer_ajax_object.COOKIEPATH;
1052 }
1053
1054 if (hurrytimer_ajax_object.COOKIE_DOMAIN) {
1055 options.domain = hurrytimer_ajax_object.COOKIE_DOMAIN;
1056 }
1057
1058 for (var name in cookies) {
1059 if (name.startsWith(button.getAttribute('data-cookie-prefix'))) {
1060 Cookies.remove(name, options);
1061
1062 if (Cookies.get(name)) {
1063 Cookies.remove(name);
1064 }
1065 }
1066 }
1067
1068 window.location.href = button.getAttribute('data-url');
1069 }
1070 });
1071 };
1072
1073 for (_iterator.s(); !(_step = _iterator.n()).done;) {
1074 _loop();
1075 }
1076 } catch (err) {
1077 _iterator.e(err);
1078 } finally {
1079 _iterator.f();
1080 }
1081 }
1082
1083 var recurringFrequencyElement = document.getElementById('hurrytRecurringFrequency');
1084 var recurringIntervalElement = document.getElementById('hurrytRecurringInterval');
1085
1086 if (recurringFrequencyElement) {
1087 recurringFrequencyElement.onchange = function (e) {
1088 return toggleRecurringDuration(e.target.value);
1089 };
1090
1091 toggleRecurringDuration(recurringFrequencyElement.value);
1092 }
1093
1094 function toggleRecurringDuration(value) {
1095 var monthsInputElement = document.getElementById('hurrytRecurringMonths');
1096 var daysInputElement = document.getElementById('hurrytRecurringDays');
1097 var hoursInputElement = document.getElementById('hurrytRecurringHours');
1098 var minutesInputElement = document.getElementById('hurrytRecurringMinutes');
1099 var secondsInputElement = document.getElementById('hurrytRecurringSeconds');
1100 var monthsDayTypeElement = document.getElementById('hurrytRecurMonthlyDayType');
1101
1102 if (value !== 'weekly' && $('input[name="recurring_days[]"]:checked').length < 7) {
1103 $('#hurrytimer-recurring-unselected-days-action').show();
1104 } else {
1105 $('#hurrytimer-recurring-unselected-days-action').hide();
1106 }
1107
1108 if (value !== 'monthly') {
1109 document.getElementById('hurrytRecurDaysList').classList.remove('hidden');
1110 document.getElementById('hurrytRecurDuration').classList.remove('hidden');
1111 monthsDayTypeElement.classList.add('hidden');
1112 }
1113
1114 switch (value) {
1115 case 'minutely':
1116 daysInputElement.value = 0;
1117 hoursInputElement.value = 0;
1118 hoursInputElement.parentNode.classList.add('hidden');
1119 daysInputElement.parentNode.classList.add('hidden');
1120 break;
1121
1122 case 'hourly':
1123 daysInputElement.value = 0;
1124 daysInputElement.parentNode.classList.add('hidden');
1125 hoursInputElement.parentNode.classList.remove('hidden');
1126 break;
1127
1128 case 'daily':
1129 case 'weekly':
1130 daysInputElement.parentNode.classList.remove('hidden');
1131 hoursInputElement.parentNode.classList.remove('hidden');
1132 break;
1133
1134 case 'monthly':
1135 daysInputElement.parentNode.classList.remove('hidden');
1136 hoursInputElement.parentNode.classList.remove('hidden');
1137 document.getElementById('hurrytRecurDaysList').classList.add('hidden');
1138 document.getElementById('hurrytRecurDuration').classList.add('hidden');
1139 monthsDayTypeElement.classList.remove('hidden');
1140 break;
1141
1142 default:
1143 break;
1144 }
1145 }
1146
1147 $('body').on('click', '.hurryt-add-wc-condition-group', function () {
1148 var _self = $(this);
1149
1150 _self.prop('disabled', true);
1151
1152 _self.next('.spinner').addClass('is-active');
1153
1154 $.get(hurrytimer_ajax_object.ajax_url, {
1155 action: 'add_wc_condition_group',
1156 nonce: hurrytimer_ajax_object.ajax_nonce
1157 }, function (html) {
1158 _self.before(html);
1159 }).always(function () {
1160 _self.prop('disabled', false);
1161
1162 _self.next('.spinner').removeClass('is-active');
1163 });
1164 });
1165 $('body').on('click', '.hurryt-add-wc-condition', function () {
1166 var _self = $(this);
1167
1168 _self.prop('disabled', true);
1169
1170 $.get(hurrytimer_ajax_object.ajax_url, {
1171 action: 'add_wc_condition',
1172 nonce: hurrytimer_ajax_object.ajax_nonce,
1173 group_id: $(this).closest('.hurryt-wc-condition-group').data('group-id')
1174 }, function (html) {
1175 _self.parent().after(html);
1176 }).always(function () {
1177 _self.prop('disabled', false);
1178 });
1179 });
1180 $('body').on('click', '.hurryt-delete-wc-condition', function () {
1181 var _self = $(this);
1182
1183 if (_self.closest('.hurryt-wc-condition-group').find('.hurryt-wc-condition').length === 1) {
1184 _self.closest('.hurryt-wc-condition-group').remove();
1185 } else {
1186 $(this).parent().remove();
1187 }
1188 });
1189 $('body').on('change', '.hurryt-wc-condition-key', function () {
1190 var _self = $(this);
1191
1192 var $value = _self.parent().find('.hurryt-wc-condition-value');
1193
1194 var $operator = _self.parent().find('.hurryt-wc-condition-operator');
1195
1196 $value.prop('disabled', true);
1197 $operator.prop('disabled', true);
1198 $.get(hurrytimer_ajax_object.ajax_url, {
1199 action: 'load_wc_condition',
1200 nonce: hurrytimer_ajax_object.ajax_nonce,
1201 condition_key: _self.val(),
1202 group_id: _self.closest('.hurryt-wc-condition-group').data('group-id')
1203 }, function (html) {
1204 _self.parent().replaceWith(html);
1205 }, 'html').always(function () {
1206 $value.prop('disabled', false);
1207 $operator.prop('disabled', false);
1208 });
1209 }); // open headline tab
1210
1211 $(document).on('click', '.hurryt-open-hl-tab', function (e) {
1212 e.preventDefault();
1213 var $tabs = $('.hurrytimer-tabbar li');
1214 $tabs.removeClass('active');
1215 $tabs.last().addClass('active');
1216 $('.hurrytimer-tabcontent').removeClass('active');
1217 $('#hurrytimer-tabcontent-styling').addClass('active');
1218 $('.hurrytimer-style-control-group').removeClass('active');
1219 $('.hurryt-subtab-hl').addClass('active');
1220 $('#hurryt-headline').focus();
1221 }); // Dismiss the Leave review notice if user clicked the "Already done!" link.
1222
1223 $(document).on('click', '#hurryt-dismiss-review-notice', function () {
1224 $(this).closest('.notice').remove();
1225 Cookies.set('hurryt_leave_review_dismissed', '1', {
1226 expires: 180
1227 });
1228 $.post(hurrytimer_ajax_object.ajax_url, {
1229 action: 'hurryt_dismiss_leave_review_notice',
1230 nonce: hurrytimer_ajax_object.ajax_nonce
1231 });
1232 }); // Dismiss the Leave review notice if user clicked the "Remind me later!" button.
1233
1234 $(document).on('click', '#hurryt-remind-review-notice', function () {
1235 $(this).closest('.notice').remove();
1236 Cookies.set('hurryt_leave_review_remind', '1', {
1237 expires: 1
1238 });
1239 $.post(hurrytimer_ajax_object.ajax_url, {
1240 action: 'hurryt_remind_leave_review_notice',
1241 nonce: hurrytimer_ajax_object.ajax_nonce
1242 });
1243 }); // removeIf(pro)
1244
1245 $(document).on('click', '#hurrytUserSessionWrap', function () {
1246 $('#hurrytUserSessionUpgradeNotice').removeClass('hidden');
1247 }); // endRemoveIf(pro)
1248
1249 $(document).on('click', '#hurryt-dismiss-headline-moved-notice', function () {
1250 $(this).parent().remove();
1251 Cookies.set('hurryt_headline_moved_notice_dismissed', '1', {
1252 expires: 365
1253 });
1254 $.post(hurrytimer_ajax_object.ajax_url, {
1255 action: 'hurryt_dismiss_headline_moved_notice',
1256 nonce: hurrytimer_ajax_object.ajax_nonce
1257 });
1258 });
1259 $('input[name="recurring_days[]"]').on('change', function () {
1260 var selected = $('input[name="recurring_days[]"]:checked').length;
1261
1262 if (selected === 7) {
1263 $('#hurrytimer-recurring-unselected-days-action').hide();
1264 } else if ($('#hurrytRecurringFrequency').val() !== 'weekly') {
1265 $('#hurrytimer-recurring-unselected-days-action').show();
1266 }
1267 }).change();
1268 })(jQuery);
1269 //# sourceMappingURL=admin.js.map
1270