-
Notifications
You must be signed in to change notification settings - Fork 4
/
content_lock.admin.js
49 lines (43 loc) · 1.6 KB
/
content_lock.admin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* @file
* Core behavior for Content locking admin.
*/
(function ($) {
'use strict';
Backdrop.behaviors.content_lock_admin = {
attach: function (context) {
var js_obj = jQuery('input[name="content_lock_unload_js"]', context);
var js_message_obj = jQuery('input[name="content_lock_unload_js_message"]', context);
var js_message_form_item_obj = js_message_obj.parents('.form-item');
var js_message_enable_obj = jQuery('input[name="content_lock_unload_js_message_enable"]', context);
var js_fieldset_obj = js_message_enable_obj.parents('fieldset');
function check_js() {
if (js_obj.is(':checked')) {
js_fieldset_obj.removeAttr('disabled').removeClass('form-disabled');
}
else {
js_fieldset_obj.attr('disabled', 'disabled').addClass('form-disabled');
}
}
function check_js_message_enable() {
if (!js_message_enable_obj.is(':checked')) {
js_message_obj.attr('disabled', 'disabled');
js_message_form_item_obj.addClass('form-disabled');
}
else {
js_message_obj.removeAttr('disabled');
js_message_form_item_obj.removeClass('form-disabled');
}
}
// Do not lose the existing message when the message is disabled.
js_message_obj.parents('form').submit(function () {
js_fieldset_obj.removeAttr('disabled');
js_message_obj.removeAttr('disabled');
});
js_message_enable_obj.click(check_js_message_enable);
js_obj.click(check_js);
check_js_message_enable();
check_js();
}
};
}(jQuery));