diff options
Diffstat (limited to 'framework/Web/UI')
-rw-r--r-- | framework/Web/UI/ActiveControls/TActiveControlAdapter.php | 20 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TActiveImageButton.php | 12 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TActiveListBox.php | 6 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TActivePageAdapter.php | 2 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TBaseActiveControl.php | 3 | ||||
-rw-r--r-- | framework/Web/UI/ActiveControls/TCallbackClientScript.php | 441 | ||||
-rw-r--r-- | framework/Web/UI/TClientScriptManager.php | 24 | ||||
-rw-r--r-- | framework/Web/UI/TControl.php | 10 | ||||
-rw-r--r-- | framework/Web/UI/TPage.php | 34 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TDatePicker.php | 8 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TJavascriptLogger.php | 2 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TRadioButton.php | 10 | ||||
-rw-r--r-- | framework/Web/UI/WebControls/TSlider.php | 2 |
13 files changed, 308 insertions, 266 deletions
diff --git a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php index ab15f091..6c209ac5 100644 --- a/framework/Web/UI/ActiveControls/TActiveControlAdapter.php +++ b/framework/Web/UI/ActiveControls/TActiveControlAdapter.php @@ -89,7 +89,6 @@ class TActiveControlAdapter extends TControlAdapter public function render($writer) { $this->getPage()->getClientScript()->registerPradoScript('ajax'); - $this->renderCallbackClientScripts(); if($this->_control->getVisible(false)) { parent::render($writer); @@ -99,25 +98,6 @@ class TActiveControlAdapter extends TControlAdapter } /** - * Register the callback clientscripts and sets the post loader IDs. - */ - protected function renderCallbackClientScripts() - { - $cs = $this->getPage()->getClientScript(); - $key = 'Prado.CallbackRequest.addPostLoaders'; - if(!$cs->isEndScriptRegistered($key)) - { - $data = $this->getPage()->getPostDataLoaders(); - if(count($data) > 0) - { - $options = TJavaScript::encode($data,false); - $script = "Prado.CallbackRequest.addPostLoaders({$options});"; - $cs->registerEndScript($key, $script); - } - } - } - - /** * @param TBaseActiveControl change base active control */ public function setBaseActiveControl($control) diff --git a/framework/Web/UI/ActiveControls/TActiveImageButton.php b/framework/Web/UI/ActiveControls/TActiveImageButton.php index b2aa9960..8fe5e33d 100644 --- a/framework/Web/UI/ActiveControls/TActiveImageButton.php +++ b/framework/Web/UI/ActiveControls/TActiveImageButton.php @@ -135,18 +135,6 @@ class TActiveImageButton extends TImageButton implements IActiveControl, ICallba } /** - * Register the x and y hidden input names of the position clicked. - * @param THtmlWriter the renderer. - */ - public function onPreRender($writer) - { - parent::onPreRender($writer); - $uid = $uid=$this->getUniqueID(); - $this->getPage()->registerPostDataLoader($uid.'_x'); - $this->getPage()->registerPostDataLoader($uid.'_y'); - } - - /** * Ensure that the ID attribute is rendered and registers the javascript code * for initializing the active control. */ diff --git a/framework/Web/UI/ActiveControls/TActiveListBox.php b/framework/Web/UI/ActiveControls/TActiveListBox.php index dfb4bf6e..913cdeda 100644 --- a/framework/Web/UI/ActiveControls/TActiveListBox.php +++ b/framework/Web/UI/ActiveControls/TActiveListBox.php @@ -95,8 +95,6 @@ class TActiveListBox extends TListBox implements IActiveControl, ICallbackEventH $client = $this->getPage()->getCallbackClient(); $client->setAttribute($this, 'multiple', $multiple ? 'multiple' : false); $client->setAttribute($this, 'name', $multiple ? $multi_id : $id); - if($multiple) - $client->addPostDataLoader($multi_id); } } @@ -130,10 +128,6 @@ class TActiveListBox extends TListBox implements IActiveControl, ICallbackEventH { parent::onPreRender($param); $this->getAdapter()->updateListItems(); - $multiple = $this->getIsMultiSelect(); - $id = $this->getUniqueID(); $multi_id = $id.'[]'; - if($multiple) - $this->getPage()->registerPostDataLoader($multi_id); } /** diff --git a/framework/Web/UI/ActiveControls/TActivePageAdapter.php b/framework/Web/UI/ActiveControls/TActivePageAdapter.php index 03fe2f16..c594ed42 100644 --- a/framework/Web/UI/ActiveControls/TActivePageAdapter.php +++ b/framework/Web/UI/ActiveControls/TActivePageAdapter.php @@ -198,7 +198,7 @@ class TActivePageAdapter extends TControlAdapter if($this->getPage()->getClientScript()->hasEndScripts()) { $writer = $response->createHtmlWriter(); - $this->getPage()->getClientScript()->renderEndScripts($writer); + $this->getPage()->getClientScript()->renderEndScriptsCallback($writer); $this->getPage()->getCallbackClient()->evaluateScript($writer); } diff --git a/framework/Web/UI/ActiveControls/TBaseActiveControl.php b/framework/Web/UI/ActiveControls/TBaseActiveControl.php index 61230719..f4daec02 100644 --- a/framework/Web/UI/ActiveControls/TBaseActiveControl.php +++ b/framework/Web/UI/ActiveControls/TBaseActiveControl.php @@ -332,6 +332,9 @@ class TBaseActiveCallbackControl extends TBaseActiveControl $options['CausesValidation']= $validate ? '' : false; $options['ValidationGroup']=$this->getValidationGroup(); $options['CallbackParameter'] = $this->getCallbackParameter(); + // needed for TCallback + if(!isset($options['EventTarget'])) + $options['EventTarget'] = $this->getControl()->getUniqueID(); return $options; } diff --git a/framework/Web/UI/ActiveControls/TCallbackClientScript.php b/framework/Web/UI/ActiveControls/TCallbackClientScript.php index 40051f76..96c8d38e 100644 --- a/framework/Web/UI/ActiveControls/TCallbackClientScript.php +++ b/framework/Web/UI/ActiveControls/TCallbackClientScript.php @@ -17,7 +17,7 @@ * executed on the client-side (i.e. the browser client that is viewing * the page) during a callback response. * - * The avaiable methods includes setting/clicking input elements, changing Css + * The available methods includes setting/clicking input elements, changing Css * styles, hiding/showing elements, and adding visual effects to elements on the * page. The client-side methods can be access through the CallbackClient * property available in TPage. @@ -27,7 +27,33 @@ * $this->getPage()->getCallbackClient()->hide($myTextBox); * </code> * - * @author Wei Zhuo <weizhuo[at]gamil[dot]com> + * To call a specific jQuery method on an element, use the {@link jQuery} method: + * <code> + * // simple example: focus a textbox + * $this->getCallbackClient()->jQuery($myTextBox, 'focus'); + * + * // complex example: resize a textbox using an animation + * $this->getCallbackClient()->jQuery($myTextBox, 'animate', array( + * array( 'width' => '+=100', + * 'height' => '+=50' + * ), + * array('duration' => 1000) + * )); + * </code> + * + * To call a jQueryUI effect on an element, use the {@link juiEffect} method: + * <code> + * // simple example: focus a textbox + * $this->getCallbackClient()->juiEffect($myTextBox, 'highlight'); + * </code> + * + * In order to use the jQueryUI effects, the jqueryui script must be registered: + * <code> + * $this->getPage()->getClientScript()->registerPradoScript('jqueryui'); + * </code> + * + * @author Wei Zhuo <weizhuo[at]gmail[dot]com> + * @author Fabio Bas <ctrlaltca[at]gmail[dot]com> * @version $Id: TCallbackClientScript.php 3245 2013-01-07 20:23:32Z ctrlaltca $ * @package System.Web.UI.ActiveControls * @since 3.1 @@ -61,27 +87,48 @@ class TCallbackClientScript extends TApplicationComponent * @param string javascript function name * @param array list of arguments for the function */ - public function callClientFunction($function, $params=null) + public function callClientFunction($function, $params=array()) { if(!is_array($params)) $params = array($params); if(count($params) > 0) { - if($params[0] instanceof TControl) + if ($params[0] instanceof ISurroundable) + $params[0] = $params[0]->getSurroundingTagID(); + elseif($params[0] instanceof TControl) $params[0] = $params[0]->getClientID(); } $this->_actions->add(array($function => $params)); } /** + * Executes a jQuery client-side method over an element. + * @param string control or element id + * @param string jQuery method name + * @param array list of arguments for the function + */ + public function jQuery($element, $method, $params=array()) + { + if ($element instanceof ISurroundable) + $element = $element->getSurroundingTagID(); + elseif($element instanceof TControl) + $element = $element->getClientID(); + + if(!is_array($params)) + $params = array($params); + + $this->_actions->add(array('Prado.Element.j' => array($element, $method, $params))); + } + + /** * Client script to set the value of a particular input element. * @param TControl control element to set the new value * @param string new value */ public function setValue($input, $text) { - $this->callClientFunction('Prado.Element.setValue', array($input, $text)); + $this->jQuery($input, 'val', $text); } /** @@ -106,6 +153,11 @@ class TCallbackClientScript extends TApplicationComponent 'Value', 'Index', 'Clear', 'Indices', 'Values', 'All', 'Invert'); $type = ($type===null) ? $this->getSelectionControlType($control) : $type; $total = $this->getSelectionControlIsListType($control) ? $control->getItemCount() : 1; + + // pass the ID to avoid getting the surrounding elements (ISurroundable) + if($control instanceof TControl) + $control = $control->getClientID(); + $this->callClientFunction('Prado.Element.select', array($control, $type.$method, $value, $total)); } @@ -132,7 +184,7 @@ class TCallbackClientScript extends TApplicationComponent */ public function click($control) { - $this->callClientFunction('Prado.Element.click', $control); + $this->jQuery($control, 'trigger', 'click'); } /** @@ -152,8 +204,7 @@ class TCallbackClientScript extends TApplicationComponent */ public function raiseClientEvent($control, $eventName) { - $this->callClientFunction('Event.fireEvent', - array($control, strtolower($eventName))); + $this->jQuery($control, 'trigger', $eventName); } /** @@ -164,9 +215,9 @@ class TCallbackClientScript extends TApplicationComponent */ public function setAttribute($control, $name, $value) { - // Attributes should be applied on Surrounding tag, except for 'disabled' attribute + // Attributes should be applied on Surrounding tag, except for 'disabled' attribute if ($control instanceof ISurroundable && strtolower($name)!=='disabled') - $control=$control->getSurroundingTagID(); + $control=$control->getSurroundingTagID(); $this->callClientFunction('Prado.Element.setAttribute',array($control, $name, $value)); } @@ -206,9 +257,7 @@ class TCallbackClientScript extends TApplicationComponent */ public function show($element) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->callClientFunction('Element.show', $element); + $this->jQuery($element, 'show'); } /** @@ -217,22 +266,33 @@ class TCallbackClientScript extends TApplicationComponent */ public function hide($element) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->callClientFunction('Element.hide', $element); + $this->jQuery($element, 'hide'); } /** * Toggles the visibility of the element. * @param TControl control element or element id - * @param string visual effect, such as, 'appear' or 'slide' or 'blind'. + * @param string visual effect, such as, 'fade' or 'slide'. * @param array additional options. */ public function toggle($element, $effect=null, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->callClientFunction('Element.toggle', array($element,$effect,$options)); + switch(strtolower($effect)) + { + case 'fade': + $method='fadeToggle'; + break; + case 'slide': + $method='slideToggle'; + break; + default: + $method='toggle'; + // avoid fancy effect by default + if(!array_key_exists('duration', $options)) + $options['duration']=0; + break; + } + $this->jQuery($element, $method, $options); } /** @@ -241,14 +301,7 @@ class TCallbackClientScript extends TApplicationComponent */ public function remove($element) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->callClientFunction('Element.remove', $element); - } - - public function addPostDataLoader($name) - { - $this->callClientFunction('Prado.CallbackRequest.addPostLoaders', $name); + $this->jQuery($element, 'remove'); } /** @@ -259,9 +312,7 @@ class TCallbackClientScript extends TApplicationComponent */ public function update($element, $content) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->replace($element, $content, 'Element.update'); + $this->jQuery($element, 'html', $content); } /** @@ -271,9 +322,7 @@ class TCallbackClientScript extends TApplicationComponent */ public function addCssClass($element, $cssClass) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->callClientFunction('Element.addClassName', array($element, $cssClass)); + $this->jQuery($element, 'addClass', $cssClass); } /** @@ -283,31 +332,19 @@ class TCallbackClientScript extends TApplicationComponent */ public function removeCssClass($element, $cssClass) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->callClientFunction('Element.removeClassName', array($element, $cssClass)); + $this->jQuery($element, 'removeClass', $cssClass); } /** - * Sets the CssClass of an element. - * @param TControl control element or element id - * @param string new CssClass name for the element. - */ - /*public function setCssClass($element, $cssClass) - { - $this->callClientFunction('Prado.Element.CssClass.set', array($element, $cssClass)); - }*/ - - /** * Scroll the top of the browser viewing area to the location of the * element. + * * @param TControl control element or element id + * @param array additional options: 'duration' in ms, 'offset' from the top in pixels */ - public function scrollTo($element) + public function scrollTo($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->callClientFunction('Element.scrollTo', $element); + $this->callClientFunction('Prado.Element.scrollTo', array($element, $options)); } /** @@ -316,7 +353,7 @@ class TCallbackClientScript extends TApplicationComponent */ public function focus($element) { - $this->callClientFunction('Prado.Element.focus', $element); + $this->jQuery($element, 'trigger', 'focus'); } /** @@ -327,9 +364,7 @@ class TCallbackClientScript extends TApplicationComponent */ public function setStyle($element, $styles) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->callClientFunction('Prado.Element.setStyle', array($element, $styles)); + $this->jQuery($element, 'css', array($styles)); } /** @@ -339,9 +374,7 @@ class TCallbackClientScript extends TApplicationComponent */ public function appendContent($element, $content) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->replace($element, $content, 'Prado.Element.Insert.append'); + $this->jQuery($element, 'append', $content); } /** @@ -351,9 +384,7 @@ class TCallbackClientScript extends TApplicationComponent */ public function prependContent($element, $content) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->replace($element, $content, 'Prado.Element.Insert.prepend'); + $this->jQuery($element, 'prepend', $content); } /** @@ -363,9 +394,7 @@ class TCallbackClientScript extends TApplicationComponent */ public function insertContentAfter($element, $content) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->replace($element, $content, 'Prado.Element.Insert.after'); + $this->jQuery($element, 'after', $content); } /** @@ -375,9 +404,7 @@ class TCallbackClientScript extends TApplicationComponent */ public function insertContentBefore($element, $content) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->replace($element, $content, 'Prado.Element.Insert.before'); + $this->jQuery($element, 'before', $content); } /** @@ -387,15 +414,13 @@ class TCallbackClientScript extends TApplicationComponent * will be used for replacement. * @param TControl control element or HTML element id. * @param string HTML fragement or the control to be rendered - * @param string replacement method, default is to replace the outter - * html content. * @param string provide a custom boundary. * @see insertAbout * @see insertBelow * @see insertBefore * @see insertAfter */ - protected function replace($element, $content, $method="Element.replace", $boundary=null) + protected function replace($element, $content, $boundary=null) { if($content instanceof TControl) { @@ -408,8 +433,7 @@ class TCallbackClientScript extends TApplicationComponent $content = null; } - $this->callClientFunction('Prado.Element.replace', - array($element, $method, $content, $boundary)); + $this->callClientFunction('Prado.Element.replace', array($element, $content, $boundary)); } /** @@ -419,8 +443,6 @@ class TCallbackClientScript extends TApplicationComponent */ public function replaceContent($element,$content) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); $this->replace($element, $content); } @@ -430,7 +452,16 @@ class TCallbackClientScript extends TApplicationComponent */ public function evaluateScript($writer) { - $this->replace(null, $writer, 'Prado.Element.evaluateScript'); + if($writer instanceof THtmlWriter) + { + $boundary = $this->getResponseContentBoundary($writer); + $content = null; + } else { + $boundary = null; + $content = $writer; + } + + $this->callClientFunction('Prado.Element.evaluateScript', array($content, $boundary)); } /** @@ -445,7 +476,7 @@ class TCallbackClientScript extends TApplicationComponent { $boundary = $this->getRenderedContentBoundary($content); } - else if($content instanceof THtmlWriter) + elseif($content instanceof THtmlWriter) { $boundary = $this->getResponseContentBoundary($content); } @@ -483,223 +514,311 @@ class TCallbackClientScript extends TApplicationComponent return null; } + /* VISUAL EFFECTS */ + /** * Add a visual effect the element. * @param string visual effect function name. * @param TControl control element or element id * @param array visual effect key-value pair options. */ - public function visualEffect($type, $element, $options=null) + public function visualEffect($type, $element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->callClientFunction($type, array($element, $options)); + $this->jQuery($element, $type, $options); } + /* BASIC EFFECTS (JQUERY CORE) */ + /** * Visual Effect: Gradually make the element appear. + * This effect doesn't need jQueryUI. + * @param TControl control element or element id + * @param array visual effect key-value pair options. + */ + public function fadeIn($element, $options=array()) + { + $this->visualEffect('fadeIn', $element, $options); + } + + /** + * Visual Effect: Gradually fade the element. + * This effect doesn't need jQueryUI. + * @param TControl control element or element id + * @param array visual effect key-value pair options. + */ + public function fadeOut($element, $options=array()) + { + $this->visualEffect('fadeOut', $element, $options); + } + + /** + * Set the opacity on a html element or control. + * This effect doesn't need jQueryUI. + * @param TControl control element or element id + * @param float opacity value between 1 and 0 + */ + public function fadeTo($element, $value, $duration=500) + { + $value = TPropertyValue::ensureFloat($value); + $this->visualEffect('fadeTo', $element, array($duration, $value)); + } + + /** + * Visual Effect: Slide down. + * This effect doesn't need jQueryUI. * @param TControl control element or element id * @param array visual effect key-value pair options. */ - public function appear($element, $options=null) + public function slideDown($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->visualEffect('Effect.Appear', $element, $options); + $this->visualEffect('slideDown', $element, $options); } /** - * Visual Effect: Blind down. + * Visual Effect: Slide up. + * This effect doesn't need jQueryUI. * @param TControl control element or element id * @param array visual effect key-value pair options. */ - public function blindDown($element, $options=null) + public function slideUp($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->visualEffect('Effect.BlindDown', $element, $options); + $this->visualEffect('slideUp', $element, $options); } + /* OLD METHODS, DEPRECATED, BACKWARDS-COMPATIBILITY */ + /** - * Visual Effect: Blind up. + * Alias of fadeIn() + * @deprecated since 3.4 * @param TControl control element or element id * @param array visual effect key-value pair options. */ - public function blindUp($element, $options=null) + public function appear($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->visualEffect('Effect.BlindUp', $element, $options); + $this->fadeIn($element, $options); + } + /** + * Alias of fadeOut() + * @deprecated since 3.4 + * @param TControl control element or element id + * @param array visual effect key-value pair options. + */ + public function fade($element, $options=array()) + { + $this->fadeOut($element, $options); } /** - * Visual Effect: Drop out. + * Alias of fadeTo() + * @deprecated since 3.4 + * @param TControl control element or element id + * @param float opacity value between 1 and 0 + */ + public function setOpacity($element, $value) + { + $this->fadeTo($element, $value); + } + + /* JQUERY UI EFFECTS */ + + /** + * Add a jQuery-ui effect the element. + * This method needs jQueryUI. + * @param string visual effect function name. + * @param TControl control element or element id + * @param array effect options. + */ + public function juiEffect($element, $effect, $options=array()) + { + $options['effect']=$effect; + $this->jQuery($element, 'effect', array($options)); + } + + /** + * Visual Effect: Blind. + * This effect needs jQueryUI. * @param TControl control element or element id * @param array visual effect key-value pair options. */ - public function dropOut($element, $options=null) + public function blind($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->visualEffect('Effect.DropOut', $element, $options); + $this->juiEffect($element, 'blind', $options); } /** - * Visual Effect: Gradually fade the element. + * Visual Effect: Drop out. + * This effect needs jQueryUI. * @param TControl control element or element id * @param array visual effect key-value pair options. */ - public function fade($element, $options=null) + public function drop($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->visualEffect('Effect.Fade', $element, $options); + $this->juiEffect($element, 'drop', $options); } /** * Visual Effect: Fold. + * This effect needs jQueryUI. * @param TControl control element or element id * @param array visual effect key-value pair options. */ - public function fold($element, $options = null) + public function fold($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->visualEffect('Effect.Fold', $element, $options); + $this->juiEffect($element, 'fold', $options); } /** * Visual Effect: Gradually make an element grow to a predetermined size. + * This effect needs jQueryUI. * @param TControl control element or element id * @param array visual effect key-value pair options. */ - public function grow($element, $options=null) + public function size($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->visualEffect('Effect.Grow', $element, $options); + $this->juiEffect($element, 'size', $options); } /** * Visual Effect: Gradually grow and fade the element. + * This effect needs jQueryUI. * @param TControl control element or element id * @param array visual effect key-value pair options. */ - public function puff($element, $options=null) + public function puff($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->visualEffect('Effect.Puff', $element, $options); + $this->juiEffect($element, 'puff', $options); } /** * Visual Effect: Pulsate. + * This effect needs jQueryUI. * @param TControl control element or element id * @param array visual effect key-value pair options. */ - public function pulsate($element, $options=null) + public function pulsate($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->visualEffect('Effect.Pulsate', $element, $options); + $this->juiEffect($element, 'pulsate', $options); } /** * Visual Effect: Shake the element. + * This effect needs jQueryUI. * @param TControl control element or element id * @param array visual effect key-value pair options. */ - public function shake($element, $options=null) + public function shake($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->visualEffect('Effect.Shake', $element, $options); + $this->juiEffect($element, 'shake', $options); } /** - * Visual Effect: Shrink the element. + * Visual Effect: Scale the element. + * This effect needs jQueryUI. * @param TControl control element or element id * @param array visual effect key-value pair options. */ - public function shrink($element, $options=null) + public function scale($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->visualEffect('Effect.Shrink', $element, $options); + $this->juiEffect($element, 'scale', $options); } /** - * Visual Effect: Slide down. + * Visual Effect: High light the element for about 2 seconds. + * This effect needs jQueryUI. * @param TControl control element or element id * @param array visual effect key-value pair options. */ - public function slideDown($element, $options=null) + public function highlight($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->visualEffect('Effect.SlideDown', $element, $options); + $this->juiEffect($element, 'highlight', $options); } + /* jui - OLD METHODS, DEPRECATED, BACKWARDS-COMPATIBILITY */ + /** - * Visual Effect: Side up. + * Alias of blind(), presets the direction to 'down' + * @deprecated since 3.4 * @param TControl control element or element id * @param array visual effect key-value pair options. */ - public function slideUp($element, $options=null) + public function blindDown($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->visualEffect('Effect.SlideUp', $element, $options); + $options['direction']='down'; + $this->blind($element, $options); } /** - * Visual Effect: Squish the element. + * Alias of blind(), presets the direction to 'up' + * @deprecated since 3.4 * @param TControl control element or element id * @param array visual effect key-value pair options. */ - public function squish($element, $options=null) + public function blindUp($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->visualEffect('Effect.Squish', $element, $options); + $options['direction']='up'; + $this->blind($element, $options); } /** - * Visual Effect: Switch Off effect. + * Alias of drop() + * @deprecated since 3.4 * @param TControl control element or element id * @param array visual effect key-value pair options. */ - public function switchOff($element, $options=null) + public function dropOut($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->visualEffect('Effect.SwitchOff', $element, $options); + $this->drop($element, $options); } /** - * Visual Effect: High light the element for about 2 seconds. + * Alias of size() + * @deprecated since 3.4 * @param TControl control element or element id * @param array visual effect key-value pair options. */ - public function highlight($element, $options=null) + public function grow($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $this->visualEffect('Prado.Effect.Highlight', $element, $options); + $this->size($element, $options); } /** - * Set the opacity on a html element or control. + * Alias of scale() + * @deprecated since 3.4 * @param TControl control element or element id - * @param float opacity value between 1 and 0 + * @param array visual effect key-value pair options. */ - public function setOpacity($element, $value) + public function shrink($element, $options=array()) { - if ($element instanceof ISurroundable) - $element=$element->getSurroundingTagID(); - $value = TPropertyValue::ensureFloat($value); - $this->callClientFunction('Element.setOpacity', array($element,$value)); + $options['percent']=0; + $this->scale($element, $options); } + + /** + * Alias of scale() + * @deprecated since 3.4 + * @param TControl control element or element id + * @param array visual effect key-value pair options. + */ + public function squish($element, $options=array()) + { + $options['origin']=array('top', 'left'); + $options['percent']=0; + $this->scale($element, $options); + } + + /** + * Alias of scale() + * @deprecated since 3.4 + * @param TControl control element or element id + * @param array visual effect key-value pair options. + */ + public function switchOff($element, $options=array()) + { + $options['direction']='vertical'; + $options['percent']=0; + $this->scale($element, $options); + } + } diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index ea828187..a9f6c5b4 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -286,8 +286,6 @@ class TClientScriptManager extends TApplicationComponent $code="new {$class}({$optionString});"; $this->_endScripts[sprintf('%08X', crc32($code))]=$code; - $this->_hiddenFields[TPage::FIELD_POSTBACK_TARGET]=''; - $this->_hiddenFields[TPage::FIELD_POSTBACK_PARAMETER]=''; $this->registerPradoScriptInternal('prado'); $params=func_get_args(); @@ -315,7 +313,6 @@ class TClientScriptManager extends TApplicationComponent $code = "new Prado.WebUI.DefaultButton($options);"; $this->_endScripts['prado:'.$panelID]=$code; - $this->_hiddenFields[TPage::FIELD_POSTBACK_TARGET]=''; $this->registerPradoScriptInternal('prado'); $params=array($panelID,$buttonID); @@ -343,11 +340,10 @@ class TClientScriptManager extends TApplicationComponent */ public function registerFocusControl($target) { - $this->registerPradoScriptInternal('effects'); + $this->registerPradoScriptInternal('jquery'); if($target instanceof TControl) $target=$target->getClientID(); - $id = TJavaScript::quoteString($target); - $this->_endScripts['prado:focus'] = 'new Effect.ScrollTo('.$id.'); Prado.Element.focus('.$id.');'; + $this->_endScripts['prado:focus'] = 'new Prado.Element.scrollTo(\''.$target.'\'); jQuery(\'#'.$target.'\').focus();'; $params=func_get_args(); $this->_page->registerCachingAction('Page.ClientScript','registerFocusControl',$params); @@ -700,6 +696,22 @@ class TClientScriptManager extends TApplicationComponent $writer->write(TJavaScript::renderScriptBlocks($this->_endScripts)); } + /** + * @param THtmlWriter writer for the rendering purpose + */ + public function renderBeginScriptsCallback($writer) + { + $writer->write(TJavaScript::renderScriptBlocksCallback($this->_beginScripts)); + } + + /** + * @param THtmlWriter writer for the rendering purpose + */ + public function renderEndScriptsCallback($writer) + { + $writer->write(TJavaScript::renderScriptBlocksCallback($this->_endScripts)); + } + public function renderHiddenFieldsBegin($writer) { $this->renderHiddenFieldsInt($writer,true); diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index 5ee20d61..cbc6a409 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -1330,21 +1330,11 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable $control->evaluateDynamicContent(); } } - $this->addToPostDataLoader(); } $this->_stage=self::CS_PRERENDERED; } /** - * Add controls implementing IPostBackDataHandler to post data loaders. - */ - protected function addToPostDataLoader() - { - if($this instanceof IPostBackDataHandler) - $this->getPage()->registerPostDataLoader($this); - } - - /** * Performs the Unload step for the control and all its child controls. * Only framework developers should use this method. */ diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php index 39656e13..394229da 100644 --- a/framework/Web/UI/TPage.php +++ b/framework/Web/UI/TPage.php @@ -155,10 +155,6 @@ class TPage extends TTemplateControl */ private $_clientState=''; /** - * @var array post data loader IDs. - */ - protected $_postDataLoaders=array(); - /** * @var boolean true if loading post data. */ protected $_isLoadingPostData=false; @@ -427,27 +423,6 @@ class TPage extends TTemplateControl } /** - * Register post data loaders for Callback to collect post data. - * This method should only be called by framework developers. - * @param TControl control that requires post data. - * @see TControl::preRenderRecursive(); - */ - public function registerPostDataLoader($control) - { - $id=is_string($control)?$control:$control->getUniqueID(); - $this->_postDataLoaders[$id] = true; - } - - /** - * Get a list of IDs of controls that are enabled and require post data. - * @return array list of IDs implementing IPostBackDataHandler - */ - public function getPostDataLoaders() - { - return array_keys($this->_postDataLoaders); - } - - /** * @return TForm the form on the page */ public function getForm() @@ -825,7 +800,6 @@ class TPage extends TTemplateControl { $id=is_string($control)?$control:$control->getUniqueID(); $this->_controlsRegisteredForPostData[$id]=true; - $this->registerPostDataLoader($id); $params=func_get_args(); foreach($this->getCachingStack() as $item) $item->registerAction('Page','registerRequiresPostData',array($id)); @@ -1301,9 +1275,9 @@ class TPageStateFormatter { $sm=$page->getApplication()->getSecurityManager(); if($page->getEnableStateValidation()) - $str=$sm->hashData(Prado::serialize($data)); + $str=$sm->hashData(serialize($data)); else - $str=Prado::serialize($data); + $str=serialize($data); if($page->getEnableStateCompression() && extension_loaded('zlib')) $str=gzcompress($str); if($page->getEnableStateEncryption()) @@ -1331,10 +1305,10 @@ class TPageStateFormatter if($page->getEnableStateValidation()) { if(($str=$sm->validateData($str))!==false) - return Prado::unserialize($str); + return unserialize($str); } else - return Prado::unserialize($str); + return unserialize($str); } return null; } diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php index 0e8d7bda..275fc557 100644 --- a/framework/Web/UI/WebControls/TDatePicker.php +++ b/framework/Web/UI/WebControls/TDatePicker.php @@ -406,14 +406,6 @@ class TDatePicker extends TTextBox public function onPreRender($param) { parent::onPreRender($param); - if($this->getInputMode() === TDatePickerInputMode::DropDownList) - { - $page = $this->getPage(); - $uniqueID = $this->getUniqueID(); - $page->registerPostDataLoader($uniqueID.TControl::ID_SEPARATOR.'day'); - $page->registerPostDataLoader($uniqueID.TControl::ID_SEPARATOR.'month'); - $page->registerPostDataLoader($uniqueID.TControl::ID_SEPARATOR.'year'); - } $this->publishCalendarStyle(); $this->registerCalendarClientScriptPre(); } diff --git a/framework/Web/UI/WebControls/TJavascriptLogger.php b/framework/Web/UI/WebControls/TJavascriptLogger.php index a2f1c1c2..2af8bda6 100644 --- a/framework/Web/UI/WebControls/TJavascriptLogger.php +++ b/framework/Web/UI/WebControls/TJavascriptLogger.php @@ -70,7 +70,7 @@ class TJavascriptLogger extends TWebControl { $key = strtolower($this->getToggleKey()); $code = isset(self::$_keyCodes[$key]) ? self::$_keyCodes[$key] : 74; - $js = "var logConsole; Event.OnLoad(function() { logConsole = new LogConsole($code)}); "; + $js = "var logConsole; jQuery(function() { logConsole = new LogConsole($code)}); "; $cs = $this->getPage()->getClientScript(); $cs->registerBeginScript($this->getClientID(),$js); $cs->registerPradoScript('logger'); diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php index 144704b4..dbb0dac0 100644 --- a/framework/Web/UI/WebControls/TRadioButton.php +++ b/framework/Web/UI/WebControls/TRadioButton.php @@ -156,16 +156,6 @@ class TRadioButton extends TCheckBox } /** - * Add the group name as post data loader if group name is set. - */ - protected function addToPostDataLoader() - { - parent::addToPostDataLoader(); - $group = $this->getGroupName(); - if(!empty($group) || $this->getViewState('UniqueGroupName','') !== '') - $this->getPage()->registerPostDataLoader($this->getUniqueGroupName()); - } - /** * @return string the name used to fetch radiobutton post data */ public function getUniqueGroupName() diff --git a/framework/Web/UI/WebControls/TSlider.php b/framework/Web/UI/WebControls/TSlider.php index dcf34bfc..a07c995f 100644 --- a/framework/Web/UI/WebControls/TSlider.php +++ b/framework/Web/UI/WebControls/TSlider.php @@ -457,7 +457,7 @@ class TSlider extends TWebControl implements IPostBackDataHandler, IDataRenderer $options['axis'] = strtolower($this->getDirection()); $options['maximum'] = $maxValue; $options['minimum'] = $minValue; - $options['range'] = TJavascript::quoteJsLiteral('$R('.$minValue.",".$maxValue.")"); + $options['range'] = array($minValue, $maxValue); $options['sliderValue'] = $this->getValue(); $options['disabled'] = !$this->getEnabled(); $values=$this->getValues(); |