PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.7.14
Shortcodes and extra features for Phlox theme v2.7.14
2.17.21 2.17.20 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.6 1.0.9 1.1.0 1.3.0 1.3.1 1.3.10 1.3.14 1.3.2 1.3.3 1.3.6 1.4.0 1.4.1 1.4.2 1.5.0 1.5.2 1.6.0 1.6.2 1.6.4 1.7.0 1.7.2 2.10.0 2.10.1 2.10.3 2.10.5 2.10.7 2.10.8 2.10.9 2.11.0 2.11.1 2.11.2 2.12.0 2.14.0 2.15.0 2.15.2 2.15.4 2.15.5 2.15.6 2.15.7 2.15.8 2.15.9 2.16.0 2.16.1 2.16.2 2.16.3 2.16.4 2.17.0 2.17.1 2.17.12 2.17.13 2.17.14 2.17.15 2.17.16 2.17.2 2.17.3 2.17.4 2.17.5 2.17.6 2.17.8 2.17.9 2.4.12 2.4.13 2.4.14 2.4.16 2.4.18 2.4.19 2.4.9 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.15 2.5.16 2.5.17 2.5.19 2.5.2 2.5.20 2.5.3 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.10 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.19 2.6.2 2.6.20 2.6.4 2.6.5 2.6.7 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.9 2.9.0 2.9.12 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.19 2.9.2 2.9.20 2.9.21 2.9.22 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8
auxin-elements / admin / assets / js / plugins.js
auxin-elements / admin / assets / js Last commit date
elementor 5 years ago solo 5 years ago tinymce 9 years ago index.php 9 years ago plugins.js 5 years ago plugins.min.js 5 years ago scripts.js 7 years ago
plugins.js
2695 lines
1 /*! Phlox Core Plugin - v2.7.14 (2021-05)
2 * All required javascript plugins for admin
3 * http://phlox.pro/
4 * Place any jQuery/helper plugins in here, instead of separate, slower script files!
5 */
6
7 if( typeof Object.create !== 'function' ){ Object.create = function (obj){ function F(){} F.prototype = obj; return new F();}; }
8
9 /*!
10 * ================== admin/assets/js/libs/featherlight.js ===================
11 **/
12
13 /**
14 * Featherlight - ultra slim jQuery lightbox
15 * Version 1.7.12 - http://noelboss.github.io/featherlight/
16 *
17 * Copyright 2017, Noël Raoul Bossart (http://www.noelboss.com)
18 * MIT Licensed.
19 **/
20 (function($) {
21 "use strict";
22
23 if('undefined' === typeof $) {
24 if('console' in window){ window.console.info('Too much lightness, Featherlight needs jQuery.'); }
25 return;
26 }
27 if($.fn.jquery.match(/-ajax/)) {
28 if('console' in window){ window.console.info('Featherlight needs regular jQuery, not the slim version.'); }
29 return;
30 }
31 /* Featherlight is exported as $.featherlight.
32 It is a function used to open a featherlight lightbox.
33
34 [tech]
35 Featherlight uses prototype inheritance.
36 Each opened lightbox will have a corresponding object.
37 That object may have some attributes that override the
38 prototype's.
39 Extensions created with Featherlight.extend will have their
40 own prototype that inherits from Featherlight's prototype,
41 thus attributes can be overriden either at the object level,
42 or at the extension level.
43 To create callbacks that chain themselves instead of overriding,
44 use chainCallbacks.
45 For those familiar with CoffeeScript, this correspond to
46 Featherlight being a class and the Gallery being a class
47 extending Featherlight.
48 The chainCallbacks is used since we don't have access to
49 CoffeeScript's `super`.
50 */
51
52 function Featherlight($content, config) {
53 if(this instanceof Featherlight) { /* called with new */
54 this.id = Featherlight.id++;
55 this.setup($content, config);
56 this.chainCallbacks(Featherlight._callbackChain);
57 } else {
58 var fl = new Featherlight($content, config);
59 fl.open();
60 return fl;
61 }
62 }
63
64 var opened = [],
65 pruneOpened = function(remove) {
66 opened = $.grep(opened, function(fl) {
67 return fl !== remove && fl.$instance.closest('body').length > 0;
68 } );
69 return opened;
70 };
71
72 // Removes keys of `set` from `obj` and returns the removed key/values.
73 function slice(obj, set) {
74 var r = {};
75 for (var key in obj) {
76 if (key in set) {
77 r[key] = obj[key];
78 delete obj[key];
79 }
80 }
81 return r;
82 }
83
84 // NOTE: List of available [iframe attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe).
85 var iFrameAttributeSet = {
86 allowfullscreen: 1, frameborder: 1, height: 1, longdesc: 1, marginheight: 1, marginwidth: 1,
87 name: 1, referrerpolicy: 1, scrolling: 1, sandbox: 1, src: 1, srcdoc: 1, width: 1
88 };
89
90 // Converts camelCased attributes to dasherized versions for given prefix:
91 // parseAttrs({hello: 1, hellFrozeOver: 2}, 'hell') => {froze-over: 2}
92 function parseAttrs(obj, prefix) {
93 var attrs = {},
94 regex = new RegExp('^' + prefix + '([A-Z])(.*)');
95 for (var key in obj) {
96 var match = key.match(regex);
97 if (match) {
98 var dasherized = (match[1] + match[2].replace(/([A-Z])/g, '-$1')).toLowerCase();
99 attrs[dasherized] = obj[key];
100 }
101 }
102 return attrs;
103 }
104
105 /* document wide key handler */
106 var eventMap = { keyup: 'onKeyUp', resize: 'onResize' };
107
108 var globalEventHandler = function(event) {
109 $.each(Featherlight.opened().reverse(), function() {
110 if (!event.isDefaultPrevented()) {
111 if (false === this[eventMap[event.type]](event)) {
112 event.preventDefault(); event.stopPropagation(); return false;
113 }
114 }
115 });
116 };
117
118 var toggleGlobalEvents = function(set) {
119 if(set !== Featherlight._globalHandlerInstalled) {
120 Featherlight._globalHandlerInstalled = set;
121 var events = $.map(eventMap, function(_, name) { return name+'.'+Featherlight.prototype.namespace; } ).join(' ');
122 $(window)[set ? 'on' : 'off'](events, globalEventHandler);
123 }
124 };
125
126 Featherlight.prototype = {
127 constructor: Featherlight,
128 /*** defaults ***/
129 /* extend featherlight with defaults and methods */
130 namespace: 'featherlight', /* Name of the events and css class prefix */
131 targetAttr: 'data-featherlight', /* Attribute of the triggered element that contains the selector to the lightbox content */
132 variant: null, /* Class that will be added to change look of the lightbox */
133 resetCss: false, /* Reset all css */
134 background: null, /* Custom DOM for the background, wrapper and the closebutton */
135 openTrigger: 'click', /* Event that triggers the lightbox */
136 closeTrigger: 'click', /* Event that triggers the closing of the lightbox */
137 filter: null, /* Selector to filter events. Think $(...).on('click', filter, eventHandler) */
138 root: 'body', /* Where to append featherlights */
139 openSpeed: 250, /* Duration of opening animation */
140 closeSpeed: 250, /* Duration of closing animation */
141 closeOnClick: 'background', /* Close lightbox on click ('background', 'anywhere' or false) */
142 closeOnEsc: true, /* Close lightbox when pressing esc */
143 closeIcon: '✕', /* Close icon */
144 loading: '', /* Content to show while initial content is loading */
145 persist: false, /* If set, the content will persist and will be shown again when opened again. 'shared' is a special value when binding multiple elements for them to share the same content */
146 otherClose: null, /* Selector for alternate close buttons (e.g. "a.close") */
147 beforeOpen: $.noop, /* Called before open. can return false to prevent opening of lightbox. Gets event as parameter, this contains all data */
148 beforeContent: $.noop, /* Called when content is loaded. Gets event as parameter, this contains all data */
149 beforeClose: $.noop, /* Called before close. can return false to prevent opening of lightbox. Gets event as parameter, this contains all data */
150 afterOpen: $.noop, /* Called after open. Gets event as parameter, this contains all data */
151 afterContent: $.noop, /* Called after content is ready and has been set. Gets event as parameter, this contains all data */
152 afterClose: $.noop, /* Called after close. Gets event as parameter, this contains all data */
153 onKeyUp: $.noop, /* Called on key up for the frontmost featherlight */
154 onResize: $.noop, /* Called after new content and when a window is resized */
155 type: null, /* Specify type of lightbox. If unset, it will check for the targetAttrs value. */
156 contentFilters: ['jquery', 'image', 'html', 'ajax', 'iframe', 'text'], /* List of content filters to use to determine the content */
157
158 /*** methods ***/
159 /* setup iterates over a single instance of featherlight and prepares the background and binds the events */
160 setup: function(target, config){
161 /* all arguments are optional */
162 if (typeof target === 'object' && target instanceof $ === false && !config) {
163 config = target;
164 target = undefined;
165 }
166
167 var self = $.extend(this, config, {target: target}),
168 css = !self.resetCss ? self.namespace : self.namespace+'-reset', /* by adding -reset to the classname, we reset all the default css */
169 $background = $(self.background || [
170 '<div class="'+css+'-loading '+css+'">',
171 '<div class="'+css+'-content">',
172 '<button class="'+css+'-close-icon '+ self.namespace + '-close" aria-label="Close">',
173 self.closeIcon,
174 '</button>',
175 '<div class="'+self.namespace+'-inner">' + self.loading + '</div>',
176 '</div>',
177 '</div>'].join('')),
178 closeButtonSelector = '.'+self.namespace+'-close' + (self.otherClose ? ',' + self.otherClose : '');
179
180 self.$instance = $background.clone().addClass(self.variant); /* clone DOM for the background, wrapper and the close button */
181
182 /* close when click on background/anywhere/null or closebox */
183 self.$instance.on(self.closeTrigger+'.'+self.namespace, function(event) {
184 if(event.isDefaultPrevented()) {
185 return;
186 }
187 var $target = $(event.target);
188 if( ('background' === self.closeOnClick && $target.is('.'+self.namespace))
189 || 'anywhere' === self.closeOnClick
190 || $target.closest(closeButtonSelector).length ){
191 self.close(event);
192 event.preventDefault();
193 }
194 });
195
196 return this;
197 },
198
199 /* this method prepares the content and converts it into a jQuery object or a promise */
200 getContent: function(){
201 if(this.persist !== false && this.$content) {
202 return this.$content;
203 }
204 var self = this,
205 filters = this.constructor.contentFilters,
206 readTargetAttr = function(name){ return self.$currentTarget && self.$currentTarget.attr(name); },
207 targetValue = readTargetAttr(self.targetAttr),
208 data = self.target || targetValue || '';
209
210 /* Find which filter applies */
211 var filter = filters[self.type]; /* check explicit type like {type: 'image'} */
212
213 /* check explicit type like data-featherlight="image" */
214 if(!filter && data in filters) {
215 filter = filters[data];
216 data = self.target && targetValue;
217 }
218 data = data || readTargetAttr('href') || '';
219
220 /* check explicity type & content like {image: 'photo.jpg'} */
221 if(!filter) {
222 for(var filterName in filters) {
223 if(self[filterName]) {
224 filter = filters[filterName];
225 data = self[filterName];
226 }
227 }
228 }
229
230 /* otherwise it's implicit, run checks */
231 if(!filter) {
232 var target = data;
233 data = null;
234 $.each(self.contentFilters, function() {
235 filter = filters[this];
236 if(filter.test) {
237 data = filter.test(target);
238 }
239 if(!data && filter.regex && target.match && target.match(filter.regex)) {
240 data = target;
241 }
242 return !data;
243 });
244 if(!data) {
245 if('console' in window){ window.console.error('Featherlight: no content filter found ' + (target ? ' for "' + target + '"' : ' (no target specified)')); }
246 return false;
247 }
248 }
249 /* Process it */
250 return filter.process.call(self, data);
251 },
252
253 /* sets the content of $instance to $content */
254 setContent: function($content){
255 this.$instance.removeClass(this.namespace+'-loading');
256
257 /* we need a special class for the iframe */
258 this.$instance.toggleClass(this.namespace+'-iframe', $content.is('iframe'));
259
260 /* replace content by appending to existing one before it is removed
261 this insures that featherlight-inner remain at the same relative
262 position to any other items added to featherlight-content */
263 this.$instance.find('.'+this.namespace+'-inner')
264 .not($content) /* excluded new content, important if persisted */
265 .slice(1).remove().end() /* In the unexpected event where there are many inner elements, remove all but the first one */
266 .replaceWith($.contains(this.$instance[0], $content[0]) ? '' : $content);
267
268 this.$content = $content.addClass(this.namespace+'-inner');
269
270 return this;
271 },
272
273 /* opens the lightbox. "this" contains $instance with the lightbox, and with the config.
274 Returns a promise that is resolved after is successfully opened. */
275 open: function(event){
276 var self = this;
277 self.$instance.hide().appendTo(self.root);
278 if((!event || !event.isDefaultPrevented())
279 && self.beforeOpen(event) !== false) {
280
281 if(event){
282 event.preventDefault();
283 }
284 var $content = self.getContent();
285
286 if($content) {
287 opened.push(self);
288
289 toggleGlobalEvents(true);
290
291 self.$instance.fadeIn(self.openSpeed);
292 self.beforeContent(event);
293
294 /* Set content and show */
295 return $.when($content)
296 .always(function($content){
297 self.setContent($content);
298 self.afterContent(event);
299 })
300 .then(self.$instance.promise())
301 /* Call afterOpen after fadeIn is done */
302 .done(function(){ self.afterOpen(event); });
303 }
304 }
305 self.$instance.detach();
306 return $.Deferred().reject().promise();
307 },
308
309 /* closes the lightbox. "this" contains $instance with the lightbox, and with the config
310 returns a promise, resolved after the lightbox is successfully closed. */
311 close: function(event){
312 var self = this,
313 deferred = $.Deferred();
314
315 if(self.beforeClose(event) === false) {
316 deferred.reject();
317 } else {
318
319 if (0 === pruneOpened(self).length) {
320 toggleGlobalEvents(false);
321 }
322
323 self.$instance.fadeOut(self.closeSpeed,function(){
324 self.$instance.detach();
325 self.afterClose(event);
326 deferred.resolve();
327 });
328 }
329 return deferred.promise();
330 },
331
332 /* resizes the content so it fits in visible area and keeps the same aspect ratio.
333 Does nothing if either the width or the height is not specified.
334 Called automatically on window resize.
335 Override if you want different behavior. */
336 resize: function(w, h) {
337 if (w && h) {
338 /* Reset apparent image size first so container grows */
339 this.$content.css('width', '').css('height', '');
340 /* Calculate the worst ratio so that dimensions fit */
341 /* Note: -1 to avoid rounding errors */
342 var ratio = Math.max(
343 w / (this.$content.parent().width()-1),
344 h / (this.$content.parent().height()-1));
345 /* Resize content */
346 if (ratio > 1) {
347 ratio = h / Math.floor(h / ratio); /* Round ratio down so height calc works */
348 this.$content.css('width', '' + w / ratio + 'px').css('height', '' + h / ratio + 'px');
349 }
350 }
351 },
352
353 /* Utility function to chain callbacks
354 [Warning: guru-level]
355 Used be extensions that want to let users specify callbacks but
356 also need themselves to use the callbacks.
357 The argument 'chain' has callback names as keys and function(super, event)
358 as values. That function is meant to call `super` at some point.
359 */
360 chainCallbacks: function(chain) {
361 for (var name in chain) {
362 this[name] = $.proxy(chain[name], this, $.proxy(this[name], this));
363 }
364 }
365 };
366
367 $.extend(Featherlight, {
368 id: 0, /* Used to id single featherlight instances */
369 autoBind: '[data-featherlight]', /* Will automatically bind elements matching this selector. Clear or set before onReady */
370 defaults: Featherlight.prototype, /* You can access and override all defaults using $.featherlight.defaults, which is just a synonym for $.featherlight.prototype */
371 /* Contains the logic to determine content */
372 contentFilters: {
373 jquery: {
374 regex: /^[#.]\w/, /* Anything that starts with a class name or identifiers */
375 test: function(elem) { return elem instanceof $ && elem; },
376 process: function(elem) { return this.persist !== false ? $(elem) : $(elem).clone(true); }
377 },
378 image: {
379 regex: /\.(png|jpg|jpeg|gif|tiff?|bmp|svg)(\?\S*)?$/i,
380 process: function(url) {
381 var self = this,
382 deferred = $.Deferred(),
383 img = new Image(),
384 $img = $('<img src="'+url+'" alt="" class="'+self.namespace+'-image" />');
385 img.onload = function() {
386 /* Store naturalWidth & height for IE8 */
387 $img.naturalWidth = img.width; $img.naturalHeight = img.height;
388 deferred.resolve( $img );
389 };
390 img.onerror = function() { deferred.reject($img); };
391 img.src = url;
392 return deferred.promise();
393 }
394 },
395 html: {
396 regex: /^\s*<[\w!][^<]*>/, /* Anything that starts with some kind of valid tag */
397 process: function(html) { return $(html); }
398 },
399 ajax: {
400 regex: /./, /* At this point, any content is assumed to be an URL */
401 process: function(url) {
402 var self = this,
403 deferred = $.Deferred();
404 /* we are using load so one can specify a target with: url.html #targetelement */
405 var $container = $('<div></div>').load(url, function(response, status){
406 if ( status !== "error" ) {
407 deferred.resolve($container.contents());
408 }
409 deferred.fail();
410 });
411 return deferred.promise();
412 }
413 },
414 iframe: {
415 process: function(url) {
416 var deferred = new $.Deferred();
417 var $content = $('<iframe/>');
418 var css = parseAttrs(this, 'iframe');
419 var attrs = slice(css, iFrameAttributeSet);
420 $content.hide()
421 .attr('src', url)
422 .attr(attrs)
423 .css(css)
424 .on('load', function() { deferred.resolve($content.show()); })
425 // We can't move an <iframe> and avoid reloading it,
426 // so let's put it in place ourselves right now:
427 .appendTo(this.$instance.find('.' + this.namespace + '-content'));
428 return deferred.promise();
429 }
430 },
431 text: {
432 process: function(text) { return $('<div>', {text: text}); }
433 }
434 },
435
436 functionAttributes: ['beforeOpen', 'afterOpen', 'beforeContent', 'afterContent', 'beforeClose', 'afterClose'],
437
438 /*** class methods ***/
439 /* read element's attributes starting with data-featherlight- */
440 readElementConfig: function(element, namespace) {
441 var Klass = this,
442 regexp = new RegExp('^data-' + namespace + '-(.*)'),
443 config = {};
444 if (element && element.attributes) {
445 $.each(element.attributes, function(){
446 var match = this.name.match(regexp);
447 if (match) {
448 var val = this.value,
449 name = $.camelCase(match[1]);
450 if ($.inArray(name, Klass.functionAttributes) >= 0) { /* jshint -W054 */
451 val = new Function(val); /* jshint +W054 */
452 } else {
453 try { val = JSON.parse(val); }
454 catch(e) {}
455 }
456 config[name] = val;
457 }
458 });
459 }
460 return config;
461 },
462
463 /* Used to create a Featherlight extension
464 [Warning: guru-level]
465 Creates the extension's prototype that in turn
466 inherits Featherlight's prototype.
467 Could be used to extend an extension too...
468 This is pretty high level wizardy, it comes pretty much straight
469 from CoffeeScript and won't teach you anything about Featherlight
470 as it's not really specific to this library.
471 My suggestion: move along and keep your sanity.
472 */
473 extend: function(child, defaults) {
474 /* Setup class hierarchy, adapted from CoffeeScript */
475 var Ctor = function(){ this.constructor = child; };
476 Ctor.prototype = this.prototype;
477 child.prototype = new Ctor();
478 child.__super__ = this.prototype;
479 /* Copy class methods & attributes */
480 $.extend(child, this, defaults);
481 child.defaults = child.prototype;
482 return child;
483 },
484
485 attach: function($source, $content, config) {
486 var Klass = this;
487 if (typeof $content === 'object' && $content instanceof $ === false && !config) {
488 config = $content;
489 $content = undefined;
490 }
491 /* make a copy */
492 config = $.extend({}, config);
493
494 /* Only for openTrigger and namespace... */
495 var namespace = config.namespace || Klass.defaults.namespace,
496 tempConfig = $.extend({}, Klass.defaults, Klass.readElementConfig($source[0], namespace), config),
497 sharedPersist;
498 var handler = function(event) {
499 var $target = $(event.currentTarget);
500 /* ... since we might as well compute the config on the actual target */
501 var elemConfig = $.extend(
502 {$source: $source, $currentTarget: $target},
503 Klass.readElementConfig($source[0], tempConfig.namespace),
504 Klass.readElementConfig(event.currentTarget, tempConfig.namespace),
505 config);
506 var fl = sharedPersist || $target.data('featherlight-persisted') || new Klass($content, elemConfig);
507 if(fl.persist === 'shared') {
508 sharedPersist = fl;
509 } else if(fl.persist !== false) {
510 $target.data('featherlight-persisted', fl);
511 }
512 if (elemConfig.$currentTarget.blur) {
513 elemConfig.$currentTarget.blur(); // Otherwise 'enter' key might trigger the dialog again
514 }
515 fl.open(event);
516 };
517
518 $source.on(tempConfig.openTrigger+'.'+tempConfig.namespace, tempConfig.filter, handler);
519
520 return handler;
521 },
522
523 current: function() {
524 var all = this.opened();
525 return all[all.length - 1] || null;
526 },
527
528 opened: function() {
529 var klass = this;
530 pruneOpened();
531 return $.grep(opened, function(fl) { return fl instanceof klass; } );
532 },
533
534 close: function(event) {
535 var cur = this.current();
536 if(cur) { return cur.close(event); }
537 },
538
539 /* Does the auto binding on startup.
540 Meant only to be used by Featherlight and its extensions
541 */
542 _onReady: function() {
543 var Klass = this;
544 if(Klass.autoBind){
545 /* Bind existing elements */
546 $(Klass.autoBind).each(function(){
547 Klass.attach($(this));
548 });
549 /* If a click propagates to the document level, then we have an item that was added later on */
550 $(document).on('click', Klass.autoBind, function(evt) {
551 if (evt.isDefaultPrevented()) {
552 return;
553 }
554 /* Bind featherlight */
555 var handler = Klass.attach($(evt.currentTarget));
556 /* Dispatch event directly */
557 handler(evt);
558 });
559 }
560 },
561
562 /* Featherlight uses the onKeyUp callback to intercept the escape key.
563 Private to Featherlight.
564 */
565 _callbackChain: {
566 onKeyUp: function(_super, event){
567 if(27 === event.keyCode) {
568 if (this.closeOnEsc) {
569 $.featherlight.close(event);
570 }
571 return false;
572 } else {
573 return _super(event);
574 }
575 },
576
577 beforeOpen: function(_super, event) {
578 // Used to disable scrolling
579 $(document.documentElement).addClass('with-featherlight');
580
581 // Remember focus:
582 this._previouslyActive = document.activeElement;
583
584 // Disable tabbing:
585 // See http://stackoverflow.com/questions/1599660/which-html-elements-can-receive-focus
586 this._$previouslyTabbable = $("a, input, select, textarea, iframe, button, iframe, [contentEditable=true]")
587 .not('[tabindex]')
588 .not(this.$instance.find('button'));
589
590 this._$previouslyWithTabIndex = $('[tabindex]').not('[tabindex="-1"]');
591 this._previousWithTabIndices = this._$previouslyWithTabIndex.map(function(_i, elem) {
592 return $(elem).attr('tabindex');
593 });
594
595 this._$previouslyWithTabIndex.add(this._$previouslyTabbable).attr('tabindex', -1);
596
597 if (document.activeElement.blur) {
598 document.activeElement.blur();
599 }
600 return _super(event);
601 },
602
603 afterClose: function(_super, event) {
604 var r = _super(event);
605 // Restore focus
606 var self = this;
607 this._$previouslyTabbable.removeAttr('tabindex');
608 this._$previouslyWithTabIndex.each(function(i, elem) {
609 $(elem).attr('tabindex', self._previousWithTabIndices[i]);
610 });
611 this._previouslyActive.focus();
612 // Restore scroll
613 if(Featherlight.opened().length === 0) {
614 $(document.documentElement).removeClass('with-featherlight');
615 }
616 return r;
617 },
618
619 onResize: function(_super, event){
620 this.resize(this.$content.naturalWidth, this.$content.naturalHeight);
621 return _super(event);
622 },
623
624 afterContent: function(_super, event){
625 var r = _super(event);
626 this.$instance.find('[autofocus]:not([disabled])').focus();
627 this.onResize(event);
628 return r;
629 }
630 }
631 });
632
633 $.featherlight = Featherlight;
634
635 /* bind jQuery elements to trigger featherlight */
636 $.fn.featherlight = function($content, config) {
637 Featherlight.attach(this, $content, config);
638 return this;
639 };
640
641 /* bind featherlight on ready if config autoBind is set */
642 $(document).ready(function(){ Featherlight._onReady(); });
643 }(jQuery));
644
645
646 /*!
647 * ================== admin/assets/js/libs/jquery.blockUI.js ===================
648 **/
649
650 /*!
651 * jQuery blockUI plugin
652 * Version 2.70.0-2014.11.23
653 * Requires jQuery v1.7 or later
654 *
655 * Examples at: http://malsup.com/jquery/block/
656 * Copyright (c) 2007-2013 M. Alsup
657 * Dual licensed under the MIT and GPL licenses:
658 * http://www.opensource.org/licenses/mit-license.php
659 * http://www.gnu.org/licenses/gpl.html
660 *
661 * Thanks to Amir-Hossein Sobhi for some excellent contributions!
662 */
663
664 ;(function() {
665 /*jshint eqeqeq:false curly:false latedef:false */
666 "use strict";
667
668 function setup($) {
669 $.fn._fadeIn = $.fn.fadeIn;
670
671 var noOp = $.noop || function() {};
672
673 // this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle
674 // confusing userAgent strings on Vista)
675 var msie = /MSIE/.test(navigator.userAgent);
676 var ie6 = /MSIE 6.0/.test(navigator.userAgent) && ! /MSIE 8.0/.test(navigator.userAgent);
677 var mode = document.documentMode || 0;
678 var setExpr = $.isFunction( document.createElement('div').style.setExpression );
679
680 // global $ methods for blocking/unblocking the entire page
681 $.blockUI = function(opts) { install(window, opts); };
682 $.unblockUI = function(opts) { remove(window, opts); };
683
684 // convenience method for quick growl-like notifications (http://www.google.com/search?q=growl)
685 $.growlUI = function(title, message, timeout, onClose) {
686 var $m = $('<div class="growlUI"></div>');
687 if (title) $m.append('<h1>'+title+'</h1>');
688 if (message) $m.append('<h2>'+message+'</h2>');
689 if (timeout === undefined) timeout = 3000;
690
691 // Added by konapun: Set timeout to 30 seconds if this growl is moused over, like normal toast notifications
692 var callBlock = function(opts) {
693 opts = opts || {};
694
695 $.blockUI({
696 message: $m,
697 fadeIn : typeof opts.fadeIn !== 'undefined' ? opts.fadeIn : 700,
698 fadeOut: typeof opts.fadeOut !== 'undefined' ? opts.fadeOut : 1000,
699 timeout: typeof opts.timeout !== 'undefined' ? opts.timeout : timeout,
700 centerY: false,
701 showOverlay: false,
702 onUnblock: onClose,
703 css: $.blockUI.defaults.growlCSS
704 });
705 };
706
707 callBlock();
708 var nonmousedOpacity = $m.css('opacity');
709 $m.mouseover(function() {
710 callBlock({
711 fadeIn: 0,
712 timeout: 30000
713 });
714
715 var displayBlock = $('.blockMsg');
716 displayBlock.stop(); // cancel fadeout if it has started
717 displayBlock.fadeTo(300, 1); // make it easier to read the message by removing transparency
718 }).mouseout(function() {
719 $('.blockMsg').fadeOut(1000);
720 });
721 // End konapun additions
722 };
723
724 // plugin method for blocking element content
725 $.fn.block = function(opts) {
726 if ( this[0] === window ) {
727 $.blockUI( opts );
728 return this;
729 }
730 var fullOpts = $.extend({}, $.blockUI.defaults, opts || {});
731 this.each(function() {
732 var $el = $(this);
733 if (fullOpts.ignoreIfBlocked && $el.data('blockUI.isBlocked'))
734 return;
735 $el.unblock({ fadeOut: 0 });
736 });
737
738 return this.each(function() {
739 if ($.css(this,'position') == 'static') {
740 this.style.position = 'relative';
741 $(this).data('blockUI.static', true);
742 }
743 this.style.zoom = 1; // force 'hasLayout' in ie
744 install(this, opts);
745 });
746 };
747
748 // plugin method for unblocking element content
749 $.fn.unblock = function(opts) {
750 if ( this[0] === window ) {
751 $.unblockUI( opts );
752 return this;
753 }
754 return this.each(function() {
755 remove(this, opts);
756 });
757 };
758
759 $.blockUI.version = 2.70; // 2nd generation blocking at no extra cost!
760
761 // override these in your code to change the default behavior and style
762 $.blockUI.defaults = {
763 // message displayed when blocking (use null for no message)
764 message: '<h1>Please wait...</h1>',
765
766 title: null, // title string; only used when theme == true
767 draggable: true, // only used when theme == true (requires jquery-ui.js to be loaded)
768
769 theme: false, // set to true to use with jQuery UI themes
770
771 // styles for the message when blocking; if you wish to disable
772 // these and use an external stylesheet then do this in your code:
773 // $.blockUI.defaults.css = {};
774 css: {
775 padding: 0,
776 margin: 0,
777 width: '30%',
778 top: '40%',
779 left: '35%',
780 textAlign: 'center',
781 color: '#000',
782 border: '3px solid #aaa',
783 backgroundColor:'#fff',
784 cursor: 'wait'
785 },
786
787 // minimal style set used when themes are used
788 themedCSS: {
789 width: '30%',
790 top: '40%',
791 left: '35%'
792 },
793
794 // styles for the overlay
795 overlayCSS: {
796 backgroundColor: '#000',
797 opacity: 0.6,
798 cursor: 'wait'
799 },
800
801 // style to replace wait cursor before unblocking to correct issue
802 // of lingering wait cursor
803 cursorReset: 'default',
804
805 // styles applied when using $.growlUI
806 growlCSS: {
807 width: '350px',
808 top: '10px',
809 left: '',
810 right: '10px',
811 border: 'none',
812 padding: '5px',
813 opacity: 0.6,
814 cursor: 'default',
815 color: '#fff',
816 backgroundColor: '#000',
817 '-webkit-border-radius':'10px',
818 '-moz-border-radius': '10px',
819 'border-radius': '10px'
820 },
821
822 // IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w
823 // (hat tip to Jorge H. N. de Vasconcelos)
824 /*jshint scripturl:true */
825 iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank',
826
827 // force usage of iframe in non-IE browsers (handy for blocking applets)
828 forceIframe: false,
829
830 // z-index for the blocking overlay
831 baseZ: 1000,
832
833 // set these to true to have the message automatically centered
834 centerX: true, // <-- only effects element blocking (page block controlled via css above)
835 centerY: true,
836
837 // allow body element to be stetched in ie6; this makes blocking look better
838 // on "short" pages. disable if you wish to prevent changes to the body height
839 allowBodyStretch: true,
840
841 // enable if you want key and mouse events to be disabled for content that is blocked
842 bindEvents: true,
843
844 // be default blockUI will supress tab navigation from leaving blocking content
845 // (if bindEvents is true)
846 constrainTabKey: true,
847
848 // fadeIn time in millis; set to 0 to disable fadeIn on block
849 fadeIn: 200,
850
851 // fadeOut time in millis; set to 0 to disable fadeOut on unblock
852 fadeOut: 400,
853
854 // time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock
855 timeout: 0,
856
857 // disable if you don't want to show the overlay
858 showOverlay: true,
859
860 // if true, focus will be placed in the first available input field when
861 // page blocking
862 focusInput: true,
863
864 // elements that can receive focus
865 focusableElements: ':input:enabled:visible',
866
867 // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
868 // no longer needed in 2012
869 // applyPlatformOpacityRules: true,
870
871 // callback method invoked when fadeIn has completed and blocking message is visible
872 onBlock: null,
873
874 // callback method invoked when unblocking has completed; the callback is
875 // passed the element that has been unblocked (which is the window object for page
876 // blocks) and the options that were passed to the unblock call:
877 // onUnblock(element, options)
878 onUnblock: null,
879
880 // callback method invoked when the overlay area is clicked.
881 // setting this will turn the cursor to a pointer, otherwise cursor defined in overlayCss will be used.
882 onOverlayClick: null,
883
884 // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
885 quirksmodeOffsetHack: 4,
886
887 // class name of the message block
888 blockMsgClass: 'blockMsg',
889
890 // if it is already blocked, then ignore it (don't unblock and reblock)
891 ignoreIfBlocked: false
892 };
893
894 // private data and functions follow...
895
896 var pageBlock = null;
897 var pageBlockEls = [];
898
899 function install(el, opts) {
900 var css, themedCSS;
901 var full = (el == window);
902 var msg = (opts && opts.message !== undefined ? opts.message : undefined);
903 opts = $.extend({}, $.blockUI.defaults, opts || {});
904
905 if (opts.ignoreIfBlocked && $(el).data('blockUI.isBlocked'))
906 return;
907
908 opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
909 css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
910 if (opts.onOverlayClick)
911 opts.overlayCSS.cursor = 'pointer';
912
913 themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {});
914 msg = msg === undefined ? opts.message : msg;
915
916 // remove the current block (if there is one)
917 if (full && pageBlock)
918 remove(window, {fadeOut:0});
919
920 // if an existing element is being used as the blocking content then we capture
921 // its current place in the DOM (and current display style) so we can restore
922 // it when we unblock
923 if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
924 var node = msg.jquery ? msg[0] : msg;
925 var data = {};
926 $(el).data('blockUI.history', data);
927 data.el = node;
928 data.parent = node.parentNode;
929 data.display = node.style.display;
930 data.position = node.style.position;
931 if (data.parent)
932 data.parent.removeChild(node);
933 }
934
935 $(el).data('blockUI.onUnblock', opts.onUnblock);
936 var z = opts.baseZ;
937
938 // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
939 // layer1 is the iframe layer which is used to supress bleed through of underlying content
940 // layer2 is the overlay layer which has opacity and a wait cursor (by default)
941 // layer3 is the message content that is displayed while blocking
942 var lyr1, lyr2, lyr3, s;
943 if (msie || opts.forceIframe)
944 lyr1 = $('<iframe class="blockUI" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>');
945 else
946 lyr1 = $('<div class="blockUI" style="display:none"></div>');
947
948 if (opts.theme)
949 lyr2 = $('<div class="blockUI blockOverlay ui-widget-overlay" style="z-index:'+ (z++) +';display:none"></div>');
950 else
951 lyr2 = $('<div class="blockUI blockOverlay" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');
952
953 if (opts.theme && full) {
954 s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:fixed">';
955 if ( opts.title ) {
956 s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>';
957 }
958 s += '<div class="ui-widget-content ui-dialog-content"></div>';
959 s += '</div>';
960 }
961 else if (opts.theme) {
962 s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:absolute">';
963 if ( opts.title ) {
964 s += '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>';
965 }
966 s += '<div class="ui-widget-content ui-dialog-content"></div>';
967 s += '</div>';
968 }
969 else if (full) {
970 s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage" style="z-index:'+(z+10)+';display:none;position:fixed"></div>';
971 }
972 else {
973 s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement" style="z-index:'+(z+10)+';display:none;position:absolute"></div>';
974 }
975 lyr3 = $(s);
976
977 // if we have a message, style it
978 if (msg) {
979 if (opts.theme) {
980 lyr3.css(themedCSS);
981 lyr3.addClass('ui-widget-content');
982 }
983 else
984 lyr3.css(css);
985 }
986
987 // style the overlay
988 if (!opts.theme /*&& (!opts.applyPlatformOpacityRules)*/)
989 lyr2.css(opts.overlayCSS);
990 lyr2.css('position', full ? 'fixed' : 'absolute');
991
992 // make iframe layer transparent in IE
993 if (msie || opts.forceIframe)
994 lyr1.css('opacity',0.0);
995
996 //$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el);
997 var layers = [lyr1,lyr2,lyr3], $par = full ? $('body') : $(el);
998 $.each(layers, function() {
999 this.appendTo($par);
1000 });
1001
1002 if (opts.theme && opts.draggable && $.fn.draggable) {
1003 lyr3.draggable({
1004 handle: '.ui-dialog-titlebar',
1005 cancel: 'li'
1006 });
1007 }
1008
1009 // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)
1010 var expr = setExpr && (!$.support.boxModel || $('object,embed', full ? null : el).length > 0);
1011 if (ie6 || expr) {
1012 // give body 100% height
1013 if (full && opts.allowBodyStretch && $.support.boxModel)
1014 $('html,body').css('height','100%');
1015
1016 // fix ie6 issue when blocked element has a border width
1017 if ((ie6 || !$.support.boxModel) && !full) {
1018 var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth');
1019 var fixT = t ? '(0 - '+t+')' : 0;
1020 var fixL = l ? '(0 - '+l+')' : 0;
1021 }
1022
1023 // simulate fixed position
1024 $.each(layers, function(i,o) {
1025 var s = o[0].style;
1026 s.position = 'absolute';
1027 if (i < 2) {
1028 if (full)
1029 s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"');
1030 else
1031 s.setExpression('height','this.parentNode.offsetHeight + "px"');
1032 if (full)
1033 s.setExpression('width','jQuery.support.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"');
1034 else
1035 s.setExpression('width','this.parentNode.offsetWidth + "px"');
1036 if (fixL) s.setExpression('left', fixL);
1037 if (fixT) s.setExpression('top', fixT);
1038 }
1039 else if (opts.centerY) {
1040 if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
1041 s.marginTop = 0;
1042 }
1043 else if (!opts.centerY && full) {
1044 var top = (opts.css && opts.css.top) ? parseInt(opts.css.top, 10) : 0;
1045 var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"';
1046 s.setExpression('top',expression);
1047 }
1048 });
1049 }
1050
1051 // show the message
1052 if (msg) {
1053 if (opts.theme)
1054 lyr3.find('.ui-widget-content').append(msg);
1055 else
1056 lyr3.append(msg);
1057 if (msg.jquery || msg.nodeType)
1058 $(msg).show();
1059 }
1060
1061 if ((msie || opts.forceIframe) && opts.showOverlay)
1062 lyr1.show(); // opacity is zero
1063 if (opts.fadeIn) {
1064 var cb = opts.onBlock ? opts.onBlock : noOp;
1065 var cb1 = (opts.showOverlay && !msg) ? cb : noOp;
1066 var cb2 = msg ? cb : noOp;
1067 if (opts.showOverlay)
1068 lyr2._fadeIn(opts.fadeIn, cb1);
1069 if (msg)
1070 lyr3._fadeIn(opts.fadeIn, cb2);
1071 }
1072 else {
1073 if (opts.showOverlay)
1074 lyr2.show();
1075 if (msg)
1076 lyr3.show();
1077 if (opts.onBlock)
1078 opts.onBlock.bind(lyr3)();
1079 }
1080
1081 // bind key and mouse events
1082 bind(1, el, opts);
1083
1084 if (full) {
1085 pageBlock = lyr3[0];
1086 pageBlockEls = $(opts.focusableElements,pageBlock);
1087 if (opts.focusInput)
1088 setTimeout(focus, 20);
1089 }
1090 else
1091 center(lyr3[0], opts.centerX, opts.centerY);
1092
1093 if (opts.timeout) {
1094 // auto-unblock
1095 var to = setTimeout(function() {
1096 if (full)
1097 $.unblockUI(opts);
1098 else
1099 $(el).unblock(opts);
1100 }, opts.timeout);
1101 $(el).data('blockUI.timeout', to);
1102 }
1103 }
1104
1105 // remove the block
1106 function remove(el, opts) {
1107 var count;
1108 var full = (el == window);
1109 var $el = $(el);
1110 var data = $el.data('blockUI.history');
1111 var to = $el.data('blockUI.timeout');
1112 if (to) {
1113 clearTimeout(to);
1114 $el.removeData('blockUI.timeout');
1115 }
1116 opts = $.extend({}, $.blockUI.defaults, opts || {});
1117 bind(0, el, opts); // unbind events
1118
1119 if (opts.onUnblock === null) {
1120 opts.onUnblock = $el.data('blockUI.onUnblock');
1121 $el.removeData('blockUI.onUnblock');
1122 }
1123
1124 var els;
1125 if (full) // crazy selector to handle odd field errors in ie6/7
1126 els = $('body').children().filter('.blockUI').add('body > .blockUI');
1127 else
1128 els = $el.find('>.blockUI');
1129
1130 // fix cursor issue
1131 if ( opts.cursorReset ) {
1132 if ( els.length > 1 )
1133 els[1].style.cursor = opts.cursorReset;
1134 if ( els.length > 2 )
1135 els[2].style.cursor = opts.cursorReset;
1136 }
1137
1138 if (full)
1139 pageBlock = pageBlockEls = null;
1140
1141 if (opts.fadeOut) {
1142 count = els.length;
1143 els.stop().fadeOut(opts.fadeOut, function() {
1144 if ( --count === 0)
1145 reset(els,data,opts,el);
1146 });
1147 }
1148 else
1149 reset(els, data, opts, el);
1150 }
1151
1152 // move blocking element back into the DOM where it started
1153 function reset(els,data,opts,el) {
1154 var $el = $(el);
1155 if ( $el.data('blockUI.isBlocked') )
1156 return;
1157
1158 els.each(function(i,o) {
1159 // remove via DOM calls so we don't lose event handlers
1160 if (this.parentNode)
1161 this.parentNode.removeChild(this);
1162 });
1163
1164 if (data && data.el) {
1165 data.el.style.display = data.display;
1166 data.el.style.position = data.position;
1167 data.el.style.cursor = 'default'; // #59
1168 if (data.parent)
1169 data.parent.appendChild(data.el);
1170 $el.removeData('blockUI.history');
1171 }
1172
1173 if ($el.data('blockUI.static')) {
1174 $el.css('position', 'static'); // #22
1175 }
1176
1177 if (typeof opts.onUnblock == 'function')
1178 opts.onUnblock(el,opts);
1179
1180 // fix issue in Safari 6 where block artifacts remain until reflow
1181 var body = $(document.body), w = body.width(), cssW = body[0].style.width;
1182 body.width(w-1).width(w);
1183 body[0].style.width = cssW;
1184 }
1185
1186 // bind/unbind the handler
1187 function bind(b, el, opts) {
1188 var full = el == window, $el = $(el);
1189
1190 // don't bother unbinding if there is nothing to unbind
1191 if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked')))
1192 return;
1193
1194 $el.data('blockUI.isBlocked', b);
1195
1196 // don't bind events when overlay is not in use or if bindEvents is false
1197 if (!full || !opts.bindEvents || (b && !opts.showOverlay))
1198 return;
1199
1200 // bind anchors and inputs for mouse and key events
1201 var events = 'mousedown mouseup keydown keypress keyup touchstart touchend touchmove';
1202 if (b)
1203 $(document).bind(events, opts, handler);
1204 else
1205 $(document).unbind(events, handler);
1206
1207 // former impl...
1208 // var $e = $('a,:input');
1209 // b ? $e.bind(events, opts, handler) : $e.unbind(events, handler);
1210 }
1211
1212 // event handler to suppress keyboard/mouse events when blocking
1213 function handler(e) {
1214 // allow tab navigation (conditionally)
1215 if (e.type === 'keydown' && e.keyCode && e.keyCode == 9) {
1216 if (pageBlock && e.data.constrainTabKey) {
1217 var els = pageBlockEls;
1218 var fwd = !e.shiftKey && e.target === els[els.length-1];
1219 var back = e.shiftKey && e.target === els[0];
1220 if (fwd || back) {
1221 setTimeout(function(){focus(back);},10);
1222 return false;
1223 }
1224 }
1225 }
1226 var opts = e.data;
1227 var target = $(e.target);
1228 if (target.hasClass('blockOverlay') && opts.onOverlayClick)
1229 opts.onOverlayClick(e);
1230
1231 // allow events within the message content
1232 if (target.parents('div.' + opts.blockMsgClass).length > 0)
1233 return true;
1234
1235 // allow events for content that is not being blocked
1236 return target.parents().children().filter('div.blockUI').length === 0;
1237 }
1238
1239 function focus(back) {
1240 if (!pageBlockEls)
1241 return;
1242 var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0];
1243 if (e)
1244 e.focus();
1245 }
1246
1247 function center(el, x, y) {
1248 var p = el.parentNode, s = el.style;
1249 var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth');
1250 var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth');
1251 if (x) s.left = l > 0 ? (l+'px') : '0';
1252 if (y) s.top = t > 0 ? (t+'px') : '0';
1253 }
1254
1255 function sz(el, p) {
1256 return parseInt($.css(el,p),10)||0;
1257 }
1258
1259 }
1260
1261
1262 /*global define:true */
1263 if (typeof define === 'function' && define.amd && define.amd.jQuery) {
1264 define(['jquery'], setup);
1265 } else {
1266 setup(jQuery);
1267 }
1268
1269 })();
1270
1271
1272 /*!
1273 * ================== admin/assets/js/libs/jquery.scrollTo.js ===================
1274 **/
1275
1276 /*!
1277 * jQuery.scrollTo
1278 * Copyright (c) 2007-2015 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com
1279 * Licensed under MIT
1280 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
1281 * @projectDescription Lightweight, cross-browser and highly customizable animated scrolling with jQuery
1282 * @author Ariel Flesler
1283 * @version 2.1.2
1284 */
1285 ;(function(factory) {
1286 'use strict';
1287 if (typeof define === 'function' && define.amd) {
1288 // AMD
1289 define(['jquery'], factory);
1290 } else if (typeof module !== 'undefined' && module.exports) {
1291 // CommonJS
1292 module.exports = factory(require('jquery'));
1293 } else {
1294 // Global
1295 factory(jQuery);
1296 }
1297 })(function($) {
1298 'use strict';
1299
1300 var $scrollTo = $.scrollTo = function(target, duration, settings) {
1301 return $(window).scrollTo(target, duration, settings);
1302 };
1303
1304 $scrollTo.defaults = {
1305 axis:'xy',
1306 duration: 0,
1307 limit:true
1308 };
1309
1310 function isWin(elem) {
1311 return !elem.nodeName ||
1312 $.inArray(elem.nodeName.toLowerCase(), ['iframe','#document','html','body']) !== -1;
1313 }
1314
1315 $.fn.scrollTo = function(target, duration, settings) {
1316 if (typeof duration === 'object') {
1317 settings = duration;
1318 duration = 0;
1319 }
1320 if (typeof settings === 'function') {
1321 settings = { onAfter:settings };
1322 }
1323 if (target === 'max') {
1324 target = 9e9;
1325 }
1326
1327 settings = $.extend({}, $scrollTo.defaults, settings);
1328 // Speed is still recognized for backwards compatibility
1329 duration = duration || settings.duration;
1330 // Make sure the settings are given right
1331 var queue = settings.queue && settings.axis.length > 1;
1332 if (queue) {
1333 // Let's keep the overall duration
1334 duration /= 2;
1335 }
1336 settings.offset = both(settings.offset);
1337 settings.over = both(settings.over);
1338
1339 return this.each(function() {
1340 // Null target yields nothing, just like jQuery does
1341 if (target === null) return;
1342
1343 var win = isWin(this),
1344 elem = win ? this.contentWindow || window : this,
1345 $elem = $(elem),
1346 targ = target,
1347 attr = {},
1348 toff;
1349
1350 switch (typeof targ) {
1351 // A number will pass the regex
1352 case 'number':
1353 case 'string':
1354 if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)) {
1355 targ = both(targ);
1356 // We are done
1357 break;
1358 }
1359 // Relative/Absolute selector
1360 targ = win ? $(targ) : $(targ, elem);
1361 /* falls through */
1362 case 'object':
1363 if (targ.length === 0) return;
1364 // DOMElement / jQuery
1365 if (targ.is || targ.style) {
1366 // Get the real position of the target
1367 toff = (targ = $(targ)).offset();
1368 }
1369 }
1370
1371 var offset = $.isFunction(settings.offset) && settings.offset(elem, targ) || settings.offset;
1372
1373 $.each(settings.axis.split(''), function(i, axis) {
1374 var Pos = axis === 'x' ? 'Left' : 'Top',
1375 pos = Pos.toLowerCase(),
1376 key = 'scroll' + Pos,
1377 prev = $elem[key](),
1378 max = $scrollTo.max(elem, axis);
1379
1380 if (toff) {// jQuery / DOMElement
1381 attr[key] = toff[pos] + (win ? 0 : prev - $elem.offset()[pos]);
1382
1383 // If it's a dom element, reduce the margin
1384 if (settings.margin) {
1385 attr[key] -= parseInt(targ.css('margin'+Pos), 10) || 0;
1386 attr[key] -= parseInt(targ.css('border'+Pos+'Width'), 10) || 0;
1387 }
1388
1389 attr[key] += offset[pos] || 0;
1390
1391 if (settings.over[pos]) {
1392 // Scroll to a fraction of its width/height
1393 attr[key] += targ[axis === 'x'?'width':'height']() * settings.over[pos];
1394 }
1395 } else {
1396 var val = targ[pos];
1397 // Handle percentage values
1398 attr[key] = val.slice && val.slice(-1) === '%' ?
1399 parseFloat(val) / 100 * max
1400 : val;
1401 }
1402
1403 // Number or 'number'
1404 if (settings.limit && /^\d+$/.test(attr[key])) {
1405 // Check the limits
1406 attr[key] = attr[key] <= 0 ? 0 : Math.min(attr[key], max);
1407 }
1408
1409 // Don't waste time animating, if there's no need.
1410 if (!i && settings.axis.length > 1) {
1411 if (prev === attr[key]) {
1412 // No animation needed
1413 attr = {};
1414 } else if (queue) {
1415 // Intermediate animation
1416 animate(settings.onAfterFirst);
1417 // Don't animate this axis again in the next iteration.
1418 attr = {};
1419 }
1420 }
1421 });
1422
1423 animate(settings.onAfter);
1424
1425 function animate(callback) {
1426 var opts = $.extend({}, settings, {
1427 // The queue setting conflicts with animate()
1428 // Force it to always be true
1429 queue: true,
1430 duration: duration,
1431 complete: callback && function() {
1432 callback.call(elem, targ, settings);
1433 }
1434 });
1435 $elem.animate(attr, opts);
1436 }
1437 });
1438 };
1439
1440 // Max scrolling position, works on quirks mode
1441 // It only fails (not too badly) on IE, quirks mode.
1442 $scrollTo.max = function(elem, axis) {
1443 var Dim = axis === 'x' ? 'Width' : 'Height',
1444 scroll = 'scroll'+Dim;
1445
1446 if (!isWin(elem))
1447 return elem[scroll] - $(elem)[Dim.toLowerCase()]();
1448
1449 var size = 'client' + Dim,
1450 doc = elem.ownerDocument || elem.document,
1451 html = doc.documentElement,
1452 body = doc.body;
1453
1454 return Math.max(html[scroll], body[scroll]) - Math.min(html[size], body[size]);
1455 };
1456
1457 function both(val) {
1458 return $.isFunction(val) || $.isPlainObject(val) ? val : { top:val, left:val };
1459 }
1460
1461 // Add special hooks so that window scroll properties can be animated
1462 $.Tween.propHooks.scrollLeft =
1463 $.Tween.propHooks.scrollTop = {
1464 get: function(t) {
1465 return $(t.elem)[t.prop]();
1466 },
1467 set: function(t) {
1468 var curr = this.get(t);
1469 // If interrupt is true and user scrolled, stop animating
1470 if (t.options.interrupt && t._last && t._last !== curr) {
1471 return $(t.elem).stop();
1472 }
1473 var next = Math.round(t.now);
1474 // Don't waste CPU
1475 // Browsers don't render floating point scroll
1476 if (curr !== next) {
1477 $(t.elem)[t.prop](next);
1478 t._last = this.get(t);
1479 }
1480 }
1481 };
1482
1483 // AMD requirement
1484 return $scrollTo;
1485 });
1486
1487
1488 /*!
1489 * ================== admin/assets/js/libs/wizard.js ===================
1490 **/
1491
1492 (function($, window, document, undefined) {
1493 "use strict";
1494
1495 // Create the defaults once
1496 var pluginName = "AuxWizard",
1497 defaults = {
1498 modalClass: ".aux-open-modal",
1499 loading: aux_setup_params.svg_loader
1500 };
1501 // The actual plugin constructor
1502 function Plugin(element, options) {
1503 this.element = element;
1504 this.$element = $(element);
1505 this.settings = $.extend({}, defaults, options);
1506 this._defaults = defaults;
1507 this._name = pluginName;
1508
1509 this.$modalElement = null;
1510 this._modalButton = null;
1511 this._ajaxData = null;
1512 this._ajaxUrl = aux_setup_params.ajaxurl;
1513 this._elStorage = {};
1514 this._importData = {};
1515
1516 // Isotope Elements
1517 this.$isotopeTemplate = null;
1518 this.$isotopeList = null;
1519 this.$isotopePlugins = null;
1520
1521 this.init();
1522 }
1523
1524 // Avoid Plugin.prototype conflicts
1525 $.extend(Plugin.prototype, {
1526 init: function() {
1527 // Create isotope elements
1528 this._callIsotope();
1529 // Isotope change group
1530 $(".aux-isotope-group").on("change", this._changeGroup.bind(this));
1531
1532 // General Events
1533 this._openModal();
1534 this._manipulations();
1535
1536 this._lazyloadConfig();
1537
1538 // Steps Manager Event
1539 $(document).on(
1540 "click",
1541 ".aux-next-step",
1542 this._stepManager.bind(this)
1543 );
1544
1545 // Install & Uninstall Demo Events
1546 $(document).on(
1547 "click",
1548 ".aux-install-demo",
1549 this._demoManager.bind(this)
1550 );
1551 $(document).on(
1552 "click",
1553 ".aux-uninstall-demo",
1554 this._uninstallDemo.bind(this)
1555 );
1556
1557 // Template Manager Event
1558 $(document).on(
1559 "click",
1560 ".aux-copy-template",
1561 this._tempManager.bind(this)
1562 );
1563
1564 // Install Plugins Event
1565 $(document).on(
1566 "click",
1567 ".install-plugins",
1568 this._pluginManager.bind(this)
1569 );
1570
1571 // Install Plugins Event
1572 $(document).on(
1573 "click",
1574 ".aux-install-updates",
1575 this._updateManager.bind(this)
1576 );
1577
1578 // Activate license
1579 $(document).on(
1580 "submit",
1581 ".auxin-check-purchase",
1582 this._activateLicense.bind(this)
1583 );
1584
1585 // Refresh Page
1586 $(document).on(
1587 "click",
1588 ".aux-refresh-page",
1589 this._refresh.bind(this)
1590 );
1591
1592 // Check envato elements email - get license code
1593 $(document).on(
1594 "click",
1595 ".aux-verify-elements-email",
1596 this._verifyEnvatoElementsEmail.bind(this)
1597 );
1598
1599 // Check envato elements token
1600 $(document).on(
1601 "click",
1602 ".aux-verify-elements-token",
1603 this._verifyEnvatoElementsToken.bind(this)
1604 );
1605
1606 },
1607
1608 /**
1609 * global AJAX callback
1610 */
1611 _globalAJAX: function(callback) {
1612 // Do Ajax & update default value
1613 $.ajax({
1614 url: this._ajaxUrl,
1615 type: "post",
1616 data: this._ajaxData
1617 }).done(callback);
1618 },
1619
1620 /**
1621 * refresh page
1622 */
1623
1624 _refresh: function(e) {
1625 // check preventDefault existence
1626 if (typeof e.preventDefault !== "undefined") {
1627 e.preventDefault();
1628 }
1629 location.reload();
1630 },
1631
1632 /**
1633 * Activate user license
1634 */
1635 _activateLicense: function(e) {
1636 // Check currentTarget existence
1637 if (!e.currentTarget) {
1638 return;
1639 }
1640 // check preventDefault existence
1641 if (typeof e.preventDefault !== "undefined") {
1642 e.preventDefault();
1643 }
1644
1645 // Set variables
1646 var $formElemment = $(e.currentTarget),
1647 $buttonElement = $formElemment.find(".aux-activate-license"),
1648 $noticeElement = $formElemment.find(".aux-notice"),
1649 statusClass = null,
1650 getFormInputs = {};
1651 $.each($formElemment.serializeArray(), function(i, field) {
1652 getFormInputs[field.name] = field.value;
1653 });
1654 // If the notice container is not exist, we've to add it.
1655 if (!$noticeElement.length) {
1656 $noticeElement = $("<div>", { class: "aux-notice" }).appendTo(
1657 $formElemment
1658 );
1659 }
1660 this._ajaxData = {
1661 action: getFormInputs.action,
1662 usermail: getFormInputs.usermail,
1663 purchase: getFormInputs.purchase,
1664 security: getFormInputs.security
1665 };
1666
1667 // Manipulation
1668 $buttonElement.addClass("aux-button-loading");
1669 $noticeElement.removeClass("success warning").hide();
1670
1671 this._controlActions("off");
1672 // Call AJAX with current _ajaxData value
1673 this._globalAJAX(
1674 function(response) {
1675 // Check response status
1676 if (response !== null && response.success) {
1677 // Then do these actions
1678 $buttonElement.addClass(
1679 "aux-button-success aux-refresh-page"
1680 );
1681 $noticeElement.addClass("success");
1682 statusClass = "aux-button-success aux-button-loading";
1683 $(this._modalButton)
1684 .closest(".aux-purchase-activation-notice")
1685 .fadeOut();
1686 } else {
1687 // Then do these actions
1688 $buttonElement.addClass("aux-button-error");
1689 $noticeElement.addClass("warning");
1690 statusClass = "aux-button-error aux-button-loading";
1691 }
1692 // Remove form progress class
1693 $formElemment.removeClass("aux-form-in-progress");
1694 // Actions
1695 setTimeout(function() {
1696 $buttonElement.removeClass(statusClass);
1697 $buttonElement
1698 .find("span")
1699 .text(response.data.buttonText);
1700 }, 1000);
1701 $noticeElement.show().html(response.data.message);
1702 this._controlActions("on");
1703 }.bind(this)
1704 );
1705 },
1706
1707 /**
1708 * open modal box (Based on featherlight plugin)
1709 */
1710 _openModal: function() {
1711 var self = this;
1712 // Display modal demo on click button
1713 var $advancedAjaxModal = $(self.settings.modalClass).featherlight({
1714 targetAttr: "href",
1715 closeOnEsc: false,
1716 closeOnClick: false,
1717 contentFilters: ["ajax"],
1718 loading: this.settings.loading,
1719 otherClose: ".aux-pp-close",
1720 afterOpen: function(e) {
1721 // init PerfectScrollbar
1722 if ($(".featherlight .aux-wizard-plugins").length) {
1723 var PScrollbar = new PerfectScrollbar(
1724 ".featherlight .aux-wizard-plugins"
1725 );
1726 }
1727 // Set golbal modal button
1728 self._modalButton = e.currentTarget;
1729 self.$modalElement = this.$instance;
1730 // Run template manager function
1731 if ($(self._modalButton).hasClass("aux-has-next-action")) {
1732 self._tempManager({ currentTarget: e.currentTarget });
1733 }
1734 }
1735 });
1736 var $simpleAjaxModal = $(".aux-ajax-open-modal").featherlight({
1737 targetAttr: "href",
1738 contentFilters: ["ajax"],
1739 otherClose: ".aux-pp-close",
1740 closeOnClick: false,
1741 loading: this.settings.loading,
1742 afterOpen: function(e) {
1743 // Set golbal modal button
1744 self._modalButton = e.currentTarget;
1745 self.$modalElement = this.$instance;
1746 }
1747 });
1748 // Auto open modal
1749 if ($simpleAjaxModal.data("auto-open") === 1) {
1750 $simpleAjaxModal.click();
1751 }
1752 },
1753
1754 /**
1755 * a callback to change the group of AuxIsotope (Used in the Template Kits Switcher to select modes between 'page' & 'section')
1756 */
1757 _changeGroup: function(e) {
1758 // Check currentTarget existence
1759 if (!e.currentTarget) {
1760 return;
1761 }
1762 // Set variables
1763 var groupName = e.currentTarget.checked ? "section" : "page";
1764 this._ajaxData = {
1765 action: "aux_isotope_group",
1766 group: groupName,
1767 nonce: $(e.currentTarget).data("nonce"),
1768 key: "templates_kit"
1769 };
1770 // Call AJAX with current _ajaxData value
1771 this._globalAJAX(
1772 function(response) {
1773 if (response !== null && response.success) {
1774 this.$isotopeTemplate.AuxIsotope(
1775 "changeGroup",
1776 groupName
1777 );
1778 } else {
1779 console.log(response);
1780 }
1781 }.bind(this)
1782 );
1783 },
1784
1785 /* ------------------------------------------------------------------------------ */
1786 // Update Manager
1787
1788 /**
1789 * Update manager main function
1790 */
1791 _updateManager: function(e) {
1792 // Check currentTarget existence
1793 if (!e.currentTarget) {
1794 return;
1795 }
1796 // check preventDefault existence
1797 if (typeof e.preventDefault !== "undefined") {
1798 e.preventDefault();
1799 }
1800
1801 var $buttonElement = $(e.currentTarget);
1802 this.$buttonParentEl = $buttonElement.closest(".aux-updates-step");
1803 this.$updatesListEl = this.$buttonParentEl.find(".aux-update-list");
1804 this.$updatesList = this.$updatesListEl.find(".aux-item");
1805 this._itemsCompleted = 0;
1806 this._attemptsBuffer = 0;
1807 this._currentItem = null;
1808 this._itemType = null;
1809 this._dataNonce = $buttonElement.data("nonce");
1810 this._buttonTarget = e.currentTarget;
1811 this.$currentNode = null;
1812
1813 // Manipulation
1814 this.$updatesListEl.addClass("installing");
1815 $buttonElement
1816 .text(aux_setup_params.btnworks_text)
1817 .addClass("disabled");
1818
1819 this._controlActions("off");
1820 this._processUpdates();
1821 },
1822
1823 /**
1824 * Process update elements
1825 */
1826 _processUpdates: function() {
1827 var self = this,
1828 doNext = false;
1829
1830 if (this.$currentNode) {
1831 if (!this.$currentNode.data("done_item")) {
1832 this._itemsCompleted++;
1833 this.$currentNode.data("done_item", 1);
1834 }
1835 }
1836
1837 this.$updatesList.each(function() {
1838 if (self._currentItem == null || doNext) {
1839 $(this).addClass("work-in-progress");
1840 self._currentItem = $(this).data("key");
1841 self._itemType = $(this).data("type");
1842 self.$currentNode = $(this);
1843 self._installUpdate();
1844 doNext = false;
1845 } else if ($(this).data("key") === self._currentItem) {
1846 $(this).removeClass("work-in-progress");
1847 doNext = true;
1848 }
1849 });
1850
1851 // If all plugins finished, then
1852 if (this._itemsCompleted >= this.$updatesList.length) {
1853 // Activate control actions
1854 this._controlActions("on");
1855 // Remove installing class
1856 this.$updatesListEl.removeClass("installing");
1857 // Remove disable class from button
1858 $(this._buttonTarget)
1859 .text(aux_setup_params.activate_text)
1860 .removeClass("disabled");
1861 if (this.$updatesList.not(".aux-success").length == 0) {
1862 // Refresh current page when all the plugins has been successfully updated.
1863 this._refresh({ currentTarget: this._buttonTarget });
1864 }
1865 }
1866 },
1867
1868 /**
1869 * Process update by type & key
1870 */
1871 _installUpdate: function() {
1872 if (this._currentItem) {
1873 this._ajaxData = {
1874 action: "auxin_start_upgrading",
1875 key: this._currentItem,
1876 type: this._itemType,
1877 nonce: this._dataNonce
1878 };
1879 this._globalAJAX(
1880 function(response) {
1881 this._updateActions(response);
1882 }.bind(this)
1883 );
1884 }
1885 },
1886
1887 /**
1888 * Item update events
1889 */
1890 _updateActions: function(response) {
1891 // Check response type
1892 if (typeof response === "object" && response.success) {
1893 // Update item status message
1894 this.$currentNode
1895 .find(".column-status span")
1896 .text(response.data.successMessage);
1897 // otherwise it's just installed and we should make a notify to user
1898 this.$currentNode
1899 .addClass("aux-success")
1900 .find(".aux-check-column")
1901 .remove();
1902 this.$currentNode
1903 .find(".check-column")
1904 .append(
1905 "<i class='aux-success-icon auxicon-check-mark-circle-outline'></i>"
1906 );
1907 } else {
1908 // error & try again with next item
1909 this.$currentNode
1910 .addClass("aux-error")
1911 .find(".column-status span")
1912 .text(response.data.errorMessage);
1913 }
1914 // Then jump to next item
1915 this._processUpdates();
1916 },
1917
1918 /* ------------------------------------------------------------------------------ */
1919 // Step Manager
1920
1921 /**
1922 * the step manager functionality (Used in modal box)
1923 */
1924 _stepManager: function(e) {
1925 // Check currentTarget existence
1926 if (!e.currentTarget) {
1927 return;
1928 }
1929 // check preventDefault existence
1930 if (typeof e.preventDefault !== "undefined") {
1931 e.preventDefault();
1932 }
1933 // Set variables
1934 var $buttonElement = $(e.currentTarget),
1935 $modalSectionElement = this.$modalElement.find(
1936 ".aux-steps-col"
1937 );
1938 this._ajaxData = {
1939 action: "aux_step_manager",
1940 next_step: $buttonElement.data("next-step"),
1941 nonce: $buttonElement.data("step-nonce"),
1942 args: $buttonElement.data("args"),
1943 next_action: $buttonElement.data("next-action")
1944 };
1945 // Manipulation
1946 $modalSectionElement.addClass("aux-step-in-progress");
1947 this._controlActions("off");
1948 // Call AJAX with current _ajaxData value
1949 this._globalAJAX(
1950 function(response) {
1951 if (response !== null && response.success) {
1952 $modalSectionElement
1953 .removeClass("aux-step-in-progress")
1954 .html(response.data.markup);
1955 // Run hidden action
1956 if (this._ajaxData.next_action) {
1957 this._tempManager({
1958 currentTarget: this._modalButton
1959 });
1960 }
1961 } else {
1962 console.log(response);
1963 }
1964 this._controlActions("on");
1965 }.bind(this)
1966 );
1967 },
1968
1969 /* ------------------------------------------------------------------------------ */
1970 // template Manager
1971
1972 /**
1973 * Template kits manager functionality
1974 */
1975 _tempManager: function(e) {
1976 // Check currentTarget existence
1977 if (!e.currentTarget) {
1978 return;
1979 }
1980 // check preventDefault existence
1981 if (typeof e.preventDefault !== "undefined") {
1982 e.preventDefault();
1983 }
1984 // Set variables
1985 var $buttonElement = $(e.currentTarget),
1986 $modalSectionElement =
1987 this.$modalElement != null
1988 ? this.$modalElement.find(".aux-steps-col")
1989 : null;
1990 this._ajaxData = {
1991 action: "auxin_templates_data",
1992 verify: $buttonElement.data("nonce"),
1993 ID: $buttonElement.data("template-id"),
1994 type: $buttonElement.data("template-type"),
1995 tmpl: $buttonElement.data("template-page-tmpl"),
1996 status: $buttonElement.data("status-type"),
1997 title: $buttonElement.data("template-title")
1998 };
1999 // Manipulation
2000 if (this._ajaxData.status === "copy") {
2001 $buttonElement.addClass("aux-button-loading");
2002 }
2003 this._controlActions("off");
2004 // Call AJAX with current _ajaxData value
2005 this._globalAJAX(
2006 function(response) {
2007 if (response !== null && response.success) {
2008 if (response.data.status === "copy") {
2009 // Put our data in elementor localStorage
2010 this._updateElementorLocalStorage(
2011 this._ajaxData.type,
2012 response.data.result.content
2013 );
2014 // Then do these actions
2015 $buttonElement.addClass("aux-button-success");
2016 setTimeout(function() {
2017 $buttonElement.removeClass(
2018 "aux-button-success aux-button-loading"
2019 );
2020 }, 1000);
2021 } else {
2022 // Change button type to copy
2023 $buttonElement
2024 .data("status-type", "copy")
2025 .prop("data-status-type", "copy")
2026 .addClass("aux-copy-template aux-orange")
2027 .removeClass(
2028 "aux-import-template aux-has-next-action aux-green2"
2029 )
2030 .removeAttr("href");
2031 // Change button text to copy
2032 $buttonElement
2033 .find("span")
2034 .text(response.data.label);
2035 // Display the more button
2036 $buttonElement
2037 .next(".aux-more-button")
2038 .removeClass("hide");
2039 // Update modal section data with success template
2040 $modalSectionElement.html(response.data.result);
2041 }
2042 } else {
2043 // Update modal section data with error template
2044 $modalSectionElement.html(response.data);
2045 }
2046 this._controlActions("on");
2047 }.bind(this)
2048 );
2049 },
2050
2051 /**
2052 * Update elementor localStorage data with new custom elements
2053 */
2054 _updateElementorLocalStorage: function(elementsType, elements) {
2055 this._elStorage["transfer"] = {
2056 type: "copy",
2057 elementsType: elementsType,
2058 elements: elements
2059 };
2060 localStorage.setItem("elementor", JSON.stringify(this._elStorage));
2061 },
2062
2063 /* ------------------------------------------------------------------------------ */
2064 // Demo Manager
2065
2066 /**
2067 * Demo manager main function
2068 */
2069 _demoManager: function(e) {
2070 // Check currentTarget existence
2071 if (!e.currentTarget) {
2072 return;
2073 }
2074 // check preventDefault existence
2075 if (typeof e.preventDefault !== "undefined") {
2076 e.preventDefault();
2077 }
2078 // Set variable
2079 var $buttonElement = $(e.currentTarget),
2080 $buttonParentEl = $buttonElement.closest(
2081 ".aux-setup-demo-actions"
2082 ),
2083 $buttonWrapperEl = $buttonParentEl.find(".aux-return-back"),
2084 $progressBarEl = $buttonParentEl.find(".aux-progress"),
2085 $optionsElement = this.$modalElement.find(".aux-install-demos"),
2086 $demoProgress = this.$modalElement.find(
2087 ".aux-install-demos-waiting"
2088 );
2089 this._ajaxData = {
2090 action: "auxin_demo_data",
2091 ID: $buttonElement.data("import-id"),
2092 verify: $buttonElement.data("nonce"),
2093 options: $optionsElement
2094 .find(".aux-import-parts")
2095 .serializeArray()
2096 };
2097 this.$progressBarLabelEl = $progressBarEl.find(
2098 ".aux-progress-label"
2099 );
2100
2101 // Actions
2102 $optionsElement.addClass("hide");
2103 $demoProgress.removeClass("hide");
2104 $buttonWrapperEl.addClass("hide");
2105 $progressBarEl.removeClass("hide");
2106 this.$progressBarLabelEl.text("Getting Demo Data ...");
2107
2108 this._controlActions("off");
2109 this._globalAJAX(
2110 function(response) {
2111 if (response !== null && response.success) {
2112 this._demoImport({
2113 target: e.currentTarget,
2114 step: "download",
2115 message: "Downloading Media ...",
2116 index: null
2117 });
2118 } else {
2119 console.log(response);
2120 $optionsElement.removeClass("hide");
2121 $demoProgress.addClass("hide");
2122 $buttonWrapperEl.removeClass("hide");
2123 $progressBarEl.addClass("hide");
2124 this._controlActions("on");
2125 }
2126 }.bind(this)
2127 );
2128 },
2129
2130 /**
2131 * Import step by step
2132 */
2133 _demoImport: function(data) {
2134 // Set variable
2135 this._ajaxData = {
2136 action: "import_step",
2137 step: data.step,
2138 index: data.index
2139 };
2140
2141 this.$progressBarLabelEl.text(data.message);
2142
2143 this._globalAJAX(
2144 function(response) {
2145 if (response !== null && response.success) {
2146 if (response.data.next !== "final") {
2147 this._demoImport({
2148 target: data.target,
2149 step: response.data.next,
2150 message: response.data.message,
2151 index: response.data.hasOwnProperty("index")
2152 ? response.data.index
2153 : ""
2154 });
2155 } else {
2156 this.$progressBarLabelEl.text(
2157 response.data.message
2158 );
2159 setTimeout(
2160 function() {
2161 this._controlActions("on");
2162 // Next Step Trigger
2163 this._stepManager({
2164 currentTarget: data.target
2165 });
2166 }.bind(this),
2167 1000
2168 );
2169 }
2170 } else {
2171 console.log(response);
2172 }
2173 }.bind(this)
2174 );
2175 },
2176
2177 /**
2178 * Uninstall demo functionality
2179 */
2180 _uninstallDemo: function(e) {
2181 // Check currentTarget existence
2182 if (!e.currentTarget) {
2183 return;
2184 }
2185 // check preventDefault existence
2186 if (typeof e.preventDefault !== "undefined") {
2187 e.preventDefault();
2188 }
2189 // Set variable
2190 var $buttonElement = $(e.currentTarget),
2191 $buttonParentEl = $buttonElement.closest(
2192 ".aux-setup-demo-actions"
2193 );
2194 this._ajaxData = {
2195 action: "aux_ajax_uninstall",
2196 id: $buttonElement.data("demo-id"),
2197 key: $(this._modalButton).data("demo-key"),
2198 nonce: $buttonElement.data("demo-nonce"),
2199 plugins: $buttonElement.data("demo-plugins")
2200 };
2201
2202 // Actions
2203 $buttonParentEl.find(".aux-return-back").addClass("hide");
2204 $buttonParentEl.find(".aux-progress").removeClass("hide");
2205
2206 this._controlActions("off");
2207
2208 this._globalAJAX(
2209 function(response) {
2210 $buttonParentEl
2211 .find(".aux-return-back")
2212 .removeClass("hide");
2213 $buttonParentEl.find(".aux-progress").addClass("hide");
2214
2215 if (response !== null && response.success) {
2216 this.$modalElement
2217 .find(".aux-steps-col")
2218 .html(response.data.markup);
2219 $(this._modalButton)
2220 .removeClass("aux-uninstall aux-orange")
2221 .addClass("aux-green2")
2222 .text(response.data.button)
2223 .attr("href", response.data.url);
2224 } else {
2225 console.log(response);
2226 }
2227 this._controlActions("on");
2228 }.bind(this)
2229 );
2230 },
2231
2232 /* ------------------------------------------------------------------------------ */
2233 // Plugin Manager
2234
2235 /**
2236 * Install/Activate Plugin
2237 */
2238 _pluginManager: function(e) {
2239 // Check currentTarget existence
2240 if (!e.currentTarget) {
2241 return;
2242 }
2243 // check preventDefault existence
2244 if (typeof e.preventDefault !== "undefined") {
2245 e.preventDefault();
2246 }
2247 // Set variable
2248 var $buttonElement = $(e.currentTarget);
2249 this.$buttonParentEl = $buttonElement.closest(
2250 ".aux-has-required-plugins"
2251 );
2252 this.$pluginsListEl = this.$buttonParentEl.find(
2253 ".aux-wizard-plugins"
2254 );
2255 this._selectedPluginsNum = this.$buttonParentEl.find(
2256 '.aux-plugin input[name="plugin[]"]:checked'
2257 ).length;
2258 this._itemsCompleted = 0;
2259 this._attemptsBuffer = 0;
2260 this._currentItem = null;
2261 this._buttonTarget = e.currentTarget;
2262 this.$currentNode = null;
2263
2264 // Manipulation
2265 this.$pluginsListEl.addClass("installing");
2266 $buttonElement
2267 .text(aux_setup_params.btnworks_text)
2268 .addClass("disabled");
2269
2270 this._controlActions("off");
2271 this._processPlugins();
2272 },
2273
2274 /**
2275 * Process selected plugins
2276 */
2277 _processPlugins: function() {
2278 var self = this,
2279 doNext = false,
2280 $pluginsList = this.$buttonParentEl.find(".aux-plugin");
2281
2282 // Scroll on each progress in modal view
2283 this._pluginScrollTo();
2284
2285 if (this.$currentNode) {
2286 if (!this.$currentNode.data("done_item")) {
2287 this._itemsCompleted++;
2288 this.$currentNode.data("done_item", 1);
2289 }
2290 this.$currentNode.find(".spinner").css("visibility", "hidden");
2291 }
2292
2293 $pluginsList.each(function() {
2294 if (self._currentItem == null || doNext) {
2295 if (
2296 $(this)
2297 .find('input[name="plugin[]"]')
2298 .is(":checked")
2299 ) {
2300 $(this).addClass("work-in-progress");
2301 self._currentItem = $(this).data("slug");
2302 self.$currentNode = $(this);
2303 self.$currentNode
2304 .find(".spinner")
2305 .css("visibility", "visible");
2306 self._installPlugin();
2307 doNext = false;
2308 }
2309 } else if ($(this).data("slug") === self._currentItem) {
2310 $(this).removeClass("work-in-progress");
2311 doNext = true;
2312 }
2313 });
2314
2315 // If all plugins finished, then
2316 if (this._itemsCompleted >= this._selectedPluginsNum) {
2317 // Activate control actions
2318 this._controlActions("on");
2319 // Remove installing class
2320 this.$buttonParentEl
2321 .find(".aux-wizard-plugins")
2322 .removeClass("installing");
2323 // Remove disable class from button
2324 $(this._buttonTarget).text(aux_setup_params.activate_text);
2325 // Change the text of "Skip This Step" button to "Next Step"
2326 this.$buttonParentEl
2327 .find(".skip-next")
2328 .text(aux_setup_params.nextstep_text);
2329 // Continue loading process
2330 if (
2331 this.$buttonParentEl.find(".aux-plugin").not(".aux-success")
2332 .length == 0 &&
2333 this.$buttonParentEl.hasClass("aux-modal-item")
2334 ) {
2335 // Change button text and data value if all required plugins has been installed & activated
2336 this._stepManager({ currentTarget: this._buttonTarget });
2337 }
2338 }
2339 },
2340
2341 /**
2342 * Process plugin by slug
2343 */
2344 _installPlugin: function() {
2345 if (this._currentItem) {
2346 var plugins = this.$buttonParentEl
2347 .find('.aux-wizard-plugins input[name="plugin[]"]:checked')
2348 .map(function() {
2349 return $(this).val();
2350 })
2351 .get();
2352 this._ajaxData = {
2353 action: "aux_setup_plugins",
2354 wpnonce: aux_setup_params.wpnonce,
2355 slug: this._currentItem,
2356 plugins: plugins
2357 };
2358 this._globalAJAX(
2359 function(response) {
2360 this._pluginActions(response);
2361 }.bind(this)
2362 );
2363 }
2364 },
2365
2366 /**
2367 * Plugin activation events
2368 */
2369 _pluginActions: function(response) {
2370 // Check response type
2371 if (typeof response === "object" && response.success) {
2372 // Update plugin status message
2373 this.$currentNode
2374 .find(".column-status span")
2375 .text(response.data.message);
2376 // At this point, if the response contains the url, it means that we need to install/activate it.
2377 if (typeof response.data.url !== "undefined") {
2378 if (this.currentItemHash == response.data.hash) {
2379 this.$currentNode
2380 .data("done_item", 0)
2381 .find(".column-status span")
2382 .text("failed");
2383 this.currentItemHash = null;
2384 this._installPlugin();
2385 } else {
2386 // we have an ajax url action to perform.
2387 this._ajaxUrl = response.data.url;
2388 this._ajaxData = response.data;
2389 this.currentItemHash = response.data.hash;
2390 this._globalAJAX(
2391 function(html) {
2392 // Reset ajax url to default admin ajax value
2393 this._ajaxUrl = aux_setup_params.ajaxurl;
2394 this.$currentNode
2395 .find(".column-status span")
2396 .text(response.data.message);
2397 this._installPlugin();
2398 }.bind(this)
2399 );
2400 }
2401 } else {
2402 // otherwise it's just installed and we should make a notify to user
2403 this.$currentNode
2404 .addClass("aux-success")
2405 .find(".aux-check-column")
2406 .remove();
2407 this.$currentNode
2408 .find(".check-column")
2409 .append(
2410 "<i class='aux-success-icon auxicon-check-mark-circle-outline'></i>"
2411 );
2412 // Then jump to next plugin
2413 this._processPlugins();
2414 }
2415 } else {
2416 // If there is an error, we will try to reinstall plugin twice with buffer checkup.
2417 if (this._attemptsBuffer > 1) {
2418 // Reset buffer value
2419 this._attemptsBuffer = 0;
2420 // error & try again with next plugin
2421 this.$currentNode
2422 .addClass("aux-error")
2423 .find(".column-status span")
2424 .text("Ajax Error!");
2425 this._processPlugins();
2426 } else {
2427 // Try again & update buffer value
2428 this.currentItemHash = null;
2429 this._attemptsBuffer++;
2430 this._installPlugin();
2431 }
2432 }
2433 },
2434
2435 /**
2436 * Scroll to active plugin row
2437 */
2438 _pluginScrollTo: function() {
2439 $(".aux-modal-item .aux-wizard-plugins").each(function() {
2440 $(this).scrollTo($(this).find(".work-in-progress"), 400);
2441 });
2442 },
2443
2444 /* ------------------------------------------------------------------------------ */
2445 // General Events
2446
2447 /**
2448 * Enable/Disable some control actions
2449 */
2450 _controlActions: function(type) {
2451 switch (type) {
2452 case "on":
2453 $(window).off("beforeunload");
2454 $(document).on("keydown keypress keyup");
2455 $(".aux-pp-close").removeClass("hide");
2456 break;
2457 default:
2458 $(window).on("beforeunload", function() {
2459 return aux_setup_params.onbefore_text;
2460 });
2461 $(document).off("keydown keypress keyup");
2462 $(".aux-pp-close").addClass("hide");
2463 }
2464 },
2465
2466 /**
2467 * Isotope callbacks
2468 */
2469 _callIsotope: function() {
2470 // isotope for template page
2471 this.$isotopeTemplate = $(".aux-isotope-templates").AuxIsotope({
2472 itemSelector: ".aux-iso-item",
2473 revealTransitionDuration: 0,
2474 revealBetweenDelay: 0,
2475 revealTransitionDelay: 0,
2476 hideTransitionDuration: 0,
2477 hideBetweenDelay: 0,
2478 hideTransitionDelay: 0,
2479 updateUponResize: true,
2480 transitionHelper: true,
2481 filters: ".aux-filters",
2482 slug: "filter",
2483 imgSizes: true
2484 });
2485
2486 // general isotope layout
2487 this.$isotopeList = $(".aux-isotope-list").AuxIsotope({
2488 itemSelector: ".aux-iso-item",
2489 revealTransitionDuration: 600,
2490 revealBetweenDelay: 50,
2491 revealTransitionDelay: 0,
2492 hideTransitionDuration: 300,
2493 hideBetweenDelay: 0,
2494 hideTransitionDelay: 0,
2495 updateUponResize: true,
2496 transitionHelper: true,
2497 filters: ".aux-filters",
2498 slug: "filter",
2499 imgSizes: true
2500 });
2501 // isotope for plugins list
2502 this.$isotopePlugins = $(".aux-isotope-plugins-list").AuxIsotope({
2503 itemSelector: ".aux-iso-item",
2504 revealTransitionDuration: 600,
2505 revealBetweenDelay: 50,
2506 revealTransitionDelay: 50,
2507 hideTransitionDuration: 100,
2508 hideBetweenDelay: 0,
2509 hideTransitionDelay: 0,
2510 updateUponResize: true,
2511 transitionHelper: true,
2512 filters: ".aux-filters",
2513 slug: "filter",
2514 imgSizes: true
2515 });
2516 },
2517
2518 /**
2519 * Refresh the isotope layout on load of each image
2520 */
2521 _lazyloadConfig: function() {
2522 document.addEventListener('lazyloaded', function( e ){
2523 $(window).trigger('resize');
2524 });
2525 },
2526
2527 /**
2528 * Global Manipulations
2529 */
2530 _manipulations: function() {
2531 // Auxin Toggle Select Plugin
2532 $(".aux-togglable").AuxinToggleSelected();
2533
2534 // init plugins border effect
2535 $('.aux-wizard-plugins input[name="plugin[]"]').each(function() {
2536 if ($(this).is(":checked")) {
2537 $(this)
2538 .closest(".aux-table-row")
2539 .addClass("is-checked");
2540 } else {
2541 $(this)
2542 .closest(".aux-table-row")
2543 .removeClass("is-checked");
2544 }
2545 $(this).click(function() {
2546 if ($(this).is(":checked")) {
2547 $(this)
2548 .closest(".aux-table-row")
2549 .addClass("is-checked");
2550 } else {
2551 $(this)
2552 .closest(".aux-table-row")
2553 .removeClass("is-checked");
2554 }
2555 });
2556 });
2557
2558 // Install plugins button display depends on user's checkbox selection
2559 $(".aux-plugins-step input[type=checkbox]").change(function() {
2560 if (
2561 $('.aux-wizard-plugins input[name="plugin[]"]').filter(
2562 ":checked"
2563 ).length > 0
2564 ) {
2565 $(".install-plugins").removeClass("disabled");
2566 } else {
2567 $(".install-plugins").addClass("disabled");
2568 }
2569 });
2570
2571 // Install demos button display depends on user's checkbox selection
2572 $(document).on(
2573 "click",
2574 ".aux-install-demos input[type=checkbox]",
2575 function(e) {
2576 if (
2577 $(".featherlight-content")
2578 .find("input[type=checkbox]")
2579 .filter(":checked").length > 0
2580 ) {
2581 $(".featherlight-content")
2582 .find(".button-next")
2583 .removeClass("aux-next-step")
2584 .data("callback", "install_demos")
2585 .attr("data-callback", "install_demos")
2586 .text(aux_setup_params.makedemo_text);
2587 } else {
2588 $(".featherlight-content")
2589 .find(".button-next")
2590 .addClass("aux-next-step")
2591 .text(aux_setup_params.nextstep_text)
2592 .data("callback", null)
2593 .removeAttr("data-callback");
2594 }
2595 }
2596 );
2597
2598 // a simple event to select custom demo type
2599 $(document).on("click", ".aux-radio", function(e) {
2600 $(this)
2601 .closest("form")
2602 .find(".aux-border")
2603 .removeClass("is-checked");
2604 $(this)
2605 .parent(".aux-border")
2606 .addClass("is-checked");
2607 });
2608
2609 // Display/Hide the pophover box of more button (Used in template kits three dotted button)
2610 $(document).on("click", ".aux-more-button", function(e) {
2611 e.preventDefault();
2612 $(this)
2613 .next(".aux-more-items")
2614 .toggleClass("aux-display");
2615 });
2616 },
2617
2618 /**
2619 * Get envato elements license code
2620 */
2621 _verifyEnvatoElementsEmail: function(e) {
2622
2623 // Check currentTarget existence
2624 if (!e.currentTarget) {
2625 return;
2626 }
2627
2628 var email = $('.email-field').val();
2629 var self = this;
2630 var $modalSectionElement = this.$modalElement.find(
2631 ".aux-steps-col"
2632 );
2633 this._buttonTarget = e.currentTarget
2634 this._ajaxData = {
2635 action: 'aux_verify_envato_elements_email',
2636 email: email,
2637 };
2638 $modalSectionElement.addClass("aux-step-in-progress");
2639 this._globalAJAX(
2640 function(response) {
2641 if (response.status) {
2642 self._stepManager({ currentTarget: self._buttonTarget });
2643 } else {
2644 $modalSectionElement.removeClass("aux-step-in-progress");
2645 $('.token-wrapper .result').addClass('error').text(response.message);
2646 }
2647 }
2648 );
2649 },
2650
2651 /**
2652 * verify envato elements token
2653 */
2654 _verifyEnvatoElementsToken: function(e) {
2655
2656 // Check currentTarget existence
2657 if (!e.currentTarget) {
2658 return;
2659 }
2660
2661 var token = $('.token-field').val();
2662 var self = this;
2663 var $modalSectionElement = this.$modalElement.find(
2664 ".aux-steps-col"
2665 );
2666 this._buttonTarget = e.currentTarget
2667 this._ajaxData = {
2668 action: 'aux_verify_envato_elements_token',
2669 token: token,
2670 };
2671 $modalSectionElement.addClass("aux-step-in-progress");
2672 this._globalAJAX(
2673 function(response) {
2674 if (response.status) {
2675 $modalSectionElement.removeClass("aux-step-in-progress");
2676 $('.token-wrapper .result').addClass('success').text(response.message);
2677 self._stepManager({ currentTarget: self._buttonTarget });
2678 } else {
2679 $modalSectionElement.removeClass("aux-step-in-progress");
2680 $('.token-wrapper .result').addClass('error').text(response.message);
2681 }
2682
2683 }
2684 );
2685 }
2686 });
2687
2688 // A really lightweight plugin wrapper around the constructor,
2689 // preventing against multiple instantiations
2690 $.fn[pluginName] = function(options) {
2691 return this.each(function() {
2692 new Plugin(this, options);
2693 });
2694 };
2695 })(jQuery, window, document);