Remove user customized theme (simplification)

Added theme folders (regardless of the RainLoop version)
This commit is contained in:
RainLoop Team 2014-05-06 01:38:49 +04:00
parent f3823333d7
commit d08689759d
26 changed files with 125 additions and 618 deletions

View file

@ -14,7 +14,6 @@ function AdminGeneral()
this.theme = oData.theme;
this.allowThemes = oData.allowThemes;
this.allowCustomTheme = oData.allowCustomTheme;
this.allowLanguagesOnSettings = oData.allowLanguagesOnSettings;
this.allowAdditionalAccounts = oData.allowAdditionalAccounts;
this.allowIdentities = oData.allowIdentities;
@ -63,12 +62,6 @@ AdminGeneral.prototype.onBuild = function ()
});
});
self.allowCustomTheme.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'AllowCustomTheme': bValue ? '1' : '0'
});
});
self.allowAdditionalAccounts.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'AllowAdditionalAccounts': bValue ? '1' : '0'

View file

@ -6,13 +6,9 @@
function LinkBuilder()
{
this.sBase = '#/';
this.sCdnStaticDomain = RL.settingsGet('CdnStaticDomain');
this.sVersion = RL.settingsGet('Version');
this.sSpecSuffix = RL.settingsGet('AuthAccountHash') || '0';
this.sServer = (RL.settingsGet('IndexFile') || './') + '?';
this.sCdnStaticDomain = '' === this.sCdnStaticDomain ? this.sCdnStaticDomain :
('/' === this.sCdnStaticDomain.substr(-1) ? this.sCdnStaticDomain : this.sCdnStaticDomain + '/');
}
/**
@ -248,8 +244,7 @@ LinkBuilder.prototype.exportContactsCsv = function ()
*/
LinkBuilder.prototype.emptyContactPic = function ()
{
return ('' === this.sCdnStaticDomain ? 'rainloop/v/' : this.sCdnStaticDomain) +
this.sVersion + '/static/css/images/empty-contact.png';
return 'rainloop/v/' + this.sVersion + '/static/css/images/empty-contact.png';
};
/**
@ -258,8 +253,7 @@ LinkBuilder.prototype.emptyContactPic = function ()
*/
LinkBuilder.prototype.sound = function (sFileName)
{
return ('' === this.sCdnStaticDomain ? 'rainloop/v/' : this.sCdnStaticDomain) +
this.sVersion + '/static/sounds/' + sFileName;
return 'rainloop/v/' + this.sVersion + '/static/sounds/' + sFileName;
};
/**
@ -268,8 +262,14 @@ LinkBuilder.prototype.sound = function (sFileName)
*/
LinkBuilder.prototype.themePreviewLink = function (sTheme)
{
return ('' === this.sCdnStaticDomain ? 'rainloop/v/' : this.sCdnStaticDomain) +
this.sVersion + '/themes/' + encodeURI(sTheme) + '/images/preview.png';
var sPrefix = 'rainloop/v/' + this.sVersion + '/';
if ('@custom' === sTheme.substr(-7))
{
sTheme = Utils.trim(sTheme.substring(0, sTheme.length - 7));
sPrefix = '';
}
return sPrefix + 'themes/' + encodeURI(sTheme) + '/images/preview.png';
};
/**
@ -277,8 +277,7 @@ LinkBuilder.prototype.themePreviewLink = function (sTheme)
*/
LinkBuilder.prototype.notificationMailIcon = function ()
{
return ('' === this.sCdnStaticDomain ? 'rainloop/v/' : this.sCdnStaticDomain) +
this.sVersion + '/static/css/images/icom-message-notification.png';
return 'rainloop/v/' + this.sVersion + '/static/css/images/icom-message-notification.png';
};
/**
@ -286,8 +285,7 @@ LinkBuilder.prototype.notificationMailIcon = function ()
*/
LinkBuilder.prototype.openPgpJs = function ()
{
return ('' === this.sCdnStaticDomain ? 'rainloop/v/' : this.sCdnStaticDomain) +
this.sVersion + '/static/js/openpgp.min.js';
return 'rainloop/v/' + this.sVersion + '/static/js/openpgp.min.js';
};
/**

View file

@ -934,7 +934,6 @@ Utils.initDataConstructorBySettings = function (oData)
}
});
oData.allowCustomTheme = ko.observable(false);
oData.allowAdditionalAccounts = ko.observable(false);
oData.allowIdentities = ko.observable(false);
oData.allowGravatar = ko.observable(false);
@ -1262,7 +1261,12 @@ Utils.disableSettingsViewModel = function (SettingsViewModelClass)
Utils.convertThemeName = function (sTheme)
{
return Utils.trim(sTheme.replace(/[^a-zA-Z]/g, ' ').replace(/([A-Z])/g, ' $1').replace(/[\s]+/g, ' '));
if ('@custom' === sTheme.substr(-7))
{
sTheme = Utils.trim(sTheme.substring(0, sTheme.length - 7));
}
return Utils.trim(sTheme.replace(/[^a-zA-Z]+/g, ' ').replace(/([A-Z])/g, ' $1').replace(/[\s]+/g, ' '));
};
/**

View file

@ -11,22 +11,8 @@ function SettingsThemes()
;
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;
@ -52,7 +38,7 @@ function SettingsThemes()
if (sUrl)
{
sUrl = sUrl.toString().replace(/\/-\/[^\/]+\/\-\//, '/-/' + sValue + '/-/');
sUrl = sUrl.toString().replace(/\/Css\/[^\/]+\/User\//, '/Css/' + ('Custom' === sValue && window.__rlah ? window.__rlah() || '0' : '0') + '/User/');
sUrl = sUrl.toString().replace(/\/Css\/[^\/]+\/User\//, '/Css/0/User/');
if ('Json/' !== sUrl.substring(sUrl.length - 5, sUrl.length))
{
@ -115,18 +101,9 @@ function SettingsThemes()
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()
;
var sCurrentTheme = RL.data().theme();
this.themesObjects(_.map(RL.data().themes(), function (sTheme) {
return {
'name': sTheme,
@ -135,92 +112,4 @@ SettingsThemes.prototype.onBuild = function ()
'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()
})
;
oJua
.on('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))
.on('onStart', _.bind(function () {
this.customThemeUploaderProgress(true);
}, this))
.on('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;
};

View file

@ -84,7 +84,6 @@ AbstractData.prototype.populateDataOnStart = function()
this.mainLanguage(RL.settingsGet('Language'));
this.mainTheme(RL.settingsGet('Theme'));
this.allowCustomTheme(!!RL.settingsGet('AllowCustomTheme'));
this.allowAdditionalAccounts(!!RL.settingsGet('AllowAdditionalAccounts'));
this.allowIdentities(!!RL.settingsGet('AllowIdentities'));
this.allowGravatar(!!RL.settingsGet('AllowGravatar'));