Permalink
Browse files

fixed #1

  • Loading branch information...
1 parent a6fd83a commit c4a20caed6e48429df5f86abaed4a8bc8b7d30c2 @schmunk42 committed Oct 20, 2011
Showing with 31 additions and 2 deletions.
  1. +18 −1 controllers/WidgetController.php
  2. +13 −1 themes/default/container.js
@@ -25,7 +25,7 @@ public function filters() {
public function accessRules() {
return array(
array('allow',
- 'actions'=>array('admin','delete','index','view','create','update','classVars'),
+ 'actions'=>array('admin','delete','index','view','create','update','classVars','updateOrder'),
'expression' => 'Yii::app()->user->checkAccess("P3widgets.Widget.*")',
),
array('deny',
@@ -162,4 +162,21 @@ public function actionClassVars($alias){
}
echo CJSON::encode($return);
}
+
+ /**
+ * tbd
+ *
+ * Thanks & Credits to peili (http://www.yiiframework.com/extension/p3widgets/#c5563)
+ */
+ public function actionUpdateOrder() {
+ $updateRecordsArray = $_POST['widget'];
+ $listingCounter = 10;
+ foreach ($updateRecordsArray as $id) {
+ $model = $this->loadModel($id);
+ $model->rank = $listingCounter;
+ $model->save(false);
+ $listingCounter = $listingCounter + 10;
+ }
+ }
+
}
@@ -14,7 +14,19 @@ $('.widget').mouseout(function(){
});
// Apply sortable function to containers, handle widget movement
+// Thanks & Credits to peili (http://www.yiiframework.com/extension/p3widgets/#c5563)
$(function() {
+ $( ".widget-container" ).sortable({
+ connectWith: ".widget-container",
+ placeholder: 'ui-state-highlight',
+ handle: '.handle',
+ update: function() {
+ var order = $(this).sortable("serialize");
+ $.post('<?php echo Yii::app()->controller->createUrl("/p3widgets/widget/updateOrder") ?>', order);
+ }
+ }).disableSelection();
+});
+/*$(function() {
$( ".widget-container" ).sortable({
connectWith: ".widget-container",
placeholder: 'ui-state-highlight',
@@ -49,7 +61,7 @@ $(function() {
);
}
}).disableSelection();
-});
+});*/
// Handler for widget deletion
$('.delete').click(

0 comments on commit c4a20ca

Please sign in to comment.