Code refactoring (5) (es5 -> es2015)

This commit is contained in:
RainLoop Team 2016-07-16 00:29:42 +03:00
parent c148e19ea3
commit cec53b111f
68 changed files with 2210 additions and 2472 deletions

View file

@ -1,6 +1,8 @@
var
_ = require('_'),
$ = require('$'),
key = require('key'),
Globals = require('Common/Globals'),
Enums = require('Common/Enums'),

View file

@ -4,6 +4,7 @@ var
_ = require('_'),
$ = require('$'),
ko = require('ko'),
key = require('key'),
JSON = require('JSON'),
Jua = require('Jua'),
@ -928,7 +929,10 @@ ComposePopupView.prototype.setSignatureFromIdentity = function(oIdentity)
{
var self = this;
this.editor(function(oEditor) {
var bHtml = false, sSignature = oIdentity.signature();
var
bHtml = false,
sSignature = oIdentity.signature();
if ('' !== sSignature)
{
if (':HTML:' === sSignature.substr(0, 6))

View file

@ -6,6 +6,8 @@ var
ko = require('ko'),
key = require('key'),
Jua = require('Jua'),
Enums = require('Common/Enums'),
Consts = require('Common/Consts'),
Globals = require('Common/Globals'),

View file

@ -28,6 +28,7 @@ function NewOpenPgpKeyPopupView()
this.keyBitLength = ko.observable(Enums.Magics.BitLength2048);
this.submitRequest = ko.observable(false);
this.submitError = ko.observable('');
this.email.subscribe(function() {
this.email.error(false);
@ -53,6 +54,7 @@ function NewOpenPgpKeyPopupView()
}
this.submitRequest(true);
this.submitError('');
_.delay(function() {
@ -81,14 +83,15 @@ function NewOpenPgpKeyPopupView()
Utils.delegateRun(self, 'cancelCommand');
}
}).then(null, function() {
}).then(null, function(e) {
self.submitRequest(false);
self.showError(e);
});
}
catch (e)
{
Utils.log(e);
self.submitRequest(false);
self.showError(e);
}
}, Enums.Magics.Time100ms);
@ -102,6 +105,15 @@ function NewOpenPgpKeyPopupView()
kn.extendAsViewModel(['View/Popup/NewOpenPgpKey', 'PopupsNewOpenPgpKeyViewModel'], NewOpenPgpKeyPopupView);
_.extend(NewOpenPgpKeyPopupView.prototype, AbstractView.prototype);
NewOpenPgpKeyPopupView.prototype.showError = function(e)
{
Utils.log(e);
if (e && e.message)
{
this.submitError(e.message);
}
};
NewOpenPgpKeyPopupView.prototype.clearPopup = function()
{
this.name('');
@ -110,6 +122,8 @@ NewOpenPgpKeyPopupView.prototype.clearPopup = function()
this.email('');
this.email.error(false);
this.keyBitLength(Enums.Magics.BitLength2048);
this.submitError('');
};
NewOpenPgpKeyPopupView.prototype.onShow = function()

View file

@ -60,15 +60,14 @@ function PluginPopupView()
list.Name = this.name();
_.each(this.configures(), function(oItem) {
var value = oItem.value();
if (false === value || true === value)
{
value = value ? '1' : '0';
}
list['_' + oItem.Name] = value;
}, this);
this.saveError('');
@ -119,6 +118,7 @@ PluginPopupView.prototype.onShow = function(oPlugin)
this.readme(oPlugin.Readme);
var aConfig = oPlugin.Config;
if (Utils.isNonEmptyArray(aConfig))
{
this.configures(_.map(aConfig, function(aItem) {
@ -160,6 +160,7 @@ PluginPopupView.prototype.onBuild = function()
{
this.tryToClosePopup();
}
return false;
}, this));
};

View file

@ -124,9 +124,10 @@ TemplatePopupView.prototype.populateBodyFromEditor = function()
TemplatePopupView.prototype.editorSetBody = function(sBody)
{
var self = this;
if (!this.editor && this.signatureDom())
{
var self = this;
this.editor = new HtmlEditor(self.signatureDom(), function() {
self.populateBodyFromEditor();
}, function() {

View file

@ -135,7 +135,6 @@ function LoginUserView()
}, this);
this.submitCommand = Utils.createCommand(this, function() {
Utils.triggerAutocompleteInputChange();
this.emailError(false);
@ -276,7 +275,6 @@ function LoginUserView()
}
return true;
}, function() {
return !this.submitRequest();
});
@ -284,12 +282,9 @@ function LoginUserView()
this.facebookLoginEnabled = ko.observable(false);
this.facebookCommand = Utils.createCommand(this, function() {
window.open(Links.socialFacebook(), 'Facebook',
'left=200,top=100,width=650,height=450,menubar=no,status=no,resizable=yes,scrollbars=yes');
'left=200,top=100,width=500,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, function() {
return !this.submitRequest() && this.facebookLoginEnabled();
});
@ -298,23 +293,17 @@ function LoginUserView()
this.googleFastLoginEnabled = ko.observable(false);
this.googleCommand = Utils.createCommand(this, function() {
window.open(Links.socialGoogle(), 'Google',
'left=200,top=100,width=650,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
'left=200,top=100,width=550,height=550,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, function() {
return !this.submitRequest() && this.googleLoginEnabled();
});
this.googleFastCommand = Utils.createCommand(this, function() {
window.open(Links.socialGoogle(true), 'Google',
'left=200,top=100,width=650,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
'left=200,top=100,width=550,height=550,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, function() {
return !this.submitRequest() && this.googleFastLoginEnabled();
});
@ -322,18 +311,14 @@ function LoginUserView()
this.twitterLoginEnabled = ko.observable(false);
this.twitterCommand = Utils.createCommand(this, function() {
window.open(Links.socialTwitter(), 'Twitter',
'left=200,top=100,width=650,height=450,menubar=no,status=no,resizable=yes,scrollbars=yes');
'left=200,top=100,width=500,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, function() {
return !this.submitRequest() && this.twitterLoginEnabled();
});
this.socialLoginEnabled = ko.computed(function() {
var
bF = this.facebookLoginEnabled(),
bG = this.googleLoginEnabled(),

View file

@ -182,7 +182,11 @@ FolderListMailBoxUserView.prototype.onBuild = function(oDom)
});
key('space', Enums.KeyState.FolderList, function() {
var bCollapsed = true, oFolder = null, $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
var
bCollapsed = true,
oFolder = null,
$items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
if ($items.length && $items[0])
{
oFolder = ko.dataFor($items[0]);

View file

@ -1068,7 +1068,10 @@ MessageViewMailBoxUserView.prototype.getAttachmentsHashes = function()
MessageViewMailBoxUserView.prototype.downloadAsZip = function()
{
var self = this, aHashes = this.getAttachmentsHashes();
var
self = this,
aHashes = this.getAttachmentsHashes();
if (0 < aHashes.length)
{
Promises.attachmentsActions('Zip', aHashes, this.downloadAsZipLoading).then(function(oResult) {
@ -1094,7 +1097,10 @@ MessageViewMailBoxUserView.prototype.downloadAsZip = function()
MessageViewMailBoxUserView.prototype.saveToOwnCloud = function()
{
var self = this, aHashes = this.getAttachmentsHashes();
var
self = this,
aHashes = this.getAttachmentsHashes();
if (0 < aHashes.length)
{
Promises.attachmentsActions('OwnCloud', aHashes, this.saveToOwnCloudLoading).then(function(oResult) {
@ -1118,7 +1124,11 @@ MessageViewMailBoxUserView.prototype.saveToOwnCloud = function()
MessageViewMailBoxUserView.prototype.saveToDropbox = function()
{
var self = this, aFiles = [], aHashes = this.getAttachmentsHashes();
var
self = this,
aFiles = [],
aHashes = this.getAttachmentsHashes();
if (0 < aHashes.length)
{
if (window.Dropbox)

View file

@ -1,6 +1,7 @@
var
_ = require('_'),
$ = require('$'),
key = require('key'),
Enums = require('Common/Enums'),