Uploading and preparing the repository to the dev version.

Original unminified source code (dev folder - js, css, less) (fixes #6)
Grunt build system
Multiple identities correction (fixes #9)
Compose html editor (fixes #12)
New general settings - Loading Description
New warning about default admin password
Split general and login screen settings
This commit is contained in:
RainLoop Team 2013-11-16 02:21:12 +04:00
parent afad45137e
commit 4cc2207513
846 changed files with 99453 additions and 2123 deletions

67
dev/Settings/Accounts.js Normal file
View file

@ -0,0 +1,67 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsAccounts()
{
var oData = RL.data();
this.accounts = oData.accounts;
this.processText = ko.computed(function () {
return oData.accountsLoading() ? Utils.i18n('SETTINGS_ACCOUNTS/LOADING_PROCESS') : '';
}, this);
this.visibility = ko.computed(function () {
return '' === this.processText() ? 'hidden' : 'visible';
}, this);
this.accountForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.deleteAccess(false);
}
}, function (oNext) {
if (oNext)
{
oNext.deleteAccess(true);
}
}
]});
}
Utils.addSettingsViewModel(SettingsAccounts, 'SettingsAccounts', 'SETTINGS_LABELS/LABEL_ACCOUNTS_NAME', 'accounts');
SettingsAccounts.prototype.addNewAccount = function ()
{
kn.showScreenPopup(PopupsAddAccountViewModel);
};
/**
*
* @param {AccountModel} oAccountToRemove
*/
SettingsAccounts.prototype.deleteAccount = function (oAccountToRemove)
{
if (oAccountToRemove && oAccountToRemove.deleteAccess())
{
this.accountForDeletion(null);
var
fRemoveAccount = function (oAccount) {
return oAccountToRemove === oAccount;
}
;
if (oAccountToRemove)
{
this.accounts.remove(fRemoveAccount);
RL.remote().accountDelete(function () {
RL.accountsAndIdentities();
}, oAccountToRemove.email);
}
}
};

View file

@ -0,0 +1,65 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsChangePasswordScreen()
{
this.changeProcess = ko.observable(false);
this.passwordUpdateError = ko.observable(false);
this.passwordUpdateSuccess = ko.observable(false);
this.currentPassword = ko.observable('');
this.newPassword = ko.observable('');
this.currentPassword.subscribe(function () {
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
}, this);
this.newPassword.subscribe(function () {
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
}, this);
this.saveNewPasswordCommand = Utils.createCommand(this, function () {
this.changeProcess(true);
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
RL.remote().changePassword(this.onChangePasswordResponse, this.currentPassword(), this.newPassword());
}, function () {
return !this.changeProcess() && '' !== this.currentPassword() && '' !== this.newPassword();
});
this.onChangePasswordResponse = _.bind(this.onChangePasswordResponse, this);
}
Utils.addSettingsViewModel(SettingsChangePasswordScreen, 'SettingsChangePassword', 'SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME', 'change-password');
SettingsChangePasswordScreen.prototype.onHide = function ()
{
this.changeProcess(false);
this.currentPassword('');
this.newPassword('');
};
SettingsChangePasswordScreen.prototype.onChangePasswordResponse = function (sResult, oData)
{
this.changeProcess(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
this.currentPassword('');
this.newPassword('');
this.passwordUpdateSuccess(true);
}
else
{
this.passwordUpdateError(true);
}
};

196
dev/Settings/Folders.js Normal file
View file

