Two new patches
[webos-internals:modifications.git] / email / email-move-popup-in-emails.patch
1 diff --git a/usr/palm/applications/com.palm.app.email/app/controllers/message-assistant.js b/usr/palm/applications/com.palm.app.email/app/controllers/message-assistant.js
2 index 761069e..dcf98d8 100644
3 --- a/usr/palm/applications/com.palm.app.email/app/controllers/message-assistant.js
4 +++ b/usr/palm/applications/com.palm.app.email/app/controllers/message-assistant.js
5 @@ -61,21 +61,29 @@ var MessageAssistant = Class.create({
6                 if (focusStage === true) {
7                         this.focusStageTimer = this.focusEmailStage.bind(this).delay(0.6);
8                 }
9 +               this.requests = [];
10         },
11  
12         setup: function() {
13                 this.setupMessage(); // get message details and setup message webview widget
14                 
15 +               // move-to menu
16 +               this.moveToMenuModel = {
17 +                       items: []
18 +                       };
19 +               
20                 // setup menu   
21                 this.cmdMenuModel = {
22                                 visible:true,
23                                 items: [
24 +                                       {label:$L('Move'),      icon:'file',      submenu:'move-to', disabled: true},
25                                         {label:$L('Reply'),     icon:'reply',     command:'reply'},
26                                         {label:$L('Reply all'), icon:'reply-all', command:'replyAll'},
27                                         {label:$L('Forward'),   icon:'forward-email', command:'forward'},
28                                         {label:$L('Delete'),    icon:'delete',    command:'delete'}
29                                 ]};
30                 this.controller.setupWidget(Mojo.Menu.commandMenu, undefined, this.cmdMenuModel);
31 +               this.controller.setupWidget('move-to', undefined, this.moveToMenuModel);
32                 
33                 this.markUnreadMenuItem =     {label:MessageAssistant.kAppMenuMarkUnread, shortcut:'k', command:'mark-unread'};
34                 this.markSetFlagMenuItem =    {label:MessageAssistant.kAppMenuSetFlag, shortcut:'g', command:'flag'};
35 @@ -175,6 +183,25 @@ var MessageAssistant = Class.create({
36                 Mojo.Event.stopListening(this.controller.stageController.document, Mojo.Event.activate, this.boundUpdateRecipientStatus);
37                 //  This currently does nothing. Commenting out
38                 //  Message.closeMessage(this.controller, this.data.id);
39 +               this.requests.each(function (r) { r.cancel();});
40 +       },
41 +       
42 +       renderFolderList: function(data) {
43 +               var padding = "                                    ";
44 +               if (data.list) {
45 +                       this.moveToMenuModel.items = [];
46 +                       data.list.each(function(folder) {
47 +                               var name = padding.substring(0, folder.depth*24) + folder.name;
48 +                               var icon = 'server-folder-icon';
49 +                               if (this.account.folder === folder.id) {
50 +                                       icon = 'server-folder-checkmark checked';
51 +                               }
52 +                               this.moveToMenuModel.items.push({label: name, command: 'move-to-cmd_' + folder.id, icon: icon});
53 +                       }.bind(this));
54 +                       this.cmdMenuModel.items[0].disabled = false;
55 +                       this.controller.modelChanged(this.moveToMenuModel);
56 +                       this.controller.modelChanged(this.cmdMenuModel);
57 +               }
58         },
59  
60         aboutToActivate: function(callback) {
61 @@ -376,6 +403,7 @@ var MessageAssistant = Class.create({
62                 var assistant = Mojo.Controller.getAppController().assistant;
63                 assistant.notificationAssistant.clear(resp.account, resp.folder, this.data.id);
64                 assistant.clearDebounce('m'+this.data.id);
65 +               this.requests.push(Folder.subscribeAccountFolderList(this.account.account, undefined, this.renderFolderList.bind(this)));
66         },
67  
68         updateRecipientStatus: function() {
69 @@ -1442,7 +1470,20 @@ var MessageAssistant = Class.create({
70         handleCommand: function(event) {
71                 if (event.type == Mojo.Event.command) {
72                         try {
73 +                               var targetId = null;
74 +                               if (event.command.substring(0, 11) === 'move-to-cmd') {
75 +                                       targetId = event.command.substring(event.command.lastIndexOf('_')+1);
76 +                                       event.command = 'move-to-cmd';
77 +                               }
78                                 switch (event.command) {
79 +                                       case 'move-to-cmd':
80 +                                               if (targetId) {
81 +                                                       Mojo.Log.error('moving to folder: %s', targetId);
82 +                                                       Message.moveMessage(this.controller, this.account.emailId, targetId);
83 +                                                       this.controller.stageController.popScene();
84 +                                               }
85 +                                               break;
86 +                                               
87                                         case 'copyAll':
88                                                 this.copyAll(event);
89                                                 break;