Commit 77ee6f53 authored by catch's avatar catch

Issue #1751070 by rballou, rteijeiro, droplet, kostyashupenko: Selectors clean-up: states.js

parent f33b2415
......@@ -601,7 +601,8 @@
* can override these state change handlers for particular parts of a page.
*/
$(document).on('state:disabled', function (e) {
var $document = $(document);
$document.on('state:disabled', function (e) {
// Only act when this change was triggered by a dependency and not by the
// element monitoring itself.
if (e.trigger) {
......@@ -615,7 +616,7 @@
}
});
$(document).on('state:required', function (e) {
$document.on('state:required', function (e) {
if (e.trigger) {
if (e.value) {
var label = 'label' + (e.target.id ? '[for=' + e.target.id + ']' : '');
......@@ -631,19 +632,19 @@
}
});
$(document).on('state:visible', function (e) {
$document.on('state:visible', function (e) {
if (e.trigger) {
$(e.target).closest('.js-form-item, .js-form-submit, .js-form-wrapper').toggle(e.value);
}
});
$(document).on('state:checked', function (e) {
$document.on('state:checked', function (e) {
if (e.trigger) {
$(e.target).prop('checked', e.value);
}
});
$(document).on('state:collapsed', function (e) {
$document.on('state:collapsed', function (e) {
if (e.trigger) {
if ($(e.target).is('[open]') === e.value) {
$(e.target).find('> summary').trigger('click');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment