mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 04:29:21 +03:00
Attachments (redesign)
This commit is contained in:
parent
735842bb88
commit
f9640b3ffa
40 changed files with 293 additions and 110 deletions
|
|
@ -33,6 +33,7 @@
|
|||
this.fYesAction = null;
|
||||
this.fNoAction = null;
|
||||
|
||||
this.bFocusYesOnShow = true;
|
||||
this.bDisabeCloseOnEsc = true;
|
||||
this.sDefaultKeyScope = Enums.KeyState.PopupAsk;
|
||||
|
||||
|
|
@ -81,8 +82,9 @@
|
|||
* @param {Function=} fNoFunc
|
||||
* @param {string=} sYesButton
|
||||
* @param {string=} sNoButton
|
||||
* @param {boolean=} bFocusYesOnShow
|
||||
*/
|
||||
AskPopupView.prototype.onShow = function (sAskDesc, fYesFunc, fNoFunc, sYesButton, sNoButton)
|
||||
AskPopupView.prototype.onShow = function (sAskDesc, fYesFunc, fNoFunc, sYesButton, sNoButton, bFocusYesOnShow)
|
||||
{
|
||||
this.clearPopup();
|
||||
|
||||
|
|
@ -99,11 +101,16 @@
|
|||
{
|
||||
this.yesButton(sNoButton);
|
||||
}
|
||||
|
||||
this.bFocusYesOnShow = Utils.isUnd(bFocusYesOnShow) ? true : !!bFocusYesOnShow;
|
||||
};
|
||||
|
||||
AskPopupView.prototype.onFocus = function ()
|
||||
{
|
||||
this.yesFocus(true);
|
||||
if (this.bFocusYesOnShow)
|
||||
{
|
||||
this.yesFocus(true);
|
||||
}
|
||||
};
|
||||
|
||||
AskPopupView.prototype.onBuild = function ()
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@
|
|||
this.aDraftInfo = null;
|
||||
this.sInReplyTo = '';
|
||||
this.bFromDraft = false;
|
||||
this.bSkipNext = false;
|
||||
this.sReferences = '';
|
||||
|
||||
this.bCapaAdditionalIdentities = Settings.capa(Enums.Capa.AdditionalIdentities);
|
||||
|
|
@ -58,6 +57,9 @@
|
|||
}
|
||||
;
|
||||
|
||||
this.bSkipNextHide = false;
|
||||
this.composeInEdit = Data.composeInEdit;
|
||||
|
||||
this.capaOpenPGP = Data.capaOpenPGP;
|
||||
|
||||
this.resizer = ko.observable(false).extend({'throttle': 50});
|
||||
|
|
@ -313,7 +315,7 @@
|
|||
this.savedError(false);
|
||||
this.saving(true);
|
||||
|
||||
this.bSkipNext = true;
|
||||
this.autosaveStart();
|
||||
|
||||
Cache.setFolderHash(Data.draftFolder(), '');
|
||||
|
||||
|
|
@ -338,11 +340,25 @@
|
|||
|
||||
}, this.canBeSendedOrSaved);
|
||||
|
||||
Events.sub('interval.1m', function () {
|
||||
if (this.modalVisibility() && !Data.draftFolderNotEnabled() && !this.isEmptyForm(false) &&
|
||||
!this.bSkipNext && !this.saving() && !this.sending() && !this.savedError())
|
||||
this.skipCommand = Utils.createCommand(this, function () {
|
||||
|
||||
this.bSkipNextHide = true;
|
||||
|
||||
if (this.modalVisibility() && !this.saving() && !this.sending() &&
|
||||
!Data.draftFolderNotEnabled())
|
||||
{
|
||||
this.saveCommand();
|
||||
}
|
||||
|
||||
this.tryToClosePopup();
|
||||
|
||||
}, this.canBeSendedOrSaved);
|
||||
|
||||
Events.sub('interval.2m', function () {
|
||||
|
||||
if (this.modalVisibility() && !Data.draftFolderNotEnabled() && !this.isEmptyForm(false) &&
|
||||
!this.saving() && !this.sending() && !this.savedError())
|
||||
{
|
||||
this.bSkipNext = false;
|
||||
this.saveCommand();
|
||||
}
|
||||
}, this);
|
||||
|
|
@ -400,6 +416,9 @@
|
|||
this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200);
|
||||
|
||||
this.emailsSource = _.bind(this.emailsSource, this);
|
||||
this.autosaveFunction = _.bind(this.autosaveFunction, this);
|
||||
|
||||
this.iTimer = 0;
|
||||
|
||||
kn.constructorEnd(this);
|
||||
}
|
||||
|
|
@ -407,6 +426,28 @@
|
|||
kn.extendAsViewModel(['View/Popup/Compose', 'PopupsComposeViewModel'], ComposePopupView);
|
||||
_.extend(ComposePopupView.prototype, AbstractView.prototype);
|
||||
|
||||
ComposePopupView.prototype.autosaveFunction = function ()
|
||||
{
|
||||
if (this.modalVisibility() && !Data.draftFolderNotEnabled() && !this.isEmptyForm(false) &&
|
||||
!this.saving() && !this.sending() && !this.savedError())
|
||||
{
|
||||
this.saveCommand();
|
||||
}
|
||||
|
||||
this.autosaveStart();
|
||||
};
|
||||
|
||||
ComposePopupView.prototype.autosaveStart = function ()
|
||||
{
|
||||
window.clearTimeout(this.iTimer);
|
||||
this.iTimer = window.setTimeout(this.autosaveFunction, 1000 * 60 * 1);
|
||||
};
|
||||
|
||||
ComposePopupView.prototype.autosaveStop = function ()
|
||||
{
|
||||
window.clearTimeout(this.iTimer);
|
||||
};
|
||||
|
||||
ComposePopupView.prototype.emailsSource = function (oData, fResponse)
|
||||
{
|
||||
require('App/User').getAutocomplete(oData.term, function (aData) {
|
||||
|
|
@ -594,6 +635,8 @@
|
|||
{
|
||||
if (oData.Result.NewFolder && oData.Result.NewUid)
|
||||
{
|
||||
bResult = true;
|
||||
|
||||
if (this.bFromDraft)
|
||||
{
|
||||
oMessage = Data.message();
|
||||
|
|
@ -606,27 +649,22 @@
|
|||
this.draftFolder(oData.Result.NewFolder);
|
||||
this.draftUid(oData.Result.NewUid);
|
||||
|
||||
if (this.modalVisibility())
|
||||
this.savedTime(window.Math.round((new window.Date()).getTime() / 1000));
|
||||
|
||||
this.savedOrSendingText(
|
||||
0 < this.savedTime() ? Utils.i18n('COMPOSE/SAVED_TIME', {
|
||||
'TIME': moment.unix(this.savedTime() - 1).format('LT')
|
||||
}) : ''
|
||||
);
|
||||
|
||||
if (this.bFromDraft)
|
||||
{
|
||||
this.savedTime(window.Math.round((new window.Date()).getTime() / 1000));
|
||||
|
||||
this.savedOrSendingText(
|
||||
0 < this.savedTime() ? Utils.i18n('COMPOSE/SAVED_TIME', {
|
||||
'TIME': moment.unix(this.savedTime() - 1).format('LT')
|
||||
}) : ''
|
||||
);
|
||||
|
||||
bResult = true;
|
||||
|
||||
if (this.bFromDraft)
|
||||
{
|
||||
Cache.setFolderHash(this.draftFolder(), '');
|
||||
}
|
||||
Cache.setFolderHash(this.draftFolder(), '');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.modalVisibility() && !bResult)
|
||||
if (!bResult)
|
||||
{
|
||||
this.savedError(true);
|
||||
this.savedOrSendingText(Utils.getNotification(Enums.Notification.CantSaveMessage));
|
||||
|
|
@ -637,7 +675,16 @@
|
|||
|
||||
ComposePopupView.prototype.onHide = function ()
|
||||
{
|
||||
this.reset();
|
||||
this.autosaveStop();
|
||||
|
||||
if (!this.bSkipNextHide)
|
||||
{
|
||||
this.composeInEdit(false);
|
||||
this.reset();
|
||||
}
|
||||
|
||||
this.bSkipNextHide = false;
|
||||
|
||||
kn.routeOn();
|
||||
};
|
||||
|
||||
|
|
@ -736,6 +783,41 @@
|
|||
{
|
||||
kn.routeOff();
|
||||
|
||||
this.autosaveStart();
|
||||
|
||||
if (this.composeInEdit())
|
||||
{
|
||||
sType = sType || Enums.ComposeType.Empty;
|
||||
|
||||
var
|
||||
self = this,
|
||||
PopupsAskViewModel = require('View/Popup/Ask')
|
||||
;
|
||||
|
||||
if (Enums.ComposeType.Empty !== sType)
|
||||
{
|
||||
kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('COMPOSE/DISCARD_UNSAVED_DATA'), function () {
|
||||
self.initOnShow(sType, oMessageOrArray, aToEmails, sCustomSubject, sCustomPlainText);
|
||||
}, null, null, null, false]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.initOnShow(sType, oMessageOrArray, aToEmails, sCustomSubject, sCustomPlainText);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string=} sType = Enums.ComposeType.Empty
|
||||
* @param {?MessageModel|Array=} oMessageOrArray = null
|
||||
* @param {Array=} aToEmails = null
|
||||
* @param {string=} sCustomSubject = null
|
||||
* @param {string=} sCustomPlainText = null
|
||||
*/
|
||||
ComposePopupView.prototype.initOnShow = function (sType, oMessageOrArray, aToEmails, sCustomSubject, sCustomPlainText)
|
||||
{
|
||||
this.composeInEdit(true);
|
||||
|
||||
var
|
||||
self = this,
|
||||
sFrom = '',
|
||||
|
|
@ -1033,14 +1115,21 @@
|
|||
PopupsAskViewModel = require('View/Popup/Ask')
|
||||
;
|
||||
|
||||
if (!kn.isPopupVisible(PopupsAskViewModel))
|
||||
if (!kn.isPopupVisible(PopupsAskViewModel) && this.modalVisibility())
|
||||
{
|
||||
kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () {
|
||||
if (self.modalVisibility())
|
||||
{
|
||||
Utils.delegateRun(self, 'closeCommand');
|
||||
}
|
||||
}]);
|
||||
if (this.bSkipNextHide || (this.isEmptyForm() && !this.draftUid()))
|
||||
{
|
||||
Utils.delegateRun(self, 'closeCommand');
|
||||
}
|
||||
else
|
||||
{
|
||||
kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_CLOSE_THIS_WINDOW'), function () {
|
||||
if (self.modalVisibility())
|
||||
{
|
||||
Utils.delegateRun(self, 'closeCommand');
|
||||
}
|
||||
}]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -1716,14 +1805,14 @@
|
|||
ComposePopupView.prototype.isEmptyForm = function (bIncludeAttachmentInProgress)
|
||||
{
|
||||
bIncludeAttachmentInProgress = Utils.isUnd(bIncludeAttachmentInProgress) ? true : !!bIncludeAttachmentInProgress;
|
||||
var bAttach = bIncludeAttachmentInProgress ?
|
||||
var bWithoutAttach = bIncludeAttachmentInProgress ?
|
||||
0 === this.attachments().length : 0 === this.attachmentsInReady().length;
|
||||
|
||||
return 0 === this.to().length &&
|
||||
0 === this.cc().length &&
|
||||
0 === this.bcc().length &&
|
||||
0 === this.subject().length &&
|
||||
bAttach &&
|
||||
bWithoutAttach &&
|
||||
(!this.oEditor || '' === this.oEditor.getData())
|
||||
;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@
|
|||
this.oContentVisible = null;
|
||||
this.oContentScrollable = null;
|
||||
|
||||
this.composeInEdit = Data.composeInEdit;
|
||||
|
||||
this.messageList = Data.messageList;
|
||||
this.folderList = Data.folderList;
|
||||
this.folderListSystem = Data.folderListSystem;
|
||||
|
|
|
|||
|
|
@ -367,7 +367,7 @@
|
|||
if (this.pswpDom)
|
||||
{
|
||||
oDom
|
||||
.on('click', 'a.attachmentImagePreview[data-index]:visible', function (oEvent) {
|
||||
.on('click', '.attachmentImagePreview[data-index]', function (oEvent) {
|
||||
|
||||
var
|
||||
oPs = null,
|
||||
|
|
@ -375,7 +375,7 @@
|
|||
aItems = []
|
||||
;
|
||||
|
||||
oDom.find('a.attachmentImagePreview:visible').each(function (index, oSubElement) {
|
||||
oDom.find('.attachmentImagePreview[data-index]').each(function (index, oSubElement) {
|
||||
|
||||
var $oItem = $(oSubElement);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue