From 54d4919e3f1b00b644fa3c107acdf20159a1b154 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sat, 12 Aug 2006 05:34:54 +0000 Subject: Update active controls. --- framework/Web/Javascripts/prototype/hash.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'framework/Web/Javascripts/prototype/hash.js') diff --git a/framework/Web/Javascripts/prototype/hash.js b/framework/Web/Javascripts/prototype/hash.js index 7e8c6f5d..1589189c 100644 --- a/framework/Web/Javascripts/prototype/hash.js +++ b/framework/Web/Javascripts/prototype/hash.js @@ -3,35 +3,45 @@ var Hash = { for (var key in this) { var value = this[key]; if (typeof value == 'function') continue; - + var pair = [key, value]; pair.key = key; pair.value = value; iterator(pair); } }, - + keys: function() { return this.pluck('key'); }, - + values: function() { return this.pluck('value'); }, - + merge: function(hash) { return $H(hash).inject($H(this), function(mergedHash, pair) { mergedHash[pair.key] = pair.value; return mergedHash; }); }, - + toQueryString: function() { - return this.map(function(pair) { - return pair.map(encodeURIComponent).join('='); + return this.map(function(pair) + { + //special case for PHP, array post data. + if(typeof(pair[1]) == 'object' || typeof(pair[1]) == 'array') + { + return $A(pair[1]).collect(function(value) + { + return encodeURIComponent(pair[0])+'='+encodeURIComponent(value); + }).join('&'); + } + else + return pair.map(encodeURIComponent).join('='); }).join('&'); }, - + inspect: function() { return '#