2015-08-18 00:00:26 +00:00
/ * *
2018-11-23 12:29:20 +00:00
* DO NOT EDIT THIS FILE .
* See the following change record for more information ,
* https : //www.drupal.org/node/2815083
* @ preserve
* * /
2015-08-18 00:00:26 +00:00
2016-04-20 16:56:34 +00:00
( function ( $ , Drupal ) {
2015-08-18 00:00:26 +00:00
Drupal . behaviors . permissions = {
2018-11-23 12:29:20 +00:00
attach : function attach ( context ) {
2015-08-18 00:00:26 +00:00
var self = this ;
$ ( 'table#permissions' ) . once ( 'permissions' ) . each ( function ( ) {
var $table = $ ( this ) ;
2018-11-23 12:29:20 +00:00
var $ancestor = void 0 ;
var method = void 0 ;
2015-08-18 00:00:26 +00:00
if ( $table . prev ( ) . length ) {
$ancestor = $table . prev ( ) ;
method = 'after' ;
2018-11-23 12:29:20 +00:00
} else {
2015-08-18 00:00:26 +00:00
$ancestor = $table . parent ( ) ;
method = 'append' ;
}
$table . detach ( ) ;
2018-11-23 12:29:20 +00:00
var $dummy = $ ( '<input type="checkbox" class="dummy-checkbox js-dummy-checkbox" disabled="disabled" checked="checked" />' ) . attr ( 'title' , Drupal . t ( 'This permission is inherited from the authenticated user role.' ) ) . hide ( ) ;
2015-08-18 00:00:26 +00:00
2018-11-23 12:29:20 +00:00
$table . find ( 'input[type="checkbox"]' ) . not ( '.js-rid-anonymous, .js-rid-authenticated' ) . addClass ( 'real-checkbox js-real-checkbox' ) . after ( $dummy ) ;
2015-08-18 00:00:26 +00:00
2018-11-23 12:29:20 +00:00
$table . find ( 'input[type=checkbox].js-rid-authenticated' ) . on ( 'click.permissions' , self . toggle ) . each ( self . toggle ) ;
2015-08-18 00:00:26 +00:00
$ancestor [ method ] ( $table ) ;
} ) ;
} ,
2018-11-23 12:29:20 +00:00
toggle : function toggle ( ) {
2015-08-18 00:00:26 +00:00
var authCheckbox = this ;
var $row = $ ( this ) . closest ( 'tr' ) ;
2018-11-23 12:29:20 +00:00
2015-08-18 00:00:26 +00:00
$row . find ( '.js-real-checkbox' ) . each ( function ( ) {
2018-11-23 12:29:20 +00:00
this . style . display = authCheckbox . checked ? 'none' : '' ;
2015-08-18 00:00:26 +00:00
} ) ;
$row . find ( '.js-dummy-checkbox' ) . each ( function ( ) {
2018-11-23 12:29:20 +00:00
this . style . display = authCheckbox . checked ? '' : 'none' ;
2015-08-18 00:00:26 +00:00
} ) ;
}
} ;
2018-11-23 12:29:20 +00:00
} ) ( jQuery , Drupal ) ;