aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Minar2010-10-18 22:24:44 -0700
committerIgor Minar2010-10-18 22:24:44 -0700
commita1fa23397f12e0b52838530a993f14491ad50869 (patch)
tree543a7d74d040567d111f15a80362dd8bf3963f4d
parentffb968b08b68351e9e2e19fd7992d55ddcdedb84 (diff)
downloadangular.js-a1fa23397f12e0b52838530a993f14491ad50869.tar.bz2
small fixes to the $location services
* fixing the jsdoc format * rewriting updateHash() method to be easier to read and so that it minifies better
-rw-r--r--src/services.js37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/services.js b/src/services.js
index 0b5923c6..a8004dd1 100644
--- a/src/services.js
+++ b/src/services.js
@@ -46,7 +46,7 @@ angularServiceInject("$location", function(browser) {
* scope.$location.update({host: 'www.google.com', protocol: 'https'});
* scope.$location.update({hashPath: '/path', hashSearch: {a: 'b', x: true}});
*
- * @param {String | Object} Full href as a string or hash object with properties
+ * @param {(string|Object)} href Full href as a string or hash object with properties
*/
function update(href) {
if (isString(href)) {
@@ -80,21 +80,26 @@ angularServiceInject("$location", function(browser) {
* scope.$location.updateHash('/hp', {a: true})
* ==> update({hashPath: '/hp', hashSearch: {a: true}})
*
- * @param {String | Object} hashPath as String or hashSearch as Object
- * @param {String | Object} hashPath as String or hashSearch as Object [optional]
+ * @param {(string|Object)} path A hashPath or hashSearch object
+ * @param {Object=} search A hashSearch object
*/
- function updateHash() {
+ function updateHash(path, search) {
var hash = {};
- for (var i = 0; i < Math.min(arguments.length, 2); i++) {
- hash[isString(arguments[i]) ? 'hashPath' : 'hashSearch'] = arguments[i];
- }
+
+ if (isString(path)) {
+ hash.hashPath = path;
+ if (isDefined(search))
+ hash.hashSearch = search;
+ } else
+ hash.hashSearch = path;
+
update(hash);
}
/**
* Returns string representation - href
*
- * @return {String} Location's href property
+ * @return {string} Location's href property
*/
function toString() {
updateLocation();
@@ -141,8 +146,8 @@ angularServiceInject("$location", function(browser) {
/**
* Compose href string from a location object
*
- * @param {Object} Location object with all properties
- * @return {String} Composed href
+ * @param {Object} loc The location object with all properties
+ * @return {string} Composed href
*/
function composeHref(loc) {
var url = toKeyValue(loc.search);
@@ -156,8 +161,8 @@ angularServiceInject("$location", function(browser) {
/**
* Compose hash string from location object
*
- * @param {Object} Object with hashPath and hashSearch properties
- * @return {String} Hash string
+ * @param {Object} loc Object with hashPath and hashSearch properties
+ * @return {string} Hash string
*/
function composeHash(loc) {
var hashSearch = toKeyValue(loc.hashSearch);
@@ -167,8 +172,8 @@ angularServiceInject("$location", function(browser) {
/**
* Parse href string into location object
*
- * @param {String} Href
- * @return {Object} Location
+ * @param {string} href
+ * @return {Object} The location object
*/
function parseHref(href) {
var loc = {};
@@ -192,8 +197,7 @@ angularServiceInject("$location", function(browser) {
/**
* Parse hash string into object
*
- * @param {String} Hash
- * @param {Object} Object with hashPath and hashSearch properties
+ * @param {string} hash
*/
function parseHash(hash) {
var h = {};
@@ -209,6 +213,7 @@ angularServiceInject("$location", function(browser) {
}
}, ['$browser'], EAGER_PUBLISHED);
+
angularServiceInject("$log", function($window){
var console = $window.console || {log: noop, warn: noop, info: noop, error: noop},
log = console.log || noop;