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
Issue #2805205 by andrewmacpherson, michielnugter, lauriekap, BarisW, pk188, Ehud, arunkumark, SteffenR, Lendude, droplet, alexpott, xiwar: Provide screen-reader feedback when filtering by block name
2017-07-24 16:26:10 +00:00
( function ( $ , Drupal , debounce ) {
2014-01-27 21:41:32 +00:00
Drupal . behaviors . blockFilterByText = {
2017-05-19 22:12:53 +00:00
attach : function attach ( context , settings ) {
2014-01-27 21:41:32 +00:00
var $input = $ ( 'input.block-filter-text' ) . once ( 'block-filter-text' ) ;
Issue #2512456 by tim.plunkett, legolasbo, MattA, dawehner, googletorp, darol100, Bojhan, webchick, andypost, ivanstegic, larowlan, lauriii, LewisNyman, tkoleary, rickvug, eliza411, lunk_rat, nickrosencrans, stpaultim, Mark LaCroix: Implement the new block layout design to emphasize the primary interaction of placing a block
2015-07-10 19:00:10 +00:00
var $table = $ ( $input . attr ( 'data-element' ) ) ;
2017-12-01 19:28:00 +00:00
var $filter _rows = void 0 ;
2013-08-15 15:29:30 +00:00
2014-01-27 21:41:32 +00:00
function filterBlockList ( e ) {
var query = $ ( e . target ) . val ( ) . toLowerCase ( ) ;
2013-08-15 15:29:30 +00:00
Issue #2512456 by tim.plunkett, legolasbo, MattA, dawehner, googletorp, darol100, Bojhan, webchick, andypost, ivanstegic, larowlan, lauriii, LewisNyman, tkoleary, rickvug, eliza411, lunk_rat, nickrosencrans, stpaultim, Mark LaCroix: Implement the new block layout design to emphasize the primary interaction of placing a block
2015-07-10 19:00:10 +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 ) ;
2014-01-27 21:41:32 +00:00
}
if ( query . length >= 2 ) {
2017-12-01 19:28:00 +00:00
$filter _rows . each ( toggleBlockEntry ) ;
Issue #2805205 by andrewmacpherson, michielnugter, lauriekap, BarisW, pk188, Ehud, arunkumark, SteffenR, Lendude, droplet, alexpott, xiwar: Provide screen-reader feedback when filtering by block name
2017-07-24 16:26:10 +00:00
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.' ) ) ;
2017-05-19 22:12:53 +00:00
} else {
2017-12-01 19:28:00 +00:00
$filter _rows . each ( function ( index ) {
Issue #2512456 by tim.plunkett, legolasbo, MattA, dawehner, googletorp, darol100, Bojhan, webchick, andypost, ivanstegic, larowlan, lauriii, LewisNyman, tkoleary, rickvug, eliza411, lunk_rat, nickrosencrans, stpaultim, Mark LaCroix: Implement the new block layout design to emphasize the primary interaction of placing a block
2015-07-10 19:00:10 +00:00
$ ( this ) . parent ( ) . parent ( ) . show ( ) ;
} ) ;
2014-01-27 21:41:32 +00:00
}
2013-08-15 15:29:30 +00:00
}
Issue #2512456 by tim.plunkett, legolasbo, MattA, dawehner, googletorp, darol100, Bojhan, webchick, andypost, ivanstegic, larowlan, lauriii, LewisNyman, tkoleary, rickvug, eliza411, lunk_rat, nickrosencrans, stpaultim, Mark LaCroix: Implement the new block layout design to emphasize the primary interaction of placing a block
2015-07-10 19:00:10 +00:00
if ( $table . length ) {
2017-12-01 19:28:00 +00:00
$filter _rows = $table . find ( 'div.block-filter-text-source' ) ;
Issue #2805205 by andrewmacpherson, michielnugter, lauriekap, BarisW, pk188, Ehud, arunkumark, SteffenR, Lendude, droplet, alexpott, xiwar: Provide screen-reader feedback when filtering by block name
2017-07-24 16:26:10 +00:00
$input . on ( 'keyup' , debounce ( filterBlockList , 200 ) ) ;
2014-01-27 21:41:32 +00:00
}
2013-08-15 15:29:30 +00:00
}
2014-01-27 21:41:32 +00:00
} ;
2013-08-15 15:29:30 +00:00
2014-01-27 21:41:32 +00:00
Drupal . behaviors . blockHighlightPlacement = {
2017-05-19 22:12:53 +00:00
attach : function attach ( context , settings ) {
2014-01-27 21:41:32 +00:00
if ( settings . blockPlacement ) {
2015-06-22 13:16:58 +00:00
$ ( context ) . find ( '[data-drupal-selector="edit-blocks"]' ) . once ( 'block-highlight' ) . each ( function ( ) {
2014-01-27 21:41:32 +00:00
var $container = $ ( this ) ;
2017-05-19 22:12:53 +00:00
2014-01-27 21:41:32 +00:00
$ ( 'html, body' ) . animate ( {
2015-05-18 13:11:31 +00:00
scrollTop : $ ( '.js-block-placed' ) . offset ( ) . top - $container . offset ( ) . top + $container . scrollTop ( )
2014-01-27 21:41:32 +00:00
} , 500 ) ;
} ) ;
}
2013-09-06 17:22:45 +00:00
}
2014-01-27 21:41:32 +00:00
} ;
Issue #2805205 by andrewmacpherson, michielnugter, lauriekap, BarisW, pk188, Ehud, arunkumark, SteffenR, Lendude, droplet, alexpott, xiwar: Provide screen-reader feedback when filtering by block name
2017-07-24 16:26:10 +00:00
} ) ( jQuery , Drupal , Drupal . debounce ) ;