| @@ -1,138 +1,176 @@ | ||
| 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){ | |
| 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 = '1'; | |
| 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; | |
| 121 | + case 'is_post_in_category': | |
| 122 | + $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=category", { | |
| 123 | + multiple: true, | |
| 124 | + multipleSep: "," | |
| 125 | + }); | |
| 126 | + break; | |
| 104 | 127 | |
| 105 | - case 'is_post_with_tag': | |
| 106 | - $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post_tag", {multiple:true, multipleSep: ","}); | |
| 107 | - break; | |
| 108 | - } | |
| 109 | -} | |
| 128 | + case 'is_post_with_tag': | |
| 129 | + $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post_tag", { | |
| 130 | + multiple: true, | |
| 131 | + multipleSep: "," | |
| 132 | + }); | |
| 133 | + break; | |
| 110 | 134 | |
| 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 | -} | |
| 135 | + case 'is_user_logged_in': | |
| 136 | + betterInput.style.display = 'none'; | |
| 137 | + valueInput.parentNode.insertBefore(tnLoggedIn, valueInput.nextSibling); | |
| 138 | + break; | |
| 119 | 139 | |
| 120 | -module.exports = { | |
| 121 | - 'Designer': Designer, | |
| 122 | - 'Option': Option, | |
| 123 | - 'events': events | |
| 124 | -}; | |
| 140 | + } | |
| 141 | + } | |
| 125 | 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 | + | |
| 126 | 159 | },{"./_designer.js":3,"./_option.js":4,"wolfy87-eventemitter":5}],3:[function(require,module,exports){ |
| 127 | -var Designer = function($, Option, events) { | |
| 160 | +'use strict'; | |
| 128 | 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 | + | |
| 129 | 166 | // vars |
| 130 | 167 | var boxId = document.getElementById('post_ID').value || 0, |
| 131 | - $editor, $editorFrame, | |
| 132 | - $innerEditor, | |
| 133 | - options = {}, | |
| 134 | - visualEditorInitialised = false; | |
| 168 | + $editor, | |
| 169 | + $editorFrame, | |
| 170 | + $innerEditor, | |
| 171 | + options = {}, | |
| 172 | + visualEditorInitialised = false; | |
| 135 | 173 | |
| 136 | 174 | var $appearanceControls = $("#boxzilla-box-appearance-controls"); |
| 137 | 175 | |
| 138 | 176 | // create Option objects |
| @@ -146,9 +184,9 @@ | ||
| 146 | 184 | // functions |
| 147 | 185 | function init() { |
| 148 | 186 | |
| 149 | 187 | // Only run if TinyMCE has actually inited |
| 150 | - if( typeof( window.tinyMCE ) !== "object" || tinyMCE.get('content') === null ) { | |
| 188 | + if (_typeof(window.tinyMCE) !== "object" || tinyMCE.get('content') === null) { | |
| 151 | 189 | return; |
| 152 | 190 | } |
| 153 | 191 | |
| 154 | 192 | // add classes to TinyMCE <html> |
| @@ -177,15 +215,15 @@ | ||
| 177 | 215 | events.trigger('editor.init'); |
| 178 | 216 | } |
| 179 | 217 | |
| 180 | 218 | /** |
| 181 | - * Applies the styles from the options to the TinyMCE Editor | |
| 182 | - * | |
| 183 | - * @return bool | |
| 184 | - */ | |
| 219 | + * Applies the styles from the options to the TinyMCE Editor | |
| 220 | + * | |
| 221 | + * @return bool | |
| 222 | + */ | |
| 185 | 223 | function applyStyles() { |
| 186 | 224 | |
| 187 | - if( ! visualEditorInitialised ) { | |
| 225 | + if (!visualEditorInitialised) { | |
| 188 | 226 | return false; |
| 189 | 227 | } |
| 190 | 228 | |
| 191 | 229 | // apply styles from CSS editor |
| @@ -204,10 +242,10 @@ | ||
| 204 | 242 | return true; |
| 205 | 243 | } |
| 206 | 244 | |
| 207 | 245 | function resetStyles() { |
| 208 | - for( var key in options ) { | |
| 209 | - if( key.substring(0,5) === 'theme' ) { | |
| 246 | + for (var key in options) { | |
| 247 | + if (key.substring(0, 5) === 'theme') { | |
| 210 | 248 | continue; |
| 211 | 249 | } |
| 212 | 250 | |
| 213 | 251 | options[key].clear(); |
| @@ -228,25 +266,25 @@ | ||
| 228 | 266 | 'init': init, |
| 229 | 267 | 'resetStyles': resetStyles, |
| 230 | 268 | 'options': options |
| 231 | 269 | }; |
| 232 | - | |
| 233 | 270 | }; |
| 234 | 271 | |
| 235 | 272 | module.exports = Designer; |
| 273 | + | |
| 236 | 274 | },{}],4:[function(require,module,exports){ |
| 237 | 275 | 'use strict'; |
| 238 | 276 | |
| 239 | 277 | var $ = window.jQuery; |
| 240 | 278 | |
| 241 | -var Option = function( element ) { | |
| 279 | +var Option = function Option(element) { | |
| 242 | 280 | |
| 243 | 281 | // find corresponding element |
| 244 | - if( typeof(element) == "string" ) { | |
| 282 | + if (typeof element == "string") { | |
| 245 | 283 | element = document.getElementById('boxzilla-' + element); |
| 246 | 284 | } |
| 247 | 285 | |
| 248 | - if( ! element ) { | |
| 286 | + if (!element) { | |
| 249 | 287 | console.error("Unable to find option element."); |
| 250 | 288 | } |
| 251 | 289 | |
| 252 | 290 | this.element = element; |
| @@ -251,11 +289,11 @@ | ||
| 251 | 289 | |
| 252 | 290 | this.element = element; |
| 253 | 291 | }; |
| 254 | 292 | |
| 255 | -Option.prototype.getColorValue = function() { | |
| 256 | - if( this.element.value.length > 0 ) { | |
| 257 | - 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')) { | |
| 258 | 296 | return $(this.element).wpColorPicker('color'); |
| 259 | 297 | } else { |
| 260 | 298 | return this.element.value; |
| 261 | 299 | } |
| @@ -263,19 +301,19 @@ | ||
| 263 | 301 | |
| 264 | 302 | return ''; |
| 265 | 303 | }; |
| 266 | 304 | |
| 267 | -Option.prototype.getPxValue = function( fallbackValue ) { | |
| 268 | - if( this.element.value.length > 0 ) { | |
| 269 | - 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"; | |
| 270 | 308 | } |
| 271 | 309 | |
| 272 | 310 | return fallbackValue || ''; |
| 273 | 311 | }; |
| 274 | 312 | |
| 275 | -Option.prototype.getValue = function( fallbackValue ) { | |
| 313 | +Option.prototype.getValue = function (fallbackValue) { | |
| 276 | 314 | |
| 277 | - if( this.element.value.length > 0 ) { | |
| 315 | + if (this.element.value.length > 0) { | |
| 278 | 316 | return this.element.value; |
| 279 | 317 | } |
| 280 | 318 | |
| 281 | 319 | return fallbackValue || ''; |
| @@ -280,26 +318,27 @@ | ||
| 280 | 318 | |
| 281 | 319 | return fallbackValue || ''; |
| 282 | 320 | }; |
| 283 | 321 | |
| 284 | -Option.prototype.clear = function() { | |
| 322 | +Option.prototype.clear = function () { | |
| 285 | 323 | this.element.value = ''; |
| 286 | 324 | }; |
| 287 | 325 | |
| 288 | -Option.prototype.setValue = function(value) { | |
| 326 | +Option.prototype.setValue = function (value) { | |
| 289 | 327 | this.element.value = value; |
| 290 | 328 | }; |
| 291 | 329 | |
| 292 | 330 | module.exports = Option; |
| 331 | + | |
| 293 | 332 | },{}],5:[function(require,module,exports){ |
| 294 | 333 | /*! |
| 295 | - * EventEmitter v4.2.11 - git.io/ee | |
| 334 | + * EventEmitter v5.2.4 - git.io/ee | |
| 296 | 335 | * Unlicense - http://unlicense.org/ |
| 297 | 336 | * Oliver Caldwell - http://oli.me.uk/ |
| 298 | 337 | * @preserve |
| 299 | 338 | */ |
| 300 | 339 | |
| 301 | -;(function () { | |
| 340 | +;(function (exports) { | |
| 302 | 341 | 'use strict'; |
| 303 | 342 | |
| 304 | 343 | /** |
| 305 | 344 | * Class for managing events. |
| @@ -310,9 +349,8 @@ | ||
| 310 | 349 | function EventEmitter() {} |
| 311 | 350 | |
| 312 | 351 | // Shortcuts to improve speed and size |
| 313 | 352 | var proto = EventEmitter.prototype; |
| 314 | - var exports = this; | |
| 315 | 353 | var originalGlobalValue = exports.EventEmitter; |
| 316 | 354 | |
| 317 | 355 | /** |
| 318 | 356 | * Finds the index of the listener for the event in its storage array. |
| @@ -411,8 +449,18 @@ | ||
| 411 | 449 | |
| 412 | 450 | return response || listeners; |
| 413 | 451 | }; |
| 414 | 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 | + | |
| 415 | 463 | /** |
| 416 | 464 | * Adds a listener function to the specified event. |
| 417 | 465 | * The listener will not be added if it is a duplicate. |
| 418 | 466 | * If the listener returns true then it will be removed after it is called. |
| @@ -422,8 +470,12 @@ | ||
| 422 | 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. |
| 423 | 471 | * @return {Object} Current instance of EventEmitter for chaining. |
| 424 | 472 | */ |
| 425 | 473 | proto.addListener = function addListener(evt, listener) { |
| 474 | + if (!isValidListener(listener)) { | |
| 475 | + throw new TypeError('listener must be a function'); | |
| 476 | + } | |
| 477 | + | |
| 426 | 478 | var listeners = this.getListenersAsObject(evt); |
| 427 | 479 | var listenerIsWrapped = typeof listener === 'object'; |
| 428 | 480 | var key; |
| 429 | 481 | |
| @@ -521,9 +573,9 @@ | ||
| 521 | 573 | proto.off = alias('removeListener'); |
| 522 | 574 | |
| 523 | 575 | /** |
| 524 | 576 | * 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. | |
| 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. | |
| 526 | 578 | * You can also pass it a regular expression to add the array of listeners to all events that match it. |
| 527 | 579 | * Yeah, this function does quite a bit. That's probably a bad thing. |
| 528 | 580 | * |
| 529 | 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. |
| @@ -536,9 +588,9 @@ | ||
| 536 | 588 | }; |
| 537 | 589 | |
| 538 | 590 | /** |
| 539 | 591 | * 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. | |
| 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. | |
| 541 | 593 | * You can also pass it an event name and an array of listeners to be removed. |
| 542 | 594 | * You can also pass it a regular expression to remove the listeners from all events that match it. |
| 543 | 595 | * |
| 544 | 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. |
| @@ -660,11 +712,10 @@ | ||
| 660 | 712 | |
| 661 | 713 | for (key in listenersMap) { |
| 662 | 714 | if (listenersMap.hasOwnProperty(key)) { |
| 663 | 715 | listeners = listenersMap[key].slice(0); |
| 664 | - i = listeners.length; | |
| 665 | 716 | |
| 666 | - while (i--) { | |
| 717 | + for (i = 0; i < listeners.length; i++) { | |
| 667 | 718 | // If the listener returns true then it shall be removed from the event |
| 668 | 719 | // The function is executed either with a basic call or an apply if there is an args array |
| 669 | 720 | listener = listeners[i]; |
| 670 | 721 | |
| @@ -763,8 +814,8 @@ | ||
| 763 | 814 | } |
| 764 | 815 | else { |
| 765 | 816 | exports.EventEmitter = EventEmitter; |
| 766 | 817 | } |
| 767 | -}.call(this)); | |
| 818 | +}(this || {})); | |
| 768 | 819 | |
| 769 | 820 | },{}]},{},[1]); |
| 770 | 821 | ; })(); |