diff options
Diffstat (limited to 'framework/Web/UI/JuiControls')
-rw-r--r-- | framework/Web/UI/JuiControls/TJuiAutoComplete.php | 6 | ||||
-rw-r--r-- | framework/Web/UI/JuiControls/TJuiControlAdapter.php | 8 | ||||
-rw-r--r-- | framework/Web/UI/JuiControls/TJuiDraggable.php | 4 | ||||
-rw-r--r-- | framework/Web/UI/JuiControls/TJuiDroppable.php | 26 | ||||
-rw-r--r-- | framework/Web/UI/JuiControls/TJuiResizable.php | 4 | ||||
-rw-r--r-- | framework/Web/UI/JuiControls/TJuiSelectable.php | 62 | ||||
-rw-r--r-- | framework/Web/UI/JuiControls/TJuiSortable.php | 74 |
7 files changed, 134 insertions, 50 deletions
diff --git a/framework/Web/UI/JuiControls/TJuiAutoComplete.php b/framework/Web/UI/JuiControls/TJuiAutoComplete.php index a8bf2d81..9f6432bf 100644 --- a/framework/Web/UI/JuiControls/TJuiAutoComplete.php +++ b/framework/Web/UI/JuiControls/TJuiAutoComplete.php @@ -4,9 +4,8 @@ * * @author Wei Zhuo <weizhuo[at]gamil[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2005-2013 PradoSoft + * @copyright Copyright © 2005-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TJuiAutoComplete.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.ActiveControls */ @@ -77,7 +76,6 @@ Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter'); * "informal" are ignored as text for suggestions. * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @version $Id: TJuiAutoComplete.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.ActiveControls * @since 3.1 */ @@ -360,7 +358,6 @@ class TJuiAutoComplete extends TActiveTextBox implements INamingContainer, IJuiO * suggestion selected by the user, -1 if not suggestion is selected. * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @version $Id: TJuiAutoComplete.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.ActiveControls * @since 3.1 */ @@ -401,7 +398,6 @@ class TJuiAutoCompleteEventParameter extends TCallbackEventParameter * item template. * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @version $Id: TJuiAutoComplete.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.ActiveControls * @since 3.1 */ diff --git a/framework/Web/UI/JuiControls/TJuiControlAdapter.php b/framework/Web/UI/JuiControls/TJuiControlAdapter.php index d92809d3..58ca34da 100644 --- a/framework/Web/UI/JuiControls/TJuiControlAdapter.php +++ b/framework/Web/UI/JuiControls/TJuiControlAdapter.php @@ -4,9 +4,8 @@ * * @author Fabio Bas <ctrlaltca@gmail.com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2013-2013 PradoSoft + * @copyright Copyright © 2013-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TJuiControl.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.JuiControls */ @@ -19,7 +18,6 @@ Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter'); * derived from a jQuery-ui widget. * * @author Fabio Bas <ctrlaltca@gmail.com> - * @version $Id: TJuiControlAdapter.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.JuiControls * @since 3.3 */ @@ -84,11 +82,10 @@ class TJuiControlAdapter extends TActiveControlAdapter /** * IJuiOptions interface * - * IJuiOptions is the interface that must be implemented by controls using + * IJuiOptions is the interface that must be implemented by controls using * {@link TJuiControlOptions}. * * @author Fabio Bas <ctrlaltca@gmail.com> - * @version $Id: TJuiControlAdapter.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.JuiControls * @since 3.3 */ @@ -109,7 +106,6 @@ interface IJuiOptions * The options array can then get retrieved using {@link toArray} and applied to the jQuery-ui widget. * * @author Fabio Bas <ctrlaltca@gmail.com> - * @version $Id: TJuiControlAdapter.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.JuiControls * @since 3.3 */ diff --git a/framework/Web/UI/JuiControls/TJuiDraggable.php b/framework/Web/UI/JuiControls/TJuiDraggable.php index eb174eb0..19d334aa 100644 --- a/framework/Web/UI/JuiControls/TJuiDraggable.php +++ b/framework/Web/UI/JuiControls/TJuiDraggable.php @@ -4,9 +4,8 @@ * * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2013-2013 PradoSoft + * @copyright Copyright © 2013-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TJuiDraggable.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.JuiControls */ @@ -27,7 +26,6 @@ Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter'); * </code> * * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> - * @version $Id: TJuiDraggable.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.JuiControls * @since 3.3 */ diff --git a/framework/Web/UI/JuiControls/TJuiDroppable.php b/framework/Web/UI/JuiControls/TJuiDroppable.php index e54d4eac..6c07e49c 100644 --- a/framework/Web/UI/JuiControls/TJuiDroppable.php +++ b/framework/Web/UI/JuiControls/TJuiDroppable.php @@ -4,9 +4,8 @@ * * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2013-2013 PradoSoft + * @copyright Copyright © 2013-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TJuiDroppable.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.JuiControls */ @@ -23,7 +22,7 @@ Prado::using('System.Web.UI.ActiveControls.TActivePanel'); * > * drag me * </com:TJuiDraggable> - * + * * <com:TJuiDroppable * ID="drop1" * Style="border: 1px solid blue; width:600px;height:600px; background-color: lime" @@ -45,7 +44,6 @@ Prado::using('System.Web.UI.ActiveControls.TActivePanel'); * </code> * * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> - * @version $Id: TJuiDroppable.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.JuiControls * @since 3.3 */ @@ -105,19 +103,19 @@ class TJuiDroppable extends TActivePanel implements IJuiOptions, ICallbackEventH $this->onDrop($param->getCallbackParameter()); $this->onCallback($param); } - + /** - * Raises the onDrop event. - * The drop parameters are encapsulated into a {@link TDropContainerEventParameter} - * + * Raises the onDrop event. + * The drop parameters are encapsulated into a {@link TJuiDroppableEventParameter} + * * @param object $dropControlId */ public function onDrop ($dropParams) { $this->raiseEvent('OnDrop', $this, new TJuiDroppableEventParameter ($this->getResponse(), $dropParams)); - + } - + /** * This method is invoked when a callback is requested. The method raises * 'OnCallback' event to fire up the event handlers. If you override this @@ -148,14 +146,12 @@ class TJuiDroppable extends TActivePanel implements IJuiOptions, ICallbackEventH /** * TJuiDroppableEventParameter class - * + * * TJuiDroppableEventParameter encapsulate the parameter * data for <b>OnDrop</b> event of TJuiDroppable components - * - * @author Christophe BOULAIN (Christophe.Boulain@ceram.fr) - * @copyright Copyright © 2008, PradoSoft + * + * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> * @license http://www.pradosoft.com/license - * @version $Id: TDropContainer.php 3285 2013-04-11 07:28:07Z ctrlaltca $ * @package System.Web.UI.JuiControls */ class TJuiDroppableEventParameter extends TCallbackEventParameter diff --git a/framework/Web/UI/JuiControls/TJuiResizable.php b/framework/Web/UI/JuiControls/TJuiResizable.php index 5d70ebf3..f4553aef 100644 --- a/framework/Web/UI/JuiControls/TJuiResizable.php +++ b/framework/Web/UI/JuiControls/TJuiResizable.php @@ -4,9 +4,8 @@ * * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2013-2013 PradoSoft + * @copyright Copyright © 2013-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TJuiResizable.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.JuiControls */ @@ -30,7 +29,6 @@ Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter'); * </code> * * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> - * @version $Id: TJuiResizable.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.JuiControls * @since 3.3 */ diff --git a/framework/Web/UI/JuiControls/TJuiSelectable.php b/framework/Web/UI/JuiControls/TJuiSelectable.php index 0818a1fc..e895c1f8 100644 --- a/framework/Web/UI/JuiControls/TJuiSelectable.php +++ b/framework/Web/UI/JuiControls/TJuiSelectable.php @@ -4,9 +4,8 @@ * * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2013-2013 PradoSoft + * @copyright Copyright © 2013-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TJuiSelectable.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.JuiControls */ @@ -29,11 +28,10 @@ Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter'); * $this->repeater1->dataBind(); * </code> * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> - * @version $Id: TJuiSelectable.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.JuiControls * @since 3.3 */ -class TJuiSelectable extends TActivePanel implements IJuiOptions +class TJuiSelectable extends TActivePanel implements IJuiOptions, ICallbackEventHandler { /** * Creates a new callback control, sets the adapter to @@ -73,6 +71,7 @@ class TJuiSelectable extends TActivePanel implements IJuiOptions protected function getPostBackOptions() { $options = $this->getOptions()->toArray(); + $options['stop'] = new TJavaScriptLiteral('function( event, ui ) { var selected = new Array(); jQuery(\'#'.$this->getClientID().' .ui-selected\').each(function(idx, item){ selected.push(item.id) }); Prado.Callback('.TJavascript::encode($this->getUniqueID()).', { \'indexes\' : selected }) }'); return $options; } @@ -91,6 +90,43 @@ class TJuiSelectable extends TActivePanel implements IJuiOptions } /** + * Raises callback event. This method is required bu {@link ICallbackEventHandler} + * interface. + * It raises the {@link onSelectedIndexChanged onSelectedIndexChanged} event, then, the {@link onCallback OnCallback} event + * This method is mainly used by framework and control developers. + * @param TCallbackEventParameter the parameter associated with the callback event + */ + public function raiseCallbackEvent($param) + { + $this->onSelectedIndexChanged($param->getCallbackParameter()); + $this->onCallback($param); + } + + /** + * Raises the onSelect event. + * The selection parameters are encapsulated into a {@link TJuiSelectableEventParameter} + * + * @param object $params + */ + public function onSelectedIndexChanged($params) + { + $this->raiseEvent('onSelectedIndexChanged', $this, new TJuiSelectableEventParameter ($this->getResponse(), $params)); + + } + + /** + * This method is invoked when a callback is requested. The method raises + * 'OnCallback' event to fire up the event handlers. If you override this + * method, be sure to call the parent implementation so that the event + * handler can be invoked. + * @param TCallbackEventParameter event parameter to be passed to the event handlers + */ + public function onCallback($param) + { + $this->raiseEvent('OnCallback', $this, $param); + } + + /** * @var ITemplate template for repeater items */ private $_repeater=null; @@ -132,7 +168,7 @@ class TJuiSelectable extends TActivePanel implements IJuiOptions $repeater = Prado::createComponent('System.Web.UI.WebControls.TRepeater'); $repeater->setHeaderTemplate(new TJuiSelectableTemplate('<ul id="'.$this->getClientId().'_0'.'">')); $repeater->setFooterTemplate(new TJuiSelectableTemplate('</ul>')); - $repeater->setItemTemplate(new TTemplate('<li><%# $this->DataItem %></li>',null)); + $repeater->setItemTemplate(new TTemplate('<li id="<%# $this->ItemIndex %>"><%# $this->DataItem %></li>',null)); $repeater->setEmptyTemplate(new TJuiSelectableTemplate('<ul></ul>')); $this->getControls()->add($repeater); return $repeater; @@ -147,7 +183,6 @@ class TJuiSelectable extends TActivePanel implements IJuiOptions * item template. * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @version $Id: TJuiAutoComplete.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.ActiveControls * @since 3.1 */ @@ -168,4 +203,19 @@ class TJuiSelectableTemplate extends TComponent implements ITemplate { $parent->getControls()->add($this->_template); } +} + +/** + * TJuiSelectableEventParameter class + * + * TJuiSelectableEventParameter encapsulate the parameter + * data for <b>OnSelectedIndexChanged</b> event of TJuiSelectable components + * + * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> + * @license http://www.pradosoft.com/license + * @package System.Web.UI.JuiControls + */ +class TJuiSelectableEventParameter extends TCallbackEventParameter +{ + public function getSelectedIndexes() { return $this->getCallbackParameter()->indexes; } }
\ No newline at end of file diff --git a/framework/Web/UI/JuiControls/TJuiSortable.php b/framework/Web/UI/JuiControls/TJuiSortable.php index bada066f..557d62ba 100644 --- a/framework/Web/UI/JuiControls/TJuiSortable.php +++ b/framework/Web/UI/JuiControls/TJuiSortable.php @@ -4,9 +4,8 @@ * * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> * @link http://www.pradosoft.com/ - * @copyright Copyright © 2013-2013 PradoSoft + * @copyright Copyright © 2013-2014 PradoSoft * @license http://www.pradosoft.com/license/ - * @version $Id: TJuiSortable.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.JuiControls */ @@ -26,11 +25,10 @@ Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter'); * </code> * * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> - * @version $Id: TJuiSortable.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.JuiControls * @since 3.3 */ -class TJuiSortable extends TActivePanel implements IJuiOptions +class TJuiSortable extends TActivePanel implements IJuiOptions, ICallbackEventHandler { /** * Creates a new callback control, sets the adapter to @@ -70,6 +68,7 @@ class TJuiSortable extends TActivePanel implements IJuiOptions protected function getPostBackOptions() { $options = $this->getOptions()->toArray(); + $options['stop'] = new TJavaScriptLiteral("function( event, ui ) { Prado.Callback(".TJavascript::encode($this->getUniqueID()).", { 'order' : jQuery(this).sortable('toArray') }) }"); return $options; } @@ -88,33 +87,70 @@ class TJuiSortable extends TActivePanel implements IJuiOptions } /** + * Raises callback event. This method is required bu {@link ICallbackEventHandler} + * interface. + * It raises the {@link onSort onSort} event, then, the {@link onCallback OnCallback} event + * This method is mainly used by framework and control developers. + * @param TCallbackEventParameter the parameter associated with the callback event + */ + public function raiseCallbackEvent($param) + { + $this->onSort($param->getCallbackParameter()); + $this->onCallback($param); + } + + /** + * Raises the onSort event. + * The order parameters are encapsulated into a {@link TJuiSortableEventParameter} + * + * @param object $params + */ + public function onSort($params) + { + $this->raiseEvent('onSort', $this, new TJuiSortableEventParameter ($this->getResponse(), $params)); + + } + + /** + * This method is invoked when a callback is requested. The method raises + * 'OnCallback' event to fire up the event handlers. If you override this + * method, be sure to call the parent implementation so that the event + * handler can be invoked. + * @param TCallbackEventParameter event parameter to be passed to the event handlers + */ + public function onCallback($param) + { + $this->raiseEvent('OnCallback', $this, $param); + } + + /** * @var ITemplate template for repeater items */ private $_repeater=null; /** - * @param array data source for Selectables. + * @param array data source for Sortables. */ public function setDataSource($data) { - $this->getSelectables()->setDataSource($data); + $this->getSortables()->setDataSource($data); } /** - * Overrides parent implementation. Callback {@link renderSelectables()} when + * Overrides parent implementation. Callback {@link renderSortables()} when * page's IsCallback property is true. */ public function dataBind() { parent::dataBind(); if($this->getPage()->getIsCallback()) - $this->renderSelectables($this->getResponse()->createHtmlWriter()); + $this->renderSortables($this->getResponse()->createHtmlWriter()); } /** * @return TRepeater suggestion list repeater */ - public function getSelectables() + public function getSortables() { if($this->_repeater===null) $this->_repeater = $this->createRepeater(); @@ -122,14 +158,14 @@ class TJuiSortable extends TActivePanel implements IJuiOptions } /** - * @return TRepeater new instance of TRepater to render the list of Selectables. + * @return TRepeater new instance of TRepater to render the list of Sortables. */ protected function createRepeater() { $repeater = Prado::createComponent('System.Web.UI.WebControls.TRepeater'); $repeater->setHeaderTemplate(new TJuiSortableTemplate('<ul id="'.$this->getClientId().'_0'.'">')); $repeater->setFooterTemplate(new TJuiSortableTemplate('</ul>')); - $repeater->setItemTemplate(new TTemplate('<li><%# $this->DataItem %></li>',null)); + $repeater->setItemTemplate(new TTemplate('<li id="<%# $this->ItemIndex %>"><%# $this->Data %></li>',null)); $repeater->setEmptyTemplate(new TJuiSortableTemplate('<ul></ul>')); $this->getControls()->add($repeater); return $repeater; @@ -144,7 +180,6 @@ class TJuiSortable extends TActivePanel implements IJuiOptions * item template. * * @author Wei Zhuo <weizhuo[at]gmail[dot]com> - * @version $Id: TJuiAutoComplete.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.ActiveControls * @since 3.1 */ @@ -165,4 +200,19 @@ class TJuiSortableTemplate extends TComponent implements ITemplate { $parent->getControls()->add($this->_template); } +} + +/** + * TJuiSortableEventParameter class + * + * TJuiSortableEventParameter encapsulate the parameter + * data for <b>OnSort</b> event of TJuiSortable components + * + * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> + * @license http://www.pradosoft.com/license + * @package System.Web.UI.JuiControls + */ +class TJuiSortableEventParameter extends TCallbackEventParameter +{ + public function getOrder() { return $this->getCallbackParameter()->order; } }
\ No newline at end of file |