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

1,661 lines 51.2 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 __webpack_require__.dn(__WEBPACK_DEFAULT_EXPORT__);
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 /******/ /* webpack/runtime/set anonymous default export name */
1087 /******/ (() => {
1088 /******/ // set .name for anonymous default exports per ES spec
1089 /******/ __webpack_require__.dn = (x) => {
1090 /******/ (Object.getOwnPropertyDescriptor(x, "name") || {}).writable || Object.defineProperty(x, "name", { value: "default", configurable: true });
1091 /******/ };
1092 /******/ })();
1093 /******/
1094 /************************************************************************/
1095 var __webpack_exports__ = {};
1096 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
1097 (() => {
1098 "use strict";
1099 /*!**************************************!*\
1100 !*** ./assets/src/js/utils/index.js ***!
1101 \**************************************/
1102 __webpack_require__.r(__webpack_exports__);
1103 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1104 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1105 /* harmony export */ });
1106 /* harmony import */ var _extend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./extend */ "./assets/src/js/utils/extend.js");
1107 /* harmony import */ var _fn__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fn */ "./assets/src/js/utils/fn.js");
1108 /* harmony import */ var _quick_tip__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./quick-tip */ "./assets/src/js/utils/quick-tip.js");
1109 /* harmony import */ var _quick_tip__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_quick_tip__WEBPACK_IMPORTED_MODULE_2__);
1110 /* harmony import */ var _message_box__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message-box */ "./assets/src/js/utils/message-box.js");
1111 /* harmony import */ var _event_callback__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./event-callback */ "./assets/src/js/utils/event-callback.js");
1112 /* harmony import */ var _hook__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./hook */ "./assets/src/js/utils/hook.js");
1113 /* harmony import */ var _cookies__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./cookies */ "./assets/src/js/utils/cookies.js");
1114 /* harmony import */ var _local_storage__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./local-storage */ "./assets/src/js/utils/local-storage.js");
1115 /* harmony import */ var _jquery_plugins__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./jquery.plugins */ "./assets/src/js/utils/jquery.plugins.js");
1116 /* harmony import */ var _iframe_submit__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./iframe-submit */ "./assets/src/js/utils/iframe-submit.js");
1117 /* harmony import */ var _show_password__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./show-password */ "./assets/src/js/utils/show-password.js");
1118 /* harmony import */ var _show_password__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(_show_password__WEBPACK_IMPORTED_MODULE_10__);
1119 /**
1120 * Utility functions may use for both admin and frontend.
1121 *
1122 * @version 3.2.6
1123 */
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136 const $ = jQuery;
1137 String.prototype.getQueryVar = function (name) {
1138 name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
1139 const regex = new RegExp('[\\?&]' + name + '=([^&#]*)'),
1140 results = regex.exec(this);
1141 return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
1142 };
1143 String.prototype.addQueryVar = function (name, value) {
1144 let url = this,
1145 m = url.split('#');
1146 url = m[0];
1147 if (name.match(/\[/)) {
1148 url += url.match(/\?/) ? '&' : '?';
1149 url += name + '=' + value;
1150 } else if (url.indexOf('&' + name + '=') != -1 || url.indexOf('?' + name + '=') != -1) {
1151 url = url.replace(new RegExp(name + '=([^&#]*)', 'g'), name + '=' + value);
1152 } else {
1153 url += url.match(/\?/) ? '&' : '?';
1154 url += name + '=' + value;
1155 }
1156 return url + (m[1] ? '#' + m[1] : '');
1157 };
1158 String.prototype.removeQueryVar = function (name) {
1159 let url = this;
1160 const m = url.split('#');
1161 url = m[0];
1162 name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
1163 const regex = new RegExp('[\\?&]' + name + '([\[][^=]*)?=([^&#]*)', 'g');
1164 url = url.replace(regex, '');
1165 return url + (m[1] ? '#' + m[1] : '');
1166 };
1167
1168 // if ( $.isEmptyObject( '' ) == false ) {
1169 // $.isEmptyObject = function( a ) {
1170 // let prop;
1171 // for ( prop in a ) {
1172 // if ( a.hasOwnProperty( prop ) ) {
1173 // return false;
1174 // }
1175 // }
1176 // return true;
1177 // };
1178 // }
1179
1180 const _default = {
1181 Hook: _hook__WEBPACK_IMPORTED_MODULE_5__["default"],
1182 setUrl(url, ember, title) {
1183 if (url) {
1184 history.pushState({}, title, url);
1185 LP.Hook.doAction('learn_press_set_location_url', url);
1186 }
1187 },
1188 toggleGroupSection(el, target) {
1189 const $el = $(el),
1190 isHide = $el.hasClass('hide-if-js');
1191 if (isHide) {
1192 $el.hide().removeClass('hide-if-js');
1193 }
1194 $el.removeClass('hide-if-js').slideToggle(function () {
1195 const $this = $(this);
1196 if ($this.is(':visible')) {
1197 $(target).addClass('toggle-on').removeClass('toggle-off');
1198 } else {
1199 $(target).addClass('toggle-off').removeClass('toggle-on');
1200 }
1201 });
1202 },
1203 overflow(el, v) {
1204 const $el = $(el),
1205 overflow = $el.css('overflow');
1206 if (v) {
1207 $el.css('overflow', v).data('overflow', overflow);
1208 } else {
1209 $el.css('overflow', $el.data('overflow'));
1210 }
1211 },
1212 getUrl() {
1213 return window.location.href;
1214 },
1215 addQueryVar(name, value, url) {
1216 return (url === undefined ? window.location.href : url).addQueryVar(name, value);
1217 },
1218 removeQueryVar(name, url) {
1219 return (url === undefined ? window.location.href : url).removeQueryVar(name);
1220 },
1221 reload(url) {
1222 if (!url) {
1223 url = window.location.href;
1224 }
1225 window.location.href = url;
1226 },
1227 parseResponse(response, type) {
1228 const m = response.match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
1229 if (m) {
1230 response = m[1];
1231 }
1232 return (type || 'json') === 'json' ? this.parseJSON(response) : response;
1233 },
1234 parseJSON(data) {
1235 if (typeof data !== 'string') {
1236 return data;
1237 }
1238 const m = String.raw({
1239 raw: data
1240 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
1241 try {
1242 if (m) {
1243 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
1244 } else {
1245 data = JSON.parse(data);
1246 }
1247 } catch (e) {
1248 data = {};
1249 }
1250 return data;
1251 },
1252 ajax(args) {
1253 const type = args.type || 'post',
1254 dataType = args.dataType || 'json',
1255 data = args.action ? $.extend(args.data, {
1256 'lp-ajax': args.action
1257 }) : args.data,
1258 beforeSend = args.beforeSend || function () {},
1259 url = args.url || window.location.href;
1260 // console.debug( beforeSend );
1261 $.ajax({
1262 data,
1263 url,
1264 type,
1265 dataType: 'html',
1266 beforeSend: beforeSend.apply(null, args),
1267 success(raw) {
1268 const response = LP.parseResponse(raw, dataType);
1269 typeof args.success === 'function' && args.success(response, raw);
1270 },
1271 error() {
1272 typeof args.error === 'function' && args.error.apply(null, LP.funcArgs2Array());
1273 }
1274 });
1275 },
1276 doAjax(args) {
1277 const type = args.type || 'post',
1278 dataType = args.dataType || 'json',
1279 action = (args.prefix === undefined || 'learnpress_') + args.action,
1280 data = args.action ? $.extend(args.data, {
1281 action
1282 }) : args.data;
1283 $.ajax({
1284 data,
1285 url: args.url || window.location.href,
1286 type,
1287 dataType: 'html',
1288 success(raw) {
1289 const response = LP.parseResponse(raw, dataType);
1290 typeof args.success === 'function' && args.success(response, raw);
1291 },
1292 error() {
1293 typeof args.error === 'function' && args.error.apply(null, LP.funcArgs2Array());
1294 }
1295 });
1296 },
1297 funcArgs2Array(args) {
1298 const arr = [];
1299 for (let i = 0; i < args.length; i++) {
1300 arr.push(args[i]);
1301 }
1302 return arr;
1303 },
1304 addFilter(action, callback) {
1305 const $doc = $(document),
1306 event = 'LP.' + action;
1307 $doc.on(event, callback);
1308 LP.log($doc.data('events'));
1309 return this;
1310 },
1311 applyFilters() {
1312 const $doc = $(document),
1313 action = arguments[0],
1314 args = this.funcArgs2Array(arguments);
1315 if ($doc.hasEvent(action)) {
1316 args[0] = 'LP.' + action;
1317 return $doc.triggerHandler.apply($doc, args);
1318 }
1319 return args[1];
1320 },
1321 addAction(action, callback) {
1322 return this.addFilter(action, callback);
1323 },
1324 doAction() {
1325 const $doc = $(document),
1326 action = arguments[0],
1327 args = this.funcArgs2Array(arguments);
1328 if ($doc.hasEvent(action)) {
1329 args[0] = 'LP.' + action;
1330 $doc.trigger.apply($doc, args);
1331 }
1332 },
1333 toElement(element, args) {
1334 if ($(element).length === 0) {
1335 return;
1336 }
1337 args = $.extend({
1338 delay: 300,
1339 duration: 'slow',
1340 offset: 50,
1341 container: null,
1342 callback: null,
1343 invisible: false
1344 }, args || {});
1345 let $container = $(args.container),
1346 rootTop = 0;
1347 if ($container.length === 0) {
1348 $container = $('body, html');
1349 }
1350 rootTop = $container.offset().top;
1351 const to = $(element).offset().top + $container.scrollTop() - rootTop - args.offset;
1352 function isElementInView(element, fullyInView) {
1353 const pageTop = $container.scrollTop();
1354 const pageBottom = pageTop + $container.height();
1355 const elementTop = $(element).offset().top - $container.offset().top;
1356 const elementBottom = elementTop + $(element).height();
1357 if (fullyInView === true) {
1358 return pageTop < elementTop && pageBottom > elementBottom;
1359 }
1360 return elementTop <= pageBottom && elementBottom >= pageTop;
1361 }
1362 if (args.invisible && isElementInView(element, true)) {
1363 return;
1364 }
1365 $container.fadeIn(10).delay(args.delay).animate({
1366 scrollTop: to
1367 }, args.duration, args.callback);
1368 },
1369 uniqueId(prefix, more_entropy) {
1370 if (typeof prefix === 'undefined') {
1371 prefix = '';
1372 }
1373 let retId;
1374 const formatSeed = function (seed, reqWidth) {
1375 seed = parseInt(seed, 10).toString(16); // to hex str
1376 if (reqWidth < seed.length) {
1377 // so long we split
1378 return seed.slice(seed.length - reqWidth);
1379 }
1380 if (reqWidth > seed.length) {
1381 // so short we pad
1382 return new Array(1 + (reqWidth - seed.length)).join('0') + seed;
1383 }
1384 return seed;
1385 };
1386
1387 // BEGIN REDUNDANT
1388 if (!this.php_js) {
1389 this.php_js = {};
1390 }
1391 // END REDUNDANT
1392 if (!this.php_js.uniqidSeed) {
1393 // init seed with big random int
1394 this.php_js.uniqidSeed = Math.floor(Math.random() * 0x75bcd15);
1395 }
1396 this.php_js.uniqidSeed++;
1397 retId = prefix; // start with prefix, add current milliseconds hex string
1398 retId += formatSeed(parseInt(new Date().getTime() / 1000, 10), 8);
1399 retId += formatSeed(this.php_js.uniqidSeed, 5); // add seed hex string
1400 if (more_entropy) {
1401 // for more entropy we add a float lower to 10
1402 retId += (Math.random() * 10).toFixed(8).toString();
1403 }
1404 return retId;
1405 },
1406 log() {
1407 //if (typeof LEARN_PRESS_DEBUG != 'undefined' && LEARN_PRESS_DEBUG && console) {
1408 for (let i = 0, n = arguments.length; i < n; i++) {
1409 console.log(arguments[i]);
1410 }
1411 //}
1412 },
1413 blockContent() {
1414 if ($('#learn-press-block-content').length === 0) {
1415 $(LP.template('learn-press-template-block-content', {})).appendTo($('body'));
1416 }
1417 LP.hideMainScrollbar().addClass('block-content');
1418 $(document).trigger('learn_press_block_content');
1419 },
1420 unblockContent() {
1421 setTimeout(function () {
1422 LP.showMainScrollbar().removeClass('block-content');
1423 $(document).trigger('learn_press_unblock_content');
1424 }, 350);
1425 },
1426 hideMainScrollbar(el) {
1427 if (!el) {
1428 el = 'html, body';
1429 }
1430 const $el = $(el);
1431 $el.each(function () {
1432 const $root = $(this),
1433 overflow = $root.css('overflow');
1434 $root.css('overflow', 'hidden').attr('overflow', overflow);
1435 });
1436 return $el;
1437 },
1438 showMainScrollbar(el) {
1439 if (!el) {
1440 el = 'html, body';
1441 }
1442 const $el = $(el);
1443 $el.each(function () {
1444 const $root = $(this),
1445 overflow = $root.attr('overflow');
1446 $root.css('overflow', overflow).removeAttr('overflow');
1447 });
1448 return $el;
1449 },
1450 template: typeof _ !== 'undefined' ? _.memoize(function (id, data) {
1451 let compiled,
1452 options = {
1453 evaluate: /<#([\s\S]+?)#>/g,
1454 interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
1455 escape: /\{\{([^\}]+?)\}\}(?!\})/g,
1456 variable: 'data'
1457 };
1458 const tmpl = function (data) {
1459 compiled = compiled || _.template($('#' + id).html(), null, options);
1460 return compiled(data);
1461 };
1462 return data ? tmpl(data) : tmpl;
1463 }, function (a, b) {
1464 return a + '-' + JSON.stringify(b);
1465 }) : function () {
1466 return '';
1467 },
1468 alert(localize, callback) {
1469 let title = '',
1470 message = '';
1471 if (typeof localize === 'string') {
1472 message = localize;
1473 } else {
1474 if (typeof localize.title !== 'undefined') {
1475 title = localize.title;
1476 }
1477 if (typeof localize.message !== 'undefined') {
1478 message = localize.message;
1479 }
1480 }
1481 $.alerts.alert(message, title, function (e) {
1482 LP._on_alert_hide();
1483 callback && callback(e);
1484 });
1485 this._on_alert_show();
1486 },
1487 confirm(localize, callback) {
1488 let title = '',
1489 message = '';
1490 if (typeof localize === 'string') {
1491 message = localize;
1492 } else {
1493 if (typeof localize.title !== 'undefined') {
1494 title = localize.title;
1495 }
1496 if (typeof localize.message !== 'undefined') {
1497 message = localize.message;
1498 }
1499 }
1500 $.alerts.confirm(message, title, function (e) {
1501 LP._on_alert_hide();
1502 callback && callback(e);
1503 });
1504 this._on_alert_show();
1505 },
1506 _on_alert_show() {
1507 const $container = $('#popup_container'),
1508 $placeholder = $('<span id="popup_container_placeholder" />').insertAfter($container).data('xxx', $container);
1509 $container.stop().css('top', '-=50').css('opacity', '0').animate({
1510 top: '+=50',
1511 opacity: 1
1512 }, 250);
1513 },
1514 _on_alert_hide() {
1515 const $holder = $('#popup_container_placeholder'),
1516 $container = $holder.data('xxx');
1517 if ($container) {
1518 $container.replaceWith($holder);
1519 }
1520 $container.appendTo($(document.body));
1521 $container.stop().animate({
1522 top: '+=50',
1523 opacity: 0
1524 }, 250, function () {
1525 $(this).remove();
1526 });
1527 },
1528 sendMessage(data, object, targetOrigin, transfer) {
1529 if ($.isPlainObject(data)) {
1530 data = JSON.stringify(data);
1531 }
1532 object = object || window;
1533 targetOrigin = targetOrigin || '*';
1534 object.postMessage(data, targetOrigin, transfer);
1535 },
1536 receiveMessage(event, b) {
1537 let target = event.origin || event.originalEvent.origin,
1538 data = event.data || event.originalEvent.data || '';
1539 if (typeof data === 'string' || data instanceof String) {
1540 if (data.indexOf('{') === 0) {
1541 data = LP.parseJSON(data);
1542 }
1543 }
1544 LP.Hook.doAction('learn_press_receive_message', data, target);
1545 },
1546 camelCaseDashObjectKeys(obj, deep = true) {
1547 const self = LP;
1548 const isArray = function (a) {
1549 return Array.isArray(a);
1550 };
1551 const isObject = function (o) {
1552 return o === Object(o) && !isArray(o) && typeof o !== 'function';
1553 };
1554 const toCamel = s => {
1555 return s.replace(/([-_][a-z])/ig, $1 => {
1556 return $1.toUpperCase().replace('-', '').replace('_', '');
1557 });
1558 };
1559 if (isObject(obj)) {
1560 const n = {};
1561 Object.keys(obj).forEach(k => {
1562 n[toCamel(k)] = deep ? self.camelCaseDashObjectKeys(obj[k]) : obj[k];
1563 });
1564 return n;
1565 } else if (isArray(obj)) {
1566 return obj.map(i => {
1567 return self.camelCaseDashObjectKeys(i);
1568 });
1569 }
1570 return obj;
1571 },
1572 IframeSubmit: _iframe_submit__WEBPACK_IMPORTED_MODULE_9__["default"]
1573 };
1574 $(document).ready(function () {
1575 if (typeof $.alerts !== 'undefined') {
1576 $.alerts.overlayColor = '#000';
1577 $.alerts.overlayOpacity = 0.5;
1578 $.alerts.okButton = lpGlobalSettings.localize.button_ok;
1579 $.alerts.cancelButton = lpGlobalSettings.localize.button_cancel;
1580 }
1581 $('.learn-press-message.fixed').each(function () {
1582 const $el = $(this),
1583 options = $el.data();
1584 (function ($el, options) {
1585 if (options.delayIn) {
1586 setTimeout(function () {
1587 $el.show().hide().fadeIn();
1588 }, options.delayIn);
1589 }
1590 if (options.delayOut) {
1591 setTimeout(function () {
1592 $el.fadeOut();
1593 }, options.delayOut + (options.delayIn || 0));
1594 }
1595 })($el, options);
1596 });
1597 setTimeout(function () {
1598 $('.learn-press-nav-tabs li.active:not(.default) a').trigger('click');
1599 }, 300);
1600
1601 //$( 'body.course-item-popup' ).parent().css( 'overflow', 'hidden' );
1602
1603 (function () {
1604 let timer = null,
1605 callback = function () {
1606 $('.auto-check-lines').checkLines(function (r) {
1607 if (r > 1) {
1608 $(this).removeClass('single-lines');
1609 } else {
1610 $(this).addClass('single-lines');
1611 }
1612 $(this).attr('rows', r);
1613 });
1614 };
1615 $(window).on('resize.check-lines', function () {
1616 if (timer) {
1617 timer && clearTimeout(timer);
1618 timer = setTimeout(callback, 300);
1619 } else {
1620 callback();
1621 }
1622 });
1623 })();
1624 $('.learn-press-tooltip, .lp-passing-conditional').LP_Tooltip({
1625 offset: [24, 24]
1626 });
1627 $('.learn-press-icon').LP_Tooltip({
1628 offset: [30, 30]
1629 });
1630 $('.learn-press-message[data-autoclose]').each(function () {
1631 const $el = $(this),
1632 delay = parseInt($el.data('autoclose'));
1633 if (delay) {
1634 setTimeout(function ($el) {
1635 $el.fadeOut();
1636 }, delay, $el);
1637 }
1638 });
1639 $(document).on('click', function () {
1640 $(document).trigger('learn-press/close-all-quick-tip');
1641 });
1642 });
1643 (0,_extend__WEBPACK_IMPORTED_MODULE_0__["default"])({
1644 Event_Callback: _event_callback__WEBPACK_IMPORTED_MODULE_4__["default"],
1645 MessageBox: _message_box__WEBPACK_IMPORTED_MODULE_3__["default"],
1646 Cookies: _cookies__WEBPACK_IMPORTED_MODULE_6__["default"],
1647 localStorage: _local_storage__WEBPACK_IMPORTED_MODULE_7__["default"],
1648 ..._default
1649 });
1650 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
1651 fn: _fn__WEBPACK_IMPORTED_MODULE_1__["default"],
1652 QuickTip: (_quick_tip__WEBPACK_IMPORTED_MODULE_2___default()),
1653 Cookies: _cookies__WEBPACK_IMPORTED_MODULE_6__["default"],
1654 localStorage: _local_storage__WEBPACK_IMPORTED_MODULE_7__["default"],
1655 showPass: (_show_password__WEBPACK_IMPORTED_MODULE_10___default())
1656 });
1657 })();
1658
1659 /******/ })()
1660 ;
1661 //# sourceMappingURL=utils.js.map