Permalink
Browse files

Closes #137: swipe down slides info down, swipe up puts it back. Also…

… fixed an event binding bug.
  • Loading branch information...
1 parent 664571d commit 0640bcf3cb4fa0563de17df70f67400ceadc8430 @raganwald committed Apr 14, 2010
View
1 .gitignore
@@ -4,3 +4,4 @@ tmp/**/*
doc/api
doc/app
doc/plugins
+config/environments/development.rb
View
2 app/views/action/gameplay/_action_inner.html.haml
@@ -1,4 +1,4 @@
-= render :partial => 'action/gameplay/toolbar', :locals => { :playing_text => "Move #{action.cardinality}" }
+= render :partial => 'action/gameplay/toolbar', :locals => { :playing_text => "Move #{action.cardinality}", :info => false }
.board
-if action.cardinality < action.game.current_move_number
= render :partial => "board/board", :locals => { :board => action.after, :latest => action.position }
View
6 app/views/action/gameplay/_toolbar.html.haml
@@ -1,6 +1,5 @@
- playing_text ||= ''
- back = false if back.nil?
-- info = true if info.nil?
- hey = true if hey.nil?
.toolbar
-if back
@@ -9,7 +8,4 @@
%span.gravatar
%span.playing= playing_text
-if hey
- %img#heyButton.iconButton.touch{:height=>30, :width=>30, :src=>'/images/tools/empty-text-green.png'}/
- -if info
- %a#infoButton.button.flip{:href=>'#info'}<
- %img{:height=>20, :width=>20, :src=>'/images/tools/info_20.png'}/
+ %img#heyButton.iconButton.touch{:height=>30, :width=>30, :src=>'/images/tools/empty-text-green.png'}/
View
2 app/views/game/show.html.haml
@@ -39,7 +39,7 @@
$(document).data('game_show_helper', game_show_helper);
});
#info
- = render :partial => 'action/gameplay/toolbar', :locals => { :back => true, :info => false, :hey => false }
+ = render :partial => 'action/gameplay/toolbar', :locals => { :back => falseG, :hey => false }
%h2 Players
%ul.rounded
%li
View
4,453 log/development.log
4,453 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
87 public/javascripts/application.js
@@ -49,7 +49,7 @@ var GO = function () {
var document_ready_hook = function () {
message_dialog_instance = $('<div></div>')
.dialog({
- dialogClass: 'wants_close message',
+ dialogClass: 'scrub message',
autoOpen: false,
height: 'auto',
title: 'Hey!',
@@ -64,7 +64,7 @@ var GO = function () {
height: 72
});
progress_dialog_instance.parent().detach().appendTo('body > .current');
- $('.message.wants_close').bind('gesture_close', function (event) {
+ $('.message.scrub').bind('gesture_scrub', function (event) {
message_dialog_instance.dialog("close");
return false;
});
@@ -316,11 +316,6 @@ var GO = function () {
});
}
};
-
- var clear_current_play = function (target) {
- set_played_stone($(target).find('.intersection.latest:not(.last)'), false);
- set_killed_stones(null, false)
- };
var liven_playing_positions = function () {
@@ -351,7 +346,7 @@ var GO = function () {
if (update_moves.size() > 0) {
// console.log('processing ' + update_moves.size() + ' updated moves');
update_moves.insertAfter('.move:last');
- update_elements_with_navigation_handlers(update_moves);
+ update_boards_with_navigation_handlers(update_moves);
}
$(html).filter('script').each(function (i, el) {
$.extend(info, jQuery.parseJSON($(el).text()));
@@ -470,15 +465,15 @@ var GO = function () {
}
};
- var update_elements_with_navigation_handlers = function () {
+ var update_boards_with_navigation_handlers = function () {
var memoized_move = function (target_move_number) {
var selector = select_move_by_move_number(target_move_number);
if ($(selector).size() == 0) {
var move_data = $('body').data('moves')[target_move_number];
var next_move = memoized_move(target_move_number + 1);
var this_move = next_move
- .clone(true)
+ .clone(false)
.removeClass()
.addClass('move')
.attr('id', id_by_move_number(target_move_number))
@@ -531,22 +526,20 @@ var GO = function () {
else {
hey.text(this_move.data('player') + ' passed.'); // TODO: Titleize
}
- update_elements_with_navigation_handlers(this_move);
+ update_boards_with_navigation_handlers(this_move);
update_hey(this_move);
this_move.insertBefore(next_move);
}
return $(selector);
};
- var goto_move = function () {
- return function (from_move_number, to_move_number) {
- var from_page = $(select_move_by_move_number(from_move_number));
- var to_page = memoized_move(to_move_number);
- jQT.swapPages(from_page, to_page, ((from_move_number > to_move_number) ? 'slide.backwards' : 'slide'));
-
- return false;
- }
- }();
- var forwards_in_time = function (target) {
+ var goto_move = function (from_move_number, to_move_number) {
+ var from_page = $(select_move_by_move_number(from_move_number));
+ var to_page = memoized_move(to_move_number);
+ jQT.swapPages(from_page, to_page, ((from_move_number > to_move_number) ? 'slide.backwards' : 'slide'));
+ return false;
+ };
+ var forwards_in_time = function (event) {
+ var target = $(event.target);
var current_move_number = current_displayed_move_number(target);
if (current_move_number < last_displayed_move_number()) {
return goto_move(current_move_number, current_move_number + 1);
@@ -592,25 +585,33 @@ var GO = function () {
return false;
}
};
- var backwards_in_time = function (target) {
+ var backwards_in_time = function (event) {
+ var target = $(event.target);
var current_move_number = current_displayed_move_number(target);
if (current_move_number > 0) {
return goto_move(current_move_number, current_move_number - 1);
}
};
+ var show_game_info = function (event) {
+ jQT.goTo($('#info'), 'slideup.reverse');
+ };
+
+ var clear_current_play = function (event) {
+ var target = $(event.target);
+ set_played_stone(target.find('.intersection.latest:not(.last)'), false);
+ set_killed_stones(null, false)
+ };
+
+ var debug_bindings = 0;
return function (selector) {
+ var c = debug_bindings++;
$(selector)
.find('.board')
- .bind('gesture_left', function (event) {
- return forwards_in_time(this);
- })
- .bind('gesture_right', function (event) {
- return backwards_in_time(this);
- })
- .bind('gesture_close', function (event) {
- return clear_current_play(this);
- })
+ .bind('gesture_left.navigation', forwards_in_time)
+ .bind('gesture_right.navigation', backwards_in_time)
+ .bind('gesture_scrub.navigation', clear_current_play)
+ .bind('gesture_bottom.navigation', show_game_info)
.end()
};
}();
@@ -643,12 +644,12 @@ var GO = function () {
var heyText = hey.text();
heyMove
.find('.toolbar #heyButton')
- .addClass('wants_close')
+ .addClass('scrub')
.each(function (index, heyButton_el) {
var heyButton = $(heyButton_el);
heyButton
.attr('src', '/images/tools/hey-text-green.png')
- .bind('gesture_close', function (event) {
+ .bind('gesture_scrub', function (event) {
$(this).qtip('hide');
})
.qtip({
@@ -699,18 +700,30 @@ var GO = function () {
var initialize_gesture_support = function() {
$('body')
- .gesture(['left', 'right', { close: function(target) {
+ .gesture([
+ 'left', 'right', 'top', 'bottom',
+ { scrub: function(target) {
return $(target)
.parents('body > *')
- .find('.wants_close');
+ .find('.scrub');
}
- }
+ },
+ { bottomright_topright: function(target) {
+ return $(target)
+ .parents('body > *')
+ .find('.ok');
+ }
+ }
]);
+ $('#info')
+ .bind('gesture_top', function(event) { jQT.goBack(); });
};
var document_ready_hook = function () {
initialize_gesture_support();
- update_elements_with_navigation_handlers('body');
+ $('.move').each(function(i, e) {
+ update_boards_with_navigation_handlers($(e));
+ });
liven_playing_positions();
update_playing_div()
update_move_infos();
View
525 public/javascripts/igesture.jquery.mobile_safari.js
@@ -4,22 +4,26 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
+//
// This code modified from jGesture, http://web.siruna.com/nico/jgesture/documentation.html,
// (c) 2008 Nico Goeminne and released under Apache License 2.0
// See: http://www.apache.org/licenses/LICENSE-2.0
+//
// Mods (so far) include support for mobile touch events under Mobile Safari,
// storing the target for creating custom events, and expanding the predefined
// events so that things like "close" can be written with eight different
// symmetric gestures.
+//
// Warning: May Contain Underscores
-// http://ozmm.org/posts/javascript_style.html
+// http://ozmm.org/posts/javascript_style.html
+//
jQuery.fn.gesture = function(events) {
var return_target = function(target) { return target; };
@@ -30,22 +34,30 @@ jQuery.fn.gesture = function(events) {
var stroke_events = {};
var gesture_events = {};
+ var default_gestures = {
+ scrub: /^(4([^48]*8[^48]*4)([^48]*8)?)|(8([^48]*4[^48]*8)([^48]*4)?)$/,
+ open: /^(4.*7.*2)|(4.*1.*6)|(8.*5.*2)|(8.*3.*6)|(2.*7.*4)|(6.*1.*4)|(2.*5.*8)|(6.*3.*8)$/,
+ close: /^(5.*2.*7)|(1.*6.*3)|(5.*8.*3)|(1.*4.*7)|(7.*2.*5)|(3.*6.*1)|(3.*8.*5)|(7.*4.*1)$/
+ };
var default_settings = {
- startStroke: "touchstart mousedown",
- stopStroke: "touchend mouseup",
- continueStroke: "touchmove mousemove",
- startGesture: "gesturestart",
- stopGesture: "gestureend",
- continueGesture: "gesturechange",
- button: "012",
- minDistance: 10,
- minScale: 0.25,
- minRotation: 22.5,
- continuesmode: false,
- repeat: false,
- disablecontextmenu: true
- };
- var settings = {};
+ startStroke: "touchstart mousedown",
+ stopStroke: "touchend mouseup",
+ continueStroke: "touchmove mousemove",
+ startGesture: "gesturestart",
+ stopGesture: "gestureend",
+ continueGesture: "gesturechange",
+ button: "012",
+ minDistance: 10,
+ minScale: 0.25,
+ minRotation: 22.5,
+ continuesmode: false,
+ repeat: false,
+ disablecontextmenu: true,
+ gestures: {}
+ };
+ var settings = {
+ gestures: {}
+ };
jQuery.each(events, function (i, e) {
if (e == 'scale' || e == 'rotate') {
@@ -59,7 +71,11 @@ jQuery.fn.gesture = function(events) {
if (typeof(default_settings[i]) == 'undefined') {
var h = (i == 'scale' || i == 'rotate') ? gesture_events : stroke_events;
if (typeof(e[i]) == 'function') {
- h[i] = e[i];
+ if (typeof(e[i]).prototype == 'undefined') {
+ settings.gestures[i] = e[i];
+ h[i] = return_target;
+ }
+ else h[i] = e[i];
}
else if (typeof(e[i]) == 'string'){
h[i] = selector_maker(e[i]);
@@ -72,167 +88,126 @@ jQuery.fn.gesture = function(events) {
}
});
- settings = jQuery.extend(default_settings, settings);
+ settings = jQuery.extend(default_settings, settings);
+ settings.gestures = jQuery.extend(default_gestures, settings.gestures);
if (!jQuery.isEmptyObject(stroke_events)) {
- var topleft = 1;
- var top = 2;
- var topright = 3;
- var right = 4;
- var bottomright = 5;
- var bottom = 6;
- var bottomleft = 7;
- var left = 8;
+ var topleft = 1;
+ var top = 2;
+ var topright = 3;
+ var right = 4;
+ var bottomright = 5;
+ var bottom = 6;
+ var bottomleft = 7;
+ var left = 8;
var stroke_handler = function (e) {
- var gesture = {
- target: null,
- moves: "",
- x: -1,
- y: -1,
- lastmove: "",
- continuesmode: false,
- getMoveNameAt: function(i) {
- switch (Number(this.moves.charAt(i))) {
- case 1:
- return "topleft";
- case 2:
- return "top";
- case 3:
- return "topright";
- case 4:
- return "right";
- case 5:
- return "bottomright";
- case 6:
- return "bottom";
- case 7:
- return "bottomleft";
- case 8:
- return "left";
- default:
- return "unknown";
- }
- },
- getName: function() {
-
- if (this.continuesmode && this.moves.length > 0) {
- return this.getMoveNameAt(this.moves.length - 1);
- }
-
- if (this.moves.length == 1) {
- return this.getMoveNameAt(0);
- }
- if (this.moves.length == 2) {
- return this.getMoveNameAt(0) + "_" + this.getMoveNameAt(1);
- }
-
- if (this.moves.length < 7) {
-
- if ((Number(this.moves.charAt(0)) == 4) &&
- (Number(this.moves.charAt(this.moves.length - 1)) == 4) &&
- (this.moves.indexOf("8") != -1)
- ) return "scrub";
-
- if ((Number(this.moves.charAt(0)) == 8) &&
- (Number(this.moves.charAt(this.moves.length - 1)) == 8) &&
- (this.moves.indexOf("4") != -1)
- ) return "scrub";
-
- }
-
- var g = this;
- var half_close_gestures = [
- {
- start: bottomright,
- connect: top,
- finish: bottomleft
- },
- {
- start: topleft,
- connect: bottom,
- finish: topright
- },
- {
- start: bottomright,
- connect: left,
- finish: topright
- },
- {
- start: topleft,
- connect: right,
- finish: bottomleft
- }
- ];
-
- for (i in half_close_gestures) {
- var e = half_close_gestures[i];
- if ((Number(g.moves.charAt(0)) == e.start) &&
- (Number(g.moves.charAt(g.moves.length - 1)) == e.finish) &&
- (g.moves.indexOf('' + e.connect) != -1)
- ) return 'close';
- if ((Number(g.moves.charAt(0)) == e.finish) &&
- (Number(g.moves.charAt(g.moves.length - 1)) == e.start) &&
- (g.moves.indexOf('' + e.connect) != -1)
- ) return 'close';
- };
-
- if (this.moves.length >= 7) {
- if ((function(str) {
- for (var i = 1; i < 8; i++) {
- var pre = Number(str.charAt(i - 1));
- var cur = Number(str.charAt(i));
- if ((pre + 1 == cur) || (pre == cur + 7)) {
- continue;
- }
- return false;
- }
- return true;
- })(this.moves)) return "circleclockwise";
-
- if ((function(str) {
- for (var i = 1; i < 8; i++) {
- var pre = Number(str.charAt(i - 1));
- var cur = Number(str.charAt(i));
- if ((pre == cur + 1) || (pre + 7 == cur)) {
- continue;
- }
- return false;
- }
- return true;
- })(this.moves)) return "circlecounterclockwise";
- }
-
- return "unknown";
- }
- };
- e.preventDefault();
- e.stopPropagation();
+ var gesture = {
+ target: null,
+ moves: "",
+ x: -1,
+ y: -1,
+ lastmove: "",
+ continuesmode: false,
+ getMoveNameAt: function(i) {
+ switch (Number(this.moves.charAt(i))) {
+ case 1:
+ return "topleft";
+ case 2:
+ return "top";
+ case 3:
+ return "topright";
+ case 4:
+ return "right";
+ case 5:
+ return "bottomright";
+ case 6:
+ return "bottom";
+ case 7:
+ return "bottomleft";
+ case 8:
+ return "left";
+ default:
+ return "unknown";
+ }
+ },
+ getName: function() {
+
+ if (this.continuesmode && this.moves.length > 0) {
+ return this.getMoveNameAt(this.moves.length - 1);
+ }
+
+ if (this.moves.length == 1) {
+ return this.getMoveNameAt(0);
+ }
+ if (this.moves.length == 2) {
+ return this.getMoveNameAt(0) + "_" + this.getMoveNameAt(1);
+ }
- if (e.button != null && settings.button.indexOf("" + e.button) == -1) return;
+ if (this.moves.length < 7) {
- gesture.target = e.target;
+ for (gesture_name in settings.gestures) {
+ if (this.moves.match(settings.gestures[gesture_name]))
+ return gesture_name;
+ }
+
+ }
+ else {
+ if ((function(str) {
+ for (var i = 1; i < 8; i++) {
+ var pre = Number(str.charAt(i - 1));
+ var cur = Number(str.charAt(i));
+ if ((pre + 1 == cur) || (pre == cur + 7)) {
+ continue;
+ }
+ return false;
+ }
+ return true;
+ })(this.moves)) return "circleclockwise";
+
+ if ((function(str) {
+ for (var i = 1; i < 8; i++) {
+ var pre = Number(str.charAt(i - 1));
+ var cur = Number(str.charAt(i));
+ if ((pre == cur + 1) || (pre + 7 == cur)) {
+ continue;
+ }
+ return false;
+ }
+ return true;
+ })(this.moves)) return "circlecounterclockwise";
+ }
+
+ return "unknown";
+ }
+ };
+ e.preventDefault();
+ e.stopPropagation();
- // disable browser context menu.
- if (settings.disablecontextmenu) {
- $(this).bind("contextmenu",
- function(e) {
- return false;
- });
- }
+ if (e.button != null && settings.button.indexOf("" + e.button) == -1) return;
- gesture.moves = "";
- gesture.x = -1;
- gesture.y = -1;
- gesture.continuesmode = settings.continuesmode;
+ gesture.target = e.target;
- $(this).bind(settings.continueStroke,
- function(e) {
- var x;
- var y;
- if (typeof(e.screenX) != 'undefined') {
+ // disable browser context menu.
+ if (settings.disablecontextmenu) {
+ $(this).bind("contextmenu",
+ function(e) {
+ return false;
+ });
+ }
+
+ gesture.moves = "";
+ gesture.x = -1;
+ gesture.y = -1;
+ gesture.continuesmode = settings.continuesmode;
+
+ $(this).bind(settings.continueStroke,
+ function(e) {
+ var x;
+ var y;
+ if (typeof(e.screenX) != 'undefined') {
x = e.screenX;
y = e.screenY;
}
@@ -245,7 +220,7 @@ jQuery.fn.gesture = function(events) {
for (i in e) {
str += ', ' + i + ': ' + e[i];
}
- console.log("don't understand x and y for " + e.type + ' event: ' + str);
+ console.error("don't understand x and y for " + e.type + ' event: ' + str);
}
else if (typeof(e.originalEvent.screenX) != 'undefined') {
x = e.originalEvent.screenX;
@@ -254,65 +229,67 @@ jQuery.fn.gesture = function(events) {
else if (typeof(e.originalEvent.targetTouches) != 'undefined') {
x = e.originalEvent.targetTouches[0].pageX;
y = e.originalEvent.targetTouches[0].pageY;
+ if (e.originalEvent.targetTouches.length > 1) {
+ $(this).unbind(settings.continueStroke);
+ $(this).unbind(settings.stopStroke);
+ return;
+ }
}
- if ((gesture.x == -1) && (gesture.y == -1)) {
- gesture.x = x;
- gesture.y = y;
- return;
- }
- var distance = Math.sqrt(Math.pow(x - gesture.x, 2) + Math.pow(y - gesture.y, 2));
- if (distance > settings.minDistance) {
- var angle = Math.atan2(x - gesture.x, y - gesture.y) / Math.PI + 1;
- var dir = 0;
- if (3 / 8 < angle && angle < 5 / 8) dir = 8;
- if (5 / 8 < angle && angle < 7 / 8) dir = 7;
- if (7 / 8 < angle && angle < 9 / 8) dir = 6;
- if (9 / 8 < angle && angle < 11 / 8) dir = 5;
- if (11 / 8 < angle && angle < 13 / 8) dir = 4;
- if (13 / 8 < angle && angle < 15 / 8) dir = 3;
- if (15 / 8 < angle || angle < 1 / 8) dir = 2;
- if (1 / 8 < angle && angle < 3 / 8) dir = 1;
+ if ((gesture.x == -1) && (gesture.y == -1)) {
+ gesture.x = x;
+ gesture.y = y;
+ return;
+ }
+ var distance = Math.sqrt(Math.pow(x - gesture.x, 2) + Math.pow(y - gesture.y, 2));
+ if (distance > settings.minDistance) {
+ var angle = Math.atan2(x - gesture.x, y - gesture.y) / Math.PI + 1;
+ var dir = 0;
+ if (3 / 8 < angle && angle < 5 / 8) dir = 8;
+ if (5 / 8 < angle && angle < 7 / 8) dir = 7;
+ if (7 / 8 < angle && angle < 9 / 8) dir = 6;
+ if (9 / 8 < angle && angle < 11 / 8) dir = 5;
+ if (11 / 8 < angle && angle < 13 / 8) dir = 4;
+ if (13 / 8 < angle && angle < 15 / 8) dir = 3;
+ if (15 / 8 < angle || angle < 1 / 8) dir = 2;
+ if (1 / 8 < angle && angle < 3 / 8) dir = 1;
- gesture.x = x;
- gesture.y = y;
+ gesture.x = x;
+ gesture.y = y;
- if (gesture.moves.length == 0) {
- gesture.moves += dir;
- gesture.lastmove = "" + dir;
- }
- else {
- if (settings.repeat || (gesture.moves.charAt(gesture.moves.length - 1) != dir)) {
- gesture.moves += dir;
- gesture.lastmove = "" + dir;
- }
- }
- if (settings.continuesmode && stroke_events[gesture.getName()]) {
+ if (gesture.moves.length == 0) {
+ gesture.moves += dir;
+ gesture.lastmove = "" + dir;
+ }
+ else {
+ if (settings.repeat || (gesture.moves.charAt(gesture.moves.length - 1) != dir)) {
+ gesture.moves += dir;
+ gesture.lastmove = "" + dir;
+ }
+ }
+ if (settings.continuesmode && stroke_events[gesture.getName()]) {
var gesture_event = jQuery.Event("gesture_" + name);
- gesture_event.gesture_data = gesture;
- stroke_events[gesture.getName()]($(gesture.target)).trigger(gesture_event);
- }
- }
- });
-
- $(this).bind(settings.stopStroke,
- function(e) {
- if (e.button != null && settings.button.indexOf("" + e.button) == -1) return;
+ gesture_event.gesture_data = gesture;
+ stroke_events[gesture.getName()]($(gesture.target)).trigger(gesture_event);
+ }
+ }
+ });
+
+ $(this).bind(settings.stopStroke,
+ function(e) {
+ if (e.button != null && settings.button.indexOf("" + e.button) == -1) return;
- if (!settings.disablecontextmenu) {
- $(this).unbind("contextmenu");
- }
- $(this).unbind(settings.continueStroke);
- $(this).unbind(settings.stopStroke);
- if (gesture.moves.length != 0 && stroke_events[gesture.getName()]) {
- console.log(gesture.getName() + ' generated by ' + event.type + ' and event created');
+ if (!settings.disablecontextmenu) {
+ $(this).unbind("contextmenu");
+ }
+ $(this).unbind(settings.continueStroke);
+ $(this).unbind(settings.stopStroke);
+ if (gesture.moves.length != 0 && stroke_events[gesture.getName()]) {
var gesture_event = jQuery.Event("gesture_" + gesture.getName());
- gesture_event.gesture_data = gesture;
- stroke_events[gesture.getName()]($(gesture.target)).trigger(gesture_event);
- }
- else if (gesture.moves.length != 0) {
- console.log(gesture.getName() + ' generated by ' + event.type);
- }
+ gesture_event.gesture_data = gesture;
+ var tar = stroke_events[gesture.getName()]($(gesture.target));
+ tar.trigger(gesture_event);
+ }
});
};
@@ -324,58 +301,80 @@ jQuery.fn.gesture = function(events) {
if (!jQuery.isEmptyObject(gesture_events)) {
var gesture_handler = function (e) {
-
- gesture.target = e.target;
+
+ var gesture = {};
+
+ gesture.target = e.target;
- // disable browser context menu.
- if (settings.disablecontextmenu) {
- $(this).bind("contextmenu",
- function(e) {
- return false;
- });
- }
+ // disable browser context menu.
+ if (settings.disablecontextmenu) {
+ $(this).bind("contextmenu",
+ function(e) {
+ return false;
+ });
+ }
- gesture.moves = "";
- gesture.x = -1;
- gesture.y = -1;
- gesture.continuesmode = settings.continuesmode;
+ gesture.moves = "";
+ gesture.x = -1;
+ gesture.y = -1;
+ gesture.continuesmode = settings.continuesmode;
- gesture.scale = 1.0;
- gesture.rotation = 0;
+ gesture.scale = 1.0;
+ gesture.rotation = 0;
- $(this).bind(settings.continueGesture,
- function(e) {
- var scale_diff = e.scale - 1.0;
- gesture.scale += scale_diff;
- if (Math.abs(gesture.scale - 1.0) >= settings.minScale) {
- gesture.name = 'scale';
- if (settings.continuesmode&& gesture_events['scale']) {
- var gesture_event = jQuery.Event("gesture_" + 'scale');
- gesture_event.gesture_data = gesture;
- gesture_events['scale']($(gesture.target)).trigger(gesture_event);
- gesture.scale = 1.0;
- gesture.rotation = 0;
- }
- }
- e.preventDefault();
- });
+ $(this).bind(settings.continueGesture,
+ function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ var scale_diff = e.originalEvent.scale - 1.0;
+ gesture.scale += scale_diff;
+ var rotation_diff = e.originalEvent.rotation - gesture.rotation
+ gesture.rotation = e.originalEvent.rotation
+ if (settings.continuesmode) {
+ if (Math.abs(gesture.scale - 1.0) >= settings.minScale && gesture_events['scale']) {
+ var gesture_event = jQuery.Event('gesture_scale');
+ gesture_event.gesture_data = jQuery.extend(gesture, { name: 'scale' });
+ gesture_event.scale = gesture.scale;
+ gesture_events['scale']($(gesture.target)).trigger(gesture_event);
+ gesture.scale = 1.0;
+ }
+ if (Math.abs(rotation_diff % 360) >= settings.minRotation && gesture_events['rotate']) {
+ var gesture_event = jQuery.Event('gesture_rotate');
+ gesture_event.gesture_data = jQuery.extend(gesture, { name: 'rotate' });
+ gesture_event.rotation = rotation_diff;
+ gesture_events['rotate']($(gesture.target)).trigger(gesture_event);
+ gesture.rotation = 0;
+ }
+ }
+ e.preventDefault();
+ });
- $(this).bind(settings.stopGesture,
- function(e) {
- if (Math.abs(gesture.scale - 1.0) >= settings.minScale && gesture_events['scale']) {
- gesture.name = 'scale';
- var gesture_event = jQuery.Event("gesture_" + 'scale');
- gesture_event.gesture_data = gesture;
- gesture_events['scale']($(gesture.target)).trigger(gesture_event);
- }
- $(this).unbind(settings.continueGesture);
- $(this).unbind(settings.stopGesture);
- });
+ $(this).bind(settings.stopGesture,
+ function(e) {
+ if (Math.abs(gesture.scale - 1.0) >= settings.minScale && gesture_events['scale']) {
+ var gesture_event = jQuery.Event('gesture_scale');
+ gesture_event.gesture_data = jQuery.extend(gesture, { name: 'scale' });
+ gesture_event.scale = gesture.scale;
+ gesture_events['scale']($(gesture.target)).trigger(gesture_event);
+ }
+ if (Math.abs(gesture.rotation % 360) >= settings.minRotation && gesture_events['rotate']) {
+ var gesture_event = jQuery.Event('gesture_rotate');
+ gesture_event.gesture_data = jQuery.extend(gesture, { name: 'rotate' });
+ gesture_event.rotation = gesture.rotation;
+ gesture_events['rotate']($(gesture.target)).trigger(gesture_event);
+ }
+ e.preventDefault();
+ e.stopPropagation();
+ $(this).unbind(settings.continueGesture);
+ $(this).unbind(settings.stopGesture);
+ });
};
this.bind(settings.startGesture, gesture_handler);
};
+ return this;
+
};
View
3 public/jqtouch/jqtouch.customized.js
@@ -645,7 +645,8 @@
goBack: goBack,
goTo: goTo,
addAnimation: addAnimation,
- submitForm: submitForm
+ submitForm: submitForm,
+history: hist
}
return publicObj;
View
3 public/stylesheets/application.css
@@ -54,5 +54,4 @@
display: none; }
.iconButton {
- float: right;
- margin-right: 42px; }
+ float: right; }
View
4 public/stylesheets/sass/application.sass
@@ -62,6 +62,4 @@
:display none
.iconButton
- :float right
- :margin
- :right 42px
+ :float right

0 comments on commit 0640bcf

Please sign in to comment.