PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / 2.5.13
Shortcodes and extra features for Phlox theme v2.5.13
2.17.22 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 6 years ago solo 6 years ago tinymce 9 years ago index.php 10 years ago plugins.js 6 years ago plugins.min.js 7 years ago scripts.js 7 years ago
plugins.js
2611 lines
1 /*! Phlox Core Plugin - v2.5.13 (2020-05-03)
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
1593 /**
1594 * global AJAX callback
1595 */
1596 _globalAJAX: function(callback) {
1597 // Do Ajax & update default value
1598 $.ajax({
1599 url: this._ajaxUrl,
1600 type: "post",
1601 data: this._ajaxData
1602 }).done(callback);
1603 },
1604
1605 /**
1606 * refresh page
1607 */
1608
1609 _refresh: function(e) {
1610 // check preventDefault existence
1611 if (typeof e.preventDefault !== "undefined") {
1612 e.preventDefault();
1613 }
1614 location.reload();
1615 },
1616
1617 /**
1618 * Activate user license
1619 */
1620 _activateLicense: function(e) {
1621 // Check currentTarget existence
1622 if (!e.currentTarget) {
1623 return;
1624 }
1625 // check preventDefault existence
1626 if (typeof e.preventDefault !== "undefined") {
1627 e.preventDefault();
1628 }
1629
1630 // Set variables
1631 var $formElemment = $(e.currentTarget),
1632 $buttonElement = $formElemment.find(".aux-activate-license"),
1633 $noticeElement = $formElemment.find(".aux-notice"),
1634 statusClass = null,
1635 getFormInputs = {};
1636 $.each($formElemment.serializeArray(), function(i, field) {
1637 getFormInputs[field.name] = field.value;
1638 });
1639 // If the notice container is not exist, we've to add it.
1640 if (!$noticeElement.length) {
1641 $noticeElement = $("<div>", { class: "aux-notice" }).appendTo(
1642 $formElemment
1643 );
1644 }
1645 this._ajaxData = {
1646 action: getFormInputs.action,
1647 usermail: getFormInputs.usermail,
1648 purchase: getFormInputs.purchase,
1649 security: getFormInputs.security
1650 };
1651
1652 // Manipulation
1653 $buttonElement.addClass("aux-button-loading");
1654 $noticeElement.removeClass("success warning").hide();
1655
1656 this._controlActions("off");
1657 // Call AJAX with current _ajaxData value
1658 this._globalAJAX(
1659 function(response) {
1660 // Check response status
1661 if (response !== null && response.success) {
1662 // Then do these actions
1663 $buttonElement.addClass(
1664 "aux-button-success aux-refresh-page"
1665 );
1666 $noticeElement.addClass("success");
1667 statusClass = "aux-button-success aux-button-loading";
1668 $(this._modalButton)
1669 .closest(".aux-purchase-activation-notice")
1670 .fadeOut();
1671 } else {
1672 // Then do these actions
1673 $buttonElement.addClass("aux-button-error");
1674 $noticeElement.addClass("warning");
1675 statusClass = "aux-button-error aux-button-loading";
1676 }
1677 // Remove form progress class
1678 $formElemment.removeClass("aux-form-in-progress");
1679 // Actions
1680 setTimeout(function() {
1681 $buttonElement.removeClass(statusClass);
1682 $buttonElement
1683 .find("span")
1684 .text(response.data.buttonText);
1685 }, 1000);
1686 $noticeElement.show().html(response.data.message);
1687 this._controlActions("on");
1688 }.bind(this)
1689 );
1690 },
1691
1692 /**
1693 * open modal box (Based on featherlight plugin)
1694 */
1695 _openModal: function() {
1696 var self = this;
1697 // Display modal demo on click button
1698 var $advancedAjaxModal = $(self.settings.modalClass).featherlight({
1699 targetAttr: "href",
1700 closeOnEsc: false,
1701 closeOnClick: false,
1702 contentFilters: ["ajax"],
1703 loading: this.settings.loading,
1704 otherClose: ".aux-pp-close",
1705 afterOpen: function(e) {
1706 // init PerfectScrollbar
1707 if ($(".featherlight .aux-wizard-plugins").length) {
1708 var PScrollbar = new PerfectScrollbar(
1709 ".featherlight .aux-wizard-plugins"
1710 );
1711 }
1712 // Set golbal modal button
1713 self._modalButton = e.currentTarget;
1714 self.$modalElement = this.$instance;
1715 // Run template manager function
1716 if ($(self._modalButton).hasClass("aux-has-next-action")) {
1717 self._tempManager({ currentTarget: e.currentTarget });
1718 }
1719 }
1720 });
1721 var $simpleAjaxModal = $(".aux-ajax-open-modal").featherlight({
1722 targetAttr: "href",
1723 contentFilters: ["ajax"],
1724 otherClose: ".aux-pp-close",
1725 closeOnClick: false,
1726 loading: this.settings.loading,
1727 afterOpen: function(e) {
1728 // Set golbal modal button
1729 self._modalButton = e.currentTarget;
1730 self.$modalElement = this.$instance;
1731 }
1732 });
1733 // Auto open modal
1734 if ($simpleAjaxModal.data("auto-open") === 1) {
1735 $simpleAjaxModal.click();
1736 }
1737 },
1738
1739 /**
1740 * a callback to change the group of AuxIsotope (Used in the Template Kits Switcher to select modes between 'page' & 'section')
1741 */
1742 _changeGroup: function(e) {
1743 // Check currentTarget existence
1744 if (!e.currentTarget) {
1745 return;
1746 }
1747 // Set variables
1748 var groupName = e.currentTarget.checked ? "section" : "page";
1749 this._ajaxData = {
1750 action: "aux_isotope_group",
1751 group: groupName,
1752 nonce: $(e.currentTarget).data("nonce"),
1753 key: "templates_kit"
1754 };
1755 // Call AJAX with current _ajaxData value
1756 this._globalAJAX(
1757 function(response) {
1758 if (response !== null && response.success) {
1759 this.$isotopeTemplate.AuxIsotope(
1760 "changeGroup",
1761 groupName
1762 );
1763 } else {
1764 console.log(response);
1765 }
1766 }.bind(this)
1767 );
1768 },
1769
1770 /* ------------------------------------------------------------------------------ */
1771 // Update Manager
1772
1773 /**
1774 * Update manager main function
1775 */
1776 _updateManager: function(e) {
1777 // Check currentTarget existence
1778 if (!e.currentTarget) {
1779 return;
1780 }
1781 // check preventDefault existence
1782 if (typeof e.preventDefault !== "undefined") {
1783 e.preventDefault();
1784 }
1785
1786 var $buttonElement = $(e.currentTarget);
1787 this.$buttonParentEl = $buttonElement.closest(".aux-updates-step");
1788 this.$updatesListEl = this.$buttonParentEl.find(".aux-update-list");
1789 this.$updatesList = this.$updatesListEl.find(".aux-item");
1790 this._itemsCompleted = 0;
1791 this._attemptsBuffer = 0;
1792 this._currentItem = null;
1793 this._itemType = null;
1794 this._dataNonce = $buttonElement.data("nonce");
1795 this._buttonTarget = e.currentTarget;
1796 this.$currentNode = null;
1797
1798 // Manipulation
1799 this.$updatesListEl.addClass("installing");
1800 $buttonElement
1801 .text(aux_setup_params.btnworks_text)
1802 .addClass("disabled");
1803
1804 this._controlActions("off");
1805 this._processUpdates();
1806 },
1807
1808 /**
1809 * Process update elements
1810 */
1811 _processUpdates: function() {
1812 var self = this,
1813 doNext = false;
1814
1815 if (this.$currentNode) {
1816 if (!this.$currentNode.data("done_item")) {
1817 this._itemsCompleted++;
1818 this.$currentNode.data("done_item", 1);
1819 }
1820 }
1821
1822 this.$updatesList.each(function() {
1823 if (self._currentItem == null || doNext) {
1824 $(this).addClass("work-in-progress");
1825 self._currentItem = $(this).data("key");
1826 self._itemType = $(this).data("type");
1827 self.$currentNode = $(this);
1828 self._installUpdate();
1829 doNext = false;
1830 } else if ($(this).data("key") === self._currentItem) {
1831 $(this).removeClass("work-in-progress");
1832 doNext = true;
1833 }
1834 });
1835
1836 // If all plugins finished, then
1837 if (this._itemsCompleted >= this.$updatesList.length) {
1838 // Activate control actions
1839 this._controlActions("on");
1840 // Remove installing class
1841 this.$updatesListEl.removeClass("installing");
1842 // Remove disable class from button
1843 $(this._buttonTarget)
1844 .text(aux_setup_params.activate_text)
1845 .removeClass("disabled");
1846 if (this.$updatesList.not(".aux-success").length == 0) {
1847 // Refresh current page when all the plugins has been successfully updated.
1848 this._refresh({ currentTarget: this._buttonTarget });
1849 }
1850 }
1851 },
1852
1853 /**
1854 * Process update by type & key
1855 */
1856 _installUpdate: function() {
1857 if (this._currentItem) {
1858 this._ajaxData = {
1859 action: "auxin_start_upgrading",
1860 key: this._currentItem,
1861 type: this._itemType,
1862 nonce: this._dataNonce
1863 };
1864 this._globalAJAX(
1865 function(response) {
1866 this._updateActions(response);
1867 }.bind(this)
1868 );
1869 }
1870 },
1871
1872 /**
1873 * Item update events
1874 */
1875 _updateActions: function(response) {
1876 // Check response type
1877 if (typeof response === "object" && response.success) {
1878 // Update item status message
1879 this.$currentNode
1880 .find(".column-status span")
1881 .text(response.data.successMessage);
1882 // otherwise it's just installed and we should make a notify to user
1883 this.$currentNode
1884 .addClass("aux-success")
1885 .find(".aux-check-column")
1886 .remove();
1887 this.$currentNode
1888 .find(".check-column")
1889 .append(
1890 "<i class='aux-success-icon auxicon-check-mark-circle-outline'></i>"
1891 );
1892 } else {
1893 // error & try again with next item
1894 this.$currentNode
1895 .addClass("aux-error")
1896 .find(".column-status span")
1897 .text(response.data.errorMessage);
1898 }
1899 // Then jump to next item
1900 this._processUpdates();
1901 },
1902
1903 /* ------------------------------------------------------------------------------ */
1904 // Step Manager
1905
1906 /**
1907 * the step manager functionality (Used in modal box)
1908 */
1909 _stepManager: function(e) {
1910 // Check currentTarget existence
1911 if (!e.currentTarget) {
1912 return;
1913 }
1914 // check preventDefault existence
1915 if (typeof e.preventDefault !== "undefined") {
1916 e.preventDefault();
1917 }
1918 // Set variables
1919 var $buttonElement = $(e.currentTarget),
1920 $modalSectionElement = this.$modalElement.find(
1921 ".aux-steps-col"
1922 );
1923 this._ajaxData = {
1924 action: "aux_step_manager",
1925 next_step: $buttonElement.data("next-step"),
1926 nonce: $buttonElement.data("step-nonce"),
1927 args: $buttonElement.data("args"),
1928 next_action: $buttonElement.data("next-action")
1929 };
1930 // Manipulation
1931 $modalSectionElement.addClass("aux-step-in-progress");
1932 this._controlActions("off");
1933 // Call AJAX with current _ajaxData value
1934 this._globalAJAX(
1935 function(response) {
1936 if (response !== null && response.success) {
1937 $modalSectionElement
1938 .removeClass("aux-step-in-progress")
1939 .html(response.data.markup);
1940 // Run hidden action
1941 if (this._ajaxData.next_action) {
1942 this._tempManager({
1943 currentTarget: this._modalButton
1944 });
1945 }
1946 } else {
1947 console.log(response);
1948 }
1949 this._controlActions("on");
1950 }.bind(this)
1951 );
1952 },
1953
1954 /* ------------------------------------------------------------------------------ */
1955 // template Manager
1956
1957 /**
1958 * Template kits manager functionality
1959 */
1960 _tempManager: function(e) {
1961 // Check currentTarget existence
1962 if (!e.currentTarget) {
1963 return;
1964 }
1965 // check preventDefault existence
1966 if (typeof e.preventDefault !== "undefined") {
1967 e.preventDefault();
1968 }
1969 // Set variables
1970 var $buttonElement = $(e.currentTarget),
1971 $modalSectionElement =
1972 this.$modalElement != null
1973 ? this.$modalElement.find(".aux-steps-col")
1974 : null;
1975 this._ajaxData = {
1976 action: "auxin_templates_data",
1977 verify: $buttonElement.data("nonce"),
1978 ID: $buttonElement.data("template-id"),
1979 type: $buttonElement.data("template-type"),
1980 tmpl: $buttonElement.data("template-page-tmpl"),
1981 status: $buttonElement.data("status-type"),
1982 title: $buttonElement.data("template-title")
1983 };
1984 // Manipulation
1985 if (this._ajaxData.status === "copy") {
1986 $buttonElement.addClass("aux-button-loading");
1987 }
1988 this._controlActions("off");
1989 // Call AJAX with current _ajaxData value
1990 this._globalAJAX(
1991 function(response) {
1992 if (response !== null && response.success) {
1993 if (response.data.status === "copy") {
1994 // Put our data in elementor localStorage
1995 this._updateElementorLocalStorage(
1996 this._ajaxData.type,
1997 response.data.result.content
1998 );
1999 // Then do these actions
2000 $buttonElement.addClass("aux-button-success");
2001 setTimeout(function() {
2002 $buttonElement.removeClass(
2003 "aux-button-success aux-button-loading"
2004 );
2005 }, 1000);
2006 } else {
2007 // Change button type to copy
2008 $buttonElement
2009 .data("status-type", "copy")
2010 .prop("data-status-type", "copy")
2011 .addClass("aux-copy-template aux-orange")
2012 .removeClass(
2013 "aux-import-template aux-has-next-action aux-green2"
2014 )
2015 .removeAttr("href");
2016 // Change button text to copy
2017 $buttonElement
2018 .find("span")
2019 .text(response.data.label);
2020 // Display the more button
2021 $buttonElement
2022 .next(".aux-more-button")
2023 .removeClass("hide");
2024 // Update modal section data with success template
2025 $modalSectionElement.html(response.data.result);
2026 }
2027 } else {
2028 // Update modal section data with error template
2029 $modalSectionElement.html(response.data);
2030 }
2031 this._controlActions("on");
2032 }.bind(this)
2033 );
2034 },
2035
2036 /**
2037 * Update elementor localStorage data with new custom elements
2038 */
2039 _updateElementorLocalStorage: function(elementsType, elements) {
2040 this._elStorage["transfer"] = {
2041 type: "copy",
2042 elementsType: elementsType,
2043 elements: elements
2044 };
2045 localStorage.setItem("elementor", JSON.stringify(this._elStorage));
2046 },
2047
2048 /* ------------------------------------------------------------------------------ */
2049 // Demo Manager
2050
2051 /**
2052 * Demo manager main function
2053 */
2054 _demoManager: function(e) {
2055 // Check currentTarget existence
2056 if (!e.currentTarget) {
2057 return;
2058 }
2059 // check preventDefault existence
2060 if (typeof e.preventDefault !== "undefined") {
2061 e.preventDefault();
2062 }
2063 // Set variable
2064 var $buttonElement = $(e.currentTarget),
2065 $buttonParentEl = $buttonElement.closest(
2066 ".aux-setup-demo-actions"
2067 ),
2068 $buttonWrapperEl = $buttonParentEl.find(".aux-return-back"),
2069 $progressBarEl = $buttonParentEl.find(".aux-progress"),
2070 $optionsElement = this.$modalElement.find(".aux-install-demos"),
2071 $demoProgress = this.$modalElement.find(
2072 ".aux-install-demos-waiting"
2073 );
2074 this._ajaxData = {
2075 action: "auxin_demo_data",
2076 ID: $buttonElement.data("import-id"),
2077 verify: $buttonElement.data("nonce"),
2078 options: $optionsElement
2079 .find(".aux-import-parts")
2080 .serializeArray()
2081 };
2082 this.$progressBarLabelEl = $progressBarEl.find(
2083 ".aux-progress-label"
2084 );
2085
2086 // Actions
2087 $optionsElement.addClass("hide");
2088 $demoProgress.removeClass("hide");
2089 $buttonWrapperEl.addClass("hide");
2090 $progressBarEl.removeClass("hide");
2091 this.$progressBarLabelEl.text("Getting Demo Data ...");
2092
2093 this._controlActions("off");
2094 this._globalAJAX(
2095 function(response) {
2096 if (response !== null && response.success) {
2097 this._demoImport({
2098 target: e.currentTarget,
2099 step: "download",
2100 message: "Downloading Media ...",
2101 index: null
2102 });
2103 } else {
2104 console.log(response);
2105 $optionsElement.removeClass("hide");
2106 $demoProgress.addClass("hide");
2107 $buttonWrapperEl.removeClass("hide");
2108 $progressBarEl.addClass("hide");
2109 this._controlActions("on");
2110 }
2111 }.bind(this)
2112 );
2113 },
2114
2115 /**
2116 * Import step by step
2117 */
2118 _demoImport: function(data) {
2119 // Set variable
2120 this._ajaxData = {
2121 action: "import_step",
2122 step: data.step,
2123 index: data.index
2124 };
2125
2126 this.$progressBarLabelEl.text(data.message);
2127
2128 this._globalAJAX(
2129 function(response) {
2130 if (response !== null && response.success) {
2131 if (response.data.next !== "final") {
2132 this._demoImport({
2133 target: data.target,
2134 step: response.data.next,
2135 message: response.data.message,
2136 index: response.data.hasOwnProperty("index")
2137 ? response.data.index
2138 : ""
2139 });
2140 } else {
2141 this.$progressBarLabelEl.text(
2142 response.data.message
2143 );
2144 setTimeout(
2145 function() {
2146 this._controlActions("on");
2147 // Next Step Trigger
2148 this._stepManager({
2149 currentTarget: data.target
2150 });
2151 }.bind(this),
2152 1000
2153 );
2154 }
2155 } else {
2156 console.log(response);
2157 }
2158 }.bind(this)
2159 );
2160 },
2161
2162 /**
2163 * Uninstall demo functionality
2164 */
2165 _uninstallDemo: function(e) {
2166 // Check currentTarget existence
2167 if (!e.currentTarget) {
2168 return;
2169 }
2170 // check preventDefault existence
2171 if (typeof e.preventDefault !== "undefined") {
2172 e.preventDefault();
2173 }
2174 // Set variable
2175 var $buttonElement = $(e.currentTarget),
2176 $buttonParentEl = $buttonElement.closest(
2177 ".aux-setup-demo-actions"
2178 );
2179 this._ajaxData = {
2180 action: "aux_ajax_uninstall",
2181 id: $buttonElement.data("demo-id"),
2182 key: $(this._modalButton).data("demo-key"),
2183 nonce: $buttonElement.data("demo-nonce"),
2184 plugins: $buttonElement.data("demo-plugins")
2185 };
2186
2187 // Actions
2188 $buttonParentEl.find(".aux-return-back").addClass("hide");
2189 $buttonParentEl.find(".aux-progress").removeClass("hide");
2190
2191 this._controlActions("off");
2192
2193 this._globalAJAX(
2194 function(response) {
2195 $buttonParentEl
2196 .find(".aux-return-back")
2197 .removeClass("hide");
2198 $buttonParentEl.find(".aux-progress").addClass("hide");
2199
2200 if (response !== null && response.success) {
2201 this.$modalElement
2202 .find(".aux-steps-col")
2203 .html(response.data.markup);
2204 $(this._modalButton)
2205 .removeClass("aux-uninstall aux-orange")
2206 .addClass("aux-green2")
2207 .text(response.data.button)
2208 .attr("href", response.data.url);
2209 } else {
2210 console.log(response);
2211 }
2212 this._controlActions("on");
2213 }.bind(this)
2214 );
2215 },
2216
2217 /* ------------------------------------------------------------------------------ */
2218 // Plugin Manager
2219
2220 /**
2221 * Install/Activate Plugin
2222 */
2223 _pluginManager: function(e) {
2224 // Check currentTarget existence
2225 if (!e.currentTarget) {
2226 return;
2227 }
2228 // check preventDefault existence
2229 if (typeof e.preventDefault !== "undefined") {
2230 e.preventDefault();
2231 }
2232 // Set variable
2233 var $buttonElement = $(e.currentTarget);
2234 this.$buttonParentEl = $buttonElement.closest(
2235 ".aux-has-required-plugins"
2236 );
2237 this.$pluginsListEl = this.$buttonParentEl.find(
2238 ".aux-wizard-plugins"
2239 );
2240 this._selectedPluginsNum = this.$buttonParentEl.find(
2241 '.aux-plugin input[name="plugin[]"]:checked'
2242 ).length;
2243 this._itemsCompleted = 0;
2244 this._attemptsBuffer = 0;
2245 this._currentItem = null;
2246 this._buttonTarget = e.currentTarget;
2247 this.$currentNode = null;
2248
2249 // Manipulation
2250 this.$pluginsListEl.addClass("installing");
2251 $buttonElement
2252 .text(aux_setup_params.btnworks_text)
2253 .addClass("disabled");
2254
2255 this._controlActions("off");
2256 this._processPlugins();
2257 },
2258
2259 /**
2260 * Process selected plugins
2261 */
2262 _processPlugins: function() {
2263 var self = this,
2264 doNext = false,
2265 $pluginsList = this.$buttonParentEl.find(".aux-plugin");
2266
2267 // Scroll on each progress in modal view
2268 this._pluginScrollTo();
2269
2270 if (this.$currentNode) {
2271 if (!this.$currentNode.data("done_item")) {
2272 this._itemsCompleted++;
2273 this.$currentNode.data("done_item", 1);
2274 }
2275 this.$currentNode.find(".spinner").css("visibility", "hidden");
2276 }
2277
2278 $pluginsList.each(function() {
2279 if (self._currentItem == null || doNext) {
2280 if (
2281 $(this)
2282 .find('input[name="plugin[]"]')
2283 .is(":checked")
2284 ) {
2285 $(this).addClass("work-in-progress");
2286 self._currentItem = $(this).data("slug");
2287 self.$currentNode = $(this);
2288 self.$currentNode
2289 .find(".spinner")
2290 .css("visibility", "visible");
2291 self._installPlugin();
2292 doNext = false;
2293 }
2294 } else if ($(this).data("slug") === self._currentItem) {
2295 $(this).removeClass("work-in-progress");
2296 doNext = true;
2297 }
2298 });
2299
2300 // If all plugins finished, then
2301 if (this._itemsCompleted >= this._selectedPluginsNum) {
2302 // Activate control actions
2303 this._controlActions("on");
2304 // Remove installing class
2305 this.$buttonParentEl
2306 .find(".aux-wizard-plugins")
2307 .removeClass("installing");
2308 // Remove disable class from button
2309 $(this._buttonTarget).text(aux_setup_params.activate_text);
2310 // Change the text of "Skip This Step" button to "Next Step"
2311 this.$buttonParentEl
2312 .find(".skip-next")
2313 .text(aux_setup_params.nextstep_text);
2314 // Continue loading process
2315 if (
2316 this.$buttonParentEl.find(".aux-plugin").not(".aux-success")
2317 .length == 0 &&
2318 this.$buttonParentEl.hasClass("aux-modal-item")
2319 ) {
2320 // Change button text and data value if all required plugins has been installed & activated
2321 this._stepManager({ currentTarget: this._buttonTarget });
2322 }
2323 }
2324 },
2325
2326 /**
2327 * Process plugin by slug
2328 */
2329 _installPlugin: function() {
2330 if (this._currentItem) {
2331 var plugins = this.$buttonParentEl
2332 .find('.aux-wizard-plugins input[name="plugin[]"]:checked')
2333 .map(function() {
2334 return $(this).val();
2335 })
2336 .get();
2337 this._ajaxData = {
2338 action: "aux_setup_plugins",
2339 wpnonce: aux_setup_params.wpnonce,
2340 slug: this._currentItem,
2341 plugins: plugins
2342 };
2343 this._globalAJAX(
2344 function(response) {
2345 this._pluginActions(response);
2346 }.bind(this)
2347 );
2348 }
2349 },
2350
2351 /**
2352 * Plugin activation events
2353 */
2354 _pluginActions: function(response) {
2355 // Check response type
2356 if (typeof response === "object" && response.success) {
2357 // Update plugin status message
2358 this.$currentNode
2359 .find(".column-status span")
2360 .text(response.data.message);
2361 // At this point, if the response contains the url, it means that we need to install/activate it.
2362 if (typeof response.data.url !== "undefined") {
2363 if (this.currentItemHash == response.data.hash) {
2364 this.$currentNode
2365 .data("done_item", 0)
2366 .find(".column-status span")
2367 .text("failed");
2368 this.currentItemHash = null;
2369 this._installPlugin();
2370 } else {
2371 // we have an ajax url action to perform.
2372 this._ajaxUrl = response.data.url;
2373 this._ajaxData = response.data;
2374 this.currentItemHash = response.data.hash;
2375 this._globalAJAX(
2376 function(html) {
2377 // Reset ajax url to default admin ajax value
2378 this._ajaxUrl = aux_setup_params.ajaxurl;
2379 this.$currentNode
2380 .find(".column-status span")
2381 .text(response.data.message);
2382 this._installPlugin();
2383 }.bind(this)
2384 );
2385 }
2386 } else {
2387 // otherwise it's just installed and we should make a notify to user
2388 this.$currentNode
2389 .addClass("aux-success")
2390 .find(".aux-check-column")
2391 .remove();
2392 this.$currentNode
2393 .find(".check-column")
2394 .append(
2395 "<i class='aux-success-icon auxicon-check-mark-circle-outline'></i>"
2396 );
2397 // Then jump to next plugin
2398 this._processPlugins();
2399 }
2400 } else {
2401 // If there is an error, we will try to reinstall plugin twice with buffer checkup.
2402 if (this._attemptsBuffer > 1) {
2403 // Reset buffer value
2404 this._attemptsBuffer = 0;
2405 // error & try again with next plugin
2406 this.$currentNode
2407 .addClass("aux-error")
2408 .find(".column-status span")
2409 .text("Ajax Error!");
2410 this._processPlugins();
2411 } else {
2412 // Try again & update buffer value
2413 this.currentItemHash = null;
2414 this._attemptsBuffer++;
2415 this._installPlugin();
2416 }
2417 }
2418 },
2419
2420 /**
2421 * Scroll to active plugin row
2422 */
2423 _pluginScrollTo: function() {
2424 $(".aux-modal-item .aux-wizard-plugins").each(function() {
2425 $(this).scrollTo($(this).find(".work-in-progress"), 400);
2426 });
2427 },
2428
2429 /* ------------------------------------------------------------------------------ */
2430 // General Events
2431
2432 /**
2433 * Enable/Disable some control actions
2434 */
2435 _controlActions: function(type) {
2436 switch (type) {
2437 case "on":
2438 $(window).off("beforeunload");
2439 $(document).on("keydown keypress keyup");
2440 $(".aux-pp-close").removeClass("hide");
2441 break;
2442 default:
2443 $(window).on("beforeunload", function() {
2444 return aux_setup_params.onbefore_text;
2445 });
2446 $(document).off("keydown keypress keyup");
2447 $(".aux-pp-close").addClass("hide");
2448 }
2449 },
2450
2451 /**
2452 * Isotope callbacks
2453 */
2454 _callIsotope: function() {
2455 // isotope for template page
2456 this.$isotopeTemplate = $(".aux-isotope-templates").AuxIsotope({
2457 itemSelector: ".aux-iso-item",
2458 revealTransitionDuration: 0,
2459 revealBetweenDelay: 0,
2460 revealTransitionDelay: 0,
2461 hideTransitionDuration: 0,
2462 hideBetweenDelay: 0,
2463 hideTransitionDelay: 0,
2464 updateUponResize: true,
2465 transitionHelper: true,
2466 filters: ".aux-filters",
2467 slug: "filter",
2468 imgSizes: true
2469 });
2470
2471 // general isotope layout
2472 this.$isotopeList = $(".aux-isotope-list").AuxIsotope({
2473 itemSelector: ".aux-iso-item",
2474 revealTransitionDuration: 600,
2475 revealBetweenDelay: 50,
2476 revealTransitionDelay: 0,
2477 hideTransitionDuration: 300,
2478 hideBetweenDelay: 0,
2479 hideTransitionDelay: 0,
2480 updateUponResize: true,
2481 transitionHelper: true,
2482 filters: ".aux-filters",
2483 slug: "filter",
2484 imgSizes: true
2485 });
2486 // isotope for plugins list
2487 this.$isotopePlugins = $(".aux-isotope-plugins-list").AuxIsotope({
2488 itemSelector: ".aux-iso-item",
2489 revealTransitionDuration: 600,
2490 revealBetweenDelay: 50,
2491 revealTransitionDelay: 50,
2492 hideTransitionDuration: 100,
2493 hideBetweenDelay: 0,
2494 hideTransitionDelay: 0,
2495 updateUponResize: true,
2496 transitionHelper: true,
2497 filters: ".aux-filters",
2498 slug: "filter",
2499 imgSizes: true
2500 });
2501 },
2502
2503 /**
2504 * Refresh the isotope layout on load of each image
2505 */
2506 _lazyloadConfig: function() {
2507 document.addEventListener('lazyloaded', function( e ){
2508 $(window).trigger('resize');
2509 });
2510 },
2511
2512 /**
2513 * Global Manipulations
2514 */
2515 _manipulations: function() {
2516 // Auxin Toggle Select Plugin
2517 $(".aux-togglable").AuxinToggleSelected();
2518
2519 // init plugins border effect
2520 $('.aux-wizard-plugins input[name="plugin[]"]').each(function() {
2521 if ($(this).is(":checked")) {
2522 $(this)
2523 .closest(".aux-table-row")
2524 .addClass("is-checked");
2525 } else {
2526 $(this)
2527 .closest(".aux-table-row")
2528 .removeClass("is-checked");
2529 }
2530 $(this).click(function() {
2531 if ($(this).is(":checked")) {
2532 $(this)
2533 .closest(".aux-table-row")
2534 .addClass("is-checked");
2535 } else {
2536 $(this)
2537 .closest(".aux-table-row")
2538 .removeClass("is-checked");
2539 }
2540 });
2541 });
2542
2543 // Install plugins button display depends on user's checkbox selection
2544 $(".aux-plugins-step input[type=checkbox]").change(function() {
2545 if (
2546 $('.aux-wizard-plugins input[name="plugin[]"]').filter(
2547 ":checked"
2548 ).length > 0
2549 ) {
2550 $(".install-plugins").removeClass("disabled");
2551 } else {
2552 $(".install-plugins").addClass("disabled");
2553 }
2554 });
2555
2556 // Install demos button display depends on user's checkbox selection
2557 $(document).on(
2558 "click",
2559 ".aux-install-demos input[type=checkbox]",
2560 function(e) {
2561 if (
2562 $(".featherlight-content")
2563 .find("input[type=checkbox]")
2564 .filter(":checked").length > 0
2565 ) {
2566 $(".featherlight-content")
2567 .find(".button-next")
2568 .removeClass("aux-next-step")
2569 .data("callback", "install_demos")
2570 .attr("data-callback", "install_demos")
2571 .text(aux_setup_params.makedemo_text);
2572 } else {
2573 $(".featherlight-content")
2574 .find(".button-next")
2575 .addClass("aux-next-step")
2576 .text(aux_setup_params.nextstep_text)
2577 .data("callback", null)
2578 .removeAttr("data-callback");
2579 }
2580 }
2581 );
2582
2583 // a simple event to select custom demo type
2584 $(document).on("click", ".aux-radio", function(e) {
2585 $(this)
2586 .closest("form")
2587 .find(".aux-border")
2588 .removeClass("is-checked");
2589 $(this)
2590 .parent(".aux-border")
2591 .addClass("is-checked");
2592 });
2593
2594 // Display/Hide the pophover box of more button (Used in template kits three dotted button)
2595 $(document).on("click", ".aux-more-button", function(e) {
2596 e.preventDefault();
2597 $(this)
2598 .next(".aux-more-items")
2599 .toggleClass("aux-display");
2600 });
2601 }
2602 });
2603
2604 // A really lightweight plugin wrapper around the constructor,
2605 // preventing against multiple instantiations
2606 $.fn[pluginName] = function(options) {
2607 return this.each(function() {
2608 new Plugin(this, options);
2609 });
2610 };
2611 })(jQuery, window, document);