mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 20:49:20 +03:00
Add copy message functionality to drag&drop (drag + shift) [#42]
+ Update jquery to 1.10.2
This commit is contained in:
parent
74af8f793a
commit
f22b90dbe3
16 changed files with 318 additions and 201 deletions
|
|
@ -289,6 +289,7 @@ Enums.Notification = {
|
|||
'CantGetMessage': 202,
|
||||
'CantDeleteMessage': 203,
|
||||
'CantMoveMessage': 204,
|
||||
'CantCopyMessage': 205,
|
||||
|
||||
'CantSaveMessage': 301,
|
||||
'CantSendMessage': 302,
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ ko.bindingHandlers.draggable = {
|
|||
}
|
||||
|
||||
oConf['helper'] = function (oEvent) {
|
||||
return fValueAccessor()(oEvent && oEvent.target ? ko.dataFor(oEvent.target) : null);
|
||||
return fValueAccessor()(oEvent && oEvent.target ? ko.dataFor(oEvent.target) : null, !!oEvent.shiftKey);
|
||||
};
|
||||
|
||||
$(oElement).draggable(oConf).on('mousedown', function () {
|
||||
|
|
|
|||
|
|
@ -525,6 +525,7 @@ Utils.initNotificationLanguage = function ()
|
|||
NotificationI18N[Enums.Notification.CantGetMessage] = Utils.i18n('NOTIFICATIONS/CANT_GET_MESSAGE');
|
||||
NotificationI18N[Enums.Notification.CantDeleteMessage] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_MESSAGE');
|
||||
NotificationI18N[Enums.Notification.CantMoveMessage] = Utils.i18n('NOTIFICATIONS/CANT_MOVE_MESSAGE');
|
||||
NotificationI18N[Enums.Notification.CantCopyMessage] = Utils.i18n('NOTIFICATIONS/CANT_MOVE_MESSAGE');
|
||||
|
||||
NotificationI18N[Enums.Notification.CantSaveMessage] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_MESSAGE');
|
||||
NotificationI18N[Enums.Notification.CantSendMessage] = Utils.i18n('NOTIFICATIONS/CANT_SEND_MESSAGE');
|
||||
|
|
|
|||
|
|
@ -507,6 +507,21 @@ WebMailAjaxRemoteStorage.prototype.messagesMove = function (fCallback, sFolder,
|
|||
}, null, '', ['MessageList', 'Message']);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sFolder
|
||||
* @param {string} sToFolder
|
||||
* @param {Array} aUids
|
||||
*/
|
||||
WebMailAjaxRemoteStorage.prototype.messagesCopy = function (fCallback, sFolder, sToFolder, aUids)
|
||||
{
|
||||
this.defaultRequest(fCallback, 'MessageCopy', {
|
||||
'FromFolder': sFolder,
|
||||
'ToFolder': sToFolder,
|
||||
'Uids': aUids.join(',')
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sFolder
|
||||
|
|
|
|||
|
|
@ -88,13 +88,14 @@ MailBoxFolderListViewModel.prototype.messagesDrop = function (oToFolder, oUi)
|
|||
{
|
||||
var
|
||||
sFromFolderFullNameRaw = oUi.helper.data('rl-folder'),
|
||||
bCopy = '1' === oUi.helper.data('rl-copy'),
|
||||
aUids = oUi.helper.data('rl-uids')
|
||||
;
|
||||
|
||||
if (MailBoxMessageListViewModel && MailBoxMessageListViewModel.__vm && Utils.isNormal(sFromFolderFullNameRaw) && Utils.isArray(aUids))
|
||||
{
|
||||
MailBoxMessageListViewModel.__vm.moveMessagesToFolder(
|
||||
sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw);
|
||||
sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw, bCopy);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -202,12 +202,12 @@ MailBoxMessageListViewModel.prototype.cancelSearch = function ()
|
|||
* @param {string} sFromFolderFullNameRaw
|
||||
* @param {Array} aUidForRemove
|
||||
* @param {string=} sToFolderFullNameRaw
|
||||
* @param {boolean=} bVisialEffectOnly = false
|
||||
* @param {boolean=} bCopy = false
|
||||
*/
|
||||
MailBoxMessageListViewModel.prototype.removeMessagesFromList = function (sFromFolderFullNameRaw, aUidForRemove, sToFolderFullNameRaw, bVisialEffectOnly)
|
||||
MailBoxMessageListViewModel.prototype.removeMessagesFromList = function (sFromFolderFullNameRaw, aUidForRemove, sToFolderFullNameRaw, bCopy)
|
||||
{
|
||||
sToFolderFullNameRaw = Utils.isNormal(sToFolderFullNameRaw) ? sToFolderFullNameRaw : '';
|
||||
bVisialEffectOnly = Utils.isUnd(bVisialEffectOnly) ? false : !!bVisialEffectOnly;
|
||||
bCopy = Utils.isUnd(bCopy) ? false : !!bCopy;
|
||||
|
||||
var
|
||||
iUnseenCount = 0 ,
|
||||
|
|
@ -221,17 +221,14 @@ MailBoxMessageListViewModel.prototype.removeMessagesFromList = function (sFromFo
|
|||
}) : []
|
||||
;
|
||||
|
||||
if (!bVisialEffectOnly)
|
||||
{
|
||||
_.each(aMessages, function (oMessage) {
|
||||
if (oMessage && oMessage.unseen())
|
||||
{
|
||||
iUnseenCount++;
|
||||
}
|
||||
});
|
||||
}
|
||||
_.each(aMessages, function (oMessage) {
|
||||
if (oMessage && oMessage.unseen())
|
||||
{
|
||||
iUnseenCount++;
|
||||
}
|
||||
});
|
||||
|
||||
if (oFromFolder && !bVisialEffectOnly)
|
||||
if (oFromFolder && !bCopy)
|
||||
{
|
||||
oFromFolder.messageCountAll(0 <= oFromFolder.messageCountAll() - aUidForRemove.length ?
|
||||
oFromFolder.messageCountAll() - aUidForRemove.length : 0);
|
||||
|
|
@ -243,7 +240,7 @@ MailBoxMessageListViewModel.prototype.removeMessagesFromList = function (sFromFo
|
|||
}
|
||||
}
|
||||
|
||||
if (oToFolder && !bVisialEffectOnly)
|
||||
if (oToFolder)
|
||||
{
|
||||
oToFolder.messageCountAll(oToFolder.messageCountAll() + aUidForRemove.length);
|
||||
if (0 < iUnseenCount)
|
||||
|
|
@ -254,31 +251,37 @@ MailBoxMessageListViewModel.prototype.removeMessagesFromList = function (sFromFo
|
|||
|
||||
if (0 < aMessages.length)
|
||||
{
|
||||
_.each(aMessages, function (oMessage) {
|
||||
if (oCurrentMessage && oCurrentMessage.requestHash === oMessage.requestHash)
|
||||
{
|
||||
oCurrentMessage = null;
|
||||
oData.message(null);
|
||||
}
|
||||
|
||||
oMessage.deleted(true);
|
||||
});
|
||||
|
||||
_.delay(function () {
|
||||
_.each(aMessages, function (oMessage) {
|
||||
oData.messageList.remove(oMessage);
|
||||
});
|
||||
}, 400);
|
||||
|
||||
if (!bVisialEffectOnly)
|
||||
if (bCopy)
|
||||
{
|
||||
_.each(aMessages, function (oMessage) {
|
||||
oMessage.checked(false);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_.each(aMessages, function (oMessage) {
|
||||
if (oCurrentMessage && oCurrentMessage.requestHash === oMessage.requestHash)
|
||||
{
|
||||
oCurrentMessage = null;
|
||||
oData.message(null);
|
||||
}
|
||||
|
||||
oMessage.deleted(true);
|
||||
});
|
||||
|
||||
_.delay(function () {
|
||||
_.each(aMessages, function (oMessage) {
|
||||
oData.messageList.remove(oMessage);
|
||||
});
|
||||
}, 400);
|
||||
|
||||
RL.data().messageListIsNotCompleted(true);
|
||||
RL.cache().setFolderHash(sFromFolderFullNameRaw, '');
|
||||
}
|
||||
|
||||
if (Utils.isNormal(sToFolderFullNameRaw))
|
||||
{
|
||||
RL.cache().setFolderHash(sToFolderFullNameRaw || '', '');
|
||||
}
|
||||
if (Utils.isNormal(sToFolderFullNameRaw))
|
||||
{
|
||||
RL.cache().setFolderHash(sToFolderFullNameRaw || '', '');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -303,9 +306,10 @@ MailBoxMessageListViewModel.prototype.moveOrDeleteResponse = function (sResult,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (oData && Enums.Notification.CantMoveMessage === oData.ErrorCode)
|
||||
if (oData && -1 < Utils.inArray(oData.ErrorCode,
|
||||
[Enums.Notification.CantMoveMessage, Enums.Notification.CantCopyMessage]))
|
||||
{
|
||||
window.alert(Utils.getNotification(Enums.Notification.CantMoveMessage));
|
||||
window.alert(Utils.getNotification(oData.ErrorCode));
|
||||
}
|
||||
|
||||
RL.cache().setFolderHash(RL.data().currentFolderFullNameRaw(), '');
|
||||
|
|
@ -321,8 +325,9 @@ MailBoxMessageListViewModel.prototype.moveOrDeleteResponse = function (sResult,
|
|||
* @param {string} sFromFolderFullNameRaw
|
||||
* @param {Array} aUidForRemove
|
||||
* @param {string} sToFolderFullNameRaw
|
||||
* @param {boolean=} bCopy = false
|
||||
*/
|
||||
MailBoxMessageListViewModel.prototype.moveMessagesToFolder = function (sFromFolderFullNameRaw, aUidForRemove, sToFolderFullNameRaw)
|
||||
MailBoxMessageListViewModel.prototype.moveMessagesToFolder = function (sFromFolderFullNameRaw, aUidForRemove, sToFolderFullNameRaw, bCopy)
|
||||
{
|
||||
if (sFromFolderFullNameRaw !== sToFolderFullNameRaw && Utils.isArray(aUidForRemove) && 0 < aUidForRemove.length)
|
||||
{
|
||||
|
|
@ -333,7 +338,9 @@ MailBoxMessageListViewModel.prototype.moveMessagesToFolder = function (sFromFold
|
|||
|
||||
if (oFromFolder && oToFolder)
|
||||
{
|
||||
RL.remote().messagesMove(
|
||||
bCopy = Utils.isUnd(bCopy) ? false : !!bCopy;
|
||||
|
||||
RL.remote()[bCopy ? 'messagesCopy' : 'messagesMove'](
|
||||
_.bind(this.moveOrDeleteResponse, this),
|
||||
oFromFolder.fullNameRaw,
|
||||
oToFolder.fullNameRaw,
|
||||
|
|
@ -342,7 +349,7 @@ MailBoxMessageListViewModel.prototype.moveMessagesToFolder = function (sFromFold
|
|||
|
||||
oToFolder.actionBlink(true);
|
||||
|
||||
this.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove, sToFolderFullNameRaw);
|
||||
this.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove, sToFolderFullNameRaw, bCopy);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -408,7 +415,7 @@ MailBoxMessageListViewModel.prototype.deleteSelectedMessageFromCurrentFolder = f
|
|||
}
|
||||
};
|
||||
|
||||
MailBoxMessageListViewModel.prototype.dragAndDronHelper = function (oMessageListItem)
|
||||
MailBoxMessageListViewModel.prototype.dragAndDronHelper = function (oMessageListItem, bCopy)
|
||||
{
|
||||
if (oMessageListItem)
|
||||
{
|
||||
|
|
@ -418,7 +425,8 @@ MailBoxMessageListViewModel.prototype.dragAndDronHelper = function (oMessageList
|
|||
var oEl = Utils.draggeblePlace();
|
||||
oEl.data('rl-folder', RL.data().currentFolderFullNameRaw());
|
||||
oEl.data('rl-uids', RL.data().messageListCheckedOrSelectedUidsWithSubMails());
|
||||
oEl.find('.text').text(RL.data().messageListCheckedOrSelectedUidsWithSubMails().length);
|
||||
oEl.data('rl-copy', bCopy ? '1' : '0');
|
||||
oEl.find('.text').text((bCopy ? '+' : '') + '' + RL.data().messageListCheckedOrSelectedUidsWithSubMails().length);
|
||||
|
||||
return oEl;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue