Skip to content

Commit 4aa0be8

Browse files
committed
Fix touch support. #169 for jquery-sortable
Fix touch support. #169 for jquery-sortable Fix touch support. In case we are dragging something clickable, preventDefault on drag, not on mousedown/touchstart by collinstocks. johnny/jquery-sortable#169 This is support for FirefoxOS
1 parent fb2dfc7 commit 4aa0be8

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

js/mameblock.src.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -1936,7 +1936,7 @@
19361936
}());
19371937

19381938
/* ===================================================
1939-
* jquery-sortable.js v0.9.13
1939+
* jquery-sortable.js v0.9.12
19401940
* http://johnny.github.com/jquery-sortable/
19411941
* ===================================================
19421942
* Copyright (c) 2012 Jonas von Andrian
@@ -1964,9 +1964,9 @@
19641964
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19651965
* ========================================================== */
19661966

1967-
19681967
!function ( $, window, pluginName, undefined){
1969-
var containerDefaults = {
1968+
var eventNames,
1969+
containerDefaults = {
19701970
// If true, items can be dragged from this container
19711971
drag: true,
19721972
// If true, items can be droped onto this container
@@ -2023,21 +2023,22 @@
20232023
// The Placeholder has not been moved yet.
20242024
onDrag: function ($item, position, _super, event) {
20252025
$item.css(position)
2026+
event.preventDefault()
20262027
},
20272028
// Called after the drag has been started,
2028-
// that is the mouse button is being held down and
2029+
// that is the mouse button is beeing held down and
20292030
// the mouse is moving.
20302031
// The container is the closest initialized container.
20312032
// Therefore it might not be the container, that actually contains the item.
20322033
onDragStart: function ($item, container, _super, event) {
20332034
$item.css({
2034-
height: $item.outerHeight(),
2035-
width: $item.outerWidth()
2035+
height: $item.height(),
2036+
width: $item.width()
20362037
})
20372038
$item.addClass(container.group.options.draggedClass)
20382039
$("body").addClass(container.group.options.bodyClass)
20392040
},
2040-
// Called when the mouse button is being released
2041+
// Called when the mouse button is beeing released
20412042
onDrop: function ($item, container, _super, event) {
20422043
$item.removeClass(container.group.options.draggedClass).removeAttr("style")
20432044
$("body").removeClass(container.group.options.bodyClass)
@@ -2046,7 +2047,7 @@
20462047
// Ignore if element clicked is input, select or textarea
20472048
onMousedown: function ($item, _super, event) {
20482049
if (!event.target.nodeName.match(/^(input|select|textarea)$/i)) {
2049-
event.preventDefault()
2050+
if (event.type.match(/^mouse/)) event.preventDefault()
20502051
return true
20512052
}
20522053
},
@@ -2191,7 +2192,7 @@
21912192
this.item = closestItem;
21922193
this.itemContainer = itemContainer;
21932194
if (this.item.is(this.options.exclude) || !this.options.onMousedown(this.item, groupDefaults.onMousedown, e)) {
2194-
return;
2195+
return;
21952196
}
21962197
this.setPointer(e);
21972198
this.toggleListeners('on');
@@ -2338,10 +2339,11 @@
23382339
) >= this.options.distance)
23392340
},
23402341
getPointer: function(e) {
2341-
var o = e.originalEvent || e.originalEvent.touches && e.originalEvent.touches[0]
2342+
var o = e.originalEvent,
2343+
t = (e.originalEvent.touches && e.originalEvent.touches[0]) || {};
23422344
return {
2343-
left: e.pageX || o.pageX,
2344-
top: e.pageY || o.pageY
2345+
left: e.pageX || o.pageX || t.pageX,
2346+
top: e.pageY || o.pageY || t.pageY
23452347
}
23462348
},
23472349
setupDelayTimer: function () {

js/src/jquery-sortable.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* ===================================================
2-
* jquery-sortable.js v0.9.13
2+
* jquery-sortable.js v0.9.12
33
* http://johnny.github.com/jquery-sortable/
44
* ===================================================
55
* Copyright (c) 2012 Jonas von Andrian
@@ -27,9 +27,9 @@
2727
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828
* ========================================================== */
2929

30-
3130
!function ( $, window, pluginName, undefined){
32-
var containerDefaults = {
31+
var eventNames,
32+
containerDefaults = {
3333
// If true, items can be dragged from this container
3434
drag: true,
3535
// If true, items can be droped onto this container
@@ -86,21 +86,22 @@
8686
// The Placeholder has not been moved yet.
8787
onDrag: function ($item, position, _super, event) {
8888
$item.css(position)
89+
event.preventDefault()
8990
},
9091
// Called after the drag has been started,
91-
// that is the mouse button is being held down and
92+
// that is the mouse button is beeing held down and
9293
// the mouse is moving.
9394
// The container is the closest initialized container.
9495
// Therefore it might not be the container, that actually contains the item.
9596
onDragStart: function ($item, container, _super, event) {
9697
$item.css({
97-
height: $item.outerHeight(),
98-
width: $item.outerWidth()
98+
height: $item.height(),
99+
width: $item.width()
99100
})
100101
$item.addClass(container.group.options.draggedClass)
101102
$("body").addClass(container.group.options.bodyClass)
102103
},
103-
// Called when the mouse button is being released
104+
// Called when the mouse button is beeing released
104105
onDrop: function ($item, container, _super, event) {
105106
$item.removeClass(container.group.options.draggedClass).removeAttr("style")
106107
$("body").removeClass(container.group.options.bodyClass)
@@ -109,7 +110,7 @@
109110
// Ignore if element clicked is input, select or textarea
110111
onMousedown: function ($item, _super, event) {
111112
if (!event.target.nodeName.match(/^(input|select|textarea)$/i)) {
112-
event.preventDefault()
113+
if (event.type.match(/^mouse/)) event.preventDefault()
113114
return true
114115
}
115116
},
@@ -254,7 +255,7 @@
254255
this.item = closestItem;
255256
this.itemContainer = itemContainer;
256257
if (this.item.is(this.options.exclude) || !this.options.onMousedown(this.item, groupDefaults.onMousedown, e)) {
257-
return;
258+
return;
258259
}
259260
this.setPointer(e);
260261
this.toggleListeners('on');
@@ -401,10 +402,11 @@
401402
) >= this.options.distance)
402403
},
403404
getPointer: function(e) {
404-
var o = e.originalEvent || e.originalEvent.touches && e.originalEvent.touches[0]
405+
var o = e.originalEvent,
406+
t = (e.originalEvent.touches && e.originalEvent.touches[0]) || {};
405407
return {
406-
left: e.pageX || o.pageX,
407-
top: e.pageY || o.pageY
408+
left: e.pageX || o.pageX || t.pageX,
409+
top: e.pageY || o.pageY || t.pageY
408410
}
409411
},
410412
setupDelayTimer: function () {

0 commit comments

Comments
 (0)