fixes checkboxes for settingsv2 (deja vu)

v1.18.x
psychobunny 10 years ago
parent a3c41e7fdb
commit fdc66eb607

@ -14,7 +14,7 @@
activateMobile(); activateMobile();
} }
$(window).on('action:ajaxify.end', function(ev, data) { $(window).on('action:ajaxify.contentLoaded', function(ev, data) {
var url = data.url; var url = data.url;
selectMenuItem(data.url); selectMenuItem(data.url);
@ -23,6 +23,8 @@
setupCheckboxes(); setupCheckboxes();
}); });
$(window).on('action:admin.settingsLoaded', setupCheckboxes);
$('[component="logout"]').on('click', app.logout); $('[component="logout"]').on('click', app.logout);
$(window).resize(setupHeaderMenu); $(window).resize(setupHeaderMenu);
@ -175,31 +177,32 @@
return $('[type=checkbox]').show(); return $('[type=checkbox]').show();
} }
$('[type=checkbox]').change(function() {
var checked = $(this).is(':checked');
$(this).siblings('[class*=fa-]').toggleClass('fa-toggle-off', !checked)
.toggleClass('fa-toggle-on', checked);
});
$('[type=checkbox]').each(function() { $('[type=checkbox]').each(function() {
var checkbox = $(this), var checkbox = $(this),
checked = checkbox.is(':checked'); checked = checkbox.is(':checked');
if (checkbox.attr('data-toggle-added')) {
return;
}
checkbox.hide(); checkbox.hide();
if (checked) { if (checked) {
checkbox.after('<i class="fa fa-toggle-on"></i>'); checkbox.after('<i class="fa fa-toggle-on"></i>');
} }
else { else {
checkbox.after('<i class="fa fa-toggle-off"></i>'); checkbox.after('<i class="fa fa-toggle-off"></i>');
} }
});
$('[type=checkbox]').change(function() {
var checked = $(this).is(':checked');
$(this).siblings('[class*=fa-]').toggleClass('fa-toggle-off', !checked) checkbox.attr('data-toggle-added', true);
.toggleClass('fa-toggle-on', checked);
}); });
$.propHooks.checked = {
set: function(elem, value, name) {
$(elem).trigger("change");
}
};
} }
}()); }());

@ -104,6 +104,8 @@ define('admin/settings', ['uploader', 'sounds'], function(uploader, sounds) {
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback(); callback();
} }
$(window).trigger('action:admin.settingsLoaded');
}; };
function handleUploads() { function handleUploads() {

@ -471,6 +471,7 @@ define('settings', function () {
} }
$(formEl).deserialize(values); $(formEl).deserialize(values);
$(window).trigger('action:admin.settingsLoaded');
callback(null, values); callback(null, values);
}); });

Loading…
Cancel
Save