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
2018-11-23 12:29:20 +00:00
( function ( $ , Drupal , debounce ) {
2015-08-18 00:00:26 +00:00
Drupal . behaviors . blockFilterByText = {
2018-11-23 12:29:20 +00:00
attach : function attach ( context , settings ) {
2015-08-18 00:00:26 +00:00
var $input = $ ( 'input.block-filter-text' ) . once ( 'block-filter-text' ) ;
2015-08-27 19:03:05 +00:00
var $table = $ ( $input . attr ( 'data-element' ) ) ;
2018-11-23 12:29:20 +00:00
var $filterRows = void 0 ;
2015-08-18 00:00:26 +00:00
function filterBlockList ( e ) {
var query = $ ( e . target ) . val ( ) . toLowerCase ( ) ;
2015-08-27 19:03:05 +00:00
function toggleBlockEntry ( index , label ) {
var $label = $ ( label ) ;
var $row = $label . parent ( ) . parent ( ) ;
var textMatch = $label . text ( ) . toLowerCase ( ) . indexOf ( query ) !== - 1 ;
$row . toggle ( textMatch ) ;
2015-08-18 00:00:26 +00:00
}
if ( query . length >= 2 ) {
2018-11-23 12:29:20 +00:00
$filterRows . each ( toggleBlockEntry ) ;
Drupal . announce ( Drupal . formatPlural ( $table . find ( 'tr:visible' ) . length - 1 , '1 block is available in the modified list.' , '@count blocks are available in the modified list.' ) ) ;
} else {
$filterRows . each ( function ( index ) {
2015-08-27 19:03:05 +00:00
$ ( this ) . parent ( ) . parent ( ) . show ( ) ;
} ) ;
2015-08-18 00:00:26 +00:00
}
}
2015-08-27 19:03:05 +00:00
if ( $table . length ) {
2018-11-23 12:29:20 +00:00
$filterRows = $table . find ( 'div.block-filter-text-source' ) ;
$input . on ( 'keyup' , debounce ( filterBlockList , 200 ) ) ;
2015-08-18 00:00:26 +00:00
}
}
} ;
Drupal . behaviors . blockHighlightPlacement = {
2018-11-23 12:29:20 +00:00
attach : function attach ( context , settings ) {
2019-01-24 08:00:03 +00:00
if ( settings . blockPlacement && $ ( '.js-block-placed' ) . length ) {
2015-08-18 00:00:26 +00:00
$ ( context ) . find ( '[data-drupal-selector="edit-blocks"]' ) . once ( 'block-highlight' ) . each ( function ( ) {
var $container = $ ( this ) ;
2018-11-23 12:29:20 +00:00
2015-08-18 00:00:26 +00:00
$ ( 'html, body' ) . animate ( {
scrollTop : $ ( '.js-block-placed' ) . offset ( ) . top - $container . offset ( ) . top + $container . scrollTop ( )
} , 500 ) ;
} ) ;
}
}
} ;
2018-11-23 12:29:20 +00:00
} ) ( jQuery , Drupal , Drupal . debounce ) ;