Skip to content

Commit

Permalink
Moved the view change events to the wb object and optimized tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentGoderre committed Dec 11, 2013
1 parent d261c84 commit b9acb94
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/core/wb.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ var getUrlParts = function( url ) {

nodes: $(),

resizeEvents: "xxsmallview.wb xsmallview.wb smallview.wb mediumview.wb largeview.wb xlargeview.wb",

add: function( selector ) {

// Lets ensure we are not running if things are disabled
Expand Down
18 changes: 10 additions & 8 deletions src/plugins/tabs/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var pluginName = "wb-tabs",
equalHeightClass = "wb-eqht",
equalHeightOffClass = equalHeightClass + "-off",
activePanel = "-activePanel",
activateEvent = "click vclick keydown",
$document = wb.doc,
$window = wb.win,
i18n, i18nText,
Expand Down Expand Up @@ -57,6 +58,7 @@ var pluginName = "wb-tabs",
$openPanel = activeId.length !== 0 ? $panels.filter( "#" + activeId ) : undefined,
elmId = $elm.attr( "id" ),
hashFocus = false,
open = "open",
$panel, i, len, tablist, isOpen, newId,
$summaries, summary, positionY;

Expand Down Expand Up @@ -119,8 +121,8 @@ var pluginName = "wb-tabs",
$openPanel = $panels.eq( 0 );
}
}
$panels.removeAttr( "open" );
$openPanel.attr( "open", "open" );
$panels.removeAttr( open );
$openPanel.attr( open, open );

// Hide the tablist in small view and the summary elements in large view
tablist = "<ul role='tablist' aria-live='off'>";
Expand All @@ -142,7 +144,7 @@ var pluginName = "wb-tabs",
uniqueCount += 1;
$panel.attr( "id", newId );
}
isOpen = !!$panel.attr( "open" );
isOpen = !!$panel.attr( open );

if ( isSmallView ) {
if ( !Modernizr.details ) {
Expand All @@ -156,9 +158,9 @@ var pluginName = "wb-tabs",
} else {
$panel.attr({
role: "tabpanel",
open: "open"
open: open
});
$panel.addClass( ( Modernizr.details ? "" : "open " ) +
$panel.addClass( ( Modernizr.details ? "" : open + " " ) +
"fade " + ( isOpen ? "in" : "out" ) );
}

Expand Down Expand Up @@ -529,7 +531,7 @@ var pluginName = "wb-tabs",
/*
* Tabs, next, previous and play/pause
*/
$document.on( "click vclick keydown", controls, function( event ) {
$document.on( activateEvent, controls, function( event ) {
var which = event.which,
elm = event.currentTarget,
className = elm.className,
Expand Down Expand Up @@ -582,14 +584,14 @@ var pluginName = "wb-tabs",
});

// These events only fire at the document level
$document.on( "xxsmallview.wb xsmallview.wb smallview.wb mediumview.wb largeview.wb xlargeview.wb", onResize );
$document.on( wb.resizeEvents, onResize );

// This event only fires on the window
$window.on( "hashchange", onHashChange );

-// Update the hash with the current open details/tab panel id

$document.on( "click vclick keydown", selector + " > details > summary", function( event ) {
$document.on( activateEvent, selector + " > details > summary", function( event ) {
var which = event.which,
details = event.currentTarget.parentNode;

Expand Down

0 comments on commit b9acb94

Please sign in to comment.