Code refactoring (Translator, Stores, ko)

This commit is contained in:
RainLoop Team 2015-01-26 03:09:22 +04:00
parent 929bffccef
commit b42ce01e7e
102 changed files with 6775 additions and 6511 deletions

View file

@ -1,4 +1,3 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function () {
@ -21,27 +20,6 @@
AbstractDataStorate.prototype.populateDataOnStart = function()
{
var
mLayout = Utils.pInt(Settings.settingsGet('Layout')),
aLanguages = Settings.settingsGet('Languages'),
aThemes = Settings.settingsGet('Themes')
;
if (Utils.isArray(aLanguages))
{
this.languages(aLanguages);
}
if (Utils.isArray(aThemes))
{
this.themes(aThemes);
}
this.mainLanguage(Settings.settingsGet('Language'));
this.mainTheme(Settings.settingsGet('Theme'));
this.themeBackgroundName(Settings.settingsGet('UserBackgroundName'));
this.themeBackgroundHash(Settings.settingsGet('UserBackgroundHash'));
this.capaAdditionalAccounts(Settings.capa(Enums.Capa.AdditionalAccounts));
this.capaAdditionalIdentities(Settings.capa(Enums.Capa.AdditionalIdentities));
this.capaGravatar(Settings.capa(Enums.Capa.Gravatar));
@ -58,43 +36,17 @@
this.allowLanguagesOnSettings(!!Settings.settingsGet('AllowLanguagesOnSettings'));
this.useLocalProxyForExternalImages(!!Settings.settingsGet('UseLocalProxyForExternalImages'));
this.editorDefaultType(Settings.settingsGet('EditorDefaultType'));
this.showImages(!!Settings.settingsGet('ShowImages'));
this.contactsAutosave(!!Settings.settingsGet('ContactsAutosave'));
this.interfaceAnimation(!!Settings.settingsGet('InterfaceAnimation'));
this.mainMessagesPerPage(Settings.settingsGet('MPP'));
this.desktopNotifications(!!Settings.settingsGet('DesktopNotifications'));
this.useThreads(!!Settings.settingsGet('UseThreads'));
this.replySameFolder(!!Settings.settingsGet('ReplySameFolder'));
this.useCheckboxesInList(!!Settings.settingsGet('UseCheckboxesInList'));
this.layout(Enums.Layout.SidePreview);
if (-1 < Utils.inArray(mLayout, [Enums.Layout.NoPreview, Enums.Layout.SidePreview, Enums.Layout.BottomPreview]))
{
this.layout(mLayout);
}
this.facebookSupported(!!Settings.settingsGet('SupportedFacebookSocial'));
this.facebookEnable(!!Settings.settingsGet('AllowFacebookSocial'));
this.facebookAppID(Settings.settingsGet('FacebookAppID'));
this.facebookAppSecret(Settings.settingsGet('FacebookAppSecret'));
this.twitterEnable(!!Settings.settingsGet('AllowTwitterSocial'));
this.twitterConsumerKey(Settings.settingsGet('TwitterConsumerKey'));
this.twitterConsumerSecret(Settings.settingsGet('TwitterConsumerSecret'));
this.googleEnable(!!Settings.settingsGet('AllowGoogleSocial'));
this.googleEnable.auth(!!Settings.settingsGet('AllowGoogleSocialAuth'));
this.googleEnable.drive(!!Settings.settingsGet('AllowGoogleSocialDrive'));
this.googleEnable.preview(!!Settings.settingsGet('AllowGoogleSocialPreview'));
this.googleClientID(Settings.settingsGet('GoogleClientID'));
this.googleClientSecret(Settings.settingsGet('GoogleClientSecret'));
this.googleApiKey(Settings.settingsGet('GoogleApiKey'));
this.dropboxEnable(!!Settings.settingsGet('AllowDropboxSocial'));
this.dropboxApiKey(Settings.settingsGet('DropboxApiKey'));
require('Stores/Social').populate();
require('Stores/UserSettings').populate();
require('Stores/NotificationSettings').populate();
this.contactsIsAllowed(!!Settings.settingsGet('ContactsIsAllowed'));
};

View file

@ -1,4 +1,3 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function () {

View file

@ -1,4 +1,3 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function () {

View file

@ -1,4 +1,3 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function () {

View file

@ -1,4 +1,3 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function () {

View file

@ -1,4 +1,3 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function () {

View file

@ -1,4 +1,3 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function () {

View file

@ -1,4 +1,3 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function () {
@ -6,7 +5,7 @@
var
window = require('window'),
Utils = require('Common/Utils')
;

View file

@ -1,4 +1,3 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function () {

View file

@ -1,4 +1,3 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function () {
@ -16,6 +15,7 @@
Globals = require('Common/Globals'),
Utils = require('Common/Utils'),
Links = require('Common/Links'),
Translator = require('Common/Translator'),
Settings = require('Storage/Settings'),
Cache = require('Storage/User/Cache'),
@ -271,7 +271,8 @@
}, this);
this.messageListPageCount = ko.computed(function () {
var iPage = window.Math.ceil(this.messageListCount() / this.messagesPerPage());
var iPage = window.Math.ceil(this.messageListCount() /
require('Stores/UserSettings').messagesPerPage());
return 0 >= iPage ? 1 : iPage;
}, this);
@ -327,13 +328,13 @@
this.messageFullScreenMode(false);
this.hideMessageBodies();
if (Enums.Layout.NoPreview === this.layout() &&
if (Enums.Layout.NoPreview === require('Stores/UserSettings').layout() &&
-1 < window.location.hash.indexOf('message-preview'))
{
require('App/User').historyBack();
}
}
else if (Enums.Layout.NoPreview === this.layout())
else if (Enums.Layout.NoPreview === require('Stores/UserSettings').layout())
{
this.message.focused(true);
}
@ -347,7 +348,7 @@
}
else if (Enums.KeyState.MessageView === Globals.keyScope())
{
if (Enums.Layout.NoPreview === this.layout() && this.message())
if (Enums.Layout.NoPreview === require('Stores/UserSettings').layout() && this.message())
{
Globals.keyScope(Enums.KeyState.MessageView);
}
@ -430,22 +431,7 @@
return aList;
}, this);
// quota
this.userQuota = ko.observable(0);
this.userUsageSize = ko.observable(0);
this.userUsageProc = ko.computed(function () {
var
iQuota = this.userQuota(),
iUsed = this.userUsageSize()
;
return 0 < iQuota ? window.Math.ceil((iUsed / iQuota) * 100) : 0;
}, this);
// other
this.filterModules = ko.observable({});
this.composeInEdit = ko.observable(false);
this.capaOpenPGP = ko.observable(false);
this.openpgpkeys = ko.observableArray([]);
@ -460,21 +446,6 @@
return !!(oItem && oItem.isPrivate);
});
// google
this.googleActions = ko.observable(false);
this.googleLoggined = ko.observable(false);
this.googleUserName = ko.observable('');
// facebook
this.facebookActions = ko.observable(false);
this.facebookLoggined = ko.observable(false);
this.facebookUserName = ko.observable('');
// twitter
this.twitterActions = ko.observable(false);
this.twitterLoggined = ko.observable(false);
this.twitterUserName = ko.observable('');
this.customThemeType = ko.observable(Enums.CustomThemeType.Light);
this.purgeMessageBodyCacheThrottle = _.throttle(this.purgeMessageBodyCache, 1000 * 30);
@ -546,17 +517,17 @@
if (Utils.isArray(aNewMessages) && 0 < aNewMessages.length)
{
var
self = this,
iIndex = 0,
iLen = aNewMessages.length,
fNotificationHelper = function (sImageSrc, sTitle, sText)
{
var
NotificationClass = Utils.notificationClass(),
NotificationSettingsStore = require('Stores/NotificationSettings'),
NotificationClass = NotificationSettingsStore.notificationClass(),
oNotification = null
;
if (NotificationClass && self.useDesktopNotifications())
if (NotificationClass && NotificationSettingsStore.enableDesktopNotification())
{
oNotification = new NotificationClass(sTitle, {
'body': sText,
@ -596,7 +567,7 @@
fNotificationHelper(
Links.notificationMailIcon(),
this.accountEmail(),
Utils.i18n('MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION', {
Translator.i18n('MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION', {
'COUNT': iLen
})
);

View file

@ -1,4 +1,3 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function () {