2016-01-11 02:25:30 +01:00
|
|
|
(function (global, factory) {
|
|
|
|
if (typeof define === "function" && define.amd) {
|
|
|
|
define('ss.PermissionCheckboxSetField', ['./jQuery'], factory);
|
|
|
|
} else if (typeof exports !== "undefined") {
|
|
|
|
factory(require('./jQuery'));
|
|
|
|
} else {
|
|
|
|
var mod = {
|
|
|
|
exports: {}
|
|
|
|
};
|
|
|
|
factory(global.jQuery);
|
|
|
|
global.ssPermissionCheckboxSetField = mod.exports;
|
|
|
|
}
|
|
|
|
})(this, function (_jQuery) {
|
2016-02-12 04:00:15 +01:00
|
|
|
'use strict';
|
|
|
|
|
2016-01-11 02:25:30 +01:00
|
|
|
var _jQuery2 = _interopRequireDefault(_jQuery);
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2016-01-11 02:25:30 +01:00
|
|
|
function _interopRequireDefault(obj) {
|
|
|
|
return obj && obj.__esModule ? obj : {
|
|
|
|
default: obj
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
_jQuery2.default.entwine('ss', function ($) {
|
2011-03-16 02:18:30 +01:00
|
|
|
$('.permissioncheckboxset .valADMIN input').entwine({
|
2016-01-11 02:25:30 +01:00
|
|
|
onmatch: function onmatch() {
|
2012-03-05 17:06:27 +01:00
|
|
|
this._super();
|
|
|
|
},
|
2016-01-11 02:25:30 +01:00
|
|
|
onunmatch: function onunmatch() {
|
2012-05-14 01:43:36 +02:00
|
|
|
this._super();
|
|
|
|
},
|
2016-01-11 02:25:30 +01:00
|
|
|
onclick: function onclick(e) {
|
2010-03-10 05:07:01 +01:00
|
|
|
this.toggleCheckboxes();
|
|
|
|
},
|
2016-01-11 02:25:30 +01:00
|
|
|
toggleCheckboxes: function toggleCheckboxes() {
|
2010-03-10 05:07:01 +01:00
|
|
|
var checkboxes = $(this).parents('.field:eq(0)').find('.checkbox').not(this);
|
|
|
|
|
2016-01-11 02:25:30 +01:00
|
|
|
if ($(this).is(':checked')) {
|
|
|
|
checkboxes.each(function () {
|
2010-03-10 05:07:01 +01:00
|
|
|
$(this).data('SecurityAdmin.oldChecked', $(this).attr('checked'));
|
|
|
|
$(this).data('SecurityAdmin.oldDisabled', $(this).attr('disabled'));
|
|
|
|
$(this).attr('disabled', 'disabled');
|
|
|
|
$(this).attr('checked', 'checked');
|
|
|
|
});
|
|
|
|
} else {
|
2016-01-11 02:25:30 +01:00
|
|
|
checkboxes.each(function () {
|
2010-03-15 22:27:06 +01:00
|
|
|
var oldChecked = $(this).data('SecurityAdmin.oldChecked');
|
|
|
|
var oldDisabled = $(this).data('SecurityAdmin.oldDisabled');
|
2016-01-11 02:25:30 +01:00
|
|
|
if (oldChecked !== null) $(this).attr('checked', oldChecked);
|
|
|
|
if (oldDisabled !== null) $(this).attr('disabled', oldDisabled);
|
2010-03-10 05:07:01 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2011-03-16 02:18:30 +01:00
|
|
|
});
|
|
|
|
$('.permissioncheckboxset .valCMS_ACCESS_LeftAndMain input').entwine({
|
2016-01-11 02:25:30 +01:00
|
|
|
getCheckboxesExceptThisOne: function getCheckboxesExceptThisOne() {
|
|
|
|
return $(this).parents('.field:eq(0)').find('li').filter(function (i) {
|
2012-01-07 18:57:14 +01:00
|
|
|
var klass = $(this).attr('class');
|
2016-01-11 02:25:30 +01:00
|
|
|
return klass ? klass.match(/CMS_ACCESS_/) : false;
|
2010-04-28 09:29:22 +02:00
|
|
|
}).find('.checkbox').not(this);
|
|
|
|
},
|
2016-01-11 02:25:30 +01:00
|
|
|
onmatch: function onmatch() {
|
2014-01-15 03:51:35 +01:00
|
|
|
this.toggleCheckboxes();
|
|
|
|
|
2011-03-16 02:18:30 +01:00
|
|
|
this._super();
|
2010-04-22 02:12:07 +02:00
|
|
|
},
|
2016-01-11 02:25:30 +01:00
|
|
|
onunmatch: function onunmatch() {
|
2012-05-14 01:43:36 +02:00
|
|
|
this._super();
|
|
|
|
},
|
2016-01-11 02:25:30 +01:00
|
|
|
onclick: function onclick(e) {
|
2014-01-15 03:51:35 +01:00
|
|
|
this.toggleCheckboxes();
|
|
|
|
},
|
2016-01-11 02:25:30 +01:00
|
|
|
toggleCheckboxes: function toggleCheckboxes() {
|
2010-04-28 09:29:22 +02:00
|
|
|
var checkboxes = this.getCheckboxesExceptThisOne();
|
2016-02-25 02:51:59 +01:00
|
|
|
|
2016-01-11 02:25:30 +01:00
|
|
|
if ($(this).is(':checked')) {
|
|
|
|
checkboxes.each(function () {
|
2014-01-15 03:51:35 +01:00
|
|
|
$(this).data('PermissionCheckboxSetField.oldChecked', $(this).is(':checked'));
|
|
|
|
$(this).data('PermissionCheckboxSetField.oldDisabled', $(this).is(':disabled'));
|
|
|
|
$(this).prop('disabled', 'disabled');
|
|
|
|
$(this).prop('checked', 'checked');
|
2010-04-22 02:12:07 +02:00
|
|
|
});
|
|
|
|
} else {
|
2016-01-11 02:25:30 +01:00
|
|
|
checkboxes.each(function () {
|
2014-01-15 03:51:35 +01:00
|
|
|
$(this).prop('checked', $(this).data('PermissionCheckboxSetField.oldChecked'));
|
|
|
|
$(this).prop('disabled', $(this).data('PermissionCheckboxSetField.oldDisabled'));
|
2010-04-22 02:12:07 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2011-03-16 02:18:30 +01:00
|
|
|
});
|
2010-03-10 05:07:01 +01:00
|
|
|
});
|
2016-01-11 02:25:30 +01:00
|
|
|
});
|