vendor: 13,669 bytes, lines 1-388
1/** 2 * CLDR JavaScript Library v0.4.3 3 * http://jquery.com/ 4 * 5 * Copyright 2013 Rafael Xavier de Souza 6 * Released under the MIT license 7 * http://jquery.org/license 8 * 9 * Date: 2015-08-24T01:00Z 10 */ 11/*! 12 * CLDR JavaScript Library v0.4.3 2015-08-24T01:00Z MIT license © Rafael Xavier 13 * http://git.io/h4lmVg 14 */ 15(function( factory ) { 16 17 if ( typeof define === "function" && define.amd ) { 18 // AMD. 19 define( [ "../cldr" ], factory ); 20 } else if ( typeof module === "object" && typeof module.exports === "object" ) { 21 // Node. CommonJS. 22 module.exports = factory( require( "cldrjs" ) ); 23 } else { 24 // Global 25 factory( Cldr ); 26 } 27 28}(function( Cldr ) { 29 30 // Build optimization hack to avoid duplicating functions across modules. 31 var pathNormalize = Cldr._pathNormalize, 32 validatePresence = Cldr._validatePresence, 33 validateType = Cldr._validateType; 34 35/*! 36 * EventEmitter v4.2.7 - git.io/ee 37 * Oliver Caldwell 38 * MIT license 39 * @preserve 40 */ 41 42var EventEmitter; 43/* jshint ignore:start */ 44EventEmitter = (function () { 45 46 47 /** 48 * Class for managing events. 49 * Can be extended to provide event functionality in other classes. 50 * 51 * @class EventEmitter Manages event registering and emitting. 52 */ 53 function EventEmitter() {} 54 55 // Shortcuts to improve speed and size 56 var proto = EventEmitter.prototype; 57 var exports = this; 58 var originalGlobalValue = exports.EventEmitter; 59 60 /** 61 * Finds the index of the listener for the event in it's storage array. 62 * 63 * @param {Function[]} listeners Array of listeners to search through. 64 * @param {Function} listener Method to look for. 65 * @return {Number} Index of the specified listener, -1 if not found 66 * @api private 67 */ 68 function indexOfListener(listeners, listener) { 69 var i = listeners.length; 70 while (i--) { 71 if (listeners[i].listener === listener) { 72 return i; 73 } 74 } 75 76 return -1; 77 } 78 79 /** 80 * Alias a method while keeping the context correct, to allow for overwriting of target method. 81 * 82 * @param {String} name The name of the target method. 83 * @return {Function} The aliased method 84 * @api private 85 */ 86 function alias(name) { 87 return function aliasClosure() { 88 return this[name].apply(this, arguments); 89 }; 90 } 91 92 /** 93 * Returns the listener array for the specified event. 94 * Will initialise the event object and listener arrays if required. 95 * 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. 96 * Each property in the object response is an array of listener functions. 97 * 98 * @param {String|RegExp} evt Name of the event to return the listeners from. 99 * @return {Function[]|Object} All listener functions for the event. 100 */ 101 proto.getListeners = function getListeners(evt) { 102 var events = this._getEvents(); 103 var response; 104 var key; 105 106 // Return a concatenated array of all matching events if 107 // the selector is a regular expression. 108 if (evt instanceof RegExp) { 109 response = {}; 110 for (key in events) { 111 if (events.hasOwnProperty(key) && evt.test(key)) { 112 response[key] = events[key]; 113 } 114 } 115 } 116 else { 117 response = events[evt] || (events[evt] = []); 118 } 119 120 return response; 121 }; 122 123 /** 124 * Takes a list of listener objects and flattens it into a list of listener functions. 125 * 126 * @param {Object[]} listeners Raw listener objects. 127 * @return {Function[]} Just the listener functions. 128 */ 129 proto.flattenListeners = function flattenListeners(listeners) { 130 var flatListeners = []; 131 var i; 132 133 for (i = 0; i < listeners.length; i += 1) { 134 flatListeners.push(listeners[i].listener); 135 } 136 137 return flatListeners; 138 }; 139 140 /** 141 * 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. 142 * 143 * @param {String|RegExp} evt Name of the event to return the listeners from. 144 * @return {Object} All listener functions for an event in an object. 145 */ 146 proto.getListenersAsObject = function getListenersAsObject(evt) { 147 var listeners = this.getListeners(evt); 148 var response; 149 150 if (listeners instanceof Array) { 151 response = {}; 152 response[evt] = listeners; 153 } 154 155 return response || listeners; 156 }; 157 158 /** 159 * Adds a listener function to the specified event. 160 * The listener will not be added if it is a duplicate. 161 * If the listener returns true then it will be removed after it is called. 162 * If you pass a regular expression as the event name then the listener will be added to all events that match it. 163 * 164 * @param {String|RegExp} evt Name of the event to attach the listener to. 165 * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling. 166 * @return {Object} Current instance of EventEmitter for chaining. 167 */ 168 proto.addListener = function addListener(evt, listener) { 169 var listeners = this.getListenersAsObject(evt); 170 var listenerIsWrapped = typeof listener === 'object'; 171 var key; 172 173 for (key in listeners) { 174 if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) { 175 listeners[key].push(listenerIsWrapped ? listener : { 176 listener: listener, 177 once: false 178 }); 179 } 180 } 181 182 return this; 183 }; 184 185 /** 186 * Alias of addListener 187 */ 188 proto.on = alias('addListener'); 189 190 /** 191 * Semi-alias of addListener. It will add a listener that will be 192 * automatically removed after it's first execution. 193 * 194 * @param {String|RegExp} evt Name of the event to attach the listener to. 195 * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling. 196 * @return {Object} Current instance of EventEmitter for chaining. 197 */ 198 proto.addOnceListener = function addOnceListener(evt, listener) { 199 return this.addListener(evt, { 200 listener: listener, 201 once: true 202 }); 203 }; 204 205 /** 206 * Alias of addOnceListener. 207 */ 208 proto.once = alias('addOnceListener'); 209 210 /** 211 * 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. 212 * You need to tell it what event names should be matched by a regex. 213 * 214 * @param {String} evt Name of the event to create. 215 * @return {Object} Current instance of EventEmitter for chaining. 216 */ 217 proto.defineEvent = function defineEvent(evt) { 218 this.getListeners(evt); 219 return this; 220 }; 221 222 /** 223 * Uses defineEvent to define multiple events. 224 * 225 * @param {String[]} evts An array of event names to define. 226 * @return {Object} Current instance of EventEmitter for chaining. 227 */ 228 proto.defineEvents = function defineEvents(evts) { 229 for (var i = 0; i < evts.length; i += 1) { 230 this.defineEvent(evts[i]); 231 } 232 return this; 233 }; 234 235 /** 236 * Removes a listener function from the specified event. 237 * When passed a regular expression as the event name, it will remove the listener from all events that match it. 238 * 239 * @param {String|RegExp} evt Name of the event to remove the listener from. 240 * @param {Function} listener Method to remove from the event. 241 * @return {Object} Current instance of EventEmitter for chaining. 242 */ 243 proto.removeListener = function removeListener(evt, listener) { 244 var listeners = this.getListenersAsObject(evt); 245 var index; 246 var key; 247 248 for (key in listeners) { 249 if (listeners.hasOwnProperty(key)) { 250 index = indexOfListener(listeners[key], listener); 251 252 if (index !== -1) { 253 listeners[key].splice(index, 1); 254 } 255 } 256 } 257 258 return this; 259 }; 260 261 /** 262 * Alias of removeListener 263 */ 264 proto.off = alias('removeListener'); 265 266 /** 267 * Adds listeners in bulk using the manipulateListeners method. 268 * 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. 269 * You can also pass it a regular expression to add the array of listeners to all events that match it. 270 * Yeah, this function does quite a bit. That's probably a bad thing. 271 * 272 * @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. 273 * @param {Function[]} [listeners] An optional array of listener functions to add. 274 * @return {Object} Current instance of EventEmitter for chaining. 275 */ 276 proto.addListeners = function addListeners(evt, listeners) { 277 // Pass through to manipulateListeners 278 return this.manipulateListeners(false, evt, listeners); 279 }; 280 281 /** 282 * Removes listeners in bulk using the manipulateListeners method. 283 * 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. 284 * You can also pass it an event name and an array of listeners to be removed. 285 * You can also pass it a regular expression to remove the listeners from all events that match it. 286 * 287 * @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. 288 * @param {Function[]} [listeners] An optional array of listener functions to remove. 289 * @return {Object} Current instance of EventEmitter for chaining. 290 */ 291 proto.removeListeners = function removeListeners(evt, listeners) { 292 // Pass through to manipulateListeners 293 return this.manipulateListeners(true, evt, listeners); 294 }; 295 296 /** 297 * 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. 298 * The first argument will determine if the listeners are removed (true) or added (false). 299 * 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. 300 * You can also pass it an event name and an array of listeners to be added/removed. 301 * You can also pass it a regular expression to manipulate the listeners of all events that match it. 302 * 303 * @param {Boolean} remove True if you want to remove listeners, false if you want to add. 304 * @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. 305 * @param {Function[]} [listeners] An optional array of listener functions to add/remove. 306 * @return {Object} Current instance of EventEmitter for chaining. 307 */ 308 proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) { 309 var i; 310 var value; 311 var single = remove ? this.removeListener : this.addListener; 312 var multiple = remove ? this.removeListeners : this.addListeners; 313 314 // If evt is an object then pass each of it's properties to this method 315 if (typeof evt === 'object' && !(evt instanceof RegExp)) { 316 for (i in evt) { 317 if (evt.hasOwnProperty(i) && (value = evt[i])) { 318 // Pass the single listener straight through to the singular method 319 if (typeof value === 'function') { 320 single.call(this, i, value); 321 } 322 else { 323 // Otherwise pass back to the multiple function 324 multiple.call(this, i, value); 325 } 326 } 327 } 328 } 329 else { 330 // So evt must be a string 331 // And listeners must be an array of listeners 332 // Loop over it and pass each one to the multiple method 333 i = listeners.length; 334 while (i--) { 335 single.call(this, evt, listeners[i]); 336 } 337 } 338 339 return this; 340 }; 341 342 /** 343 * Removes all listeners from a specified event. 344 * If you do not specify an event then all listeners will be removed. 345 * That means every event will be emptied. 346 * You can also pass a regex to remove all events that match it. 347 * 348 * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed. 349 * @return {Object} Current instance of EventEmitter for chaining. 350 */ 351 proto.removeEvent = function removeEvent(evt) { 352 var type = typeof evt; 353 var events = this._getEvents(); 354 var key; 355 356 // Remove different things depending on the state of evt 357 if (type === 'string') { 358 // Remove all listeners for the specified event 359 delete events[evt]; 360 } 361 else if (evt instanceof RegExp) { 362 // Remove all events matching the regex. 363 for (key in events) { 364 if (events.hasOwnProperty(key) && evt.test(key)) { 365 delete events[key]; 366 } 367 } 368 } 369 else { 370 // Remove all listeners in all events 371 delete this._events; 372 } 373 374 return this; 375 }; 376 377 /** 378 * Alias of removeEvent. 379 * 380 * Added to mirror the node API. 381 */ 382 proto.removeAllListeners = alias('removeEvent'); 383 384 /** 385 * Emits an event of your choice. 386 * When emitted, every listener attached to that event will be executed. 387 * If you pass the optional argument array then those arguments will be passed to every listener upon execution. 388 * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
389 * So they will not arrive within the array on the other side, they will be separate. 390 * You can also pass a regular expression to emit to all events that match it. 391 * 392 * @param {String|RegExp} evt Name of the event to emit and execute listeners for. 393 * @param {Array} [args] Optional array of arguments to be passed to each listener. 394 * @return {Object} Current instance of EventEmitter for chaining. 395 */ 396 proto.emitEvent = function emitEvent(evt, args) { 397 var listeners = this.getListenersAsObject(evt); 398 var listener; 399 var i; 400 var key; 401 var response; 402 403 for (key in listeners) { 404 if (listeners.hasOwnProperty(key)) { 405 i = listeners[key].length; 406 407 while (i--) { 408 // If the listener returns true then it shall be removed from the event 409 // The function is executed either with a basic call or an apply if there is an args array 410 listener = listeners[key][i]; 411 412 if (listener.once === true) { 413 this.removeListener(evt, listener.listener); 414 } 415 416 response = listener.listener.apply(this, args || []); 417 418 if (response === this._getOnceReturnValue()) { 419 this.removeListener(evt, listener.listener); 420 } 421 } 422 } 423 } 424 425 return this; 426 }; 427 428 /** 429 * Alias of emitEvent 430 */ 431 proto.trigger = alias('emitEvent'); 432 433 /** 434 * 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. 435 * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it. 436 * 437 * @param {String|RegExp} evt Name of the event to emit and execute listeners for. 438 * @param {...*} Optional additional arguments to be passed to each listener. 439 * @return {Object} Current instance of EventEmitter for chaining. 440 */ 441 proto.emit = function emit(evt) { 442 var args = Array.prototype.slice.call(arguments, 1); 443 return this.emitEvent(evt, args); 444 }; 445 446 /** 447 * Sets the current value to check against when executing listeners. If a 448 * listeners return value matches the one set here then it will be removed 449 * after execution. This value defaults to true. 450 * 451 * @param {*} value The new value to check for when executing listeners. 452 * @return {Object} Current instance of EventEmitter for chaining. 453 */ 454 proto.setOnceReturnValue = function setOnceReturnValue(value) { 455 this._onceReturnValue = value; 456 return this; 457 }; 458 459 /** 460 * Fetches the current value to check against when executing listeners. If 461 * the listeners return value matches this one then it should be removed 462 * automatically. It will return true by default. 463 * 464 * @return {*|Boolean} The current value to check for or the default, true. 465 * @api private 466 */ 467 proto._getOnceReturnValue = function _getOnceReturnValue() { 468 if (this.hasOwnProperty('_onceReturnValue')) { 469 return this._onceReturnValue; 470 } 471 else { 472 return true; 473 } 474 }; 475 476 /** 477 * Fetches the events object and creates one if required. 478 * 479 * @return {Object} The events storage object. 480 * @api private 481 */ 482 proto._getEvents = function _getEvents() { 483 return this._events || (this._events = {}); 484 }; 485 486 /** 487 * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version. 488 * 489 * @return {Function} Non conflicting EventEmitter class. 490 */ 491 EventEmitter.noConflict = function noConflict() { 492 exports.EventEmitter = originalGlobalValue; 493 return EventEmitter; 494 }; 495 496 return EventEmitter; 497}()); 498/* jshint ignore:end */ 499 500 501 502 var validateTypeFunction = function( value, name ) { 503 validateType( value, name, typeof value === "undefined" || typeof value === "function", "Function" ); 504 }; 505 506 507 508 509 var superGet, superInit, 510 globalEe = new EventEmitter(); 511 512 function validateTypeEvent( value, name ) { 513 validateType( value, name, typeof value === "string" || value instanceof RegExp, "String or RegExp" ); 514 } 515 516 function validateThenCall( method, self ) { 517 return function( event, listener ) { 518 validatePresence( event, "event" ); 519 validateTypeEvent( event, "event" ); 520 521 validatePresence( listener, "listener" ); 522 validateTypeFunction( listener, "listener" ); 523 524 return self[ method ].apply( self, arguments ); 525 }; 526 } 527 528 function off( self ) { 529 return validateThenCall( "off", self ); 530 } 531 532 function on( self ) { 533 return validateThenCall( "on", self ); 534 } 535 536 function once( self ) { 537 return validateThenCall( "once", self ); 538 } 539 540 Cldr.off = off( globalEe ); 541 Cldr.on = on( globalEe ); 542 Cldr.once = once( globalEe ); 543 544 /** 545 * Overload Cldr.prototype.init(). 546 */ 547 superInit = Cldr.prototype.init; 548 Cldr.prototype.init = function() { 549 var ee; 550 this.ee = ee = new EventEmitter(); 551 this.off = off( ee ); 552 this.on = on( ee ); 553 this.once = once( ee ); 554 superInit.apply( this, arguments ); 555 }; 556 557 /** 558 * getOverload is encapsulated, because of cldr/unresolved. If it's loaded
559 * after cldr/event (and note it overwrites .get), it can trigger this 560 * overload again. 561 */ 562 function getOverload() { 563 564 /** 565 * Overload Cldr.prototype.get(). 566 */ 567 superGet = Cldr.prototype.get; 568 Cldr.prototype.get = function( path ) { 569 var value = superGet.apply( this, arguments ); 570 path = pathNormalize( path, this.attributes ).join( "/" ); 571 globalEe.trigger( "get", [ path, value ] ); 572 this.ee.trigger( "get", [ path, value ] ); 573 return value; 574 }; 575 } 576 577 Cldr._eventInit = getOverload; 578 getOverload(); 579 580 return Cldr; 581 582 583 584 585}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.