Skip to content
This repository
Browse code

listview filter inset respects prototype options Fixes #3761

  • Loading branch information...
commit 748ada1f441ca8c6d2824d489000d6e8809ec62d 1 parent bee587d
John Bender authored March 07, 2012
2  js/jquery.mobile.listview.filter.js
@@ -101,7 +101,7 @@ $( document ).delegate( ":jqmData(role='listview')", "listviewcreate", function(
101 101
 		.appendTo( wrapper )
102 102
 		.textinput();
103 103
 
104  
-	if ( $( this ).jqmData( "inset" ) ) {
  104
+	if ( listview.options.inset ) {
105 105
 		wrapper.addClass( "ui-listview-filter-inset" );
106 106
 	}
107 107
 
13  tests/unit/listview/index.html
@@ -332,5 +332,18 @@ <h2 id="qunit-userAgent"></h2>
332 332
   </div>
333 333
 </div>
334 334
 
  335
+<div id="list-inset-filter-prototype" data-nstest-theme="b">
  336
+	<ul data-nstest-role="listview" data-nstest-filter="true">
  337
+		<li>foo</li>
  338
+		<li>bar</li>
  339
+	</ul>
  340
+</div>
  341
+
  342
+<div id="list-inset-filter-data-attr" data-nstest-theme="b">
  343
+	<ul data-nstest-role="listview" data-nstest-filter="true" data-nstest-inset="true">
  344
+		<li>foo</li>
  345
+		<li>bar</li>
  346
+	</ul>
  347
+</div>
335 348
 </body>
336 349
 </html>
45  tests/unit/listview/listview_core.js
@@ -4,7 +4,8 @@
4 4
 
5 5
 // TODO split out into seperate test files
6 6
 (function($){
7  
-	var home = $.mobile.path.parseUrl( location.href ).pathname + location.search;
  7
+	var home = $.mobile.path.parseUrl( location.href ).pathname + location.search,
  8
+		insetVal = $.mobile.listview.prototype.options.inset;
8 9
 
9 10
 	$.mobile.defaultTransition = "none";
10 11
 
@@ -19,6 +20,10 @@
19 20
 
20 21
 				$.mobile.changePage( home );
21 22
 			}
  23
+		},
  24
+
  25
+		teardown: function() {
  26
+			$.mobile.listview.prototype.options.inset = insetVal;
22 27
 		}
23 28
 	});
24 29
 
@@ -789,4 +794,42 @@
789 794
 			start
790 795
 		]);
791 796
 	});
  797
+
  798
+	asyncTest( "list filter is inset from prototype options value", function() {
  799
+		$.mobile.listview.prototype.options.inset = true;
  800
+		$("#list-inset-filter-prototype").page();
  801
+
  802
+		$.testHelper.pageSequence([
  803
+			function() {
  804
+				$.mobile.changePage("#list-inset-filter-prototype");
  805
+			},
  806
+
  807
+			function( timedOut) {
  808
+				ok( !timedOut );
  809
+				same( $.mobile.activePage.find("form.ui-listview-filter-inset").length, 1, "form is inset");
  810
+				window.history.back();
  811
+			},
  812
+
  813
+			start
  814
+		]);
  815
+	});
  816
+
  817
+	asyncTest( "list filter is inset from data attr value", function() {
  818
+		$.mobile.listview.prototype.options.inset = false;
  819
+		$("#list-inset-filter-data-attr").page();
  820
+
  821
+		$.testHelper.pageSequence([
  822
+			function() {
  823
+				$.mobile.changePage("#list-inset-filter-data-attr");
  824
+			},
  825
+
  826
+			function( timedOut) {
  827
+				ok( !timedOut );
  828
+				same( $.mobile.activePage.find("form.ui-listview-filter-inset").length, 1, "form is inset");
  829
+				window.history.back();
  830
+			},
  831
+
  832
+			start
  833
+		]);
  834
+	});
792 835
 })(jQuery);

0 notes on commit 748ada1

Please sign in to comment.
Something went wrong with that request. Please try again.