@ -0,0 +1,196 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsFolders()
{
var oData = RL.data();
this.foldersListError = oData.foldersListError;
this.folderList = oData.folderList;
this.processText = ko.computed(function () {
var
oData = RL.data(),
bLoading = oData.foldersLoading(),
bCreating = oData.foldersCreating(),
bDeleting = oData.foldersDeleting(),
bRenaming = oData.foldersRenaming()
;
if (bCreating)
{
return Utils.i18n('SETTINGS_FOLDERS/CREATING_PROCESS');
}
else if (bDeleting)
{
return Utils.i18n('SETTINGS_FOLDERS/DELETING_PROCESS');
}
else if (bRenaming)
{
return Utils.i18n('SETTINGS_FOLDERS/RENAMING_PROCESS');
}
else if (bLoading)
{
return Utils.i18n('SETTINGS_FOLDERS/LOADING_PROCESS');
}
return '';
}, this);
this.visibility = ko.computed(function () {
return '' === this.processText() ? 'hidden' : 'visible';
}, this);
this.folderForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.deleteAccess(false);
}
}, function (oNext) {
if (oNext)
{
oNext.deleteAccess(true);
}
}
]});
this.folderForEdit = ko.observable(null).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.edited(false);
}
}, function (oNext) {
if (oNext && oNext.canBeEdited())
{
oNext.edited(true);
}
}
]});
this.useImapSubscribe = !!RL.settingsGet('UseImapSubscribe');
}
Utils.addSettingsViewModel(SettingsFolders, 'SettingsFolders', 'SETTINGS_LABELS/LABEL_FOLDERS_NAME', 'folders');
SettingsFolders.prototype.folderEditOnEnter = function (oFolder)
{
var sEditName = oFolder ? Utils.trim(oFolder.nameForEdit()) : '';
if ('' !== sEditName && oFolder.name() !== sEditName)
{
RL.local().set(Enums.ClientSideKeyName.FoldersLashHash, '');
RL.data().foldersRenaming(true);
RL.remote().folderRename(function (sResult, oData) {
RL.data().foldersRenaming(false);
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
{
RL.data().foldersListError(
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_RENAME_FOLDER'));
}
RL.folders(false);
}, oFolder.fullNameRaw, sEditName);
RL.cache().removeFolderFromCacheList(oFolder.fullNameRaw);
oFolder.name(sEditName);
}
oFolder.edited(false);
};
SettingsFolders.prototype.folderEditOnEsc = function (oFolder)
{
if (oFolder)
{
oFolder.edited(false);
}
};
SettingsFolders.prototype.onShow = function ()
{
RL.data().foldersListError('');
};
SettingsFolders.prototype.createFolder = function ()
{
kn.showScreenPopup(PopupsFolderCreateViewModel);
};
SettingsFolders.prototype.systemFolder = function ()
{
kn.showScreenPopup(PopupsFolderSystemViewModel);
};
SettingsFolders.prototype.deleteFolder = function (oFolderToRemove)
{
if (oFolderToRemove && oFolderToRemove.canBeDeleted() && oFolderToRemove.deleteAccess() &&
0 === oFolderToRemove.privateMessageCountAll())
{
this.folderForDeletion(null);
var
fRemoveFolder = function (oFolder) {
if (oFolderToRemove === oFolder)
{
return true;
}
oFolder.subFolders.remove(fRemoveFolder);
return false;
}
;
if (oFolderToRemove)
{
RL.local().set(Enums.ClientSideKeyName.FoldersLashHash, '');
RL.data().folderList.remove(fRemoveFolder);
RL.data().foldersDeleting(true);
RL.remote().folderDelete(function (sResult, oData) {
RL.data().foldersDeleting(false);
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
{
RL.data().foldersListError(
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_DELETE_FOLDER'));
}
RL.folders(false);
}, oFolderToRemove.fullNameRaw);
RL.cache().removeFolderFromCacheList(oFolderToRemove.fullNameRaw);
}
}
else if (0 < oFolderToRemove.privateMessageCountAll())
{
RL.data().foldersListError(Utils.getNotification(Enums.Notification.CantDeleteNonEmptyFolder));
}
};
SettingsFolders.prototype.subscribeFolder = function (oFolder)
{
RL.local().set(Enums.ClientSideKeyName.FoldersLashHash, '');
RL.remote().folderSetSubscribe(Utils.emptyFunction, oFolder.fullNameRaw, true);
oFolder.subScribed(true);
};
SettingsFolders.prototype.unSubscribeFolder = function (oFolder)
{
RL.local().set(Enums.ClientSideKeyName.FoldersLashHash, '');
RL.remote().folderSetSubscribe(Utils.emptyFunction, oFolder.fullNameRaw, false);
oFolder.subScribed(false);
};

155
dev/Settings/General.js Normal file
View file

@ -0,0 +1,155 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsGeneral()
{
var oData = RL.data();
this.mainLanguage = oData.mainLanguage;
this.mainMessagesPerPage = oData.mainMessagesPerPage;
this.mainMessagesPerPageArray = Consts.Defaults.MessagesPerPageArray;
this.editorDefaultType = oData.editorDefaultType;
this.showImages = oData.showImages;
this.interfaceAnimation = oData.interfaceAnimation;
this.useDesktopNotifications = oData.useDesktopNotifications;
this.threading = oData.threading;
this.useThreads = oData.useThreads;
this.replySameFolder = oData.replySameFolder;
this.usePreviewPane = oData.usePreviewPane;
this.useCheckboxesInList = oData.useCheckboxesInList;
this.allowLanguagesOnSettings = oData.allowLanguagesOnSettings;
this.isDesktopNotificationsSupported = ko.computed(function () {
return Enums.DesktopNotifications.NotSupported !== oData.desktopNotificationsPermisions();
});
this.isDesktopNotificationsDenied = ko.computed(function () {
return Enums.DesktopNotifications.NotSupported === oData.desktopNotificationsPermisions() ||
Enums.DesktopNotifications.Denied === oData.desktopNotificationsPermisions();
});
this.mainLanguageFullName = ko.computed(function () {
return Utils.convertLangName(this.mainLanguage());
}, this);
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});
this.mppTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.isAnimationSupported = Globals.bAnimationSupported;
}
Utils.addSettingsViewModel(SettingsGeneral, 'SettingsGeneral', 'SETTINGS_LABELS/LABEL_GENERAL_NAME', 'general', true);
SettingsGeneral.prototype.onBuild = function ()
{
var self = this;
_.delay(function () {
var
oData = RL.data(),
f1 = Utils.settingsSaveHelperSimpleFunction(self.mppTrigger, self)
;
oData.language.subscribe(function (sValue) {
self.languageTrigger(Enums.SaveSettingsStep.Animate);
$.ajax({
'url': RL.link().langLink(sValue),
'dataType': 'script',
'cache': true
}).done(function() {
Utils.i18nToDoc();
self.languageTrigger(Enums.SaveSettingsStep.TrueResult);
}).fail(function() {
self.languageTrigger(Enums.SaveSettingsStep.FalseResult);
}).always(function() {
_.delay(function () {
self.languageTrigger(Enums.SaveSettingsStep.Idle);
}, 1000);
});
RL.remote().saveSettings(Utils.emptyFunction, {
'Language': sValue
});
});
oData.editorDefaultType.subscribe(function (sValue) {
RL.remote().saveSettings(Utils.emptyFunction, {
'EditorDefaultType': sValue
});
});
oData.messagesPerPage.subscribe(function (iValue) {
RL.remote().saveSettings(f1, {
'MPP': iValue
});
});
oData.showImages.subscribe(function (bValue) {
RL.remote().saveSettings(Utils.emptyFunction, {
'ShowImages': bValue ? '1' : '0'
});
});
oData.interfaceAnimation.subscribe(function (sValue) {
RL.remote().saveSettings(Utils.emptyFunction, {
'InterfaceAnimation': sValue
});
});
oData.useDesktopNotifications.subscribe(function (bValue) {
Utils.timeOutAction('SaveDesktopNotifications', function () {
RL.remote().saveSettings(Utils.emptyFunction, {
'DesktopNotifications': bValue ? '1' : '0'
});
}, 3000);
});
oData.replySameFolder.subscribe(function (bValue) {
Utils.timeOutAction('SaveReplySameFolder', function () {
RL.remote().saveSettings(Utils.emptyFunction, {
'ReplySameFolder': bValue ? '1' : '0'
});
}, 3000);
});
oData.useThreads.subscribe(function (bValue) {
oData.messageList([]);
RL.remote().saveSettings(Utils.emptyFunction, {
'UseThreads': bValue ? '1' : '0'
});
});
oData.usePreviewPane.subscribe(function (bValue) {
oData.messageList([]);
RL.remote().saveSettings(Utils.emptyFunction, {
'UsePreviewPane': bValue ? '1' : '0'
});
});
oData.useCheckboxesInList.subscribe(function (bValue) {
RL.remote().saveSettings(Utils.emptyFunction, {
'UseCheckboxesInList': bValue ? '1' : '0'
});
});
}, 50);
};
SettingsGeneral.prototype.onShow = function ()
{
RL.data().desktopNotifications.valueHasMutated();
};
SettingsGeneral.prototype.selectLanguage = function ()
{
kn.showScreenPopup(PopupsLanguagesViewModel);
};

