2015-06-05 20:17:55 +00:00
/ * *
2017-05-19 22:12:53 +00:00
* DO NOT EDIT THIS FILE .
* See the following change record for more information ,
2017-05-23 14:30:14 +00:00
* https : //www.drupal.org/node/2815083
2017-05-19 22:12:53 +00:00
* @ preserve
* * /
2015-06-05 20:17:55 +00:00
2016-02-29 03:25:57 +00:00
( function ( $ , Drupal ) {
2014-01-27 21:41:32 +00:00
Drupal . behaviors . permissions = {
2017-05-19 22:12:53 +00:00
attach : function attach ( context ) {
2014-01-27 21:41:32 +00:00
var self = this ;
2015-03-23 10:29:17 +00:00
$ ( 'table#permissions' ) . once ( 'permissions' ) . each ( function ( ) {
2014-01-27 21:41:32 +00:00
var $table = $ ( this ) ;
2017-07-06 06:21:40 +00:00
var $ancestor = void 0 ;
var method = void 0 ;
2014-01-27 21:41:32 +00:00
if ( $table . prev ( ) . length ) {
$ancestor = $table . prev ( ) ;
method = 'after' ;
2017-05-19 22:12:53 +00:00
} else {
2014-01-27 21:41:32 +00:00
$ancestor = $table . parent ( ) ;
method = 'append' ;
}
$table . detach ( ) ;
2011-07-03 17:48:22 +00:00
2019-09-20 23:18:38 +00:00
var $dummy = $ ( Drupal . theme ( 'checkbox' ) ) . removeClass ( 'form-checkbox' ) . addClass ( 'dummy-checkbox js-dummy-checkbox' ) . attr ( 'disabled' , 'disabled' ) . attr ( 'checked' , 'checked' ) . attr ( 'title' , Drupal . t ( 'This permission is inherited from the authenticated user role.' ) ) . hide ( ) ;
2009-05-12 08:33:19 +00:00
2017-05-19 22:12:53 +00:00
$table . find ( 'input[type="checkbox"]' ) . not ( '.js-rid-anonymous, .js-rid-authenticated' ) . addClass ( 'real-checkbox js-real-checkbox' ) . after ( $dummy ) ;
2009-05-12 08:33:19 +00:00
2017-05-19 22:12:53 +00:00
$table . find ( 'input[type=checkbox].js-rid-authenticated' ) . on ( 'click.permissions' , self . toggle ) . each ( self . toggle ) ;
2011-07-03 17:48:22 +00:00
2014-01-27 21:41:32 +00:00
$ancestor [ method ] ( $table ) ;
} ) ;
} ,
2017-05-19 22:12:53 +00:00
toggle : function toggle ( ) {
2015-04-19 15:30:43 +00:00
var authCheckbox = this ;
var $row = $ ( this ) . closest ( 'tr' ) ;
2017-05-19 22:12:53 +00:00
2015-05-19 13:12:05 +00:00
$row . find ( '.js-real-checkbox' ) . each ( function ( ) {
2017-05-19 22:12:53 +00:00
this . style . display = authCheckbox . checked ? 'none' : '' ;
2014-01-27 21:41:32 +00:00
} ) ;
2015-05-19 13:12:05 +00:00
$row . find ( '.js-dummy-checkbox' ) . each ( function ( ) {
2017-05-19 22:12:53 +00:00
this . style . display = authCheckbox . checked ? '' : 'none' ;
2014-01-27 21:41:32 +00:00
} ) ;
}
} ;
2017-05-19 22:12:53 +00:00
} ) ( jQuery , Drupal ) ;