summaryrefslogtreecommitdiffstats
path: root/apps/theming/js/settings-admin.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/theming/js/settings-admin.js')
-rw-r--r--apps/theming/js/settings-admin.js114
1 files changed, 41 insertions, 73 deletions
diff --git a/apps/theming/js/settings-admin.js b/apps/theming/js/settings-admin.js
index 1f416bb2940..25ac092a964 100644
--- a/apps/theming/js/settings-admin.js
+++ b/apps/theming/js/settings-admin.js
@@ -35,7 +35,6 @@ function setThemingValue(setting, value) {
OC.msg.finishedSaving('#theming_settings_msg', response);
$('#theming_settings_loading').hide();
});
-
}
function preview(setting, value, serverCssUrl) {
@@ -69,17 +68,6 @@ function preview(setting, value, serverCssUrl) {
}
reloadStylesheets(OC.generateUrl('/apps/theming/styles'));
- // Preview images
- var timestamp = new Date().getTime();
- if (setting === 'logoMime') {
- var previewImageLogo = document.getElementById('theming-preview-logo');
- if (value !== '') {
- previewImageLogo.src = OC.generateUrl('/apps/theming/logo') + "?v" + timestamp;
- } else {
- previewImageLogo.src = OC.getRootPath() + '/core/img/logo.svg?v' + timestamp;
- }
- }
-
if (setting === 'name') {
window.document.title = t('core', 'Admin') + " - " + value;
}
@@ -119,53 +107,36 @@ $(document).ready(function () {
$('#theming .theme-undo').each(function() {
var setting = $(this).data('setting');
var value = $('#theming-'+setting).val();
- if(setting === 'logoMime' || setting === 'backgroundMime') {
- var value = $('#current-'+setting).val();
- }
hideUndoButton(setting, value);
});
- var uploadParamsLogo = {
- pasteZone: null,
- dropZone: null,
- done: function (e, response) {
- preview('logoMime', response.result.data.name);
- OC.msg.finishedSaving('#theming_settings_msg', response.result);
- $('label#uploadlogo').addClass('icon-upload').removeClass('icon-loading-small');
- $('.theme-undo[data-setting=logoMime]').show();
- },
- submit: function(e, response) {
- startLoading();
- $('label#uploadlogo').removeClass('icon-upload').addClass('icon-loading-small');
- },
- fail: function (e, response){
- OC.msg.finishedError('#theming_settings_msg', response._response.jqXHR.responseJSON.data.message);
- $('label#uploadlogo').addClass('icon-upload').removeClass('icon-loading-small');
- $('#theming_settings_loading').hide();
- }
- };
- var uploadParamsLogin = {
+ $('.fileupload').fileupload({
pasteZone: null,
dropZone: null,
done: function (e, response) {
- preview('backgroundMime', response.result.data.name);
+ var $form = $(e.target).closest('form');
+ var key = $form.data('image-key');
+
+ preview(key + 'Mime', response.result.data.name, response.result.data.serverCssUrl);
+ $form.find('.image-preview').css('backgroundImage', response.result.data.url + '?v=' + new Date().getTime());
OC.msg.finishedSaving('#theming_settings_msg', response.result);
- $('label#upload-login-background').addClass('icon-upload').removeClass('icon-loading-small');
- $('.theme-undo[data-setting=backgroundMime]').show();
+ $form.find('label.button').addClass('icon-upload').removeClass('icon-loading-small');
+ $form.find('.theme-undo').show();
},
submit: function(e, response) {
+ var $form = $(e.target).closest('form');
+ var key = $form.data('image-key');
startLoading();
- $('label#upload-login-background').removeClass('icon-upload').addClass('icon-loading-small');
+ $form.find('label.button').removeClass('icon-upload').addClass('icon-loading-small');
},
fail: function (e, response){
- $('label#upload-login-background').removeClass('icon-loading-small').addClass('icon-upload');
+ var $form = $(e.target).closest('form');
OC.msg.finishedError('#theming_settings_msg', response._response.jqXHR.responseJSON.data.message);
+ $form.find('label.button').addClass('icon-upload').removeClass('icon-loading-small');
$('#theming_settings_loading').hide();
}
- };
+ });
- $('#uploadlogo').fileupload(uploadParamsLogo);
- $('#upload-login-background').fileupload(uploadParamsLogin);
// clicking preview should also trigger file upload dialog
$('#theming-preview-logo').on('click', function(e) {
e.stopPropagation();
@@ -202,46 +173,42 @@ $(document).ready(function () {
$('#theming-name').change(function(e) {
var el = $(this);
- if(checkName()){
- $.when(el.focusout()).then(function() {
- setThemingValue('name', $(this).val());
- });
- if (e.keyCode == 13) {
- setThemingValue('name', $(this).val());
- }
- }
});
- $('#theming-url').change(function(e) {
+ $('#theming input[type=text]').change(function(e) {
var el = $(this);
- $.when(el.focusout()).then(function() {
- setThemingValue('url', $(this).val());
- });
- if (e.keyCode == 13) {
- setThemingValue('url', $(this).val());
+ var setting = el.parent().find('div[data-setting]').data('setting');
+ var value = $(this).val();
+
+ if(setting === 'color') {
+ if (value.indexOf('#') !== 0) {
+ value = '#' + value;
+ }
+ }
+ if(setting === 'name') {
+ if(checkName()){
+ $.when(el.focusout()).then(function() {
+ setThemingValue('name', value);
+ });
+ if (e.keyCode == 13) {
+ setThemingValue('name', value);
+ }
+ }
}
- });
- $('#theming-slogan').change(function(e) {
- var el = $(this);
$.when(el.focusout()).then(function() {
- setThemingValue('slogan', $(this).val());
+ setThemingValue(setting, value);
});
if (e.keyCode == 13) {
- setThemingValue('slogan', $(this).val());
+ setThemingValue(setting, value);
}
});
- $('#theming-color').change(function (e) {
- var color = $(this).val();
- if (color.indexOf('#') !== 0) {
- color = '#' + color;
- }
- setThemingValue('color', color);
- });
-
$('.theme-undo').click(function (e) {
var setting = $(this).data('setting');
+ var $form = $(this).closest('form');
+ var image = $form.data('image-key');
+
startLoading();
$('.theme-undo[data-setting=' + setting + ']').hide();
$.post(
@@ -251,7 +218,7 @@ $(document).ready(function () {
var colorPicker = document.getElementById('theming-color');
colorPicker.style.backgroundColor = response.data.value;
colorPicker.value = response.data.value.slice(1).toUpperCase();
- } else if (setting !== 'logoMime' && setting !== 'backgroundMime') {
+ } else if (!image) {
var input = document.getElementById('theming-'+setting);
input.value = response.data.value;
}
@@ -262,11 +229,12 @@ $(document).ready(function () {
$('.theme-remove-bg').click(function() {
startLoading();
$.post(
- OC.generateUrl('/apps/theming/ajax/updateLogo'), {'backgroundColor' : true}
+ OC.generateUrl('/apps/theming/ajax/updateStylesheet'), {'setting' : 'backgroundMime', 'value' : 'backgroundColor'}
).done(function(response) {
- preview('backgroundMime', 'backgroundColor');
+ preview('backgroundMime', 'backgroundColor', response.data.serverCssUrl);
}).fail(function(response) {
OC.msg.finishedSaving('#theming_settings_msg', response);
+ $('#theming_settings_loading').hide();
});
});