Improved dragNdrop in web interface

Monotone-Parent: fa22dd2e0a005adc266396ab36652336d8368a4a
Monotone-Revision: 2052b9dc077ae7af1e3a8d4929d79cfd202de6ad

Monotone-Author: flachapelle@inverse.ca
Monotone-Date: 2009-07-20T21:06:33
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Francis Lachapelle 2009-07-20 21:06:33 +00:00
parent 4f43a4fbd2
commit a364ab95a7
2 changed files with 2523 additions and 2510 deletions

View file

@ -106,9 +106,8 @@ function contactsListCallback(http) {
table.observe("mousedown", onContactSelectionChange);
configureSortableTableHeaders(table);
TableKit.Resizable.init(table, {'trueResize' : true, 'keepWidth' : true});
configureDraggables();
}
configureDragAndDrop ();
var rows = table.tBodies[0].rows;
for (var i = 0; i < rows.length; i++) {
var row = $(rows[i]);
@ -603,7 +602,7 @@ function appendAddressBook(name, folder) {
.replace("&gt;", ">", "g")));
setEventsOnAddressBook(li);
updateAddressBooksMenus();
configureDragAndDrop ();
configureDroppables();
}
return result;
@ -706,16 +705,16 @@ function configureDragHandles() {
var handle = $("dragHandle");
if (handle) {
handle.addInterface(SOGoDragHandlesInterface);
handle.leftBlock=$("contactFoldersList");
handle.rightBlock=$("rightPanel");
handle.leftBlock = $("contactFoldersList");
handle.rightBlock = $("rightPanel");
handle.leftMargin = 100;
}
handle = $("rightDragHandle");
if (handle) {
handle.addInterface(SOGoDragHandlesInterface);
handle.upperBlock=$("contactsListContent");
handle.lowerBlock=$("contactView");
handle.upperBlock = $("contactsListContent");
handle.lowerBlock = $("contactView");
}
}
@ -760,6 +759,7 @@ function configureAddressBooks() {
setEventsOnAddressBook(lis[i]);
lookupDeniedFolders();
configureDroppables();
var personalFolder = $("/personal");
personalFolder.selectElement();
@ -1047,7 +1047,6 @@ function initContacts(event) {
configureAbToolbar();
configureAddressBooks();
updateAddressBooksMenus();
// initDnd();
var table = $("contactsList");
if (table) {
@ -1066,33 +1065,37 @@ function initContacts(event) {
sorting["ascending"] = true;
}
function configureDragAndDrop () {
Droppables.empty ();
function configureDraggables() {
var mainElement = $("dragDropVisual");
Draggables.empty ();
var mainElement = new Element ("div", {id: "dragDropVisual"});
if (mainElement == null) {
mainElement = new Element ("div", {id: "dragDropVisual"});
document.body.appendChild(mainElement);
mainElement.absolutize ();
mainElement.style.display = "none";
}
mainElement.hide();
new Draggable ("dragDropVisual",
{
handle: "contactsList",
{ handle: "contactsList",
onStart: startDragging,
onEnd: stopDragging,
onDrag: whileDragging,
scroll: window
});
}
function configureDroppables() {
var drops = $$("ul#contactFolders li");
Droppables.empty ();
drops.each (function (drop) {
if (!drop.hasClassName ("remote"))
Droppables.add (drop.id,
{
hoverclass: "genericHoverClass",
{ hoverclass: "genericHoverClass",
onDrop: dropAction
});
});
}
function currentFolderIsRemote () {
@ -1125,7 +1128,7 @@ function startDragging (itm, e) {
var count = contacts.length;
if (!containsVLF (contacts)) {
handle.style.display = "block";
handle.show();
handle.update (count);
if (e.shiftKey || currentFolderIsRemote ())
handle.addClassName ("copy");
@ -1142,7 +1145,7 @@ function whileDragging (itm, e) {
function stopDragging () {
var handle = $("dragDropVisual");
handle.style.display = "none";
handle.hide();
if (handle.hasClassName ("copy"))
handle.removeClassName ("copy");
}
@ -1151,12 +1154,9 @@ function dropAction (dropped, zone, e) {
var action = "move";
if ($("dragDropVisual").hasClassName ("copy"))
action = "copy";
else
$('contactView').update();
dropSelectedContacts (action, zone.id.substr (1));
if (action != "copy") {
var div = $('contactView');
div.innerHTML = "";
}
}
function dropSelectedContacts (action, toId) {

View file

@ -9,7 +9,7 @@ if (typeof textMailAccounts != 'undefined') {
mailAccounts = textMailAccounts.evalJSON(true);
else
mailAccounts = new Array();
}
}
var defaultColumnsOrder;
if (typeof textDefaultColumnsOrder != 'undefined') {
@ -17,7 +17,7 @@ if (typeof textDefaultColumnsOrder != 'undefined') {
defaultColumnsOrder = textDefaultColumnsOrder.evalJSON(true);
else
defaultColumnsOrder = new Array();
}
}
var Mailer = {
currentMailbox: null,
@ -449,6 +449,9 @@ function onMailboxMenuMove(event) {
var uids = new Array(); // message IDs
var paths = new Array(); // row IDs
Mailer.currentMessages[Mailer.currentMailbox] = null;
$('messageContent').update();
if (this.tagName == 'LI') // from contextual menu
targetMailbox = this.mailbox.fullName();
else // from DnD
@ -460,6 +463,11 @@ function onMailboxMenuMove(event) {
rows[i].hide();
uids.push(uid);
paths.push(path);
for (var j = 0; j < Mailer.popups.length; j++)
if (Mailer.popups[j].messageUID == path) {
Mailer.popups[j].close();
break;
}
}
var url = ApplicationBaseURL + encodeURI(Mailer.currentMailbox) + "/moveMessages";
var parameters = "uid=" + uids.join(",") + "&folder=" + targetMailbox;
@ -621,8 +629,8 @@ function messageListCallback(http) {
table = $('messageList');
configureMessageListEvents(table);
TableKit.Resizable.init(table, {'trueResize' : true, 'keepWidth' : true});
configureDraggables();
}
configureDragAndDrop ();
configureMessageListBodyEvents(table);
var selected = http.callbackData;
@ -1662,7 +1670,7 @@ function onLoadMailboxesCallback(http) {
checkAjaxRequestsState();
getFoldersState();
updateStatusFolders();
configureDragAndDrop ();
configureDroppables();
}
}
else
@ -2147,36 +2155,35 @@ Mailbox.prototype = {
};
function configureDragAndDrop () {
Droppables.empty ();
function configureDraggables () {
var mainElement = $("dragDropVisual");
Draggables.empty ();
var mainElement = new Element ("div", {id: "dragDropVisual"});
if (mainElement == null) {
mainElement = new Element ("div", {id: "dragDropVisual"});
document.body.appendChild(mainElement);
mainElement.absolutize ();
mainElement.style.display = "none";
}
mainElement.hide();
new Draggable ("dragDropVisual",
{
handle: "messageList",
{ handle: "messageList",
onStart: startDragging,
onEnd: stopDragging,
onDrag: whileDragging,
scroll: "folderTreeContent"
});
scroll: "folderTreeContent" });
}
function configureDroppables () {
var drops = $$("div#dmailboxTree1 div.dTreeNode a.node span.nodeName");
Droppables.empty ();
drops.each (function (drop) {
drop.identify ()
Droppables.add (drop.id,
{
hoverclass: "genericHoverClass",
onDrop: dropAction
{ hoverclass: "genericHoverClass",
onDrop: dropAction });
});
});
}
function startDragging (itm, e) {
@ -2187,23 +2194,25 @@ function startDragging (itm, e) {
var handle = $("dragDropVisual");
var count = $('messageList').getSelectedRowsId().length;
handle.style.display = "block";
handle.update (count);
if (e.shiftKey)
handle.addClassName ("copy");
handle.show();
}
function whileDragging (itm, e) {
if (e) {
var handle = $("dragDropVisual");
if (e.shiftKey)
handle.addClassName ("copy");
else if (handle.hasClassName ("copy"))
handle.removeClassName ("copy");
}
}
function stopDragging () {
var handle = $("dragDropVisual");
handle.style.display = "none";
handle.hide();
if (handle.hasClassName ("copy"))
handle.removeClassName ("copy");
}
@ -2212,10 +2221,14 @@ function dropAction (dropped, zone, e) {
var destination = zone.up("div.dTreeNode");
var f;
if ($("dragDropVisual").hasClassName("copy"))
if ($("dragDropVisual").hasClassName("copy")) {
// Message(s) copied
f = onMailboxMenuCopy.bind(destination);
else
var f = onMailboxMenuMove.bind(destination);
}
else {
// Message(s) moved
f = onMailboxMenuMove.bind(destination);
}
f();
}