PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.2.0
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.2.0
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.2.0, at assets/js/dist/utils.js

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