summaryrefslogtreecommitdiff
path: root/lib/prado/framework/Web/UI/JuiControls
diff options
context:
space:
mode:
Diffstat (limited to 'lib/prado/framework/Web/UI/JuiControls')
-rw-r--r--lib/prado/framework/Web/UI/JuiControls/TJuiAutoComplete.php495
-rw-r--r--lib/prado/framework/Web/UI/JuiControls/TJuiControlAdapter.php203
-rw-r--r--lib/prado/framework/Web/UI/JuiControls/TJuiControlOptions.php181
-rw-r--r--lib/prado/framework/Web/UI/JuiControls/TJuiDatePicker.php287
-rw-r--r--lib/prado/framework/Web/UI/JuiControls/TJuiDialog.php283
-rw-r--r--lib/prado/framework/Web/UI/JuiControls/TJuiDraggable.php169
-rw-r--r--lib/prado/framework/Web/UI/JuiControls/TJuiDroppable.php220
-rw-r--r--lib/prado/framework/Web/UI/JuiControls/TJuiProgressbar.php156
-rw-r--r--lib/prado/framework/Web/UI/JuiControls/TJuiResizable.php172
-rw-r--r--lib/prado/framework/Web/UI/JuiControls/TJuiSelectable.php280
-rw-r--r--lib/prado/framework/Web/UI/JuiControls/TJuiSortable.php333
11 files changed, 2779 insertions, 0 deletions
diff --git a/lib/prado/framework/Web/UI/JuiControls/TJuiAutoComplete.php b/lib/prado/framework/Web/UI/JuiControls/TJuiAutoComplete.php
new file mode 100644
index 0000000..be6b1b4
--- /dev/null
+++ b/lib/prado/framework/Web/UI/JuiControls/TJuiAutoComplete.php
@@ -0,0 +1,495 @@
+<?php
+/**
+ * TJuiAutoComplete class file.
+ *
+ * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
+ * @link https://github.com/pradosoft/prado
+ * @copyright Copyright &copy; 2005-2015 The PRADO Group
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * Load active text box.
+ */
+Prado::using('System.Web.UI.ActiveControls.TActiveTextBox');
+Prado::using('System.Web.UI.ActiveControls.TCallbackEventParameter');
+Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter');
+/**
+ * TJuiAutoComplete class.
+ *
+ * TJuiAutoComplete is a textbox that provides a list of suggestion on
+ * the current partial word typed in the textbox. The suggestions are
+ * requested using callbacks, and raises the {@link onSuggestion OnSuggestion}
+ * event. The events of the TActiveText (from which TJuiAutoComplete is extended from)
+ * and {@link onSuggestion OnSuggestion} are mutually exculsive. That is,
+ * if {@link onTextChange OnTextChange} and/or {@link onCallback OnCallback}
+ * events are raise, then {@link onSuggestion OnSuggestion} will not be raise, and
+ * vice versa.
+ *
+ * The list of suggestions should be set in the {@link onSuggestion OnSuggestion}
+ * event handler. The partial word to match the suggestion is in the
+ * {@link TCallbackEventParameter::getCallbackParameter TCallbackEventParameter::CallbackParameter}
+ * property. The datasource of the TJuiAutoComplete must be set using {@link setDataSource}
+ * method. This sets the datasource for the suggestions repeater, available through
+ * the {@link getSuggestions Suggestions} property. Header, footer templates and
+ * other properties of the repeater can be access via the {@link getSuggestions Suggestions}
+ * property and its sub-properties.
+ *
+ * The {@link setTextCssClass TextCssClass} property if set is used to find
+ * the element within the Suggestions.ItemTemplate and Suggestions.AlternatingItemTemplate
+ * that contains the actual text for the suggestion selected. That is,
+ * only text inside elements with CSS class name equal to {@link setTextCssClass TextCssClass}
+ * will be used as suggestions.
+ *
+ * To return the list of suggestions back to the browser, supply a non-empty data source
+ * and call databind. For example,
+ * <code>
+ * function autocomplete_suggestion($sender, $param)
+ * {
+ * $token = $param->getToken(); //the partial word to match
+ * $sender->setDataSource($this->getSuggestionsFor($token)); //set suggestions
+ * $sender->dataBind();
+ * }
+ * </code>
+ *
+ * The suggestion will be rendered when the {@link dataBind()} method is called
+ * <strong>during a callback request</strong>.
+ *
+ * When an suggestion is selected, that is, when the use has clicked, pressed
+ * the "Enter" key, or pressed the "Tab" key, the {@link onSuggestionSelected OnSuggestionSelected}
+ * event is raised. The
+ * {@link TCallbackEventParameter::getCallbackParameter TCallbackEventParameter::CallbackParameter}
+ * property contains the index of the selected suggestion.
+ *
+ * TJuiAutoComplete allows multiple suggestions within one textbox with each
+ * word or phrase separated by any characters specified in the
+ * {@link setSeparator Separator} property. The {@link setFrequency Frequency}
+ * and {@link setMinChars MinChars} properties sets the delay and minimum number
+ * of characters typed, respectively, before requesting for sugggestions.
+ *
+ * Use {@link onTextChange OnTextChange} and/or {@link onCallback OnCallback} events
+ * to handle post backs due to {@link setAutoPostBack AutoPostBack}.
+ *
+ * In the {@link getSuggestions Suggestions} TRepater item template, all HTML text elements
+ * are considered as text for the suggestion. Text within HTML elements with CSS class name
+ * "informal" are ignored as text for suggestions.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TJuiAutoComplete extends TActiveTextBox implements INamingContainer, IJuiOptions
+{
+ /**
+ * @var ITemplate template for repeater items
+ */
+ private $_repeater=null;
+ /**
+ * @var TPanel result panel holding the suggestion items.
+ */
+ private $_resultPanel=null;
+
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TJuiControlAdapter($this));
+ }
+
+ /**
+ * @return string the name of the jQueryUI widget method
+ */
+ public function getWidget()
+ {
+ return 'autocomplete';
+ }
+
+ /**
+ * @return string the clientid of the jQueryUI widget element
+ */
+ public function getWidgetID()
+ {
+ return $this->getClientID();
+ }
+
+ /**
+ * Object containing defined javascript options
+ * @return TJuiControlOptions
+ */
+ public function getOptions()
+ {
+ if (($options=$this->getViewState('JuiOptions'))===null)
+ {
+ $options=new TJuiControlOptions($this);
+ $this->setViewState('JuiOptions', $options);
+ }
+ return $options;
+ }
+
+ /**
+ * Array containing valid javascript options
+ * @return array()
+ */
+ public function getValidOptions()
+ {
+ return array('appendTo', 'autoFocus', 'delay', 'disabled', 'minLength', 'position', 'source');
+ }
+
+ /**
+ * Array containing valid javascript events
+ * @return array()
+ */
+ public function getValidEvents()
+ {
+ return array();
+ }
+
+ /**
+ * @param string Css class name of the element to use for suggestion.
+ */
+ public function setTextCssClass($value)
+ {
+ $this->setViewState('TextCssClass', $value);
+ }
+
+ /**
+ * @return string Css class name of the element to use for suggestion.
+ */
+ public function getTextCssClass()
+ {
+ return $this->getViewState('TextCssClass');
+ }
+
+
+ /**
+ * @return string word or token separators (delimiters).
+ */
+ public function getSeparator()
+ {
+ return $this->getViewState('separator', '');
+ }
+
+ /**
+ * @param string word or token separators (delimiters).
+ */
+ public function setSeparator($value)
+ {
+ $this->setViewState('separator', TPropertyValue::ensureString($value), '');
+ }
+
+ /**
+ * @return float maximum delay (in seconds) before requesting a suggestion.
+ */
+ public function getFrequency()
+ {
+ return $this->getViewState('frequency', 0.4);
+ }
+
+ /**
+ * @param float maximum delay (in seconds) before requesting a suggestion.
+ * Default is 0.4.
+ */
+ public function setFrequency($value)
+ {
+ $this->setViewState('frequency', TPropertyValue::ensureFloat($value), 0.4);
+ }
+
+ /**
+ * @return integer minimum number of characters before requesting a suggestion.
+ */
+ public function getMinChars()
+ {
+ return $this->getViewState('minChars','');
+ }
+
+ /**
+ * @param integer minimum number of characters before requesting a suggestion.
+ * Default is 1
+ */
+ public function setMinChars($value)
+ {
+ $this->setViewState('minChars', TPropertyValue::ensureInteger($value), 1);
+ }
+
+ /**
+ * Raises the callback event. This method is overrides the parent implementation.
+ * If {@link setAutoPostBack AutoPostBack} is enabled it will raise
+ * {@link onTextChanged OnTextChanged} event event and then the
+ * {@link onCallback OnCallback} event. The {@link onSuggest OnSuggest} event is
+ * raise if the request is to find sugggestions, the {@link onTextChanged OnTextChanged}
+ * and {@link onCallback OnCallback} events are <b>NOT</b> raised.
+ * This method is mainly used by framework and control developers.
+ * @param TCallbackEventParameter the event parameter
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $token = $param->getCallbackParameter();
+ if(is_array($token) && count($token) == 2)
+ {
+ if($token[1] === '__TJuiAutoComplete_onSuggest__')
+ {
+ $parameter = new TJuiAutoCompleteEventParameter($this->getResponse(), $token[0]);
+ $this->onSuggest($parameter);
+ }
+ else if($token[1] === '__TJuiAutoComplete_onSuggestionSelected__')
+ {
+ $parameter = new TJuiAutoCompleteEventParameter($this->getResponse(), null, $token[0]);
+ $this->onSuggestionSelected($parameter);
+ }
+ }
+ else if($this->getAutoPostBack())
+ parent::raiseCallbackEvent($param);
+ }
+
+ /**
+ * This method is invoked when an autocomplete suggestion is requested.
+ * The method raises 'OnSuggest' event. 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 onSuggest($param)
+ {
+ $this->raiseEvent('OnSuggest', $this, $param);
+ }
+
+ /**
+ * This method is invoked when an autocomplete suggestion is selected.
+ * The method raises 'OnSuggestionSelected' event. 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 onSuggestionSelected($param)
+ {
+ $this->raiseEvent('OnSuggestionSelected', $this, $param);
+ }
+
+ /**
+ * @param array data source for suggestions.
+ */
+ public function setDataSource($data)
+ {
+ $this->getSuggestions()->setDataSource($data);
+ }
+
+ /**
+ * Overrides parent implementation. Callback {@link renderSuggestions()} when
+ * page's IsCallback property is true.
+ */
+ public function dataBind()
+ {
+ parent::dataBind();
+ if($this->getPage()->getIsCallback())
+ $this->renderSuggestions($this->getResponse()->createHtmlWriter());
+ }
+
+ /**
+ * @return TPanel suggestion results panel.
+ */
+ public function getResultPanel()
+ {
+ if($this->_resultPanel===null)
+ $this->_resultPanel = $this->createResultPanel();
+ return $this->_resultPanel;
+ }
+
+ /**
+ * @return TPanel new instance of result panel. Default uses TPanel.
+ */
+ protected function createResultPanel()
+ {
+ $panel = Prado::createComponent('System.Web.UI.WebControls.TPanel');
+ $this->getControls()->add($panel);
+ $panel->setID('result');
+ return $panel;
+ }
+
+ /**
+ * @return TRepeater suggestion list repeater
+ */
+ public function getSuggestions()
+ {
+ if($this->_repeater===null)
+ $this->_repeater = $this->createRepeater();
+ return $this->_repeater;
+ }
+
+ /**
+ * @return TRepeater new instance of TRepater to render the list of suggestions.
+ */
+ protected function createRepeater()
+ {
+ $repeater = Prado::createComponent('System.Web.UI.WebControls.TRepeater');
+ $repeater->setItemTemplate(new TTemplate('<%# $this->Data %>',null));
+ $this->getControls()->add($repeater);
+ return $repeater;
+ }
+
+ /**
+ * Renders the end tag and registers javascript effects library.
+ */
+ public function renderEndTag($writer)
+ {
+ parent::renderEndTag($writer);
+ $this->renderResultPanel($writer);
+ }
+
+ /**
+ * Renders the result panel.
+ * @param THtmlWriter the renderer.
+ */
+ protected function renderResultPanel($writer)
+ {
+ $this->getResultPanel()->render($writer);
+ }
+
+ /**
+ * Renders the suggestions during a callback respones.
+ * @param THtmlWriter the renderer.
+ */
+ public function renderCallback($writer)
+ {
+ $this->renderSuggestions($writer);
+ }
+
+ /**
+ * Renders the suggestions repeater.
+ * @param THtmlWriter the renderer.
+ */
+ public function renderSuggestions($writer)
+ {
+ if($this->getActiveControl()->canUpdateClientSide())
+ {
+ $data=array();
+ $items=$this->getSuggestions()->getItems();
+ $writer = new TTextWriter;
+ for($i=0; $i<$items->Count; $i++)
+ {
+ $items->itemAt($i)->render($writer);
+ $item=$writer->flush();
+ $data[]=array( 'id' => $i, 'label' => $item);
+ }
+
+ $this->getResponse()->getAdapter()->setResponseData($data);
+ }
+ }
+
+ /**
+ * @return array list of callback options.
+ */
+ protected function getPostBackOptions()
+ {
+ $options = $this->getOptions()->toArray();
+
+ if(strlen($separator = $this->getSeparator()))
+ $options['Separators'] = $separator;
+
+ if($this->getAutoPostBack())
+ {
+ $options = array_merge($options,parent::getPostBackOptions());
+ $options['AutoPostBack'] = true;
+ }
+ if(strlen($textCssClass = $this->getTextCssClass()))
+ $options['textCssClass'] = $textCssClass;
+ $options['minLength'] = $this->getMinChars();
+ $options['delay'] = $this->getFrequency()*1000.0;
+ $options['appendTo'] = '#'.$this->getResultPanel()->getClientID();
+ $options['ID'] = $this->getClientID();
+ $options['EventTarget'] = $this->getUniqueID();
+ $options['CausesValidation'] = $this->getCausesValidation();
+ $options['ValidationGroup'] = $this->getValidationGroup();
+ return $options;
+ }
+
+ /**
+ * Override parent implementation, no javascript is rendered here instead
+ * the javascript required for active control is registered in {@link addAttributesToRender}.
+ */
+ protected function renderClientControlScript($writer)
+ {
+ }
+
+ /**
+ * @return string corresponding javascript class name for this TActiveButton.
+ */
+ protected function getClientClassName()
+ {
+ return 'Prado.WebUI.TJuiAutoComplete';
+ }
+}
+
+/**
+ * TAutCompleteEventParameter contains the {@link getToken Token} requested by
+ * the user for a partial match of the suggestions.
+ *
+ * The {@link getSelectedIndex SelectedIndex} is a zero-based index of the
+ * suggestion selected by the user, -1 if not suggestion is selected.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TJuiAutoCompleteEventParameter extends TCallbackEventParameter
+{
+ private $_selectedIndex=-1;
+
+ /**
+ * Creates a new TCallbackEventParameter.
+ */
+ public function __construct($response, $parameter, $index=-1)
+ {
+ parent::__construct($response, $parameter);
+ $this->_selectedIndex=$index;
+ }
+
+ /**
+ * @return int selected suggestion zero-based index, -1 if not selected.
+ */
+ public function getSelectedIndex()
+ {
+ return $this->_selectedIndex;
+ }
+
+ /**
+ * @return string token for matching a list of suggestions.
+ */
+ public function getToken()
+ {
+ return $this->getCallbackParameter();
+ }
+}
+
+/**
+ * TJuiAutoCompleteTemplate class.
+ *
+ * TJuiAutoCompleteTemplate is the default template for TJuiAutoCompleteTemplate
+ * item template.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TJuiAutoCompleteTemplate extends TComponent implements ITemplate
+{
+ private $_template;
+
+ public function __construct($template)
+ {
+ $this->_template = $template;
+ }
+ /**
+ * Instantiates the template.
+ * It creates a {@link TDataList} control.
+ * @param TControl parent to hold the content within the template
+ */
+ public function instantiateIn($parent)
+ {
+ $parent->getControls()->add($this->_template);
+ }
+}
diff --git a/lib/prado/framework/Web/UI/JuiControls/TJuiControlAdapter.php b/lib/prado/framework/Web/UI/JuiControls/TJuiControlAdapter.php
new file mode 100644
index 0000000..7feac4f
--- /dev/null
+++ b/lib/prado/framework/Web/UI/JuiControls/TJuiControlAdapter.php
@@ -0,0 +1,203 @@
+<?php
+/**
+ * TJuiControlAdapter class file.
+ *
+ * @author Fabio Bas <ctrlaltca@gmail.com>
+ * @link https://github.com/pradosoft/prado
+ * @copyright Copyright &copy; 2013-2015 PradoSoft
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @package System.Web.UI.JuiControls
+ */
+
+Prado::using('System.Web.UI.ActiveControls.TActiveControlAdapter');
+Prado::using('System.Web.UI.JuiControls.TJuiControlOptions');
+
+/**
+ * TJuiControlAdapter class
+ *
+ * TJuiControlAdapter is the base adapter class for controls that are
+ * derived from a jQuery-ui widget. It exposes convenience methods to
+ * publish jQuery-UI javascript and css assets.
+ *
+ * @author Fabio Bas <ctrlaltca@gmail.com>
+ * @package System.Web.UI.JuiControls
+ * @since 3.3
+ */
+class TJuiControlAdapter extends TActiveControlAdapter
+{
+ const SCRIPT_PATH = 'jquery';
+ const CSS_PATH = 'css';
+ const BASE_CSS_FILENAME ='jquery-ui.css';
+
+ /**
+ * Replace default StateTracker with {@link TJuiCallbackPageStateTracker} for
+ * options tracking in ViewState.
+ * @param TEventParameter event parameter to be passed to the event handlers
+ */
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ $this->setStateTracker('TJuiCallbackPageStateTracker');
+ }
+
+ /**
+ * @param string set the jquery-ui style
+ */
+ public function setJuiBaseStyle($value)
+ {
+ $this->getControl()->setViewState('JuiBaseStyle', $value, 'base');
+ }
+
+ /**
+ * @return string current jquery-ui style
+ */
+ public function getJuiBaseStyle()
+ {
+ return $this->getControl()->getViewState('JuiBaseStyle', 'base');
+ }
+
+ /**
+ * Inject jquery script and styles before render
+ */
+ public function onPreRender($param)
+ {
+ parent::onPreRender($param);
+ $this->getPage()->getClientScript()->registerPradoScript('jqueryui');
+ $this->publishJuiStyle(self::BASE_CSS_FILENAME);
+ }
+
+ /**
+ * @param string jQuery asset file in the self::SCRIPT_PATH directory.
+ * @return string jQuery asset url.
+ */
+ protected function getAssetUrl($file='')
+ {
+ $base = $this->getPage()->getClientScript()->getPradoScriptAssetUrl();
+ return $base.'/'.self::SCRIPT_PATH.'/'.$file;
+ }
+
+ /**
+ * Publish the jQuery-ui style Css asset file.
+ * @param file name
+ * @return string Css file url.
+ */
+ public function publishJuiStyle($file)
+ {
+ $url = $this->getAssetUrl(self::CSS_PATH.'/'.$this->getJuiBaseStyle().'/'.$file);
+ $cs = $this->getPage()->getClientScript();
+ if(!$cs->isStyleSheetFileRegistered($url))
+ $cs->registerStyleSheetFile($url, $url);
+ return $url;
+ }
+
+ /**
+ * Calls the parent implementation first and sets the parent control for the
+ * {@link TJuiControlOptions} again afterwards since it was not serialized in viewstate.
+ */
+ public function loadState() {
+ parent::loadState();
+ $this->getControl()->getOptions()->setControl($this->getControl());
+ }
+
+}
+
+/**
+ * TJuiEventParameter class
+ *
+ * TJuiEventParameter encapsulate the parameters for callback
+ * events of TJui* components.
+ * Any parameter representing a control is identified by its
+ * clientside ID.
+ * TJuiEventParameter contains a {@link getControl} helper method
+ * that retrieves an existing PRADO control on che current page from its
+ * clientside ID as returned by the callback.
+ * For example, if the parameter contains a "draggable" item (as returned in
+ * {@link TJuiDroppable}::OnDrop event), the relative PRADO control can be
+ * retrieved using:
+ * <code>
+ * $draggable = $param->getControl($param->getCallbackParameter()->draggable);
+ * </code>
+ *
+ * A shortcut __get() method is implemented, too:
+ * <code>
+ * $draggable = $param->DraggableControl;
+ * </code>
+ *
+ * @author Fabio Bas <ctrlaltca[at]gmail[dot]com>
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @package System.Web.UI.JuiControls
+ */
+class TJuiEventParameter extends TCallbackEventParameter
+{
+ /**
+ * getControl
+ *
+ * Compatibility method to get a control from its clientside id
+ * @return TControl control, or null if not found
+ */
+ public function getControl($id)
+ {
+ $control=null;
+ $service=prado::getApplication()->getService();
+ if ($service instanceof TPageService)
+ {
+ // Find the control
+ // Warning, this will not work if you have a '_' in your control Id !
+ $controlId=str_replace(TControl::CLIENT_ID_SEPARATOR,TControl::ID_SEPARATOR,$id);
+ $control=$service->getRequestedPage()->findControl($controlId);
+ }
+ return $control;
+ }
+
+ /**
+ * Gets a control instance named after a returned control id.
+ * Example: if a $param->draggable control id is returned from clientside,
+ * calling $param->DraggableControl will return the control instance
+ * @return mixed control or null if not set.
+ */
+ public function __get($name)
+ {
+ $pos=strpos($name, 'Control',1);
+ $name=strtolower(substr($name, 0, $pos));
+
+ $cp=$this->getCallbackParameter();
+ if(!isset($cp->$name) || $cp->$name=='')
+ return null;
+
+ return $this->getControl($cp->$name);
+ }
+}
+
+/**
+ * TJuiCallbackPageStateTracker class.
+ *
+ * Tracking changes to the page state during callback, including {@link TJuiControlOptions}.
+ *
+ * @author LANDWEHR Computer und Software GmbH
+ * @package System.Web.UI.JuiControls
+ * @since 3.3
+ */
+class TJuiCallbackPageStateTracker extends TCallbackPageStateTracker {
+
+ /**
+ * Add the {@link TJuiControlOptions} to the states to track.
+ */
+ protected function addStatesToTrack()
+ {
+ parent::addStatesToTrack();
+ $states = $this->getStatesToTrack();
+ $states['JuiOptions'] = array('TMapCollectionDiff', array($this, 'updateJuiOptions'));
+ }
+
+ /**
+ * Updates the options of the jQueryUI widget.
+ * @param array list of widget options to change.
+ */
+ protected function updateJuiOptions($options)
+ {
+ foreach ($options as $key => $value) $options[$key] = $key . ': ' . (is_string($value) ? "'{$value}'" : TPropertyValue::ensureString($value));
+ $code = "jQuery('#{$this->_control->getWidgetID()}').{$this->_control->getWidget()}('option', { " . implode(', ', $options) . " });";
+ $this->_control->getPage()->getClientScript()->registerEndScript(sprintf('%08X', crc32($code)), $code);
+ }
+
+} \ No newline at end of file
diff --git a/lib/prado/framework/Web/UI/JuiControls/TJuiControlOptions.php b/lib/prado/framework/Web/UI/JuiControls/TJuiControlOptions.php
new file mode 100644
index 0000000..64cf710
--- /dev/null
+++ b/lib/prado/framework/Web/UI/JuiControls/TJuiControlOptions.php
@@ -0,0 +1,181 @@
+<?php
+/**
+ * TJuiControlOptions class file.
+ *
+ * @author Fabio Bas <ctrlaltca@gmail.com>
+ * @link https://github.com/pradosoft/prado
+ * @copyright Copyright &copy; 2013-2015 PradoSoft
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @package System.Web.UI.JuiControls
+ */
+
+/**
+ * IJuiOptions interface
+ *
+ * IJuiOptions is the interface that must be implemented by controls using
+ * {@link TJuiControlOptions}.
+ *
+ * @author Fabio Bas <ctrlaltca@gmail.com>
+ * @package System.Web.UI.JuiControls
+ * @since 3.3
+ */
+interface IJuiOptions
+{
+ public function getWidget();
+ public function getWidgetID();
+ public function getOptions();
+ public function getValidOptions();
+ public function getValidEvents();
+}
+
+/**
+ * TJuiControlOptions interface
+ *
+ * TJuiControlOptions is an helper class that can collect a list of options
+ * for a control. The control must implement {@link IJuiOptions}.
+ * The options are validated againg an array of valid options provided by the control itself.
+ * Since component properties are case insensitive, the array of valid options is used
+ * to ensure the option name has the correct case.
+ * The options array can then get retrieved using {@link toArray} and applied to the jQuery-ui widget.
+ * In addition to the options, this class will render the needed javascript to raise a callback
+ * for any event for which an handler is defined in the control.
+ *
+ * @author Fabio Bas <ctrlaltca@gmail.com>
+ * @package System.Web.UI.JuiControls
+ * @since 3.3
+ */
+class TJuiControlOptions
+{
+ /**
+ * @var TMap map of javascript options.
+ */
+ private $_options;
+ /**
+ * @var TControl parent control.
+ */
+ private $_control;
+
+ /**
+ * Constructor. Set the parent control owning these options.
+ * @param TControl parent control
+ */
+ public function __construct($control)
+ {
+ $this->setControl($control);
+ }
+
+ /**
+ * Sets the parent control.
+ * @param TControl $control
+ * @throws THttpException
+ */
+ public function setControl($control)
+ {
+ if(!$control instanceof IJuiOptions)
+ throw new THttpException(500,'juioptions_control_invalid',$control->ID);
+ $this->_control=$control;
+ }
+
+ /**
+ * Sets a named options with a value. Options are used to store and retrive
+ * named values for the javascript control.
+ * @param string option name.
+ * @param mixed option value.
+ * @throws THttpException
+ */
+ public function __set($name,$value)
+ {
+ if($this->_options===null)
+ $this->_options=array();
+
+ foreach($this->_control->getValidOptions() as $option)
+ {
+ if(0 == strcasecmp($name, $option))
+ {
+ $low = strtolower($value);
+ if($low === 'null')
+ {
+ $this->_options[$option] = null;
+ } elseif($low === 'true') {
+ $this->_options[$option] = true;
+ } elseif($low === 'false') {
+ $this->_options[$option] = false;
+ } elseif(is_numeric($value)) {
+ // trick to get float or integer automatically when needed
+ $this->_options[$option] = $value + 0;
+ } elseif(substr($low,0,8)=='function') {
+ $this->_options[$option] = new TJavaScriptLiteral($value);
+ } else {
+ $this->_options[$option] = $value;
+ }
+ return;
+ }
+ }
+
+ throw new THttpException(500,'juioptions_option_invalid',$this->_control->ID, $name);
+ }
+
+ /**
+ * Gets an option named value. Options are used to store and retrive
+ * named values for the base active controls.
+ * @param string option name.
+ * @return mixed options value or null if not set.
+ */
+ public function __get($name)
+ {
+ if($this->_options===null)
+ $this->_options=array();
+
+ foreach($this->_control->getValidOptions() as $option)
+ {
+ if(0 == strcasecmp($name, $option) && isset($this->_options[$option]))
+ {
+ return $this->_options[$option];
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Only serialize the options itself, not the corresponding parent control.
+ * @return mixed array with the names of all variables of that object that should be serialized.
+ */
+ public function __sleep() {
+ return array('_options');
+ }
+
+ /**
+ * @return Array of active control options
+ */
+ public function toArray()
+ {
+ $ret= ($this->_options===null) ? array() : $this->_options;
+
+ foreach($this->_control->getValidEvents() as $event)
+ if($this->_control->hasEventHandler('on'.$event))
+ $ret[$event]=new TJavaScriptLiteral("function( event, ui ) { Prado.JuiCallback(".TJavascript::encode($this->_control->getUniqueID()).", ".TJavascript::encode($event).", event, ui, this); }");
+
+ return $ret;
+ }
+
+ /**
+ * Raise the specific callback event handler of the target control.
+ * @param mixed callback parameters
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $callbackParam=$param->CallbackParameter;
+ if(isset($callbackParam->event))
+ {
+ $eventName = 'On'.ucfirst($callbackParam->event);
+ if($this->_control->hasEventHandler($eventName))
+ {
+ $this->_control->$eventName( new TJuiEventParameter(
+ $this->_control->getResponse(),
+ isset($callbackParam->ui) ? $callbackParam->ui : null)
+ );
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/lib/prado/framework/Web/UI/JuiControls/TJuiDatePicker.php b/lib/prado/framework/Web/UI/JuiControls/TJuiDatePicker.php
new file mode 100644
index 0000000..487714d
--- /dev/null
+++ b/lib/prado/framework/Web/UI/JuiControls/TJuiDatePicker.php
@@ -0,0 +1,287 @@
+<?php
+/**
+ * TJuiDatePicker class file.
+ *
+ * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de>
+ * @link http://www.landwehr-software.de/
+ * @copyright Copyright &copy; 2015 LANDWEHR Computer und Software GmbH
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @package System.Web.UI.ActiveControls
+ */
+
+/**
+ * Load active text box.
+ */
+Prado::using('System.Web.UI.ActiveControls.TActiveTextBox');
+Prado::using('System.Web.UI.ActiveControls.TCallbackEventParameter');
+Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter');
+/**
+ * TJuiDatePicker class.
+ *
+ * TJuiDatePicker is a textbox that provides a date input. When the text box receives focus,
+ * a calendar will pop up and users can pick up from it a date that will be automatically
+ * entered into the text box. TJuiDatePicker is an extension to {@link TActivePanel} based on
+ * jQuery-UI's {@link http://jqueryui.com/dialog/ Dialog} widget.
+ *
+ * <code>
+ * <com:TJuiDatePicker ID="datepicker1" />
+ * </code>
+ *
+ * @author LANDWEHR Computer und Software GmbH <programmierung@landwehr-software.de>
+ * @package System.Web.UI.JuiControls
+ * @since 3.3
+ */
+class TJuiDatePicker extends TActiveTextBox implements INamingContainer, IJuiOptions
+{
+
+ /**
+ * The static variable is used to determine if this is the first instance of TJuiDatePicker. If true,
+ * it will register an additional clientscript to set the language specific global default settings.
+ * @var boolean true, if this is the first instance of TJuiDatePicker, false otherwise
+ */
+ private static $_first = true;
+
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TJuiControlAdapter($this));
+ }
+
+ /**
+ * @return string the name of the jQueryUI widget method
+ */
+ public function getWidget()
+ {
+ return 'datepicker';
+ }
+
+ /**
+ * @return string the clientid of the jQueryUI widget element
+ */
+ public function getWidgetID()
+ {
+ return $this->getClientID();
+ }
+
+ /**
+ * Object containing defined javascript options
+ * @return TJuiControlOptions
+ */
+ public function getOptions()
+ {
+ if (($options=$this->getViewState('JuiOptions'))===null)
+ {
+ $options=new TJuiControlOptions($this);
+ $this->setViewState('JuiOptions', $options);
+ }
+ return $options;
+ }
+
+ /**
+ * Array containing valid javascript options
+ * @return array()
+ */
+ public function getValidOptions()
+ {
+ return array('altField', 'altFormat', 'appendText', 'autoSize', 'buttonImage', 'buttonImageOnly', 'buttonText', 'calculateWeek',
+ 'changeMonth', 'changeYear', 'closeText', 'constrainInput', 'currentText', 'dateFormat', 'dayNames', 'dayNamesMin',
+ 'dayNamesShort', 'defaultDate', 'duration', 'firstDay', 'gotoCurrent', 'hideIfNoPrevNext', 'isRTL', 'maxDate',
+ 'minDate', 'monthNames', 'monthNamesShort', 'navigationAsDateFormat', 'nextText', 'numberOfMonths', 'prevText',
+ 'selectOtherMonths', 'shortYearCutoff', 'showAnim', 'showButtonPanel', 'showCurrentAtPos', 'showMonthAfterYear',
+ 'showOn', 'showOptions', 'showOtherMonths', 'showWeek', 'stepMonths', 'weekHeader', 'yearRange', 'yearSuffix',
+ 'beforeShow', 'beforeShowDay', 'onChangeMonthYear', 'onClose', 'onSelect');
+ }
+
+ /**
+ * Array containing valid javascript events
+ * @return array()
+ */
+ public function getValidEvents()
+ {
+ return array();
+ }
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control. Also registers language specific global
+ * settings for the first used date picker.
+ */
+ protected function addAttributesToRender($writer)
+ {
+ $cs=$this->getPage()->getClientScript();
+ if(self::$_first)
+ {
+ $code="jQuery(document).ready(function(){jQuery.datepicker.setDefaults(jQuery.datepicker.regional['{$this->getCurrentCulture()}']);});";
+ $cs->registerEndScript(sprintf('%08X', crc32($code)), $code);
+ self::$_first=false;
+ }
+ parent::addAttributesToRender($writer);
+ $options=TJavascript::encode($this->getOptions()->toArray());
+ $code="jQuery('#".$this->getWidgetID()."').".$this->getWidget()."(".$options.");";
+ $cs->registerEndScript(sprintf('%08X', crc32($code)), $code);
+ }
+
+ /**
+ * @return TTextBoxMode the behavior mode of the underlying {@link TTextBox} component.
+ * Fixed to TTextBoxMode::SingleLine for the TJuiDatePicker.
+ */
+ public function getTextMode()
+ {
+ return TTextBoxMode::SingleLine;
+ }
+
+ /**
+ * Setting the behavior mode of the underlying TTextBox component is NOT supported.
+ * @param TTextBoxMode the text mode
+ * @throws TNotSupportedException not supported, fixed to TTextBoxMode::SingleLine.
+ */
+ public function setTextMode($value)
+ {
+ throw new TNotSupportedException('juidatepicker_settextmode_unsupported');
+ }
+
+ /**
+ * Gets the current culture.
+ * @return string current culture, e.g. en_AU.
+ */
+ public function getCulture()
+ {
+ return $this->getViewState('Culture', '');
+ }
+
+ /**
+ * Sets the culture/language for the date picker.
+ * @param string a culture string, e.g. en_AU.
+ */
+ public function setCulture($value)
+ {
+ $this->setViewState('Culture', $value, '');
+ }
+
+ /**
+ * @return string the current culture, falls back to application if culture is not set.
+ */
+ protected function getCurrentCulture()
+ {
+ $app = $this->getApplication()->getGlobalization(false);
+ return $this->getCulture() == '' ?
+ ($app ? $app->getCulture() : 'en') : $this->getCulture();
+ }
+
+ /**
+ * @return string the format of the date string
+ */
+ public function getDateFormat()
+ {
+ return $this->getViewState('DateFormat','dd-MM-yyyy');
+ }
+
+ /**
+ * Sets the format of the date string.
+ * @param string the format of the date string
+ */
+ public function setDateFormat($value)
+ {
+ $this->setViewState('DateFormat',$value,'dd-MM-yyyy');
+ }
+
+ /**
+ * Returns the timestamp selected by the user.
+ * This method is required by {@link IDataRenderer}.
+ * It is the same as {@link getTimeStamp()}.
+ * @return integer the timestamp of the TDatePicker control.
+ * @see getTimeStamp
+ * @since 3.1.2
+ */
+ public function getData()
+ {
+ return $this->getTimeStamp();
+ }
+
+ /**
+ * Sets the timestamp represented by this control.
+ * This method is required by {@link IDataRenderer}.
+ * It is the same as {@link setTimeStamp()}.
+ * @param integer the timestamp of the TDatePicker control.
+ * @see setTimeStamp
+ * @since 3.1.2
+ */
+ public function setData($value)
+ {
+ $this->setTimeStamp($value);
+ }
+
+ /**
+ * @return string the date string.
+ */
+ public function getDate()
+ {
+ return $this->getText();
+ }
+
+ /**
+ * @param string date string
+ */
+ public function setDate($value)
+ {
+ $this->setText($value);
+ }
+
+ /**
+ * @return integer current selected date from the date picker as timestamp, NULL if timestamp is not set previously.
+ */
+ public function getTimeStamp()
+ {
+ if(trim($this->getText())==='')
+ return null;
+ else
+ return $this->getTimeStampFromText();
+ }
+
+ /**
+ * Sets the date for the date picker using timestamp.
+ * @param float time stamp for the date picker
+ */
+ public function setTimeStamp($value)
+ {
+ if($value===null || (is_string($value) && trim($value)===''))
+ $this->setText('');
+ else
+ {
+ $date = TPropertyValue::ensureFloat($value);
+ $formatter = Prado::createComponent('System.Util.TSimpleDateFormatter',$this->getDateFormat());
+ $this->setText($formatter->format($date));
+ }
+ }
+
+ /**
+ * Gets the date from the text input using TSimpleDateFormatter
+ * @return integer current selected date timestamp
+ */
+ protected function getTimeStampFromText()
+ {
+ $pattern = $this->getDateFormat();
+ $pattern = str_replace(array('MMMM', 'MMM'), array('MM','MM'), $pattern);
+ $formatter = Prado::createComponent('System.Util.TSimpleDateFormatter',$pattern);
+ return $formatter->parse($this->getText());
+ }
+
+ /**
+ * Returns the value to be validated.
+ * This methid is required by IValidatable interface.
+ * @return integer the interger timestamp if valid, otherwise the original text.
+ */
+ public function getValidationPropertyValue()
+ {
+ if(($text = $this->getText()) === '')
+ return '';
+ $date = $this->getTimeStamp();
+ return $date == null ? $text : $date;
+ }
+
+} \ No newline at end of file
diff --git a/lib/prado/framework/Web/UI/JuiControls/TJuiDialog.php b/lib/prado/framework/Web/UI/JuiControls/TJuiDialog.php
new file mode 100644
index 0000000..e02157d
--- /dev/null
+++ b/lib/prado/framework/Web/UI/JuiControls/TJuiDialog.php
@@ -0,0 +1,283 @@
+<?php
+/**
+ * TJuiDialog class file.
+ *
+ * @author David Otto <ottodavid[at]gmx[dot]net>
+ * @link https://github.com/pradosoft/prado
+ * @copyright Copyright &copy; 2013-2015 PradoSoft
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @package System.Web.UI.JuiControls
+ */
+
+Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter');
+Prado::using('System.Web.UI.ActiveControls.TActivePanel');
+
+/**
+ * TJuiDialog class.
+ *
+ * TJuiDialog is an extension to {@link TActivePanel} based on jQuery-UI's
+ * {@link http://jqueryui.com/dialog/ Dialog} widget.
+ *
+ *
+ * <code>
+ * <com:TJuiDialog
+ * ID="dlg1"
+ * >
+ * contents
+ * </com:TJuiDialog>
+ * </code>
+ *
+ * @author David Otto <ottodavid[at]gmx[dot]net>
+ * @package System.Web.UI.JuiControls
+ * @since 3.3
+ */
+class TJuiDialog extends TActivePanel implements IJuiOptions, ICallbackEventHandler
+{
+ protected $_options;
+
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TJuiControlAdapter($this));
+ }
+
+ /**
+ * @return string the name of the jQueryUI widget method
+ */
+ public function getWidget()
+ {
+ return 'dialog';
+ }
+
+ /**
+ * @return string the clientid of the jQueryUI widget element
+ */
+ public function getWidgetID()
+ {
+ return $this->getClientID();
+ }
+
+ /**
+ * Object containing defined javascript options
+ * @return TJuiControlOptions
+ */
+ public function getOptions()
+ {
+ if (($options=$this->getViewState('JuiOptions'))===null)
+ {
+ $options=new TJuiControlOptions($this);
+ $this->setViewState('JuiOptions', $options);
+ }
+ return $options;
+ }
+
+ /**
+ * Array containing valid javascript options
+ * @return array()
+ */
+ public function getValidOptions()
+ {
+ return array('appendTo', 'autoOpen', 'buttons', 'closeOnEscape', 'closeText', 'dialogClass', 'draggable', 'height', 'hide', 'minHeight', 'minWidth', 'maxHeight', 'maxWidth', 'modal', 'position', 'resizeable', 'show', 'title', 'width');
+ }
+
+ /**
+ * Array containing valid javascript events
+ * @return array()
+ */
+ public function getValidEvents()
+ {
+ return array('beforeClose', 'close', 'create', 'drag', 'dragStart', 'dragStop', 'focus', 'open', 'resize', 'resizeStart', 'resizeStop');
+ }
+
+ /**
+ * @return array list of callback options.
+ */
+ protected function getPostBackOptions()
+ {
+ $options = $this->getOptions()->toArray();
+
+ foreach($this->getControls() as $control)
+ if($control instanceof TJuiDialogButton)
+ $options['buttons'][] = $control->getPostBackOptions();
+
+ return $options;
+ }
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
+ */
+ protected function addAttributesToRender($writer)
+ {
+ parent::addAttributesToRender($writer);
+
+ $writer->addAttribute('id',$this->getClientID());
+ $options=TJavascript::encode($this->getPostBackOptions());
+ $cs=$this->getPage()->getClientScript();
+ $code="jQuery('#".$this->getWidgetID()."').".$this->getWidget()."(".$options.");";
+ $cs->registerEndScript(sprintf('%08X', crc32($code)), $code);
+ }
+
+ /**
+ * Raises callback event. This method is required by the {@link ICallbackEventHandler}
+ * interface.
+ * @param TCallbackEventParameter the parameter associated with the callback event
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->getOptions()->raiseCallbackEvent($param);
+ }
+
+ /**
+ * Raises the OnCreate event
+ * @param object $params event parameters
+ */
+ public function onOpen ($params)
+ {
+ $this->raiseEvent('OnOpen', $this, $params);
+ }
+
+ /**
+ * Open this dialog
+ */
+ public function open()
+ {
+ $this->triggerClientMethod('open');
+ }
+
+ /**
+ * Close this dialog
+ */
+ public function close()
+ {
+ $this->triggerClientMethod('close');
+ }
+
+ private function triggerClientMethod($method)
+ {
+ $cs = $this->getPage()->getClientScript();
+ $code = "jQuery('#".$this->getClientId()."').dialog('".$method."');";
+ $cs->registerEndScript(sprintf('%08X', crc32($code)), $code);
+ }
+
+ /**
+ * Rendering as a fieldset is not supported for TJuiDialog.
+ * @param string the legend text. If this value is not empty, the panel will be rendered as a fieldset.
+ * @throws TNotSupportedException not supported for TJuiDialog.
+ */
+ public function setGroupingText($value)
+ {
+ throw new TNotSupportedException('Rendering as a fieldset is not supported for {0}.', get_class($this));
+ }
+
+ /**
+ * Overrides parent implementation to just render the inner contents and avoid replacing the element itself when
+ * updating clientside, because replacing/removing will cause jqueryui to fire destroy on the original dialog extension.
+ * @param THtmlWriter html writer
+ */
+ public function render($writer)
+ {
+ if($this->getHasPreRendered() && $this->getActiveControl()->canUpdateClientSide())
+ {
+ parent::renderContents($writer);
+ $this->getPage()->getCallbackClient()->replaceContent($this, $writer, false);
+ }
+ else
+ parent::render($writer);
+ }
+}
+
+/**
+ * TJuiDialogButton class
+ *
+ * This button must be child of a TJuiDialog. It can be used to bind an callback
+ * to the buttons of the dialog.
+ *
+ * <code>
+ * <com:TJuiDialog> * >
+ * Text
+ * <com:TJuiDialogButton Text="Ok" OnClick="Ok" />
+ *
+ * </com:TJuiDialog>
+ * </code>
+ *
+ * @author David Otto <ottodavid[at]gmx[dot]net>
+ * @package System.Web.UI.JuiControls
+ * @since 3.3
+ */
+class TJuiDialogButton extends TControl implements ICallbackEventHandler, IActiveControl
+{
+
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TActiveControlAdapter($this));
+ }
+
+ /**
+ * @return TBaseActiveCallbackControl standard callback control options.
+ */
+ public function getActiveControl()
+ {
+ return $this->getAdapter()->getBaseActiveControl();
+ }
+
+ /**
+ * Array containing defined javascript options
+ * @return array
+ */
+ public function getPostBackOptions()
+ {
+ return array(
+ 'text' => $this->getText(),
+ 'click' => new TJavaScriptLiteral("function(){new Prado.Callback('".$this->getUniqueID()."', 'onClick');}"
+ )) ;
+ }
+
+ /**
+ * @return string caption of the button
+ */
+ public function getText()
+ {
+ return $this->getViewState('Text','');
+ }
+
+ /**
+ * @param string caption of the button
+ */
+ public function setText($value)
+ {
+ $this->setViewState('Text',$value,'');
+ }
+
+ /**
+ * Raises the OnClick event
+ * @param object $params event parameters
+ */
+ public function onClick ($params)
+ {
+ $this->raiseEvent('OnClick', $this, $params);
+ }
+
+ /**
+ * Raises callback event.
+ * raises the appropriate event(s) (e.g. OnClick)
+ * @param TCallbackEventParameter the parameter associated with the callback event
+ */
+ public function raiseCallbackEvent($param)
+ {
+ if($param->CallbackParameter === 'onClick')
+ $this->onClick($param);
+ }
+
+} \ No newline at end of file
diff --git a/lib/prado/framework/Web/UI/JuiControls/TJuiDraggable.php b/lib/prado/framework/Web/UI/JuiControls/TJuiDraggable.php
new file mode 100644
index 0000000..f32e257
--- /dev/null
+++ b/lib/prado/framework/Web/UI/JuiControls/TJuiDraggable.php
@@ -0,0 +1,169 @@
+<?php
+/**
+ * TJuiDraggable class file.
+ *
+ * @author Fabio Bas <ctrlaltca[at]gmail[dot]com>
+ * @link https://github.com/pradosoft/prado
+ * @copyright Copyright &copy; 2013-2015 PradoSoft
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @package System.Web.UI.JuiControls
+ */
+
+Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter');
+Prado::using('System.Web.UI.ActiveControls.TActivePanel');
+
+/**
+ * TJuiDraggable class.
+ *
+ * TJuiDraggable is an extension to {@link TActivePanel} based on jQuery-UI's
+ * {@link http://jqueryui.com/draggable/ Draggable} interaction.
+ * The panel can be moved using the mouse, and eventually dropped over a
+ * {@link TJuiDroppable}.
+ *
+ * <code>
+ * <com:TJuiDraggable
+ * ID="drag1"
+ * Style="border: 1px solid red; width:100px;height:100px"
+ * Options.Axis="y"
+ * OnStop="drag1_dragged"
+ * >
+ * drag me
+ * </com:TJuiDraggable>
+ * </code>
+ *
+ * @author Fabio Bas <ctrlaltca[at]gmail[dot]com>
+ * @package System.Web.UI.JuiControls
+ * @since 3.3
+ */
+class TJuiDraggable extends TActivePanel implements IJuiOptions, ICallbackEventHandler
+{
+ protected $_options;
+
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TJuiControlAdapter($this));
+ }
+
+ /**
+ * @return string the name of the jQueryUI widget method
+ */
+ public function getWidget()
+ {
+ return 'draggable';
+ }
+
+ /**
+ * @return string the clientid of the jQueryUI widget element
+ */
+ public function getWidgetID()
+ {
+ return $this->getClientID();
+ }
+
+ /**
+ * Object containing defined javascript options
+ * @return TJuiControlOptions
+ */
+ public function getOptions()
+ {
+ if (($options=$this->getViewState('JuiOptions'))===null)
+ {
+ $options=new TJuiControlOptions($this);
+ $this->setViewState('JuiOptions', $options);
+ }
+ return $options;
+ }
+
+ /**
+ * Array containing valid javascript options
+ * @return array()
+ */
+ public function getValidOptions()
+ {
+ return array('addClasses', 'appendTo', 'axis', 'cancel', 'connectToSortable', 'containment', 'cursor', 'cursorAt', 'delay', 'disabled', 'distance', 'grid', 'handle', 'helper', 'iframeFix', 'opacity', 'refreshPositions', 'revert', 'revertDuration', 'scope', 'scroll', 'scrollSensitivity', 'scrollSpeed', 'snap', 'snapMode', 'snapTolerance', 'stack', 'zIndex');
+ }
+
+ /**
+ * Array containing valid javascript events
+ * @return array()
+ */
+ public function getValidEvents()
+ {
+ return array('create', 'drag', 'start', 'stop');
+ }
+
+ /**
+ * @return array list of callback options.
+ */
+ protected function getPostBackOptions()
+ {
+ return $this->getOptions()->toArray();
+ }
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
+ */
+ protected function addAttributesToRender($writer)
+ {
+ parent::addAttributesToRender($writer);
+
+ $writer->addAttribute('id',$this->getClientID());
+ $options=TJavascript::encode($this->getPostBackOptions());
+ $cs=$this->getPage()->getClientScript();
+ $code="jQuery('#".$this->getWidgetID()."').".$this->getWidget()."(".$options.");";
+ $cs->registerEndScript(sprintf('%08X', crc32($code)), $code);
+ }
+
+ /**
+ * Raises callback event. This method is required by the {@link ICallbackEventHandler}
+ * interface.
+ * @param TCallbackEventParameter the parameter associated with the callback event
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->getOptions()->raiseCallbackEvent($param);
+ }
+
+ /**
+ * Raises the OnCreate event
+ * @param object $params event parameters
+ */
+ public function onCreate ($params)
+ {
+ $this->raiseEvent('OnCreate', $this, $params);
+ }
+
+ /**
+ * Raises the OnDrag event
+ * @param object $params event parameters
+ */
+ public function onDrag ($params)
+ {
+ $this->raiseEvent('OnDrag', $this, $params);
+ }
+
+ /**
+ * Raises the OnStart event
+ * @param object $params event parameters
+ */
+ public function onStart ($params)
+ {
+ $this->raiseEvent('OnStart', $this, $params);
+ }
+
+ /**
+ * Raises the OnStop event
+ * @param object $params event parameters
+ */
+ public function onStop ($params)
+ {
+ $this->raiseEvent('OnStop', $this, $params);
+ }
+}
diff --git a/lib/prado/framework/Web/UI/JuiControls/TJuiDroppable.php b/lib/prado/framework/Web/UI/JuiControls/TJuiDroppable.php
new file mode 100644
index 0000000..9a61572
--- /dev/null
+++ b/lib/prado/framework/Web/UI/JuiControls/TJuiDroppable.php
@@ -0,0 +1,220 @@
+<?php
+/**
+ * TJuiDroppable class file.
+ *
+ * @author Fabio Bas <ctrlaltca[at]gmail[dot]com>
+ * @link https://github.com/pradosoft/prado
+ * @copyright Copyright &copy; 2013-2015 PradoSoft
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @package System.Web.UI.JuiControls
+ */
+
+Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter');
+Prado::using('System.Web.UI.ActiveControls.TActivePanel');
+
+/**
+ * TJuiDroppable class.
+ *
+ * TJuiDroppable is an extension to {@link TActivePanel} based on jQuery-UI's
+ * {@link http://jqueryui.com/droppable/ Droppable} interaction.
+ * When a {@link TJuiDraggable} is dropped over a TJuiDroppable panel, the
+ * {@link onDrop OnDrop} event will be triggered. The event hanler will receive
+ * a {@link TJuiEventParameter} object containing a reference to the dropped control
+ * in the <tt>DraggableControl</tt> property.
+ *
+ * <code>
+ * <com:TJuiDraggable
+ * ID="drag1"
+ * Style="border: 1px solid red; width:100px;height:100px;background-color: #fff"
+ * >
+ * drag me
+ * </com:TJuiDraggable>
+ *
+ * <com:TJuiDroppable
+ * ID="drop1"
+ * Style="border: 1px solid blue; width:600px;height:600px; background-color: lime"
+ * OnDrop="drop1_ondrop"
+ * >
+ * drop it over me
+ * </com:TJuiDroppable>
+ * </code>
+ *
+ * <code>
+ * public function drop1_ondrop($sender, $param)
+ * {
+ * $draggable=$param->DraggableControl;
+ * $offset=$param->getCallbackParameter()->offset;
+ * $target=$param->getCallbackParameter()->target->offset;
+ * $top=$offset->top - $target->top;
+ * $left=$offset->left - $target->left;
+ * $this->label1->Text="Dropped ".$draggable->ID." at: <br/>Top=".$top." Left=".$left;
+ * }
+ * </code>
+ *
+ * @author Fabio Bas <ctrlaltca[at]gmail[dot]com>
+ * @package System.Web.UI.JuiControls
+ * @since 3.3
+ */
+class TJuiDroppable extends TActivePanel implements IJuiOptions, ICallbackEventHandler
+{
+ protected $_options;
+
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TJuiControlAdapter($this));
+ }
+
+ /**
+ * @return string the name of the jQueryUI widget method
+ */
+ public function getWidget()
+ {
+ return 'droppable';
+ }
+
+ /**
+ * @return string the clientid of the jQueryUI widget element
+ */
+ public function getWidgetID()
+ {
+ return $this->getClientID();
+ }
+
+ /**
+ * Object containing defined javascript options
+ * @return TJuiControlOptions
+ */
+ public function getOptions()
+ {
+ if (($options=$this->getViewState('JuiOptions'))===null)
+ {
+ $options=new TJuiControlOptions($this);
+ $this->setViewState('JuiOptions', $options);
+ }
+ return $options;
+ }
+
+ /**
+ * Array containing valid javascript options
+ * @return array()
+ */
+ public function getValidOptions()
+ {
+ return array('accept', 'activeClass', 'addClasses', 'disabled', 'greedy', 'hoverClass', 'scope', 'tolerance');
+ }
+
+ /**
+ * Array containing valid javascript events
+ * @return array()
+ */
+ public function getValidEvents()
+ {
+ return array('activate', 'create', 'deactivate', 'drop', 'out', 'over');
+ }
+
+ /**
+ * @return array list of callback options.
+ */
+ protected function getPostBackOptions()
+ {
+ return $this->getOptions()->toArray();
+ }
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
+ */
+ protected function addAttributesToRender($writer)
+ {
+ parent::addAttributesToRender($writer);
+
+ $writer->addAttribute('id',$this->getClientID());
+ $options=TJavascript::encode($this->getPostBackOptions());
+ $cs=$this->getPage()->getClientScript();
+ $code="jQuery('#".$this->getWidgetID()."').".$this->getWidget()."(".$options.");";
+ $cs->registerEndScript(sprintf('%08X', crc32($code)), $code);
+ }
+
+ /**
+ * Raises callback event. This method is required by the {@link ICallbackEventHandler}
+ * interface.
+ * @param TCallbackEventParameter the parameter associated with the callback event
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->getOptions()->raiseCallbackEvent($param);
+ }
+
+ /**
+ * Raises the OnActivate event
+ * @param object $params event parameters
+ */
+ public function onActivate ($params)
+ {
+ $this->raiseEvent('OnActivate', $this, $params);
+ }
+
+ /**
+ * Raises the OnCreate event
+ * @param object $params event parameters
+ */
+ public function onCreate ($params)
+ {
+ $this->raiseEvent('OnCreate', $this, $params);
+ }
+
+ /**
+ * Raises the OnDeactivate event
+ * @param object $params event parameters
+ */
+ public function onDeactivate ($params)
+ {
+ $this->raiseEvent('OnDeactivate', $this, $params);
+ }
+
+ /**
+ * Raises the OnDrop event
+ * @param object $params event parameters
+ */
+ public function onDrop ($params)
+ {
+ $this->raiseEvent('OnDrop', $this, $params);
+ }
+
+ /**
+ * Raises the OnOut event
+ * @param object $params event parameters
+ */
+ public function OnOut ($params)
+ {
+ $this->raiseEvent('OnOut', $this, $params);
+ }
+
+ /**
+ * Raises the OnOver event
+ * @param object $params event parameters
+ */
+ public function OnOver ($params)
+ {
+ $this->raiseEvent('OnOver', $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
+ */
+
+ public function onCallback($param)
+ {
+ $this->raiseEvent('OnCallback', $this, $param);
+ }
+}
diff --git a/lib/prado/framework/Web/UI/JuiControls/TJuiProgressbar.php b/lib/prado/framework/Web/UI/JuiControls/TJuiProgressbar.php
new file mode 100644
index 0000000..61e185e
--- /dev/null
+++ b/lib/prado/framework/Web/UI/JuiControls/TJuiProgressbar.php
@@ -0,0 +1,156 @@
+<?php
+/**
+ * TJuiProgressbar class file.
+ *
+ * @author Fabio Bas <ctrlaltca[at]gmail[dot]com>
+ * @link https://github.com/pradosoft/prado
+ * @copyright Copyright &copy; 2013-2015 PradoSoft
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @package System.Web.UI.JuiControls
+ */
+
+Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter');
+Prado::using('System.Web.UI.ActiveControls.TActivePanel');
+
+/**
+ * TJuiProgressbar class.
+ *
+ * TJuiProgressbar is an extension to {@link TActivePanel} based on jQuery-UI's
+ * {@link http://jqueryui.com/progressbar/ Progressbar} widget.
+ *
+ * <code>
+ * <com:TJuiProgressbar
+ * ID="pbar1"
+ * Options.Max="100"
+ * Options.Value="75"
+ * OnChange="pbar1_changed"
+ * />
+ * </code>
+ *
+ * @author Fabio Bas <ctrlaltca[at]gmail[dot]com>
+ * @package System.Web.UI.JuiControls
+ * @since 3.3
+ */
+class TJuiProgressbar extends TActivePanel implements IJuiOptions, ICallbackEventHandler
+{
+ protected $_options;
+
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TJuiControlAdapter($this));
+ }
+
+ /**
+ * @return string the name of the jQueryUI widget method
+ */
+ public function getWidget()
+ {
+ return 'progressbar';
+ }
+
+ /**
+ * @return string the clientid of the jQueryUI widget element
+ */
+ public function getWidgetID()
+ {
+ return $this->getClientID();
+ }
+
+ /**
+ * Object containing defined javascript options
+ * @return TJuiControlOptions
+ */
+ public function getOptions()
+ {
+ if (($options=$this->getViewState('JuiOptions'))===null)
+ {
+ $options=new TJuiControlOptions($this);
+ $this->setViewState('JuiOptions', $options);
+ }
+ return $options;
+ }
+
+ /**
+ * Array containing valid javascript options
+ * @return array()
+ */
+ public function getValidOptions()
+ {
+ return array('disabled', 'max', 'value');
+ }
+
+ /**
+ * Array containing valid javascript events
+ * @return array()
+ */
+ public function getValidEvents()
+ {
+ return array('change', 'complete', 'create');
+ }
+
+ /**
+ * @return array list of callback options.
+ */
+ protected function getPostBackOptions()
+ {
+ return $this->getOptions()->toArray();
+ }
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
+ */
+ protected function addAttributesToRender($writer)
+ {
+ parent::addAttributesToRender($writer);
+
+ $writer->addAttribute('id',$this->getClientID());
+ $options=TJavascript::encode($this->getPostBackOptions());
+ $cs=$this->getPage()->getClientScript();
+ $code="jQuery('#".$this->getWidgetID()."').".$this->getWidget()."(".$options.");";
+ $cs->registerEndScript(sprintf('%08X', crc32($code)), $code);
+ }
+
+ /**
+ * Raises callback event. This method is required by the {@link ICallbackEventHandler}
+ * interface.
+ * @param TCallbackEventParameter the parameter associated with the callback event
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->getOptions()->raiseCallbackEvent($param);
+ }
+
+ /**
+ * Raises the OnChange event
+ * @param object $params event parameters
+ */
+ public function onChange($params)
+ {
+ $this->raiseEvent('OnChange', $this, $params);
+ }
+
+ /**
+ * Raises the OnComplete event
+ * @param object $params event parameters
+ */
+ public function onComplete($params)
+ {
+ $this->raiseEvent('OnComplete', $this, $params);
+ }
+
+ /**
+ * Raises the OnCreate event
+ * @param object $params event parameters
+ */
+ public function onCreate($params)
+ {
+ $this->raiseEvent('OnCreate', $this, $params);
+ }
+}
diff --git a/lib/prado/framework/Web/UI/JuiControls/TJuiResizable.php b/lib/prado/framework/Web/UI/JuiControls/TJuiResizable.php
new file mode 100644
index 0000000..c73305f
--- /dev/null
+++ b/lib/prado/framework/Web/UI/JuiControls/TJuiResizable.php
@@ -0,0 +1,172 @@
+<?php
+/**
+ * TJuiResizable class file.
+ *
+ * @author Fabio Bas <ctrlaltca[at]gmail[dot]com>
+ * @link https://github.com/pradosoft/prado
+ * @copyright Copyright &copy; 2013-2015 PradoSoft
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @package System.Web.UI.JuiControls
+ */
+
+Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter');
+Prado::using('System.Web.UI.ActiveControls.TActivePanel');
+
+/**
+ * TJuiResizable class.
+ *
+ * TJuiResizable is an extension to {@link TActivePanel} based on jQuery-UI's
+ * {@link http://jqueryui.com/resizable/ Resizable} interaction.
+ * A small handle is shown on the bottom right corner of the panel, that permits
+ * the panel to be resized using the mouse.
+ *
+ * <code>
+ * <com:TJuiResizable
+ * ID="resize1"
+ * Style="border: 1px solid green; width:100px;height:100px;background-color: #00dd00"
+ * Options.maxHeight="250"
+ * Options.maxWidth="350"
+ * Options.minHeight="150"
+ * Options.minWidth="200"
+ * >
+ * resize me
+ * </com:TJuiResizable>
+ * </code>
+ *
+ * @author Fabio Bas <ctrlaltca[at]gmail[dot]com>
+ * @package System.Web.UI.JuiControls
+ * @since 3.3
+ */
+class TJuiResizable extends TActivePanel implements IJuiOptions, ICallbackEventHandler
+{
+ protected $_options;
+
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TJuiControlAdapter($this));
+ }
+
+ /**
+ * @return string the name of the jQueryUI widget method
+ */
+ public function getWidget()
+ {
+ return 'resizable';
+ }
+
+ /**
+ * @return string the clientid of the jQueryUI widget element
+ */
+ public function getWidgetID()
+ {
+ return $this->getClientID();
+ }
+
+ /**
+ * Object containing defined javascript options
+ * @return TJuiControlOptions
+ */
+ public function getOptions()
+ {
+ if (($options=$this->getViewState('JuiOptions'))===null)
+ {
+ $options=new TJuiControlOptions($this);
+ $this->setViewState('JuiOptions', $options);
+ }
+ return $options;
+ }
+
+ /**
+ * Array containing valid javascript options
+ * @return array()
+ */
+ public function getValidOptions()
+ {
+ return array('alsoResize', 'animate', 'animateDuration', 'animateEasing', 'aspectRatio', 'autoHide', 'cancel', 'containment', 'delay', 'disabled', 'distance', 'ghost', 'grid', 'handles', 'helper', 'maxHeight', 'maxWidth', 'minHeight', 'minWidth');
+ }
+
+ /**
+ * Array containing valid javascript events
+ * @return array()
+ */
+ public function getValidEvents()
+ {
+ return array('create', 'resize', 'start', 'stop');
+ }
+
+ /**
+ * @return array list of callback options.
+ */
+ protected function getPostBackOptions()
+ {
+ $options = $this->getOptions()->toArray();
+ return $options;
+ }
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
+ */
+ protected function addAttributesToRender($writer)
+ {
+ parent::addAttributesToRender($writer);
+
+ $writer->addAttribute('id',$this->getClientID());
+ $options=TJavascript::encode($this->getPostBackOptions());
+ $cs=$this->getPage()->getClientScript();
+ $code="jQuery('#".$this->getWidgetID()."').".$this->getWidget()."(".$options.");";
+ $cs->registerEndScript(sprintf('%08X', crc32($code)), $code);
+ }
+
+ /**
+ * Raises callback event. This method is required by the {@link ICallbackEventHandler}
+ * interface.
+ * @param TCallbackEventParameter the parameter associated with the callback event
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->getOptions()->raiseCallbackEvent($param);
+ }
+
+ /**
+ * Raises the OnCreate event
+ * @param object $params event parameters
+ */
+ public function onCreate ($params)
+ {
+ $this->raiseEvent('OnCreate', $this, $params);
+ }
+
+ /**
+ * Raises the OnResize event
+ * @param object $params event parameters
+ */
+ public function onResize ($params)
+ {
+ $this->raiseEvent('OnResize', $this, $params);
+ }
+
+ /**
+ * Raises the OnStart event
+ * @param object $params event parameters
+ */
+ public function onStart ($params)
+ {
+ $this->raiseEvent('OnStart', $this, $params);
+ }
+
+ /**
+ * Raises the OnStop event
+ * @param object $params event parameters
+ */
+ public function onStop ($params)
+ {
+ $this->raiseEvent('OnStop', $this, $params);
+ }
+}
diff --git a/lib/prado/framework/Web/UI/JuiControls/TJuiSelectable.php b/lib/prado/framework/Web/UI/JuiControls/TJuiSelectable.php
new file mode 100644
index 0000000..7fdaaa7
--- /dev/null
+++ b/lib/prado/framework/Web/UI/JuiControls/TJuiSelectable.php
@@ -0,0 +1,280 @@
+<?php
+/**
+ * TJuiSelectable class file.
+ *
+ * @author Fabio Bas <ctrlaltca[at]gmail[dot]com>
+ * @link https://github.com/pradosoft/prado
+ * @copyright Copyright &copy; 2013-2015 PradoSoft
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @package System.Web.UI.JuiControls
+ */
+
+Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter');
+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.
+ * TJuiSelectable 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>
+ * .ui-selecting { background: #FECA40; }
+ * .ui-selected { background: #F39814; color: white; }
+ * </style>
+ * <com:TJuiSelectable ID="repeater1" />
+ * </code>
+ *
+ * <code>
+ * $this->repeater1->DataSource=array('home', 'office', 'car', 'boat', 'plane');
+ * $this->repeater1->dataBind();
+ * </code>
+ * @author Fabio Bas <ctrlaltca[at]gmail[dot]com>
+ * @package System.Web.UI.JuiControls
+ * @since 3.3
+ */
+class TJuiSelectable extends TActivePanel implements IJuiOptions, ICallbackEventHandler
+{
+ protected $_options;
+
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TJuiControlAdapter($this));
+ }
+
+ /**
+ * @return string the name of the jQueryUI widget method
+ */
+ public function getWidget()
+ {
+ return 'selectable';
+ }
+
+ /**
+ * @return string the clientid of the jQueryUI widget element
+ */
+ public function getWidgetID()
+ {
+ return $this->getClientID() . '_0';
+ }
+
+ /**
+ * Object containing defined javascript options
+ * @return TJuiControlOptions
+ */
+ public function getOptions()
+ {
+ if (($options=$this->getViewState('JuiOptions'))===null)
+ {
+ $options=new TJuiControlOptions($this);
+ $this->setViewState('JuiOptions', $options);
+ }
+ return $options;
+ }
+
+ /**
+ * Array containing valid javascript options
+ * @return array()
+ */
+ public function getValidOptions()
+ {
+ return array('appendTo', 'autoRefresh', 'cancel', 'delay', 'disabled', 'distance', 'filter', 'tolerance');
+ }
+
+ /**
+ * Array containing valid javascript events
+ * @return array()
+ */
+ public function getValidEvents()
+ {
+ return array('create', 'selected', 'selecting', 'start', 'stop', 'unselected', 'unselecting');
+ }
+
+ /**
+ * @return array list of callback options.
+ */
+ protected function getPostBackOptions()
+ {
+ $options = $this->getOptions()->toArray();
+ // 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;
+ }
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
+ */
+ protected function addAttributesToRender($writer)
+ {
+ parent::addAttributesToRender($writer);
+ $writer->addAttribute('id',$this->getClientID());
+ $options=TJavascript::encode($this->getPostBackOptions());
+ $cs=$this->getPage()->getClientScript();
+ $code="jQuery('#".$this->getWidgetID()."').".$this->getWidget()."(".$options.");";
+ $cs->registerEndScript(sprintf('%08X', crc32($code)), $code);
+ }
+
+ /**
+ * Raises callback event. This method is required by the {@link ICallbackEventHandler}
+ * interface.
+ * @param TCallbackEventParameter the parameter associated with the callback event
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->getOptions()->raiseCallbackEvent($param);
+ }
+
+ /**
+ * Raises the OnCreate event
+ * @param object $params event parameters
+ */
+ public function onCreate ($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);
+ }
+
+ /**
+ * Raises the OnStart event
+ * @param object $params event parameters
+ */
+ public function onStart ($params)
+ {
+ $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);
+ }
+
+ /**
+ * @var ITemplate template for repeater items
+ */
+ private $_repeater=null;
+
+ /**
+ * @param array data source for Selectables.
+ */
+ public function setDataSource($data)
+ {
+ $this->getSelectables()->setDataSource($data);
+ }
+
+ /**
+ * Overrides parent implementation. Callback {@link renderSelectables()} when
+ * page's IsCallback property is true.
+ */
+ public function dataBind()
+ {
+ parent::dataBind();
+ if($this->getPage()->getIsCallback())
+ $this->renderSelectables($this->getResponse()->createHtmlWriter());
+ }
+
+ /**
+ * @return TRepeater suggestion list repeater
+ */
+ public function getSelectables()
+ {
+ if($this->_repeater===null)
+ $this->_repeater = $this->createRepeater();
+ return $this->_repeater;
+ }
+
+ /**
+ * @return TRepeater new instance of TRepater to render the list of Selectables.
+ */
+ protected function createRepeater()
+ {
+ $repeater = Prado::createComponent('System.Web.UI.WebControls.TRepeater');
+ $repeater->setHeaderTemplate(new TJuiSelectableTemplate('<ul id="'.$this->getWidgetID().'">'));
+ $repeater->setFooterTemplate(new TJuiSelectableTemplate('</ul>'));
+ $repeater->setItemTemplate(new TTemplate('<li id="<%# $this->ItemIndex %>"><%# $this->DataItem %></li>',null));
+ $repeater->setEmptyTemplate(new TJuiSelectableTemplate('<ul></ul>'));
+ $this->getControls()->add($repeater);
+ return $repeater;
+ }
+}
+
+/**
+ * TJuiSelectableTemplate class.
+ *
+ * TJuiSelectableTemplate is the default template for TJuiSelectableTemplate
+ * item template.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TJuiSelectableTemplate extends TComponent implements ITemplate
+{
+ private $_template;
+
+ public function __construct($template)
+ {
+ $this->_template = $template;
+ }
+ /**
+ * Instantiates the template.
+ * It creates a {@link TDataList} control.
+ * @param TControl parent to hold the content within the template
+ */
+ public function instantiateIn($parent)
+ {
+ $parent->getControls()->add($this->_template);
+ }
+}
diff --git a/lib/prado/framework/Web/UI/JuiControls/TJuiSortable.php b/lib/prado/framework/Web/UI/JuiControls/TJuiSortable.php
new file mode 100644
index 0000000..3fd62f2
--- /dev/null
+++ b/lib/prado/framework/Web/UI/JuiControls/TJuiSortable.php
@@ -0,0 +1,333 @@
+<?php
+/**
+ * TJuiSortable class file.
+ *
+ * @author Fabio Bas <ctrlaltca[at]gmail[dot]com>
+ * @link https://github.com/pradosoft/prado
+ * @copyright Copyright &copy; 2013-2015 PradoSoft
+ * @license https://github.com/pradosoft/prado/blob/master/COPYRIGHT
+ * @package System.Web.UI.JuiControls
+ */
+
+Prado::using('System.Web.UI.JuiControls.TJuiControlAdapter');
+Prado::using('System.Web.UI.ActiveControls.TActivePanel');
+
+/**
+ * TJuiSortable class.
+ *
+ * TJuiSortable is an extension to {@link TActivePanel} based on jQuery-UI's
+ * {@link http://jqueryui.com/sortable/ Sortable} 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 sortered dragging and dropping them.
+ *
+ * <code>
+ * <com:TJuiSortable ID="repeater1" />
+ * </code>
+ *
+ * <code>
+ * $this->repeater1->DataSource=array('home', 'office', 'car', 'boat', 'plane');
+ * $this->repeater1->dataBind();
+ * </code>
+ *
+ * @author Fabio Bas <ctrlaltca[at]gmail[dot]com>
+ * @package System.Web.UI.JuiControls
+ * @since 3.3
+ */
+class TJuiSortable extends TActivePanel implements IJuiOptions, ICallbackEventHandler
+{
+ protected $_options;
+
+ /**
+ * Creates a new callback control, sets the adapter to
+ * TActiveControlAdapter. If you override this class, be sure to set the
+ * adapter appropriately by, for example, by calling this constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->setAdapter(new TJuiControlAdapter($this));
+ }
+
+ /**
+ * @return string the name of the jQueryUI widget method
+ */
+ public function getWidget()
+ {
+ return 'sortable';
+ }
+
+ /**
+ * @return string the clientid of the jQueryUI widget element
+ */
+ public function getWidgetID()
+ {
+ return $this->getClientID() . '_0';
+ }
+
+ /**
+ * Object containing defined javascript options
+ * @return TJuiControlOptions
+ */
+ public function getOptions()
+ {
+ if (($options=$this->getViewState('JuiOptions'))===null)
+ {
+ $options=new TJuiControlOptions($this);
+ $this->setViewState('JuiOptions', $options);
+ }
+ return $options;
+ }
+
+ /**
+ * Array containing valid javascript options
+ * @return array()
+ */
+ public function getValidOptions()
+ {
+ return array('appendTo', 'axis', 'cancel', 'connectWith', 'containment', 'cursor', 'cursorAt', 'delay', 'disabled', 'distance', 'dropOnEmpty', 'forceHelperSize', 'forcePlaceholderSize', 'grid', 'handle', 'helper', 'items', 'opacity', 'placeholder', 'revert', 'scroll', 'scrollSensitivity', 'scrollSpeed', 'tolerance', 'zIndex');
+ }
+
+ /**
+ * Array containing valid javascript events
+ * @return array()
+ */
+ public function getValidEvents()
+ {
+ return array('activate', 'beforeStop', 'change', 'create', 'deactivate', 'out', 'over', 'receive', 'remove', 'sort', 'start', 'stop', 'update');
+ }
+
+ /**
+ * @return array list of callback options.
+ */
+ protected function getPostBackOptions()
+ {
+ $options = $this->getOptions()->toArray();
+ // overload some events to add information about the items order
+ foreach($options as $event => $implementation)
+ {
+ if($event=='sort' || $event=='stop')
+ $options[$event]=new TJavaScriptLiteral('function( event, ui ) { ui.index = jQuery(this).sortable(\'toArray\'); Prado.JuiCallback('.TJavascript::encode($this->getUniqueID()).', \''.$event.'\', event, ui, this); }');
+ }
+ return $options;
+ }
+
+ /**
+ * Ensure that the ID attribute is rendered and registers the javascript code
+ * for initializing the active control.
+ */
+ protected function addAttributesToRender($writer)
+ {
+ parent::addAttributesToRender($writer);
+ $writer->addAttribute('id',$this->getClientID());
+ $options=TJavascript::encode($this->getPostBackOptions());
+ $cs=$this->getPage()->getClientScript();
+ $code="jQuery('#".$this->getWidgetID()."').".$this->getWidget()."(".$options.");";
+ $cs->registerEndScript(sprintf('%08X', crc32($code)), $code);
+ }
+
+ /**
+ * Raises callback event. This method is required by the {@link ICallbackEventHandler}
+ * interface.
+ * @param TCallbackEventParameter the parameter associated with the callback event
+ */
+ public function raiseCallbackEvent($param)
+ {
+ $this->getOptions()->raiseCallbackEvent($param);
+ }
+
+ /**
+ * Raises the OnActivate event
+ * @param object $params event parameters
+ */
+ public function onActivate ($params)
+ {
+ $this->raiseEvent('OnActivate', $this, $params);
+ }
+
+ /**
+ * Raises the OnBeforeStop event
+ * @param object $params event parameters
+ */
+ public function onBeforeStop ($params)
+ {
+ $this->raiseEvent('OnBeforeStop', $this, $params);
+ }
+
+ /**
+ * Raises the OnChange event
+ * @param object $params event parameters
+ */
+ public function onChange ($params)
+ {
+ $this->raiseEvent('OnChange', $this, $params);
+ }
+
+ /**
+ * Raises the OnCreate event
+ * @param object $params event parameters
+ */
+ public function onCreate ($params)
+ {
+ $this->raiseEvent('OnCreate', $this, $params);
+ }
+
+ /**
+ * Raises the OnDeactivate event
+ * @param object $params event parameters
+ */
+ public function onDeactivate ($params)
+ {
+ $this->raiseEvent('OnDeactivate', $this, $params);
+ }
+
+ /**
+ * Raises the OnOut event
+ * @param object $params event parameters
+ */
+ public function onOut ($params)
+ {
+ $this->raiseEvent('OnOut', $this, $params);
+ }
+
+ /**
+ * Raises the OnOver event
+ * @param object $params event parameters
+ */
+ public function onOver ($params)
+ {
+ $this->raiseEvent('OnOver', $this, $params);
+ }
+
+ /**
+ * Raises the OnReceive event
+ * @param object $params event parameters
+ */
+ public function onReceive ($params)
+ {
+ $this->raiseEvent('OnReceive', $this, $params);
+ }
+
+ /**
+ * Raises the OnRemove event
+ * @param object $params event parameters
+ */
+ public function onRemove ($params)
+ {
+ $this->raiseEvent('OnRemove', $this, $params);
+ }
+
+ /**
+ * Raises the OnSort event
+ * @param object $params event parameters
+ */
+ public function onSort ($params)
+ {
+ $this->raiseEvent('OnSort', $this, $params);
+ }
+
+ /**
+ * Raises the OnStart event
+ * @param object $params event parameters
+ */
+ public function onStart ($params)
+ {
+ $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 OnUpdate event
+ * @param object $params event parameters
+ */
+ public function onUpdate ($params)
+ {
+ $this->raiseEvent('OnUpdate', $this, $params);
+ }
+
+ /**
+ * @var ITemplate template for repeater items
+ */
+ private $_repeater=null;
+
+ /**
+ * @param array data source for Sortables.
+ */
+ public function setDataSource($data)
+ {
+ $this->getSortables()->setDataSource($data);
+ }
+
+ /**
+ * Overrides parent implementation. Callback {@link renderSortables()} when
+ * page's IsCallback property is true.
+ */
+ public function dataBind()
+ {
+ parent::dataBind();
+ if($this->getPage()->getIsCallback())
+ $this->renderSortables($this->getResponse()->createHtmlWriter());
+ }
+
+ /**
+ * @return TRepeater suggestion list repeater
+ */
+ public function getSortables()
+ {
+ if($this->_repeater===null)
+ $this->_repeater = $this->createRepeater();
+ return $this->_repeater;
+ }
+
+ /**
+ * @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->getWidgetID().'">'));
+ $repeater->setFooterTemplate(new TJuiSortableTemplate('</ul>'));
+ $repeater->setItemTemplate(new TTemplate('<li id="<%# $this->ItemIndex %>"><%# $this->Data %></li>',null));
+ $repeater->setEmptyTemplate(new TJuiSortableTemplate('<ul></ul>'));
+ $this->getControls()->add($repeater);
+ return $repeater;
+ }
+}
+
+
+/**
+ * TJuiSortableTemplate class.
+ *
+ * TJuiSortableTemplate is the default template for TJuiSortableTemplate
+ * item template.
+ *
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @package System.Web.UI.ActiveControls
+ * @since 3.1
+ */
+class TJuiSortableTemplate extends TComponent implements ITemplate
+{
+ private $_template;
+
+ public function __construct($template)
+ {
+ $this->_template = $template;
+ }
+ /**
+ * Instantiates the template.
+ * It creates a {@link TDataList} control.
+ * @param TControl parent to hold the content within the template
+ */
+ public function instantiateIn($parent)
+ {
+ $parent->getControls()->add($this->_template);
+ }
+}