summaryrefslogtreecommitdiff
path: root/modules/organize/views
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2011-01-05 02:00:40 -0800
committerBharat Mediratta <bharat@menalto.com>2011-01-05 02:00:40 -0800
commit372905bd1310fc446db795661e1eb013674e5a75 (patch)
tree135f75d44a8f7511128739f29313eb07066998b9 /modules/organize/views
parentc590f881ebbb005390f6e4f8a37a6252a5796f51 (diff)
Support moving an item before or after the target.
Diffstat (limited to 'modules/organize/views')
-rw-r--r--modules/organize/views/organize_dialog.html.php23
1 files changed, 17 insertions, 6 deletions
diff --git a/modules/organize/views/organize_dialog.html.php b/modules/organize/views/organize_dialog.html.php
index 773e1955..a482fb92 100644
--- a/modules/organize/views/organize_dialog.html.php
+++ b/modules/organize/views/organize_dialog.html.php
@@ -131,13 +131,22 @@
getTargetFromEvent: function(e) {
return e.getTarget("div.thumb", 10);
},
- onNodeEnter: function(target, dd, e, data) {
- Ext.fly(target).addClass("active");
- },
onNodeOut: function(target, dd, e, data) {
- Ext.fly(target).removeClass("active");
+ Ext.fly(target).removeClass("active-left");
+ Ext.fly(target).removeClass("active-right");
},
onNodeOver: function(target, dd, e, data) {
+ var target_x = Ext.lib.Dom.getX(target);
+ var target_center = target_x + (target.offsetWidth / 2);
+ if (Ext.lib.Event.getPageX(e) < target_center) {
+ Ext.fly(target).addClass("active-left");
+ Ext.fly(target).removeClass("active-right");
+ this.drop_side = "before";
+ } else {
+ Ext.fly(target).removeClass("active-left");
+ Ext.fly(target).addClass("active-right");
+ this.drop_side = "after";
+ }
return Ext.dd.DropZone.prototype.dropAllowed;
},
onNodeDrop: function(target, dd, e, data) {
@@ -147,8 +156,9 @@
source_ids.push(Ext.fly(nodes[i]).getAttribute("rel"));
}
start_busy(<?= t("Rearranging...")->for_js() ?>);
+ target = Ext.fly(target);
Ext.Ajax.request({
- url: '<?= url::site("organize/move_before") ?>',
+ url: '<?= url::site("organize/rearrange") ?>',
method: "post",
success: function() {
stop_busy();
@@ -161,7 +171,8 @@
},
params: {
source_ids: source_ids.join(","),
- target_id: Ext.fly(target).getAttribute("rel"),
+ target_id: target.getAttribute("rel"),
+ relative: this.drop_side, // calculated in onNodeOver
csrf: '<?= access::csrf_token() ?>'
}
});