diff options
author | Simon Rettberg | 2019-03-27 16:07:45 +0100 |
---|---|---|
committer | Simon Rettberg | 2019-03-27 20:40:55 +0100 |
commit | aaaba1cd39f0fce30e82d0a07c3ec15ee5d5810f (patch) | |
tree | ae332a9bd63da9465ba8bd9eee8da392c496fc4b /modules-available | |
parent | [baseconfig] Remove bootstrap-switch, use checkbox (diff) | |
download | slx-admin-aaaba1cd39f0fce30e82d0a07c3ec15ee5d5810f.tar.gz slx-admin-aaaba1cd39f0fce30e82d0a07c3ec15ee5d5810f.tar.xz slx-admin-aaaba1cd39f0fce30e82d0a07c3ec15ee5d5810f.zip |
[baseconfig] Activate enable/override checkbox when changing a setting
A common mistake is trying to override a setting for a location, but
actually forgetting to check the "override" checkbox. Do this
automatically as soon as a field is being changed.
Diffstat (limited to 'modules-available')
-rw-r--r-- | modules-available/baseconfig/templates/_page.html | 67 |
1 files changed, 37 insertions, 30 deletions
diff --git a/modules-available/baseconfig/templates/_page.html b/modules-available/baseconfig/templates/_page.html index 27b40e37..86ab8362 100644 --- a/modules-available/baseconfig/templates/_page.html +++ b/modules-available/baseconfig/templates/_page.html @@ -37,7 +37,7 @@ </label> </div> </div> - <div class="col-md-5"> + <div class="col-md-5 config-container"> {{{item}}} <div class="slx-default"> {{#defaultsource}}{{lang_inheritSource}}:{{/defaultsource}} @@ -83,33 +83,6 @@ <script type="text/javascript"> -function updateShadows(e) { - var rules = $(e).data('shadows'); - if (!rules) return; - var currentValue = $(e).val(); - for (var triggerVal in rules) { - if (!rules.hasOwnProperty(triggerVal)) - continue; - var targets = rules[triggerVal]; - for (var i = 0; i < targets.length; ++i) { - var target = targets[i]; - var inp = $('#' + target); - var selitem = inp.data('selitem'); - - if (currentValue === triggerVal) { - inp.prop('disabled', true); - if (selitem) selitem.disable(); - inp.filter('.multiselect').multiselect('disable'); - } else { - inp.prop('disabled', false); - if (selitem) selitem.enable(); - inp.filter('.multiselect').multiselect('enable'); - } - } - } -} - - document.addEventListener("DOMContentLoaded", function () { /* apply selectize on all multiinput-selectize inputs */ $("input.multiinput").each(function (idx, elem) { @@ -132,8 +105,42 @@ document.addEventListener("DOMContentLoaded", function () { $('select.multiselect').filter(':disabled').multiselect('disable'); /* data-shadowing bindings */ + var updateShadows = function() { + var $this = $(this); + var rules = $this.data('shadows'); + if (!rules) return; + var currentValue = $this.val(); + for (var triggerVal in rules) { + if (!rules.hasOwnProperty(triggerVal)) + continue; + var targets = rules[triggerVal]; + for (var i = 0; i < targets.length; ++i) { + var target = targets[i]; + var inp = $('#' + target); + var selitem = inp.data('selitem'); + + if (currentValue === triggerVal) { + inp.prop('disabled', true); + if (selitem) selitem.disable(); + inp.filter('.multiselect').multiselect('disable'); + } else { + inp.prop('disabled', false); + if (selitem) selitem.enable(); + inp.filter('.multiselect').multiselect('enable'); + } + } + } + }; var $allShadowingFields = $('[data-shadows]'); - $allShadowingFields.on('change', function (event) { updateShadows(event.target); }); - $allShadowingFields.each(function (idx, elem) { updateShadows(elem); }); + $allShadowingFields.on('change', updateShadows); + $allShadowingFields.each(updateShadows); + + var updateCheckbox = function() { + var id = '#CB_' + $(this).attr('id'); + $(id).prop('checked', true); + }; + var $cont = $('.config-container'); + $cont.find('select, input').on('change', updateCheckbox); + $cont.find('input').on('input', updateCheckbox); }); </script> |