v1.18.x
Baris Soner Usakli 11 years ago
parent 8c14a59f93
commit 893efa5f2a

@ -19,6 +19,7 @@ define(['uploader'], function(uploader) {
numFields = fields.length, numFields = fields.length,
saveBtn = document.getElementById('save'), saveBtn = document.getElementById('save'),
x, key, inputType; x, key, inputType;
for (x = 0; x < numFields; x++) { for (x = 0; x < numFields; x++) {
key = fields[x].getAttribute('data-field'); key = fields[x].getAttribute('data-field');
inputType = fields[x].getAttribute('type'); inputType = fields[x].getAttribute('type');
@ -45,29 +46,36 @@ define(['uploader'], function(uploader) {
} }
saveBtn.addEventListener('click', function(e) { saveBtn.addEventListener('click', function(e) {
var key, value;
e.preventDefault(); e.preventDefault();
for (x = 0; x < numFields; x++) { for (x = 0; x < numFields; x++) {
key = fields[x].getAttribute('data-field'); saveField(fields[x]);
if (fields[x].nodeName === 'INPUT') { }
inputType = fields[x].getAttribute('type'); });
function saveField(field) {
var key = field.getAttribute('data-field'),
value;
if (field.nodeName === 'INPUT') {
inputType = field.getAttribute('type');
switch (inputType) { switch (inputType) {
case 'text': case 'text':
case 'password': case 'password':
case 'textarea': case 'textarea':
case 'number': case 'number':
value = fields[x].value; value = field.value;
break; break;
case 'checkbox': case 'checkbox':
value = fields[x].checked ? '1' : '0'; value = field.checked ? '1' : '0';
break; break;
} }
} else if (fields[x].nodeName === 'TEXTAREA') { } else if (field.nodeName === 'TEXTAREA') {
value = fields[x].value; value = field.value;
} else if (fields[x].nodeName === 'SELECT') { } else if (field.nodeName === 'SELECT') {
value = fields[x].value; value = field.value;
} }
socket.emit('admin.config.set', { socket.emit('admin.config.set', {
@ -84,6 +92,10 @@ define(['uploader'], function(uploader) {
}); });
} }
if(app.config[key] !== undefined) {
app.config[key] = value;
}
app.alert({ app.alert({
alert_id: 'config_status', alert_id: 'config_status',
timeout: 2500, timeout: 2500,
@ -94,7 +106,6 @@ define(['uploader'], function(uploader) {
}); });
} }
});
$('#uploadLogoBtn').on('click', function() { $('#uploadLogoBtn').on('click', function() {
uploader.open(RELATIVE_PATH + '/admin/uploadlogo', {}, 0, function(image) { uploader.open(RELATIVE_PATH + '/admin/uploadlogo', {}, 0, function(image) {

Loading…
Cancel
Save