diff options
author | Julius Haertl <jus@bitgrid.net> | 2016-08-24 12:34:45 +0300 |
---|---|---|
committer | Julius Haertl <jus@bitgrid.net> | 2016-08-26 13:08:12 +0300 |
commit | 3d38cb95709e735483a644e26bd8c444b07c3317 (patch) | |
tree | 8ba76953ded6beb04a9c62522779fd58586eaeee /apps/theming | |
parent | d95aec2ed2a8a6f9afe169e828d1bbeb0a316618 (diff) |
Theming: Hide undo button on default values
Diffstat (limited to 'apps/theming')
-rw-r--r-- | apps/theming/js/settings-admin.js | 30 | ||||
-rw-r--r-- | apps/theming/templates/settings-admin.php | 4 |
2 files changed, 32 insertions, 2 deletions
diff --git a/apps/theming/js/settings-admin.js b/apps/theming/js/settings-admin.js index a18874941e8..77777d2dde9 100644 --- a/apps/theming/js/settings-admin.js +++ b/apps/theming/js/settings-admin.js @@ -109,6 +109,25 @@ function preview(setting, value) { } else { previewImage.style.backgroundImage = "url('" + OC.getRootPath() + '/core/img/background.jpg?v' + timestamp + "')"; } + + } + hideUndoButton(setting, value); +} + +function hideUndoButton(setting, value) { + var themingDefaults = { + name: 'Nextcloud', + slogan: t('lib', 'a safe home for all your data'), + url: 'https://nextcloud.com', + color: '#0082c9', + logoMime: '', + backgroundMime: '' + }; + + if (value === themingDefaults[setting] || value === '') { + $('.theme-undo[data-setting=' + setting + ']').hide(); + } else { + $('.theme-undo[data-setting=' + setting + ']').show(); } } @@ -117,6 +136,14 @@ $(document).ready(function () { $('html > head').append($('<style type="text/css" id="previewStyles"></style>')); + $('#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, @@ -192,11 +219,12 @@ $(document).ready(function () { if (setting === 'color') { var colorPicker = document.getElementById('theming-color'); colorPicker.style.backgroundColor = response.data.value; - colorPicker.value = response.data.value.slice(1); + colorPicker.value = response.data.value.slice(1).toUpperCase(); } else if (setting !== 'logoMime' && setting !== 'backgroundMime') { var input = document.getElementById('theming-'+setting); input.value = response.data.value; } + preview(setting, response.data.value); OC.msg.finishedSaving('#theming_settings_msg', response); }); diff --git a/apps/theming/templates/settings-admin.php b/apps/theming/templates/settings-admin.php index 66288d37656..b6c97040230 100644 --- a/apps/theming/templates/settings-admin.php +++ b/apps/theming/templates/settings-admin.php @@ -60,14 +60,16 @@ style('theming', 'settings-admin'); </p> <p> <form class="uploadButton" method="post" action="<?php p($_['uploadLogoRoute']) ?>"> + <input type="hidden" id="current-logoMime" name="current-logoMime" value="<?php p($_['logoMime']); ?>" /> <label for="uploadlogo"><span><?php p($l->t('Logo')) ?></span></label> - <input id="uploadlogo" class="upload-logo-field" name="uploadlogo" type="file"> + <input id="uploadlogo" class="upload-logo-field" name="uploadlogo" type="file" /> <label for="uploadlogo" class="button icon-upload svg" id="uploadlogo" title="<?php p($l->t('Upload new logo')) ?>"></label> <span data-setting="logoMime" data-toggle="tooltip" data-original-title="<?php p($l->t('reset to default')); ?>" class="theme-undo icon icon-history"></span> </form> </p> <p> <form class="uploadButton" method="post" action="<?php p($_['uploadLogoRoute']) ?>"> + <input type="hidden" id="current-backgroundMime" name="current-backgroundMime" value="<?php p($_['backgroundMime']); ?>" /> <label for="upload-login-background"><span><?php p($l->t('Log in image')) ?></span></label> <input id="upload-login-background" class="upload-logo-field" name="upload-login-background" type="file"> <label for="upload-login-background" class="button icon-upload svg" id="upload-login-background" title="<?php p($l->t("Upload new login background")) ?>"></label> |