Permalink
Browse files

Got rid of pseudo selectors :header and :eq(0) since they take a long…

… time on WP7.5 (Mango). This shaves off 300 msecs when loading the form gallery page.
  • Loading branch information...
1 parent 8fb55a8 commit 8e23813d255e8d2c4eccd6f025154ca7e4c8d863 @jblas jblas committed Nov 10, 2011
Showing with 11 additions and 8 deletions.
  1. +11 −8 js/jquery.mobile.collapsible.js
View
19 js/jquery.mobile.collapsible.js
@@ -11,7 +11,7 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
expandCueText: " click to expand contents",
collapseCueText: " click to collapse contents",
collapsed: true,
- heading: ">:header,>legend",
+ heading: "h1,h2,h3,h4,h5,h6,legend",
theme: null,
contentTheme: null,
iconTheme: "d",
@@ -22,7 +22,7 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
var $el = this.element,
o = this.options,
collapsible = $el.addClass( "ui-collapsible" ),
- collapsibleHeading = $el.find( o.heading ).eq( 0 ),
+ collapsibleHeading = $el.children( o.heading ).first(),
collapsibleContent = collapsible.wrapInner( "<div class='ui-collapsible-content'></div>" ).find( ".ui-collapsible-content" ),
collapsibleSet = $el.closest( ":jqmData(role='collapsible-set')" ).addClass( "ui-collapsible-set" ),
colllapsiblesInSet = collapsibleSet.children( ":jqmData(role='collapsible')" );
@@ -54,7 +54,8 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
.addClass( "ui-collapsible-heading" )
.append( "<span class='ui-collapsible-heading-status'></span>" )
.wrapInner( "<a href='#' class='ui-collapsible-heading-toggle'></a>" )
- .find( "a:eq(0)" )
+ .find( "a" )
+ .first()
.buttonMarkup({
shadow: false,
corners: false,
@@ -65,7 +66,7 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
if ( !collapsibleSet.length ) {
collapsibleHeading
- .find( "a:eq(0), .ui-btn-inner" )
+ .find( "a" ).first().add( collapsibleHeading.find( ".ui-btn-inner" ) )
.addClass( "ui-corner-top ui-corner-bottom" );
} else {
// If we are in a collapsible set
@@ -86,22 +87,24 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
}
colllapsiblesInSet.first()
- .find( "a:eq(0)" )
+ .find( "a" )
+ .first()
.addClass( "ui-corner-top" )
.find( ".ui-btn-inner" )
.addClass( "ui-corner-top" );
colllapsiblesInSet.last()
.jqmData( "collapsible-last", true )
- .find( "a:eq(0)" )
+ .find( "a" )
+ .first()
.addClass( "ui-corner-bottom" )
.find( ".ui-btn-inner" )
.addClass( "ui-corner-bottom" );
if ( collapsible.jqmData( "collapsible-last" ) ) {
collapsibleHeading
- .find( "a:eq(0), .ui-btn-inner" )
+ .find( "a" ).first().add ( collapsibleHeading.find( ".ui-btn-inner" ) )
.addClass( "ui-corner-bottom" );
}
}
@@ -131,7 +134,7 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
if ( contentTheme && ( !collapsibleSet.length || collapsible.jqmData( "collapsible-last" ) ) ) {
collapsibleHeading
- .find( "a:eq(0), .ui-btn-inner" )
+ .find( "a" ).first().add( collapsibleHeading.find( ".ui-btn-inner" ) )
.toggleClass( "ui-corner-bottom", isCollapse );
collapsibleContent.toggleClass( "ui-corner-bottom", !isCollapse );
}

0 comments on commit 8e23813

Please sign in to comment.