implement gestures
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
//= require hammer.min.js
|
||||||
//= require jquery-1.11.1.min.js
|
//= require jquery-1.11.1.min.js
|
||||||
//= require jquery-ui-1.11.2.min.js
|
//= require jquery-ui-1.11.2.min.js
|
||||||
//= require jquery.hotkeys.js
|
//= require jquery.hotkeys.js
|
||||||
@@ -5,6 +6,7 @@
|
|||||||
//= require jquery-ui-autocomplete-custom.js
|
//= require jquery-ui-autocomplete-custom.js
|
||||||
//= require jquery.storageapi.js
|
//= require jquery.storageapi.js
|
||||||
//= require jquery.dropdown.min.js
|
//= require jquery.dropdown.min.js
|
||||||
|
//= require jquery.hammer.js
|
||||||
//= require ugoira_player.js
|
//= require ugoira_player.js
|
||||||
//= require stupidtable.js
|
//= require stupidtable.js
|
||||||
//= require rails.js
|
//= require rails.js
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
if ($("#c-posts").length && $("#a-index").length) {
|
if ($("#c-posts").length && $("#a-index").length) {
|
||||||
this.initialize_excerpt();
|
this.initialize_excerpt();
|
||||||
|
this.initialize_gestures();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($("#c-posts").length && $("#a-show").length) {
|
if ($("#c-posts").length && $("#a-show").length) {
|
||||||
@@ -24,6 +25,7 @@
|
|||||||
this.initialize_post_image_resize_to_window_link();
|
this.initialize_post_image_resize_to_window_link();
|
||||||
this.initialize_similar();
|
this.initialize_similar();
|
||||||
this.initialize_replace_image_dialog();
|
this.initialize_replace_image_dialog();
|
||||||
|
this.initialize_gestures();
|
||||||
|
|
||||||
if ((Danbooru.meta("always-resize-images") === "true") || ((Danbooru.Cookie.get("dm") != "1") && (window.innerWidth <= 660))) {
|
if ((Danbooru.meta("always-resize-images") === "true") || ((Danbooru.Cookie.get("dm") != "1") && (window.innerWidth <= 660))) {
|
||||||
$("#image-resize-to-window-link").click();
|
$("#image-resize-to-window-link").click();
|
||||||
@@ -35,6 +37,38 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Danbooru.Post.initialize_gestures = function() {
|
||||||
|
var hasNext = $("a[rel~=next]").length > 0;
|
||||||
|
var hasPrev = $("a[rel~=prev]").length > 0;
|
||||||
|
|
||||||
|
if (hasNext) {
|
||||||
|
$("body").hammer().bind("panleft", function(e) {
|
||||||
|
var percentage = 100 * e.gesture.deltaX / window.innerWidth;
|
||||||
|
$("body").css({"transition-duration": "0.1s", "transform": "translateX(" + percentage + "%)"});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasPrev) {
|
||||||
|
$("body").hammer().bind("panright", function(e) {
|
||||||
|
var percentage = 100 * e.gesture.deltaX / window.innerWidth;
|
||||||
|
$("body").css({"transition-duration": "0.1s", "transform": "translateX(" + percentage + "%)"});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$("body").hammer().bind("panend", function(e) {
|
||||||
|
var percentage = e.gesture.deltaX / window.innerWidth;
|
||||||
|
if (hasPrev && percentage > 0.4) {
|
||||||
|
$("body").css({"transition-timing-function": "ease", "transition-duration": "0.3s", "opacity": "0", "transform": "translateX(150%)"});
|
||||||
|
Danbooru.Post.nav_prev(e);
|
||||||
|
} else if (hasNext && percentage < -0.4) {
|
||||||
|
$("body").css({"transition-timing-function": "ease", "transition-duration": "0.3s", "opacity": "0", "transform": "translateX(-150%)"});
|
||||||
|
Danbooru.Post.nav_next(e);
|
||||||
|
} else {
|
||||||
|
$("body").css({"transition-timing-function": "ease", "transition-duration": "0.5s", "transform": "none"});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Danbooru.Post.initialize_edit_dialog = function(e) {
|
Danbooru.Post.initialize_edit_dialog = function(e) {
|
||||||
$("#open-edit-dialog").button().show().click(function(e) {
|
$("#open-edit-dialog").button().show().click(function(e) {
|
||||||
$(window).scrollTop($("#image").offset().top);
|
$(window).scrollTop($("#image").offset().top);
|
||||||
@@ -133,8 +167,10 @@
|
|||||||
if (href) {
|
if (href) {
|
||||||
location.href = href;
|
location.href = href;
|
||||||
}
|
}
|
||||||
|
} else if ($(".paginator a[rel~=prev]").length) {
|
||||||
|
location.href = $("a[rel~=prev]").attr("href");
|
||||||
} else {
|
} else {
|
||||||
var href = $("#pool-nav a.active[rel=prev], #favgroup-nav a.active[rel=prev]").attr("href");
|
var href = $("#pool-nav a.active[rel~=prev], #favgroup-nav a.active[rel~=prev]").attr("href");
|
||||||
if (href) {
|
if (href) {
|
||||||
location.href = href;
|
location.href = href;
|
||||||
}
|
}
|
||||||
@@ -147,8 +183,10 @@
|
|||||||
if ($("#search-seq-nav").length) {
|
if ($("#search-seq-nav").length) {
|
||||||
var href = $("#search-seq-nav a[rel~=next]").attr("href");
|
var href = $("#search-seq-nav a[rel~=next]").attr("href");
|
||||||
location.href = href;
|
location.href = href;
|
||||||
|
} else if ($("a[rel~=next]").length) {
|
||||||
|
location.href = $("a[rel~=next]").attr("href");
|
||||||
} else {
|
} else {
|
||||||
var href = $("#pool-nav a.active[rel=next], #favgroup-nav a.active[rel=next]").attr("href");
|
var href = $("#pool-nav a.active[rel~=next], #favgroup-nav a.active[rel~=next]").attr("href");
|
||||||
if (href) {
|
if (href) {
|
||||||
location.href = href;
|
location.href = href;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ end
|
|||||||
|
|
||||||
combined_spammers.each do |uid|
|
combined_spammers.each do |uid|
|
||||||
unless Ban.where(user_id: uid).exists?
|
unless Ban.where(user_id: uid).exists?
|
||||||
Ban.create(duration: 10000, reason: "Spam (automated ref f6147ace)", user_id: uid)
|
Ban.create!(duration: 10000, reason: "Spam (automated ref f6147ace)", user_id: uid)
|
||||||
puts "banned #{uid}"
|
puts "banned #{uid}"
|
||||||
sleep 1
|
sleep 1
|
||||||
end
|
end
|
||||||
|
|||||||
12
vendor/assets/javascripts/hammer.min.js
vendored
12
vendor/assets/javascripts/hammer.min.js
vendored
File diff suppressed because one or more lines are too long
33
vendor/assets/javascripts/jquery.hammer.js
vendored
Normal file
33
vendor/assets/javascripts/jquery.hammer.js
vendored
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
(function(factory) {
|
||||||
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
define(['jquery', 'hammerjs'], factory);
|
||||||
|
} else if (typeof exports === 'object') {
|
||||||
|
factory(require('jquery'), require('hammerjs'));
|
||||||
|
} else {
|
||||||
|
factory(jQuery, Hammer);
|
||||||
|
}
|
||||||
|
}(function($, Hammer) {
|
||||||
|
function hammerify(el, options) {
|
||||||
|
var $el = $(el);
|
||||||
|
if(!$el.data("hammer")) {
|
||||||
|
$el.data("hammer", new Hammer($el[0], options));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$.fn.hammer = function(options) {
|
||||||
|
return this.each(function() {
|
||||||
|
hammerify(this, options);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// extend the emit method to also trigger jQuery events
|
||||||
|
Hammer.Manager.prototype.emit = (function(originalEmit) {
|
||||||
|
return function(type, data) {
|
||||||
|
originalEmit.call(this, type, data);
|
||||||
|
$(this.element).trigger({
|
||||||
|
type: type,
|
||||||
|
gesture: data
|
||||||
|
});
|
||||||
|
};
|
||||||
|
})(Hammer.Manager.prototype.emit);
|
||||||
|
}));
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
/*! 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
|
|
||||||
Reference in New Issue
Block a user