PluginProbe
Boxzilla – WordPress Popup Builder / 3.1.16
Boxzilla – WordPress Popup Builder v3.1.16
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.16, at assets/js/admin-script.js

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