Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
addFirstLastClasses: .not( ".ui-screen-hidden" ) -> custom function
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Schulhof committed May 29, 2014
1 parent 3d85609 commit 7b818d8
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions js/widgets/addFirstLastClasses.js
Expand Up @@ -7,16 +7,31 @@ define( [ "jquery", "../core" ], function( jQuery ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {

var uiScreenHiddenRegex = /\bui-screen-hidden\b/;
function noHiddenClass( elements ) {
var index,
length = elements.length,
result = [];

for ( index = 0; index < length; index++ ) {
if ( !elements[ index ].className.match( uiScreenHiddenRegex ) ) {
result.push( elements[ index ] );
}
}

return $( result );
}

$.mobile.behaviors.addFirstLastClasses = {
_getVisibles: function( $els, create ) {
var visibles;

if ( create ) {
visibles = $els.not( ".ui-screen-hidden" );
visibles = noHiddenClass( $els );
} else {
visibles = $els.filter( ":visible" );
if ( visibles.length === 0 ) {
visibles = $els.not( ".ui-screen-hidden" );
visibles = noHiddenClass( $els );
}
}

Expand Down

0 comments on commit 7b818d8

Please sign in to comment.