summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts
diff options
context:
space:
mode:
authorwei <>2006-08-12 05:34:54 +0000
committerwei <>2006-08-12 05:34:54 +0000
commit54d4919e3f1b00b644fa3c107acdf20159a1b154 (patch)
tree1c3e9cc679d4e08cc4beb06eee6f79838a34cb31 /framework/Web/Javascripts
parent6dd529fdc25404da07cf9256d92f2a94985c65fc (diff)
Update active controls.
Diffstat (limited to 'framework/Web/Javascripts')
-rw-r--r--framework/Web/Javascripts/js/ajax.js15
-rw-r--r--framework/Web/Javascripts/js/prado.js20
-rw-r--r--framework/Web/Javascripts/prado/activecontrols3.js11
-rw-r--r--framework/Web/Javascripts/prado/ajax3.js17
-rw-r--r--framework/Web/Javascripts/prado/element.js15
-rw-r--r--framework/Web/Javascripts/prototype/form.js60
-rw-r--r--framework/Web/Javascripts/prototype/hash.js26
7 files changed, 111 insertions, 53 deletions
diff --git a/framework/Web/Javascripts/js/ajax.js b/framework/Web/Javascripts/js/ajax.js
index fd1b7a76..0836f094 100644
--- a/framework/Web/Javascripts/js/ajax.js
+++ b/framework/Web/Javascripts/js/ajax.js
@@ -34,7 +34,9 @@ this.transport.onreadystatechange=Prototype.emptyFunction;},getHeaderData:functi
catch(e)
{if(typeof(json)=="string")
return Prado.CallbackRequest.decode(json);}}});Prado.CallbackRequest=Class.create();Object.extend(Prado.CallbackRequest,{FIELD_CALLBACK_TARGET:'PRADO_CALLBACK_TARGET',FIELD_CALLBACK_PARAMETER:'PRADO_CALLBACK_PARAMETER',FIELD_CALLBACK_PAGESTATE:'PRADO_PAGESTATE',FIELD_POSTBACK_TARGET:'PRADO_POSTBACK_TARGET',FIELD_POSTBACK_PARAMETER:'PRADO_POSTBACK_PARAMETER',PostDataLoaders:[],DATA_HEADER:'X-PRADO-DATA',ACTION_HEADER:'X-PRADO-ACTIONS',ERROR_HEADER:'X-PRADO-ERROR',PAGESTATE_HEADER:'X-PRADO-PAGESTATE',requestInProgress:null,addPostLoaders:function(ids)
-{this.PostDataLoaders=this.PostDataLoaders.concat(ids);},dispatchActions:function(transport,actions)
+{this.PostDataLoaders=this.PostDataLoaders.concat(ids);list=[];this.PostDataLoaders.each(function(id)
+{if(list.indexOf(id)<0)
+list.push(id);});this.PostDataLoaders=list;},dispatchActions:function(transport,actions)
{if(actions&&actions.length>0)
actions.each(this.__run.bind(this,transport));},__run:function(transport,command)
{for(var method in command)
@@ -93,8 +95,9 @@ Prado.CallbackRequest.dispatchNormalRequest(this);},_getPostData:function()
{var data={};var callback=Prado.CallbackRequest;if(this.options.PostInputs!=false)
{callback.PostDataLoaders.each(function(name)
{$A(document.getElementsByName(name)).each(function(element)
-{var value=$F(element);if(typeof(value)!="undefined")
-data[name]=value;})})}
+{if(element.type&&element.name==name)
+{value=$F(element);if(typeof(value)!="undefined")
+data[name]=value;}})})}
if(typeof(this.options.params)!="undefined")
data[callback.FIELD_CALLBACK_PARAMETER]=callback.encode(this.options.params);var pageState=$F(callback.FIELD_CALLBACK_PAGESTATE);if(typeof(pageState)!="undefined")
data[callback.FIELD_CALLBACK_PAGESTATE]=pageState;data[callback.FIELD_CALLBACK_TARGET]=this.id;if(this.options.EventTarget)
@@ -197,8 +200,8 @@ if(this.saving)return;this.effect=new Effect.Highlight(this.element,{startcolor:
this.editing=false;this.saving=false;this.oldInnerHTML=null;this.onLeaveEditMode();},onComplete:function(transport){this.leaveEditMode();this.options.onComplete.bind(this)(transport,this.element);},onEnterEditMode:function(){},onLeaveEditMode:function(){},dispose:function(){if(this.oldInnerHTML){this.element.innerHTML=this.oldInnerHTML;}
this.leaveEditMode();Event.stopObserving(this.element,'click',this.onclickListener);Event.stopObserving(this.element,'mouseover',this.mouseoverListener);Event.stopObserving(this.element,'mouseout',this.mouseoutListener);if(this.options.externalControl){Event.stopObserving(this.options.externalControl,'click',this.onclickListener);Event.stopObserving(this.options.externalControl,'mouseover',this.mouseoverListener);Event.stopObserving(this.options.externalControl,'mouseout',this.mouseoutListener);}}};Ajax.InPlaceCollectionEditor=Class.create();Object.extend(Ajax.InPlaceCollectionEditor.prototype,Ajax.InPlaceEditor.prototype);Object.extend(Ajax.InPlaceCollectionEditor.prototype,{createEditField:function(){if(!this.cached_selectTag){var selectTag=document.createElement("select");var collection=this.options.collection||[];var optionTag;collection.each(function(e,i){optionTag=document.createElement("option");optionTag.value=(e instanceof Array)?e[0]:e;if(this.options.value==optionTag.value)optionTag.selected=true;optionTag.appendChild(document.createTextNode((e instanceof Array)?e[1]:e));selectTag.appendChild(optionTag);}.bind(this));this.cached_selectTag=selectTag;}
this.editField=this.cached_selectTag;if(this.options.loadTextURL)this.loadExternalText();this.form.appendChild(this.editField);this.options.callback=function(form,value){return"value="+encodeURIComponent(value);}}});Form.Element.DelayedObserver=Class.create();Form.Element.DelayedObserver.prototype={initialize:function(element,delay,callback){this.delay=delay||0.5;this.element=$(element);this.callback=callback;this.timer=null;this.lastValue=$F(this.element);Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));},delayedListener:function(event){if(this.lastValue==$F(this.element))return;if(this.timer)clearTimeout(this.timer);this.timer=setTimeout(this.onTimerEvent.bind(this),this.delay*1000);this.lastValue=$F(this.element);},onTimerEvent:function(){this.timer=null;this.callback(this.element,$F(this.element));}};Prado.WebUI.CallbackControl=Class.extend(Prado.WebUI.PostBackControl,{onPostBack:function(event,options)
-{request=new Prado.CallbackRequest(options.EventTarget,options);request.dispatch();Event.stop(event);}});Prado.WebUI.TActiveButton=Class.extend(Prado.WebUI.CallbackControl);Prado.WebUI.TActiveCheckBox=Class.extend(Prado.WebUI.CallbackControl,{onPostBack:function(event,options)
-{request=new Prado.CallbackRequest(options.EventTarget,options);request.dispatch();}});Prado.WebUI.TActiveTextBox=Class.extend(Prado.WebUI.TTextBox,{onInit:function(options)
+{request=new Prado.CallbackRequest(options.EventTarget,options);request.dispatch();Event.stop(event);}});Prado.WebUI.TActiveButton=Class.extend(Prado.WebUI.CallbackControl);Prado.WebUI.TActiveLinkButton=Class.extend(Prado.WebUI.CallbackControl);Prado.WebUI.TActiveCheckBox=Class.extend(Prado.WebUI.CallbackControl,{onPostBack:function(event,options)
+{request=new Prado.CallbackRequest(options.EventTarget,options);request.dispatch();}});Prado.WebUI.TActiveRadioButton=Class.extend(Prado.WebUI.TActiveCheckBox);Prado.WebUI.TActiveTextBox=Class.extend(Prado.WebUI.TTextBox,{onInit:function(options)
{if(options['TextMode']!='MultiLine')
Event.observe(this.element,"keydown",this.handleReturnKey.bind(this));Event.observe(this.element,"change",this.doCallback.bindEvent(this,options));},doCallback:function(event,options)
{request=new Prado.CallbackRequest(options.EventTarget,options);request.dispatch();Event.stop(event);}});Prado.WebUI.TAutoComplete=Class.extend(Autocompleter.Base,Prado.WebUI.TActiveTextBox.prototype);Prado.WebUI.TAutoComplete=Class.extend(Prado.WebUI.TAutoComplete,{initialize:function(options)
@@ -225,4 +228,4 @@ this.timers[id].startTimer();},stop:function(id)
{if(this.timers[id])
this.timers[id].stopTimer();}});Prado.WebUI.ActiveListControl=Base.extend({constructor:function(options)
{this.element=$(options.ID);this.options=options;Event.observe(this.element,"change",this.doCallback.bind(this));},doCallback:function(event)
-{request=new Prado.CallbackRequest(this.options.EventTarget,this.options);request.dispatch();Event.stop(event);}});Prado.WebUI.TActiveDropDownList=Prado.WebUI.ActiveListControl; \ No newline at end of file
+{request=new Prado.CallbackRequest(this.options.EventTarget,this.options);request.dispatch();Event.stop(event);}});Prado.WebUI.TActiveDropDownList=Prado.WebUI.ActiveListControl;Prado.WebUI.TActiveListBox=Prado.WebUI.ActiveListControl; \ No newline at end of file
diff --git a/framework/Web/Javascripts/js/prado.js b/framework/Web/Javascripts/js/prado.js
index 25a26d70..e3930cfd 100644
--- a/framework/Web/Javascripts/js/prado.js
+++ b/framework/Web/Javascripts/js/prado.js
@@ -54,7 +54,12 @@ results.push(iterable[i]);return results;}}
Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse)
Array.prototype._reverse=Array.prototype.reverse;Object.extend(Array.prototype,{_each:function(iterator){for(var i=0;i<this.length;i++)
iterator(this[i]);},clear:function(){this.length=0;return this;},first:function(){return this[0];},last:function(){return this[this.length-1];},compact:function(){return this.select(function(value){return value!=undefined||value!=null;});},flatten:function(){return this.inject([],function(array,value){return array.concat(value&&value.constructor==Array?value.flatten():[value]);});},without:function(){var values=$A(arguments);return this.select(function(value){return!values.include(value);});},indexOf:function(object){for(var i=0;i<this.length;i++)
-if(this[i]==object)return i;return-1;},reverse:function(inline){return(inline!==false?this:this.toArray())._reverse();},inspect:function(){return'['+this.map(Object.inspect).join(', ')+']';}});var Hash={_each:function(iterator){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('=');}).join('&');},inspect:function(){return'#<Hash:{'+this.map(function(pair){return pair.map(Object.inspect).join(': ');}).join(', ')+'}>';}}
+if(this[i]==object)return i;return-1;},reverse:function(inline){return(inline!==false?this:this.toArray())._reverse();},inspect:function(){return'['+this.map(Object.inspect).join(', ')+']';}});var Hash={_each:function(iterator){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)
+{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'#<Hash:{'+this.map(function(pair){return pair.map(Object.inspect).join(': ');}).join(', ')+'}>';}}
function $H(object){var hash=Object.extend({},object||{});Object.extend(hash,Enumerable);Object.extend(hash,Hash);return hash;}
ObjectRange=Class.create();Object.extend(ObjectRange.prototype,Enumerable);Object.extend(ObjectRange.prototype,{initialize:function(start,end,exclusive){this.start=start;this.end=end;this.exclusive=exclusive;},_each:function(iterator){var value=this.start;do{iterator(value);value=value.succ();}while(this.include(value));},include:function(value){if(value<this.start)
return false;if(this.exclusive)
@@ -102,7 +107,8 @@ return matchingInputs;},disable:function(form){var elements=Form.getElements(for
Form.Element={serialize:function(element){element=$(element);var method=element.tagName.toLowerCase();var parameter=Form.Element.Serializers[method](element);if(parameter){var key=encodeURIComponent(parameter[0]);if(key.length==0)return;if(parameter[1].constructor!=Array)
parameter[1]=[parameter[1]];return parameter[1].map(function(value){return key+'='+encodeURIComponent(value);}).join('&');}},getValue:function(element){element=$(element);var method=element.tagName.toLowerCase();var parameter=Form.Element.Serializers[method](element);if(parameter)
return parameter[1];}}
-Form.Element.Serializers={input:function(element){switch(element.type.toLowerCase()){case'submit':case'hidden':case'password':case'text':return Form.Element.Serializers.textarea(element);case'checkbox':case'radio':return Form.Element.Serializers.inputSelector(element);}
+Form.Element.Serializers={input:function(element){if(typeof(element.type)=="undefined")
+return false;switch(element.type.toLowerCase()){case'submit':case'hidden':case'password':case'text':return Form.Element.Serializers.textarea(element);case'checkbox':case'radio':return Form.Element.Serializers.inputSelector(element);}
return false;},inputSelector:function(element){if(element.checked)
return[element.name,element.value];},textarea:function(element){return[element.name,element.value];},select:function(element){return Form.Element.Serializers[element.type=='select-one'?'selectOne':'selectMany'](element);},selectOne:function(element){var value='',opt,index=element.selectedIndex;if(index>=0){opt=element.options[index];value=opt.value||opt.text;}
return[element.name,value];},selectMany:function(element){var value=[];for(var i=0;i<element.length;i++){var opt=element.options[i];if(opt.selected)
@@ -256,9 +262,13 @@ el.value=value;},select:function(element,method,value,total)
{control=selection.isSelectable(el)?[el]:selection.getListElements(element,total);selection[method](control,value);}},click:function(element)
{var el=$(element);if(el)
Event.fireEvent(el,'click');},setAttribute:function(element,attribute,value)
-{var el=$(element);if(attribute=="disabled"&&value==false)
+{var el=$(element);if((attribute=="disabled"||attribute=="multiple")&&value==false)
el.removeAttribute(attribute);else if(attribute.match(/^on/i))
-el[attribute]=eval("(function(event){"+value+"})");else
+{try
+{eval("(func = function(event){"+value+"})");el[attribute]=func;}
+catch(e)
+{throw"Error in evaluating '"+value+"' for attribute "+attribute+" for element "+element.id;}}
+else
el.setAttribute(attribute,value);},setOptions:function(element,options)
{var el=$(element);if(el&&el.tagName.toLowerCase()=="select")
{el.options.length=options.length;for(var i=0;i<options.length;i++)
@@ -280,7 +290,7 @@ return null;},evaluateScript:function(content)
Prado.Element.Selection={isSelectable:function(el)
{if(el&&el.type)
{switch(el.type.toLowerCase())
-{case'checkbox':case'radio':case'select':case'select-one':return true;}}
+{case'checkbox':case'radio':case'select':case'select-multiple':case'select-one':return true;}}
return false;},inputValue:function(el,value)
{switch(el.type.toLowerCase())
{case'checkbox':case'radio':return el.checked=value;}},selectValue:function(elements,value)
diff --git a/framework/Web/Javascripts/prado/activecontrols3.js b/framework/Web/Javascripts/prado/activecontrols3.js
index 71719f35..f75d3684 100644
--- a/framework/Web/Javascripts/prado/activecontrols3.js
+++ b/framework/Web/Javascripts/prado/activecontrols3.js
@@ -15,6 +15,10 @@ Prado.WebUI.CallbackControl = Class.extend(Prado.WebUI.PostBackControl,
* TActiveButton control.
*/
Prado.WebUI.TActiveButton = Class.extend(Prado.WebUI.CallbackControl);
+/**
+ * TActiveLinkButton control.
+ */
+Prado.WebUI.TActiveLinkButton = Class.extend(Prado.WebUI.CallbackControl);
/**
* Active check box.
@@ -29,6 +33,12 @@ Prado.WebUI.TActiveCheckBox = Class.extend(Prado.WebUI.CallbackControl,
});
/**
+ * TActiveRadioButton control.
+ */
+Prado.WebUI.TActiveRadioButton = Class.extend(Prado.WebUI.TActiveCheckBox);
+
+
+/**
* TActiveTextBox control, handles onchange event.
*/
Prado.WebUI.TActiveTextBox = Class.extend(Prado.WebUI.TTextBox,
@@ -212,3 +222,4 @@ Prado.WebUI.ActiveListControl = Base.extend(
});
Prado.WebUI.TActiveDropDownList = Prado.WebUI.ActiveListControl;
+Prado.WebUI.TActiveListBox = Prado.WebUI.ActiveListControl;
diff --git a/framework/Web/Javascripts/prado/ajax3.js b/framework/Web/Javascripts/prado/ajax3.js
index 8de0b0fe..de5af4ca 100644
--- a/framework/Web/Javascripts/prado/ajax3.js
+++ b/framework/Web/Javascripts/prado/ajax3.js
@@ -120,6 +120,13 @@ Object.extend(Prado.CallbackRequest,
addPostLoaders : function(ids)
{
this.PostDataLoaders = this.PostDataLoaders.concat(ids);
+ list = [];
+ this.PostDataLoaders.each(function(id)
+ {
+ if(list.indexOf(id) < 0)
+ list.push(id);
+ });
+ this.PostDataLoaders = list;
},
/**
@@ -477,9 +484,13 @@ Prado.CallbackRequest.prototype =
{
$A(document.getElementsByName(name)).each(function(element)
{
- var value = $F(element);
- if(typeof(value) != "undefined")
- data[name] = value;
+ //IE will try to get elements with ID == name as well.
+ if(element.type && element.name == name)
+ {
+ value = $F(element);
+ if(typeof(value) != "undefined")
+ data[name] = value;
+ }
})
})
}
diff --git a/framework/Web/Javascripts/prado/element.js b/framework/Web/Javascripts/prado/element.js
index 9b7bd120..d234e71b 100644
--- a/framework/Web/Javascripts/prado/element.js
+++ b/framework/Web/Javascripts/prado/element.js
@@ -33,10 +33,20 @@ Prado.Element =
setAttribute : function(element, attribute, value)
{
var el = $(element);
- if(attribute == "disabled" && value==false)
+ if((attribute == "disabled" || attribute == "multiple") && value==false)
el.removeAttribute(attribute);
else if(attribute.match(/^on/i)) //event methods
- el[attribute] = eval("(function(event){"+value+"})");
+ {
+ try
+ {
+ eval("(func = function(event){"+value+"})");
+ el[attribute] = func;
+ }
+ catch(e)
+ {
+ throw "Error in evaluating '"+value+"' for attribute "+attribute+" for element "+element.id;
+ }
+ }
else
el.setAttribute(attribute, value);
},
@@ -110,6 +120,7 @@ Prado.Element.Selection =
case 'checkbox':
case 'radio':
case 'select':
+ case 'select-multiple':
case 'select-one':
return true;
}
diff --git a/framework/Web/Javascripts/prototype/form.js b/framework/Web/Javascripts/prototype/form.js
index 590f7f9f..41745353 100644
--- a/framework/Web/Javascripts/prototype/form.js
+++ b/framework/Web/Javascripts/prototype/form.js
@@ -7,17 +7,17 @@ var Field = {
focus: function(element) {
$(element).focus();
},
-
+
present: function() {
for (var i = 0; i < arguments.length; i++)
if ($(arguments[i]).value == '') return false;
return true;
},
-
+
select: function(element) {
$(element).select();
},
-
+
activate: function(element) {
element = $(element);
element.focus();
@@ -32,16 +32,16 @@ var Form = {
serialize: function(form) {
var elements = Form.getElements($(form));
var queryComponents = new Array();
-
+
for (var i = 0; i < elements.length; i++) {
var queryComponent = Form.Element.serialize(elements[i]);
if (queryComponent)
queryComponents.push(queryComponent);
}
-
+
return queryComponents.join('&');
},
-
+
getElements: function(form) {
form = $(form);
var elements = new Array();
@@ -53,19 +53,19 @@ var Form = {
}
return elements;
},
-
+
getInputs: function(form, typeName, name) {
form = $(form);
var inputs = form.getElementsByTagName('input');
-
+
if (!typeName && !name)
return inputs;
-
+
var matchingInputs = new Array();
for (var i = 0; i < inputs.length; i++) {
var input = inputs[i];
if ((typeName && input.type != typeName) ||
- (name && input.name != name))
+ (name && input.name != name))
continue;
matchingInputs.push(input);
}
@@ -111,25 +111,25 @@ Form.Element = {
element = $(element);
var method = element.tagName.toLowerCase();
var parameter = Form.Element.Serializers[method](element);
-
+
if (parameter) {
var key = encodeURIComponent(parameter[0]);
if (key.length == 0) return;
-
+
if (parameter[1].constructor != Array)
parameter[1] = [parameter[1]];
-
+
return parameter[1].map(function(value) {
return key + '=' + encodeURIComponent(value);
}).join('&');
}
},
-
+
getValue: function(element) {
element = $(element);
var method = element.tagName.toLowerCase();
var parameter = Form.Element.Serializers[method](element);
-
+
if (parameter)
return parameter[1];
}
@@ -137,13 +137,15 @@ Form.Element = {
Form.Element.Serializers = {
input: function(element) {
+ if(typeof(element.type) == "undefined")
+ return false;
switch (element.type.toLowerCase()) {
case 'submit':
case 'hidden':
case 'password':
case 'text':
return Form.Element.Serializers.textarea(element);
- case 'checkbox':
+ case 'checkbox':
case 'radio':
return Form.Element.Serializers.inputSelector(element);
}
@@ -158,12 +160,12 @@ Form.Element.Serializers = {
textarea: function(element) {
return [element.name, element.value];
},
-
+
select: function(element) {
- return Form.Element.Serializers[element.type == 'select-one' ?
+ return Form.Element.Serializers[element.type == 'select-one' ?
'selectOne' : 'selectMany'](element);
},
-
+
selectOne: function(element) {
var value = '', opt, index = element.selectedIndex;
if (index >= 0) {
@@ -172,7 +174,7 @@ Form.Element.Serializers = {
}
return [element.name, value];
},
-
+
selectMany: function(element) {
var value = [];
for (var i = 0; i < element.length; i++) {
@@ -196,15 +198,15 @@ Abstract.TimedObserver.prototype = {
this.frequency = frequency;
this.element = $(element);
this.callback = callback;
-
+
this.lastValue = this.getValue();
this.registerCallback();
},
-
+
registerCallback: function() {
setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
},
-
+
onTimerEvent: function() {
var value = this.getValue();
if (this.lastValue != value) {
@@ -235,14 +237,14 @@ Abstract.EventObserver.prototype = {
initialize: function(element, callback) {
this.element = $(element);
this.callback = callback;
-
+
this.lastValue = this.getValue();
if (this.element.tagName.toLowerCase() == 'form')
this.registerFormCallbacks();
else
this.registerCallback(this.element);
},
-
+
onElementEvent: function() {
var value = this.getValue();
if (this.lastValue != value) {
@@ -250,17 +252,17 @@ Abstract.EventObserver.prototype = {
this.lastValue = value;
}
},
-
+
registerFormCallbacks: function() {
var elements = Form.getElements(this.element);
for (var i = 0; i < elements.length; i++)
this.registerCallback(elements[i]);
},
-
+
registerCallback: function(element) {
if (element.type) {
switch (element.type.toLowerCase()) {
- case 'checkbox':
+ case 'checkbox':
case 'radio':
Event.observe(element, 'click', this.onElementEvent.bind(this));
break;
@@ -272,7 +274,7 @@ Abstract.EventObserver.prototype = {
Event.observe(element, 'change', this.onElementEvent.bind(this));
break;
}
- }
+ }
}
}
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 '#<Hash:{' + this.map(function(pair) {
return pair.map(Object.inspect).join(': ');