PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.0
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.0
4.4.8 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 All 139 releases
learnpress / assets / js / dist / utils.js

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

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