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

Commit d5597db

Browse files
author
Oskari Koskimies
committed
Merge commit 'upstream/master'
2 parents afc5cf0 + 8ca008e commit d5597db

File tree

3 files changed

+58
-53
lines changed

3 files changed

+58
-53
lines changed

js/jquery.mobile.listview.js

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,15 @@ $.widget( "mobile.listview", $.mobile.widget, {
4444

4545
item.find( "p, dl" ).addClass( "ui-li-desc" );
4646

47-
$list.find( "li" ).find( ">img:eq(0), >:first>img:eq(0)" ).addClass( "ui-li-thumb" ).each(function() {
48-
$( this ).closest( "li" ).addClass( $(this).is( ".ui-li-icon" ) ? "ui-li-has-icon" : "ui-li-has-thumb" );
47+
var children = item.children();
48+
children.filter("img:eq(0)").add(children.eq(0).children("img:eq(0)")).addClass( "ui-li-thumb" ).each(function() {
49+
item.addClass( $(this).is( ".ui-li-icon" ) ? "ui-li-has-icon" : "ui-li-has-thumb" );
4950
});
5051

51-
var aside = item.find( ".ui-li-aside" );
52-
53-
if ( aside.length ) {
54-
aside.each(function(i, el) {
55-
$(el).prependTo( $(el).parent() ); //shift aside to front for css float
56-
});
57-
}
58-
59-
if ( $.support.cssPseudoElement || !$.nodeName( item[0], "ol" ) ) {
60-
return;
61-
}
52+
item.find( ".ui-li-aside" ).each(function() {
53+
var $this = $(this);
54+
$this.prependTo( $this.parent() ); //shift aside to front for css float
55+
});
6256
},
6357

6458
_removeCorners: function(li){
@@ -74,25 +68,28 @@ $.widget( "mobile.listview", $.mobile.widget, {
7468
$list = this.element,
7569
self = this,
7670
dividertheme = $list.jqmData( "dividertheme" ) || o.dividerTheme,
71+
listsplittheme = $list.jqmData( "splittheme" ),
72+
listspliticon = $list.jqmData( "spliticon" ),
7773
li = $list.children( "li" ),
7874
counter = $.support.cssPseudoElement || !$.nodeName( $list[0], "ol" ) ? 0 : 1;
7975

8076
if ( counter ) {
8177
$list.find( ".ui-li-dec" ).remove();
8278
}
8379

84-
li.each(function( pos ) {
85-
var item = $( this ),
80+
var numli = li.length;
81+
for (var pos = 0; pos < numli; pos++) {
82+
var item = li.eq(pos),
8683
itemClass = "ui-li";
8784

8885
// If we're creating the element, we update it regardless
8986
if ( !create && item.hasClass( "ui-li" ) ) {
90-
return;
87+
continue;
9188
}
9289

9390
var itemTheme = item.jqmData("theme") || o.theme;
9491

95-
var a = item.find( ">a" );
92+
var a = item.children( "a" );
9693

9794
if ( a.length ) {
9895
var icon = item.jqmData("icon");
@@ -113,7 +110,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
113110
itemClass += " ui-li-has-alt";
114111

115112
var last = a.last(),
116-
splittheme = $list.jqmData( "splittheme" ) || last.jqmData( "theme" ) || o.splitTheme;
113+
splittheme = listsplittheme || last.jqmData( "theme" ) || o.splitTheme;
117114

118115
last
119116
.appendTo(item)
@@ -133,7 +130,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
133130
corners: true,
134131
theme: splittheme,
135132
iconpos: "notext",
136-
icon: $list.jqmData( "spliticon" ) || last.jqmData( "icon" ) || o.splitIcon
133+
icon: listspliticon || last.jqmData( "icon" ) || o.splitIcon
137134
} ) );
138135
}
139136

@@ -199,7 +196,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
199196
if ( !create ) {
200197
self._itemApply( $list, item );
201198
}
202-
});
199+
}
203200
},
204201

205202
//create a string for ID/subpage url creation
@@ -212,6 +209,7 @@ $.widget( "mobile.listview", $.mobile.widget, {
212209
parentPage = parentList.closest( ".ui-page" ),
213210
parentId = parentPage.jqmData( "url" ),
214211
o = this.options,
212+
dns = "data-" + $.mobile.ns,
215213
self = this,
216214
persistentFooterID = parentPage.find( ":jqmData(role='footer')" ).jqmData( "id" );
217215

@@ -224,14 +222,12 @@ $.widget( "mobile.listview", $.mobile.widget, {
224222
id = parentId + "&" + $.mobile.subPageUrlKey + "=" + self._idStringEscape(title + " " + i),
225223
theme = list.jqmData( "theme" ) || o.theme,
226224
countTheme = list.jqmData( "counttheme" ) || parentList.jqmData( "counttheme" ) || o.countTheme,
227-
newPage = list.wrap( "<div data-" + $.mobile.ns + "role='page'><div data-" + $.mobile.ns + "role='content'></div></div>" )
225+
newPage = list.detach()
226+
.wrap( "<div " + dns + "role='page'" + dns + "url='" + id + "' " + dns + "theme='" + theme + "' " + dns + "count-theme='" + countTheme + "'><div " + dns + "role='content'></div></div>" )
228227
.parent()
229-
.before( "<div data-" + $.mobile.ns + "role='header' data-" + $.mobile.ns + "theme='" + o.headerTheme + "'><div class='ui-title'>" + title + "</div></div>" )
230-
.after( persistentFooterID ? $( "<div data-" + $.mobile.ns + "role='footer' data-" + $.mobile.ns + "id='"+ persistentFooterID +"'>") : "" )
228+
.before( "<div " + dns + "role='header' " + dns + "theme='" + o.headerTheme + "'><div class='ui-title'>" + title + "</div></div>" )
229+
.after( persistentFooterID ? $( "<div " + dns + "role='footer' " + dns + "id='"+ persistentFooterID +"'>") : "" )
231230
.parent()
232-
.attr( "data-" + $.mobile.ns + "url", id )
233-
.attr( "data-" + $.mobile.ns + "theme", theme )
234-
.attr( "data-" + $.mobile.ns + "count-theme", countTheme )
235231
.appendTo( $.mobile.pageContainer );
236232

237233
newPage.page();

js/jquery.mobile.vmouse.js

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var dataPropertyName = "virtualMouseBindings",
3333
didScroll = false,
3434
clickBlockList = [],
3535
blockMouseTriggers = false,
36+
blockTouchTriggers = false,
3637
eventCaptureSupported = $.support.eventCapture,
3738
$document = $(document),
3839
nextTouchID = 1,
@@ -118,34 +119,12 @@ function getClosestElementWithVirtualBinding(element, eventType)
118119

119120
function enableTouchBindings()
120121
{
121-
if (!activeDocHandlers["touchbindings"]){
122-
$document.bind("touchend", handleTouchEnd)
123-
124-
// On touch platforms, touching the screen and then dragging your finger
125-
// causes the window content to scroll after some distance threshold is
126-
// exceeded. On these platforms, a scroll prevents a click event from being
127-
// dispatched, and on some platforms, even the touchend is suppressed. To
128-
// mimic the suppression of the click event, we need to watch for a scroll
129-
// event. Unfortunately, some platforms like iOS don't dispatch scroll
130-
// events until *AFTER* the user lifts their finger (touchend). This means
131-
// we need to watch both scroll and touchmove events to figure out whether
132-
// or not a scroll happenens before the touchend event is fired.
133-
134-
.bind("touchmove", handleTouchMove)
135-
.bind("scroll", handleScroll);
136-
137-
activeDocHandlers["touchbindings"] = 1;
138-
}
122+
blockTouchTriggers = false;
139123
}
140124

141125
function disableTouchBindings()
142126
{
143-
if (activeDocHandlers["touchbindings"]){
144-
$document.unbind("touchmove", handleTouchMove)
145-
.unbind("touchend", handleTouchEnd)
146-
.unbind("scroll", handleScroll);
147-
activeDocHandlers["touchbindings"] = 0;
148-
}
127+
blockTouchTriggers = true;
149128
}
150129

151130
function enableMouseBindings()
@@ -232,6 +211,10 @@ function handleTouchStart(event)
232211

233212
function handleScroll(event)
234213
{
214+
if (blockTouchTriggers){
215+
return;
216+
}
217+
235218
if (!didScroll){
236219
triggerVirtualEvent("vmousecancel", event, getVirtualBindingFlags(event.target));
237220
}
@@ -242,6 +225,10 @@ function handleScroll(event)
242225

243226
function handleTouchMove(event)
244227
{
228+
if (blockTouchTriggers){
229+
return;
230+
}
231+
245232
var t = getNativeEvent(event).touches[0];
246233

247234
var didCancel = didScroll,
@@ -259,6 +246,10 @@ function handleTouchMove(event)
259246

260247
function handleTouchEnd(event)
261248
{
249+
if (blockTouchTriggers){
250+
return;
251+
}
252+
262253
disableTouchBindings();
263254

264255
var flags = getVirtualBindingFlags(event.target);
@@ -339,7 +330,22 @@ function getSpecialEventObject(eventType)
339330

340331
activeDocHandlers["touchstart"] = (activeDocHandlers["touchstart"] || 0) + 1;
341332
if (activeDocHandlers["touchstart"] === 1) {
342-
$document.bind("touchstart", handleTouchStart);
333+
$document.bind("touchstart", handleTouchStart)
334+
335+
.bind("touchend", handleTouchEnd)
336+
337+
// On touch platforms, touching the screen and then dragging your finger
338+
// causes the window content to scroll after some distance threshold is
339+
// exceeded. On these platforms, a scroll prevents a click event from being
340+
// dispatched, and on some platforms, even the touchend is suppressed. To
341+
// mimic the suppression of the click event, we need to watch for a scroll
342+
// event. Unfortunately, some platforms like iOS don't dispatch scroll
343+
// events until *AFTER* the user lifts their finger (touchend). This means
344+
// we need to watch both scroll and touchmove events to figure out whether
345+
// or not a scroll happenens before the touchend event is fired.
346+
347+
.bind("touchmove", handleTouchMove)
348+
.bind("scroll", handleScroll);
343349
}
344350
}
345351
},
@@ -359,7 +365,10 @@ function getSpecialEventObject(eventType)
359365

360366
--activeDocHandlers["touchstart"];
361367
if (!activeDocHandlers["touchstart"]) {
362-
$document.unbind("touchstart", handleTouchStart);
368+
$document.unbind("touchstart", handleTouchStart)
369+
.unbind("touchmove", handleTouchMove)
370+
.unbind("touchend", handleTouchEnd)
371+
.unbind("scroll", handleScroll);
363372
}
364373
}
365374

tests/unit/navigation/navigation_core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
asyncTest( "forms with data attribute ajax set to false will not call changePage", function(){
3939
var called = false,
4040
newChangePage = function(){
41-
called = truue;
41+
called = true;
4242
};
4343

4444
$.testHelper.sequence([

0 commit comments

Comments
 (0)