You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by br...@apache.org on 2014/01/06 21:25:48 UTC
[08/13] Updating Angular to 1.2.3 release
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/9c3b3ee1/www/cdvah/js/libs/angular.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/libs/angular.js b/www/cdvah/js/libs/angular.js
index c34fc04..41afab5 100644
--- a/www/cdvah/js/libs/angular.js
+++ b/www/cdvah/js/libs/angular.js
@@ -1,6 +1,6 @@
/**
- * @license AngularJS v1.2.0-rc.3
- * (c) 2010-2012 Google, Inc. http://angularjs.org
+ * @license AngularJS v1.2.3
+ * (c) 2010-2014 Google, Inc. http://angularjs.org
* License: MIT
*/
(function(window, document, undefined) {'use strict';
@@ -40,11 +40,11 @@ function minErr(module) {
template = arguments[1],
templateArgs = arguments,
stringify = function (obj) {
- if (isFunction(obj)) {
+ if (typeof obj === 'function') {
return obj.toString().replace(/ \{[\s\S]*$/, '');
- } else if (isUndefined(obj)) {
+ } else if (typeof obj === 'undefined') {
return 'undefined';
- } else if (!isString(obj)) {
+ } else if (typeof obj !== 'string') {
return JSON.stringify(obj);
}
return obj;
@@ -56,11 +56,11 @@ function minErr(module) {
if (index + 2 < templateArgs.length) {
arg = templateArgs[index + 2];
- if (isFunction(arg)) {
+ if (typeof arg === 'function') {
return arg.toString().replace(/ ?\{[\s\S]*$/, '');
- } else if (isUndefined(arg)) {
+ } else if (typeof arg === 'undefined') {
return 'undefined';
- } else if (!isString(arg)) {
+ } else if (typeof arg !== 'string') {
return toJson(arg);
}
return arg;
@@ -68,7 +68,7 @@ function minErr(module) {
return match;
});
- message = message + '\nhttp://errors.angularjs.org/' + version.full + '/' +
+ message = message + '\nhttp://errors.angularjs.org/1.2.3/' +
(module ? module + '/' : '') + code;
for (i = 2; i < arguments.length; i++) {
message = message + (i == 2 ? '?' : '&') + 'p' + (i-2) + '=' +
@@ -79,6 +79,90 @@ function minErr(module) {
};
}
+/* We need to tell jshint what variables are being exported */
+/* global
+ -angular,
+ -msie,
+ -jqLite,
+ -jQuery,
+ -slice,
+ -push,
+ -toString,
+ -ngMinErr,
+ -_angular,
+ -angularModule,
+ -nodeName_,
+ -uid,
+
+ -lowercase,
+ -uppercase,
+ -manualLowercase,
+ -manualUppercase,
+ -nodeName_,
+ -isArrayLike,
+ -forEach,
+ -sortedKeys,
+ -forEachSorted,
+ -reverseParams,
+ -nextUid,
+ -setHashKey,
+ -extend,
+ -int,
+ -inherit,
+ -noop,
+ -identity,
+ -valueFn,
+ -isUndefined,
+ -isDefined,
+ -isObject,
+ -isString,
+ -isNumber,
+ -isDate,
+ -isArray,
+ -isFunction,
+ -isRegExp,
+ -isWindow,
+ -isScope,
+ -isFile,
+ -isBoolean,
+ -trim,
+ -isElement,
+ -makeMap,
+ -map,
+ -size,
+ -includes,
+ -indexOf,
+ -arrayRemove,
+ -isLeafNode,
+ -copy,
+ -shallowCopy,
+ -equals,
+ -csp,
+ -concat,
+ -sliceArgs,
+ -bind,
+ -toJsonReplacer,
+ -toJson,
+ -fromJson,
+ -toBoolean,
+ -startingTag,
+ -tryDecodeURIComponent,
+ -parseKeyValue,
+ -toKeyValue,
+ -encodeUriSegment,
+ -encodeUriQuery,
+ -angularInit,
+ -bootstrap,
+ -snake_case,
+ -bindJQuery,
+ -assertArg,
+ -assertArgFn,
+ -assertNotHasOwnProperty,
+ -getter,
+ -getBlockElements,
+
+*/
+
////////////////////////////////////
/**
@@ -106,11 +190,13 @@ var uppercase = function(string){return isString(string) ? string.toUpperCase()
var manualLowercase = function(s) {
+ /* jshint bitwise: false */
return isString(s)
? s.replace(/[A-Z]/g, function(ch) {return String.fromCharCode(ch.charCodeAt(0) | 32);})
: s;
};
var manualUppercase = function(s) {
+ /* jshint bitwise: false */
return isString(s)
? s.replace(/[a-z]/g, function(ch) {return String.fromCharCode(ch.charCodeAt(0) & ~32);})
: s;
@@ -156,7 +242,8 @@ if (isNaN(msie)) {
/**
* @private
* @param {*} obj
- * @return {boolean} Returns true if `obj` is an array or array-like object (NodeList, Arguments, String ...)
+ * @return {boolean} Returns true if `obj` is an array or array-like object (NodeList, Arguments,
+ * String ...)
*/
function isArrayLike(obj) {
if (obj == null || isWindow(obj)) {
@@ -250,7 +337,7 @@ function forEachSorted(obj, iterator, context) {
* @returns {function(*, string)}
*/
function reverseParams(iteratorFn) {
- return function(value, key) { iteratorFn(key, value) };
+ return function(value, key) { iteratorFn(key, value); };
}
/**
@@ -536,7 +623,7 @@ var trim = (function() {
// TODO: we should move this into IE/ES5 polyfill
if (!String.prototype.trim) {
return function(value) {
- return isString(value) ? value.replace(/^\s*/, '').replace(/\s*$/, '') : value;
+ return isString(value) ? value.replace(/^\s\s*/, '').replace(/\s\s*$/, '') : value;
};
}
return function(value) {
@@ -609,17 +696,17 @@ function map(obj, iterator, context) {
* @returns {number} The size of `obj` or `0` if `obj` is neither an object nor an array.
*/
function size(obj, ownPropsOnly) {
- var size = 0, key;
+ var count = 0, key;
if (isArray(obj) || isString(obj)) {
return obj.length;
} else if (isObject(obj)){
for (key in obj)
if (!ownPropsOnly || obj.hasOwnProperty(key))
- size++;
+ count++;
}
- return size;
+ return count;
}
@@ -669,9 +756,6 @@ function isLeafNode (node) {
* * If `source` is not an object or array (inc. `null` and `undefined`), `source` is returned.
* * If `source` is identical to 'destination' an exception will be thrown.
*
- * Note: this function is used to augment the Object type in Angular expressions. See
- * {@link ng.$filter} for more information about Angular arrays.
- *
* @param {*} source The source that will be used to make a copy.
* Can be any type, including primitives, `null`, and `undefined`.
* @param {(Object|Array)=} destination Destination into which the source is copied. If
@@ -716,7 +800,8 @@ function isLeafNode (node) {
*/
function copy(source, destination){
if (isWindow(source) || isScope(source)) {
- throw ngMinErr('cpws', "Can't copy! Making copies of Window or Scope instances is not supported.");
+ throw ngMinErr('cpws',
+ "Can't copy! Making copies of Window or Scope instances is not supported.");
}
if (!destination) {
@@ -733,7 +818,8 @@ function copy(source, destination){
}
}
} else {
- if (source === destination) throw ngMinErr('cpi', "Can't copy! Source and destination are identical.");
+ if (source === destination) throw ngMinErr('cpi',
+ "Can't copy! Source and destination are identical.");
if (isArray(source)) {
destination.length = 0;
for ( var i = 0; i < source.length; i++) {
@@ -777,13 +863,14 @@ function shallowCopy(src, dst) {
* @function
*
* @description
- * Determines if two objects or two values are equivalent. Supports value types, regular expressions, arrays and
- * objects.
+ * Determines if two objects or two values are equivalent. Supports value types, regular
+ * expressions, arrays and objects.
*
* Two objects or values are considered equivalent if at least one of the following is true:
*
* * Both objects or values pass `===` comparison.
- * * Both objects or values are of the same type and all of their properties pass `===` comparison.
+ * * Both objects or values are of the same type and all of their properties are equal by
+ * comparing them with `angular.equals`.
* * Both values are NaN. (In JavaScript, NaN == NaN => false. But we consider two NaN as equal)
* * Both values represent the same regular expression (In JavasScript,
* /abc/ == /abc/ => false. But we consider two regular expressions as equal when their textual
@@ -839,6 +926,13 @@ function equals(o1, o2) {
}
+function csp() {
+ return (document.securityPolicy && document.securityPolicy.isActive) ||
+ (document.querySelector &&
+ !!(document.querySelector('[ng-csp]') || document.querySelector('[data-ng-csp]')));
+}
+
+
function concat(array1, array2, index) {
return array1.concat(slice.call(array2, index));
}
@@ -848,6 +942,7 @@ function sliceArgs(args, startIndex) {
}
+/* jshint -W101 */
/**
* @ngdoc function
* @name angular.bind
@@ -856,14 +951,15 @@ function sliceArgs(args, startIndex) {
* @description
* Returns a function which calls function `fn` bound to `self` (`self` becomes the `this` for
* `fn`). You can supply optional `args` that are prebound to the function. This feature is also
- * known as [partial application](http://en.wikipedia.org/wiki/Partial_application), as distinguished
- * from [function currying](http://en.wikipedia.org/wiki/Currying#Contrast_with_partial_function_application).
+ * known as [partial application](http://en.wikipedia.org/wiki/Partial_application), as
+ * distinguished from [function currying](http://en.wikipedia.org/wiki/Currying#Contrast_with_partial_function_application).
*
* @param {Object} self Context which `fn` should be evaluated in.
* @param {function()} fn Function to be bound.
* @param {...*} args Optional arguments to be prebound to the `fn` function call.
* @returns {function()} Function that wraps the `fn` with all the specified bindings.
*/
+/* jshint +W101 */
function bind(self, fn) {
var curryArgs = arguments.length > 2 ? sliceArgs(arguments, 2) : [];
if (isFunction(fn) && !(fn instanceof RegExp)) {
@@ -1023,10 +1119,12 @@ function toKeyValue(obj) {
forEach(obj, function(value, key) {
if (isArray(value)) {
forEach(value, function(arrayValue) {
- parts.push(encodeUriQuery(key, true) + (arrayValue === true ? '' : '=' + encodeUriQuery(arrayValue, true)));
+ parts.push(encodeUriQuery(key, true) +
+ (arrayValue === true ? '' : '=' + encodeUriQuery(arrayValue, true)));
});
} else {
- parts.push(encodeUriQuery(key, true) + (value === true ? '' : '=' + encodeUriQuery(value, true)));
+ parts.push(encodeUriQuery(key, true) +
+ (value === true ? '' : '=' + encodeUriQuery(value, true)));
}
});
return parts.length ? parts.join('&') : '';
@@ -1083,26 +1181,38 @@ function encodeUriQuery(val, pctEncodeSpaces) {
*
* @description
*
- * Use this directive to auto-bootstrap an application. Only
- * one ngApp directive can be used per HTML document. The directive
- * designates the root of the application and is typically placed
- * at the root of the page.
- *
- * The first ngApp found in the document will be auto-bootstrapped. To use multiple applications in an
- * HTML document you must manually bootstrap them using {@link angular.bootstrap}.
- * Applications cannot be nested.
- *
- * In the example below if the `ngApp` directive were not placed
- * on the `html` element then the document would not be compiled
- * and the `{{ 1+2 }}` would not be resolved to `3`.
- *
- * `ngApp` is the easiest way to bootstrap an application.
- *
- <doc:example>
- <doc:source>
- I can add: 1 + 2 = {{ 1+2 }}
- </doc:source>
- </doc:example>
+ * Use this directive to **auto-bootstrap** an AngularJS application. The `ngApp` directive
+ * designates the **root element** of the application and is typically placed near the root element
+ * of the page - e.g. on the `<body>` or `<html>` tags.
+ *
+ * Only one AngularJS application can be auto-bootstrapped per HTML document. The first `ngApp`
+ * found in the document will be used to define the root element to auto-bootstrap as an
+ * application. To run multiple applications in an HTML document you must manually bootstrap them using
+ * {@link angular.bootstrap} instead. AngularJS applications cannot be nested within each other.
+ *
+ * You can specify an **AngularJS module** to be used as the root module for the application. This
+ * module will be loaded into the {@link AUTO.$injector} when the application is bootstrapped and
+ * should contain the application code needed or have dependencies on other modules that will
+ * contain the code. See {@link angular.module} for more information.
+ *
+ * In the example below if the `ngApp` directive were not placed on the `html` element then the
+ * document would not be compiled, the `AppController` would not be instantiated and the `{{ a+b }}`
+ * would not be resolved to `3`.
+ *
+ * `ngApp` is the easiest, and most common, way to bootstrap an application.
+ *
+ <example module="ngAppDemo">
+ <file name="index.html">
+ <div ng-controller="ngAppDemoController">
+ I can add: {{a}} + {{b}} = {{ a+b }}
+ </file>
+ <file name="script.js">
+ angular.module('ngAppDemo', []).controller('ngAppDemoController', function($scope) {
+ $scope.a = 1;
+ $scope.b = 2;
+ });
+ </file>
+ </example>
*
*/
function angularInit(element, bootstrap) {
@@ -1163,7 +1273,8 @@ function angularInit(element, bootstrap) {
* @param {Element} element DOM element which is the root of angular application.
* @param {Array<String|Function|Array>=} modules an array of modules to load into the application.
* Each item in the array should be the name of a predefined module or a (DI annotated)
- * function that will be invoked by the injector as a run block. See: {@link angular.module modules}
+ * function that will be invoked by the injector as a run block.
+ * See: {@link angular.module modules}
* @returns {AUTO.$injector} Returns the newly created injector for this app.
*/
function bootstrap(element, modules) {
@@ -1187,7 +1298,6 @@ function bootstrap(element, modules) {
element.data('$injector', injector);
compile(element)(scope);
});
- animate.enabled(true);
}]
);
return injector;
@@ -1224,14 +1334,16 @@ function bindJQuery() {
jqLite = jQuery;
extend(jQuery.fn, {
scope: JQLitePrototype.scope,
+ isolateScope: JQLitePrototype.isolateScope,
controller: JQLitePrototype.controller,
injector: JQLitePrototype.injector,
inheritedData: JQLitePrototype.inheritedData
});
- // Method signature: JQLitePatchJQueryRemove(name, dispatchThis, filterElems, getterIfNoArguments)
- JQLitePatchJQueryRemove('remove', true, true, false);
- JQLitePatchJQueryRemove('empty', false, false, false);
- JQLitePatchJQueryRemove('html', false, false, true);
+ // Method signature:
+ // jqLitePatchJQueryRemove(name, dispatchThis, filterElems, getterIfNoArguments)
+ jqLitePatchJQueryRemove('remove', true, true, false);
+ jqLitePatchJQueryRemove('empty', false, false, false);
+ jqLitePatchJQueryRemove('html', false, false, true);
} else {
jqLite = JQLite;
}
@@ -1297,6 +1409,28 @@ function getter(obj, path, bindFnToScope) {
}
/**
+ * Return the siblings between `startNode` and `endNode`, inclusive
+ * @param {Object} object with `startNode` and `endNode` properties
+ * @returns jQlite object containing the elements
+ */
+function getBlockElements(block) {
+ if (block.startNode === block.endNode) {
+ return jqLite(block.startNode);
+ }
+
+ var element = block.startNode;
+ var elements = [element];
+
+ do {
+ element = element.nextSibling;
+ if (!element) break;
+ elements.push(element);
+ } while (element !== block.endNode);
+
+ return jqLite(elements);
+}
+
+/**
* @ngdoc interface
* @name angular.Module
* @description
@@ -1307,12 +1441,18 @@ function getter(obj, path, bindFnToScope) {
function setupModuleLoader(window) {
var $injectorMinErr = minErr('$injector');
+ var ngMinErr = minErr('ng');
function ensure(obj, name, factory) {
return obj[name] || (obj[name] = factory());
}
- return ensure(ensure(window, 'angular', Object), 'module', function() {
+ 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 = {};
@@ -1321,7 +1461,8 @@ function setupModuleLoader(window) {
* @name angular.module
* @description
*
- * The `angular.module` is a global place for creating, registering and retrieving Angular modules.
+ * 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.
*
@@ -1359,22 +1500,28 @@ function setupModuleLoader(window) {
* {@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
- * the module is being retrieved for further configuration.
+ * @param {Array.<string>=} requires If specified then new module is being created. If
+ * unspecified then the 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()}.
+ * {@link angular.Module#methods_config Module#config()}.
* @returns {module} new module with the {@link angular.Module} api.
*/
return function module(name, requires, configFn) {
+ 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);
+ 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.<*>>} */
@@ -1397,7 +1544,8 @@ function setupModuleLoader(window) {
* @propertyOf angular.Module
* @returns {Array.<string>} List of module names which must be loaded before this module.
* @description
- * Holds the list of modules which the injector will load before the current module is loaded.
+ * Holds the list of modules which the injector will load before the current module is
+ * loaded.
*/
requires: requires,
@@ -1416,7 +1564,8 @@ function setupModuleLoader(window) {
* @name angular.Module#provider
* @methodOf angular.Module
* @param {string} name service name
- * @param {Function} providerType Construction function for creating new instance of the service.
+ * @param {Function} providerType Construction function for creating new instance of the
+ * service.
* @description
* See {@link AUTO.$provide#provider $provide.provider()}.
*/
@@ -1472,14 +1621,15 @@ function setupModuleLoader(window) {
* @name angular.Module#animation
* @methodOf angular.Module
* @param {string} name animation name
- * @param {Function} animationFactory Factory function for creating new instance of an animation.
+ * @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 ngAnimate.$animate $animate} service and
- * directives that use this service.
+ * Defines an animation hook that can be later used with
+ * {@link ngAnimate.$animate $animate} service and directives that use this service.
*
* <pre>
* module.animation('.animation-name', function($inject1, $inject2) {
@@ -1532,7 +1682,7 @@ function setupModuleLoader(window) {
* @param {Function} directiveFactory Factory function for creating new instance of
* directives.
* @description
- * See {@link ng.$compileProvider#directive $compileProvider.directive()}.
+ * See {@link ng.$compileProvider#methods_directive $compileProvider.directive()}.
*/
directive: invokeLater('$compileProvider', 'directive'),
@@ -1579,7 +1729,7 @@ function setupModuleLoader(window) {
return function() {
invokeQueue[insertMethod || 'push']([provider, method, arguments]);
return moduleInstance;
- }
+ };
}
});
};
@@ -1587,6 +1737,81 @@ function setupModuleLoader(window) {
}
+/* global
+ angularModule: true,
+ version: true,
+
+ $LocaleProvider,
+ $CompileProvider,
+
+ htmlAnchorDirective,
+ inputDirective,
+ inputDirective,
+ formDirective,
+ scriptDirective,
+ selectDirective,
+ styleDirective,
+ optionDirective,
+ ngBindDirective,
+ ngBindHtmlDirective,
+ ngBindTemplateDirective,
+ ngClassDirective,
+ ngClassEvenDirective,
+ ngClassOddDirective,
+ ngCspDirective,
+ ngCloakDirective,
+ ngControllerDirective,
+ ngFormDirective,
+ ngHideDirective,
+ ngIfDirective,
+ ngIncludeDirective,
+ ngInitDirective,
+ ngNonBindableDirective,
+ ngPluralizeDirective,
+ ngRepeatDirective,
+ ngShowDirective,
+ ngStyleDirective,
+ ngSwitchDirective,
+ ngSwitchWhenDirective,
+ ngSwitchDefaultDirective,
+ ngOptionsDirective,
+ ngTranscludeDirective,
+ ngModelDirective,
+ ngListDirective,
+ ngChangeDirective,
+ requiredDirective,
+ requiredDirective,
+ ngValueDirective,
+ ngAttributeAliasDirectives,
+ ngEventDirectives,
+
+ $AnchorScrollProvider,
+ $AnimateProvider,
+ $BrowserProvider,
+ $CacheFactoryProvider,
+ $ControllerProvider,
+ $DocumentProvider,
+ $ExceptionHandlerProvider,
+ $FilterProvider,
+ $InterpolateProvider,
+ $IntervalProvider,
+ $HttpProvider,
+ $HttpBackendProvider,
+ $LocationProvider,
+ $LogProvider,
+ $ParseProvider,
+ $RootScopeProvider,
+ $QProvider,
+ $$SanitizeUriProvider,
+ $SceProvider,
+ $SceDelegateProvider,
+ $SnifferProvider,
+ $TemplateCacheProvider,
+ $TimeoutProvider,
+ $WindowProvider
+*/
+
+
/**
* @ngdoc property
* @name angular.version
@@ -1601,11 +1826,11 @@ function setupModuleLoader(window) {
* - `codeName` – `{string}` – Code name of the release, such as "jiggling-armfat".
*/
var version = {
- full: '1.2.0-rc.3', // all of these placeholder strings will be replaced by grunt's
+ full: '1.2.3', // all of these placeholder strings will be replaced by grunt's
major: 1, // package task
minor: 2,
- dot: 0,
- codeName: 'ferocious-twitch'
+ dot: 3,
+ codeName: 'unicorn-zapper'
};
@@ -1631,12 +1856,13 @@ function publishExternalAPI(angular){
'isNumber': isNumber,
'isElement': isElement,
'isArray': isArray,
- '$$minErr': minErr,
'version': version,
'isDate': isDate,
'lowercase': lowercase,
'uppercase': uppercase,
- 'callbacks': {counter: 0}
+ 'callbacks': {counter: 0},
+ '$$minErr': minErr,
+ '$$csp': csp
});
angularModule = setupModuleLoader(window);
@@ -1648,6 +1874,10 @@ function publishExternalAPI(angular){
angularModule('ng', ['ngLocale'], ['$provide',
function ngModule($provide) {
+ // $$sanitizeUriProvider needs to be before $compileProvider as it is used by it.
+ $provide.provider({
+ $$sanitizeUri: $$SanitizeUriProvider
+ });
$provide.provider('$compile', $CompileProvider).
directive({
a: htmlAnchorDirective,
@@ -1664,7 +1894,6 @@ function publishExternalAPI(angular){
ngClass: ngClassDirective,
ngClassEven: ngClassEvenDirective,
ngClassOdd: ngClassOddDirective,
- ngCsp: ngCspDirective,
ngCloak: ngCloakDirective,
ngController: ngControllerDirective,
ngForm: ngFormDirective,
@@ -1720,6 +1949,14 @@ function publishExternalAPI(angular){
]);
}
+/* global
+
+ -JQLitePrototype,
+ -addEventListenerFn,
+ -removeEventListenerFn,
+ -BOOLEAN_ATTR
+*/
+
//////////////////////////////////
//JQLite
//////////////////////////////////
@@ -1797,6 +2034,9 @@ function publishExternalAPI(angular){
* - `injector()` - retrieves the injector of the current element or its parent.
* - `scope()` - retrieves the {@link api/ng.$rootScope.Scope scope} of the current
* element or its parent.
+ * - `isolateScope()` - retrieves an isolate {@link api/ng.$rootScope.Scope scope} if one is attached directly to the
+ * current element. This getter should be used only on elements that contain a directive which starts a new isolate
+ * scope. Calling `scope()` on this element always returns the original non-isolate scope.
* - `inheritedData()` - same as `data()`, but walks up the DOM until a value is found or the top
* parent element is reached.
*
@@ -1842,13 +2082,14 @@ function camelCase(name) {
//
/////////////////////////////////////////////
-function JQLitePatchJQueryRemove(name, dispatchThis, filterElems, getterIfNoArguments) {
+function jqLitePatchJQueryRemove(name, dispatchThis, filterElems, getterIfNoArguments) {
var originalJqFn = jQuery.fn[name];
originalJqFn = originalJqFn.$original || originalJqFn;
removePatch.$original = originalJqFn;
jQuery.fn[name] = removePatch;
function removePatch(param) {
+ // jshint -W040
var list = filterElems && param ? [this.filter(param)] : [this],
fireEvent = dispatchThis,
set, setIndex, setLength,
@@ -1894,30 +2135,30 @@ function JQLite(element) {
// http://msdn.microsoft.com/en-us/library/ms533897(VS.85).aspx
div.innerHTML = '<div> </div>' + element; // IE insanity to make NoScope elements work!
div.removeChild(div.firstChild); // remove the superfluous div
- JQLiteAddNodes(this, div.childNodes);
+ jqLiteAddNodes(this, div.childNodes);
var fragment = jqLite(document.createDocumentFragment());
fragment.append(this); // detach the elements from the temporary DOM div.
} else {
- JQLiteAddNodes(this, element);
+ jqLiteAddNodes(this, element);
}
}
-function JQLiteClone(element) {
+function jqLiteClone(element) {
return element.cloneNode(true);
}
-function JQLiteDealoc(element){
- JQLiteRemoveData(element);
+function jqLiteDealoc(element){
+ jqLiteRemoveData(element);
for ( var i = 0, children = element.childNodes || []; i < children.length; i++) {
- JQLiteDealoc(children[i]);
+ jqLiteDealoc(children[i]);
}
}
-function JQLiteOff(element, type, fn, unsupported) {
+function jqLiteOff(element, type, fn, unsupported) {
if (isDefined(unsupported)) throw jqLiteMinErr('offargs', 'jqLite#off() does not support the `selector` argument');
- var events = JQLiteExpandoStore(element, 'events'),
- handle = JQLiteExpandoStore(element, 'handle');
+ var events = jqLiteExpandoStore(element, 'events'),
+ handle = jqLiteExpandoStore(element, 'handle');
if (!handle) return; //no listeners registered
@@ -1938,7 +2179,7 @@ function JQLiteOff(element, type, fn, unsupported) {
}
}
-function JQLiteRemoveData(element, name) {
+function jqLiteRemoveData(element, name) {
var expandoId = element[jqName],
expandoStore = jqCache[expandoId];
@@ -1950,14 +2191,14 @@ function JQLiteRemoveData(element, name) {
if (expandoStore.handle) {
expandoStore.events.$destroy && expandoStore.handle({}, '$destroy');
- JQLiteOff(element);
+ jqLiteOff(element);
}
delete jqCache[expandoId];
element[jqName] = undefined; // ie does not allow deletion of attributes on elements.
}
}
-function JQLiteExpandoStore(element, key, value) {
+function jqLiteExpandoStore(element, key, value) {
var expandoId = element[jqName],
expandoStore = jqCache[expandoId || -1];
@@ -1972,14 +2213,14 @@ function JQLiteExpandoStore(element, key, value) {
}
}
-function JQLiteData(element, key, value) {
- var data = JQLiteExpandoStore(element, 'data'),
+function jqLiteData(element, key, value) {
+ var data = jqLiteExpandoStore(element, 'data'),
isSetter = isDefined(value),
keyDefined = !isSetter && isDefined(key),
isSimpleGetter = keyDefined && !isObject(key);
if (!data && !isSimpleGetter) {
- JQLiteExpandoStore(element, 'data', data = {});
+ jqLiteExpandoStore(element, 'data', data = {});
}
if (isSetter) {
@@ -1998,13 +2239,13 @@ function JQLiteData(element, key, value) {
}
}
-function JQLiteHasClass(element, selector) {
+function jqLiteHasClass(element, selector) {
if (!element.getAttribute) return false;
return ((" " + (element.getAttribute('class') || '') + " ").replace(/[\n\t]/g, " ").
indexOf( " " + selector + " " ) > -1);
}
-function JQLiteRemoveClass(element, cssClasses) {
+function jqLiteRemoveClass(element, cssClasses) {
if (cssClasses && element.setAttribute) {
forEach(cssClasses.split(' '), function(cssClass) {
element.setAttribute('class', trim(
@@ -2016,7 +2257,7 @@ function JQLiteRemoveClass(element, cssClasses) {
}
}
-function JQLiteAddClass(element, cssClasses) {
+function jqLiteAddClass(element, cssClasses) {
if (cssClasses && element.setAttribute) {
var existingClasses = (' ' + (element.getAttribute('class') || '') + ' ')
.replace(/[\n\t]/g, " ");
@@ -2032,7 +2273,7 @@ function JQLiteAddClass(element, cssClasses) {
}
}
-function JQLiteAddNodes(root, elements) {
+function jqLiteAddNodes(root, elements) {
if (elements) {
elements = (!elements.nodeName && isDefined(elements.length) && !isWindow(elements))
? elements
@@ -2043,11 +2284,11 @@ function JQLiteAddNodes(root, elements) {
}
}
-function JQLiteController(element, name) {
- return JQLiteInheritedData(element, '$' + (name || 'ngController' ) + 'Controller');
+function jqLiteController(element, name) {
+ return jqLiteInheritedData(element, '$' + (name || 'ngController' ) + 'Controller');
}
-function JQLiteInheritedData(element, name, value) {
+function jqLiteInheritedData(element, name, value) {
element = jqLite(element);
// if element is the document object work with the html element instead
@@ -2055,9 +2296,13 @@ function JQLiteInheritedData(element, name, value) {
if(element[0].nodeType == 9) {
element = element.find('html');
}
+ var names = isArray(name) ? name : [name];
while (element.length) {
- if ((value = element.data(name)) !== undefined) return value;
+
+ for (var i = 0, ii = names.length; i < ii; i++) {
+ if ((value = element.data(names[i])) !== undefined) return value;
+ }
element = element.parent();
}
}
@@ -2081,7 +2326,9 @@ var JQLitePrototype = JQLite.prototype = {
} else {
this.on('DOMContentLoaded', trigger); // works for modern browsers and IE9
// we can not use jqLite since we are not done loading and jQuery could be loaded later.
+ // jshint -W064
JQLite(window).on('load', trigger); // fallback to window.onload for others
+ // jshint +W064
}
},
toString: function() {
@@ -2123,24 +2370,30 @@ function getBooleanAttrName(element, name) {
}
forEach({
- data: JQLiteData,
- inheritedData: JQLiteInheritedData,
+ data: jqLiteData,
+ inheritedData: jqLiteInheritedData,
scope: function(element) {
- return JQLiteInheritedData(element, '$scope');
+ // Can't use jqLiteData here directly so we stay compatible with jQuery!
+ return jqLite(element).data('$scope') || jqLiteInheritedData(element.parentNode || element, ['$isolateScope', '$scope']);
},
- controller: JQLiteController ,
+ isolateScope: function(element) {
+ // Can't use jqLiteData here directly so we stay compatible with jQuery!
+ return jqLite(element).data('$isolateScope') || jqLite(element).data('$isolateScopeNoTemplate');
+ },
+
+ controller: jqLiteController ,
injector: function(element) {
- return JQLiteInheritedData(element, '$injector');
+ return jqLiteInheritedData(element, '$injector');
},
removeAttr: function(element,name) {
element.removeAttribute(name);
},
- hasClass: JQLiteHasClass,
+ hasClass: jqLiteHasClass,
css: function(element, name, value) {
name = camelCase(name);
@@ -2216,7 +2469,7 @@ forEach({
return getText;
function getText(element, value) {
- var textProp = NODE_TYPE_TEXT_PROPERTY[element.nodeType]
+ var textProp = NODE_TYPE_TEXT_PROPERTY[element.nodeType];
if (isUndefined(value)) {
return textProp ? element[textProp] : '';
}
@@ -2245,7 +2498,7 @@ forEach({
return element.innerHTML;
}
for (var i = 0, childNodes = element.childNodes; i < childNodes.length; i++) {
- JQLiteDealoc(childNodes[i]);
+ jqLiteDealoc(childNodes[i]);
}
element.innerHTML = value;
}
@@ -2256,14 +2509,14 @@ forEach({
JQLite.prototype[name] = function(arg1, arg2) {
var i, key;
- // JQLiteHasClass has only two arguments, but is a getter-only fn, so we need to special-case it
+ // jqLiteHasClass has only two arguments, but is a getter-only fn, so we need to special-case it
// in a way that survives minification.
- if (((fn.length == 2 && (fn !== JQLiteHasClass && fn !== JQLiteController)) ? arg1 : arg2) === undefined) {
+ if (((fn.length == 2 && (fn !== jqLiteHasClass && fn !== jqLiteController)) ? arg1 : arg2) === undefined) {
if (isObject(arg1)) {
// we are a write, but the object properties are the key/values
for(i=0; i < this.length; i++) {
- if (fn === JQLiteData) {
+ if (fn === jqLiteData) {
// data() takes the whole object in jQuery
fn(this[i], arg1);
} else {
@@ -2278,7 +2531,7 @@ forEach({
// we are a read, so read the first child.
var value = fn.$dv;
// Only if we have $dv do we iterate over all, otherwise it is just the first element.
- var jj = value == undefined ? Math.min(this.length, 1) : this.length;
+ var jj = (value === undefined) ? Math.min(this.length, 1) : this.length;
for (var j = 0; j < jj; j++) {
var nodeValue = fn(this[j], arg1, arg2);
value = value ? value + nodeValue : nodeValue;
@@ -2324,7 +2577,7 @@ function createEventHandler(element, events) {
}
event.isDefaultPrevented = function() {
- return event.defaultPrevented || event.returnValue == false;
+ return event.defaultPrevented || event.returnValue === false;
};
forEach(events[type || event.type], function(fn) {
@@ -2355,18 +2608,18 @@ function createEventHandler(element, events) {
// selector.
//////////////////////////////////////////
forEach({
- removeData: JQLiteRemoveData,
+ removeData: jqLiteRemoveData,
- dealoc: JQLiteDealoc,
+ dealoc: jqLiteDealoc,
on: function onFn(element, type, fn, unsupported){
if (isDefined(unsupported)) throw jqLiteMinErr('onargs', 'jqLite#on() does not support the `selector` or `eventData` parameters');
- var events = JQLiteExpandoStore(element, 'events'),
- handle = JQLiteExpandoStore(element, 'handle');
+ var events = jqLiteExpandoStore(element, 'events'),
+ handle = jqLiteExpandoStore(element, 'handle');
- if (!events) JQLiteExpandoStore(element, 'events', events = {});
- if (!handle) JQLiteExpandoStore(element, 'handle', handle = createEventHandler(element, events));
+ if (!events) jqLiteExpandoStore(element, 'events', events = {});
+ if (!handle) jqLiteExpandoStore(element, 'handle', handle = createEventHandler(element, events));
forEach(type.split(' '), function(type){
var eventFns = events[type];
@@ -2375,6 +2628,7 @@ forEach({
if (type == 'mouseenter' || type == 'mouseleave') {
var contains = document.body.contains || document.body.compareDocumentPosition ?
function( a, b ) {
+ // jshint bitwise: false
var adown = a.nodeType === 9 ? a.documentElement : a,
bup = b && b.parentNode;
return a === bup || !!( bup && bup.nodeType === 1 && (
@@ -2414,17 +2668,17 @@ forEach({
addEventListenerFn(element, type, handle);
events[type] = [];
}
- eventFns = events[type]
+ eventFns = events[type];
}
eventFns.push(fn);
});
},
- off: JQLiteOff,
+ off: jqLiteOff,
replaceWith: function(element, replaceNode) {
var index, parent = element.parentNode;
- JQLiteDealoc(element);
+ jqLiteDealoc(element);
forEach(new JQLite(replaceNode), function(node){
if (index) {
parent.insertBefore(node, index.nextSibling);
@@ -2475,7 +2729,7 @@ forEach({
},
remove: function(element) {
- JQLiteDealoc(element);
+ jqLiteDealoc(element);
var parent = element.parentNode;
if (parent) parent.removeChild(element);
},
@@ -2488,14 +2742,14 @@ forEach({
});
},
- addClass: JQLiteAddClass,
- removeClass: JQLiteRemoveClass,
+ addClass: jqLiteAddClass,
+ removeClass: jqLiteRemoveClass,
toggleClass: function(element, selector, condition) {
if (isUndefined(condition)) {
- condition = !JQLiteHasClass(element, selector);
+ condition = !jqLiteHasClass(element, selector);
}
- (condition ? JQLiteAddClass : JQLiteRemoveClass)(element, selector);
+ (condition ? jqLiteAddClass : jqLiteRemoveClass)(element, selector);
},
parent: function(element) {
@@ -2520,11 +2774,11 @@ forEach({
return element.getElementsByTagName(selector);
},
- clone: JQLiteClone,
+ clone: jqLiteClone,
triggerHandler: function(element, eventName, eventData) {
- var eventFns = (JQLiteExpandoStore(element, 'events') || {})[eventName];
-
+ var eventFns = (jqLiteExpandoStore(element, 'events') || {})[eventName];
+
eventData = eventData || [];
var event = [{
@@ -2543,17 +2797,17 @@ forEach({
JQLite.prototype[name] = function(arg1, arg2, arg3) {
var value;
for(var i=0; i < this.length; i++) {
- if (value == undefined) {
+ if (isUndefined(value)) {
value = fn(this[i], arg1, arg2, arg3);
- if (value !== undefined) {
+ if (isDefined(value)) {
// any function which returns a value needs to be wrapped
value = jqLite(value);
}
} else {
- JQLiteAddNodes(value, fn(this[i], arg1, arg2, arg3));
+ jqLiteAddNodes(value, fn(this[i], arg1, arg2, arg3));
}
}
- return value == undefined ? this : value;
+ return isDefined(value) ? value : this;
};
// bind legacy bind/unbind to on/off
@@ -2742,9 +2996,9 @@ function annotate(fn) {
*
* ## Inference
*
- * In JavaScript calling `toString()` on a function returns the function definition. The definition can then be
- * parsed and the function arguments can be extracted. *NOTE:* This does not work with minification, and obfuscation
- * tools since these tools change the argument names.
+ * In JavaScript calling `toString()` on a function returns the function definition. The definition
+ * can then be parsed and the function arguments can be extracted. *NOTE:* This does not work with
+ * minification, and obfuscation tools since these tools change the argument names.
*
* ## `$inject` Annotation
* By adding a `$inject` property onto a function the injection parameters can be specified.
@@ -2776,8 +3030,8 @@ function annotate(fn) {
* @param {!function} fn The function to invoke. Function parameters are injected according to the
* {@link guide/di $inject Annotation} rules.
* @param {Object=} self The `this` for the invoked method.
- * @param {Object=} locals Optional object. If preset then any argument names are read from this object first, before
- * the `$injector` is consulted.
+ * @param {Object=} locals Optional object. If preset then any argument names are read from this
+ * object first, before the `$injector` is consulted.
* @returns {*} the value returned by the invoked `fn` function.
*/
@@ -2798,12 +3052,13 @@ function annotate(fn) {
* @name AUTO.$injector#instantiate
* @methodOf AUTO.$injector
* @description
- * Create a new instance of JS type. The method takes a constructor function invokes the new operator and supplies
- * all of the arguments to the constructor function as specified by the constructor annotation.
+ * Create a new instance of JS type. The method takes a constructor function invokes the new
+ * operator and supplies all of the arguments to the constructor function as specified by the
+ * constructor annotation.
*
* @param {function} Type Annotated constructor function.
- * @param {Object=} locals Optional object. If preset then any argument names are read from this object first, before
- * the `$injector` is consulted.
+ * @param {Object=} locals Optional object. If preset then any argument names are read from this
+ * object first, before the `$injector` is consulted.
* @returns {Object} new instance of `Type`.
*/
@@ -2813,14 +3068,16 @@ function annotate(fn) {
* @methodOf AUTO.$injector
*
* @description
- * Returns an array of service names which the function is requesting for injection. This API is used by the injector
- * to determine which services need to be injected into the function when the function is invoked. There are three
- * ways in which the function can be annotated with the needed dependencies.
+ * Returns an array of service names which the function is requesting for injection. This API is
+ * used by the injector to determine which services need to be injected into the function when the
+ * function is invoked. There are three ways in which the function can be annotated with the needed
+ * dependencies.
*
* # Argument names
*
- * The simplest form is to extract the dependencies from the arguments of the function. This is done by converting
- * the function into a string using `toString()` method and extracting the argument names.
+ * The simplest form is to extract the dependencies from the arguments of the function. This is done
+ * by converting the function into a string using `toString()` method and extracting the argument
+ * names.
* <pre>
* // Given
* function MyController($scope, $route) {
@@ -2831,13 +3088,13 @@ function annotate(fn) {
* expect(injector.annotate(MyController)).toEqual(['$scope', '$route']);
* </pre>
*
- * This method does not work with code minification / obfuscation. For this reason the following annotation strategies
- * are supported.
+ * This method does not work with code minification / obfuscation. For this reason the following
+ * annotation strategies are supported.
*
* # The `$inject` property
*
- * If a function has an `$inject` property and its value is an array of strings, then the strings represent names of
- * services to be injected into the function.
+ * If a function has an `$inject` property and its value is an array of strings, then the strings
+ * represent names of services to be injected into the function.
* <pre>
* // Given
* var MyController = function(obfuscatedScope, obfuscatedRoute) {
@@ -2852,9 +3109,9 @@ function annotate(fn) {
*
* # The array notation
*
- * It is often desirable to inline Injected functions and that's when setting the `$inject` property is very
- * inconvenient. In these situations using the array notation to specify the dependencies in a way that survives
- * minification is a better choice:
+ * It is often desirable to inline Injected functions and that's when setting the `$inject` property
+ * is very inconvenient. In these situations using the array notation to specify the dependencies in
+ * a way that survives minification is a better choice:
*
* <pre>
* // We wish to write this (not minification / obfuscation safe)
@@ -2880,8 +3137,8 @@ function annotate(fn) {
* ).toEqual(['$compile', '$rootScope']);
* </pre>
*
- * @param {function|Array.<string|Function>} fn Function for which dependent service names need to be retrieved as described
- * above.
+ * @param {function|Array.<string|Function>} fn Function for which dependent service names need to
+ * be retrieved as described above.
*
* @returns {Array.<string>} The names of the services which the function requires.
*/
@@ -2895,35 +3152,36 @@ function annotate(fn) {
*
* @description
*
- * The {@link AUTO.$provide $provide} service has a number of methods for registering components with
- * the {@link AUTO.$injector $injector}. Many of these functions are also exposed on {@link angular.Module}.
+ * The {@link AUTO.$provide $provide} service has a number of methods for registering components
+ * with the {@link AUTO.$injector $injector}. Many of these functions are also exposed on
+ * {@link angular.Module}.
*
* An Angular **service** is a singleton object created by a **service factory**. These **service
* factories** are functions which, in turn, are created by a **service provider**.
- * The **service providers** are constructor functions. When instantiated they must contain a property
- * called `$get`, which holds the **service factory** function.
- *
+ * The **service providers** are constructor functions. When instantiated they must contain a
+ * property called `$get`, which holds the **service factory** function.
+ *
* When you request a service, the {@link AUTO.$injector $injector} is responsible for finding the
* correct **service provider**, instantiating it and then calling its `$get` **service factory**
* function to get the instance of the **service**.
- *
+ *
* Often services have no configuration options and there is no need to add methods to the service
* provider. The provider will be no more than a constructor function with a `$get` property. For
* these cases the {@link AUTO.$provide $provide} service has additional helper methods to register
* services without specifying a provider.
*
- * * {@link AUTO.$provide#provider provider(provider)} - registers a **service provider** with the
+ * * {@link AUTO.$provide#methods_provider provider(provider)} - registers a **service provider** with the
* {@link AUTO.$injector $injector}
- * * {@link AUTO.$provide#constant constant(obj)} - registers a value/object that can be accessed by
+ * * {@link AUTO.$provide#methods_constant constant(obj)} - registers a value/object that can be accessed by
* providers and services.
- * * {@link AUTO.$provide#value value(obj)} - registers a value/object that can only be accessed by
+ * * {@link AUTO.$provide#methods_value value(obj)} - registers a value/object that can only be accessed by
* services, not providers.
- * * {@link AUTO.$provide#factory factory(fn)} - registers a service **factory function**, `fn`, that
- * will be wrapped in a **service provider** object, whose `$get` property will contain the given
- * factory function.
- * * {@link AUTO.$provide#service service(class)} - registers a **constructor function**, `class` that
- * will be wrapped in a **service provider** object, whose `$get` property will instantiate a new
- * object using the given constructor function.
+ * * {@link AUTO.$provide#methods_factory factory(fn)} - registers a service **factory function**, `fn`,
+ * that will be wrapped in a **service provider** object, whose `$get` property will contain the
+ * given factory function.
+ * * {@link AUTO.$provide#methods_service service(class)} - registers a **constructor function**, `class` that
+ * that will be wrapped in a **service provider** object, whose `$get` property will instantiate
+ * a new object using the given constructor function.
*
* See the individual methods for more information and examples.
*/
@@ -2934,33 +3192,38 @@ function annotate(fn) {
* @methodOf AUTO.$provide
* @description
*
- * Register a **provider function** with the {@link AUTO.$injector $injector}. Provider functions are
- * constructor functions, whose instances are responsible for "providing" a factory for a service.
- *
+ * Register a **provider function** with the {@link AUTO.$injector $injector}. Provider functions
+ * are constructor functions, whose instances are responsible for "providing" a factory for a
+ * service.
+ *
* Service provider names start with the name of the service they provide followed by `Provider`.
- * For example, the {@link ng.$log $log} service has a provider called {@link ng.$logProvider $logProvider}.
+ * For example, the {@link ng.$log $log} service has a provider called
+ * {@link ng.$logProvider $logProvider}.
*
- * Service provider objects can have additional methods which allow configuration of the provider and
- * its service. Importantly, you can configure what kind of service is created by the `$get` method,
- * or how that service will act. For example, the {@link ng.$logProvider $logProvider} has a method
- * {@link ng.$logProvider#debugEnabled debugEnabled}
+ * Service provider objects can have additional methods which allow configuration of the provider
+ * and its service. Importantly, you can configure what kind of service is created by the `$get`
+ * method, or how that service will act. For example, the {@link ng.$logProvider $logProvider} has a
+ * method {@link ng.$logProvider#debugEnabled debugEnabled}
* which lets you specify whether the {@link ng.$log $log} service will log debug messages to the
* console or not.
*
- * @param {string} name The name of the instance. NOTE: the provider will be available under `name + 'Provider'` key.
+ * @param {string} name The name of the instance. NOTE: the provider will be available under `name +
+ 'Provider'` key.
* @param {(Object|function())} provider If the provider is:
*
* - `Object`: then it should have a `$get` method. The `$get` method will be invoked using
- * {@link AUTO.$injector#invoke $injector.invoke()} when an instance needs to be created.
+ * {@link AUTO.$injector#invoke $injector.invoke()} when an instance needs to be
+ * created.
* - `Constructor`: a new instance of the provider will be created using
- * {@link AUTO.$injector#instantiate $injector.instantiate()}, then treated as `object`.
+ * {@link AUTO.$injector#instantiate $injector.instantiate()}, then treated as
+ * `object`.
*
* @returns {Object} registered provider instance
* @example
*
* The following example shows how to create a simple event tracking service and register it using
- * {@link AUTO.$provide#provider $provide.provider()}.
+ * {@link AUTO.$provide#methods_provider $provide.provider()}.
*
* <pre>
* // Define the eventTracker provider
@@ -3031,16 +3294,16 @@ function annotate(fn) {
* Register a **service factory**, which will be called to return the service instance.
* This is short for registering a service where its provider consists of only a `$get` property,
* which is the given service factory function.
- * You should use {@link AUTO.$provide#factory $provide.factor(getFn)} if you do not need to configure
- * your service in a provider.
+ * You should use {@link AUTO.$provide#factory $provide.factory(getFn)} if you do not need to
+ * configure your service in a provider.
*
* @param {string} name The name of the instance.
- * @param {function()} $getFn The $getFn for the instance creation. Internally this is a short hand for
- * `$provide.provider(name, {$get: $getFn})`.
+ * @param {function()} $getFn The $getFn for the instance creation. Internally this is a short hand
+ * for `$provide.provider(name, {$get: $getFn})`.
* @returns {Object} registered provider instance
*
* @example
- * Here is an example of registering a service
+ * Here is an example of registering a service
* <pre>
* $provide.factory('ping', ['$http', function($http) {
* return function ping() {
@@ -3063,11 +3326,12 @@ function annotate(fn) {
* @methodOf AUTO.$provide
* @description
*
- * Register a **service constructor**, which will be invoked with `new` to create the service instance.
+ * Register a **service constructor**, which will be invoked with `new` to create the service
+ * instance.
* This is short for registering a service where its provider's `$get` property is the service
* constructor function that will be used to instantiate the service instance.
*
- * You should use {@link AUTO.$provide#service $provide.service(class)} if you define your service
+ * You should use {@link AUTO.$provide#methods_service $provide.service(class)} if you define your service
* as a type/class. This is common when using {@link http://coffeescript.org CoffeeScript}.
*
* @param {string} name The name of the instance.
@@ -3075,14 +3339,14 @@ function annotate(fn) {
* @returns {Object} registered provider instance
*
* @example
- * Here is an example of registering a service using {@link AUTO.$provide#service $provide.service(class)}
- * that is defined as a CoffeeScript class.
+ * Here is an example of registering a service using
+ * {@link AUTO.$provide#methods_service $provide.service(class)} that is defined as a CoffeeScript class.
* <pre>
* class Ping
* constructor: (@$http)->
* send: ()=>
* @$http.get('/ping')
- *
+ *
* $provide.service('ping', ['$http', Ping])
* </pre>
* You would then inject and use this service like this:
@@ -3100,14 +3364,16 @@ function annotate(fn) {
* @methodOf AUTO.$provide
* @description
*
- * Register a **value service** with the {@link AUTO.$injector $injector}, such as a string, a number,
- * an array, an object or a function. This is short for registering a service where its provider's
- * `$get` property is a factory function that takes no arguments and returns the **value service**.
+ * Register a **value service** with the {@link AUTO.$injector $injector}, such as a string, a
+ * number, an array, an object or a function. This is short for registering a service where its
+ * provider's `$get` property is a factory function that takes no arguments and returns the **value
+ * service**.
*
- * Value services are similar to constant services, except that they cannot be injected into a module
- * configuration function (see {@link angular.Module#config}) but they can be overridden by an Angular
+ * Value services are similar to constant services, except that they cannot be injected into a
+ * module configuration function (see {@link angular.Module#config}) but they can be overridden by
+ * an Angular
* {@link AUTO.$provide#decorator decorator}.
- *
+ *
* @param {string} name The name of the instance.
* @param {*} value The value.
* @returns {Object} registered provider instance
@@ -3115,11 +3381,11 @@ function annotate(fn) {
* @example
* Here are some examples of creating value services.
* <pre>
- * $provide.constant('ADMIN_USER', 'admin');
- *
- * $provide.constant('RoleLookup', { admin: 0, writer: 1, reader: 2 });
- *
- * $provide.constant('halfOf', function(value) {
+ * $provide.value('ADMIN_USER', 'admin');
+ *
+ * $provide.value('RoleLookup', { admin: 0, writer: 1, reader: 2 });
+ *
+ * $provide.value('halfOf', function(value) {
* return value / 2;
* });
* </pre>
@@ -3132,10 +3398,10 @@ function annotate(fn) {
* @methodOf AUTO.$provide
* @description
*
- * Register a **constant service**, such as a string, a number, an array, an object or a function, with
- * the {@link AUTO.$injector $injector}. Unlike {@link AUTO.$provide#value value} it can be injected
- * into a module configuration function (see {@link angular.Module#config}) and it cannot be
- * overridden by an Angular {@link AUTO.$provide#decorator decorator}.
+ * Register a **constant service**, such as a string, a number, an array, an object or a function,
+ * with the {@link AUTO.$injector $injector}. Unlike {@link AUTO.$provide#value value} it can be
+ * injected into a module configuration function (see {@link angular.Module#config}) and it cannot
+ * be overridden by an Angular {@link AUTO.$provide#decorator decorator}.
*
* @param {string} name The name of the constant.
* @param {*} value The constant value.
@@ -3145,9 +3411,9 @@ function annotate(fn) {
* Here a some examples of creating constants:
* <pre>
* $provide.constant('SHARD_HEIGHT', 306);
- *
+ *
* $provide.constant('MY_COLOURS', ['red', 'blue', 'grey']);
- *
+ *
* $provide.constant('double', function(value) {
* return value * 2;
* });
@@ -3163,8 +3429,8 @@ function annotate(fn) {
*
* Register a **service decorator** with the {@link AUTO.$injector $injector}. A service decorator
* intercepts the creation of a service, allowing it to override or modify the behaviour of the
- * service. The object returned by the decorator may be the original service, or a new service object
- * which replaces or wraps and delegates to the original service.
+ * service. The object returned by the decorator may be the original service, or a new service
+ * object which replaces or wraps and delegates to the original service.
*
* @param {string} name The name of the service to decorate.
* @param {function()} decorator This function will be invoked when the service needs to be
@@ -3229,7 +3495,7 @@ function createInjector(modulesToLoad) {
} else {
return delegate(key, value);
}
- }
+ };
}
function provider(name, provider_) {
@@ -3251,7 +3517,7 @@ function createInjector(modulesToLoad) {
}]);
}
- function value(name, value) { return factory(name, valueFn(value)); }
+ function value(name, val) { return factory(name, valueFn(val)); }
function constant(name, value) {
assertNotHasOwnProperty(name, 'constant');
@@ -3273,17 +3539,17 @@ function createInjector(modulesToLoad) {
// Module Loading
////////////////////////////////////
function loadModules(modulesToLoad){
- var runBlocks = [];
+ var runBlocks = [], moduleFn, invokeQueue, i, ii;
forEach(modulesToLoad, function(module) {
if (loadedModules.get(module)) return;
loadedModules.put(module, true);
try {
if (isString(module)) {
- var moduleFn = angularModule(module);
+ moduleFn = angularModule(module);
runBlocks = runBlocks.concat(loadModules(moduleFn.requires)).concat(moduleFn._runBlocks);
- for(var invokeQueue = moduleFn._invokeQueue, i = 0, ii = invokeQueue.length; i < ii; i++) {
+ for(invokeQueue = moduleFn._invokeQueue, i = 0, ii = invokeQueue.length; i < ii; i++) {
var invokeArgs = invokeQueue[i],
provider = providerInjector.get(invokeArgs[0]);
@@ -3301,12 +3567,15 @@ function createInjector(modulesToLoad) {
module = module[module.length - 1];
}
if (e.message && e.stack && e.stack.indexOf(e.message) == -1) {
- // Safari & FF's stack traces don't contain error.message content unlike those of Chrome and IE
+ // Safari & FF's stack traces don't contain error.message content
+ // unlike those of Chrome and IE
// So if stack doesn't contain message, we create a new string that contains both.
// Since error.stack is read-only in Safari, I'm overriding e and not e.stack here.
+ /* jshint -W022 */
e = e.message + '\n' + e.stack;
}
- throw $injectorMinErr('modulerr', "Failed to instantiate module {0} due to:\n{1}", module, e.stack || e.message || e);
+ throw $injectorMinErr('modulerr', "Failed to instantiate module {0} due to:\n{1}",
+ module, e.stack || e.message || e);
}
});
return runBlocks;
@@ -3344,7 +3613,8 @@ function createInjector(modulesToLoad) {
for(i = 0, length = $inject.length; i < length; i++) {
key = $inject[i];
if (typeof key !== 'string') {
- throw $injectorMinErr('itkn', 'Incorrect injection token! Expected service name as string, got {0}', key);
+ throw $injectorMinErr('itkn',
+ 'Incorrect injection token! Expected service name as string, got {0}', key);
}
args.push(
locals && locals.hasOwnProperty(key)
@@ -3369,8 +3639,10 @@ function createInjector(modulesToLoad) {
case 6: return fn(args[0], args[1], args[2], args[3], args[4], args[5]);
case 7: return fn(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
case 8: return fn(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);
- case 9: return fn(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8]);
- case 10: return fn(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9]);
+ case 9: return fn(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7],
+ args[8]);
+ case 10: return fn(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7],
+ args[8], args[9]);
default: return fn.apply(self, args);
}
}
@@ -3385,7 +3657,7 @@ function createInjector(modulesToLoad) {
instance = new Constructor();
returnedValue = invoke(Type, instance, locals);
- return isObject(returnedValue) ? returnedValue : instance;
+ return isObject(returnedValue) || isFunction(returnedValue) ? returnedValue : instance;
}
return {
@@ -3400,7 +3672,6 @@ function createInjector(modulesToLoad) {
}
}
-
/**
* @ngdoc function
* @name ng.$anchorScroll
@@ -3508,7 +3779,8 @@ var $animateMinErr = minErr('$animate');
* @name ng.$animateProvider
*
* @description
- * Default implementation of $animate that doesn't perform any animations, instead just synchronously performs DOM
+ * Default implementation of $animate that doesn't perform any animations, instead just
+ * synchronously performs DOM
* updates and calls done() callbacks.
*
* In order to enable animations the ngAnimate module has to be loaded.
@@ -3517,6 +3789,7 @@ var $animateMinErr = minErr('$animate');
*/
var $AnimateProvider = ['$provide', function($provide) {
+
this.$$selectors = {};
@@ -3526,12 +3799,14 @@ var $AnimateProvider = ['$provide', function($provide) {
* @methodOf ng.$animateProvider
*
* @description
- * Registers a new injectable animation factory function. The factory function produces the animation object which
- * contains callback functions for each event that is expected to be animated.
+ * Registers a new injectable animation factory function. The factory function produces the
+ * animation object which contains callback functions for each event that is expected to be
+ * animated.
*
- * * `eventFn`: `function(Element, doneFunction)` The element to animate, the `doneFunction` must be called once the
- * element animation is complete. If a function is returned then the animation service will use this function to
- * cancel the animation whenever a cancel event is triggered.
+ * * `eventFn`: `function(Element, doneFunction)` The element to animate, the `doneFunction`
+ * must be called once the element animation is complete. If a function is returned then the
+ * animation service will use this function to cancel the animation whenever a cancel event is
+ * triggered.
*
*
*<pre>
@@ -3547,7 +3822,8 @@ var $AnimateProvider = ['$provide', function($provide) {
*</pre>
*
* @param {string} name The name of the animation.
- * @param {function} factory The factory function that will be executed to return the animation object.
+ * @param {function} factory The factory function that will be executed to return the animation
+ * object.
*/
this.register = function(name, factory) {
var key = name + '-animation';
@@ -3560,59 +3836,63 @@ var $AnimateProvider = ['$provide', function($provide) {
this.$get = ['$timeout', function($timeout) {
/**
+ *
* @ngdoc object
* @name ng.$animate
+ * @description The $animate service provides rudimentary DOM manipulation functions to
+ * insert, remove and move elements within the DOM, as well as adding and removing classes.
+ * This service is the core service used by the ngAnimate $animator service which provides
+ * high-level animation hooks for CSS and JavaScript.
*
- * @description
- * The $animate service provides rudimentary DOM manipulation functions to insert, remove and move elements within
- * the DOM, as well as adding and removing classes. This service is the core service used by the ngAnimate $animator
- * service which provides high-level animation hooks for CSS and JavaScript.
- *
- * $animate is available in the AngularJS core, however, the ngAnimate module must be included to enable full out
- * animation support. Otherwise, $animate will only perform simple DOM manipulation operations.
+ * $animate is available in the AngularJS core, however, the ngAnimate module must be included
+ * to enable full out animation support. Otherwise, $animate will only perform simple DOM
+ * manipulation operations.
*
- * To learn more about enabling animation support, click here to visit the {@link ngAnimate ngAnimate module page}
- * as well as the {@link ngAnimate.$animate ngAnimate $animate service page}.
+ * To learn more about enabling animation support, click here to visit the {@link ngAnimate
+ * ngAnimate module page} as well as the {@link ngAnimate.$animate ngAnimate $animate service
+ * page}.
*/
return {
/**
+ *
* @ngdoc function
* @name ng.$animate#enter
* @methodOf ng.$animate
* @function
- *
- * @description
- * Inserts the element into the DOM either after the `after` element or within the `parent` element. Once complete,
- * the done() callback will be fired (if provided).
- *
+ * @description Inserts the element into the DOM either after the `after` element or within
+ * the `parent` element. Once complete, the done() callback will be fired (if provided).
* @param {jQuery/jqLite element} element the element which will be inserted into the DOM
- * @param {jQuery/jqLite element} parent the parent element which will append the element as a child (if the after element is not present)
- * @param {jQuery/jqLite element} after the sibling element which will append the element after itself
- * @param {function=} done callback function that will be called after the element has been inserted into the DOM
+ * @param {jQuery/jqLite element} parent the parent element which will append the element as
+ * a child (if the after element is not present)
+ * @param {jQuery/jqLite element} after the sibling element which will append the element
+ * after itself
+ * @param {function=} done callback function that will be called after the element has been
+ * inserted into the DOM
*/
enter : function(element, parent, after, done) {
- var afterNode = after && after[after.length - 1];
- var parentNode = parent && parent[0] || afterNode && afterNode.parentNode;
- // IE does not like undefined so we have to pass null.
- var afterNextSibling = (afterNode && afterNode.nextSibling) || null;
- forEach(element, function(node) {
- parentNode.insertBefore(node, afterNextSibling);
- });
+ if (after) {
+ after.after(element);
+ } else {
+ if (!parent || !parent[0]) {
+ parent = after.parent();
+ }
+ parent.append(element);
+ }
done && $timeout(done, 0, false);
},
/**
+ *
* @ngdoc function
* @name ng.$animate#leave
* @methodOf ng.$animate
* @function
- *
- * @description
- * Removes the element from the DOM. Once complete, the done() callback will be fired (if provided).
- *
+ * @description Removes the element from the DOM. Once complete, the done() callback will be
+ * fired (if provided).
* @param {jQuery/jqLite element} element the element which will be removed from the DOM
- * @param {function=} done callback function that will be called after the element has been removed from the DOM
+ * @param {function=} done callback function that will be called after the element has been
+ * removed from the DOM
*/
leave : function(element, done) {
element.remove();
@@ -3620,19 +3900,23 @@ var $AnimateProvider = ['$provide', function($provide) {
},
/**
+ *
* @ngdoc function
* @name ng.$animate#move
* @methodOf ng.$animate
* @function
- *
- * @description
- * Moves the position of the provided element within the DOM to be placed either after the `after` element or inside of the `parent` element.
- * Once complete, the done() callback will be fired (if provided).
- *
- * @param {jQuery/jqLite element} element the element which will be moved around within the DOM
- * @param {jQuery/jqLite element} parent the parent element where the element will be inserted into (if the after element is not present)
- * @param {jQuery/jqLite element} after the sibling element where the element will be positioned next to
- * @param {function=} done the callback function (if provided) that will be fired after the element has been moved to its new position
+ * @description Moves the position of the provided element within the DOM to be placed
+ * either after the `after` element or inside of the `parent` element. Once complete, the
+ * done() callback will be fired (if provided).
+ *
+ * @param {jQuery/jqLite element} element the element which will be moved around within the
+ * DOM
+ * @param {jQuery/jqLite element} parent the parent element where the element will be
+ * inserted into (if the after element is not present)
+ * @param {jQuery/jqLite element} after the sibling element where the element will be
+ * positioned next to
+ * @param {function=} done the callback function (if provided) that will be fired after the
+ * element has been moved to its new position
*/
move : function(element, parent, after, done) {
// Do not remove element before insert. Removing will cause data associated with the
@@ -3641,47 +3925,49 @@ var $AnimateProvider = ['$provide', function($provide) {
},
/**
+ *
* @ngdoc function
* @name ng.$animate#addClass
* @methodOf ng.$animate
* @function
- *
- * @description
- * Adds the provided className CSS class value to the provided element. Once complete, the done() callback will be fired (if provided).
- *
- * @param {jQuery/jqLite element} element the element which will have the className value added to it
+ * @description Adds the provided className CSS class value to the provided element. Once
+ * complete, the done() callback will be fired (if provided).
+ * @param {jQuery/jqLite element} element the element which will have the className value
+ * added to it
* @param {string} className the CSS class which will be added to the element
- * @param {function=} done the callback function (if provided) that will be fired after the className value has been added to the element
+ * @param {function=} done the callback function (if provided) that will be fired after the
+ * className value has been added to the element
*/
addClass : function(element, className, done) {
className = isString(className) ?
className :
isArray(className) ? className.join(' ') : '';
forEach(element, function (element) {
- JQLiteAddClass(element, className);
+ jqLiteAddClass(element, className);
});
done && $timeout(done, 0, false);
},
/**
+ *
* @ngdoc function
* @name ng.$animate#removeClass
* @methodOf ng.$animate
* @function
- *
- * @description
- * Removes the provided className CSS class value from the provided element. Once complete, the done() callback will be fired (if provided).
- *
- * @param {jQuery/jqLite element} element the element which will have the className value removed from it
+ * @description Removes the provided className CSS class value from the provided element.
+ * Once complete, the done() callback will be fired (if provided).
+ * @param {jQuery/jqLite element} element the element which will have the className value
+ * removed from it
* @param {string} className the CSS class which will be removed from the element
- * @param {function=} done the callback function (if provided) that will be fired after the className value has been removed from the element
+ * @param {function=} done the callback function (if provided) that will be fired after the
+ * className value has been removed from the element
*/
removeClass : function(element, className, done) {
className = isString(className) ?
className :
isArray(className) ? className.join(' ') : '';
forEach(element, function (element) {
- JQLiteRemoveClass(element, className);
+ jqLiteRemoveClass(element, className);
});
done && $timeout(done, 0, false);
},
@@ -3965,30 +4251,35 @@ function Browser(window, document, $log, $sniffer) {
* It is not meant to be used directly, use the $cookie service instead.
*
* The return values vary depending on the arguments that the method was called with as follows:
- * <ul>
- * <li>cookies() -> hash of all cookies, this is NOT a copy of the internal state, so do not modify it</li>
- * <li>cookies(name, value) -> set name to value, if value is undefined delete the cookie</li>
- * <li>cookies(name) -> the same as (name, undefined) == DELETES (no one calls it right now that way)</li>
- * </ul>
- *
+ *
+ * - cookies() -> hash of all cookies, this is NOT a copy of the internal state, so do not modify
+ * it
+ * - cookies(name, value) -> set name to value, if value is undefined delete the cookie
+ * - cookies(name) -> the same as (name, undefined) == DELETES (no one calls it right now that
+ * way)
+ *
* @returns {Object} Hash of all cookies (if called without any parameter)
*/
self.cookies = function(name, value) {
+ /* global escape: false, unescape: false */
var cookieLength, cookieArray, cookie, i, index;
if (name) {
if (value === undefined) {
- rawDocument.cookie = escape(name) + "=;path=" + cookiePath + ";expires=Thu, 01 Jan 1970 00:00:00 GMT";
+ rawDocument.cookie = escape(name) + "=;path=" + cookiePath +
+ ";expires=Thu, 01 Jan 1970 00:00:00 GMT";
} else {
if (isString(value)) {
- cookieLength = (rawDocument.cookie = escape(name) + '=' + escape(value) + ';path=' + cookiePath).length + 1;
+ cookieLength = (rawDocument.cookie = escape(name) + '=' + escape(value) +
+ ';path=' + cookiePath).length + 1;
// per http://www.ietf.org/rfc/rfc2109.txt browser must allow at minimum:
// - 300 cookies
// - 20 cookies per unique domain
// - 4096 bytes per cookie
if (cookieLength > 4096) {
- $log.warn("Cookie '"+ name +"' possibly not set or overflowed because it was too large ("+
+ $log.warn("Cookie '"+ name +
+ "' possibly not set or overflowed because it was too large ("+
cookieLength + " > 4096 bytes)!");
}
}
@@ -4003,7 +4294,7 @@ function Browser(window, document, $log, $sniffer) {
cookie = cookieArray[i];
index = cookie.indexOf('=');
if (index > 0) { //ignore nameless cookies
- var name = unescape(cookie.substring(0, index));
+ name = unescape(cookie.substring(0, index));
// the first value that is seen for a cookie is the most
// specific one. values for the same cookie name that
// follow are for less specific paths.
@@ -4053,7 +4344,8 @@ function Browser(window, document, $log, $sniffer) {
* Cancels a deferred task identified with `deferId`.
*
* @param {*} deferId Token returned by the `$browser.defer` function.
- * @returns {boolean} Returns `true` if the task hasn't executed yet and was successfully canceled.
+ * @returns {boolean} Returns `true` if the task hasn't executed yet and was successfully
+ * canceled.
*/
self.defer.cancel = function(deferId) {
if (pendingDeferIds[deferId]) {
@@ -4089,8 +4381,9 @@ function $BrowserProvider(){
*
* cache.put("key", "value");
* cache.put("another key", "another value");
- *
- * expect(cache.info()).toEqual({id: 'cacheId', size: 2}); // Since we've specified no options on creation
+ *
+ * // We've specified no options on creation
+ * expect(cache.info()).toEqual({id: 'cacheId', size: 2});
*
* </pre>
*
@@ -4103,7 +4396,8 @@ function $BrowserProvider(){
* @returns {object} Newly created cache object with the following set of methods:
*
* - `{object}` `info()` — Returns id, size, and options of cache.
- * - `{{*}}` `put({string} key, {*} value)` — Puts a new key-value pair into the cache and returns it.
+ * - `{{*}}` `put({string} key, {*} value)` — Puts a new key-value pair into the cache and returns
+ * it.
* - `{{*}}` `get({string} key)` — Returns cached value for `key` or undefined for cache miss.
* - `{void}` `remove({string} key)` — Removes a key-value pair from the cache.
* - `{void}` `removeAll()` — Removes all cached values.
@@ -4270,9 +4564,9 @@ function $CacheFactoryProvider() {
* @name ng.$templateCache
*
* @description
- * The first time a template is used, it is loaded in the template cache for quick retrieval. You can
- * load templates directly into the cache in a `script` tag, or by consuming the `$templateCache`
- * service directly.
+ * The first time a template is used, it is loaded in the template cache for quick retrieval. You
+ * can load templates directly into the cache in a `script` tag, or by consuming the
+ * `$templateCache` service directly.
*
* Adding via the `script` tag:
* <pre>
@@ -4286,8 +4580,8 @@ function $CacheFactoryProvider() {
* </html>
* </pre>
*
- * **Note:** the `script` tag containing the template does not need to be included in the `head` of the document, but
- * it must be below the `ng-app` definition.
+ * **Note:** the `script` tag containing the template does not need to be included in the `head` of
+ * the document, but it must be below the `ng-app` definition.
*
* Adding via the $templateCache service:
*
@@ -4342,21 +4636,367 @@ function $TemplateCacheProvider() {
*
* @description
* Compiles a piece of HTML string or DOM into a template and produces a template function, which
- * can then be used to link {@link ng.$rootScope.Scope scope} and the template together.
+ * can then be used to link {@link ng.$rootScope.Scope `scope`} and the template together.
+ *
+ * The compilation is a process of walking the DOM tree and matching DOM elements to
+ * {@link ng.$compileProvider#methods_directive directives}.
+ *
+ * <div class="alert alert-warning">
+ * **Note:** This document is an in-depth reference of all directive options.
+ * For a gentle introduction to directives with examples of common use cases,
+ * see the {@link guide/directive directive guide}.
+ * </div>
+ *
+ * ## Comprehensive Directive API
+ *
+ * There are many different options for a directive.
+ *
+ * The difference resides in the return value of the factory function.
+ * You can either return a "Directive Definition Object" (see below) that defines the directive properties,
+ * or just the `postLink` function (all other properties will have the default values).
+ *
+ * <div class="alert alert-success">
+ * **Best Practice:** It's recommended to use the "directive definition object" form.
+ * </div>
+ *
+ * Here's an example directive declared with a Directive Definition Object:
+ *
+ * <pre>
+ * var myModule = angular.module(...);
+ *
+ * myModule.directive('directiveName', function factory(injectables) {
+ * var directiveDefinitionObject = {
+ * priority: 0,
+ * template: '<div></div>', // or // function(tElement, tAttrs) { ... },
+ * // or
+ * // templateUrl: 'directive.html', // or // function(tElement, tAttrs) { ... },
+ * replace: false,
+ * transclude: false,
+ * restrict: 'A',
+ * scope: false,
+ * controller: function($scope, $element, $attrs, $transclude, otherInjectables) { ... },
+ * require: 'siblingDirectiveName', // or // ['^parentDirectiveName', '?optionalDirectiveName', '?^optionalParent'],
+ * compile: function compile(tElement, tAttrs, transclude) {
+ * return {
+ * pre: function preLink(scope, iElement, iAttrs, controller) { ... },
+ * post: function postLink(scope, iElement, iAttrs, controller) { ... }
+ * }
+ * // or
+ * // return function postLink( ... ) { ... }
+ * },
+ * // or
+ * // link: {
+ * // pre: function preLink(scope, iElement, iAttrs, controller) { ... },
+ * // post: function postLink(scope, iElement, iAttrs, controller) { ... }
+ * // }
+ * // or
+ * // link: function postLink( ... ) { ... }
+ * };
+ * return directiveDefinitionObject;
+ * });
+ * </pre>
+ *
+ * <div class="alert alert-warning">
+ * **Note:** Any unspecified options will use the default value. You can see the default values below.
+ * </div>
+ *
+ * Therefore the above can be simplified as:
+ *
+ * <pre>
+ * var myModule = angular.module(...);
+ *
+ * myModule.directive('directiveName', function factory(injectables) {
+ * var directiveDefinitionObject = {
+ * link: function postLink(scope, iElement, iAttrs) { ... }
+ * };
+ * return directiveDefinitionObject;
+ * // or
+ * // return function postLink(scope, iElement, iAttrs) { ... }
+ * });
+ * </pre>
+ *
+ *
+ *
+ * ### Directive Definition Object
+ *
+ * The directive definition object provides instructions to the {@link api/ng.$compile
+ * compiler}. The attributes are:
+ *
+ * #### `priority`
+ * When there are multiple directives defined on a single DOM element, sometimes it
+ * is necessary to specify the order in which the directives are applied. The `priority` is used
+ * to sort the directives before their `compile` functions get called. Priority is defined as a
+ * number. Directives with greater numerical `priority` are compiled first. Pre-link functions
+ * are also run in priority order, but post-link functions are run in reverse order. The order
+ * of directives with the same priority is undefined. The default priority is `0`.
+ *
+ * #### `terminal`
+ * If set to true then the current `priority` will be the last set of directives
+ * which will execute (any directives at the current priority will still execute
+ * as the order of execution on same `priority` is undefined).
+ *
+ * #### `scope`
+ * **If set to `true`,** then a new scope will be created for this directive. If multiple directives on the
+ * same element request a new scope, only one new scope is created. The new scope rule does not
+ * apply for the root of the template since the root of the template always gets a new scope.
+ *
+ * **If set to `{}` (object hash),** then a new "isolate" scope is created. The 'isolate' scope differs from
+ * normal scope in that it does not prototypically inherit from the parent scope. This is useful
+ * when creating reusable components, which should not accidentally read or modify data in the
+ * parent scope.
+ *
+ * The 'isolate' scope takes an object hash which defines a set of local scope properties
+ * derived from the parent scope. These local properties are useful for aliasing values for
+ * templates. Locals definition is a hash of local scope property to its source:
+ *
+ * * `@` or `@attr` - bind a local scope property to the value of DOM attribute. The result is
+ * always a string since DOM attributes are strings. If no `attr` name is specified then the
+ * attribute name is assumed to be the same as the local name.
+ * Given `<widget my-attr="hello {{name}}">` and widget definition
+ * of `scope: { localName:'@myAttr' }`, then widget scope property `localName` will reflect
+ * the interpolated value of `hello {{name}}`. As the `name` attribute changes so will the
+ * `localName` property on the widget scope. The `name` is read from the parent scope (not
+ * component scope).
+ *
+ * * `=` or `=attr` - set up bi-directional binding between a local scope property and the
+ * parent scope property of name defined via the value of the `attr` attribute. If no `attr`
+ * name is specified then the attribute name is assumed to be the same as the local name.
+ * Given `<widget my-attr="parentModel">` and widget definition of
+ * `scope: { localModel:'=myAttr' }`, then widget scope property `localModel` will reflect the
+ * value of `parentModel` on the parent scope. Any changes to `parentModel` will be reflected
+ * in `localModel` and any changes in `localModel` will reflect in `parentModel`. If the parent
+ * scope property doesn't exist, it will throw a NON_ASSIGNABLE_MODEL_EXPRESSION exception. You
+ * can avoid this behavior using `=?` or `=?attr` in order to flag the property as optional.
+ *
+ * * `&` or `&attr` - provides a way to execute an expression in the context of the parent scope.
+ * If no `attr` name is specified then the attribute name is assumed to be the same as the
+ * local name. Given `<widget my-attr="count = count + value">` and widget definition of
+ * `scope: { localFn:'&myAttr' }`, then isolate scope property `localFn` will point to
+ * a function wrapper for the `count = count + value` expression. Often it's desirable to
+ * pass data from the isolated scope via an expression and to the parent scope, this can be
+ * done by passing a map of local variable names and values into the expression wrapper fn.
+ * For example, if the expression is `increment(amount)` then we can specify the amount value
+ * by calling the `localFn` as `localFn({amount: 22})`.
+ *
+ *
+ *
+ * #### `controller`
+ * Controller constructor function. The controller is instantiated before the
+ * pre-linking phase and it is shared with other directives (see
+ * `require` attribute). This allows the directives to communicate with each other and augment
+ * each other's behavior. The controller is injectable (and supports bracket notation) with the following locals:
+ *
+ * * `$scope` - Current scope associated with the element
+ * * `$element` - Current element
+ * * `$attrs` - Current attributes object for the element
+ * * `$transclude` - A transclude linking function pre-bound to the correct transclusion scope.
+ * The scope can be overridden by an optional first argument.
+ * `function([scope], cloneLinkingFn)`.
+ *
+ *
+ * #### `require`
+ * Require another directive and inject its controller as the fourth argument to the linking function. The
+ * `require` takes a string name (or array of strings) of the directive(s) to pass in.
<TRUNCATED>