Skip to content

/ Zope / gocept svn checkins / Archive / 2010 / 2010-02 / SVN: r30618 - in webmailer/gocept.webmail/trunk: . gocept/webmail/browser/resources

[ << ] [ >> ]

[ SVN: r30616 - gtimelog/tags/0.1.3 / Christian ... ] [ SVN: r30636 - in gocept.autocomplete/trunk: . ... ]

SVN: r30618 - in webmailer/gocept.webmail/trunk: . gocept/webmail/browser/resources
Thomas Lotze <tl(at)gocept.com>
2010-02-23 08:10:09 [ FULL ]
Author: thomas
Date: Tue Feb 23 08:10:07 2010
New Revision: 30618

Log:
re #4932: merged 4892-jquery branch, landing multiselection on the trunk


Added:
   webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/select.js
      - copied unchanged from r30617,
webmailer/gocept.webmail/branches/4892-jquery/gocept/webmail/browser/resources/select.js
   webmailer/gocept.webmail/trunk/selection.txt
      - copied unchanged from r30617,
webmailer/gocept.webmail/branches/4892-jquery/selection.txt
   webmailer/gocept.webmail/trunk/selection_scaling.txt
      - copied unchanged from r30617,
webmailer/gocept.webmail/branches/4892-jquery/selection_scaling.txt
Modified:
   webmailer/gocept.webmail/trunk/   (props changed)
   webmailer/gocept.webmail/trunk/TODO.txt
   webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js
   webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/runner.js
   webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/utilities.js
  
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/webmailer-main.js

Modified: webmailer/gocept.webmail/trunk/TODO.txt
==============================================================================
--- webmailer/gocept.webmail/trunk/TODO.txt	(original)
+++ webmailer/gocept.webmail/trunk/TODO.txt	Tue Feb 23 08:10:07 2010
(at)(at) -1,6 +1,7 (at)(at)
-Todo new:
+Todo
+====
 
-entirely new features:
+new features:
 
 * when someone sends an overly long line, we don't want a horizontal
   scrollbar but wrap the text somehow (Thomas)
(at)(at) -18,9 +19,31 (at)(at)
 
 * Allow downloading messages into mbox files. (Thomas)
 
-* Implement multi-selection of messages in a folder, apply operations
-  such as deletion or moving to all selected messages instead of just
-  one.  (Martijn)
+* Implement operations on selection of multiple messages in a folder
(Martijn):
+
+  * downloading
+
+  * possibly printing the number of selected messages and size in
+    table caption
+
+  * do we want a copy or cut button and/or menu entry? We have a drag
+    & drop implementation.
+
+  * should a message be opened by default (and perhaps selected?) when
+    we first enter a folder?
+
+  * there is a mysterious URL being generated somewhere at some point to
+    here:
+
+    http://localhost:8080/test/admin/user-localhost/+INBOX/(at)(at)delete_messages/delete_messages
+
+    Figure out what is going on.
+
+  * Nicer interaction when deleting, instead of the reloading of the
+    table that happens now, perhaps delete removed rows from it?
+
+  * prevent DOS attacks from happening when a huge amount of messages
+    are range-selected.
 
 * Some way of catching Javascript problems in a way that enables any
   user to submit meaningful bug reports. This should be implemented in
(at)(at) -42,10 +65,9 (at)(at)
 
 * when editing a draft message that's being displayed, update the preview
 
-new features:
+newly discovered features:
 
-* multi select: retain multiselections after scrolling, what to do
-  with "select all" (Martijn)
+* keyboard shortcuts for various operations (navigation, copy & paste,
etc)
 
 code structure:
 
(at)(at) -112,3 +134,4 (at)(at)
   see a completely empty and therefore not very clear draft)
 
 * improve testing
+

