PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.7
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.7
4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 4.2.1 All 138 releases
learnpress / assets / js / dist / utils.js

utils.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.1.7, at assets/js/dist/utils.js

1,885 lines 49.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (function() { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "./assets/src/js/utils/cookies.js":
5 /*!****************************************!*\
6 !*** ./assets/src/js/utils/cookies.js ***!
7 \****************************************/
8 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
9
10 "use strict";
11 __webpack_require__.r(__webpack_exports__);
12 const Cookies = {
13 get: (name, def, global) => {
14 let ret;
15
16 if (global) {
17 ret = wpCookies.get(name);
18 } else {
19 let ck = wpCookies.get('LP');
20
21 if (ck) {
22 ck = JSON.parse(ck);
23 ret = name ? ck[name] : ck;
24 }
25 }
26
27 if (!ret && ret !== def) {
28 ret = def;
29 }
30
31 return ret;
32 },
33
34 set(name, value, expires, path, domain, secure) {
35 if (arguments.length > 2) {
36 wpCookies.set(name, value, expires, path, domain, secure);
37 } else if (arguments.length == 2) {
38 let ck = wpCookies.get('LP');
39
40 if (ck) {
41 ck = JSON.parse(ck);
42 } else {
43 ck = {};
44 }
45
46 ck[name] = value;
47 wpCookies.set('LP', JSON.stringify(ck), '', '/');
48 } else {
49 wpCookies.set('LP', JSON.stringify(name), '', '/');
50 }
51 },
52
53 remove(name) {
54 const allCookies = Cookies.get();
55 const reg = new RegExp(name, 'g');
56 const newCookies = {};
57 const useRegExp = name.match(/\*/);
58
59 for (const i in allCookies) {
60 if (useRegExp) {
61 if (!i.match(reg)) {
62 newCookies[i] = allCookies[i];
63 }
64 } else if (name != i) {
65 newCookies[i] = allCookies[i];
66 }
67 }
68
69 Cookies.set(newCookies);
70 }
71
72 };
73 /* harmony default export */ __webpack_exports__["default"] = (Cookies);
74
75 /***/ }),
76
77 /***/ "./assets/src/js/utils/event-callback.js":
78 /*!***********************************************!*\
79 !*** ./assets/src/js/utils/event-callback.js ***!
80 \***********************************************/
81 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
82
83 "use strict";
84 __webpack_require__.r(__webpack_exports__);
85 /**
86 * Manage event callbacks.
87 Allow add/remove a callback function into custom event of an object.
88 *
89 * @class
90 * @param self
91 */
92 const Event_Callback = function Event_Callback(self) {
93 const callbacks = {};
94 const $ = window.jQuery;
95
96 this.on = function (event, callback) {
97 let namespaces = event.split('.'),
98 namespace = '';
99
100 if (namespaces.length > 1) {
101 event = namespaces[0];
102 namespace = namespaces[1];
103 }
104
105 if (!callbacks[event]) {
106 callbacks[event] = [[], {}];
107 }
108
109 if (namespace) {
110 if (!callbacks[event][1][namespace]) {
111 callbacks[event][1][namespace] = [];
112 }
113
114 callbacks[event][1][namespace].push(callback);
115 } else {
116 callbacks[event][0].push(callback);
117 }
118
119 return self;
120 };
121
122 this.off = function (event, callback) {
123 let namespaces = event.split('.'),
124 namespace = '';
125
126 if (namespaces.length > 1) {
127 event = namespaces[0];
128 namespace = namespaces[1];
129 }
130
131 if (!callbacks[event]) {
132 return self;
133 }
134
135 let at = -1;
136
137 if (!namespace) {
138 if (typeof callback === 'function') {
139 at = callbacks[event][0].indexOf(callback);
140
141 if (at < 0) {
142 return self;
143 }
144
145 callbacks[event][0].splice(at, 1);
146 } else {
147 callbacks[event][0] = [];
148 }
149 } else {
150 if (!callbacks[event][1][namespace]) {
151 return self;
152 }
153
154 if (typeof callback === 'function') {
155 at = callbacks[event][1][namespace].indexOf(callback);
156
157 if (at < 0) {
158 return self;
159 }
160
161 callbacks[event][1][namespace].splice(at, 1);
162 } else {
163 callbacks[event][1][namespace] = [];
164 }
165 }
166
167 return self;
168 };
169
170 this.callEvent = function (event, callbackArgs) {
171 if (!callbacks[event]) {
172 return;
173 }
174
175 if (callbacks[event][0]) {
176 for (var i = 0; i < callbacks[event][0].length; i++) {
177 typeof callbacks[event][0][i] === 'function' && callbacks[event][i][0].apply(self, callbackArgs);
178 }
179 }
180
181 if (callbacks[event][1]) {
182 for (var i in callbacks[event][1]) {
183 for (let j = 0; j < callbacks[event][1][i].length; j++) {
184 typeof callbacks[event][1][i][j] === 'function' && callbacks[event][1][i][j].apply(self, callbackArgs);
185 }
186 }
187 }
188 };
189 };
190
191 /* harmony default export */ __webpack_exports__["default"] = (Event_Callback);
192
193 /***/ }),
194
195 /***/ "./assets/src/js/utils/extend.js":
196 /*!***************************************!*\
197 !*** ./assets/src/js/utils/extend.js ***!
198 \***************************************/
199 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
200
201 "use strict";
202 __webpack_require__.r(__webpack_exports__);
203 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
204 /* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; }
205 /* harmony export */ });
206 /* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__() {
207 window.LP = window.LP || {};
208
209 if (typeof arguments[0] === 'string') {
210 LP[arguments[0]] = LP[arguments[0]] || {};
211 LP[arguments[0]] = jQuery.extend(LP[arguments[0]], arguments[1]);
212 } else {
213 LP = jQuery.extend(LP, arguments[0]);
214 }
215 }
216
217 /***/ }),
218
219 /***/ "./assets/src/js/utils/fn.js":
220 /*!***********************************!*\
221 !*** ./assets/src/js/utils/fn.js ***!
222 \***********************************/
223 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
224
225 "use strict";
226 __webpack_require__.r(__webpack_exports__);
227 /**
228 * Auto prepend `LP` prefix for jQuery fn plugin name.
229 *
230 * Create : $.fn.LP( 'PLUGIN_NAME', func) <=> $.fn.LP_PLUGIN_NAME
231 * Usage: $(selector).LP('PLUGIN_NAME') <=> $(selector).LP_PLUGIN_NAME()
232 *
233 * @version 3.2.6
234 */
235 const $ = window.jQuery;
236 let exp;
237
238 (function () {
239 if ($ === undefined) {
240 return;
241 }
242
243 $.fn.LP = exp = function (widget, fn) {
244 if (typeof fn === 'function') {
245 $.fn['LP_' + widget] = fn;
246 } else if (widget) {
247 const args = [];
248
249 if (arguments.length > 1) {
250 for (let i = 1; i < arguments.length; i++) {
251 args.push(arguments[i]);
252 }
253 }
254
255 return typeof $(this)['LP_' + widget] === 'function' ? $(this)['LP_' + widget].apply(this, args) : this;
256 }
257
258 return this;
259 };
260 })();
261
262 /* harmony default export */ __webpack_exports__["default"] = (exp);
263
264 /***/ }),
265
266 /***/ "./assets/src/js/utils/hook.js":
267 /*!*************************************!*\
268 !*** ./assets/src/js/utils/hook.js ***!
269 \*************************************/
270 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
271
272 "use strict";
273 __webpack_require__.r(__webpack_exports__);
274 const Hook = {
275 hooks: {
276 action: {},
277 filter: {}
278 },
279
280 addAction(action, callable, priority, tag) {
281 this.addHook('action', action, callable, priority, tag);
282 return this;
283 },
284
285 addFilter(action, callable, priority, tag) {
286 this.addHook('filter', action, callable, priority, tag);
287 return this;
288 },
289
290 doAction(action) {
291 return this.doHook('action', action, arguments);
292 },
293
294 applyFilters(action) {
295 return this.doHook('filter', action, arguments);
296 },
297
298 removeAction(action, tag) {
299 this.removeHook('action', action, tag);
300 return this;
301 },
302
303 removeFilter(action, priority, tag) {
304 this.removeHook('filter', action, priority, tag);
305 return this;
306 },
307
308 addHook(hookType, action, callable, priority, tag) {
309 if (undefined === this.hooks[hookType][action]) {
310 this.hooks[hookType][action] = [];
311 }
312
313 const hooks = this.hooks[hookType][action];
314
315 if (undefined === tag) {
316 tag = action + '_' + hooks.length;
317 }
318
319 this.hooks[hookType][action].push({
320 tag,
321 callable,
322 priority
323 });
324 return this;
325 },
326
327 doHook(hookType, action, args) {
328 args = Array.prototype.slice.call(args, 1);
329
330 if (undefined !== this.hooks[hookType][action]) {
331 let hooks = this.hooks[hookType][action],
332 hook;
333 hooks.sort(function (a, b) {
334 return a.priority - b.priority;
335 });
336
337 for (let i = 0; i < hooks.length; i++) {
338 hook = hooks[i].callable;
339
340 if (typeof hook !== 'function') {
341 hook = window[hook];
342 }
343
344 if ('action' === hookType) {
345 args[i] = hook.apply(null, args);
346 } else {
347 args[0] = hook.apply(null, args);
348 }
349 }
350 }
351
352 if ('filter' === hookType) {
353 return args[0];
354 }
355
356 return args;
357 },
358
359 removeHook(hookType, action, priority, tag) {
360 if (undefined !== this.hooks[hookType][action]) {
361 const hooks = this.hooks[hookType][action];
362
363 for (let i = hooks.length - 1; i >= 0; i--) {
364 if ((undefined === tag || tag === hooks[i].tag) && (undefined === priority || priority === hooks[i].priority)) {
365 hooks.splice(i, 1);
366 }
367 }
368 }
369
370 return this;
371 }
372
373 };
374 /* harmony default export */ __webpack_exports__["default"] = (Hook);
375
376 /***/ }),
377
378 /***/ "./assets/src/js/utils/iframe-submit.js":
379 /*!**********************************************!*\
380 !*** ./assets/src/js/utils/iframe-submit.js ***!
381 \**********************************************/
382 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
383
384 "use strict";
385 __webpack_require__.r(__webpack_exports__);
386 let iframeCounter = 1;
387 const $ = window.jQuery || jQuery;
388
389 const IframeSubmit = function (form) {
390 const iframeId = 'ajax-iframe-' + iframeCounter;
391 let $iframe = $('form[name="' + iframeId + '"]');
392
393 if (!$iframe.length) {
394 $iframe = $('<iframe />').appendTo(document.body).attr({
395 name: iframeId,
396 src: '#'
397 });
398 }
399
400 $(form).on('submit', function () {
401 const $form = $(form).clone().appendTo(document.body);
402 $form.attr('target', iframeId);
403 $form.find('#submit').remove();
404 return false;
405 });
406 iframeCounter++;
407 };
408
409 /* harmony default export */ __webpack_exports__["default"] = (IframeSubmit);
410
411 /***/ }),
412
413 /***/ "./assets/src/js/utils/jquery.plugins.js":
414 /*!***********************************************!*\
415 !*** ./assets/src/js/utils/jquery.plugins.js ***!
416 \***********************************************/
417 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
418
419 "use strict";
420 __webpack_require__.r(__webpack_exports__);
421 const $ = window.jQuery || jQuery;
422
423 const serializeJSON = function serializeJSON(path) {
424 const isInput = $(this).is('input') || $(this).is('select') || $(this).is('textarea');
425 let unIndexed = isInput ? $(this).serializeArray() : $(this).find('input, select, textarea').serializeArray(),
426 indexed = {},
427 validate = /(\[([a-zA-Z0-9_-]+)?\]?)/g,
428 arrayKeys = {},
429 end = false;
430 $.each(unIndexed, function () {
431 const that = this,
432 match = this.name.match(/^([0-9a-zA-Z_-]+)/);
433
434 if (!match) {
435 return;
436 }
437
438 let keys = this.name.match(validate),
439 objPath = "indexed['" + match[0] + "']";
440
441 if (keys) {
442 if (typeof indexed[match[0]] != 'object') {
443 indexed[match[0]] = {};
444 }
445
446 $.each(keys, function (i, prop) {
447 prop = prop.replace(/\]|\[/g, '');
448 let rawPath = objPath.replace(/'|\[|\]/g, ''),
449 objExp = '',
450 preObjPath = objPath;
451
452 if (prop == '') {
453 if (arrayKeys[rawPath] == undefined) {
454 arrayKeys[rawPath] = 0;
455 } else {
456 arrayKeys[rawPath]++;
457 }
458
459 objPath += "['" + arrayKeys[rawPath] + "']";
460 } else {
461 if (!isNaN(prop)) {
462 arrayKeys[rawPath] = prop;
463 }
464
465 objPath += "['" + prop + "']";
466 }
467
468 try {
469 if (i == keys.length - 1) {
470 objExp = objPath + '=that.value;';
471 end = true;
472 } else {
473 objExp = objPath + '={}';
474 end = false;
475 }
476
477 const evalString = '' + 'if( typeof ' + objPath + " == 'undefined'){" + objExp + ';' + '}else{' + 'if(end){' + 'if(typeof ' + preObjPath + "!='object'){" + preObjPath + '={};}' + objExp + '}' + '}';
478 eval(evalString);
479 } catch (e) {
480 console.log('Error:' + e + '\n' + objExp);
481 }
482 });
483 } else {
484 indexed[match[0]] = this.value;
485 }
486 });
487
488 if (path) {
489 path = "['" + path.replace('.', "']['") + "']";
490 const c = 'try{indexed = indexed' + path + '}catch(ex){console.log(c, ex);}';
491 eval(c);
492 }
493
494 return indexed;
495 };
496
497 const LP_Tooltip = options => {
498 options = $.extend({}, {
499 offset: [0, 0]
500 }, options || {});
501 return $.each(undefined, function () {
502 const $el = $(this),
503 content = $el.data('content');
504
505 if (!content || $el.data('LP_Tooltip') !== undefined) {
506 return;
507 }
508
509 let $tooltip = null;
510 $el.on('mouseenter', function (e) {
511 $tooltip = $('<div class="learn-press-tooltip-bubble"/>').html(content).appendTo($('body')).hide();
512 const position = $el.offset();
513
514 if (Array.isArray(options.offset)) {
515 const top = options.offset[1],
516 left = options.offset[0];
517
518 if ($.isNumeric(left)) {
519 position.left += left;
520 } else {}
521
522 if ($.isNumeric(top)) {
523 position.top += top;
524 } else {}
525 }
526
527 $tooltip.css({
528 top: position.top,
529 left: position.left
530 });
531 $tooltip.fadeIn();
532 });
533 $el.on('mouseleave', function (e) {
534 $tooltip && $tooltip.remove();
535 });
536 $el.data('tooltip', true);
537 });
538 };
539
540 const hasEvent = function hasEvent(name) {
541 const events = $(this).data('events');
542
543 if (typeof events.LP == 'undefined') {
544 return false;
545 }
546
547 for (i = 0; i < events.LP.length; i++) {
548 if (events.LP[i].namespace == name) {
549 return true;
550 }
551 }
552
553 return false;
554 };
555
556 const dataToJSON = function dataToJSON() {
557 const json = {};
558 $.each(this[0].attributes, function () {
559 const m = this.name.match(/^data-(.*)/);
560
561 if (m) {
562 json[m[1]] = this.value;
563 }
564 });
565 return json;
566 };
567
568 const rows = function rows() {
569 const h = $(this).height();
570 const lh = $(this).css('line-height').replace('px', '');
571 $(this).attr({
572 height: h,
573 'line-height': lh
574 });
575 return Math.floor(h / parseInt(lh));
576 };
577
578 const checkLines = function checkLines(p) {
579 return this.each(function () {
580 const $e = $(this),
581 rows = $e.rows();
582 p.call(this, rows);
583 });
584 };
585
586 const findNext = function findNext(selector) {
587 const $selector = $(selector),
588 $root = this.first(),
589 index = $selector.index($root),
590 $next = $selector.eq(index + 1);
591 return $next.length ? $next : false;
592 };
593
594 const findPrev = function findPrev(selector) {
595 const $selector = $(selector),
596 $root = this.first(),
597 index = $selector.index($root),
598 $prev = $selector.eq(index - 1);
599 return $prev.length ? $prev : false;
600 };
601
602 const progress = function progress(v) {
603 return this.each(function () {
604 const t = parseInt(v / 100 * 360),
605 timer = null,
606 $this = $(this);
607
608 if (t < 180) {
609 $this.find('.progress-circle').removeClass('gt-50');
610 } else {
611 $this.find('.progress-circle').addClass('gt-50');
612 }
613
614 $this.find('.fill').css({
615 transform: 'rotate(' + t + 'deg)'
616 });
617 });
618 };
619
620 $.fn.serializeJSON = serializeJSON;
621 $.fn.LP_Tooltip = LP_Tooltip;
622 $.fn.hasEvent = hasEvent;
623 $.fn.dataToJSON = dataToJSON;
624 $.fn.rows = rows;
625 $.fn.checkLines = checkLines;
626 $.fn.findNext = findNext;
627 $.fn.findPrev = findPrev;
628 $.fn.progress = progress;
629 /* harmony default export */ __webpack_exports__["default"] = ({
630 serializeJSON,
631 LP_Tooltip,
632 hasEvent,
633 dataToJSON,
634 rows,
635 checkLines,
636 findNext,
637 findPrev,
638 progress
639 });
640
641 /***/ }),
642
643 /***/ "./assets/src/js/utils/local-storage.js":
644 /*!**********************************************!*\
645 !*** ./assets/src/js/utils/local-storage.js ***!
646 \**********************************************/
647 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
648
649 "use strict";
650 __webpack_require__.r(__webpack_exports__);
651 const _localStorage = {
652 __key: 'LP',
653
654 set(name, value) {
655 const data = _localStorage.get();
656
657 const {
658 set
659 } = lodash;
660 set(data, name, value);
661 localStorage.setItem(_localStorage.__key, JSON.stringify(data));
662 },
663
664 get(name, def) {
665 const data = JSON.parse(localStorage.getItem(_localStorage.__key) || '{}');
666 const {
667 get
668 } = lodash;
669 const value = get(data, name);
670 return !name ? data : value !== undefined ? value : def;
671 },
672
673 exists(name) {
674 const data = _localStorage.get(); // return data.hasOwnProperty( name );
675
676
677 return name in data;
678 },
679
680 remove(name) {
681 const data = _localStorage.get();
682
683 const newData = lodash.omit(data, name);
684
685 _localStorage.__set(newData);
686 },
687
688 __get() {
689 return localStorage.getItem(_localStorage.__key);
690 },
691
692 __set(data) {
693 localStorage.setItem(_localStorage.__key, JSON.stringify(data || '{}'));
694 }
695
696 };
697 /* harmony default export */ __webpack_exports__["default"] = (_localStorage);
698
699 /***/ }),
700
701 /***/ "./assets/src/js/utils/message-box.js":
702 /*!********************************************!*\
703 !*** ./assets/src/js/utils/message-box.js ***!
704 \********************************************/
705 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
706
707 "use strict";
708 __webpack_require__.r(__webpack_exports__);
709 const $ = window.jQuery;
710 const MessageBox = {
711 $block: null,
712 $window: null,
713 events: {},
714 instances: [],
715 instance: null,
716
717 quickConfirm(elem, args) {
718 const $e = $(elem);
719 $('[learn-press-quick-confirm]').each(function () {
720 let $ins;
721 ($ins = $(this).data('quick-confirm')) && (console.log($ins), $ins.destroy());
722 });
723 !$e.attr('learn-press-quick-confirm') && $e.attr('learn-press-quick-confirm', 'true').data('quick-confirm', new function (elem, args) {
724 var $elem = $(elem),
725 $div = $('<span class="learn-press-quick-confirm"></span>').insertAfter($elem),
726 //($(document.body)),
727 offset = $(elem).position() || {
728 left: 0,
729 top: 0
730 },
731 timerOut = null,
732 timerHide = null,
733 n = 3,
734 hide = function () {
735 $div.fadeOut('fast', function () {
736 $(this).remove();
737 $div.parent().css('position', '');
738 });
739 $elem.removeAttr('learn-press-quick-confirm').data('quick-confirm', undefined);
740 stop();
741 },
742 stop = function () {
743 timerHide && clearInterval(timerHide);
744 timerOut && clearInterval(timerOut);
745 },
746 start = function () {
747 timerOut = setInterval(function () {
748 if (--n == 0) {
749 hide.call($div[0]);
750 typeof args.onCancel === 'function' && args.onCancel(args.data);
751 stop();
752 }
753
754 $div.find('span').html(' (' + n + ')');
755 }, 1000);
756 timerHide = setInterval(function () {
757 if (!$elem.is(':visible') || $elem.css('visibility') == 'hidden') {
758 stop();
759 $div.remove();
760 $div.parent().css('position', '');
761 typeof args.onCancel === 'function' && args.onCancel(args.data);
762 }
763 }, 350);
764 };
765
766 args = $.extend({
767 message: '',
768 data: null,
769 onOk: null,
770 onCancel: null,
771 offset: {
772 top: 0,
773 left: 0
774 }
775 }, args || {});
776 $div.html(args.message || $elem.attr('data-confirm-remove') || 'Are you sure?').append('<span> (' + n + ')</span>').css({});
777 $div.click(function () {
778 typeof args.onOk === 'function' && args.onOk(args.data);
779 hide();
780 }).hover(function () {
781 stop();
782 }, function () {
783 start();
784 }); //$div.parent().css('position', 'relative');
785
786 $div.css({
787 left: offset.left + $elem.outerWidth() - $div.outerWidth() + args.offset.left,
788 top: offset.top + $elem.outerHeight() + args.offset.top + 5
789 }).hide().fadeIn('fast');
790 start();
791
792 this.destroy = function () {
793 $div.remove();
794 $elem.removeAttr('learn-press-quick-confirm').data('quick-confirm', undefined);
795 stop();
796 };
797 }(elem, args));
798 },
799
800 show(message, args) {
801 //this.hide();
802 $.proxy(function () {
803 args = $.extend({
804 title: '',
805 buttons: '',
806 events: false,
807 autohide: false,
808 message,
809 data: false,
810 id: LP.uniqueId(),
811 onHide: null
812 }, args || {});
813 this.instances.push(args);
814 this.instance = args;
815 const $doc = $(document),
816 $body = $(document.body);
817
818 if (!this.$block) {
819 this.$block = $('<div id="learn-press-message-box-block"></div>').appendTo($body);
820 }
821
822 if (!this.$window) {
823 this.$window = $('<div id="learn-press-message-box-window"><div id="message-box-wrap"></div> </div>').insertAfter(this.$block);
824 this.$window.click(function () {});
825 } //this.events = args.events || {};
826
827
828 this._createWindow(message, args.title, args.buttons);
829
830 this.$block.show();
831 this.$window.show().attr('instance', args.id);
832 $(window).bind('resize.message-box', $.proxy(this.update, this)).bind('scroll.message-box', $.proxy(this.update, this));
833 this.update(true);
834
835 if (args.autohide) {
836 setTimeout(function () {
837 LP.MessageBox.hide();
838 typeof args.onHide === 'function' && args.onHide.call(LP.MessageBox, args);
839 }, args.autohide);
840 }
841 }, this)();
842 },
843
844 blockUI(message) {
845 message = (message !== false ? message ? message : 'Wait a moment' : '') + '<div class="message-box-animation"></div>';
846 this.show(message);
847 },
848
849 hide(delay, instance) {
850 if (instance) {
851 this._removeInstance(instance.id);
852 } else if (this.instance) {
853 this._removeInstance(this.instance.id);
854 }
855
856 if (this.instances.length === 0) {
857 if (this.$block) {
858 this.$block.hide();
859 }
860
861 if (this.$window) {
862 this.$window.hide();
863 }
864
865 $(window).unbind('resize.message-box', this.update).unbind('scroll.message-box', this.update);
866 } else if (this.instance) {
867 this._createWindow(this.instance.message, this.instance.title, this.instance.buttons);
868 }
869 },
870
871 update(force) {
872 let that = this,
873 $wrap = this.$window.find('#message-box-wrap'),
874 timer = $wrap.data('timer'),
875 _update = function () {
876 LP.Hook.doAction('learn_press_message_box_before_resize', that);
877 let $content = $wrap.find('.message-box-content').css('height', '').css('overflow', 'hidden'),
878 width = $wrap.outerWidth(),
879 height = $wrap.outerHeight(),
880 contentHeight = $content.height(),
881 windowHeight = $(window).height(),
882 top = $wrap.offset().top;
883
884 if (contentHeight > windowHeight - 50) {
885 $content.css({
886 height: windowHeight - 25
887 });
888 height = $wrap.outerHeight();
889 } else {
890 $content.css('height', '').css('overflow', '');
891 }
892
893 $wrap.css({
894 marginTop: ($(window).height() - height) / 2
895 });
896 LP.Hook.doAction('learn_press_message_box_resize', height, that);
897 };
898
899 if (force) {
900 _update();
901 }
902
903 timer && clearTimeout(timer);
904 timer = setTimeout(_update, 250);
905 },
906
907 _removeInstance(id) {
908 for (let i = 0; i < this.instances.length; i++) {
909 if (this.instances[i].id === id) {
910 this.instances.splice(i, 1);
911 const len = this.instances.length;
912
913 if (len) {
914 this.instance = this.instances[len - 1];
915 this.$window.attr('instance', this.instance.id);
916 } else {
917 this.instance = false;
918 this.$window.removeAttr('instance');
919 }
920
921 break;
922 }
923 }
924 },
925
926 _getInstance(id) {
927 for (let i = 0; i < this.instances.length; i++) {
928 if (this.instances[i].id === id) {
929 return this.instances[i];
930 }
931 }
932 },
933
934 _createWindow(message, title, buttons) {
935 const $wrap = this.$window.find('#message-box-wrap').html('');
936
937 if (title) {
938 $wrap.append('<h3 class="message-box-title">' + title + '</h3>');
939 }
940
941 $wrap.append($('<div class="message-box-content"></div>').html(message));
942
943 if (buttons) {
944 const $buttons = $('<div class="message-box-buttons"></div>');
945
946 switch (buttons) {
947 case 'yesNo':
948 $buttons.append(this._createButton(LP_Settings.localize.button_yes, 'yes'));
949 $buttons.append(this._createButton(LP_Settings.localize.button_no, 'no'));
950 break;
951
952 case 'okCancel':
953 $buttons.append(this._createButton(LP_Settings.localize.button_ok, 'ok'));
954 $buttons.append(this._createButton(LP_Settings.localize.button_cancel, 'cancel'));
955 break;
956
957 default:
958 $buttons.append(this._createButton(LP_Settings.localize.button_ok, 'ok'));
959 }
960
961 $wrap.append($buttons);
962 }
963 },
964
965 _createButton(title, type) {
966 const $button = $('<button type="button" class="button message-box-button message-box-button-' + type + '">' + title + '</button>'),
967 callback = 'on' + (type.substr(0, 1).toUpperCase() + type.substr(1));
968 $button.data('callback', callback).click(function () {
969 const instance = $(this).data('instance'),
970 callback = instance.events[$(this).data('callback')];
971
972 if ($.type(callback) === 'function') {
973 if (callback.apply(LP.MessageBox, [instance]) === false) {// return;
974 } else {
975 LP.MessageBox.hide(null, instance);
976 }
977 } else {
978 LP.MessageBox.hide(null, instance);
979 }
980 }).data('instance', this.instance);
981 return $button;
982 }
983
984 };
985 /* harmony default export */ __webpack_exports__["default"] = (MessageBox);
986
987 /***/ }),
988
989 /***/ "./assets/src/js/utils/quick-tip.js":
990 /*!******************************************!*\
991 !*** ./assets/src/js/utils/quick-tip.js ***!
992 \******************************************/
993 /***/ (function() {
994
995 (function ($) {
996 function QuickTip(el, options) {
997 const $el = $(el),
998 uniId = $el.attr('data-id') || LP.uniqueId();
999 options = $.extend({
1000 event: 'hover',
1001 autoClose: true,
1002 single: true,
1003 closeInterval: 1000,
1004 arrowOffset: null,
1005 tipClass: ''
1006 }, options, $el.data());
1007 $el.attr('data-id', uniId);
1008 let content = $el.attr('data-content-tip') || $el.html(),
1009 $tip = $('<div class="learn-press-tip-floating">' + content + '</div>'),
1010 t = null,
1011 closeInterval = 0,
1012 useData = false,
1013 arrowOffset = options.arrowOffset === 'el' ? $el.outerWidth() / 2 : 8,
1014 $content = $('#__' + uniId);
1015
1016 if ($content.length === 0) {
1017 $(document.body).append($('<div />').attr('id', '__' + uniId).html(content).css('display', 'none'));
1018 }
1019
1020 content = $content.html();
1021 $tip.addClass(options.tipClass);
1022 $el.data('content-tip', content);
1023
1024 if ($el.attr('data-content-tip')) {
1025 //$el.removeAttr('data-content-tip');
1026 useData = true;
1027 }
1028
1029 closeInterval = options.closeInterval;
1030
1031 if (options.autoClose === false) {
1032 $tip.append('<a class="close"></a>');
1033 $tip.on('click', '.close', function () {
1034 close();
1035 });
1036 }
1037
1038 function show() {
1039 if (t) {
1040 clearTimeout(t);
1041 return;
1042 }
1043
1044 if (options.single) {
1045 $('.learn-press-tip').not($el).LP('QuickTip', 'close');
1046 }
1047
1048 $tip.appendTo(document.body);
1049 const pos = $el.offset();
1050 $tip.css({
1051 top: pos.top - $tip.outerHeight() - 8,
1052 left: pos.left - $tip.outerWidth() / 2 + arrowOffset
1053 });
1054 }
1055
1056 function hide() {
1057 t && clearTimeout(t);
1058 t = setTimeout(function () {
1059 $tip.detach();
1060 t = null;
1061 }, closeInterval);
1062 }
1063
1064 function close() {
1065 closeInterval = 0;
1066 hide();
1067 closeInterval = options.closeInterval;
1068 }
1069
1070 function open() {
1071 show();
1072 }
1073
1074 if (!useData) {
1075 $el.html('');
1076 }
1077
1078 if (options.event === 'click') {
1079 $el.on('click', function (e) {
1080 e.stopPropagation();
1081 show();
1082 });
1083 }
1084
1085 $(document).on('learn-press/close-all-quick-tip', function () {
1086 close();
1087 });
1088 $el.hover(function (e) {
1089 e.stopPropagation();
1090
1091 if (options.event !== 'click') {
1092 show();
1093 }
1094 }, function (e) {
1095 e.stopPropagation();
1096
1097 if (options.autoClose) {
1098 hide();
1099 }
1100 }).addClass('ready');
1101 return {
1102 close,
1103 open
1104 };
1105 }
1106
1107 $.fn.LP('QuickTip', function (options) {
1108 return $.each(this, function () {
1109 let $tip = $(this).data('quick-tip');
1110
1111 if (!$tip) {
1112 $tip = new QuickTip(this, options);
1113 $(this).data('quick-tip', $tip);
1114 }
1115
1116 if (typeof options === 'string') {
1117 $tip[options] && $tip[options].apply($tip);
1118 }
1119 });
1120 });
1121 })(jQuery);
1122
1123 /***/ }),
1124
1125 /***/ "./assets/src/js/utils/show-password.js":
1126 /*!**********************************************!*\
1127 !*** ./assets/src/js/utils/show-password.js ***!
1128 \**********************************************/
1129 /***/ (function() {
1130
1131 const $ = jQuery;
1132 $(function () {
1133 $('.form-field input[type="password"]').wrap('<span class="lp-password-input"></span>');
1134 $('.lp-password-input').append('<span class="lp-show-password-input"></span>');
1135 $('.lp-show-password-input').on('click', function () {
1136 $(this).toggleClass('display-password');
1137
1138 if ($(this).hasClass('display-password')) {
1139 $(this).siblings(['input[type="password"]']).prop('type', 'text');
1140 } else {
1141 $(this).siblings('input[type="text"]').prop('type', 'password');
1142 }
1143 });
1144 });
1145
1146 /***/ })
1147
1148 /******/ });
1149 /************************************************************************/
1150 /******/ // The module cache
1151 /******/ var __webpack_module_cache__ = {};
1152 /******/
1153 /******/ // The require function
1154 /******/ function __webpack_require__(moduleId) {
1155 /******/ // Check if module is in cache
1156 /******/ var cachedModule = __webpack_module_cache__[moduleId];
1157 /******/ if (cachedModule !== undefined) {
1158 /******/ return cachedModule.exports;
1159 /******/ }
1160 /******/ // Create a new module (and put it into the cache)
1161 /******/ var module = __webpack_module_cache__[moduleId] = {
1162 /******/ // no module.id needed
1163 /******/ // no module.loaded needed
1164 /******/ exports: {}
1165 /******/ };
1166 /******/
1167 /******/ // Execute the module function
1168 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
1169 /******/
1170 /******/ // Return the exports of the module
1171 /******/ return module.exports;
1172 /******/ }
1173 /******/
1174 /************************************************************************/
1175 /******/ /* webpack/runtime/compat get default export */
1176 /******/ !function() {
1177 /******/ // getDefaultExport function for compatibility with non-harmony modules
1178 /******/ __webpack_require__.n = function(module) {
1179 /******/ var getter = module && module.__esModule ?
1180 /******/ function() { return module['default']; } :
1181 /******/ function() { return module; };
1182 /******/ __webpack_require__.d(getter, { a: getter });
1183 /******/ return getter;
1184 /******/ };
1185 /******/ }();
1186 /******/
1187 /******/ /* webpack/runtime/define property getters */
1188 /******/ !function() {
1189 /******/ // define getter functions for harmony exports
1190 /******/ __webpack_require__.d = function(exports, definition) {
1191 /******/ for(var key in definition) {
1192 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
1193 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
1194 /******/ }
1195 /******/ }
1196 /******/ };
1197 /******/ }();
1198 /******/
1199 /******/ /* webpack/runtime/hasOwnProperty shorthand */
1200 /******/ !function() {
1201 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
1202 /******/ }();
1203 /******/
1204 /******/ /* webpack/runtime/make namespace object */
1205 /******/ !function() {
1206 /******/ // define __esModule on exports
1207 /******/ __webpack_require__.r = function(exports) {
1208 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
1209 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1210 /******/ }
1211 /******/ Object.defineProperty(exports, '__esModule', { value: true });
1212 /******/ };
1213 /******/ }();
1214 /******/
1215 /************************************************************************/
1216 var __webpack_exports__ = {};
1217 // This entry need to be wrapped in an IIFE because it need to be in strict mode.
1218 !function() {
1219 "use strict";
1220 /*!**************************************!*\
1221 !*** ./assets/src/js/utils/index.js ***!
1222 \**************************************/
1223 __webpack_require__.r(__webpack_exports__);
1224 /* harmony import */ var _extend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./extend */ "./assets/src/js/utils/extend.js");
1225 /* harmony import */ var _fn__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fn */ "./assets/src/js/utils/fn.js");
1226 /* harmony import */ var _quick_tip__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./quick-tip */ "./assets/src/js/utils/quick-tip.js");
1227 /* harmony import */ var _quick_tip__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_quick_tip__WEBPACK_IMPORTED_MODULE_2__);
1228 /* harmony import */ var _message_box__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message-box */ "./assets/src/js/utils/message-box.js");
1229 /* harmony import */ var _event_callback__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./event-callback */ "./assets/src/js/utils/event-callback.js");
1230 /* harmony import */ var _hook__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./hook */ "./assets/src/js/utils/hook.js");
1231 /* harmony import */ var _cookies__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./cookies */ "./assets/src/js/utils/cookies.js");
1232 /* harmony import */ var _local_storage__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./local-storage */ "./assets/src/js/utils/local-storage.js");
1233 /* harmony import */ var _jquery_plugins__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./jquery.plugins */ "./assets/src/js/utils/jquery.plugins.js");
1234 /* harmony import */ var _iframe_submit__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./iframe-submit */ "./assets/src/js/utils/iframe-submit.js");
1235 /* harmony import */ var _show_password__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./show-password */ "./assets/src/js/utils/show-password.js");
1236 /* harmony import */ var _show_password__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(_show_password__WEBPACK_IMPORTED_MODULE_10__);
1237 /**
1238 * Utility functions may use for both admin and frontend.
1239 *
1240 * @version 3.2.6
1241 */
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253 const $ = jQuery;
1254
1255 String.prototype.getQueryVar = function (name) {
1256 name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
1257 const regex = new RegExp('[\\?&]' + name + '=([^&#]*)'),
1258 results = regex.exec(this);
1259 return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
1260 };
1261
1262 String.prototype.addQueryVar = function (name, value) {
1263 let url = this,
1264 m = url.split('#');
1265 url = m[0];
1266
1267 if (name.match(/\[/)) {
1268 url += url.match(/\?/) ? '&' : '?';
1269 url += name + '=' + value;
1270 } else if (url.indexOf('&' + name + '=') != -1 || url.indexOf('?' + name + '=') != -1) {
1271 url = url.replace(new RegExp(name + '=([^&#]*)', 'g'), name + '=' + value);
1272 } else {
1273 url += url.match(/\?/) ? '&' : '?';
1274 url += name + '=' + value;
1275 }
1276
1277 return url + (m[1] ? '#' + m[1] : '');
1278 };
1279
1280 String.prototype.removeQueryVar = function (name) {
1281 let url = this;
1282 const m = url.split('#');
1283 url = m[0];
1284 name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
1285 const regex = new RegExp('[\\?&]' + name + '([\[][^=]*)?=([^&#]*)', 'g');
1286 url = url.replace(regex, '');
1287 return url + (m[1] ? '#' + m[1] : '');
1288 }; // if ( $.isEmptyObject( '' ) == false ) {
1289 // $.isEmptyObject = function( a ) {
1290 // let prop;
1291 // for ( prop in a ) {
1292 // if ( a.hasOwnProperty( prop ) ) {
1293 // return false;
1294 // }
1295 // }
1296 // return true;
1297 // };
1298 // }
1299
1300
1301 const _default = {
1302 Hook: _hook__WEBPACK_IMPORTED_MODULE_5__["default"],
1303
1304 setUrl(url, ember, title) {
1305 if (url) {
1306 history.pushState({}, title, url);
1307 LP.Hook.doAction('learn_press_set_location_url', url);
1308 }
1309 },
1310
1311 toggleGroupSection(el, target) {
1312 const $el = $(el),
1313 isHide = $el.hasClass('hide-if-js');
1314
1315 if (isHide) {
1316 $el.hide().removeClass('hide-if-js');
1317 }
1318
1319 $el.removeClass('hide-if-js').slideToggle(function () {
1320 const $this = $(this);
1321
1322 if ($this.is(':visible')) {
1323 $(target).addClass('toggle-on').removeClass('toggle-off');
1324 } else {
1325 $(target).addClass('toggle-off').removeClass('toggle-on');
1326 }
1327 });
1328 },
1329
1330 overflow(el, v) {
1331 const $el = $(el),
1332 overflow = $el.css('overflow');
1333
1334 if (v) {
1335 $el.css('overflow', v).data('overflow', overflow);
1336 } else {
1337 $el.css('overflow', $el.data('overflow'));
1338 }
1339 },
1340
1341 getUrl() {
1342 return window.location.href;
1343 },
1344
1345 addQueryVar(name, value, url) {
1346 return (url === undefined ? window.location.href : url).addQueryVar(name, value);
1347 },
1348
1349 removeQueryVar(name, url) {
1350 return (url === undefined ? window.location.href : url).removeQueryVar(name);
1351 },
1352
1353 reload(url) {
1354 if (!url) {
1355 url = window.location.href;
1356 }
1357
1358 window.location.href = url;
1359 },
1360
1361 parseResponse(response, type) {
1362 const m = response.match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
1363
1364 if (m) {
1365 response = m[1];
1366 }
1367
1368 return (type || 'json') === 'json' ? this.parseJSON(response) : response;
1369 },
1370
1371 parseJSON(data) {
1372 if (typeof data !== 'string') {
1373 return data;
1374 }
1375
1376 const m = String.raw({
1377 raw: data
1378 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
1379
1380 try {
1381 if (m) {
1382 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
1383 } else {
1384 data = JSON.parse(data);
1385 }
1386 } catch (e) {
1387 data = {};
1388 }
1389
1390 return data;
1391 },
1392
1393 ajax(args) {
1394 const type = args.type || 'post',
1395 dataType = args.dataType || 'json',
1396 data = args.action ? $.extend(args.data, {
1397 'lp-ajax': args.action
1398 }) : args.data,
1399 beforeSend = args.beforeSend || function () {},
1400 url = args.url || window.location.href; // console.debug( beforeSend );
1401
1402
1403 $.ajax({
1404 data,
1405 url,
1406 type,
1407 dataType: 'html',
1408 beforeSend: beforeSend.apply(null, args),
1409
1410 success(raw) {
1411 const response = LP.parseResponse(raw, dataType);
1412 typeof args.success === 'function' && args.success(response, raw);
1413 },
1414
1415 error() {
1416 typeof args.error === 'function' && args.error.apply(null, LP.funcArgs2Array());
1417 }
1418
1419 });
1420 },
1421
1422 doAjax(args) {
1423 const type = args.type || 'post',
1424 dataType = args.dataType || 'json',
1425 action = (args.prefix === undefined || 'learnpress_') + args.action,
1426 data = args.action ? $.extend(args.data, {
1427 action
1428 }) : args.data;
1429 $.ajax({
1430 data,
1431 url: args.url || window.location.href,
1432 type,
1433 dataType: 'html',
1434
1435 success(raw) {
1436 const response = LP.parseResponse(raw, dataType);
1437 typeof args.success === 'function' && args.success(response, raw);
1438 },
1439
1440 error() {
1441 typeof args.error === 'function' && args.error.apply(null, LP.funcArgs2Array());
1442 }
1443
1444 });
1445 },
1446
1447 funcArgs2Array(args) {
1448 const arr = [];
1449
1450 for (let i = 0; i < args.length; i++) {
1451 arr.push(args[i]);
1452 }
1453
1454 return arr;
1455 },
1456
1457 addFilter(action, callback) {
1458 const $doc = $(document),
1459 event = 'LP.' + action;
1460 $doc.on(event, callback);
1461 LP.log($doc.data('events'));
1462 return this;
1463 },
1464
1465 applyFilters() {
1466 const $doc = $(document),
1467 action = arguments[0],
1468 args = this.funcArgs2Array(arguments);
1469
1470 if ($doc.hasEvent(action)) {
1471 args[0] = 'LP.' + action;
1472 return $doc.triggerHandler.apply($doc, args);
1473 }
1474
1475 return args[1];
1476 },
1477
1478 addAction(action, callback) {
1479 return this.addFilter(action, callback);
1480 },
1481
1482 doAction() {
1483 const $doc = $(document),
1484 action = arguments[0],
1485 args = this.funcArgs2Array(arguments);
1486
1487 if ($doc.hasEvent(action)) {
1488 args[0] = 'LP.' + action;
1489 $doc.trigger.apply($doc, args);
1490 }
1491 },
1492
1493 toElement(element, args) {
1494 if ($(element).length === 0) {
1495 return;
1496 }
1497
1498 args = $.extend({
1499 delay: 300,
1500 duration: 'slow',
1501 offset: 50,
1502 container: null,
1503 callback: null,
1504 invisible: false
1505 }, args || {});
1506 let $container = $(args.container),
1507 rootTop = 0;
1508
1509 if ($container.length === 0) {
1510 $container = $('body, html');
1511 }
1512
1513 rootTop = $container.offset().top;
1514 const to = $(element).offset().top + $container.scrollTop() - rootTop - args.offset;
1515
1516 function isElementInView(element, fullyInView) {
1517 const pageTop = $container.scrollTop();
1518 const pageBottom = pageTop + $container.height();
1519 const elementTop = $(element).offset().top - $container.offset().top;
1520 const elementBottom = elementTop + $(element).height();
1521
1522 if (fullyInView === true) {
1523 return pageTop < elementTop && pageBottom > elementBottom;
1524 }
1525
1526 return elementTop <= pageBottom && elementBottom >= pageTop;
1527 }
1528
1529 if (args.invisible && isElementInView(element, true)) {
1530 return;
1531 }
1532
1533 $container.fadeIn(10).delay(args.delay).animate({
1534 scrollTop: to
1535 }, args.duration, args.callback);
1536 },
1537
1538 uniqueId(prefix, more_entropy) {
1539 if (typeof prefix === 'undefined') {
1540 prefix = '';
1541 }
1542
1543 let retId;
1544
1545 const formatSeed = function (seed, reqWidth) {
1546 seed = parseInt(seed, 10).toString(16); // to hex str
1547
1548 if (reqWidth < seed.length) {
1549 // so long we split
1550 return seed.slice(seed.length - reqWidth);
1551 }
1552
1553 if (reqWidth > seed.length) {
1554 // so short we pad
1555 return new Array(1 + (reqWidth - seed.length)).join('0') + seed;
1556 }
1557
1558 return seed;
1559 }; // BEGIN REDUNDANT
1560
1561
1562 if (!this.php_js) {
1563 this.php_js = {};
1564 } // END REDUNDANT
1565
1566
1567 if (!this.php_js.uniqidSeed) {
1568 // init seed with big random int
1569 this.php_js.uniqidSeed = Math.floor(Math.random() * 0x75bcd15);
1570 }
1571
1572 this.php_js.uniqidSeed++;
1573 retId = prefix; // start with prefix, add current milliseconds hex string
1574
1575 retId += formatSeed(parseInt(new Date().getTime() / 1000, 10), 8);
1576 retId += formatSeed(this.php_js.uniqidSeed, 5); // add seed hex string
1577
1578 if (more_entropy) {
1579 // for more entropy we add a float lower to 10
1580 retId += (Math.random() * 10).toFixed(8).toString();
1581 }
1582
1583 return retId;
1584 },
1585
1586 log() {
1587 //if (typeof LEARN_PRESS_DEBUG != 'undefined' && LEARN_PRESS_DEBUG && console) {
1588 for (let i = 0, n = arguments.length; i < n; i++) {
1589 console.log(arguments[i]);
1590 } //}
1591
1592 },
1593
1594 blockContent() {
1595 if ($('#learn-press-block-content').length === 0) {
1596 $(LP.template('learn-press-template-block-content', {})).appendTo($('body'));
1597 }
1598
1599 LP.hideMainScrollbar().addClass('block-content');
1600 $(document).trigger('learn_press_block_content');
1601 },
1602
1603 unblockContent() {
1604 setTimeout(function () {
1605 LP.showMainScrollbar().removeClass('block-content');
1606 $(document).trigger('learn_press_unblock_content');
1607 }, 350);
1608 },
1609
1610 hideMainScrollbar(el) {
1611 if (!el) {
1612 el = 'html, body';
1613 }
1614
1615 const $el = $(el);
1616 $el.each(function () {
1617 const $root = $(this),
1618 overflow = $root.css('overflow');
1619 $root.css('overflow', 'hidden').attr('overflow', overflow);
1620 });
1621 return $el;
1622 },
1623
1624 showMainScrollbar(el) {
1625 if (!el) {
1626 el = 'html, body';
1627 }
1628
1629 const $el = $(el);
1630 $el.each(function () {
1631 const $root = $(this),
1632 overflow = $root.attr('overflow');
1633 $root.css('overflow', overflow).removeAttr('overflow');
1634 });
1635 return $el;
1636 },
1637
1638 template: typeof _ !== 'undefined' ? _.memoize(function (id, data) {
1639 let compiled,
1640 options = {
1641 evaluate: /<#([\s\S]+?)#>/g,
1642 interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
1643 escape: /\{\{([^\}]+?)\}\}(?!\})/g,
1644 variable: 'data'
1645 };
1646
1647 const tmpl = function (data) {
1648 compiled = compiled || _.template($('#' + id).html(), null, options);
1649 return compiled(data);
1650 };
1651
1652 return data ? tmpl(data) : tmpl;
1653 }, function (a, b) {
1654 return a + '-' + JSON.stringify(b);
1655 }) : function () {
1656 return '';
1657 },
1658
1659 alert(localize, callback) {
1660 let title = '',
1661 message = '';
1662
1663 if (typeof localize === 'string') {
1664 message = localize;
1665 } else {
1666 if (typeof localize.title !== 'undefined') {
1667 title = localize.title;
1668 }
1669
1670 if (typeof localize.message !== 'undefined') {
1671 message = localize.message;
1672 }
1673 }
1674
1675 $.alerts.alert(message, title, function (e) {
1676 LP._on_alert_hide();
1677
1678 callback && callback(e);
1679 });
1680
1681 this._on_alert_show();
1682 },
1683
1684 confirm(localize, callback) {
1685 let title = '',
1686 message = '';
1687
1688 if (typeof localize === 'string') {
1689 message = localize;
1690 } else {
1691 if (typeof localize.title !== 'undefined') {
1692 title = localize.title;
1693 }
1694
1695 if (typeof localize.message !== 'undefined') {
1696 message = localize.message;
1697 }
1698 }
1699
1700 $.alerts.confirm(message, title, function (e) {
1701 LP._on_alert_hide();
1702
1703 callback && callback(e);
1704 });
1705
1706 this._on_alert_show();
1707 },
1708
1709 _on_alert_show() {
1710 const $container = $('#popup_container'),
1711 $placeholder = $('<span id="popup_container_placeholder" />').insertAfter($container).data('xxx', $container);
1712 $container.stop().css('top', '-=50').css('opacity', '0').animate({
1713 top: '+=50',
1714 opacity: 1
1715 }, 250);
1716 },
1717
1718 _on_alert_hide() {
1719 const $holder = $('#popup_container_placeholder'),
1720 $container = $holder.data('xxx');
1721
1722 if ($container) {
1723 $container.replaceWith($holder);
1724 }
1725
1726 $container.appendTo($(document.body));
1727 $container.stop().animate({
1728 top: '+=50',
1729 opacity: 0
1730 }, 250, function () {
1731 $(this).remove();
1732 });
1733 },
1734
1735 sendMessage(data, object, targetOrigin, transfer) {
1736 if ($.isPlainObject(data)) {
1737 data = JSON.stringify(data);
1738 }
1739
1740 object = object || window;
1741 targetOrigin = targetOrigin || '*';
1742 object.postMessage(data, targetOrigin, transfer);
1743 },
1744
1745 receiveMessage(event, b) {
1746 let target = event.origin || event.originalEvent.origin,
1747 data = event.data || event.originalEvent.data || '';
1748
1749 if (typeof data === 'string' || data instanceof String) {
1750 if (data.indexOf('{') === 0) {
1751 data = LP.parseJSON(data);
1752 }
1753 }
1754
1755 LP.Hook.doAction('learn_press_receive_message', data, target);
1756 },
1757
1758 camelCaseDashObjectKeys(obj) {
1759 let deep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1760 const self = LP;
1761
1762 const isArray = function (a) {
1763 return Array.isArray(a);
1764 };
1765
1766 const isObject = function (o) {
1767 return o === Object(o) && !isArray(o) && typeof o !== 'function';
1768 };
1769
1770 const toCamel = s => {
1771 return s.replace(/([-_][a-z])/ig, $1 => {
1772 return $1.toUpperCase().replace('-', '').replace('_', '');
1773 });
1774 };
1775
1776 if (isObject(obj)) {
1777 const n = {};
1778 Object.keys(obj).forEach(k => {
1779 n[toCamel(k)] = deep ? self.camelCaseDashObjectKeys(obj[k]) : obj[k];
1780 });
1781 return n;
1782 } else if (isArray(obj)) {
1783 return obj.map(i => {
1784 return self.camelCaseDashObjectKeys(i);
1785 });
1786 }
1787
1788 return obj;
1789 },
1790
1791 IframeSubmit: _iframe_submit__WEBPACK_IMPORTED_MODULE_9__["default"]
1792 };
1793 $(document).ready(function () {
1794 if (typeof $.alerts !== 'undefined') {
1795 $.alerts.overlayColor = '#000';
1796 $.alerts.overlayOpacity = 0.5;
1797 $.alerts.okButton = lpGlobalSettings.localize.button_ok;
1798 $.alerts.cancelButton = lpGlobalSettings.localize.button_cancel;
1799 }
1800
1801 $('.learn-press-message.fixed').each(function () {
1802 const $el = $(this),
1803 options = $el.data();
1804
1805 (function ($el, options) {
1806 if (options.delayIn) {
1807 setTimeout(function () {
1808 $el.show().hide().fadeIn();
1809 }, options.delayIn);
1810 }
1811
1812 if (options.delayOut) {
1813 setTimeout(function () {
1814 $el.fadeOut();
1815 }, options.delayOut + (options.delayIn || 0));
1816 }
1817 })($el, options);
1818 });
1819 setTimeout(function () {
1820 $('.learn-press-nav-tabs li.active:not(.default) a').trigger('click');
1821 }, 300);
1822 $('body.course-item-popup').parent().css('overflow', 'hidden');
1823
1824 (function () {
1825 let timer = null,
1826 callback = function () {
1827 $('.auto-check-lines').checkLines(function (r) {
1828 if (r > 1) {
1829 $(this).removeClass('single-lines');
1830 } else {
1831 $(this).addClass('single-lines');
1832 }
1833
1834 $(this).attr('rows', r);
1835 });
1836 };
1837
1838 $(window).on('resize.check-lines', function () {
1839 if (timer) {
1840 timer && clearTimeout(timer);
1841 timer = setTimeout(callback, 300);
1842 } else {
1843 callback();
1844 }
1845 });
1846 })();
1847
1848 $('.learn-press-tooltip, .lp-passing-conditional').LP_Tooltip({
1849 offset: [24, 24]
1850 });
1851 $('.learn-press-icon').LP_Tooltip({
1852 offset: [30, 30]
1853 });
1854 $('.learn-press-message[data-autoclose]').each(function () {
1855 const $el = $(this),
1856 delay = parseInt($el.data('autoclose'));
1857
1858 if (delay) {
1859 setTimeout(function ($el) {
1860 $el.fadeOut();
1861 }, delay, $el);
1862 }
1863 });
1864 $(document).on('click', function () {
1865 $(document).trigger('learn-press/close-all-quick-tip');
1866 });
1867 });
1868 (0,_extend__WEBPACK_IMPORTED_MODULE_0__["default"])({
1869 Event_Callback: _event_callback__WEBPACK_IMPORTED_MODULE_4__["default"],
1870 MessageBox: _message_box__WEBPACK_IMPORTED_MODULE_3__["default"],
1871 Cookies: _cookies__WEBPACK_IMPORTED_MODULE_6__["default"],
1872 localStorage: _local_storage__WEBPACK_IMPORTED_MODULE_7__["default"],
1873 ..._default
1874 });
1875 /* harmony default export */ __webpack_exports__["default"] = ({
1876 fn: _fn__WEBPACK_IMPORTED_MODULE_1__["default"],
1877 QuickTip: (_quick_tip__WEBPACK_IMPORTED_MODULE_2___default()),
1878 Cookies: _cookies__WEBPACK_IMPORTED_MODULE_6__["default"],
1879 localStorage: _local_storage__WEBPACK_IMPORTED_MODULE_7__["default"],
1880 showPass: (_show_password__WEBPACK_IMPORTED_MODULE_10___default())
1881 });
1882 }();
1883 /******/ })()
1884 ;
1885 //# sourceMappingURL=utils.js.map