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

1,676 lines 51.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "./assets/src/js/utils/cookies.js"
5 /*!****************************************!*\
6 !*** ./assets/src/js/utils/cookies.js ***!
7 \****************************************/
8 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
9
10 "use strict";
11 __webpack_require__.r(__webpack_exports__);
12 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
14 /* harmony export */ });
15 const Cookies = {
16 get: (name, def, global) => {
17 let ret;
18 if (global) {
19 ret = wpCookies.get(name);
20 } else {
21 let ck = wpCookies.get('LP');
22 if (ck) {
23 ck = JSON.parse(ck);
24 ret = name ? ck[name] : ck;
25 }
26 }
27 if (!ret && ret !== def) {
28 ret = def;
29 }
30 return ret;
31 },
32 set(name, value, expires, path, domain, secure) {
33 if (arguments.length > 2) {
34 wpCookies.set(name, value, expires, path, domain, secure);
35 } else if (arguments.length == 2) {
36 let ck = wpCookies.get('LP');
37 if (ck) {
38 ck = JSON.parse(ck);
39 } else {
40 ck = {};
41 }
42 ck[name] = value;
43 wpCookies.set('LP', JSON.stringify(ck), '', '/');
44 } else {
45 wpCookies.set('LP', JSON.stringify(name), '', '/');
46 }
47 },
48 remove(name) {
49 const allCookies = Cookies.get();
50 const reg = new RegExp(name, 'g');
51 const newCookies = {};
52 const useRegExp = name.match(/\*/);
53 for (const i in allCookies) {
54 if (useRegExp) {
55 if (!i.match(reg)) {
56 newCookies[i] = allCookies[i];
57 }
58 } else if (name != i) {
59 newCookies[i] = allCookies[i];
60 }
61 }
62 Cookies.set(newCookies);
63 }
64 };
65 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Cookies);
66
67 /***/ },
68
69 /***/ "./assets/src/js/utils/event-callback.js"
70 /*!***********************************************!*\
71 !*** ./assets/src/js/utils/event-callback.js ***!
72 \***********************************************/
73 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
74
75 "use strict";
76 __webpack_require__.r(__webpack_exports__);
77 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
78 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
79 /* harmony export */ });
80 /**
81 * Manage event callbacks.
82 Allow add/remove a callback function into custom event of an object.
83 *
84 * @class
85 * @param self
86 */
87 const Event_Callback = function Event_Callback(self) {
88 const callbacks = {};
89 const $ = window.jQuery;
90 this.on = function (event, callback) {
91 let namespaces = event.split('.'),
92 namespace = '';
93 if (namespaces.length > 1) {
94 event = namespaces[0];
95 namespace = namespaces[1];
96 }
97 if (!callbacks[event]) {
98 callbacks[event] = [[], {}];
99 }
100 if (namespace) {
101 if (!callbacks[event][1][namespace]) {
102 callbacks[event][1][namespace] = [];
103 }
104 callbacks[event][1][namespace].push(callback);
105 } else {
106 callbacks[event][0].push(callback);
107 }
108 return self;
109 };
110 this.off = function (event, callback) {
111 let namespaces = event.split('.'),
112 namespace = '';
113 if (namespaces.length > 1) {
114 event = namespaces[0];
115 namespace = namespaces[1];
116 }
117 if (!callbacks[event]) {
118 return self;
119 }
120 let at = -1;
121 if (!namespace) {
122 if (typeof callback === 'function') {
123 at = callbacks[event][0].indexOf(callback);
124 if (at < 0) {
125 return self;
126 }
127 callbacks[event][0].splice(at, 1);
128 } else {
129 callbacks[event][0] = [];
130 }
131 } else {
132 if (!callbacks[event][1][namespace]) {
133 return self;
134 }
135 if (typeof callback === 'function') {
136 at = callbacks[event][1][namespace].indexOf(callback);
137 if (at < 0) {
138 return self;
139 }
140 callbacks[event][1][namespace].splice(at, 1);
141 } else {
142 callbacks[event][1][namespace] = [];
143 }
144 }
145 return self;
146 };
147 this.callEvent = function (event, callbackArgs) {
148 if (!callbacks[event]) {
149 return;
150 }
151 if (callbacks[event][0]) {
152 for (var i = 0; i < callbacks[event][0].length; i++) {
153 typeof callbacks[event][0][i] === 'function' && callbacks[event][i][0].apply(self, callbackArgs);
154 }
155 }
156 if (callbacks[event][1]) {
157 for (var i in callbacks[event][1]) {
158 for (let j = 0; j < callbacks[event][1][i].length; j++) {
159 typeof callbacks[event][1][i][j] === 'function' && callbacks[event][1][i][j].apply(self, callbackArgs);
160 }
161 }
162 }
163 };
164 };
165 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (Event_Callback);
166
167 /***/ },
168
169 /***/ "./assets/src/js/utils/extend.js"
170 /*!***************************************!*\
171 !*** ./assets/src/js/utils/extend.js ***!
172 \***************************************/
173 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
174
175 "use strict";
176 __webpack_require__.r(__webpack_exports__);
177 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
178 /* harmony export */ "default": () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__)
179 /* harmony export */ });
180 __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 /******/ __webpack_require__.dn = (x) => {
1105 /******/ (Object.getOwnPropertyDescriptor(x, "name") || {}).writable || Object.defineProperty(x, "name", { value: "default", configurable: true });
1106 /******/ };
1107 /******/ })();
1108 /******/
1109 /************************************************************************/
1110 let __webpack_exports__ = {};
1111 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
1112 (() => {
1113 "use strict";
1114 /*!**************************************!*\
1115 !*** ./assets/src/js/utils/index.js ***!
1116 \**************************************/
1117 __webpack_require__.r(__webpack_exports__);
1118 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1119 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1120 /* harmony export */ });
1121 /* harmony import */ var _extend__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./extend */ "./assets/src/js/utils/extend.js");
1122 /* harmony import */ var _fn__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fn */ "./assets/src/js/utils/fn.js");
1123 /* harmony import */ var _quick_tip__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./quick-tip */ "./assets/src/js/utils/quick-tip.js");
1124 /* harmony import */ var _quick_tip__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_quick_tip__WEBPACK_IMPORTED_MODULE_2__);
1125 /* harmony import */ var _message_box__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./message-box */ "./assets/src/js/utils/message-box.js");
1126 /* harmony import */ var _event_callback__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./event-callback */ "./assets/src/js/utils/event-callback.js");
1127 /* harmony import */ var _hook__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./hook */ "./assets/src/js/utils/hook.js");
1128 /* harmony import */ var _cookies__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./cookies */ "./assets/src/js/utils/cookies.js");
1129 /* harmony import */ var _local_storage__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./local-storage */ "./assets/src/js/utils/local-storage.js");
1130 /* harmony import */ var _jquery_plugins__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./jquery.plugins */ "./assets/src/js/utils/jquery.plugins.js");
1131 /* harmony import */ var _iframe_submit__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./iframe-submit */ "./assets/src/js/utils/iframe-submit.js");
1132 /* harmony import */ var _show_password__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./show-password */ "./assets/src/js/utils/show-password.js");
1133 /* harmony import */ var _show_password__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(_show_password__WEBPACK_IMPORTED_MODULE_10__);
1134 /**
1135 * Utility functions may use for both admin and frontend.
1136 *
1137 * @version 3.2.6
1138 */
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151 const $ = jQuery;
1152 String.prototype.getQueryVar = function (name) {
1153 name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
1154 const regex = new RegExp('[\\?&]' + name + '=([^&#]*)'),
1155 results = regex.exec(this);
1156 return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
1157 };
1158 String.prototype.addQueryVar = function (name, value) {
1159 let url = this,
1160 m = url.split('#');
1161 url = m[0];
1162 if (name.match(/\[/)) {
1163 url += url.match(/\?/) ? '&' : '?';
1164 url += name + '=' + value;
1165 } else if (url.indexOf('&' + name + '=') != -1 || url.indexOf('?' + name + '=') != -1) {
1166 url = url.replace(new RegExp(name + '=([^&#]*)', 'g'), name + '=' + value);
1167 } else {
1168 url += url.match(/\?/) ? '&' : '?';
1169 url += name + '=' + value;
1170 }
1171 return url + (m[1] ? '#' + m[1] : '');
1172 };
1173 String.prototype.removeQueryVar = function (name) {
1174 let url = this;
1175 const m = url.split('#');
1176 url = m[0];
1177 name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
1178 const regex = new RegExp('[\\?&]' + name + '([\[][^=]*)?=([^&#]*)', 'g');
1179 url = url.replace(regex, '');
1180 return url + (m[1] ? '#' + m[1] : '');
1181 };
1182
1183 // if ( $.isEmptyObject( '' ) == false ) {
1184 // $.isEmptyObject = function( a ) {
1185 // let prop;
1186 // for ( prop in a ) {
1187 // if ( a.hasOwnProperty( prop ) ) {
1188 // return false;
1189 // }
1190 // }
1191 // return true;
1192 // };
1193 // }
1194
1195 const _default = {
1196 Hook: _hook__WEBPACK_IMPORTED_MODULE_5__["default"],
1197 setUrl(url, ember, title) {
1198 if (url) {
1199 history.pushState({}, title, url);
1200 LP.Hook.doAction('learn_press_set_location_url', url);
1201 }
1202 },
1203 toggleGroupSection(el, target) {
1204 const $el = $(el),
1205 isHide = $el.hasClass('hide-if-js');
1206 if (isHide) {
1207 $el.hide().removeClass('hide-if-js');
1208 }
1209 $el.removeClass('hide-if-js').slideToggle(function () {
1210 const $this = $(this);
1211 if ($this.is(':visible')) {
1212 $(target).addClass('toggle-on').removeClass('toggle-off');
1213 } else {
1214 $(target).addClass('toggle-off').removeClass('toggle-on');
1215 }
1216 });
1217 },
1218 overflow(el, v) {
1219 const $el = $(el),
1220 overflow = $el.css('overflow');
1221 if (v) {
1222 $el.css('overflow', v).data('overflow', overflow);
1223 } else {
1224 $el.css('overflow', $el.data('overflow'));
1225 }
1226 },
1227 getUrl() {
1228 return window.location.href;
1229 },
1230 addQueryVar(name, value, url) {
1231 return (url === undefined ? window.location.href : url).addQueryVar(name, value);
1232 },
1233 removeQueryVar(name, url) {
1234 return (url === undefined ? window.location.href : url).removeQueryVar(name);
1235 },
1236 reload(url) {
1237 if (!url) {
1238 url = window.location.href;
1239 }
1240 window.location.href = url;
1241 },
1242 parseResponse(response, type) {
1243 const m = response.match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
1244 if (m) {
1245 response = m[1];
1246 }
1247 return (type || 'json') === 'json' ? this.parseJSON(response) : response;
1248 },
1249 parseJSON(data) {
1250 if (typeof data !== 'string') {
1251 return data;
1252 }
1253 const m = String.raw({
1254 raw: data
1255 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
1256 try {
1257 if (m) {
1258 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
1259 } else {
1260 data = JSON.parse(data);
1261 }
1262 } catch (e) {
1263 data = {};
1264 }
1265 return data;
1266 },
1267 ajax(args) {
1268 const type = args.type || 'post',
1269 dataType = args.dataType || 'json',
1270 data = args.action ? $.extend(args.data, {
1271 'lp-ajax': args.action
1272 }) : args.data,
1273 beforeSend = args.beforeSend || function () {},
1274 url = args.url || window.location.href;
1275 // console.debug( beforeSend );
1276 $.ajax({
1277 data,
1278 url,
1279 type,
1280 dataType: 'html',
1281 beforeSend: beforeSend.apply(null, args),
1282 success(raw) {
1283 const response = LP.parseResponse(raw, dataType);
1284 typeof args.success === 'function' && args.success(response, raw);
1285 },
1286 error() {
1287 typeof args.error === 'function' && args.error.apply(null, LP.funcArgs2Array());
1288 }
1289 });
1290 },
1291 doAjax(args) {
1292 const type = args.type || 'post',
1293 dataType = args.dataType || 'json',
1294 action = (args.prefix === undefined || 'learnpress_') + args.action,
1295 data = args.action ? $.extend(args.data, {
1296 action
1297 }) : args.data;
1298 $.ajax({
1299 data,
1300 url: args.url || window.location.href,
1301 type,
1302 dataType: 'html',
1303 success(raw) {
1304 const response = LP.parseResponse(raw, dataType);
1305 typeof args.success === 'function' && args.success(response, raw);
1306 },
1307 error() {
1308 typeof args.error === 'function' && args.error.apply(null, LP.funcArgs2Array());
1309 }
1310 });
1311 },
1312 funcArgs2Array(args) {
1313 const arr = [];
1314 for (let i = 0; i < args.length; i++) {
1315 arr.push(args[i]);
1316 }
1317 return arr;
1318 },
1319 addFilter(action, callback) {
1320 const $doc = $(document),
1321 event = 'LP.' + action;
1322 $doc.on(event, callback);
1323 LP.log($doc.data('events'));
1324 return this;
1325 },
1326 applyFilters() {
1327 const $doc = $(document),
1328 action = arguments[0],
1329 args = this.funcArgs2Array(arguments);
1330 if ($doc.hasEvent(action)) {
1331 args[0] = 'LP.' + action;
1332 return $doc.triggerHandler.apply($doc, args);
1333 }
1334 return args[1];
1335 },
1336 addAction(action, callback) {
1337 return this.addFilter(action, callback);
1338 },
1339 doAction() {
1340 const $doc = $(document),
1341 action = arguments[0],
1342 args = this.funcArgs2Array(arguments);
1343 if ($doc.hasEvent(action)) {
1344 args[0] = 'LP.' + action;
1345 $doc.trigger.apply($doc, args);
1346 }
1347 },
1348 toElement(element, args) {
1349 if ($(element).length === 0) {
1350 return;
1351 }
1352 args = $.extend({
1353 delay: 300,
1354 duration: 'slow',
1355 offset: 50,
1356 container: null,
1357 callback: null,
1358 invisible: false
1359 }, args || {});
1360 let $container = $(args.container),
1361 rootTop = 0;
1362 if ($container.length === 0) {
1363 $container = $('body, html');
1364 }
1365 rootTop = $container.offset().top;
1366 const to = $(element).offset().top + $container.scrollTop() - rootTop - args.offset;
1367 function isElementInView(element, fullyInView) {
1368 const pageTop = $container.scrollTop();
1369 const pageBottom = pageTop + $container.height();
1370 const elementTop = $(element).offset().top - $container.offset().top;
1371 const elementBottom = elementTop + $(element).height();
1372 if (fullyInView === true) {
1373 return pageTop < elementTop && pageBottom > elementBottom;
1374 }
1375 return elementTop <= pageBottom && elementBottom >= pageTop;
1376 }
1377 if (args.invisible && isElementInView(element, true)) {
1378 return;
1379 }
1380 $container.fadeIn(10).delay(args.delay).animate({
1381 scrollTop: to
1382 }, args.duration, args.callback);
1383 },
1384 uniqueId(prefix, more_entropy) {
1385 if (typeof prefix === 'undefined') {
1386 prefix = '';
1387 }
1388 let retId;
1389 const formatSeed = function (seed, reqWidth) {
1390 seed = parseInt(seed, 10).toString(16); // to hex str
1391 if (reqWidth < seed.length) {
1392 // so long we split
1393 return seed.slice(seed.length - reqWidth);
1394 }
1395 if (reqWidth > seed.length) {
1396 // so short we pad
1397 return new Array(1 + (reqWidth - seed.length)).join('0') + seed;
1398 }
1399 return seed;
1400 };
1401
1402 // BEGIN REDUNDANT
1403 if (!this.php_js) {
1404 this.php_js = {};
1405 }
1406 // END REDUNDANT
1407 if (!this.php_js.uniqidSeed) {
1408 // init seed with big random int
1409 this.php_js.uniqidSeed = Math.floor(Math.random() * 0x75bcd15);
1410 }
1411 this.php_js.uniqidSeed++;
1412 retId = prefix; // start with prefix, add current milliseconds hex string
1413 retId += formatSeed(parseInt(new Date().getTime() / 1000, 10), 8);
1414 retId += formatSeed(this.php_js.uniqidSeed, 5); // add seed hex string
1415 if (more_entropy) {
1416 // for more entropy we add a float lower to 10
1417 retId += (Math.random() * 10).toFixed(8).toString();
1418 }
1419 return retId;
1420 },
1421 log() {
1422 //if (typeof LEARN_PRESS_DEBUG != 'undefined' && LEARN_PRESS_DEBUG && console) {
1423 for (let i = 0, n = arguments.length; i < n; i++) {
1424 console.log(arguments[i]);
1425 }
1426 //}
1427 },
1428 blockContent() {
1429 if ($('#learn-press-block-content').length === 0) {
1430 $(LP.template('learn-press-template-block-content', {})).appendTo($('body'));
1431 }
1432 LP.hideMainScrollbar().addClass('block-content');
1433 $(document).trigger('learn_press_block_content');
1434 },
1435 unblockContent() {
1436 setTimeout(function () {
1437 LP.showMainScrollbar().removeClass('block-content');
1438 $(document).trigger('learn_press_unblock_content');
1439 }, 350);
1440 },
1441 hideMainScrollbar(el) {
1442 if (!el) {
1443 el = 'html, body';
1444 }
1445 const $el = $(el);
1446 $el.each(function () {
1447 const $root = $(this),
1448 overflow = $root.css('overflow');
1449 $root.css('overflow', 'hidden').attr('overflow', overflow);
1450 });
1451 return $el;
1452 },
1453 showMainScrollbar(el) {
1454 if (!el) {
1455 el = 'html, body';
1456 }
1457 const $el = $(el);
1458 $el.each(function () {
1459 const $root = $(this),
1460 overflow = $root.attr('overflow');
1461 $root.css('overflow', overflow).removeAttr('overflow');
1462 });
1463 return $el;
1464 },
1465 template: typeof _ !== 'undefined' ? _.memoize(function (id, data) {
1466 let compiled,
1467 options = {
1468 evaluate: /<#([\s\S]+?)#>/g,
1469 interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,
1470 escape: /\{\{([^\}]+?)\}\}(?!\})/g,
1471 variable: 'data'
1472 };
1473 const tmpl = function (data) {
1474 compiled = compiled || _.template($('#' + id).html(), null, options);
1475 return compiled(data);
1476 };
1477 return data ? tmpl(data) : tmpl;
1478 }, function (a, b) {
1479 return a + '-' + JSON.stringify(b);
1480 }) : function () {
1481 return '';
1482 },
1483 alert(localize, callback) {
1484 let title = '',
1485 message = '';
1486 if (typeof localize === 'string') {
1487 message = localize;
1488 } else {
1489 if (typeof localize.title !== 'undefined') {
1490 title = localize.title;
1491 }
1492 if (typeof localize.message !== 'undefined') {
1493 message = localize.message;
1494 }
1495 }
1496 $.alerts.alert(message, title, function (e) {
1497 LP._on_alert_hide();
1498 callback && callback(e);
1499 });
1500 this._on_alert_show();
1501 },
1502 confirm(localize, callback) {
1503 let title = '',
1504 message = '';
1505 if (typeof localize === 'string') {
1506 message = localize;
1507 } else {
1508 if (typeof localize.title !== 'undefined') {
1509 title = localize.title;
1510 }
1511 if (typeof localize.message !== 'undefined') {
1512 message = localize.message;
1513 }
1514 }
1515 $.alerts.confirm(message, title, function (e) {
1516 LP._on_alert_hide();
1517 callback && callback(e);
1518 });
1519 this._on_alert_show();
1520 },
1521 _on_alert_show() {
1522 const $container = $('#popup_container'),
1523 $placeholder = $('<span id="popup_container_placeholder" />').insertAfter($container).data('xxx', $container);
1524 $container.stop().css('top', '-=50').css('opacity', '0').animate({
1525 top: '+=50',
1526 opacity: 1
1527 }, 250);
1528 },
1529 _on_alert_hide() {
1530 const $holder = $('#popup_container_placeholder'),
1531 $container = $holder.data('xxx');
1532 if ($container) {
1533 $container.replaceWith($holder);
1534 }
1535 $container.appendTo($(document.body));
1536 $container.stop().animate({
1537 top: '+=50',
1538 opacity: 0
1539 }, 250, function () {
1540 $(this).remove();
1541 });
1542 },
1543 sendMessage(data, object, targetOrigin, transfer) {
1544 if ($.isPlainObject(data)) {
1545 data = JSON.stringify(data);
1546 }
1547 object = object || window;
1548 targetOrigin = targetOrigin || '*';
1549 object.postMessage(data, targetOrigin, transfer);
1550 },
1551 receiveMessage(event, b) {
1552 let target = event.origin || event.originalEvent.origin,
1553 data = event.data || event.originalEvent.data || '';
1554 if (typeof data === 'string' || data instanceof String) {
1555 if (data.indexOf('{') === 0) {
1556 data = LP.parseJSON(data);
1557 }
1558 }
1559 LP.Hook.doAction('learn_press_receive_message', data, target);
1560 },
1561 camelCaseDashObjectKeys(obj, deep = true) {
1562 const self = LP;
1563 const isArray = function (a) {
1564 return Array.isArray(a);
1565 };
1566 const isObject = function (o) {
1567 return o === Object(o) && !isArray(o) && typeof o !== 'function';
1568 };
1569 const toCamel = s => {
1570 return s.replace(/([-_][a-z])/ig, $1 => {
1571 return $1.toUpperCase().replace('-', '').replace('_', '');
1572 });
1573 };
1574 if (isObject(obj)) {
1575 const n = {};
1576 Object.keys(obj).forEach(k => {
1577 n[toCamel(k)] = deep ? self.camelCaseDashObjectKeys(obj[k]) : obj[k];
1578 });
1579 return n;
1580 } else if (isArray(obj)) {
1581 return obj.map(i => {
1582 return self.camelCaseDashObjectKeys(i);
1583 });
1584 }
1585 return obj;
1586 },
1587 IframeSubmit: _iframe_submit__WEBPACK_IMPORTED_MODULE_9__["default"]
1588 };
1589 $(document).ready(function () {
1590 if (typeof $.alerts !== 'undefined') {
1591 $.alerts.overlayColor = '#000';
1592 $.alerts.overlayOpacity = 0.5;
1593 $.alerts.okButton = lpGlobalSettings.localize.button_ok;
1594 $.alerts.cancelButton = lpGlobalSettings.localize.button_cancel;
1595 }
1596 $('.learn-press-message.fixed').each(function () {
1597 const $el = $(this),
1598 options = $el.data();
1599 (function ($el, options) {
1600 if (options.delayIn) {
1601 setTimeout(function () {
1602 $el.show().hide().fadeIn();
1603 }, options.delayIn);
1604 }
1605 if (options.delayOut) {
1606 setTimeout(function () {
1607 $el.fadeOut();
1608 }, options.delayOut + (options.delayIn || 0));
1609 }
1610 })($el, options);
1611 });
1612 setTimeout(function () {
1613 $('.learn-press-nav-tabs li.active:not(.default) a').trigger('click');
1614 }, 300);
1615
1616 //$( 'body.course-item-popup' ).parent().css( 'overflow', 'hidden' );
1617
1618 (function () {
1619 let timer = null,
1620 callback = function () {
1621 $('.auto-check-lines').checkLines(function (r) {
1622 if (r > 1) {
1623 $(this).removeClass('single-lines');
1624 } else {
1625 $(this).addClass('single-lines');
1626 }
1627 $(this).attr('rows', r);
1628 });
1629 };
1630 $(window).on('resize.check-lines', function () {
1631 if (timer) {
1632 timer && clearTimeout(timer);
1633 timer = setTimeout(callback, 300);
1634 } else {
1635 callback();
1636 }
1637 });
1638 })();
1639 $('.learn-press-tooltip, .lp-passing-conditional').LP_Tooltip({
1640 offset: [24, 24]
1641 });
1642 $('.learn-press-icon').LP_Tooltip({
1643 offset: [30, 30]
1644 });
1645 $('.learn-press-message[data-autoclose]').each(function () {
1646 const $el = $(this),
1647 delay = parseInt($el.data('autoclose'));
1648 if (delay) {
1649 setTimeout(function ($el) {
1650 $el.fadeOut();
1651 }, delay, $el);
1652 }
1653 });
1654 $(document).on('click', function () {
1655 $(document).trigger('learn-press/close-all-quick-tip');
1656 });
1657 });
1658 (0,_extend__WEBPACK_IMPORTED_MODULE_0__["default"])({
1659 Event_Callback: _event_callback__WEBPACK_IMPORTED_MODULE_4__["default"],
1660 MessageBox: _message_box__WEBPACK_IMPORTED_MODULE_3__["default"],
1661 Cookies: _cookies__WEBPACK_IMPORTED_MODULE_6__["default"],
1662 localStorage: _local_storage__WEBPACK_IMPORTED_MODULE_7__["default"],
1663 ..._default
1664 });
1665 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
1666 fn: _fn__WEBPACK_IMPORTED_MODULE_1__["default"],
1667 QuickTip: (_quick_tip__WEBPACK_IMPORTED_MODULE_2___default()),
1668 Cookies: _cookies__WEBPACK_IMPORTED_MODULE_6__["default"],
1669 localStorage: _local_storage__WEBPACK_IMPORTED_MODULE_7__["default"],
1670 showPass: (_show_password__WEBPACK_IMPORTED_MODULE_10___default())
1671 });
1672 })();
1673
1674 /******/ })()
1675 ;
1676 //# sourceMappingURL=utils.js.map