User:Locke/common.js: Difference between revisions
Jump to navigation
Jump to search
Want an adless experience? Log in or Create an account.
m (update doc) |
(fix handling of undefined selector) |
||
Line 57: | Line 57: | ||
var ts = $( this ); | var ts = $( this ); | ||
var s = ts.data( 'tabSelector' ); | var s = ts.data( 'tabSelector' ); | ||
selections[ s == undefined ? '' : s ] = ts.find( '.active' ).data( 'tabSelection' ); | selections[ s == undefined ? '' : '-' + s ] = ts.find( '.active' ).data( 'tabSelection' ); | ||
} ); | } ); | ||
// make sure this tabset takes priority in case multiple tabsets use the same selector | // make sure this tabset takes priority in case multiple tabsets use the same selector | ||
selections[ selector == undefined ? '' : selector ] = tab.data( 'tabSelection' ); | selections[ selector == undefined ? '' : '-' + selector ] = tab.data( 'tabSelection' ); | ||
// hide contents (except nested contents) | // hide contents (except nested contents) | ||
Line 70: | Line 70: | ||
// show the selected content | // show the selected content | ||
var selectors = Object.keys( selections ).map( function( s ) { | var selectors = Object.keys( selections ).map( function( s ) { | ||
return '[data-tab-content | return '[data-tab-content' + s + '="' + selections[ s ] + '"]'; | ||
} ); | } ); | ||
container.find( '.zdw-tabcontent' + selectors.join( '' ) ).show(); | container.find( '.zdw-tabcontent' + selectors.join( '' ) ).show(); | ||
} ); | } ); | ||
} ); | } ); |