forked from deblan/side_menu
73 lines
2.1 KiB
JavaScript
73 lines
2.1 KiB
JavaScript
/**
|
|
* @license GNU AGPL version 3 or any later version
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
* License, or (at your option) 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/>.
|
|
*/
|
|
|
|
const elements = [
|
|
'side-menu-background-color',
|
|
'side-menu-background-color-to',
|
|
'side-menu-current-app-background-color',
|
|
'side-menu-text-color',
|
|
'side-menu-opener',
|
|
'side-menu-opener-position',
|
|
'side-menu-opener-hover',
|
|
'side-menu-opener-only',
|
|
'side-menu-display-logo',
|
|
'side-menu-hide-when-no-apps',
|
|
'side-menu-size-icon',
|
|
'side-menu-size-text',
|
|
'side-menu-cache',
|
|
];
|
|
|
|
const selector = '#side-menu-message';
|
|
|
|
const saveSettings = (key) => {
|
|
const element = elements[key]
|
|
const name = $('#' + element).attr('name')
|
|
let value = $('#' + element).val()
|
|
const size = elements.length
|
|
|
|
if (element === 'side-menu-cache') {
|
|
value++
|
|
}
|
|
|
|
OCP.AppConfig.setValue('side_menu', name, value, {
|
|
success: () => {
|
|
OC.msg.finishedSuccess(
|
|
selector,
|
|
t('side_menu', (key + 1) + '/' + size)
|
|
)
|
|
|
|
if (key < size - 1) {
|
|
saveSettings(++key)
|
|
} else {
|
|
OC.msg.finishedSuccess(selector, t('side_menu', 'Saved'))
|
|
}
|
|
},
|
|
error: () => {
|
|
OC.msg.finishedError(selector, t('side_menu', 'Error while saving "' + element + '"'))
|
|
}
|
|
});
|
|
}
|
|
|
|
$(document).ready(() => {
|
|
$('#side-menu-save').on('click', (event) => {
|
|
event.preventDefault()
|
|
OC.msg.startSaving(selector)
|
|
|
|
saveSettings(0)
|
|
});
|
|
});
|