109
dev/Settings/Identities.js Normal file
View file

@ -0,0 +1,109 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsIdentities()
{
var oData = RL.data();
this.identities = oData.identities;
this.legent = ko.computed(function () {
return Utils.i18n('SETTINGS_IDENTITIES/LEGEND_IDENTITIES_FOR', {'EMAIL': oData.accountEmail()});
}, this);
this.processText = ko.computed(function () {
return oData.identitiesLoading() ? Utils.i18n('SETTINGS_IDENTITIES/LOADING_PROCESS') : '';
}, this);
this.visibility = ko.computed(function () {
return '' === this.processText() ? 'hidden' : 'visible';
}, this);
this.identityForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.deleteAccess(false);
}
}, function (oNext) {
if (oNext)
{
oNext.deleteAccess(true);
}
}
]});
this.signature = oData.signature;
this.signatureTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
}
Utils.addSettingsViewModel(SettingsIdentities, 'SettingsIdentities', 'SETTINGS_LABELS/LABEL_IDENTITIES_NAME', 'identities');
SettingsIdentities.prototype.addNewIdentity = function ()
{
kn.showScreenPopup(PopupsIdentityViewModel);
};
SettingsIdentities.prototype.editIdentity = function (oIdentity)
{
kn.showScreenPopup(PopupsIdentityViewModel, [oIdentity]);
};
/**
*
* @param {IdentityModel} oIdentityToRemove
*/
SettingsIdentities.prototype.deleteIdentity = function (oIdentityToRemove)
{
if (oIdentityToRemove && oIdentityToRemove.deleteAccess())
{
this.identityForDeletion(null);
var
fRemoveFolder = function (oIdentity) {
return oIdentityToRemove === oIdentity;
}
;
if (oIdentityToRemove)
{
this.identities.remove(fRemoveFolder);
RL.remote().identityDelete(function () {
RL.accountsAndIdentities();
}, oIdentityToRemove.id);
}
}
};
SettingsIdentities.prototype.onBuild = function (oDom)
{
var self = this;
oDom
.on('click', '.identity-item .e-action', function () {
var oIdentityItem = ko.dataFor(this);
if (oIdentityItem)
{
self.editIdentity(oIdentityItem);
}
})
;
_.delay(function () {
var
oData = RL.data(),
f1 = Utils.settingsSaveHelperSimpleFunction(self.signatureTrigger, self)
;
oData.signature.subscribe(function (sValue) {
RL.remote().saveSettings(f1, {
'Signature': sValue
});
});
}, 50);
};

