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

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