PluginProbe
Boxzilla – WordPress Popup Builder / 3.2
Boxzilla – WordPress Popup Builder v3.2
3.4.11 3.4.10 3.4.9 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 trunk 3.0 3.0.1 3.0.2 3.0.3 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 All 72 releases
← All changes | assets/js/admin-script.js +186 -131 3.03.2 View file →
@@ -1,134 +1,176 @@
1 -(function () { var require = undefined; var define = undefined; (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
1 +(function () { var require = undefined; var module = undefined; var exports = undefined; var define = undefined; (function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(require,module,exports){
2 +'use strict';
3 +
2 4 window.Boxzilla_Admin = require('./admin/_admin.js');
5 +
3 6 },{"./admin/_admin.js":2}],2:[function(require,module,exports){
4 7 'use strict';
5 8
6 -var $ = window.jQuery;
7 -var Option = require('./_option.js');
8 -var optionControls = document.getElementById('boxzilla-box-options-controls');
9 -var $optionControls = $(optionControls);
9 +(function () {
10 + 'use strict';
10 11
11 -// sanity check, are we on the correct page?
12 -if( $optionControls.length === 0 ) {
13 - return;
14 -}
12 + var $ = window.jQuery;
13 + var Option = require('./_option.js');
14 + var optionControls = document.getElementById('boxzilla-box-options-controls');
15 + var $optionControls = $(optionControls);
16 + var tnLoggedIn = document.createTextNode(' logged in');
15 17
16 -var EventEmitter = require('wolfy87-eventemitter');
17 -var events = new EventEmitter();
18 -var Designer = require('./_designer.js')($, Option, events);
19 -var rowTemplate = wp.template('rule-row-template');
20 -var i18n = boxzilla_i18n;
18 + // sanity check, are we on the correct page?
19 + if ($optionControls.length === 0) {
20 + return;
21 + }
21 22
22 -// events
23 -$optionControls.on('click', ".boxzilla-add-rule", addRuleFields);
24 -$optionControls.on('click', ".boxzilla-remove-rule", removeRule);
25 -$optionControls.on('change', ".boxzilla-rule-condition", setContextualHelpers);
26 -$optionControls.find('.boxzilla-auto-show-trigger').on('change', toggleTriggerOptions );
23 + var EventEmitter = require('wolfy87-eventemitter');
24 + var events = new EventEmitter();
25 + var Designer = require('./_designer.js')($, Option, events);
26 + var rowTemplate = wp.template('rule-row-template');
27 + var i18n = boxzilla_i18n;
27 28
28 -$(window).load(function() {
29 - if( typeof(window.tinyMCE) === "undefined" ) {
30 - document.getElementById('notice-notinymce').style.display = '';
31 - }
32 -});
29 + // events
30 + $optionControls.on('click', ".boxzilla-add-rule", addRuleFields);
31 + $optionControls.on('click', ".boxzilla-remove-rule", removeRule);
32 + $optionControls.on('change', ".boxzilla-rule-condition", setContextualHelpers);
33 + $optionControls.find('.boxzilla-auto-show-trigger').on('change', toggleTriggerOptions);
33 34
34 -// call contextual helper method for each row
35 -$('.boxzilla-rule-row').each(setContextualHelpers);
35 + $(window).load(function () {
36 + if (typeof window.tinyMCE === "undefined") {
37 + document.getElementById('notice-notinymce').style.display = '';
38 + }
39 + });
36 40
37 -function toggleTriggerOptions() {
38 - $optionControls.find('.boxzilla-trigger-options').toggle( this.value !== '' );
39 -}
41 + // call contextual helper method for each row
42 + $('.boxzilla-rule-row').each(setContextualHelpers);
40 43
41 -function removeRule() {
42 - $(this).parents('tr').remove();
43 -}
44 + function toggleTriggerOptions() {
45 + $optionControls.find('.boxzilla-trigger-options').toggle(this.value !== '');
46 + }
44 47
45 -function setContextualHelpers() {
48 + function removeRule() {
49 + $(this).parents('tr').remove();
50 + }
46 51
47 - var context = ( this.tagName.toLowerCase() === "tr" ) ? this : $(this).parents('tr').get(0);
48 - var condition = context.querySelector('.boxzilla-rule-condition').value;
49 - var valueInput = context.querySelector('.boxzilla-rule-value');
50 - var qualifierInput = context.querySelector('.boxzilla-rule-qualifier');
51 - var betterInput = valueInput.cloneNode(true);
52 - var $betterInput = $(betterInput);
52 + function setContextualHelpers() {
53 + var context = this.tagName.toLowerCase() === "tr" ? this : $(this).parents('tr').get(0);
54 + var condition = context.querySelector('.boxzilla-rule-condition').value;
55 + var valueInput = context.querySelector('.boxzilla-rule-value');
56 + var qualifierInput = context.querySelector('.boxzilla-rule-qualifier');
57 + var betterInput = valueInput.cloneNode(true);
58 + var $betterInput = $(betterInput);
53 59
54 - // remove previously added helpers
55 - $(context.querySelectorAll('.boxzilla-helper')).remove();
60 + // remove previously added helpers
61 + $(context.querySelectorAll('.boxzilla-helper')).remove();
56 62
57 - // prepare better input
58 - betterInput.removeAttribute('name');
59 - betterInput.className = betterInput.className + ' boxzilla-helper';
60 - valueInput.parentNode.insertBefore(betterInput, valueInput.nextSibling);
61 - $betterInput.change(function() { valueInput.value = this.value; });
63 + // prepare better input
64 + betterInput.removeAttribute('name');
65 + betterInput.className = betterInput.className + ' boxzilla-helper';
66 + valueInput.parentNode.insertBefore(betterInput, valueInput.nextSibling);
67 + $betterInput.change(function () {
68 + valueInput.value = this.value;
69 + });
62 70
63 - betterInput.style.display = '';
64 - valueInput.style.display = 'none';
65 - qualifierInput.style.display = '';
71 + betterInput.style.display = '';
72 + valueInput.style.display = 'none';
73 + qualifierInput.style.display = '';
74 + if (tnLoggedIn.parentNode) {
75 + tnLoggedIn.parentNode.removeChild(tnLoggedIn);
76 + }
66 77
67 - // change placeholder for textual help
68 - switch(condition) {
69 - default:
70 - betterInput.placeholder = i18n.enterCommaSeparatedValues;
71 - break;
78 + // change placeholder for textual help
79 + switch (condition) {
80 + default:
81 + betterInput.placeholder = i18n.enterCommaSeparatedValues;
82 + break;
72 83
73 - case '':
74 - case 'everywhere':
75 - qualifierInput.value = '';
76 - valueInput.value = '';
77 - betterInput.style.display = 'none';
78 - qualifierInput.style.display = 'none';
79 - break;
84 + case '':
85 + case 'everywhere':
86 + qualifierInput.value = '1';
87 + valueInput.value = '';
88 + betterInput.style.display = 'none';
89 + qualifierInput.style.display = 'none';
90 + break;
80 91
81 - case 'is_single':
82 - case 'is_post':
83 - betterInput.placeholder = i18n.enterCommaSeparatedPosts;
84 - $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post", {multiple:true, multipleSep: ","});
85 - break;
92 + case 'is_single':
93 + case 'is_post':
94 + betterInput.placeholder = i18n.enterCommaSeparatedPosts;
95 + $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post", {
96 + multiple: true,
97 + multipleSep: ","
98 + });
99 + break;
86 100
87 - case 'is_page':
88 - betterInput.placeholder = i18n.enterCommaSeparatedPages;
89 - $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=page", {multiple:true, multipleSep: ","});
90 - break;
101 + case 'is_page':
102 + betterInput.placeholder = i18n.enterCommaSeparatedPages;
103 + $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=page", {
104 + multiple: true,
105 + multipleSep: ","
106 + });
107 + break;
91 108
92 - case 'is_post_type':
93 - betterInput.placeholder = i18n.enterCommaSeparatedPostTypes;
94 - $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post_type", {multiple:true, multipleSep: ","});
95 - break;
109 + case 'is_post_type':
110 + betterInput.placeholder = i18n.enterCommaSeparatedPostTypes;
111 + $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post_type", {
112 + multiple: true,
113 + multipleSep: ","
114 + });
115 + break;
96 116
97 - case 'is_url':
98 - betterInput.placeholder = i18n.enterCommaSeparatedRelativeUrls;
99 - break;
117 + case 'is_url':
118 + betterInput.placeholder = i18n.enterCommaSeparatedRelativeUrls;
119 + break;
100 120
101 - case 'is_post_in_category':
102 - $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=category", {multiple:true, multipleSep: ","});
103 - break;
104 - }
105 -}
121 + case 'is_post_in_category':
122 + $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=category", {
123 + multiple: true,
124 + multipleSep: ","
125 + });
126 + break;
106 127
107 -function addRuleFields() {
108 - var data = {
109 - 'key': optionControls.querySelectorAll('.boxzilla-rule-row').length
110 - };
111 - var html = rowTemplate(data);
112 - $(document.getElementById('boxzilla-box-rules')).after(html);
113 - return false;
114 -}
128 + case 'is_post_with_tag':
129 + $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post_tag", {
130 + multiple: true,
131 + multipleSep: ","
132 + });
133 + break;
115 134
116 -module.exports = {
117 - 'Designer': Designer,
118 - 'Option': Option,
119 - 'events': events
120 -};
135 + case 'is_user_logged_in':
136 + betterInput.style.display = 'none';
137 + valueInput.parentNode.insertBefore(tnLoggedIn, valueInput.nextSibling);
138 + break;
121 139
140 + }
141 + }
142 +
143 + function addRuleFields() {
144 + var data = {
145 + 'key': optionControls.querySelectorAll('.boxzilla-rule-row').length
146 + };
147 + var html = rowTemplate(data);
148 + $(document.getElementById('boxzilla-box-rules')).after(html);
149 + return false;
150 + }
151 +
152 + module.exports = {
153 + 'Designer': Designer,
154 + 'Option': Option,
155 + 'events': events
156 + };
157 +})();
158 +
122 159 },{"./_designer.js":3,"./_option.js":4,"wolfy87-eventemitter":5}],3:[function(require,module,exports){
123 -var Designer = function($, Option, events) {
160 +'use strict';
124 161
162 +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
163 +
164 +var Designer = function Designer($, Option, events) {
165 +
125 166 // vars
126 167 var boxId = document.getElementById('post_ID').value || 0,
127 - $editor, $editorFrame,
128 - $innerEditor,
129 - options = {},
130 - visualEditorInitialised = false;
168 + $editor,
169 + $editorFrame,
170 + $innerEditor,
171 + options = {},
172 + visualEditorInitialised = false;
131 173
132 174 var $appearanceControls = $("#boxzilla-box-appearance-controls");
133 175
134 176 // create Option objects
@@ -142,9 +184,9 @@
142 184 // functions
143 185 function init() {
144 186
145 187 // Only run if TinyMCE has actually inited
146 - if( typeof( window.tinyMCE ) !== "object" || tinyMCE.get('content') === null ) {
188 + if (_typeof(window.tinyMCE) !== "object" || tinyMCE.get('content') === null) {
147 189 return;
148 190 }
149 191
150 192 // add classes to TinyMCE <html>
@@ -173,15 +215,15 @@
173 215 events.trigger('editor.init');
174 216 }
175 217
176 218 /**
177 - * Applies the styles from the options to the TinyMCE Editor
178 - *
179 - * @return bool
180 - */
219 + * Applies the styles from the options to the TinyMCE Editor
220 + *
221 + * @return bool
222 + */
181 223 function applyStyles() {
182 224
183 - if( ! visualEditorInitialised ) {
225 + if (!visualEditorInitialised) {
184 226 return false;
185 227 }
186 228
187 229 // apply styles from CSS editor
@@ -200,10 +242,10 @@
200 242 return true;
201 243 }
202 244
203 245 function resetStyles() {
204 - for( var key in options ) {
205 - if( key.substring(0,5) === 'theme' ) {
246 + for (var key in options) {
247 + if (key.substring(0, 5) === 'theme') {
206 248 continue;
207 249 }
208 250
209 251 options[key].clear();
@@ -224,25 +266,25 @@
224 266 'init': init,
225 267 'resetStyles': resetStyles,
226 268 'options': options
227 269 };
228 -
229 270 };
230 271
231 272 module.exports = Designer;
273 +
232 274 },{}],4:[function(require,module,exports){
233 275 'use strict';
234 276
235 277 var $ = window.jQuery;
236 278
237 -var Option = function( element ) {
279 +var Option = function Option(element) {
238 280
239 281 // find corresponding element
240 - if( typeof(element) == "string" ) {
282 + if (typeof element == "string") {
241 283 element = document.getElementById('boxzilla-' + element);
242 284 }
243 285
244 - if( ! element ) {
286 + if (!element) {
245 287 console.error("Unable to find option element.");
246 288 }
247 289
248 290 this.element = element;
@@ -247,11 +289,11 @@
247 289
248 290 this.element = element;
249 291 };
250 292
251 -Option.prototype.getColorValue = function() {
252 - if( this.element.value.length > 0 ) {
253 - if( $(this.element).hasClass('wp-color-field')) {
293 +Option.prototype.getColorValue = function () {
294 + if (this.element.value.length > 0) {
295 + if ($(this.element).hasClass('wp-color-field')) {
254 296 return $(this.element).wpColorPicker('color');
255 297 } else {
256 298 return this.element.value;
257 299 }
@@ -259,19 +301,19 @@
259 301
260 302 return '';
261 303 };
262 304
263 -Option.prototype.getPxValue = function( fallbackValue ) {
264 - if( this.element.value.length > 0 ) {
265 - return parseInt( this.element.value ) + "px";
305 +Option.prototype.getPxValue = function (fallbackValue) {
306 + if (this.element.value.length > 0) {
307 + return parseInt(this.element.value) + "px";
266 308 }
267 309
268 310 return fallbackValue || '';
269 311 };
270 312
271 -Option.prototype.getValue = function( fallbackValue ) {
313 +Option.prototype.getValue = function (fallbackValue) {
272 314
273 - if( this.element.value.length > 0 ) {
315 + if (this.element.value.length > 0) {
274 316 return this.element.value;
275 317 }
276 318
277 319 return fallbackValue || '';
@@ -276,26 +318,27 @@
276 318
277 319 return fallbackValue || '';
278 320 };
279 321
280 -Option.prototype.clear = function() {
322 +Option.prototype.clear = function () {
281 323 this.element.value = '';
282 324 };
283 325
284 -Option.prototype.setValue = function(value) {
326 +Option.prototype.setValue = function (value) {
285 327 this.element.value = value;
286 328 };
287 329
288 330 module.exports = Option;
331 +
289 332 },{}],5:[function(require,module,exports){
290 333 /*!
291 - * EventEmitter v4.2.11 - git.io/ee
334 + * EventEmitter v5.2.4 - git.io/ee
292 335 * Unlicense - http://unlicense.org/
293 336 * Oliver Caldwell - http://oli.me.uk/
294 337 * @preserve
295 338 */
296 339
297 -;(function () {
340 +;(function (exports) {
298 341 'use strict';
299 342
300 343 /**
301 344 * Class for managing events.
@@ -306,9 +349,8 @@
306 349 function EventEmitter() {}
307 350
308 351 // Shortcuts to improve speed and size
309 352 var proto = EventEmitter.prototype;
310 - var exports = this;
311 353 var originalGlobalValue = exports.EventEmitter;
312 354
313 355 /**
314 356 * Finds the index of the listener for the event in its storage array.
@@ -407,8 +449,18 @@
407 449
408 450 return response || listeners;
409 451 };
410 452
453 + function isValidListener (listener) {
454 + if (typeof listener === 'function' || listener instanceof RegExp) {
455 + return true
456 + } else if (listener && typeof listener === 'object') {
457 + return isValidListener(listener.listener)
458 + } else {
459 + return false
460 + }
461 + }
462 +
411 463 /**
412 464 * Adds a listener function to the specified event.
413 465 * The listener will not be added if it is a duplicate.
414 466 * If the listener returns true then it will be removed after it is called.
@@ -418,8 +470,12 @@
418 470 * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
419 471 * @return {Object} Current instance of EventEmitter for chaining.
420 472 */
421 473 proto.addListener = function addListener(evt, listener) {
474 + if (!isValidListener(listener)) {
475 + throw new TypeError('listener must be a function');
476 + }
477 +
422 478 var listeners = this.getListenersAsObject(evt);
423 479 var listenerIsWrapped = typeof listener === 'object';
424 480 var key;
425 481
@@ -517,9 +573,9 @@
517 573 proto.off = alias('removeListener');
518 574
519 575 /**
520 576 * Adds listeners in bulk using the manipulateListeners method.
521 - * If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
577 + * If you pass an object as the first argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
522 578 * You can also pass it a regular expression to add the array of listeners to all events that match it.
523 579 * Yeah, this function does quite a bit. That's probably a bad thing.
524 580 *
525 581 * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
@@ -532,9 +588,9 @@
532 588 };
533 589
534 590 /**
535 591 * Removes listeners in bulk using the manipulateListeners method.
536 - * If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
592 + * If you pass an object as the first argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
537 593 * You can also pass it an event name and an array of listeners to be removed.
538 594 * You can also pass it a regular expression to remove the listeners from all events that match it.
539 595 *
540 596 * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
@@ -656,11 +712,10 @@
656 712
657 713 for (key in listenersMap) {
658 714 if (listenersMap.hasOwnProperty(key)) {
659 715 listeners = listenersMap[key].slice(0);
660 - i = listeners.length;
661 716
662 - while (i--) {
717 + for (i = 0; i < listeners.length; i++) {
663 718 // If the listener returns true then it shall be removed from the event
664 719 // The function is executed either with a basic call or an apply if there is an args array
665 720 listener = listeners[i];
666 721
@@ -759,8 +814,8 @@
759 814 }
760 815 else {
761 816 exports.EventEmitter = EventEmitter;
762 817 }
763 -}.call(this));
818 +}(this || {}));
764 819
765 820 },{}]},{},[1]);
766 - })();
821 +; })();