52
dev/Settings/Personal.js Normal file
View file

@ -0,0 +1,52 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsPersonal()
{
var oData = RL.data();
this.displayName = oData.displayName;
this.replyTo = oData.replyTo;
this.signature = oData.signature;
this.nameTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.replyTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.signatureTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
}
Utils.addSettingsViewModel(SettingsPersonal, 'SettingsPersonal', 'SETTINGS_LABELS/LABEL_PERSONAL_NAME', 'personal');
SettingsPersonal.prototype.onBuild = function ()
{
var self = this;
_.delay(function () {
var
oData = RL.data(),
f1 = Utils.settingsSaveHelperSimpleFunction(self.nameTrigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.replyTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.signatureTrigger, self)
;
oData.displayName.subscribe(function (sValue) {
RL.remote().saveSettings(f1, {
'DisplayName': sValue
});
});
oData.replyTo.subscribe(function (sValue) {
RL.remote().saveSettings(f2, {
'ReplyTo': sValue
});
});
oData.signature.subscribe(function (sValue) {
RL.remote().saveSettings(f3, {
'Signature': sValue
});
});
}, 50);
};

68
dev/Settings/Social.js Normal file
View file

@ -0,0 +1,68 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsSocialScreen()
{
var oData = RL.data();
this.googleEnable = oData.googleEnable;
this.googleActions = oData.googleActions;
this.googleLoggined = oData.googleLoggined;
this.googleUserName = oData.googleUserName;
this.facebookEnable = oData.facebookEnable;
this.facebookActions = oData.facebookActions;
this.facebookLoggined = oData.facebookLoggined;
this.facebookUserName = oData.facebookUserName;
this.twitterEnable = oData.twitterEnable;
this.twitterActions = oData.twitterActions;
this.twitterLoggined = oData.twitterLoggined;
this.twitterUserName = oData.twitterUserName;
this.connectGoogle = Utils.createCommand(this, function () {
if (!this.googleLoggined())
{
RL.googleConnect();
}
}, function () {
return !this.googleLoggined() && !this.googleActions();
});
this.disconnectGoogle = Utils.createCommand(this, function () {
RL.googleDisconnect();
});
this.connectFacebook = Utils.createCommand(this, function () {
if (!this.facebookLoggined())
{
RL.facebookConnect();
}
}, function () {
return !this.facebookLoggined() && !this.facebookActions();
});
this.disconnectFacebook = Utils.createCommand(this, function () {
RL.facebookDisconnect();
});
this.connectTwitter = Utils.createCommand(this, function () {
if (!this.twitterLoggined())
{
RL.twitterConnect();
}
}, function () {
return !this.twitterLoggined() && !this.twitterActions();
});
this.disconnectTwitter = Utils.createCommand(this, function () {
RL.twitterDisconnect();
});
}
Utils.addSettingsViewModel(SettingsSocialScreen, 'SettingsSocial', 'SETTINGS_LABELS/LABEL_SOCIAL_NAME', 'social');

