Skip to content

Commit

Permalink
Theming: Hide undo button on default values
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusknorr committed Aug 25, 2016
1 parent 9b5d475 commit 75afc96
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
30 changes: 29 additions & 1 deletion apps/theming/js/settings-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand All @@ -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,
Expand Down Expand Up @@ -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);
});
Expand Down
4 changes: 3 additions & 1 deletion apps/theming/templates/settings-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@
</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>
Expand Down

0 comments on commit 75afc96

Please sign in to comment.