From 6228873cf9d6471463d2413e7dfd7447f759baf2 Mon Sep 17 00:00:00 2001 From: "christophe.boulain" <> Date: Wed, 3 Dec 2008 14:22:03 +0000 Subject: Merge from trunk --- .../ActiveControls/Samples/DragDrop/Home.page | 90 +++++++++++++++++ .../pages/ActiveControls/Samples/DragDrop/Home.php | 112 +++++++++++++++++++++ .../Samples/DragDrop/assets/product1.png | Bin 0 -> 10711 bytes .../Samples/DragDrop/assets/product2.png | Bin 0 -> 9550 bytes .../Samples/DragDrop/assets/trash.png | Bin 0 -> 783 bytes 5 files changed, 202 insertions(+) create mode 100755 demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.page create mode 100755 demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.php create mode 100755 demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product1.png create mode 100755 demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product2.png create mode 100755 demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/trash.png (limited to 'demos/quickstart/protected/pages/ActiveControls/Samples') diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.page b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.page new file mode 100755 index 00000000..89d64110 --- /dev/null +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.page @@ -0,0 +1,90 @@ + + +

Drag & Drop demo !

+ +

Product List :

+ +
+ + + + + Data['ProductImageUrl']%> /> + + + +
+

Your shopping cart :

+ + + + Your shopping cart is empty, please add some items ! + + + Data['ProductCount'] > 1)%> + > + Data['ProductImageUrl']%>/> + Data['ProductTitle']%>/> + + + + + +

Remove Items from cart by dropping them here

+ +
diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.php b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.php new file mode 100755 index 00000000..276ee6a4 --- /dev/null +++ b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/Home.php @@ -0,0 +1,112 @@ +getIsPostBack() && !$this->getIsCallBack()) + { + + $this->populateProductList(); + $this->populateShoppingList(); + } + } + + private function getProductData () + { + return array ( + array ( + 'ProductId' => 'Product1', + 'ProductImageUrl' => $this->publishAsset('assets/product1.png'), + 'ProductTitle' => 'Cup' + ), + array ( + 'ProductId' => 'Product2', + 'ProductImageUrl' => $this->publishAsset('assets/product2.png'), + 'ProductTitle' => 'T-Shirt' + ) + ); + } + + private function getProduct ($key) + { + foreach ($this->getProductData() as $product) + if ($product['ProductId']==$key) return $product; + 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 () + { + return $this->getViewState('ShoppingList', array ()); + } + + public function setShoppingListData ($value) + { + $this->setViewState('ShoppingList', TPropertyValue::ensureArray($value), array ()); + } + + public function addItemToCart ($sender, $param) + { + $control=$param->getDroppedControl(); + // Get the Key from the repeater item + $item=$control->getNamingContainer(); + $key=$this->ProductList->getDataKeys()->itemAt($item->getItemIndex()); + $product=$this->getProduct($key); + $shoppingList=$this->getShoppingListData(); + if (isset ($shoppingList[$key])) + { + // Already an item of this type, increment counter + $shoppingList[$key]['ProductCount']++; + } + else + { + // Add an item to the shopping list + $shoppingList[$key]=$product; + $shoppingList[$key]['ProductCount']=1; + } + $this->setShoppingListData($shoppingList); + + } + + public function removeItemFromCart ($sender, $param) + { + $control=$param->getDroppedControl(); + $item=$control->getNamingContainer(); + $key=$this->ShoppingList->getDataKeys()->itemAt($item->getItemIndex()); + $shoppingList=$this->getShoppingListData(); + if (isset($shoppingList[$key])) + { + if ($shoppingList[$key]['ProductCount'] > 1) + $shoppingList[$key]['ProductCount'] --; + else + unset($shoppingList[$key]); + } + $this->setShoppingListData($shoppingList); + + } + + public function redrawCart ($sender, $param) + { + $this->populateShoppingList(); + $this->cart->render($param->NewWriter); + + } +} +?> \ No newline at end of file diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product1.png b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product1.png new file mode 100755 index 00000000..ae03d551 Binary files /dev/null and b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product1.png differ diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product2.png b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product2.png new file mode 100755 index 00000000..25e81ad7 Binary files /dev/null and b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/product2.png differ diff --git a/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/trash.png b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/trash.png new file mode 100755 index 00000000..184f7628 Binary files /dev/null and b/demos/quickstart/protected/pages/ActiveControls/Samples/DragDrop/assets/trash.png differ -- cgit v1.2.3