From d7bab1f9a50b7a8da51486c19af854f7e3d86130 Mon Sep 17 00:00:00 2001 From: eddiemonge Date: Thu, 21 Apr 2011 14:33:49 -0700 Subject: [PATCH 1/2] micro-optimizations and styling changes to listview.js --- js/jquery.mobile.listview.js | 48 ++++++++++++++---------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/js/jquery.mobile.listview.js b/js/jquery.mobile.listview.js index c39c760d..78a1ae27 100644 --- a/js/jquery.mobile.listview.js +++ b/js/jquery.mobile.listview.js @@ -18,40 +18,32 @@ $.widget( "mobile.listview", $.mobile.widget, { }, _create: function() { - var $list = this.element, - o = this.options; + var t = this; // create listview markup - $list - .addClass( "ui-listview" ); - - if ( o.inset ) { - $list.addClass( "ui-listview-inset ui-corner-all ui-shadow" ); - } + t.element.addClass(function( i, orig ) { + return orig + " ui-listview " + ( t.options.inset ? " ui-listview-inset ui-corner-all ui-shadow " : "" ); + }); - this.refresh(); + t.refresh(); }, _itemApply: function( $list, item ) { // TODO class has to be defined in markup item.find( ".ui-li-count" ) - .addClass( "ui-btn-up-" + ($list.jqmData( "counttheme" ) || this.options.countTheme) + " ui-btn-corner-all" ); - - item.find( "h1, h2, h3, h4, h5, h6" ).addClass( "ui-li-heading" ); - - item.find( "p, dl" ).addClass( "ui-li-desc" ); - - item.find("img:first-child:eq(0)").addClass( "ui-li-thumb" ).each(function() { + .addClass( "ui-btn-up-" + ($list.jqmData( "counttheme" ) || this.options.countTheme) + " ui-btn-corner-all" ).end() + .find( "h1, h2, h3, h4, h5, h6" ).addClass( "ui-li-heading" ).end() + .find( "p, dl" ).addClass( "ui-li-desc" ).end() + .find("img:first-child:eq(0)").addClass( "ui-li-thumb" ).each(function() { item.addClass( $(this).is( ".ui-li-icon" ) ? "ui-li-has-icon" : "ui-li-has-thumb" ); - }); - - item.find( ".ui-li-aside" ).each(function() { + }).end() + .find( ".ui-li-aside" ).each(function() { var $this = $(this); $this.prependTo( $this.parent() ); //shift aside to front for css float }); }, - _removeCorners: function(li){ + _removeCorners: function( li ) { li .add( li.find(".ui-btn-inner, .ui-li-link-alt, .ui-li-thumb") ) .removeClass( "ui-corner-top ui-corner-bottom ui-corner-br ui-corner-bl ui-corner-tr ui-corner-tl" ); @@ -73,8 +65,7 @@ $.widget( "mobile.listview", $.mobile.widget, { $list.find( ".ui-li-dec" ).remove(); } - var numli = li.length; - for (var pos = 0; pos < numli; pos++) { + for (var pos = 0, numli = li.length; pos < numli; pos++) { var item = li.eq(pos), itemClass = "ui-li"; @@ -83,9 +74,8 @@ $.widget( "mobile.listview", $.mobile.widget, { continue; } - var itemTheme = item.jqmData("theme") || o.theme; - - var a = item.children( "a" ); + var itemTheme = item.jqmData("theme") || o.theme, + a = item.children( "a" ); if ( a.length ) { var icon = item.jqmData("icon"); @@ -121,7 +111,7 @@ $.widget( "mobile.listview", $.mobile.widget, { iconpos: false }) .find( ".ui-btn-inner" ) - .append( $( "" ).buttonMarkup({ + .append( $( "" ).buttonMarkup({ shadow: true, corners: true, theme: splittheme, @@ -136,7 +126,7 @@ $.widget( "mobile.listview", $.mobile.widget, { //reset counter when a divider heading is encountered if ( counter ) { - counter = 1; + counter = ! counter || 1; } } else { @@ -228,8 +218,8 @@ $.widget( "mobile.listview", $.mobile.widget, { newPage.page(); var anchor = parent.find('a:first'); - if (!anchor.length) { - anchor = $("").html( nodeEls || title ).prependTo(parent.empty()); + if ( !anchor.length ) { + anchor = $("").html( nodeEls || title ).prependTo( parent.empty() ); } anchor.attr('href','#' + id); }).listview(); From 279d71828a5bf6d76c2a96d70abc7f81ba051f6f Mon Sep 17 00:00:00 2001 From: eddiemonge Date: Thu, 21 Apr 2011 14:40:58 -0700 Subject: [PATCH 2/2] left a test piece of code in previously --- js/jquery.mobile.listview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/jquery.mobile.listview.js b/js/jquery.mobile.listview.js index 78a1ae27..1a28aaeb 100644 --- a/js/jquery.mobile.listview.js +++ b/js/jquery.mobile.listview.js @@ -126,7 +126,7 @@ $.widget( "mobile.listview", $.mobile.widget, { //reset counter when a divider heading is encountered if ( counter ) { - counter = ! counter || 1; + counter = 1; } } else {