diff --git a/example/personalLog/personalLog.js b/example/personalLog/personalLog.js index c22b8702e4a6..5015cd6466a7 100644 --- a/example/personalLog/personalLog.js +++ b/example/personalLog/personalLog.js @@ -46,7 +46,7 @@ app.controller('LogCtrl', ['$cookieStore', '$scope', function LogCtrl($cookieSto /** * Persistently removes a log from logs. - * @param {object} log The log to remove. + * @param {Object} log The log to remove. */ $scope.rmLog = function(log) { for ( var i = 0; i < logs.length; i++) { diff --git a/src/Angular.js b/src/Angular.js index 3a11f3ea7188..d99c51d7db7b 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -51,7 +51,7 @@ function fromCharCode(code) {return String.fromCharCode(code);} var Error = window.Error, /** holds major version number for IE or NaN for real browsers */ - msie = int((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]), + msie = atoi((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]), jqLite, // delay binding since jQuery could be loaded after us. jQuery, // delay binding slice = [].slice, @@ -86,10 +86,10 @@ var Error = window.Error, expect(log).toEqual(['name: misko', 'gender:male']); * - * @param {Object|Array} obj Object to iterate over. + * @param {Object|Array|undefined} obj Object to iterate over. * @param {Function} iterator Iterator function. * @param {Object=} context Object to become context (`this`) for the iterator function. - * @returns {Object|Array} Reference to `obj`. + * @returns {Object|Array|undefined} Reference to `obj`. */ function forEach(obj, iterator, context) { var key; @@ -184,9 +184,9 @@ function nextUid() { * to `dst`. You can specify multiple `src` objects. * * @param {Object} dst Destination object. - * @param {...Object} src Source object(s). + * @param {...Object} var_args Source object(s). */ -function extend(dst) { +function extend(dst, var_args) { forEach(arguments, function(obj){ if (obj !== dst) { forEach(obj, function(value, key){ @@ -197,7 +197,7 @@ function extend(dst) { return dst; } -function int(str) { +function atoi(str) { return parseInt(str, 10); } @@ -330,7 +330,7 @@ function isNumber(value){return typeof value == 'number';} * @returns {boolean} True if `value` is a `Date`. */ function isDate(value){ - return toString.apply(value) == '[object Date]'; + return toString.apply(/** @type {Object} */ (value)) == '[object Date]'; } @@ -346,7 +346,7 @@ function isDate(value){ * @returns {boolean} True if `value` is an `Array`. */ function isArray(value) { - return toString.apply(value) == '[object Array]'; + return toString.apply(/** @type {Object} */ (value)) == '[object Array]'; } @@ -372,7 +372,7 @@ function isFunction(value){return typeof value == 'function';} * @returns {boolean} True if `obj` is a window obj. */ function isWindow(obj) { - return obj && obj.document && obj.location && obj.alert && obj.setInterval; + return Boolean(obj && obj.document && obj.location && obj.alert && obj.setInterval); } @@ -403,18 +403,18 @@ function trim(value) { * @description * Determines if a reference is a DOM element (or wrapped jQuery element). * - * @param {*} value Reference to check. + * @param {*} node Reference to check. * @returns {boolean} True if `value` is a DOM element (or wrapped jQuery element). */ function isElement(node) { - return node && + return Boolean(node && (node.nodeName // we are a direct element - || (node.bind && node.find)); // we have a bind and find method part of jQuery API + || (node.bind && node.find))); // we have a bind and find method part of jQuery API } /** * @param str 'key1,key2,...' - * @returns {object} in the form of {key1:true, key2:true, ...} + * @returns {Object} in the form of {key1:true, key2:true, ...} */ function makeMap(str){ var obj = {}, items = str.split(","), i; @@ -530,16 +530,16 @@ function isLeafNode (node) { function copy(source, destination){ if (isWindow(source) || isScope(source)) throw Error("Can't copy Window or Scope"); if (!destination) { - destination = source; if (source) { if (isArray(source)) { - destination = copy(source, []); + return copy(source, []); } else if (isDate(source)) { - destination = new Date(source.getTime()); + return new Date(source.getTime()); } else if (isObject(source)) { - destination = copy(source, {}); + return copy(source, {}); } } + return source; } else { if (source === destination) throw Error("Can't copy equivalent objects or arrays"); if (isArray(source)) { @@ -653,15 +653,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 are prebound to the function. This feature is also + * `fn`). You can supply optional `var_args` that are are prebound to the function. This feature is also * known as [function currying](http://en.wikipedia.org/wiki/Currying). * * @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. + * @param {...*} var_args Optional arguments to be prebound to the `fn` function call. * @returns {function()} Function that wraps the `fn` with all the specified bindings. */ -function bind(self, fn) { +function bind(self, fn, var_args) { var curryArgs = arguments.length > 2 ? sliceArgs(arguments, 2) : []; if (isFunction(fn) && !(fn instanceof RegExp)) { return curryArgs.length @@ -712,7 +712,7 @@ function toJsonReplacer(key, value) { * @returns {string} Jsonified string representing `obj`. */ function toJson(obj, pretty) { - return JSON.stringify(obj, toJsonReplacer, pretty ? ' ' : null); + return window.JSON.stringify(obj, toJsonReplacer, pretty ? ' ' : null); } @@ -729,7 +729,7 @@ function toJson(obj, pretty) { */ function fromJson(json) { return isString(json) - ? JSON.parse(json) + ? window.JSON.parse(json) : json; } @@ -767,7 +767,8 @@ function startingTag(element) { * @returns Object.<(string|boolean)> */ function parseKeyValue(/**string*/keyValue) { - var obj = {}, key_value, key; + var obj = {}; + var key_value, key; forEach((keyValue || "").split('&'), function(keyValue){ if (keyValue) { key_value = keyValue.split('='); @@ -832,7 +833,7 @@ function encodeUriQuery(val, pctEncodeSpaces) { * @name ng.directive:ngApp * * @element ANY - * @param {angular.Module} ngApp an optional application + * @param {angular.Module} bootstrap an optional application * {@link angular.module module} name to load. * * @description @@ -908,7 +909,7 @@ function angularInit(element, bootstrap) { * See: {@link guide/bootstrap Bootstrap} * * @param {Element} element DOM element which is the root of angular application. - * @param {Array=} modules an array of module declarations. See: {@link angular.module modules} + * @param {Array.=} modules an array of module declarations. See: {@link angular.module modules} * @returns {AUTO.$injector} Returns the newly created injector for this app. */ function bootstrap(element, modules) { @@ -961,6 +962,9 @@ function bindJQuery() { /** * throw error of the argument is falsy. + * @param {*} arg + * @param {string=} name + * @param {string=} reason */ function assertArg(arg, name, reason) { if (!arg) { @@ -969,7 +973,12 @@ function assertArg(arg, name, reason) { return arg; } -function assertArgFn(arg, name, acceptArrayAnnotation) { +/** + * @param {*} arg + * @param {string} name + * @param {boolean=} acceptArrayAnnotation + */ + function assertArgFn(arg, name, acceptArrayAnnotation) { if (acceptArrayAnnotation && isArray(arg)) { arg = arg[arg.length - 1]; } diff --git a/src/apis.js b/src/apis.js index 0e94e2a55ce2..e4daf82a8be3 100644 --- a/src/apis.js +++ b/src/apis.js @@ -33,6 +33,8 @@ function hashKey(obj) { /** * HashMap which can use objects as keys + * @param {(Object|Array)=} array + * @constructor */ function HashMap(array){ forEach(array, this.put, this); @@ -69,6 +71,7 @@ HashMap.prototype = { /** * A map where multiple values can be added to the same key such that they form a queue. * @returns {HashQueueMap} + * @constructor */ function HashQueueMap() {} HashQueueMap.prototype = { diff --git a/src/auto/injector.js b/src/auto/injector.js index bdc82da51a83..d7256d56c2ac 100644 --- a/src/auto/injector.js +++ b/src/auto/injector.js @@ -159,7 +159,7 @@ function annotate(fn) { * 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 {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. * @returns {Object} new instance of `Type`. @@ -583,12 +583,14 @@ function createInjector(modulesToLoad) { } function instantiate(Type, locals) { - var Constructor = function() {}, - instance, returnedValue; + /** + * @constructor + */ + var Constructor = function() {}; Constructor.prototype = (isArray(Type) ? Type[Type.length - 1] : Type).prototype; - instance = new Constructor(); - returnedValue = invoke(Type, instance, locals); + var instance = new Constructor(); + var returnedValue = invoke(Type, instance, locals); return isObject(returnedValue) ? returnedValue : instance; } diff --git a/src/jqLite.js b/src/jqLite.js index 8305f0c30f2c..d2b480939aa8 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -71,14 +71,14 @@ * - `inheritedData()` - same as `data()`, but walks up the DOM until a value is found or the top * parent element is reached. * - * @param {string|DOMElement} element HTML string or DOMElement to be wrapped into jQuery. + * @param {string|Element} element HTML string or Element to be wrapped into jQuery. * @returns {Object} jQuery object. */ -var jqCache = JQLite.cache = {}, - jqName = JQLite.expando = 'ng-' + new Date().getTime(), - jqId = 1, - addEventListenerFn = (window.document.addEventListener +var jqCache = JQLite.cache = {}; +var jqName = JQLite.expando = 'ng-' + new Date().getTime(); +var jqId = 1; +var addEventListenerFn = (window.document.addEventListener ? function(element, type, fn) {element.addEventListener(type, fn, false);} : function(element, type, fn) {element.attachEvent('on' + type, fn);}), removeEventListenerFn = (window.document.removeEventListener @@ -112,6 +112,10 @@ function camelCase(name) { // ///////////////////////////////////////////// +/** + * @param {string} name + * @param {boolean=} dispatchThis + */ function JQLitePatchJQueryRemove(name, dispatchThis) { var originalJqFn = jQuery.fn[name]; originalJqFn = originalJqFn.$original || originalJqFn; @@ -146,6 +150,10 @@ function JQLitePatchJQueryRemove(name, dispatchThis) { } ///////////////////////////////////////////// + +/** + * @constructor + */ function JQLite(element) { if (element instanceof JQLite) { return element; @@ -181,6 +189,11 @@ function JQLiteDealoc(element){ } } +/** + * @param {Object} element + * @param {string=} type + * @param {function()=} fn + */ function JQLiteUnbind(element, type, fn) { var events = JQLiteExpandoStore(element, 'events'), handle = JQLiteExpandoStore(element, 'handle'); @@ -216,6 +229,11 @@ function JQLiteRemoveData(element) { } } +/** + * @param {Object} element + * @param {string} key + * @param {*=} value + */ function JQLiteExpandoStore(element, key, value) { var expandoId = element[jqName], expandoStore = jqCache[expandoId || -1]; @@ -299,6 +317,11 @@ function JQLiteController(element, name) { return JQLiteInheritedData(element, '$' + (name || 'ngController' ) + 'Controller'); } +/** + * @param {Object} element + * @param {string} name + * @param {*=} value + */ function JQLiteInheritedData(element, name, value) { element = jqLite(element); @@ -329,7 +352,7 @@ var JQLitePrototype = JQLite.prototype = { this.bind('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. - JQLite(window).bind('load', trigger); // fallback to window.onload for others + new JQLite(window).bind('load', trigger); // fallback to window.onload for others }, toString: function() { var value = []; diff --git a/src/loader.js b/src/loader.js index ecb166085460..2c300e4efb5b 100644 --- a/src/loader.js +++ b/src/loader.js @@ -58,7 +58,7 @@ 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.=} requires If specified then new module is being created. If unspecified then the + * @param {Array.} 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()}. @@ -212,7 +212,7 @@ function setupModuleLoader(window) { * @ngdoc method * @name angular.Module#run * @methodOf angular.Module - * @param {Function} initializationFn Execute this function after injector creation. + * @param {Function} block Execute this function after injector creation. * Useful for application initialization. * @description * Use this method to register work which should be performed when the injector is done @@ -233,7 +233,7 @@ function setupModuleLoader(window) { /** * @param {string} provider * @param {string} method - * @param {String=} insertMethod + * @param {string=} insertMethod * @returns {angular.Module} */ function invokeLater(provider, method, insertMethod) { diff --git a/src/ng/browser.js b/src/ng/browser.js index 3925348317ce..8f704e5db61c 100644 --- a/src/ng/browser.js +++ b/src/ng/browser.js @@ -16,11 +16,11 @@ * the real browser apis. */ /** - * @param {object} window The global window object. - * @param {object} document jQuery wrapped document. - * @param {function()} XHR XMLHttpRequest constructor. - * @param {object} $log console.log or an object with the same interface. - * @param {object} $sniffer $sniffer service + * @param {Object} window The global window object. + * @param {Object} document jQuery wrapped document. + * @param {Object} $log console.log or an object with the same interface. + * @param {Object} $sniffer $sniffer service + * @constructor */ function Browser(window, document, $log, $sniffer) { var self = this, @@ -106,7 +106,8 @@ function Browser(window, document, $log, $sniffer) { /** * @param {number} interval How often should browser call poll functions (ms) - * @param {function()} setTimeout Reference to a real or fake `setTimeout` function. + * @param {function(function(),number)} setTimeout Reference to a real or + * fake `setTimeout` function. * * @description * Configures the poller to run in the specified intervals, using the specified @@ -143,7 +144,7 @@ function Browser(window, document, $log, $sniffer) { * NOTE: this api is intended for use only by the $location service. Please use the * {@link ng.$location $location service} to change url. * - * @param {string} url New url (when used as setter) + * @param {string=} url New url (when used as setter) * @param {boolean=} replace Should new url replace current history record ? */ self.url = function(url, replace) { @@ -205,7 +206,7 @@ function Browser(window, document, $log, $sniffer) { * @param {function(string)} listener Listener function to be called when url changes. * @return {function(string)} Returns the registered listener fn - handy if the fn is anonymous. */ - self.onUrlChange = function(callback) { + self.onUrlChange = function(listener) { if (!urlChangeInit) { // We listen on both (hashchange/popstate) when available, as some browsers (e.g. Opera) // don't fire popstate when user change the address bar and don't fire hashchange when url @@ -221,8 +222,8 @@ function Browser(window, document, $log, $sniffer) { urlChangeInit = true; } - urlChangeListeners.push(callback); - return callback; + urlChangeListeners.push(listener); + return listener; }; ////////////////////////////////////////////////////////////// @@ -233,7 +234,7 @@ function Browser(window, document, $log, $sniffer) { * Returns current * (always relative - without domain) * - * @returns {string=} + * @returns {string|null} */ self.baseHref = function() { var href = baseElement.attr('href'); @@ -271,7 +272,7 @@ function Browser(window, document, $log, $sniffer) { var cookieLength, cookieArray, cookie, i, index; if (name) { - if (value === undefined) { + if (!value) { rawDocument.cookie = escape(name) + "=;path=" + cookiePath + ";expires=Thu, 01 Jan 1970 00:00:00 GMT"; } else { if (isString(value)) { diff --git a/src/ng/cacheFactory.js b/src/ng/cacheFactory.js index ce690ebfe2a4..91416b5fa1a6 100644 --- a/src/ng/cacheFactory.js +++ b/src/ng/cacheFactory.js @@ -11,9 +11,9 @@ * * - `{number=}` `capacity` — turns the cache into LRU cache. * - * @returns {object} Newly created cache object with the following set of methods: + * @returns {Object} Newly created cache object with the following set of methods: * - * - `{object}` `info()` — Returns id, size, and options of cache. + * - `{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. * - `{{*}}` `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. diff --git a/src/ng/compile.js b/src/ng/compile.js index 9ed7f1079a31..f5f87dead3d8 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -92,8 +92,8 @@ var NON_ASSIGNABLE_MODEL_EXPRESSION = 'Non-assignable model expression: '; * * - * @param {string|DOMElement} element Element or HTML string to compile into a template function. - * @param {function(angular.Scope[, cloneAttachFn]} transclude function available to directives. + * @param {string|Element} element Element or HTML string to compile into a template function. + * @param {function(angular.Scope[, cloneAttachFn])} transclude function available to directives. * @param {number} maxPriority only apply directives lower then given priority (Only effects the * root element(s), not their children) * @returns {function(scope[, cloneAttachFn])} a link function which is used to bind template @@ -215,6 +215,9 @@ function $CompileProvider($provide) { function($injector, $interpolate, $exceptionHandler, $http, $templateCache, $parse, $controller, $rootScope) { + /** + * @constructor + */ var Attributes = function(element, attr) { this.$$element = element; this.$attr = attr || {}; @@ -358,12 +361,12 @@ function $CompileProvider($provide) { * function, which is the a linking function for the node. * * @param {NodeList} nodeList an array of nodes to compile - * @param {function(angular.Scope[, cloneAttachFn]} transcludeFn A linking function, where the + * @param {function(angular.Scope[, cloneAttachFn])} transcludeFn A linking function, where the * scope argument is auto-generated to the new child of the transcluded parent scope. - * @param {DOMElement=} $rootElement If the nodeList is the root of the compilation tree then the + * @param {Element=} $rootElement If the nodeList is the root of the compilation tree then the * rootElement must be set the jqLite collection of the compile root. This is * needed so that the jqLite collection items can be replaced with widgets. - * @param {number=} max directive priority + * @param {number=} maxPriority directive priority * @returns {?function} A composite linking function of all of the matched directives or null. */ function compileNodes(nodeList, transcludeFn, $rootElement, maxPriority) { @@ -517,9 +520,9 @@ function $CompileProvider($provide) { * this needs to be pre-sorted by priority order. * @param {Node} compileNode The raw DOM node to apply the compile functions to * @param {Object} templateAttrs The shared attribute function - * @param {function(angular.Scope[, cloneAttachFn]} transcludeFn A linking function, where the + * @param {function(angular.Scope[, cloneAttachFn])} transcludeFn A linking function, where the * scope argument is auto-generated to the new child of the transcluded parent scope. - * @param {DOMElement} $rootElement If we are working on the root of the compile tree then this + * @param {Element} $rootElement If we are working on the root of the compile tree then this * argument has the root jqLite array so that we can replace widgets on it. * @returns linkFn */ @@ -858,8 +861,8 @@ function $CompileProvider($provide) { * on the template need to be merged with the existing attributes in the DOM. * The desired effect is to have both of the attributes present. * - * @param {object} dst destination attributes (original DOM) - * @param {object} src source attributes (from the directive template) + * @param {Object} dst destination attributes (original DOM) + * @param {Object} src source attributes (from the directive template) */ function mergeTemplateAttributes(dst, src) { var srcAttr = src.$attr, @@ -1039,10 +1042,10 @@ function $CompileProvider($provide) { * This is a special jqLite.replaceWith, which can replace items which * have no parents, provided that the containing jqLite collection is provided. * - * @param {JqLite=} $rootElement The root of the compile tree. Used so that we can replace nodes - * in the root of the tree. - * @param {JqLite} $element The jqLite element which we are going to replace. We keep the shell, - * but replace its DOM node reference. + * @param {Element} $rootElement The root of the compile tree. Used so that + * we can replace nodes in the root of the tree. + * @param {Element} $element The jqLite element which we are going to + * replace. We keep the shell, but replace its DOM node reference. * @param {Node} newNode The new DOM node. */ function replaceWith($rootElement, $element, newNode) { @@ -1101,7 +1104,7 @@ function directiveNormalize(name) { * @ngdoc property * @name ng.$compile.directive.Attributes#$attr * @propertyOf ng.$compile.directive.Attributes - * @returns {object} A map of DOM element attribute names to the normalized name. This is + * @returns {Object} A map of DOM element attribute names to the normalized name. This is * needed to do reverse lookup from normalized name back to actual name. */ diff --git a/src/ng/directive/form.js b/src/ng/directive/form.js index b4d500c6e76c..c5688684e4cf 100644 --- a/src/ng/directive/form.js +++ b/src/ng/directive/form.js @@ -54,7 +54,11 @@ function FormController(element, attrs) { element.addClass(PRISTINE_CLASS); toggleValidCss(true); - // convenience method for easy toggling of classes + /** + * Convenience method for easy toggling of classes + * @param {boolean} isValid + * @param {string=} validationErrorKey + */ function toggleValidCss(isValid, validationErrorKey) { validationErrorKey = validationErrorKey ? '-' + snake_case(validationErrorKey, '-') : ''; element. diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index aaabd1033398..0b64e21905bb 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -474,7 +474,7 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) { // min length validator if (attr.ngMinlength) { - var minlength = int(attr.ngMinlength); + var minlength = atoi(attr.ngMinlength); var minLengthValidator = function(value) { if (!isEmpty(value) && value.length < minlength) { ctrl.$setValidity('minlength', false); @@ -491,7 +491,7 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) { // max length validator if (attr.ngMaxlength) { - var maxlength = int(attr.ngMaxlength); + var maxlength = atoi(attr.ngMaxlength); var maxLengthValidator = function(value) { if (!isEmpty(value) && value.length > maxlength) { ctrl.$setValidity('maxlength', false); @@ -929,7 +929,11 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$ $element.addClass(PRISTINE_CLASS); toggleValidCss(true); - // convenience method for easy toggling of classes + /** + * Convenience method for easy toggling of classes + * @param {boolean} isValid + * @param {string=} validationErrorKey + */ function toggleValidCss(isValid, validationErrorKey) { validationErrorKey = validationErrorKey ? '-' + snake_case(validationErrorKey, '-') : ''; $element. diff --git a/src/ng/directive/ngSwitch.js b/src/ng/directive/ngSwitch.js index 0c9e2a8db26c..56df176451ca 100644 --- a/src/ng/directive/ngSwitch.js +++ b/src/ng/directive/ngSwitch.js @@ -1,5 +1,7 @@ 'use strict'; +var NG_SWITCH = 'ng-switch'; + /** * @ngdoc directive * @name ng.directive:ngSwitch @@ -59,7 +61,6 @@ */ -var NG_SWITCH = 'ng-switch'; var ngSwitchDirective = valueFn({ restrict: 'EA', compile: function(element, attr) { diff --git a/src/ng/filter.js b/src/ng/filter.js index e3ccb72ee2b6..c45d02aab2c3 100644 --- a/src/ng/filter.js +++ b/src/ng/filter.js @@ -55,7 +55,7 @@ * @description * Register filter factory function. * - * @param {String} name Name of the filter. + * @param {string} name Name of the filter. * @param {function} fn The filter factory function which is injectable. */ @@ -71,7 +71,7 @@ * * {{ expression | [ filter_name ] }} * - * @param {String} name Name of the filter function to retrieve + * @param {string} name Name of the filter function to retrieve * @return {Function} the filter function */ $FilterProvider.$inject = ['$provide']; diff --git a/src/ng/filter/filters.js b/src/ng/filter/filters.js index 57186981f075..21ab14510821 100644 --- a/src/ng/filter/filters.js +++ b/src/ng/filter/filters.js @@ -177,21 +177,33 @@ function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) { return parts.join(''); } +/** + * @param {number} num + * @param {number} digits + * @param {boolean=} trim + * @returns {string} + */ function padNumber(num, digits, trim) { var neg = ''; if (num < 0) { neg = '-'; num = -num; } - num = '' + num; - while(num.length < digits) num = '0' + num; + var str = '' + num; + while(str.length < digits) str = '0' + str; if (trim) - num = num.substr(num.length - digits); - return neg + num; + str = str.substr(str.length - digits); + return neg + str; } -function dateGetter(name, size, offset, trim) { +/** + * @param {string} name + * @param {number} size + * @param {number=} offset + * @param {boolean=} trim + */ + function dateGetter(name, size, offset, trim) { return function(date) { var value = date['get' + name](); if (offset > 0 || value > -offset) @@ -201,6 +213,10 @@ function dateGetter(name, size, offset, trim) { }; } +/** + * @param {string} name + * @param {boolean=} shortForm + */ function dateStrGetter(name, shortForm) { return function(date, formats) { var value = date['get' + name](); @@ -210,6 +226,9 @@ function dateStrGetter(name, shortForm) { }; } +/** + * @param {Date} date + */ function timeZoneGetter(date) { var offset = date.getTimezoneOffset(); return padNumber(offset / 60, 2) + padNumber(Math.abs(offset % 60), 2); @@ -337,11 +356,11 @@ function dateFilter($locale) { tzHour = 0, tzMin = 0; if (match[9]) { - tzHour = int(match[9] + match[10]); - tzMin = int(match[9] + match[11]); + tzHour = atoi(match[9] + match[10]); + tzMin = atoi(match[9] + match[11]); } - date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3])); - date.setUTCHours(int(match[4]||0) - tzHour, int(match[5]||0) - tzMin, int(match[6]||0), int(match[7]||0)); + date.setUTCFullYear(atoi(match[1]), atoi(match[2]) - 1, atoi(match[3])); + date.setUTCHours(atoi(match[4]||0) - tzHour, atoi(match[5]||0) - tzMin, atoi(match[6]||0), atoi(match[7]||0)); return date; } return string; @@ -357,7 +376,7 @@ function dateFilter($locale) { format = $locale.DATETIME_FORMATS[format] || format; if (isString(date)) { if (NUMBER_STRING.test(date)) { - date = int(date); + date = atoi(date); } else { date = jsonStringToDate(date); } diff --git a/src/ng/filter/limitTo.js b/src/ng/filter/limitTo.js index 536c703868d0..ab6b4c768fc4 100644 --- a/src/ng/filter/limitTo.js +++ b/src/ng/filter/limitTo.js @@ -56,7 +56,7 @@ function limitToFilter(){ return function(array, limit) { if (!(array instanceof Array)) return array; - limit = int(limit); + limit = atoi(limit); var out = [], i, n; diff --git a/src/ng/http.js b/src/ng/http.js index d840c78b620c..b63758a389bc 100644 --- a/src/ng/http.js +++ b/src/ng/http.js @@ -47,7 +47,7 @@ function isSameDomain(requestUrl, locationUrl) { var domain1 = { protocol: match[2], host: match[4], - port: int(match[6]) || DEFAULT_PORTS[match[2]] || null, + port: atoi(match[6]) || DEFAULT_PORTS[match[2]] || null, // IE8 sets unmatched groups to '' instead of undefined. relativeProtocol: match[2] === undefined || match[2] === '' }; @@ -56,7 +56,7 @@ function isSameDomain(requestUrl, locationUrl) { var domain2 = { protocol: match[1], host: match[3], - port: int(match[5]) || DEFAULT_PORTS[match[1]] || null + port: atoi(match[5]) || DEFAULT_PORTS[match[1]] || null }; return (domain1.protocol == domain2.protocol || domain1.relativeProtocol) && @@ -72,7 +72,7 @@ function isSameDomain(requestUrl, locationUrl) { * Headers are lazy parsed when first requested. * @see parseHeaders * - * @param {(string|Object)} headers Headers to provide access to. + * @param {string} headers Headers to provide access to. * @returns {function(string=)} Returns a getter function which if called with: * * - if called with single an argument returns a single header value or null @@ -81,6 +81,9 @@ function isSameDomain(requestUrl, locationUrl) { function headersGetter(headers) { var headersObj = isObject(headers) ? headers : undefined; + /** + * @param {string=} name The header name. + */ return function(name) { if (!headersObj) headersObj = parseHeaders(headers); @@ -393,7 +396,7 @@ function $HttpProvider() { * cookie with {@link http://en.wikipedia.org/wiki/Rainbow_table salt for added security}. * * - * @param {object} config Object describing the request to be made and how it should be + * @param {Object} config Object describing the request to be made and how it should be * processed. The object has following properties: * * - **method** – `{string}` – HTTP method (e.g. 'GET', 'POST', etc) diff --git a/src/ng/location.js b/src/ng/location.js index 73ef7f7b1db7..88f7b76d4889 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -28,13 +28,17 @@ function stripHash(url) { } +/** + * @param {string} url + * @param {Object=} obj + */ function matchUrl(url, obj) { var match = URL_MATCH.exec(url); match = { protocol: match[1], host: match[3], - port: int(match[5]) || DEFAULT_PORTS[match[1]] || null, + port: atoi(match[5]) || DEFAULT_PORTS[match[1]] || null, path: match[6] || '/', search: match[8], hash: match[10] @@ -341,7 +345,7 @@ LocationUrl.prototype = { * * Change search part when called with parameter and return `$location`. * - * @param {string|object=} search New search params - string or hash object + * @param {string|Object=} search New search params - string or hash object * @param {string=} paramValue If `search` is a string, then `paramValue` will override only a * single search parameter. If the value is `null`, the parameter will be deleted. * @@ -399,6 +403,9 @@ LocationUrl.prototype = { LocationHashbangUrl.prototype = inherit(LocationUrl.prototype); +/** + * @constructor + */ function LocationHashbangInHtml5Url(url, hashPrefix, appBaseUrl, baseExtra) { LocationHashbangUrl.apply(this, arguments); diff --git a/src/ng/parse.js b/src/ng/parse.js index 97aba1130364..9cf4a35c8fb5 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -113,6 +113,11 @@ function lex(text, csp){ return ch == '-' || ch == '+' || isNumber(ch); } + /** + * @param {string} error + * @param {number=} start + * @param {number=} end + */ function throwError(error, start, end) { end = end || index; throw Error("Lexer Error: " + error + " at column" + @@ -323,6 +328,12 @@ function parser(text, json, $filter, csp){ return false; } + /** + * @param {string=} e1 + * @param {string=} e2 + * @param {string=} e3 + * @param {string=} e4 + */ function expect(e1, e2, e3, e4){ var token = peek(e1, e2, e3, e4); if (token) { @@ -668,7 +679,7 @@ function setter(obj, path, setValue) { * Return the value accesible from the object by path. Any undefined traversals are ignored * @param {Object} obj starting object * @param {string} path path to traverse - * @param {boolean=true} bindFnToScope + * @param {boolean} bindFnToScope * @returns value as accesbile by path */ //TODO(misko): this function needs to be removed diff --git a/src/ng/q.js b/src/ng/q.js index 8b4747552081..5b80a97a55fa 100644 --- a/src/ng/q.js +++ b/src/ng/q.js @@ -164,7 +164,7 @@ function $QProvider() { * @param {function(function)} nextTick Function for executing functions in the next turn. * @param {function(...*)} exceptionHandler Function into which unexpected exceptions are passed for * debugging purposes. - * @returns {object} Promise manager. + * @returns {Object} Promise manager. */ function qFactory(nextTick, exceptionHandler) { diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index c99416f0040d..8fb28faac37b 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -119,14 +119,7 @@ function $RootScopeProvider(){ expect(parent.salutation).toEqual('Hello'); * * - * - * @param {Object.=} providers Map of service factory which need to be provided - * for the current scope. Defaults to {@link ng}. - * @param {Object.=} instanceCache Provides pre-instantiated services which should - * append/override services provided by `providers`. This is handy when unit-testing and having - * the need to override a default service. - * @returns {Object} Newly created scope. - * + * @constructor */ function Scope() { this.$id = nextUid(); @@ -186,6 +179,9 @@ function $RootScopeProvider(){ child = new Scope(); child.$root = this.$root; } else { + /** + * @constructor + */ Child = function() {}; // should be anonymous; This is so that when the minifier munges // the name it does not become random set of chars. These will then show up as class // name in the debugger. @@ -266,14 +262,14 @@ function $RootScopeProvider(){ * * * - * @param {(function()|string)} watchExpression Expression that is evaluated on each + * @param {(function()|string)} watchExp Expression that is evaluated on each * {@link ng.$rootScope.Scope#$digest $digest} cycle. A change in the return value triggers a * call to the `listener`. * * - `string`: Evaluated as {@link guide/expression expression} * - `function(scope)`: called with current `scope` as a parameter. * @param {(function()|string)=} listener Callback called whenever the return value of - * the `watchExpression` changes. + * the `watchExp` changes. * * - `string`: Evaluated as {@link guide/expression expression} * - `function(newValue, oldValue, scope)`: called with current and previous values as parameters. @@ -506,7 +502,7 @@ function $RootScopeProvider(){ expect(scope.$eval(function(scope){ return scope.a + scope.b; })).toEqual(3); * * - * @param {(string|function())=} expression An angular expression to be executed. + * @param {(string|function())=} expr An angular expression to be executed. * * - `string`: execute using the rules as defined in {@link guide/expression expression}. * - `function(scope)`: execute the function with the current `scope` parameter. @@ -535,7 +531,7 @@ function $RootScopeProvider(){ * Any exceptions from the execution of the expression are forwarded to the * {@link ng.$exceptionHandler $exceptionHandler} service. * - * @param {(string|function())=} expression An angular expression to be executed. + * @param {(string|function())=} expr An angular expression to be executed. * * - `string`: execute using the rules as defined in {@link guide/expression expression}. * - `function(scope)`: execute the function with the current `scope` parameter. @@ -584,7 +580,7 @@ function $RootScopeProvider(){ * was executed using the {@link ng.$rootScope.Scope#$digest $digest()} method. * * - * @param {(string|function())=} exp An angular expression to be executed. + * @param {(string|function())=} expr An angular expression to be executed. * * - `string`: execute using the rules as defined in {@link guide/expression expression}. * - `function(scope)`: execute the function with current `scope` parameter. diff --git a/src/ng/sniffer.js b/src/ng/sniffer.js index 9342fbd51b57..cb91aff15ced 100644 --- a/src/ng/sniffer.js +++ b/src/ng/sniffer.js @@ -16,7 +16,7 @@ function $SnifferProvider() { this.$get = ['$window', '$document', function($window, $document) { var eventSupport = {}, - android = int((/android (\d+)/.exec(lowercase($window.navigator.userAgent)) || [])[1]), + android = atoi((/android (\d+)/.exec(lowercase($window.navigator.userAgent)) || [])[1]), document = $document[0]; return { diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index 647a01fe38b2..b685b192be98 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -371,17 +371,17 @@ angular.mock.$LogProvider = function() { tzHour = 0, tzMin = 0; if (match[9]) { - tzHour = int(match[9] + match[10]); - tzMin = int(match[9] + match[11]); + tzHour = atoi(match[9] + match[10]); + tzMin = atoi(match[9] + match[11]); } - date.setUTCFullYear(int(match[1]), int(match[2]) - 1, int(match[3])); - date.setUTCHours(int(match[4]||0) - tzHour, int(match[5]||0) - tzMin, int(match[6]||0), int(match[7]||0)); + date.setUTCFullYear(atoi(match[1]), atoi(match[2]) - 1, atoi(match[3])); + date.setUTCHours(atoi(match[4]||0) - tzHour, atoi(match[5]||0) - tzMin, atoi(match[6]||0), atoi(match[7]||0)); return date; } return string; } - function int(str) { + function atoi(str) { return parseInt(str, 10); } diff --git a/src/ngSanitize/sanitize.js b/src/ngSanitize/sanitize.js index 04eafa0d77dc..f4dc1d7e4cb2 100644 --- a/src/ngSanitize/sanitize.js +++ b/src/ngSanitize/sanitize.js @@ -183,7 +183,7 @@ function makeMap(str) { * }); * * @param {string} html string - * @param {object} handler + * @param {Object} handler */ function htmlParser( html, handler ) { var index, chars, match, stack = [], last = html; @@ -339,7 +339,7 @@ function encodeEntities(value) { /** * create an HTML/XML writer which writes to buffer * @param {Array} buf use buf.jain('') to get out sanitized html string - * @returns {object} in the form of { + * @returns {Object} in the form of { * start: function(tag, attrs, unary) {}, * end: function(tag) {}, * chars: function(text) {}, diff --git a/src/ngScenario/Describe.js b/src/ngScenario/Describe.js index 4d52e9d58486..d2acdf71e436 100644 --- a/src/ngScenario/Describe.js +++ b/src/ngScenario/Describe.js @@ -128,7 +128,7 @@ angular.scenario.Describe.prototype.xit = angular.noop; * Gets an array of functions representing all the tests (recursively). * that can be executed with SpecRunner's. * - * @return {Array} Array of it blocks { + * @return {Array.} Array of it blocks { * definition : Object // parent Describe * only: boolean * name: string diff --git a/src/ngScenario/ObjectModel.js b/src/ngScenario/ObjectModel.js index 9c6ce56c23f4..f4b17b25a4cd 100644 --- a/src/ngScenario/ObjectModel.js +++ b/src/ngScenario/ObjectModel.js @@ -155,7 +155,7 @@ angular.scenario.ObjectModel.prototype.emit = function(eventName) { * this spec. * * @param spec Spec to compute the path for. - * @return {Array} The describe block path + * @return {Array.} The describe block path */ angular.scenario.ObjectModel.prototype.getDefinitionPath = function(spec) { var path = []; @@ -182,7 +182,7 @@ angular.scenario.ObjectModel.prototype.getSpec = function(id) { * * @param {string} id Id of the spec * @param {string} name Name of the spec - * @param {Array=} definitionNames List of all describe block names that wrap this spec + * @param {Array.=} definitionNames List of all describe block names that wrap this spec */ angular.scenario.ObjectModel.Spec = function(id, name, definitionNames) { this.id = id; diff --git a/src/ngScenario/Scenario.js b/src/ngScenario/Scenario.js index 4833e62954b3..2fdfab3fcd40 100644 --- a/src/ngScenario/Scenario.js +++ b/src/ngScenario/Scenario.js @@ -227,7 +227,7 @@ function callerFile(offset) { * Triggers a browser event. Attempts to choose the right event if one is * not specified. * - * @param {Object} element Either a wrapped jQuery/jqLite node or a DOMElement + * @param {Object} element Either a wrapped jQuery/jqLite node or a Element * @param {string} type Optional event type. * @param {Array.=} keys Optional list of pressed keys * (valid values: 'alt', 'meta', 'shift', 'ctrl') diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js index ac22c72c05cd..913313b96129 100644 --- a/test/testabilityPatch.js +++ b/test/testabilityPatch.js @@ -85,7 +85,7 @@ function dealoc(obj) { } /** - * @param {DOMElement} element + * @param {Element} element * @param {boolean=} showNgClass */ function sortedHtml(element, showNgClass) {