PluginProbe
Boxzilla – WordPress Popup Builder / 3.1.4
Boxzilla – WordPress Popup Builder v3.1.4
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.4, at assets/js/admin-script.js

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