summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes5
-rw-r--r--HISTORY1
-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
-rw-r--r--framework/Web/UI/ActiveControls/TCallbackClientScript.php7
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket538.page25
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket538.php102
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket542.page16
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket542.php23
-rw-r--r--tests/FunctionalTests/tickets/tests/Ticket538TestCase.php30
11 files changed, 321 insertions, 10 deletions
diff --git a/.gitattributes b/.gitattributes
index ed9bb3a2..6a72c98d 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2403,7 +2403,11 @@ tests/FunctionalTests/tickets/protected/pages/Ticket511.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket518.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket521.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket521.php -text
+tests/FunctionalTests/tickets/protected/pages/Ticket538.page -text
+tests/FunctionalTests/tickets/protected/pages/Ticket538.php -text
tests/FunctionalTests/tickets/protected/pages/Ticket54.page -text
+tests/FunctionalTests/tickets/protected/pages/Ticket542.page -text
+tests/FunctionalTests/tickets/protected/pages/Ticket542.php -text
tests/FunctionalTests/tickets/protected/pages/Ticket54Master.php -text
tests/FunctionalTests/tickets/protected/pages/Ticket54Master.tpl -text
tests/FunctionalTests/tickets/protected/pages/Ticket573.page -text
@@ -2436,6 +2440,7 @@ tests/FunctionalTests/tickets/tests/Ticket477TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket488TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket507TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket521TestCase.php -text
+tests/FunctionalTests/tickets/tests/Ticket538TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket54TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket573TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket578TestCase.php -text
diff --git a/HISTORY b/HISTORY
index ceca195a..ab680136 100644
--- a/HISTORY
+++ b/HISTORY
@@ -4,6 +4,7 @@ BUG: Ticket#278 - client-side validator enable/disable (conditional) (Wei)
BUG: Ticket#492 - TDataGridPagerStyle not found error (Qiang)
BUG: Ticket#517 - Quickstart I18N sample: conflicting module ID (Wei)
BUG: Ticket#521 - comment tag on TActiveButton stop callback (Wei)
+BUG: Ticket#538 - TActiveListBox doesn't support optgroup (Wei)
BUG: Ticket#549 - set/get Timestamp on TDatePicker shound handle "null" values (Qiang)
BUG: Ticket#550 - explicitly include TCallbackClientSide in TCallbackOptions (Qiang)
BUG: Ticket#553 - I18N quickstart sample does not work (Qiang)
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;
},
/**
diff --git a/framework/Web/UI/ActiveControls/TCallbackClientScript.php b/framework/Web/UI/ActiveControls/TCallbackClientScript.php
index b10552e8..837b5b51 100644
--- a/framework/Web/UI/ActiveControls/TCallbackClientScript.php
+++ b/framework/Web/UI/ActiveControls/TCallbackClientScript.php
@@ -176,7 +176,12 @@ class TCallbackClientScript extends TApplicationComponent
{
$options = array();
foreach($items as $item)
- $options[] = array($item->getText(),$item->getValue());
+ {
+ if($item->getHasAttributes())
+ $options[] = array($item->getText(),$item->getValue(), $item->getAttributes()->itemAt('Group'));
+ else
+ $options[] = array($item->getText(),$item->getValue());
+ }
$this->callClientFunction('Prado.Element.setOptions', array($control, $options));
}
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket538.page b/tests/FunctionalTests/tickets/protected/pages/Ticket538.page
new file mode 100644
index 00000000..80ab5ff0
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket538.page
@@ -0,0 +1,25 @@
+<com:TContent ID="Content">
+<!-- $Id: Home.page 1650 2007-01-24 06:55:32Z wei $ -->
+
+ <com:TActiveListBox ID="DataSelector" OnSelectedIndexChanged="dataSelector_Clicked" >
+ <com:TListItem Value="1" Text="select data set 1" Attributes.Group="group1" />
+ <com:TListItem Value="2" Text="select data set 2" />
+ <com:TListItem Value="3" Text="select data set 3" />
+ <com:TListItem Value="4" Text="select data set 4" />
+ </com:TActiveListBox>
+ <com:TActiveListBox
+ ID="DataViewer"
+ SelectionMode="Multiple"
+ Rows="5"
+ Style="background-color: #0cf"
+ Width="400px">
+ <com:TListItem Value="0" Text="empty :(" />
+ </com:TActiveListBox>
+ <com:TActiveButton
+ ID="selectBtn"
+ Text="view more..."
+ OnClick="selectBtn_Clicked"/>
+ <br />
+<com:TActiveLabel ID="ALLog" Text="waiting for response..." />
+
+<div class="last-modified">$Id: Home.page 1650 2007-01-24 06:55:32Z wei $</div></com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket538.php b/tests/FunctionalTests/tickets/protected/pages/Ticket538.php
new file mode 100644
index 00000000..2ad9fd43
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket538.php
@@ -0,0 +1,102 @@
+<?php
+// $Id: Home.php 1405 2006-09-10 01:03:56Z wei $
+Prado::using('System.Web.UI.ActiveControls.*');
+class Ticket538 extends TPage
+{
+ public function checkboxClicked($sender,$param)
+ {
+ $sender->Text= $sender->ClientID . " clicked";
+ }
+
+ public function checkboxCallback($sender, $param)
+ {
+ $sender->Text .= ' using callback';
+ }
+
+ public function readData()
+ {
+ $data=array(
+ array('id'=>'001','name'=>'John','age'=>31),
+ array('id'=>'002','name'=>'Mary','age'=>30),
+ array('id'=>'003','name'=>'Cary','age'=>20),
+ array('id'=>'004','name'=>'Kevin','age'=>65),
+ array('id'=>'005','name'=>'Steven','age'=>10),
+ array('id'=>'006','name'=>'Josh','age'=>23),
+ array('id'=>'007','name'=>'Lary','age'=>54));
+ return $data;
+ }
+
+ //--------------------------------------------------------------------
+ // TListBox
+ //--------------------------------------------------------------------
+
+ public function dataSelector2_Clicked($sender, $param)
+ {
+ $this->DataViewer2->DataTextField='name';
+ $this->DataViewer2->Items->clear();
+ foreach ($this->readData() as $index=>$person)
+ {
+ $item = new TListItem('G1: '.$person['name'].'=>'.$person['age'],$index);
+ $item->Attributes->Group = 'test1';
+ $this->DataViewer2->Items->add($item);
+ }
+ foreach ($this->readData() as $index=>$person)
+ {
+ $item2 = new TListItem('G2: '.$person['name'].'=>'.$person['age'],$index+100);
+ $item2->Attributes->Group = 'test2';
+ $this->DataViewer2->Items->add($item2);
+ }
+ $this->DataViewer2->dataBind();
+ }
+
+ public function selectBtn2_Clicked()
+ {
+ $text = '';
+ foreach ($this->DataViewer2->SelectedIndices as $index)
+ {
+ $text .= '"'.$this->DataViewer2->Items[$index]->Attributes->Group.'", ';
+ }
+ $this->ALLog->setText($text);
+ }
+
+ //--------------------------------------------------------------------
+ // TActiveListBox
+ //--------------------------------------------------------------------
+
+
+ public function dataSelector_Clicked($sender, $param)
+ {
+ $this->DataViewer->DataTextField='name';
+ $this->DataViewer->Items->clear();
+ foreach ($this->readData() as $index=>$person)
+ {
+ $item = new TListItem('G1: '.$person['name'].'=>'.$person['age'],$index);
+ $item->Attributes->Group = 'test1';
+ $this->DataViewer->Items->add($item);
+ }
+
+ foreach ($this->readData() as $index=>$person)
+ {
+ $item2 = new TListItem('G2: '.$person['name'].'=>'.$person['age'],$index+100);
+ $item2->Attributes->Group = 'test2';
+ $this->DataViewer->Items->add($item2);
+ }
+ $this->DataViewer->dataBind();
+ }
+
+ public function selectBtn_Clicked()
+ {
+ $text = '';
+ foreach ($this->DataViewer->SelectedIndices as $index)
+ {
+ if($this->DataViewer->Items[$index]->Attributes['Group'])
+ $text .= $index .'- "'.$this->DataViewer->Items[$index]->Attributes->Group.'", ';
+ else
+ $text .= $index.',';
+ }
+ $this->ALLog->setText($text);
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket542.page b/tests/FunctionalTests/tickets/protected/pages/Ticket542.page
new file mode 100644
index 00000000..5c39c6b5
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket542.page
@@ -0,0 +1,16 @@
+<com:TContent ID="Content">
+ <com:TActivePanel ID="TheBox" Attributes.style="width: 600px; border: solid 1px #000000; position: relative; padding: 5px;">
+ <div>
+ Some content
+ Test
+ 123
+ 456
+ </div>
+ </com:TActivePanel>
+
+ <com:TActiveButton OnCallback="blindDown" Text="Blind Down" />
+ <com:TActiveButton OnCallback="blindUp" Text="Blind Up" />
+ <com:TActiveButton OnCallback="slideDown" Text="Slide Down" />
+ <com:TActiveButton OnCallback="slideUp" Text="Slide Up" />
+
+</com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket542.php b/tests/FunctionalTests/tickets/protected/pages/Ticket542.php
new file mode 100644
index 00000000..bcd32a04
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket542.php
@@ -0,0 +1,23 @@
+<?php
+Prado::using('System.Web.UI.ActiveControls.*');
+class Ticket542 extends TPage {
+
+ public function slideUp($sender, $param) {
+ $this->CallbackClient->slideUp($this->TheBox);
+ }
+
+ public function blindUp($sender, $param) {
+ $this->CallbackClient->blindUp($this->TheBox);
+ }
+
+ public function slideDown($sender, $param) {
+ $this->CallbackClient->slideDown($this->TheBox);
+ }
+
+ public function blindDown($sender, $param) {
+ $this->CallbackClient->blindDown($this->TheBox);
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/tests/FunctionalTests/tickets/tests/Ticket538TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket538TestCase.php
new file mode 100644
index 00000000..712ff24b
--- /dev/null
+++ b/tests/FunctionalTests/tickets/tests/Ticket538TestCase.php
@@ -0,0 +1,30 @@
+<?php
+
+class Ticket538TestCase extends SeleniumTestCase
+{
+ function test()
+ {
+ $base="ctl0_Content_";
+ $this->open('tickets/index.php?page=Ticket538');
+ $this->verifyTitle("Verifying Ticket 538", "");
+
+ $this->assertText("{$base}ALLog", 'waiting for response...');
+
+ $this->select("{$base}DataViewer", "empty :(");
+ $this->click("{$base}selectBtn");
+ $this->pause(800);
+
+ $this->assertText("{$base}ALLog", '0,');
+
+ $this->select("{$base}DataSelector", "select data set 2");
+ $this->pause(800);
+ $this->select("{$base}DataViewer", "G1: Steven=>10");
+ $this->addSelection("{$base}DataViewer", "G2: Kevin=>65");
+
+ $this->click("{$base}selectBtn");
+ $this->pause(800);
+ $this->assertText("{$base}ALLog", '4- "test1", 10- "test2",');
+ }
+}
+
+?> \ No newline at end of file