silk.tabs = ( xb.core.object.extend( { ctor: function() { var self = this; $( window ).on( "hashchange", function( evt ) { console.log( "tabs::hashchange", window.location.hash ); self.setTab( window.location.hash, 200 ); } ); $( document ).on( "ready", function( evt ) { console.log( "tabs::document.ready", window.location.hash ); self.setTab( window.location.hash, 1000 ); } ); }, setTab: function( hash, delay ) { var self = this; window.setTimeout( function() { self.setTabDOM( hash ); }, delay ); }, setTabDOM: function( hash ) { var hash = hash; if ( typeof( hash ) !== "string" || hash[ 0 ] !== "#" ) { return null; } hash = hash.substr( 1 ); var links = $( "a.tabIndex[href$='#" + hash +"']" ); var tab = document.getElementById( hash ); if ( tab !== null ) { $( ".tabPane.active" ).removeClass( "active" ); $( "a.tabIndex.active" ).removeClass( "active" ); links.addClass( "active" ); $( tab ).addClass( "active" ); } } } ) )();