summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts
diff options
context:
space:
mode:
authorwei <>2007-03-30 07:11:11 +0000
committerwei <>2007-03-30 07:11:11 +0000
commit96c0b5c35463387664db3fa69898d54a929eaa2a (patch)
tree19e2ee4be1ff30a651d4fed63c6b04a36778a5a6 /framework/Web/Javascripts
parent62958aa45b4ccf5369b41b7e635582b1be0d1edc (diff)
Fixed #538
Diffstat (limited to 'framework/Web/Javascripts')
-rw-r--r--framework/Web/Javascripts/js/compressed/prado.js18
-rw-r--r--framework/Web/Javascripts/js/debug/prado.js52
-rw-r--r--framework/Web/Javascripts/prado/scriptaculous-adapter.js52
3 files changed, 113 insertions, 9 deletions
diff --git a/framework/Web/Javascripts/js/compressed/prado.js b/framework/Web/Javascripts/js/compressed/prado.js
index 9912b1fc..55651927 100644
--- a/framework/Web/Javascripts/js/compressed/prado.js
+++ b/framework/Web/Javascripts/js/compressed/prado.js
@@ -291,9 +291,21 @@ 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)return;if(el&&el.tagName.toLowerCase()=="select")
-{el.options.length=options.length;for(var i=0;i<options.length;i++)
-el.options[i]=new Option(options[i][0],options[i][1]);}},focus:function(element)
+{var el=$(element);if(!el)return;var previousGroup=null;var optGroup=null;if(el&&el.tagName.toLowerCase()=="select")
+{while(el.childNodes.length>0)
+el.removeChild(el.lastChild);var optDom=Prado.Element.createOptions(options);for(var i=0;i<optDom.length;i++)
+el.appendChild(optDom[i]);}},createOptions:function(options)
+{var previousGroup=null;var optgroup=null;var result=[];for(var i=0;i<options.length;i++)
+{var option=options[i];if(option.length>2)
+{var group=option[2];if(group!=previousGroup)
+{if(previousGroup!=null&&optgroup!=null)
+{result.push(optgroup);previousGroup=null;optgroup=null;}
+optgroup=document.createElement('optgroup');optgroup.label=group;previousGroup=group;}}
+var opt=document.createElement('option');opt.text=option[0];opt.innerText=option[0];opt.value=option[1];if(optgroup!=null)
+optgroup.appendChild(opt);else
+result.push(opt);}
+if(optgroup!=null)
+result.push(optgroup);return result;},focus:function(element)
{var obj=$(element);if(typeof(obj)!="undefined"&&typeof(obj.focus)!="undefined")
setTimeout(function(){obj.focus();},100);return false;},replace:function(element,method,content,boundary)
{if(boundary)
diff --git a/framework/Web/Javascripts/js/debug/prado.js b/framework/Web/Javascripts/js/debug/prado.js
index 0e815b99..d1a04f4f 100644
--- a/framework/Web/Javascripts/js/debug/prado.js
+++ b/framework/Web/Javascripts/js/debug/prado.js
@@ -3648,12 +3648,58 @@ Prado.Element =
{
var el = $(element);
if(!el) return;
+ var previousGroup = null;
+ var optGroup=null;
if(el && el.tagName.toLowerCase() == "select")
{
- el.options.length = options.length;
- for(var i = 0; i<options.length; i++)
- el.options[i] = new Option(options[i][0],options[i][1]);
+ while(el.childNodes.length > 0)
+ el.removeChild(el.lastChild);
+
+ var optDom = Prado.Element.createOptions(options);
+ for(var i = 0; i < optDom.length; i++)
+ el.appendChild(optDom[i]);
+ }
+ },
+
+ /**
+ * Create opt-group options from an array of options[0]=text, options[1]=value, options[2]=group
+ */
+ createOptions : function(options)
+ {
+ var previousGroup = null;
+ var optgroup=null;
+ var result = [];
+ for(var i = 0; i<options.length; i++)
+ {
+ var option = options[i];
+ if(option.length > 2)
+ {
+ var group = option[2];
+ if(group!=previousGroup)
+ {
+ if(previousGroup!=null && optgroup!=null)
+ {
+ result.push(optgroup);
+ previousGroup=null;
+ optgroup=null;
+ }
+ optgroup = document.createElement('optgroup');
+ optgroup.label = group;
+ previousGroup = group;
+ }
+ }
+ var opt = document.createElement('option');
+ opt.text = option[0];
+ opt.innerText = option[0];
+ opt.value = option[1];
+ if(optgroup!=null)
+ optgroup.appendChild(opt);
+ else
+ result.push(opt);
}
+ if(optgroup!=null)
+ result.push(optgroup);
+ return result;
},
/**
diff --git a/framework/Web/Javascripts/prado/scriptaculous-adapter.js b/framework/Web/Javascripts/prado/scriptaculous-adapter.js
index f7971884..63b49600 100644
--- a/framework/Web/Javascripts/prado/scriptaculous-adapter.js
+++ b/framework/Web/Javascripts/prado/scriptaculous-adapter.js
@@ -236,12 +236,58 @@ Prado.Element =
{
var el = $(element);
if(!el) return;
+ var previousGroup = null;
+ var optGroup=null;
if(el && el.tagName.toLowerCase() == "select")
{
- el.options.length = options.length;
- for(var i = 0; i<options.length; i++)
- el.options[i] = new Option(options[i][0],options[i][1]);
+ while(el.childNodes.length > 0)
+ el.removeChild(el.lastChild);
+
+ var optDom = Prado.Element.createOptions(options);
+ for(var i = 0; i < optDom.length; i++)
+ el.appendChild(optDom[i]);
+ }
+ },
+
+ /**
+ * Create opt-group options from an array of options[0]=text, options[1]=value, options[2]=group
+ */
+ createOptions : function(options)
+ {
+ var previousGroup = null;
+ var optgroup=null;
+ var result = [];
+ for(var i = 0; i<options.length; i++)
+ {
+ var option = options[i];
+ if(option.length > 2)
+ {
+ var group = option[2];
+ if(group!=previousGroup)
+ {
+ if(previousGroup!=null && optgroup!=null)
+ {
+ result.push(optgroup);
+ previousGroup=null;
+ optgroup=null;
+ }
+ optgroup = document.createElement('optgroup');
+ optgroup.label = group;
+ previousGroup = group;
+ }
+ }
+ var opt = document.createElement('option');
+ opt.text = option[0];
+ opt.innerText = option[0];
+ opt.value = option[1];
+ if(optgroup!=null)
+ optgroup.appendChild(opt);
+ else
+ result.push(opt);
}
+ if(optgroup!=null)
+ result.push(optgroup);
+ return result;
},
/**