add gesture support for mobile page

This commit is contained in:
r888888888
2014-04-12 14:48:16 -07:00
parent 8895759ea1
commit 08da53f7f0
5 changed files with 65 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
//= require jquery-1.10.1.min.js
//= require hammer.min.js
//= require jquery.hammer.min.js
$(function() {
$(document).hammer();
});

View File

@@ -9,4 +9,27 @@
<%= content_for(:html_header) do %>
<meta name="viewport" content="width=device-width,initial-scale=1">
<script type="text/javascript">
$(function() {
$(document).on("swipeleft", function() {
var href = $(".paginator a[rel=next]").attr("href");
if (href) {
window.location = href;
}
});
$(document).on("swiperight", function() {
var href = $(".paginator a[rel=prev]").attr("href");
if (href) {
window.location = href;
}
})
});
</script>
<% end %>
<% if @post_set.tag_string.present? %>
<%= @post_set.humanized_tag_string %> - <%= Danbooru.config.app_name %>
<% else %>
<%= Danbooru.config.app_name %>
<% end %>

View File

@@ -11,4 +11,22 @@
<%= content_for(:html_header) do %>
<meta name="viewport" content="width=device-width,initial-scale=<%= @post.device_scale %>">
<script type="text/javascript">
$(function() {
$(document).on("swipeleft", function() {
var href = $(".paginator a[rel=next]").attr("href");
if (href) {
window.location = href;
}
});
$(document).on("swiperight", function() {
window.history.back();
})
});
</script>
<% end %>
<% content_for(:page_title) do %>
<%= @post.presenter.humanized_essential_tag_string %> - <%= Danbooru.config.app_name %>
<% end %>

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,8 @@
/*! jQuery plugin for Hammer.JS - v1.1.0dev - 2014-04-11
* http://eightmedia.github.com/hammer.js
*
* Copyright (c) 2014 Jorik Tangelder <j.tangelder@gmail.com>;
* Licensed under the MIT license */
!function(a){"use strict";function b(a,b){Date.now||(Date.now=function(){return(new Date).getTime()}),a.utils.each(["on","off"],function(c){a.utils[c]=function(a,d,e){b(a)[c](d,function(a){var c=b.extend({},a.originalEvent,a);e.call(this,c)})}}),a.Instance.prototype.trigger=function(a,c){var d=b(this.element);return d.has(c.target).length&&(d=b(c.target)),d.trigger({type:a,gesture:c})},b.fn.hammer=function(c){return this.each(function(){var d=b(this),e=d.data("hammer");e?e&&c&&a.utils.extend(e.options,c):d.data("hammer",new a(this,c||{}))})}}"function"==typeof define&&define.amd?define(["hammerjs","jquery"],b):b(a.Hammer,a.jQuery||a.Zepto)}(window);
//# sourceMappingURL=jquery.hammer.min.map