From e33efebbe5971909226d18b24d2b7030d3772665 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 5 Jan 2014 22:44:09 +0100 Subject: Re-enable prototype-based scripts, and enable old drag&drop controls --- .../pages/ActiveControls/Samples/DragDrop/Home.php | 35 +++++----- framework/Web/Javascripts/packages.php | 80 ++++++++++++---------- .../source/prado/activecontrols/dragdrop.js | 12 ++-- framework/Web/UI/ActiveControls/TDropContainer.php | 54 +++++++-------- 4 files changed, 96 insertions(+), 85 deletions(-) diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.php index 30ef750b..7d3163dc 100755 --- a/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.php +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.php @@ -9,12 +9,12 @@ class Home extends TPage parent::onInit($param); if (!$this->getIsPostBack() && !$this->getIsCallBack()) { - + $this->populateProductList(); $this->populateShoppingList(); } } - + private function getProductData () { return array ( @@ -30,38 +30,41 @@ class Home extends TPage ) ); } - + private function getProduct ($key) { foreach ($this->getProductData() as $product) if ($product['ProductId']==$key) return $product; - return null; + return null; } - + protected function populateProductList () { $this->ProductList->DataSource=$this->getProductData(); $this->ProductList->Databind(); } - + protected function populateShoppingList () { $this->ShoppingList->DataSource=$this->getShoppingListData(); $this->ShoppingList->Databind(); - + } - - + + public function getShoppingListData () { + $a=$this->getViewState('ShoppingList', array ()); + var_export($a); return $this->getViewState('ShoppingList', array ()); } - + public function setShoppingListData ($value) { + var_export($value); $this->setViewState('ShoppingList', TPropertyValue::ensureArray($value), array ()); } - + public function addItemToCart ($sender, $param) { $control=$param->getDroppedControl(); @@ -82,9 +85,9 @@ class Home extends TPage $shoppingList[$key]['ProductCount']=1; } $this->setShoppingListData($shoppingList); - + } - + public function removeItemFromCart ($sender, $param) { $control=$param->getDroppedControl(); @@ -99,13 +102,13 @@ class Home extends TPage unset($shoppingList[$key]); } $this->setShoppingListData($shoppingList); - + } - + public function redrawCart ($sender, $param) { $this->populateShoppingList(); $this->cart->render($param->NewWriter); - + } } diff --git a/framework/Web/Javascripts/packages.php b/framework/Web/Javascripts/packages.php index 8223ecba..a86ac3c0 100644 --- a/framework/Web/Javascripts/packages.php +++ b/framework/Web/Javascripts/packages.php @@ -9,11 +9,7 @@ if (!defined('SCRIPTACULOUS_DIR')) define ('SCRIPTACULOUS_DIR', 'scriptaculous-1 //package names and its contents (files relative to the current directory) $packages = array( - 'prototype' => array( - PROTOTYPE_DIR.'/prototype.js', - SCRIPTACULOUS_DIR.'/builder.js', - SCRIPTACULOUS_DIR.'/effects.js' - ), + // base prado scripts 'prado' => array( 'prado/prado.js', 'prado/controls/controls.js' @@ -40,15 +36,6 @@ $packages = array( 'prado/activecontrols/activecontrols3.js', ), - 'dragdrop'=>array( - SCRIPTACULOUS_DIR.'/dragdrop.js', - 'prado/activecontrols/dragdrop.js' - ), - - 'dragdropextra'=>array( - 'prado/activecontrols/dragdropextra.js', - ), - 'slider'=>array( 'prado/controls/slider.js' ), @@ -60,19 +47,15 @@ $packages = array( 'tabpanel'=>array( 'prado/controls/tabpanel.js' ), - + 'activedatepicker' => array( 'prado/activecontrols/activedatepicker.js' ), - + 'activefileupload' => array( 'prado/activefileupload/activefileupload.js' ), - 'accordion'=>array( - 'prado/controls/accordion.js' - ), - 'htmlarea'=>array( 'prado/controls/htmlarea.js' ), @@ -81,14 +64,6 @@ $packages = array( 'prado/controls/htmlarea4.js' ), - 'ratings' => array( - 'prado/ratings/ratings.js', - ), - - 'inlineeditor' => array( - 'prado/activecontrols/inlineeditor.js' - ), - // jquery 'jquery' => array( JQUERY_DIR.'/jquery.js', @@ -98,12 +73,43 @@ $packages = array( JQUERY_DIR.'/jquery-ui-i18n.min.js', ), + // prototype + scriptaculous + 'prototype' => array( + PROTOTYPE_DIR.'/prototype.js', + SCRIPTACULOUS_DIR.'/builder.js', + SCRIPTACULOUS_DIR.'/effects.js' + ), + + 'dragdrop'=>array( + SCRIPTACULOUS_DIR.'/dragdrop.js', + 'prado/activecontrols/dragdrop.js' + ), + + 'dragdropextra'=>array( + 'prado/activecontrols/dragdropextra.js', + ), + + 'accordion'=>array( + 'prado/controls/accordion.js' + ), + + 'ratings' => array( + 'prado/ratings/ratings.js', + ), + + 'inlineeditor' => array( + 'prado/activecontrols/inlineeditor.js' + ), + + 'autocomplete' => array( + SCRIPTACULOUS_DIR.'/controls.js', + 'prado/activecontrols/autocomplete.js' + ), ); //package names and their dependencies $dependencies = array( - 'prototype' => array('prototype'), 'jquery' => array('jquery'), 'prado' => array('jquery', 'prado'), 'validator' => array('jquery', 'prado', 'validator'), @@ -119,15 +125,15 @@ $dependencies = array( 'htmlarea4' => array('jquery', 'prado', 'htmlarea4'), 'keyboard' => array('jquery', 'prado', 'keyboard'), 'slider' => array('jquery', 'prado', 'slider'), - 'dragdrop' => array(), -/* - 'dragdrop' => array('prototype', 'prado', 'effects', 'ajax', 'dragdrop'), - 'dragdropextra' => array('prototype', 'prado', 'effects', 'ajax', 'dragdrop','dragdropextra'), - 'accordion' => array('prototype', 'prado', 'effects', 'accordion'), - 'ratings' => array('prototype', 'prado', 'effects', 'ajax', 'ratings'), - 'inlineeditor' => array('prototype', 'prado', 'effects', 'ajax', 'inlineeditor'), - */ + 'inlineeditor' => array('jquery', 'prado', 'ajax', 'inlineeditor'), 'jqueryui' => array('jquery', 'jqueryui'), + + 'prototype' => array('prototype'), + 'dragdrop' => array('prototype', 'jquery', 'prado', 'ajax', 'dragdrop'), + 'dragdropextra' => array('prototype', 'jquery', 'prado', 'ajax', 'dragdrop','dragdropextra'), + 'accordion' => array('prototype', 'jquery', 'prado', 'accordion'), + 'ratings' => array('prototype', 'jquery', 'prado', 'ajax', 'ratings'), + 'autocomplete' => array('prototype', 'jquery', 'prado', 'ajax', 'autocomplete'), ); return array($packages, $dependencies); diff --git a/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js b/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js index 7fa9e791..9e583c1f 100755 --- a/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js @@ -1,20 +1,22 @@ +jQuery.noConflict(); + /** * DropContainer control */ - -Prado.WebUI.DropContainer = jQuery.klass(Prado.WebUI.CallbackControl, + +Prado.WebUI.DropContainer = Class.create(Prado.WebUI.CallbackControl, { onInit: function(options) { this.options = options; - Object.extend (this.options, + Object.extend (this.options, { onDrop: this.onDrop.bind(this) }); - + Droppables.add (options.ID, this.options); }, - + onDrop: function(dragElement, dropElement, event) { var elementId=dragElement.id.replace(/clone_/,""); diff --git a/framework/Web/UI/ActiveControls/TDropContainer.php b/framework/Web/UI/ActiveControls/TDropContainer.php index 43e8017c..c7ea79b5 100755 --- a/framework/Web/UI/ActiveControls/TDropContainer.php +++ b/framework/Web/UI/ActiveControls/TDropContainer.php @@ -1,7 +1,7 @@ {@link setAcceptCssClass AcceptCssClass} : a coma delimited classname of elements that the drop container can accept. * {@link setHoverCssClass HoverCssClass}: CSS classname of the container when a draggable element hovers over the container. - * + * * Events: - * + * * {@link OnDrop OnDrop} : raised when a TDraggable control is dropped. The dropped control id is encapsulated in the event parameter, * as well as mouse coordinates and key modifiers status * - * + * * @author Christophe BOULAIN (Christophe.Boulain@gmail.com) * @copyright Copyright © 2008, PradoSoft * @license http://www.pradosoft.com/license * @version $Id: TDropContainer.php 3285 2013-04-11 07:28:07Z ctrlaltca $ * @package System.Web.UI.ActiveControls */ -class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHandler -{ +class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHandler +{ private $_container=null; - + /** * Creates a new callback control, sets the adapter to * TActiveControlAdapter. If you override this class, be sure to set the @@ -91,7 +91,7 @@ class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHan { $this->setViewState('Accepts', TPropertyValue::ensureArray($value), ''); } - + /** * Sets the Css class name used when a draggble element is hovering * over this container. @@ -111,8 +111,8 @@ class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHan { return $this->getViewState('HoverClass', ''); } - - + + /** * Raises callback event. This method is required bu {@link ICallbackEventHandler} * interface. @@ -125,19 +125,19 @@ class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHan $this->onDrop($param->getCallbackParameter()); $this->onCallback($param); } - + /** - * Raises the onDrop event. + * Raises the onDrop event. * The drop parameters are encapsulated into a {@link TDropContainerEventParameter} - * + * * @param object $dropControlId */ public function onDrop ($dropParams) { $this->raiseEvent('OnDrop', $this, new TDropContainerEventParameter ($dropParams)); - + } - + /** * This method is invoked when a callback is requested. The method raises * 'OnCallback' event to fire up the event handlers. If you override this @@ -149,7 +149,7 @@ class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHan { $this->raiseEvent('OnCallback', $this, $param); } - + /** * Gets the post back options for this textbox. * @return array @@ -163,7 +163,7 @@ class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHan $options['hoverclass'] = $this->getHoverCssClass(); return $options; } - + /** * Gets the name of the javascript class responsible for performing postback for this control. * This method overrides the parent implementation. @@ -172,7 +172,7 @@ class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHan protected function getClientClassName() { return 'Prado.WebUI.DropContainer'; - } + } /** * Registers clientscripts @@ -198,7 +198,7 @@ class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHan $this->getActiveControl()->registerCallbackClientScript( $this->getClientClassName(), $this->getPostBackOptions()); } - + /** * Creates child control * Override parent implementation to create a container which will contain all @@ -214,7 +214,7 @@ class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHan parent::getControls()->add($this->_container); } } - + /** * Override parent implementation to return the container control collection. * @@ -225,7 +225,7 @@ class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHan $this->ensureChildControls(); return $this->_container->getControls(); } - + /** * Renders and replaces the panel's content on the client-side. * When render() is called before the OnPreRender event, such as when render() @@ -246,15 +246,15 @@ class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHan $this->getPage()->getAdapter()->registerControlToRender($this->_container,$writer); } } - + } /** * TDropContainerEventParameter class - * + * * TDropContainerEventParameter encapsulate the parameter * data for OnDrop event of TDropContainer components - * + * * @author Christophe BOULAIN (Christophe.Boulain@ceram.fr) * @copyright Copyright © 2008, PradoSoft * @license http://www.pradosoft.com/license -- cgit v1.2.3