34255 lines · 1.2 MB · JavaScript
RawDownload
 */function reloadWithDebugInfo() {  window.name = 'NG_ENABLE_DEBUG_INFO!' + window.name;  window.location.reload();} /** * @name angular.getTestability * @module ng * @description * Get the testability service for the instance of Angular on the given * element. * @param {DOMElement} element DOM element which is the root of angular application. */function getTestability(rootElement) {  var injector = angular.element(rootElement).injector();  if (!injector) {    throw ngMinErr('test',      'no injector found for element argument to getTestability');  }  return injector.get('$$testability');} var SNAKE_CASE_REGEXP = /[A-Z]/g;function snake_case(name, separator) {  separator = separator || '_';  return name.replace(SNAKE_CASE_REGEXP, function(letter, pos) {    return (pos ? separator : '') + letter.toLowerCase();  });} var bindJQueryFired = false;function bindJQuery() {  var originalCleanData;   if (bindJQueryFired) {    return;  }   // bind to jQuery if present;  var jqName = jq();  jQuery = isUndefined(jqName) ? window.jQuery :   // use jQuery (if present)           !jqName             ? undefined     :   // use jqLite                                 window[jqName];   // use jQuery specified by `ngJq`   // Use jQuery if it exists with proper functionality, otherwise default to us.  // Angular 1.2+ requires jQuery 1.7+ for on()/off() support.  // Angular 1.3+ technically requires at least jQuery 2.1+ but it may work with older  // versions. It will not work for sure with jQuery <1.7, though.  if (jQuery && jQuery.fn.on) {    jqLite = jQuery;    extend(jQuery.fn, {      scope: JQLitePrototype.scope,      isolateScope: JQLitePrototype.isolateScope,      controller: /** @type {?} */ (JQLitePrototype).controller,      injector: JQLitePrototype.injector,      inheritedData: JQLitePrototype.inheritedData    });     // All nodes removed from the DOM via various jQuery APIs like .remove()    // are passed through jQuery.cleanData. Monkey-patch this method to fire    // the $destroy event on all removed nodes.    originalCleanData = jQuery.cleanData;    jQuery.cleanData = function(elems) {      var events;      for (var i = 0, elem; (elem = elems[i]) != null; i++) {        events = jQuery._data(elem, 'events');        if (events && events.$destroy) {          jQuery(elem).triggerHandler('$destroy');        }      }      originalCleanData(elems);    };  } else {    jqLite = JQLite;  }   angular.element = jqLite;   // Prevent double-proxying.  bindJQueryFired = true;} /** * throw error if the argument is falsy. */function assertArg(arg, name, reason) {  if (!arg) {    throw ngMinErr('areq', 'Argument \'{0}\' is {1}', (name || '?'), (reason || 'required'));  }  return arg;} function assertArgFn(arg, name, acceptArrayAnnotation) {  if (acceptArrayAnnotation && isArray(arg)) {      arg = arg[arg.length - 1];  }   assertArg(isFunction(arg), name, 'not a function, got ' +      (arg && typeof arg === 'object' ? arg.constructor.name || 'Object' : typeof arg));  return arg;} /** * throw error if the name given is hasOwnProperty * @param  {String} name    the name to test * @param  {String} context the context in which the name is used, such as module or directive */function assertNotHasOwnProperty(name, context) {  if (name === 'hasOwnProperty') {    throw ngMinErr('badname', 'hasOwnProperty is not a valid {0} name', context);  }} /** * Return the value accessible from the object by path. Any undefined traversals are ignored * @param {Object} obj starting object * @param {String} path path to traverse * @param {boolean} [bindFnToScope=true] * @returns {Object} value as accessible by path *///TODO(misko): this function needs to be removedfunction getter(obj, path, bindFnToScope) {  if (!path) return obj;  var keys = path.split('.');  var key;  var lastInstance = obj;  var len = keys.length;   for (var i = 0; i < len; i++) {    key = keys[i];    if (obj) {      obj = (lastInstance = obj)[key];    }  }  if (!bindFnToScope && isFunction(obj)) {    return bind(lastInstance, obj);  }  return obj;} /** * Return the DOM siblings between the first and last node in the given array. * @param {Array} array like object * @returns {Array} the inputted object or a jqLite collection containing the nodes */function getBlockNodes(nodes) {  // TODO(perf): update `nodes` instead of creating a new object?  var node = nodes[0];  var endNode = nodes[nodes.length - 1];  var blockNodes;   for (var i = 1; node !== endNode && (node = node.nextSibling); i++) {    if (blockNodes || nodes[i] !== node) {      if (!blockNodes) {        blockNodes = jqLite(slice.call(nodes, 0, i));      }      blockNodes.push(node);    }  }   return blockNodes || nodes;}  /** * Creates a new object without a prototype. This object is useful for lookup without having to * guard against prototypically inherited properties via hasOwnProperty. * * Related micro-benchmarks: * - http://jsperf.com/object-create2 * - http://jsperf.com/proto-map-lookup/2 * - http://jsperf.com/for-in-vs-object-keys2 * * @returns {Object} */function createMap() {  return Object.create(null);} function stringify(value) {  if (value == null) { // null || undefined    return '';  }  switch (typeof value) {    case 'string':      break;    case 'number':      value = '' + value;      break;    default:      if (hasCustomToString(value) && !isArray(value) && !isDate(value)) {        value = value.toString();      } else {        value = toJson(value);      }  }   return value;} var NODE_TYPE_ELEMENT = 1;var NODE_TYPE_ATTRIBUTE = 2;var NODE_TYPE_TEXT = 3;var NODE_TYPE_COMMENT = 8;var NODE_TYPE_DOCUMENT = 9;var NODE_TYPE_DOCUMENT_FRAGMENT = 11; /** * @ngdoc type * @name angular.Module * @module ng * @description * * Interface for configuring angular {@link angular.module modules}. */ function setupModuleLoader(window) {   var $injectorMinErr = minErr('$injector');  var ngMinErr = minErr('ng');   function ensure(obj, name, factory) {    return obj[name] || (obj[name] = factory());  }   var angular = ensure(window, 'angular', Object);   // We need to expose `angular.$$minErr` to modules such as `ngResource` that reference it during bootstrap  angular.$$minErr = angular.$$minErr || minErr;   return ensure(angular, 'module', function() {    /** @type {Object.<string, angular.Module>} */    var modules = {};     /**     * @ngdoc function     * @name angular.module     * @module ng     * @description     *     * The `angular.module` is a global place for creating, registering and retrieving Angular     * modules.     * All modules (angular core or 3rd party) that should be available to an application must be     * registered using this mechanism.     *     * Passing one argument retrieves an existing {@link angular.Module},     * whereas passing more than one argument creates a new {@link angular.Module}     *     *     * # Module     *     * A module is a collection of services, directives, controllers, filters, and configuration information.     * `angular.module` is used to configure the {@link auto.$injector $injector}.     *     * ```js     * // Create a new module     * var myModule = angular.module('myModule', []);     *     * // register a new service     * myModule.value('appName', 'MyCoolApp');     *     * // configure existing services inside initialization blocks.     * myModule.config(['$locationProvider', function($locationProvider) {     *   // Configure existing providers     *   $locationProvider.hashPrefix('!');     * }]);     * ```     *     * Then you can create an injector and load your modules like this:     *     * ```js     * var injector = angular.injector(['ng', 'myModule'])     * ```     *     * However it's more likely that you'll just use     * {@link ng.directive:ngApp ngApp} or     * {@link angular.bootstrap} to simplify this process for you.     *     * @param {!string} name The name of the module to create or retrieve.     * @param {!Array.<string>=} requires If specified then new module is being created. If     *        unspecified then the module is being retrieved for further configuration.     * @param {Function=} configFn Optional configuration function for the module. Same as     *        {@link angular.Module#config Module#config()}.     * @returns {angular.Module} new module with the {@link angular.Module} api.     */    return function module(name, requires, configFn) {       var info = {};       var assertNotHasOwnProperty = function(name, context) {        if (name === 'hasOwnProperty') {          throw ngMinErr('badname', 'hasOwnProperty is not a valid {0} name', context);        }      };       assertNotHasOwnProperty(name, 'module');      if (requires && modules.hasOwnProperty(name)) {        modules[name] = null;      }      return ensure(modules, name, function() {        if (!requires) {          throw $injectorMinErr('nomod', 'Module \'{0}\' is not available! You either misspelled ' +             'the module name or forgot to load it. If registering a module ensure that you ' +             'specify the dependencies as the second argument.', name);        }         /** @type {!Array.<Array.<*>>} */        var invokeQueue = [];         /** @type {!Array.<Function>} */        var configBlocks = [];         /** @type {!Array.<Function>} */        var runBlocks = [];         var config = invokeLater('$injector', 'invoke', 'push', configBlocks);         /** @type {angular.Module} */        var moduleInstance = {          // Private state          _invokeQueue: invokeQueue,          _configBlocks: configBlocks,          _runBlocks: runBlocks,           /**           * @ngdoc method           * @name angular.Module#info           * @module ng           *           * @param {Object=} info Information about the module           * @returns {Object|Module} The current info object for this module if called as a getter,           *                          or `this` if called as a setter.           *           * @description           * Read and write custom information about this module.           * For example you could put the version of the module in here.           *           * ```js           * angular.module('myModule', []).info({ version: '1.0.0' });           * ```           *           * The version could then be read back out by accessing the module elsewhere:           *           * ```           * var version = angular.module('myModule').info().version;           * ```           *           * You can also retrieve this information during runtime via the           * {@link $injector#modules `$injector.modules`} property:           *           * ```js           * var version = $injector.modules['myModule'].info().version;           * ```           */          info: function(value) {            if (isDefined(value)) {              if (!isObject(value)) throw ngMinErr('aobj', 'Argument \'{0}\' must be an object', 'value');              info = value;              return this;            }            return info;          },           /**           * @ngdoc property           * @name angular.Module#requires           * @module ng           *           * @description           * Holds the list of modules which the injector will load before the current module is           * loaded.           */          requires: requires,           /**           * @ngdoc property           * @name angular.Module#name           * @module ng           *           * @description           * Name of the module.           */          name: name,            /**           * @ngdoc method           * @name angular.Module#provider           * @module ng           * @param {string} name service name           * @param {Function} providerType Construction function for creating new instance of the           *                                service.           * @description           * See {@link auto.$provide#provider $provide.provider()}.           */          provider: invokeLaterAndSetModuleName('$provide', 'provider'),           /**           * @ngdoc method           * @name angular.Module#factory           * @module ng           * @param {string} name service name           * @param {Function} providerFunction Function for creating new instance of the service.           * @description           * See {@link auto.$provide#factory $provide.factory()}.           */          factory: invokeLaterAndSetModuleName('$provide', 'factory'),           /**           * @ngdoc method           * @name angular.Module#service           * @module ng           * @param {string} name service name           * @param {Function} constructor A constructor function that will be instantiated.           * @description           * See {@link auto.$provide#service $provide.service()}.           */          service: invokeLaterAndSetModuleName('$provide', 'service'),           /**           * @ngdoc method           * @name angular.Module#value           * @module ng           * @param {string} name service name           * @param {*} object Service instance object.           * @description           * See {@link auto.$provide#value $provide.value()}.           */          value: invokeLater('$provide', 'value'),           /**           * @ngdoc method           * @name angular.Module#constant           * @module ng           * @param {string} name constant name           * @param {*} object Constant value.           * @description           * Because the constants are fixed, they get applied before other provide methods.           * See {@link auto.$provide#constant $provide.constant()}.           */          constant: invokeLater('$provide', 'constant', 'unshift'),            /**           * @ngdoc method           * @name angular.Module#decorator           * @module ng           * @param {string} name The name of the service to decorate.           * @param {Function} decorFn This function will be invoked when the service needs to be           *                           instantiated and should return the decorated service instance.           * @description           * See {@link auto.$provide#decorator $provide.decorator()}.           */          decorator: invokeLaterAndSetModuleName('$provide', 'decorator', configBlocks),           /**           * @ngdoc method           * @name angular.Module#animation           * @module ng           * @param {string} name animation name           * @param {Function} animationFactory Factory function for creating new instance of an           *                                    animation.           * @description           *           * **NOTE**: animations take effect only if the **ngAnimate** module is loaded.           *           *           * Defines an animation hook that can be later used with           * {@link $animate $animate} service and directives that use this service.           *           * ```js           * module.animation('.animation-name', function($inject1, $inject2) {           *   return {           *     eventName : function(element, done) {           *       //code to run the animation           *       //once complete, then run done()           *       return function cancellationFunction(element) {           *         //code to cancel the animation           *       }           *     }           *   }           * })           * ```           *           * See {@link ng.$animateProvider#register $animateProvider.register()} and           * {@link ngAnimate ngAnimate module} for more information.           */          animation: invokeLaterAndSetModuleName('$animateProvider', 'register'),           /**           * @ngdoc method           * @name angular.Module#filter           * @module ng           * @param {string} name Filter name - this must be a valid angular expression identifier           * @param {Function} filterFactory Factory function for creating new instance of filter.           * @description           * See {@link ng.$filterProvider#register $filterProvider.register()}.           *           * <div class="alert alert-warning">           * **Note:** Filter names must be valid angular {@link expression} identifiers, such as `uppercase` or `orderBy`.

Lines 2001–2500 of 34255. Previous lines

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t