216
dev/Settings/Themes.js Normal file
View file

@ -0,0 +1,216 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsThemes()
{
var
self = this,
oData = RL.data()
;
this.mainTheme = oData.mainTheme;
this.customThemeType = ko.observable(RL.settingsGet('CustomThemeType'));
this.customThemeImg = ko.observable(RL.settingsGet('CustomThemeImg'));
this.themesObjects = ko.observableArray([]);
this.customThemeUploaderProgress = ko.observable(false);
this.customThemeUploaderButton = ko.observable(null);
this.showCustomThemeConfig = ko.computed(function () {
return 'Custom' === this.mainTheme();
}, this);
this.showCustomThemeConfig.subscribe(function () {
Utils.windowResize();
});
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});
this.oLastAjax = null;
this.iTimer = 0;
RL.data().theme.subscribe(function (sValue) {
_.each(this.themesObjects(), function (oTheme) {
oTheme.selected(sValue === oTheme.name);
});
var
oThemeLink = $('#rlThemeLink'),
oThemeStyle = $('#rlThemeStyle'),
sUrl = oThemeLink.attr('href')
;
if (!sUrl)
{
sUrl = oThemeStyle.attr('data-href');
}
if (sUrl)
{
sUrl = sUrl.toString().replace(/\/-\/[^\/]+\/\-\//, '/-/' + sValue + '/-/');
sUrl = sUrl.toString().replace(/\/Css\/[^\/]+\/User\//, '/Css/' + ('Custom' === sValue && window.__rlah ? window.__rlah() || '0' : '0') + '/User/');
if ('Json/' !== sUrl.substring(sUrl.length - 5, sUrl.length))
{
sUrl += 'Json/';
}
window.clearTimeout(self.iTimer);
self.themeTrigger(Enums.SaveSettingsStep.Animate);
if (this.oLastAjax && this.oLastAjax.abort)
{
this.oLastAjax.abort();
}
this.oLastAjax = $.ajax({
'url': sUrl,
'dataType': 'json'
}).done(function(aData) {
if (aData && Utils.isArray(aData) && 2 === aData.length)
{
if (oThemeLink && oThemeLink[0] && (!oThemeStyle || !oThemeStyle[0]))
{
oThemeStyle = $('<style id="rlThemeStyle"></style>');
oThemeLink.after(oThemeStyle);
oThemeLink.remove();
}
if (oThemeStyle && oThemeStyle[0])
{
oThemeStyle.attr('data-href', sUrl).attr('data-theme', aData[0]).text(aData[1]);
}
self.themeTrigger(Enums.SaveSettingsStep.TrueResult);
}
}).always(function() {
self.iTimer = window.setTimeout(function () {
self.themeTrigger(Enums.SaveSettingsStep.Idle);
}, 1000);
self.oLastAjax = null;
});
}
RL.remote().saveSettings(null, {
'Theme': sValue
});
}, this);
}
Utils.addSettingsViewModel(SettingsThemes, 'SettingsThemes', 'SETTINGS_LABELS/LABEL_THEMES_NAME', 'themes');
SettingsThemes.prototype.removeCustomThemeImg = function ()
{
this.customThemeImg('');
};
SettingsThemes.prototype.onBuild = function ()
{
var
self = this,
sCurrentTheme = RL.data().theme()
;
this.themesObjects(_.map(RL.data().themes(), function (sTheme) {
return {
'name': sTheme,
'nameDisplay': Utils.convertThemeName(sTheme),
'selected': ko.observable(sTheme === sCurrentTheme),
'themePreviewSrc': RL.link().themePreviewLink(sTheme)
};
}));
_.delay(function () {
self.customThemeType.subscribe(function (sValue) {
RL.remote().saveSettings(function () {
RL.data().theme.valueHasMutated();
}, {
'CustomThemeType': sValue
});
});
self.customThemeImg.subscribe(function (sValue) {
RL.remote().saveSettings(function () {
RL.data().theme.valueHasMutated();
}, {
'CustomThemeImg': sValue
});
});
}, 50);
this.initCustomThemeUploader();
};
SettingsThemes.prototype.initCustomThemeUploader = function ()
{
if (this.customThemeUploaderButton())
{
var
oJua = new Jua({
'action': RL.link().uploadBackground(),
'name': 'uploader',
'queueSize': 1,
'multipleSizeLimit': 1,
'disableFolderDragAndDrop': true,
'clickElement': this.customThemeUploaderButton(),
'onSelect': _.bind(function (sId, oData) {
var
sFileName = Utils.isUnd(oData.FileName) ? '' : oData.FileName.toString(),
sFileNameExt = sFileName.substring(sFileName.length - 4, sFileName.length),
mSize = Utils.isNormal(oData.Size) ? Utils.pInt(oData.Size) : null
;
if (-1 === Utils.inArray(sFileNameExt, ['jpeg', '.jpg', '.png']))
{
window.alert(Utils.i18n('SETTINGS_THEMES/ERROR_FILE_TYPE_ERROR'));
return false;
}
if (1024 * 1024 < mSize)
{
window.alert(Utils.i18n('SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG'));
return false;
}
return true;
}, this),
'onStart': _.bind(function () {
this.customThemeUploaderProgress(true);
}, this),
'onComplete': _.bind(function (sId, bResult, oData) {
if (!bResult || !oData || !oData.Result)
{
window.alert(
oData && oData.ErrorCode ? Utils.getUploadErrorDescByCode(oData.ErrorCode) : Utils.getUploadErrorDescByCode(Enums.UploadErrorCode.Unknown)
);
}
else
{
this.customThemeImg(oData.Result);
}
this.customThemeUploaderProgress(false);
}, this)
})
;
return !!oJua;
}
return false;
};