2016-06-06 18:40:38 +03:00
|
|
|
/**
|
|
|
|
* @author Björn Schießle <bjoern@schiessle.org>
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2016, Bjoern Schiessle
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
2016-06-22 14:44:33 +03:00
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
2016-06-06 18:40:38 +03:00
|
|
|
* License, or (at your opinion) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
|
|
|
*/
|
2016-06-09 22:46:30 +03:00
|
|
|
|
|
|
|
function setThemingValue(setting, value) {
|
2016-06-16 18:30:18 +03:00
|
|
|
OC.msg.startSaving('#theming_settings_msg');
|
2016-06-09 22:46:30 +03:00
|
|
|
$.post(
|
|
|
|
OC.generateUrl('/apps/theming/ajax/updateStylesheet'), {'setting' : setting, 'value' : value}
|
2016-06-16 18:30:18 +03:00
|
|
|
).done(function(response) {
|
|
|
|
OC.msg.finishedSaving('#theming_settings_msg', response);
|
|
|
|
}).fail(function(response) {
|
|
|
|
OC.msg.finishedSaving('#theming_settings_msg', response);
|
|
|
|
});
|
2016-06-09 22:46:30 +03:00
|
|
|
preview(setting, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
function preview(setting, value) {
|
|
|
|
if (setting === 'color') {
|
|
|
|
var headerClass = document.getElementById('header');
|
|
|
|
headerClass.style.background = value;
|
|
|
|
headerClass.style.backgroundImage = '../img/logo-icon.svg';
|
|
|
|
}
|
2016-06-21 22:21:46 +03:00
|
|
|
if (setting === 'logoMime') {
|
|
|
|
console.log(setting);
|
2016-06-09 22:46:30 +03:00
|
|
|
var logos = document.getElementsByClassName('logo-icon');
|
2016-06-22 15:04:54 +03:00
|
|
|
var timestamp = new Date().getTime();
|
2016-06-21 22:21:46 +03:00
|
|
|
if(value !== '') {
|
2016-06-22 15:04:54 +03:00
|
|
|
logos[0].style.background = "url('" + OC.generateUrl('/apps/theming/logo') + "?v" + timestamp + "')";
|
2016-06-22 14:44:33 +03:00
|
|
|
logos[0].style.backgroundSize = "62px 34px";
|
2016-06-21 22:21:46 +03:00
|
|
|
} else {
|
2016-06-22 15:04:54 +03:00
|
|
|
logos[0].style.background = "url('" + OC.getRootPath() + '/core/img/logo-icon.svg?v' + timestamp +"')";
|
2016-06-22 14:44:33 +03:00
|
|
|
logos[0].style.backgroundSize = "62px 34px";
|
2016-06-09 22:46:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function () {
|
2016-06-27 21:36:23 +03:00
|
|
|
$('#theming [data-toggle="tooltip"]').tooltip();
|
2016-06-09 22:46:30 +03:00
|
|
|
|
2016-06-21 22:21:46 +03:00
|
|
|
var uploadParamsLogo = {
|
|
|
|
pasteZone: null,
|
2016-06-21 22:46:27 +03:00
|
|
|
dropZone: null,
|
2016-06-21 22:21:46 +03:00
|
|
|
done: function (e, response) {
|
|
|
|
preview('logoMime', response.result.data.name);
|
|
|
|
OC.msg.finishedSaving('#theming_settings_msg', response.result);
|
|
|
|
},
|
|
|
|
submit: function(e, response) {
|
|
|
|
OC.msg.startSaving('#theming_settings_msg');
|
|
|
|
},
|
|
|
|
fail: function (e, data){
|
|
|
|
OC.msg.finishedSaving('#theming_settings_msg', response);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
var uploadParamsLogin = {
|
2016-06-09 22:46:30 +03:00
|
|
|
pasteZone: null,
|
2016-06-21 22:46:27 +03:00
|
|
|
dropZone: null,
|
2016-06-16 18:30:18 +03:00
|
|
|
done: function (e, response) {
|
2016-06-21 22:21:46 +03:00
|
|
|
preview('backgroundMime', response.result.data.name);
|
2016-06-16 18:30:18 +03:00
|
|
|
OC.msg.finishedSaving('#theming_settings_msg', response.result);
|
2016-06-09 22:46:30 +03:00
|
|
|
},
|
2016-06-16 18:30:18 +03:00
|
|
|
submit: function(e, response) {
|
|
|
|
OC.msg.startSaving('#theming_settings_msg');
|
2016-06-09 22:46:30 +03:00
|
|
|
},
|
|
|
|
fail: function (e, data){
|
2016-06-16 18:30:18 +03:00
|
|
|
OC.msg.finishedSaving('#theming_settings_msg', response);
|
2016-06-09 22:46:30 +03:00
|
|
|
}
|
|
|
|
};
|
2016-06-22 14:44:33 +03:00
|
|
|
|
2016-06-21 22:21:46 +03:00
|
|
|
$('#uploadlogo').fileupload(uploadParamsLogo);
|
|
|
|
$('#upload-login-background').fileupload(uploadParamsLogin);
|
2016-06-09 22:46:30 +03:00
|
|
|
|
|
|
|
$('#theming-name').keyup(function (e) {
|
|
|
|
if (e.keyCode == 13) {
|
|
|
|
setThemingValue('name', $(this).val());
|
|
|
|
}
|
|
|
|
}).focusout(function (e) {
|
|
|
|
setThemingValue('name', $(this).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#theming-url').keyup(function (e) {
|
|
|
|
if (e.keyCode == 13) {
|
|
|
|
setThemingValue('url', $(this).val());
|
|
|
|
}
|
|
|
|
}).focusout(function (e) {
|
|
|
|
setThemingValue('url', $(this).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#theming-slogan').keyup(function (e) {
|
|
|
|
if (e.keyCode == 13) {
|
|
|
|
setThemingValue('slogan', $(this).val());
|
|
|
|
}
|
|
|
|
}).focusout(function (e) {
|
|
|
|
setThemingValue('slogan', $(this).val());
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#theming-color').change(function (e) {
|
|
|
|
setThemingValue('color', '#' + $(this).val());
|
|
|
|
});
|
2016-06-22 14:44:33 +03:00
|
|
|
|
2016-06-09 22:46:30 +03:00
|
|
|
$('.theme-undo').click(function (e) {
|
|
|
|
var setting = $(this).data('setting');
|
2016-06-16 18:30:18 +03:00
|
|
|
OC.msg.startSaving('#theming_settings_msg');
|
2016-06-09 22:46:30 +03:00
|
|
|
$.post(
|
|
|
|
OC.generateUrl('/apps/theming/ajax/undoChanges'), {'setting' : setting}
|
2016-06-16 18:30:18 +03:00
|
|
|
).done(function(response) {
|
2016-06-09 22:46:30 +03:00
|
|
|
if (setting === 'color') {
|
|
|
|
var colorPicker = document.getElementById('theming-color');
|
2016-06-16 18:30:18 +03:00
|
|
|
colorPicker.style.backgroundColor = response.data.value;
|
|
|
|
colorPicker.value = response.data.value.slice(1);
|
2016-06-21 22:21:46 +03:00
|
|
|
} else if (setting !== 'logoMime' && setting !== 'backgroundMime') {
|
2016-06-09 22:46:30 +03:00
|
|
|
var input = document.getElementById('theming-'+setting);
|
2016-06-16 18:30:18 +03:00
|
|
|
input.value = response.data.value;
|
2016-06-09 22:46:30 +03:00
|
|
|
}
|
2016-06-16 18:30:18 +03:00
|
|
|
preview(setting, response.data.value);
|
|
|
|
OC.msg.finishedSaving('#theming_settings_msg', response);
|
2016-06-09 22:46:30 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|