summaryrefslogtreecommitdiffstats
path: root/apps/theming/js/settings-admin.js
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2016-06-09 21:46:30 +0200
committerLukas Reschke <lukas@owncloud.com>2016-06-27 10:26:22 +0200
commit10f6ca20bcf521f125700f892b09bf745a595ea7 (patch)
tree668da5e4ba4580ede60773abf254e42c46fb5a97 /apps/theming/js/settings-admin.js
parent363b76faee862e1cccd826d25a0f208ef656e1bc (diff)
downloadnextcloud-server-10f6ca20bcf521f125700f892b09bf745a595ea7.tar.gz
nextcloud-server-10f6ca20bcf521f125700f892b09bf745a595ea7.zip
write theme settings to database
Diffstat (limited to 'apps/theming/js/settings-admin.js')
-rw-r--r--apps/theming/js/settings-admin.js83
1 files changed, 83 insertions, 0 deletions
diff --git a/apps/theming/js/settings-admin.js b/apps/theming/js/settings-admin.js
index 317773a32c2..76456543076 100644
--- a/apps/theming/js/settings-admin.js
+++ b/apps/theming/js/settings-admin.js
@@ -18,3 +18,86 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
+
+function setThemingValue(setting, value) {
+ $.post(
+ OC.generateUrl('/apps/theming/ajax/updateStylesheet'), {'setting' : setting, 'value' : value}
+ );
+ 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';
+
+ }
+ if (setting === 'logoName') {
+ var logos = document.getElementsByClassName('logo-icon');
+ for (var i = 0; i < logos.length; i++) {
+ logos[i].style.background= "url('" + OC.getRootPath() + "/themes/theming-app/core/img/" + value + "')";
+ }
+ }
+}
+
+$(document).ready(function () {
+
+ var uploadparms = {
+ pasteZone: null,
+ done: function (e, data) {
+ preview('logoName', data.result.name);
+ },
+ submit: function(e, data) {
+ },
+ fail: function (e, data){
+ }
+ };
+
+ $('#uploadlogo').fileupload(uploadparms);
+
+ $('#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());
+ });
+
+ $('.theme-undo').click(function (e) {
+ var setting = $(this).data('setting');
+ $.post(
+ OC.generateUrl('/apps/theming/ajax/undoChanges'), {'setting' : setting}
+ ).done(function(data) {
+ if (setting === 'color') {
+ var colorPicker = document.getElementById('theming-color');
+ colorPicker.style.backgroundColor = data.value;
+ colorPicker.value = data.value.slice(1);
+ } else if (setting !== 'logoName') {
+ var input = document.getElementById('theming-'+setting);
+ input.value = data.value;
+ }
+ preview(setting, data.value);
+ });
+ });
+});