Modified:
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js
==============================================================================
---
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js	(original)
+++
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js	Tue
Feb 23 08:10:07 2010
(at)(at) -1,4 +1,4 (at)(at)
-Def(function() {
+(function($){
 
     YAHOO.gocept.webmailer.onMessageListResized = new
YAHOO.util.CustomEvent("onMessageListResized");
     YAHOO.gocept.webmailer.onDraftModified = new
YAHOO.util.CustomEvent("onDraftModified");
(at)(at) -6,10 +6,9 (at)(at)
     YAHOO.gocept.webmailer.onFolderInfoUpdated = new
YAHOO.util.CustomEvent("onFolderInfoUpdated");
     YAHOO.gocept.webmailer.onOpenComposer = new
YAHOO.util.CustomEvent("onOpenComposer");
 
-});
-
-
-(function($){
+/* the maximum amount of popups that should pop up when
+   opening multiple messages */
+var MAXIMUM_POPUP_WINDOWS = 1;
 
 YAHOO.gocept.webmailer.Container = Class(
 {
(at)(at) -60,7 +59,7 (at)(at)
     apply_to_message_container: function(callback) {
         var self = this;
         self.apply_to_children(function(children) {
-            $(children).each(function(index, child) {
+            $.each(children, function(index, child) {
                 if (child.name == 'INBOX') {
                     callback(child);
                     return false;
(at)(at) -76,11 +75,10 (at)(at)
     address_name: 'from_name',
     address_heading: 'Absender',
 
-    canBeRaw: true,
-    canEdit: false,
-    canDelete: true,
-    canForward: true,
-    canReply: true,
+    allowed_operations: {'raw': null,
+                         'delete': null,
+                         'forward': null,
+                         'reply': null},
 
     messages_view: 'messages',
 
(at)(at) -103,11 +101,9 (at)(at)
     address_name: 'to',
     address_heading: 'Empfänger',
 
-    canBeRaw: true,
-    canEdit: true,
-    canDelete: true,
-    canForward: false,
-    canReply: false,
+    allowed_operations: {'raw': null,
+                         'edit': null,
+                         'delete': null},
 
     messages_view: 'drafts'
 });
(at)(at) -124,7 +120,7 (at)(at)
     var cell_content = '';
 
     var seen = false;
-    $(flags).each(function(index, flag){
+    $.each(flags, function(index, flag){
         if (flag == '\\Seen') {
             seen = true;
         }
(at)(at) -156,10 +152,7 (at)(at)
     document.App.preferences.set("sort", [index, sortorder]);
 };
 
-var open_message = function(rowId, status) {
-    if (!status) {
-        return;
-    }
+var open_message = function(rowId) {
 
     // jqgrid does not retain information about the original row data but only
     // keeps the formatted cell contents. We therefore need to remove the
(at)(at) -168,15 +161,7 (at)(at)
     $('#message-table tr#'+escaped_rowId+' td img.message_unread').remove();
 
     document.App.preview_pane.loading();
-    var folder = document.App.selected_folder;
-    return document.App.preview_pane.load({
-        url: rowId,
-        canBeRaw: folder.canBeRaw,
-        canEdit: folder.canEdit,
-        canDelete: folder.canDelete,
-        canForward: folder.canForward,
-        canReply: folder.canReply
-    });
+    return document.App.preview_pane.load(rowId);
 };
 
 var start_drag = function(event) {
(at)(at) -186,13 +171,21 (at)(at)
     }
 
     // we want the tr
-    var element = event.target.parentNode;
+    var row = event.target.parentNode;
+
+    var tableselect = $('#message-table').existingTableSelect();
+
+    // if the tr isn't selected, and we aren't holding down
+    // the ctrl key, we need to single-select it first
+    if (!event.ctrlKey && !tableselect.is_selected(row.id)) {
+        tableselect.single_select(row.id);
+    }
 
-    ddRow = YAHOO.gocept.webmailer.util.get_dd_proxy(element.id);
+    ddRow = YAHOO.gocept.webmailer.util.get_dd_proxy(row.id);
     ddRow.handleMouseDown(event);
 
     ddRow.getSource = function() {
-        return {url: element.id};
+        return {message_urls: tableselect.get_selected_rowids()};
     };
 
     ddRow.onDragDrop = function(ev, id) {
(at)(at) -200,15 +193,16 (at)(at)
         var target = this.getTarget(id);
         if (!this.checkDropTarget(source, target))
             return;
-        var method = '/(at)(at)move';
+        var method = '/(at)(at)move_messages';
         var source_changed = true;
         if (ev.ctrlKey) {
-            method = '/(at)(at)copy';
+            method = '/(at)(at)copy_messages';
             source_changed = false;
-        };
-        url = source.url + method;
+        }
+        var folder_url = target.url;
+        var url = folder_url + method;
         document.Connection.post(
-            url, {folder_url: target.url}, function(result) {
+            url, source, function(result) {
                 YAHOO.util.DragDropMgr.stopDrag(ev, true);
                 if (source_changed) {
                     YAHOO.gocept.webmailer.onFolderContentsChanged.fire();
(at)(at) -218,6 +212,12 (at)(at)
     };
 };
 
+// information about the last server request made
+var last_page = null;
+var last_sord = null;
+var last_idx = null;
+var last_rownum = 50;
+
 // Beware the magic number.
 var message_table_height = 219;
 
(at)(at) -228,6 +228,7 (at)(at)
 
 var load = function(folder) {
     document.App.preview_pane.reset();
+    disable_message_buttons_and_menu();
 
     document.App.selected_folder = folder;
     var init_sort = document.App.preferences.data['sort'];
(at)(at) -240,14 +241,25 (at)(at)
     $('#message-table').jqGrid('GridUnload');
     $('#message-table').unbind('mousedown');
 
+    var tableselect = $('#message-table').existingTableSelect()
+    if (tableselect !== null) {
+        tableselect.unload();
+    }
+
+    tableselect = $('#message-table').tableSelect({
+        'update_selection': update_selection
+    });
+
+    var json_url = folder.url + '/(at)(at)' + folder.messages_view + '_jqgrid'
// XXX REST
+
     var options = {
+        afterInsertRow: tableselect.select_if_needed,
         autowidth: true,
-        beforeSelectRow: function(){
-            // XXX temporary fix for jqgrid's behaviour, should be removed
-            // when merging the multiselection feature
-            $('#message-table tr').removeClass('ui-state-highlight');
-            $('#message-table tr').attr('aria-selected', 'false');
-            return true;
+        beforeSelectRow: function(rowid, e) {
+            tableselect.handle_select_event(last_page, rowid, e);
+            // this function returns false to take over jqgrid's
+            // native selection mechanism completely
+            return false;
         },
         caption: folder.name,
         colModel: [{name: 'flags',
(at)(at) -264,17 +276,58 (at)(at)
         height: message_table_height,
         hidegrid: false,
         loadComplete: function(data) { set_folder_total(folder, data); },
-//        multiselect: true,
-        onSelectRow: open_message,
         onSortCol: save_sorting_state,
-        rowNum: 50,
+        rowNum: last_rownum, // this is never updated, so we just set it
         scroll: 1,
         sortname: sortname,
         sortorder: sortorder,
-        url: folder.url + '/(at)(at)' + folder.messages_view + '_jqgrid' //
XXX REST
+        url: json_url
     };
 
-    $('#message-table').jqGrid(options);
+    var grid = $('#message-table').jqGrid(options);
+
+    /* this sets up a hackish way to maintain the current page we're loading
*/
+    grid.setGridParam({
+        'gridComplete': function(xhr) {
+            last_page = grid.getGridParam('page');
+            last_sord = grid.getGridParam('sortorder');
+            last_sidx = grid.getGridParam('sortname');
+        }
+    });
+
+    tableselect.config('batched_rowids', function(from_batch, to_batch,
callback) {
+        /* batch 0 doesn't exist */
+        if (from_batch == 0) {
+            from_batch = 1;
+        }
+
+        var rowids = [];
+
+        /* retrieve all batches in order, and finally call callback
+           when all batches have been retrieved */
+        var get_batch = function(batch) {
+            $.getJSON(json_url,
+                      {'page': batch,
+                       'nd': new Date().getTime(),
+                       'rows': last_rownum,
+                       'sidx': last_sidx,
+                       'sord': last_sord
+                      },
+                      function(json) {
+                          $.each(json.rows, function(i, value) {
+                              rowids.push(value.id);
+                          });
+                          var next_batch = batch + 1;
+                          if (next_batch <= to_batch) {
+                              get_batch(next_batch);
+                          } else {
+                              callback(rowids);
+                          }
+                      });
+        }
+        get_batch(from_batch);
+    });
+
     $('#message-table').mousedown(start_drag);
 };
 
(at)(at) -331,80 +384,174 (at)(at)
        
'dependent=yes,location=no,menubar=no,toolbar=no,width=800,height=540');
 });
 
-})(jQuery);
+var get_selected_rowids = function() {
+    return $('#message-table').existingTableSelect().get_selected_rowids();
+};
 
+var get_limited_selected_messageids = function() {
+    var messageids = get_selected_rowids();
+    if (messageids.length > MAXIMUM_POPUP_WINDOWS) {
+        /* XXX we could instead show a feedback message and bail out */
+        messageids = messageids.slice(0, MAXIMUM_POPUP_WINDOWS);
+    }
+    return messageids;
+};
 
-//
-// Preview pane
-//
+var get_one_selected_messageid = function() {
+    var messageids = get_selected_rowids();
+    if (messageids.length > 1) {
+        /* XXX we could instead show a feedback message and bail out */
+        return messageids[0];
+    } else if (messageids.length == 1) {
+        return messageids[0];
+    } else {
+        return null;
+    }
+};
 
-Def(function(){
+var update_selection = function(tableselect) {
+    var selected_rowids = tableselect.get_selected_rowids();
 
-    YAHOO.gocept.webmailer.PreviewPane = Class({
-        construct: function() {
-            var self = this;
-            //
-            // Register the message-context menu items
-            //
-            reply = function() {
-                document.Connection.post(self.message.url+'/(at)(at)reply',
-                    null, function(result) {
-                        var message =
YAHOO.lang.JSON.parse(result.responseText);
-                       
YAHOO.gocept.webmailer.onOpenComposer.fire(message['url']);
-                });
-            };
-            self.reply_button = YAHOO.gocept.webmailer.util.bind_menu_item(
-                'message-reply', reply);
-            self.reply_button.cfg.setProperty('disabled', true);
-            self.reply_icon = YAHOO.gocept.webmailer.util.bind_menu_item(
-                'message-reply-icon', reply);
-            self.reply_icon.cfg.setProperty('disabled', true);
-
-            forward = function() {
-                document.Connection.post(self.message.url+'/(at)(at)forward',
-                    null, function(result) {
-                        var message =
YAHOO.lang.JSON.parse(result.responseText);
-                       
YAHOO.gocept.webmailer.onOpenComposer.fire(message['url']);
-                });
-            };
-            self.forward_button = YAHOO.gocept.webmailer.util.bind_menu_item(
-                'message-forward', forward);
-            self.forward_button.cfg.setProperty('disabled', true);
-            self.forward_icon = YAHOO.gocept.webmailer.util.bind_menu_item(
-                'message-forward-icon', forward);
-            self.forward_icon.cfg.setProperty('disabled', true);
-
-            self.edit_button = YAHOO.gocept.webmailer.util.bind_menu_item(
-                    'message-edit', function() {
-                YAHOO.gocept.webmailer.onOpenComposer.fire(self.message.url);
-            });
-            self.edit_button.cfg.setProperty('disabled', true);
+    // update the preview pane
+    if (selected_rowids.length == 1) {
+        // if there is only a single message selected, show it
+        $.each(selected_rowids, function(i, rowid) {
+            open_message(rowid)
+        });
+        // we do want to show buttons
+        update_message_buttons_and_menu(document.App.selected_folder);
 
-            del = function() {
-                document.Connection.post(self.message.url+'/(at)(at)delete',
-                    null, function(result) {
-                        document.App.preview_pane.reset();
-                        YAHOO.gocept.webmailer.onFolderContentsChanged.fire();
-                });
-            };
-            self.delete_button = YAHOO.gocept.webmailer.util.bind_menu_item(
-                'message-delete', del);
-            self.delete_button.cfg.setProperty('disabled', true);
-            self.delete_icon = YAHOO.gocept.webmailer.util.bind_menu_item(
-                'message-delete-icon', del);
-            self.delete_icon.cfg.setProperty('disabled', true);
-
-            self.raw_button = YAHOO.gocept.webmailer.util.bind_menu_item(
-                    'message-raw', function() {
-                document.App.preview_pane.load_raw(self.message);
-            });
-            self.raw_button.cfg.setProperty('disabled', true);
-        },
+    } else if (selected_rowids.length > 1) {
+        // if are multiple messages selected, empty preview area
+        document.App.preview_pane.reset();
+        // we do want to show buttons
+        update_message_buttons_and_menu(document.App.selected_folder);
+    } else {
+        // show nothing is nothing is selected
+        document.App.preview_pane.reset();
+        // also disable buttons
+        disable_message_buttons_and_menu();
+    }
+
+};
 
-        load: function(message) {
-            var self = document.App.preview_pane;
-            self.message = message;
+var reply = function() {
+    var callback = function(result) {
+        var message = YAHOO.lang.JSON.parse(result.responseText);
+        YAHOO.gocept.webmailer.onOpenComposer.fire(message['url']);
+    };
+
+    $.each(get_limited_selected_messageids(), function(i, messageid) {
+        document.Connection.post(messageid + '/(at)(at)reply', null,
callback);
+    });
+};
+
+var forward = function() {
+    var callback = function(result) {
+        var message = YAHOO.lang.JSON.parse(result.responseText);
+        YAHOO.gocept.webmailer.onOpenComposer.fire(message['url']);
+    };
+
+    $.each(get_limited_selected_messageids(), function(i, messageid) {
+        document.Connection.post(messageid + '/(at)(at)forward', null,
callback);
+    });
+};
 
+var edit = function() {
+    $.each(get_limited_selected_messageids(), function(i, messageid) {
+        YAHOO.gocept.webmailer.onOpenComposer.fire(messageid);
+    });
+};
+
+var raw = function() {
+    var messageid = get_one_selected_messageid();
+    if (messageid === null) {
+        return;
+    }
+
+    document.App.preview_pane.load_raw(messageid);
+};
+
+var normal = function() {
+    var messageid = get_one_selected_messageid();
+    if (messageid === null) {
+        return;
+    }
+
+    document.App.preview_pane.load(messageid);
+};
+
+var del = function() {
+    var callback = function(result) {
+        document.App.preview_pane.reset();
+        YAHOO.gocept.webmailer.onFolderContentsChanged.fire();
+    };
+
+    var folder_url = document.App.selected_folder.url;
+
+    var messageids = get_selected_rowids();
+    if (messageids.length == 0) {
+        return;
+    }
+    document.Connection.post(folder_url + '/(at)(at)delete_messages',
+                             {'message_urls': messageids},
+                             callback);
+};
+
+var possible_operations = {
+    reply: { fn: reply, icon: true },
+    forward: { fn: forward, icon: true },
+    edit: { fn: edit, icon: false },
+    'delete': { fn: del, icon: true },
+    raw: { fn: raw, icon: false }
+};
+
+YAHOO.gocept.webmailer.setup_message_buttons_and_menu = function() {
+    var bind_menu_item = YAHOO.gocept.webmailer.util.bind_menu_item;
+
+    $.each(possible_operations, function(name, info) {
+        var button = bind_menu_item('message-' + name, info.fn);
+        button.cfg.setProperty('disabled', true);
+        if (info.icon) {
+            var icon = bind_menu_item('message-' + name + '-icon', info.fn);
+            icon.cfg.setProperty('disabled', true);
+        }
+    });
+};
+
+var update_message_buttons_and_menu = function(folder) {
+    var enable = YAHOO.gocept.webmailer.util.enable_menu_item;
+    var disable = YAHOO.gocept.webmailer.util.disable_menu_item;
+
+    $.each(possible_operations, function(name, info) {
+        if (name in folder.allowed_operations) {
+            enable('message-' + name);
+            if (info.icon) {
+                enable('message-' + name + '-icon');
+            }
+        } else {
+            disable('message-' + name);
+            if (info.icon) {
+                disable('message-' + name + '-icon');
+            }
+        }
+    });
+};
+
+var disable_message_buttons_and_menu = function() {
+    var disable = YAHOO.gocept.webmailer.util.disable_menu_item;
+
+    $.each(possible_operations, function(name, info) {
+        disable('message-' + name);
+        if (info.icon) {
+            disable('message-' + name + '-icon');
+        }
+    });
+};
+
+
+YAHOO.gocept.webmailer.PreviewPane = Class({
+        load: function(messageid) {
             // Load the message content and display it. We need to accept
             // errors pages.
             var display = function(result) {
(at)(at) -413,69 +560,34 (at)(at)
                     message_parts['header'] +
                     message_parts['body'] +
                     message_parts['footer']);
-                self.raw_button.cfg.setProperty('text', 'View raw');
-                self.raw_button.cfg.setProperty(
-                    'onclick', {fn: function() {
document.App.preview_pane.load_raw(message); }}
-                    );
+                var button = YAHOO.gocept.webmailer.util.bind_menu_item(
+                    'message-raw', raw);
+                button.cfg.setProperty('text', 'View raw');
             };
-            document.Connection.get(message.url+'/(at)(at)render', display,
display);
+            document.Connection.get(messageid + '/(at)(at)render', display,
display);
 
-            // Activate menu entries depending on the message's capabilities
-            if (message.canReply) {
-                self.reply_button.cfg.setProperty('disabled', false);
-                self.reply_icon.cfg.setProperty('disabled', false);
-            };
-            if (message.canForward) {
-                self.forward_button.cfg.setProperty('disabled', false);
-                self.forward_icon.cfg.setProperty('disabled', false);
-            };
-            if (message.canEdit) {
-                self.edit_button.cfg.setProperty('disabled', false);
-            };
-            if (message.canDelete) {
-                self.delete_button.cfg.setProperty('disabled', false);
-                self.delete_icon.cfg.setProperty('disabled', false);
-            };
-            if (message.canBeRaw) {
-                self.raw_button.cfg.setProperty('disabled', false);
-            };
         },
 
-        load_raw: function(message) {
-            var self = document.App.preview_pane;
+        load_raw: function(messageid) {
+            var self = this;
             self.loading();
-            document.Connection.get(message.url+'/(at)(at)raw',
function(result) {
+            document.Connection.get(messageid + '/(at)(at)raw',
function(result) {
                 var result = YAHOO.lang.JSON.parse(result.responseText);
                 $('#preview-pane').html(result['raw']);
-                self.raw_button.cfg.setProperty('text', 'View normal');
-                self.raw_button.cfg.setProperty('disabled', false);
-                document.App.preview_pane.raw_button.cfg.setProperty(
-                    'onclick', {fn: function() {
document.App.preview_pane.load(message); }}
-                    );
+                var button = YAHOO.gocept.webmailer.util.bind_menu_item(
+                    'message-raw', normal);
+                button.cfg.setProperty('text', 'View normal');
             });
         },
 
         loading: function() {
-            var self = this;
             $('#preview-pane').html('<img
src="++resource++gocept.webmail/images/mail-loading.gif" style="position:
relative; left: 48%; top: 40%;" />');
         },
 
         reset: function() {
-            var self = this;
-            self.message = null;
             $('#preview-pane').html('');
             $('#preview-pane').addClass('message-view');
-
-            // Deactivate message-context menu items.
-            self.reply_button.cfg.setProperty('disabled', true);
-            self.reply_icon.cfg.setProperty('disabled', true);
-            self.forward_button.cfg.setProperty('disabled', true);
-            self.forward_icon.cfg.setProperty('disabled', true);
-            self.edit_button.cfg.setProperty('disabled', true);
-            self.delete_button.cfg.setProperty('disabled', true);
-            self.delete_icon.cfg.setProperty('disabled', true);
-            self.raw_button.cfg.setProperty('disabled', true);
         }
-    });
-
 });
+
+})(jQuery);

Modified:
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/runner.js
==============================================================================
---
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/runner.js	(original)
+++
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/runner.js	Tue
Feb 23 08:10:07 2010
(at)(at) -77,7 +77,9 (at)(at)
 
     add_webmail_js('connection');
     add_webmail_js('preferences');
+    add_webmail_js('select', ['jquery']);
     add_webmail_js('message', ['jqgrid',
+                               'webmail-select',
                                'webmail-preferences',
                                'webmail-webmailer']);
 

Modified:
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/utilities.js
==============================================================================
---
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/utilities.js	(original)
+++
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/utilities.js	Tue
Feb 23 08:10:07 2010
(at)(at) -91,21 +91,28 (at)(at)
     };
 
 
-    YAHOO.gocept.webmailer.util.bind_menu_item = function(id, callback) {
-        item_id = "menuitem-" + id;
-        YAHOO.util.Event.addListener(
-            document.getElementById(item_id), "click", callback);
+    YAHOO.gocept.webmailer.util.get_menu_item = function(id) {
+        var item_id = 'menuitem-' + id;
         return YAHOO.widget.MenuManager.getMenuItem(item_id);
     };
 
 
+    YAHOO.gocept.webmailer.util.bind_menu_item = function(id, callback) {
+        var item = YAHOO.gocept.webmailer.util.get_menu_item(id);
+        item.cfg.setProperty('onclick', {fn: callback});
+        return item;
+    };
+
+
     YAHOO.gocept.webmailer.util.enable_menu_item = function(id) {
-        document.getElementById("menuitem-" + id).disabled = false;
+        var item = YAHOO.gocept.webmailer.util.get_menu_item(id);
+        item.cfg.setProperty('disabled', false);
     };
 
 
     YAHOO.gocept.webmailer.util.disable_menu_item = function(id) {
-        document.getElementById("menuitem-" + id).disabled = true;
+        var item = YAHOO.gocept.webmailer.util.get_menu_item(id);
+        item.cfg.setProperty('disabled', true);
     };
 
     YAHOO.gocept.webmailer.util.get_dd_proxy = function(id) {

Modified:
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/webmailer-main.js
==============================================================================
---
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/webmailer-main.js	(original)
+++
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/webmailer-main.js	Tue
Feb 23 08:10:07 2010
(at)(at) -198,6 +198,7 (at)(at)
             menubar.render();
 
             self.preview_pane = new YAHOO.gocept.webmailer.PreviewPane();
+            YAHOO.gocept.webmailer.setup_message_buttons_and_menu();
             self.reload_tree();
 
             // Menu items

SVN: r30619 - webmailer/gocept.webmail/branches/4892-jquery
Thomas Lotze <tl(at)gocept.com>
2010-02-23 08:12:47 [ FULL ]
Author: thomas
Date: Tue Feb 23 08:12:47 2010
New Revision: 30619

Log:
deleted feature branch after merging it to the trunk


Removed:
   webmailer/gocept.webmail/branches/4892-jquery/

SVN: r30620 - webmailer/gocept.webmail/trunk
Thomas Lotze <tl(at)gocept.com>
2010-02-23 08:23:13 [ FULL ]
Author: thomas
Date: Tue Feb 23 08:23:12 2010
New Revision: 30620

Log:
wrote down things that occurred to me while reviewing the merge of the
multiselection feature


Modified:
   webmailer/gocept.webmail/trunk/TODO.txt

Modified: webmailer/gocept.webmail/trunk/TODO.txt
==============================================================================
--- webmailer/gocept.webmail/trunk/TODO.txt	(original)
+++ webmailer/gocept.webmail/trunk/TODO.txt	Tue Feb 23 08:23:12 2010
(at)(at) -23,6 +23,11 (at)(at)
 
   * downloading
 
+  * forwarding, replying (probably so that a single new message is created
+    that refers to all selected messages, which should eliminate the need for
+    functions that are limited to a small number of messages in order to
+    prevent many pop-up windows from opening at once)
+
   * possibly printing the number of selected messages and size in
     table caption
 
(at)(at) -45,6 +50,12 (at)(at)
   * prevent DOS attacks from happening when a huge amount of messages
     are range-selected.
 
+  * disable the view raw/normal menu entry when multiple messages are selected
+
+  * make menu entries and icons generate events to couple stuff in message.js
+    more loosely, be able to move raw() and normal() functions inside the
+    PreviewPane class
+
 * Some way of catching Javascript problems in a way that enables any
   user to submit meaningful bug reports. This should be implemented in
   such a way that it is usable not only for the webmailer but other

SVN: r30621 - webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources
Thomas Lotze <tl(at)gocept.com>
2010-02-23 16:41:46 [ FULL ]
Author: thomas
Date: Tue Feb 23 16:41:44 2010
New Revision: 30621

Log:
do multi-select when the meta key is pressed, which is an abstraction of the
PC's ctrl key and the Mac's command key


Modified:
   webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js

Modified:
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js
==============================================================================
---
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js	(original)
+++
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js	Tue
Feb 23 16:41:44 2010
(at)(at) -177,7 +177,7 (at)(at)
 
     // if the tr isn't selected, and we aren't holding down
     // the ctrl key, we need to single-select it first
-    if (!event.ctrlKey && !tableselect.is_selected(row.id)) {
+    if (!event.metaKey && !tableselect.is_selected(row.id)) {
         tableselect.single_select(row.id);
     }

SVN: r30622 - webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources
Thomas Lotze <tl(at)gocept.com>
2010-02-23 16:43:12 [ FULL ]
Author: thomas
Date: Tue Feb 23 16:43:12 2010
New Revision: 30622

Log:
added the recent check-in comment to the code since I found it quite useful
afterwards


Modified:
   webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js

Modified:
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js
==============================================================================
---
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js	(original)
+++
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js	Tue
Feb 23 16:43:12 2010
(at)(at) -175,8 +175,9 (at)(at)
 
     var tableselect = $('#message-table').existingTableSelect();
 
-    // if the tr isn't selected, and we aren't holding down
-    // the ctrl key, we need to single-select it first
+    // if the tr isn't selected, and we aren't holding down the meta key
+    // (which is the ctrl key on PCs and the cmd key on Macs), we need to
+    // single-select it first
     if (!event.metaKey && !tableselect.is_selected(row.id)) {
         tableselect.single_select(row.id);
     }

SVN: r30623 - webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources
Thomas Lotze <tl(at)gocept.com>
2010-02-23 16:58:05 [ FULL ]
Author: thomas
Date: Tue Feb 23 16:58:04 2010
New Revision: 30623

Log:
found another occurrence of the ctrl key to be replaced by the meta key


Modified:
   webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/select.js

Modified:
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/select.js
==============================================================================
---
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/select.js	(original)
+++
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/select.js	Tue
Feb 23 16:58:04 2010
(at)(at) -179,7 +179,7 (at)(at)
                         batch, rowid,
                         self._last_touched_batch, self._last_touched_rowid);
                 }
-            } else if (e.ctrlKey) {
+            } else if (e.metaKey) {
                 self._last_touched_rowid = rowid;
                 self._last_touched_batch = batch;
                 self.multi_select(rowid);

SVN: r30624 - webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources
Thomas Lotze <tl(at)gocept.com>
2010-02-23 17:23:18 [ FULL ]
Author: thomas
Date: Tue Feb 23 17:23:17 2010
New Revision: 30624

Log:
when selecting a range of messages, visually select and unselect them in the
table at better points in time


Modified:
   webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js
   webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/select.js

Modified:
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js
==============================================================================
---
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js	(original)
+++
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js	Tue
Feb 23 17:23:17 2010
(at)(at) -178,7 +178,7 (at)(at)
     // if the tr isn't selected, and we aren't holding down the meta key
     // (which is the ctrl key on PCs and the cmd key on Macs), we need to
     // single-select it first
-    if (!event.metaKey && !tableselect.is_selected(row.id)) {
+    if (!(event.metaKey || event.shiftKey) &&
!tableselect.is_selected(row.id)) {
         tableselect.single_select(row.id);
     }
 

Modified:
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/select.js
==============================================================================
---
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/select.js	(original)
+++
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/select.js	Tue
Feb 23 17:23:17 2010
(at)(at) -267,8 +267,6 (at)(at)
            from_rowid or to_rowid could be in any order.
         */
         range_select: function(from_batch, from_rowid, to_batch, to_rowid) {
-            self._unselect_selected();
-            
             if (from_batch > to_batch) {
                 var temp = to_batch;
                 to_batch = from_batch;
(at)(at) -278,6 +276,7 (at)(at)
             var callback = function(rowids) {
                 var selected = [];
                 var in_range = false;
+                self._unselect_selected();
                 $.each(rowids, function(i, rowid) {
                     if (!in_range) {
                         if (rowid == from_rowid || rowid == to_rowid) {

SVN: r30625 - webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources
Thomas Lotze <tl(at)gocept.com>
2010-02-24 09:40:38 [ FULL ]
Author: thomas
Date: Wed Feb 24 09:40:37 2010
New Revision: 30625

Log:
fixed a function call that broke in IE (and should never have worked anywhere
else, for that matter)


Modified:
   webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js

Modified:
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js
==============================================================================
---
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js	(original)
+++
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js	Wed
Feb 24 09:40:37 2010
(at)(at) -223,7 +223,7 (at)(at)
 var message_table_height = 219;
 
 var set_folder_total = function(folder, jsondata) {
-    var response = JSON.parse(jsondata.responseText);
+    var response = YAHOO.lang.JSON.parse(jsondata.responseText);
     folder.set_total(response.records);
 };

SVN: r30641 - webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources
Thomas Lotze <tl(at)gocept.com>
2010-02-26 14:01:12 [ FULL ]
Author: thomas
Date: Fri Feb 26 14:01:10 2010
New Revision: 30641

Log:
check whether the global selected folder is defined in the first place before
accessing its URL


Modified:
   webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js

Modified:
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js
==============================================================================
---
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js	(original)
+++
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/message.js	Fri
Feb 26 14:01:10 2010
(at)(at) -352,6 +352,9 (at)(at)
     // XXX We accept either a folder or a folder URL because the client may be
     // using URLs to talk about folders that haven't been instantiated yet,
     // e.g. function folders of accounts. This should be straightened out.
+    if (document.App.selected_folder == undefined) {
+        return;
+    }
     var folder = (params.length) ? params[0] : document.App.selected_folder;
     if (folder === document.App.selected_folder ||
         folder === document.App.selected_folder.url) {
(at)(at) -364,6 +367,9 (at)(at)
     // XXX We accept either a folder or a folder URL because the client may be
     // using URLs to talk about folders that haven't been instantiated yet,
     // e.g. function folders of accounts. This should be straightened out.
+    if (document.App.selected_folder == undefined) {
+        return;
+    }
     var folder = (params.length) ? params[0] : document.App.selected_folder;
     if (folder === document.App.selected_folder ||
         folder === document.App.selected_folder.url) {

SVN: r30642 - webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources
Thomas Lotze <tl(at)gocept.com>
2010-02-27 22:19:08 [ FULL ]
Author: thomas
Date: Sat Feb 27 22:19:05 2010
New Revision: 30642

Log:
fixed #6909: brought back old-style functions for binding, enabling and
disabling menu buttons that had wrongly been changed so as to work with YUI
menu items only due to their misleading names


Modified:
  
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/composer-main.js
  
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/management-main.js
   webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/utilities.js

Modified:
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/composer-main.js
==============================================================================
---
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/composer-main.js	(original)
+++
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/composer-main.js	Sat
Feb 27 22:19:05 2010
(at)(at) -24,16 +24,16 (at)(at)
                 self.tab_attachments =
document.getElementById("composeBarTabAttachments");
                 self.composer = new YAHOO.gocept.webmailer.Composer(
                     draft_url, profile_url);
-                self.bind_menu_items();
+                self.bind_buttons();
             });
             self.layout.render();
         },
 
-        bind_menu_items: function() {
-            YAHOO.gocept.webmailer.util.bind_menu_item("send", function () {
+        bind_buttons: function() {
+            YAHOO.gocept.webmailer.util.bind_button("send", function () {
                 document.App.composer.send_message();
             });
-            YAHOO.gocept.webmailer.util.bind_menu_item("save", function () {
+            YAHOO.gocept.webmailer.util.bind_button("save", function () {
                 document.App.composer.save_draft();
             });
         }

Modified:
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/management-main.js
==============================================================================
---
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/management-main.js	(original)
+++
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/management-main.js	Sat
Feb 27 22:19:05 2010
(at)(at) -29,18 +29,18 (at)(at)
 
                 self.account_list = new YAHOO.gocept.webmailer.AccountList();
                 self.account_edit_form = new
YAHOO.gocept.webmailer.AccountEditForm();
-                self.bind_menu_items();
+                self.bind_buttons();
             });
             self.layout.render();
         },
 
-        bind_menu_items: function() {
+        bind_buttons: function() {
             var self = this;
-            YAHOO.gocept.webmailer.util.bind_menu_item("new", function () {
+            YAHOO.gocept.webmailer.util.bind_button("new", function () {
                 self.reset();
                 self.loadAccountEditForm();
             });
-            YAHOO.gocept.webmailer.util.bind_menu_item("delete", function () {
+            YAHOO.gocept.webmailer.util.bind_button("delete", function () {
                 var url = self.selected_account.url + '/(at)(at)delete';
                 document.Connection.post(url, null, function(result) {
                     self.account_list = new
YAHOO.gocept.webmailer.AccountList();
(at)(at) -50,13 +50,13 (at)(at)
                     parent.document.App.reload_tree();
                     });
             });
-            YAHOO.gocept.webmailer.util.disable_menu_item("delete");
+            YAHOO.gocept.webmailer.util.disable_button("delete");
         },
 
         loadAccountEditForm: function() {
             document.App.account_edit_form.reset();
            
YAHOO.gocept.webmailer.util.show(document.App.domNodes.account_edit_form);
-            YAHOO.gocept.webmailer.util.bind_menu_item("save", function () {
+            YAHOO.gocept.webmailer.util.bind_button("save", function () {
                 document.App.account_edit_form.save_account();
             });
         },
(at)(at) -106,7 +106,7 (at)(at)
         reset: function() {
            
YAHOO.gocept.webmailer.util.hide(document.App.domNodes.account_edit_form);
            
YAHOO.gocept.webmailer.util.hide(document.App.domNodes.sent_folder_selection);
-            YAHOO.gocept.webmailer.util.disable_menu_item("delete");
+            YAHOO.gocept.webmailer.util.disable_button("delete");
             document.App.selected_account = null;
         }
     });
(at)(at) -183,7 +183,7 (at)(at)
                     document.App.selected_account = account;
                     document.App.loadAccountEditForm();
                    
document.App.fillAccountEditForm(document.App.selected_account);
-                    YAHOO.gocept.webmailer.util.enable_menu_item("delete");
+                    YAHOO.gocept.webmailer.util.enable_button("delete");
                 }
             });
             table.subscribe("rowUnselectEvent", function(event) {

Modified:
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/utilities.js
==============================================================================
---
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/utilities.js	(original)
+++
webmailer/gocept.webmail/trunk/gocept/webmail/browser/resources/utilities.js	Sat
Feb 27 22:19:05 2010
(at)(at) -91,6 +91,24 (at)(at)
     };
 
 
+    YAHOO.gocept.webmailer.util.bind_button = function(id, callback) {
+        item_id = "menuitem-" + id;
+        YAHOO.util.Event.addListener(
+            document.getElementById(item_id), "click", callback);
+        return YAHOO.widget.MenuManager.getMenuItem(item_id);
+    };
+
+
+    YAHOO.gocept.webmailer.util.enable_button = function(id) {
+        document.getElementById("menuitem-" + id).disabled = false;
+    };
+
+
+    YAHOO.gocept.webmailer.util.disable_button = function(id) {
+        document.getElementById("menuitem-" + id).disabled = true;
+    };
+
+
     YAHOO.gocept.webmailer.util.get_menu_item = function(id) {
         var item_id = 'menuitem-' + id;
         return YAHOO.widget.MenuManager.getMenuItem(item_id);

SVN: r30643 - webmailer/gocept.restmail/trunk/gocept/restmail/browser
Thomas Lotze <tl(at)gocept.com>
2010-02-27 22:53:30 [ FULL ]
Author: thomas
Date: Sat Feb 27 22:53:29 2010
New Revision: 30643

Log:
re #6910: actually implemented delete_messages for drafts


Modified:
   webmailer/gocept.restmail/trunk/gocept/restmail/browser/configure.zcml
   webmailer/gocept.restmail/trunk/gocept/restmail/browser/profile.py

Modified:
webmailer/gocept.restmail/trunk/gocept/restmail/browser/configure.zcml
==============================================================================
---
webmailer/gocept.restmail/trunk/gocept/restmail/browser/configure.zcml	(original)
+++ webmailer/gocept.restmail/trunk/gocept/restmail/browser/configure.zcml	Sat
Feb 27 22:53:29 2010
(at)(at) -465,6 +465,11 (at)(at)
       attribute="children"
       />
 
+    <browser:page
+      name="delete_messages"
+      attribute="delete_drafts"
+      />
+
   </browser:pages>
 
   <browser:pages

Modified: webmailer/gocept.restmail/trunk/gocept/restmail/browser/profile.py
==============================================================================
---
webmailer/gocept.restmail/trunk/gocept/restmail/browser/profile.py	(original)
+++ webmailer/gocept.restmail/trunk/gocept/restmail/browser/profile.py	Sat Feb
27 22:53:29 2010
(at)(at) -213,3 +213,20 (at)(at)
                  'name': account.title or u'unnamed',
                  'type': 'account'})
         return data
+
+    (at)gocept.restmail.browser.json.view
+    def delete_drafts(self, message_urls):
+        """Delete a number of draft messages."""
+        messages = self._get_messages(message_urls)
+
+        for message in messages:
+            message.delete()
+        return {}
+
+    def _get_messages(self, message_urls):
+        """Turn list of submitted message_urls into messages.
+        """
+        # XXX Beware code copied & pasted from message.py
+        return [gocept.restmail.browser.traversal.traverse(
+                url, self.context, self.request) for
+                url in message_urls]

MailBoxer