PluginProbe
Boxzilla – WordPress Popup Builder / 3.1.9
Boxzilla – WordPress Popup Builder v3.1.9
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
boxzilla / assets / js / admin-script.js

admin-script.js in Boxzilla – WordPress Popup Builder 3.1.9, at assets/js/admin-script.js

785 lines 27.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function () { var require = undefined; var module = undefined; var exports = 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){
2 'use strict';
3
4 window.Boxzilla_Admin = require('./admin/_admin.js');
5
6 },{"./admin/_admin.js":2}],2:[function(require,module,exports){
7 'use strict';
8
9 (function () {
10 'use strict';
11
12 var $ = window.jQuery;
13 var Option = require('./_option.js');
14 var optionControls = document.getElementById('boxzilla-box-options-controls');
15 var $optionControls = $(optionControls);
16
17 // sanity check, are we on the correct page?
18 if ($optionControls.length === 0) {
19 return;
20 }
21
22 var EventEmitter = require('wolfy87-eventemitter');
23 var events = new EventEmitter();
24 var Designer = require('./_designer.js')($, Option, events);
25 var rowTemplate = wp.template('rule-row-template');
26 var i18n = boxzilla_i18n;
27
28 // events
29 $optionControls.on('click', ".boxzilla-add-rule", addRuleFields);
30 $optionControls.on('click', ".boxzilla-remove-rule", removeRule);
31 $optionControls.on('change', ".boxzilla-rule-condition", setContextualHelpers);
32 $optionControls.find('.boxzilla-auto-show-trigger').on('change', toggleTriggerOptions);
33
34 $(window).load(function () {
35 if (typeof window.tinyMCE === "undefined") {
36 document.getElementById('notice-notinymce').style.display = '';
37 }
38 });
39
40 // call contextual helper method for each row
41 $('.boxzilla-rule-row').each(setContextualHelpers);
42
43 function toggleTriggerOptions() {
44 $optionControls.find('.boxzilla-trigger-options').toggle(this.value !== '');
45 }
46
47 function removeRule() {
48 $(this).parents('tr').remove();
49 }
50
51 function setContextualHelpers() {
52
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);
59
60 // remove previously added helpers
61 $(context.querySelectorAll('.boxzilla-helper')).remove();
62
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 });
70
71 betterInput.style.display = '';
72 valueInput.style.display = 'none';
73 qualifierInput.style.display = '';
74
75 // change placeholder for textual help
76 switch (condition) {
77 default:
78 betterInput.placeholder = i18n.enterCommaSeparatedValues;
79 break;
80
81 case '':
82 case 'everywhere':
83 qualifierInput.value = '1';
84 valueInput.value = '';
85 betterInput.style.display = 'none';
86 qualifierInput.style.display = 'none';
87 break;
88
89 case 'is_single':
90 case 'is_post':
91 betterInput.placeholder = i18n.enterCommaSeparatedPosts;
92 $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post", { multiple: true, multipleSep: "," });
93 break;
94
95 case 'is_page':
96 betterInput.placeholder = i18n.enterCommaSeparatedPages;
97 $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=page", { multiple: true, multipleSep: "," });
98 break;
99
100 case 'is_post_type':
101 betterInput.placeholder = i18n.enterCommaSeparatedPostTypes;
102 $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post_type", { multiple: true, multipleSep: "," });
103 break;
104
105 case 'is_url':
106 betterInput.placeholder = i18n.enterCommaSeparatedRelativeUrls;
107 break;
108
109 case 'is_post_in_category':
110 $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=category", { multiple: true, multipleSep: "," });
111 break;
112
113 case 'is_post_with_tag':
114 $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post_tag", { multiple: true, multipleSep: "," });
115 break;
116 }
117 }
118
119 function addRuleFields() {
120 var data = {
121 'key': optionControls.querySelectorAll('.boxzilla-rule-row').length
122 };
123 var html = rowTemplate(data);
124 $(document.getElementById('boxzilla-box-rules')).after(html);
125 return false;
126 }
127
128 module.exports = {
129 'Designer': Designer,
130 'Option': Option,
131 'events': events
132 };
133 })();
134
135 },{"./_designer.js":3,"./_option.js":4,"wolfy87-eventemitter":5}],3:[function(require,module,exports){
136 'use strict';
137
138 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; };
139
140 var Designer = function Designer($, Option, events) {
141
142 // vars
143 var boxId = document.getElementById('post_ID').value || 0,
144 $editor,
145 $editorFrame,
146 $innerEditor,
147 options = {},
148 visualEditorInitialised = false;
149
150 var $appearanceControls = $("#boxzilla-box-appearance-controls");
151
152 // create Option objects
153 options.borderColor = new Option('border-color');
154 options.borderWidth = new Option('border-width');
155 options.borderStyle = new Option('border-style');
156 options.backgroundColor = new Option('background-color');
157 options.width = new Option('width');
158 options.color = new Option('color');
159
160 // functions
161 function init() {
162
163 // Only run if TinyMCE has actually inited
164 if (_typeof(window.tinyMCE) !== "object" || tinyMCE.get('content') === null) {
165 return;
166 }
167
168 // add classes to TinyMCE <html>
169 $editorFrame = $("#content_ifr");
170 $editor = $editorFrame.contents().find('html');
171 $editor.css({
172 'background': 'white'
173 });
174
175 // add content class and padding to TinyMCE <body>
176 $innerEditor = $editor.find('#tinymce');
177 $innerEditor.addClass('boxzilla boxzilla-' + boxId);
178 $innerEditor.css({
179 'margin': 0,
180 'background': 'white',
181 'display': 'inline-block',
182 'width': 'auto',
183 'min-width': '240px',
184 'position': 'relative'
185 });
186 $innerEditor.get(0).style.cssText += ';padding: 25px !important;';
187
188 visualEditorInitialised = true;
189
190 /* @since 2.0.3 */
191 events.trigger('editor.init');
192 }
193
194 /**
195 * Applies the styles from the options to the TinyMCE Editor
196 *
197 * @return bool
198 */
199 function applyStyles() {
200
201 if (!visualEditorInitialised) {
202 return false;
203 }
204
205 // apply styles from CSS editor
206 $innerEditor.css({
207 'border-color': options.borderColor.getColorValue(), //getColorValue( 'borderColor', '' ),
208 'border-width': options.borderWidth.getPxValue(), //getPxValue( 'borderWidth', '' ),
209 'border-style': options.borderStyle.getValue(), //getValue('borderStyle', '' ),
210 'background-color': options.backgroundColor.getColorValue(), //getColorValue( 'backgroundColor', ''),
211 'width': options.width.getPxValue(), //getPxValue( 'width', 'auto' ),
212 'color': options.color.getColorValue() // getColorValue( 'color', '' )
213 });
214
215 /* @since 2.0.3 */
216 events.trigger('editor.styles.apply');
217
218 return true;
219 }
220
221 function resetStyles() {
222 for (var key in options) {
223 if (key.substring(0, 5) === 'theme') {
224 continue;
225 }
226
227 options[key].clear();
228 }
229 applyStyles();
230
231 /* @since 2.0.3 */
232 events.trigger('editor.styles.reset');
233 }
234
235 // event binders
236 $appearanceControls.find('input.boxzilla-color-field').wpColorPicker({ change: applyStyles, clear: applyStyles });
237 $appearanceControls.find(":input").not(".boxzilla-color-field").change(applyStyles);
238 events.on('editor.init', applyStyles);
239
240 // public methods
241 return {
242 'init': init,
243 'resetStyles': resetStyles,
244 'options': options
245 };
246 };
247
248 module.exports = Designer;
249
250 },{}],4:[function(require,module,exports){
251 'use strict';
252
253 var $ = window.jQuery;
254
255 var Option = function Option(element) {
256
257 // find corresponding element
258 if (typeof element == "string") {
259 element = document.getElementById('boxzilla-' + element);
260 }
261
262 if (!element) {
263 console.error("Unable to find option element.");
264 }
265
266 this.element = element;
267 };
268
269 Option.prototype.getColorValue = function () {
270 if (this.element.value.length > 0) {
271 if ($(this.element).hasClass('wp-color-field')) {
272 return $(this.element).wpColorPicker('color');
273 } else {
274 return this.element.value;
275 }
276 }
277
278 return '';
279 };
280
281 Option.prototype.getPxValue = function (fallbackValue) {
282 if (this.element.value.length > 0) {
283 return parseInt(this.element.value) + "px";
284 }
285
286 return fallbackValue || '';
287 };
288
289 Option.prototype.getValue = function (fallbackValue) {
290
291 if (this.element.value.length > 0) {
292 return this.element.value;
293 }
294
295 return fallbackValue || '';
296 };
297
298 Option.prototype.clear = function () {
299 this.element.value = '';
300 };
301
302 Option.prototype.setValue = function (value) {
303 this.element.value = value;
304 };
305
306 module.exports = Option;
307
308 },{}],5:[function(require,module,exports){
309 /*!
310 * EventEmitter v4.2.11 - git.io/ee
311 * Unlicense - http://unlicense.org/
312 * Oliver Caldwell - http://oli.me.uk/
313 * @preserve
314 */
315
316 ;(function () {
317 'use strict';
318
319 /**
320 * Class for managing events.
321 * Can be extended to provide event functionality in other classes.
322 *
323 * @class EventEmitter Manages event registering and emitting.
324 */
325 function EventEmitter() {}
326
327 // Shortcuts to improve speed and size
328 var proto = EventEmitter.prototype;
329 var exports = this;
330 var originalGlobalValue = exports.EventEmitter;
331
332 /**
333 * Finds the index of the listener for the event in its storage array.
334 *
335 * @param {Function[]} listeners Array of listeners to search through.
336 * @param {Function} listener Method to look for.
337 * @return {Number} Index of the specified listener, -1 if not found
338 * @api private
339 */
340 function indexOfListener(listeners, listener) {
341 var i = listeners.length;
342 while (i--) {
343 if (listeners[i].listener === listener) {
344 return i;
345 }
346 }
347
348 return -1;
349 }
350
351 /**
352 * Alias a method while keeping the context correct, to allow for overwriting of target method.
353 *
354 * @param {String} name The name of the target method.
355 * @return {Function} The aliased method
356 * @api private
357 */
358 function alias(name) {
359 return function aliasClosure() {
360 return this[name].apply(this, arguments);
361 };
362 }
363
364 /**
365 * Returns the listener array for the specified event.
366 * Will initialise the event object and listener arrays if required.
367 * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
368 * Each property in the object response is an array of listener functions.
369 *
370 * @param {String|RegExp} evt Name of the event to return the listeners from.
371 * @return {Function[]|Object} All listener functions for the event.
372 */
373 proto.getListeners = function getListeners(evt) {
374 var events = this._getEvents();
375 var response;
376 var key;
377
378 // Return a concatenated array of all matching events if
379 // the selector is a regular expression.
380 if (evt instanceof RegExp) {
381 response = {};
382 for (key in events) {
383 if (events.hasOwnProperty(key) && evt.test(key)) {
384 response[key] = events[key];
385 }
386 }
387 }
388 else {
389 response = events[evt] || (events[evt] = []);
390 }
391
392 return response;
393 };
394
395 /**
396 * Takes a list of listener objects and flattens it into a list of listener functions.
397 *
398 * @param {Object[]} listeners Raw listener objects.
399 * @return {Function[]} Just the listener functions.
400 */
401 proto.flattenListeners = function flattenListeners(listeners) {
402 var flatListeners = [];
403 var i;
404
405 for (i = 0; i < listeners.length; i += 1) {
406 flatListeners.push(listeners[i].listener);
407 }
408
409 return flatListeners;
410 };
411
412 /**
413 * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
414 *
415 * @param {String|RegExp} evt Name of the event to return the listeners from.
416 * @return {Object} All listener functions for an event in an object.
417 */
418 proto.getListenersAsObject = function getListenersAsObject(evt) {
419 var listeners = this.getListeners(evt);
420 var response;
421
422 if (listeners instanceof Array) {
423 response = {};
424 response[evt] = listeners;
425 }
426
427 return response || listeners;
428 };
429
430 /**
431 * Adds a listener function to the specified event.
432 * The listener will not be added if it is a duplicate.
433 * If the listener returns true then it will be removed after it is called.
434 * If you pass a regular expression as the event name then the listener will be added to all events that match it.
435 *
436 * @param {String|RegExp} evt Name of the event to attach the listener to.
437 * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
438 * @return {Object} Current instance of EventEmitter for chaining.
439 */
440 proto.addListener = function addListener(evt, listener) {
441 var listeners = this.getListenersAsObject(evt);
442 var listenerIsWrapped = typeof listener === 'object';
443 var key;
444
445 for (key in listeners) {
446 if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
447 listeners[key].push(listenerIsWrapped ? listener : {
448 listener: listener,
449 once: false
450 });
451 }
452 }
453
454 return this;
455 };
456
457 /**
458 * Alias of addListener
459 */
460 proto.on = alias('addListener');
461
462 /**
463 * Semi-alias of addListener. It will add a listener that will be
464 * automatically removed after its first execution.
465 *
466 * @param {String|RegExp} evt Name of the event to attach the listener to.
467 * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
468 * @return {Object} Current instance of EventEmitter for chaining.
469 */
470 proto.addOnceListener = function addOnceListener(evt, listener) {
471 return this.addListener(evt, {
472 listener: listener,
473 once: true
474 });
475 };
476
477 /**
478 * Alias of addOnceListener.
479 */
480 proto.once = alias('addOnceListener');
481
482 /**
483 * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
484 * You need to tell it what event names should be matched by a regex.
485 *
486 * @param {String} evt Name of the event to create.
487 * @return {Object} Current instance of EventEmitter for chaining.
488 */
489 proto.defineEvent = function defineEvent(evt) {
490 this.getListeners(evt);
491 return this;
492 };
493
494 /**
495 * Uses defineEvent to define multiple events.
496 *
497 * @param {String[]} evts An array of event names to define.
498 * @return {Object} Current instance of EventEmitter for chaining.
499 */
500 proto.defineEvents = function defineEvents(evts) {
501 for (var i = 0; i < evts.length; i += 1) {
502 this.defineEvent(evts[i]);
503 }
504 return this;
505 };
506
507 /**
508 * Removes a listener function from the specified event.
509 * When passed a regular expression as the event name, it will remove the listener from all events that match it.
510 *
511 * @param {String|RegExp} evt Name of the event to remove the listener from.
512 * @param {Function} listener Method to remove from the event.
513 * @return {Object} Current instance of EventEmitter for chaining.
514 */
515 proto.removeListener = function removeListener(evt, listener) {
516 var listeners = this.getListenersAsObject(evt);
517 var index;
518 var key;
519
520 for (key in listeners) {
521 if (listeners.hasOwnProperty(key)) {
522 index = indexOfListener(listeners[key], listener);
523
524 if (index !== -1) {
525 listeners[key].splice(index, 1);
526 }
527 }
528 }
529
530 return this;
531 };
532
533 /**
534 * Alias of removeListener
535 */
536 proto.off = alias('removeListener');
537
538 /**
539 * Adds listeners in bulk using the manipulateListeners method.
540 * 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.
541 * You can also pass it a regular expression to add the array of listeners to all events that match it.
542 * Yeah, this function does quite a bit. That's probably a bad thing.
543 *
544 * @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.
545 * @param {Function[]} [listeners] An optional array of listener functions to add.
546 * @return {Object} Current instance of EventEmitter for chaining.
547 */
548 proto.addListeners = function addListeners(evt, listeners) {
549 // Pass through to manipulateListeners
550 return this.manipulateListeners(false, evt, listeners);
551 };
552
553 /**
554 * Removes listeners in bulk using the manipulateListeners method.
555 * 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.
556 * You can also pass it an event name and an array of listeners to be removed.
557 * You can also pass it a regular expression to remove the listeners from all events that match it.
558 *
559 * @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.
560 * @param {Function[]} [listeners] An optional array of listener functions to remove.
561 * @return {Object} Current instance of EventEmitter for chaining.
562 */
563 proto.removeListeners = function removeListeners(evt, listeners) {
564 // Pass through to manipulateListeners
565 return this.manipulateListeners(true, evt, listeners);
566 };
567
568 /**
569 * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
570 * The first argument will determine if the listeners are removed (true) or added (false).
571 * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
572 * You can also pass it an event name and an array of listeners to be added/removed.
573 * You can also pass it a regular expression to manipulate the listeners of all events that match it.
574 *
575 * @param {Boolean} remove True if you want to remove listeners, false if you want to add.
576 * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
577 * @param {Function[]} [listeners] An optional array of listener functions to add/remove.
578 * @return {Object} Current instance of EventEmitter for chaining.
579 */
580 proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
581 var i;
582 var value;
583 var single = remove ? this.removeListener : this.addListener;
584 var multiple = remove ? this.removeListeners : this.addListeners;
585
586 // If evt is an object then pass each of its properties to this method
587 if (typeof evt === 'object' && !(evt instanceof RegExp)) {
588 for (i in evt) {
589 if (evt.hasOwnProperty(i) && (value = evt[i])) {
590 // Pass the single listener straight through to the singular method
591 if (typeof value === 'function') {
592 single.call(this, i, value);
593 }
594 else {
595 // Otherwise pass back to the multiple function
596 multiple.call(this, i, value);
597 }
598 }
599 }
600 }
601 else {
602 // So evt must be a string
603 // And listeners must be an array of listeners
604 // Loop over it and pass each one to the multiple method
605 i = listeners.length;
606 while (i--) {
607 single.call(this, evt, listeners[i]);
608 }
609 }
610
611 return this;
612 };
613
614 /**
615 * Removes all listeners from a specified event.
616 * If you do not specify an event then all listeners will be removed.
617 * That means every event will be emptied.
618 * You can also pass a regex to remove all events that match it.
619 *
620 * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
621 * @return {Object} Current instance of EventEmitter for chaining.
622 */
623 proto.removeEvent = function removeEvent(evt) {
624 var type = typeof evt;
625 var events = this._getEvents();
626 var key;
627
628 // Remove different things depending on the state of evt
629 if (type === 'string') {
630 // Remove all listeners for the specified event
631 delete events[evt];
632 }
633 else if (evt instanceof RegExp) {
634 // Remove all events matching the regex.
635 for (key in events) {
636 if (events.hasOwnProperty(key) && evt.test(key)) {
637 delete events[key];
638 }
639 }
640 }
641 else {
642 // Remove all listeners in all events
643 delete this._events;
644 }
645
646 return this;
647 };
648
649 /**
650 * Alias of removeEvent.
651 *
652 * Added to mirror the node API.
653 */
654 proto.removeAllListeners = alias('removeEvent');
655
656 /**
657 * Emits an event of your choice.
658 * When emitted, every listener attached to that event will be executed.
659 * If you pass the optional argument array then those arguments will be passed to every listener upon execution.
660 * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
661 * So they will not arrive within the array on the other side, they will be separate.
662 * You can also pass a regular expression to emit to all events that match it.
663 *
664 * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
665 * @param {Array} [args] Optional array of arguments to be passed to each listener.
666 * @return {Object} Current instance of EventEmitter for chaining.
667 */
668 proto.emitEvent = function emitEvent(evt, args) {
669 var listenersMap = this.getListenersAsObject(evt);
670 var listeners;
671 var listener;
672 var i;
673 var key;
674 var response;
675
676 for (key in listenersMap) {
677 if (listenersMap.hasOwnProperty(key)) {
678 listeners = listenersMap[key].slice(0);
679 i = listeners.length;
680
681 while (i--) {
682 // If the listener returns true then it shall be removed from the event
683 // The function is executed either with a basic call or an apply if there is an args array
684 listener = listeners[i];
685
686 if (listener.once === true) {
687 this.removeListener(evt, listener.listener);
688 }
689
690 response = listener.listener.apply(this, args || []);
691
692 if (response === this._getOnceReturnValue()) {
693 this.removeListener(evt, listener.listener);
694 }
695 }
696 }
697 }
698
699 return this;
700 };
701
702 /**
703 * Alias of emitEvent
704 */
705 proto.trigger = alias('emitEvent');
706
707 /**
708 * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
709 * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
710 *
711 * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
712 * @param {...*} Optional additional arguments to be passed to each listener.
713 * @return {Object} Current instance of EventEmitter for chaining.
714 */
715 proto.emit = function emit(evt) {
716 var args = Array.prototype.slice.call(arguments, 1);
717 return this.emitEvent(evt, args);
718 };
719
720 /**
721 * Sets the current value to check against when executing listeners. If a
722 * listeners return value matches the one set here then it will be removed
723 * after execution. This value defaults to true.
724 *
725 * @param {*} value The new value to check for when executing listeners.
726 * @return {Object} Current instance of EventEmitter for chaining.
727 */
728 proto.setOnceReturnValue = function setOnceReturnValue(value) {
729 this._onceReturnValue = value;
730 return this;
731 };
732
733 /**
734 * Fetches the current value to check against when executing listeners. If
735 * the listeners return value matches this one then it should be removed
736 * automatically. It will return true by default.
737 *
738 * @return {*|Boolean} The current value to check for or the default, true.
739 * @api private
740 */
741 proto._getOnceReturnValue = function _getOnceReturnValue() {
742 if (this.hasOwnProperty('_onceReturnValue')) {
743 return this._onceReturnValue;
744 }
745 else {
746 return true;
747 }
748 };
749
750 /**
751 * Fetches the events object and creates one if required.
752 *
753 * @return {Object} The events storage object.
754 * @api private
755 */
756 proto._getEvents = function _getEvents() {
757 return this._events || (this._events = {});
758 };
759
760 /**
761 * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
762 *
763 * @return {Function} Non conflicting EventEmitter class.
764 */
765 EventEmitter.noConflict = function noConflict() {
766 exports.EventEmitter = originalGlobalValue;
767 return EventEmitter;
768 };
769
770 // Expose the class either via AMD, CommonJS or the global object
771 if (typeof define === 'function' && define.amd) {
772 define(function () {
773 return EventEmitter;
774 });
775 }
776 else if (typeof module === 'object' && module.exports){
777 module.exports = EventEmitter;
778 }
779 else {
780 exports.EventEmitter = EventEmitter;
781 }
782 }.call(this));
783
784 },{}]},{},[1]);
785 ; })();