CollapsibleTabs: Avoid Sizzle selectors

Change-Id: I199a11602df50f2120dce6f861bb4b6260ab9380
This commit is contained in:
Ed Sanders 2019-07-01 16:02:07 +01:00
parent a5c492414a
commit a4f61a832e
1 changed files with 10 additions and 12 deletions

View File

@ -96,7 +96,9 @@
},
handleResize: function () {
$.collapsibleTabs.instances.forEach( function ( $el ) {
var data = $.collapsibleTabs.getSettings( $el );
var $tab,
data = $.collapsibleTabs.getSettings( $el );
if ( data.shifting ) {
return;
}
@ -105,24 +107,21 @@
if ( $el.children( data.collapsible ).length && data.collapseCondition() ) {
$el.trigger( 'beforeTabCollapse' );
// move the element to the dropdown menu
$.collapsibleTabs.moveToCollapsed( $el.children( data.collapsible + ':last' ) );
$.collapsibleTabs.moveToCollapsed( $el.children( data.collapsible ).last() );
}
$tab = $( data.collapsedContainer ).children( data.collapsible ).first();
// if there are still moveable items in the dropdown menu,
// and there is sufficient space to place them in the tab container
if (
$( data.collapsedContainer + ' ' + data.collapsible ).length &&
data.expandCondition(
$.collapsibleTabs.getSettings(
$( data.collapsedContainer ).children(
data.collapsible + ':first' )
).expandedWidth
$.collapsibleTabs.getSettings( $tab ).expandedWidth
)
) {
// move the element from the dropdown to the tab
$el.trigger( 'beforeTabExpand' );
$.collapsibleTabs
.moveToExpanded( data.collapsedContainer + ' ' + data.collapsible + ':first' );
$.collapsibleTabs.moveToExpanded( $tab );
}
} );
},
@ -156,9 +155,8 @@
rAF( $.collapsibleTabs.handleResize );
} );
},
moveToExpanded: function ( ele ) {
var data, expContainerSettings, $target, expandedWidth,
$moving = $( ele );
moveToExpanded: function ( $moving ) {
var data, expContainerSettings, $target, expandedWidth;
data = $.collapsibleTabs.getSettings( $moving );
if ( !data ) {
@ -171,7 +169,7 @@
expContainerSettings.shifting = true;
// grab the next appearing placeholder so we can use it for replacing
$target = $( data.expandedContainer ).find( 'span.placeholder:first' );
$target = $( data.expandedContainer ).find( 'span.placeholder' ).first();
expandedWidth = data.expandedWidth;
$moving.css( 'position', 'relative' ).css( ( isRTL ? 'right' : 'left' ), 0 ).css( 'width', '1px' );
$target.replaceWith(