diff options
3 files changed, 70 insertions, 38 deletions
| diff --git a/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSelectable/Home.page b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSelectable/Home.page index 4af5d637..cd778625 100644 --- a/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSelectable/Home.page +++ b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSelectable/Home.page @@ -29,7 +29,10 @@  <tr><td class="samplenote">  Default options with a little css applied:  </td><td class="sampleaction"> -	<com:TJuiSelectable ID="repeater1"  onSelectedIndexChanged="repeater1_onSelectedIndexChanged"/> +	<com:TJuiSelectable +		ID="repeater1" +		OnStop="repeater1_onStop" +	/>  	<com:TActiveLabel ID="label1" />  </td></tr> diff --git a/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSelectable/Home.php b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSelectable/Home.php index cf8d40f1..ada38408 100644 --- a/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSelectable/Home.php +++ b/demos/quickstart/protected/pages/JuiControls/Samples/TJuiSelectable/Home.php @@ -21,10 +21,10 @@ class Home extends TPage  		}  	} -	public function repeater1_onSelectedIndexChanged($sender, $param) +	public function repeater1_onStop($sender, $param)  	{  		$this->label1->Text="Selected items:"; -		$items = $param->getSelectedIndexes(); +		$items = $param->getCallbackParameter()->index;  		foreach($items as $index)  			$this->label1->Text.=' '.$this->data[$index]; diff --git a/framework/Web/UI/JuiControls/TJuiSelectable.php b/framework/Web/UI/JuiControls/TJuiSelectable.php index 968f0170..8915c4a2 100644 --- a/framework/Web/UI/JuiControls/TJuiSelectable.php +++ b/framework/Web/UI/JuiControls/TJuiSelectable.php @@ -15,6 +15,11 @@ Prado::using('System.Web.UI.ActiveControls.TActivePanel');  /**   * TJuiSelectable class.   * + * TJuiSelectable is an extension to {@link TActivePanel} based on jQuery-UI's + * {@link http://jqueryui.com/selectable/ Selectable} interaction. + * The panel can be feed a {@link setDataSource DataSource} and will interally + * render a {@link TRepeater} that displays items in an unordered list. + * Items can be selected by clicking on them, individually or in a group.   *   * <code>   * <style> @@ -82,7 +87,11 @@ class TJuiSelectable extends TActivePanel implements IJuiOptions, ICallbackEvent  	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 }) }'); +		// overload the "OnStop" event to add information about the current selected items +		if(isset($options['stop'])) +		{ +			$options['stop']=new TJavaScriptLiteral('function( event, ui ) { ui.index = new Array(); jQuery(\'#'.$this->getClientID().' .ui-selected\').each(function(idx, item){ ui.index.push(item.id) }); Prado.JuiCallback('.TJavascript::encode($this->getUniqueID()).', \'stop\', event, ui, this); }'); +		}  		return $options;  	} @@ -101,40 +110,76 @@ class TJuiSelectable extends TActivePanel implements IJuiOptions, ICallbackEvent  	}  	/** -	 * Raises callback event. This method is required bu {@link ICallbackEventHandler} +	 * Raises callback event. This method is required by the {@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); +		$this->getOptions()->raiseCallbackEvent($param);  	}  	/** -	 * Raises the onSelect event. -	 * The selection parameters are encapsulated into a {@link TJuiSelectableEventParameter} -	 * -	 * @param object $params +	 * Raises the OnCreate event +	 * @param object $params event parameters  	 */ -	public function onSelectedIndexChanged($params) +	public function onCreate ($params)  	{ -		$this->raiseEvent('onSelectedIndexChanged', $this, new TJuiSelectableEventParameter ($this->getResponse(), $params)); +		$this->raiseEvent('OnCreate', $this, $params); +	} +	/** +	 * Raises the OnSelected event +	 * @param object $params event parameters +	 */ +	public function onSelected ($params) +	{ +		$this->raiseEvent('OnSelected', $this, $params); +	} + +	/** +	 * Raises the OnSelecting event +	 * @param object $params event parameters +	 */ +	public function onSelecting ($params) +	{ +		$this->raiseEvent('OnSelecting', $this, $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 +	 * Raises the OnStart event +	 * @param object $params event parameters  	 */ -	public function onCallback($param) +	public function onStart ($params)  	{ -		$this->raiseEvent('OnCallback', $this, $param); +		$this->raiseEvent('OnStart', $this, $params); +	} + +	/** +	 * Raises the OnStop event +	 * @param object $params event parameters +	 */ +	public function onStop ($params) +	{ +		$this->raiseEvent('OnStop', $this, $params); +	} + +	/** +	 * Raises the OnUnselected event +	 * @param object $params event parameters +	 */ +	public function onUnselected ($params) +	{ +		$this->raiseEvent('OnUnselected', $this, $params); +	} + +	/** +	 * Raises the OnUnselecting event +	 * @param object $params event parameters +	 */ +	public function onUnselecting ($params) +	{ +		$this->raiseEvent('OnUnselecting', $this, $params);  	}  	/** @@ -186,7 +231,6 @@ class TJuiSelectable extends TActivePanel implements IJuiOptions, ICallbackEvent  	}  } -  /**   * TJuiSelectableTemplate class.   * @@ -215,18 +259,3 @@ 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 | 
