summaryrefslogtreecommitdiffstats
path: root/module/web/static/js/libs/jquery.fastClick-0.2.js
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-08-27 13:04:18 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-08-27 13:04:18 +0200
commit6507b334c8e2c850924ce17d12bc4afacab500c7 (patch)
tree60d449934be4b840f1a85d019c85f3e78adbf1be /module/web/static/js/libs/jquery.fastClick-0.2.js
parentnew mobile template (diff)
downloadpyload-6507b334c8e2c850924ce17d12bc4afacab500c7.tar.xz
missing files, improved scaling
Diffstat (limited to 'module/web/static/js/libs/jquery.fastClick-0.2.js')
-rw-r--r--module/web/static/js/libs/jquery.fastClick-0.2.js96
1 files changed, 96 insertions, 0 deletions
diff --git a/module/web/static/js/libs/jquery.fastClick-0.2.js b/module/web/static/js/libs/jquery.fastClick-0.2.js
new file mode 100644
index 000000000..49eb75d2a
--- /dev/null
+++ b/module/web/static/js/libs/jquery.fastClick-0.2.js
@@ -0,0 +1,96 @@
+/**
+ * jQuery.fastClick.js
+ *
+ * Work around the 300ms delay for the click event in some mobile browsers.
+ *
+ * Code based on <http://code.google.com/mobile/articles/fast_buttons.html>
+ *
+ * @usage
+ * $('button').fastClick(function() {alert('clicked!');});
+ *
+ * @license Under Creative Commons Attribution 3.0 License
+ * @author Dave Hulbert (dave1010)
+ * @version 0.2 2011-09-20
+ */
+
+/*global document, window, jQuery, Math */
+
+(function($) {
+
+$.fn.fastClick = function(handler) {
+ return $(this).each(function(){
+ $.FastButton($(this)[0], handler);
+ });
+};
+
+$.FastButton = function(element, handler) {
+ var startX, startY;
+
+ var reset = function() {
+ $(element).unbind('touchend');
+ $("body").unbind('touchmove.fastClick');
+ };
+
+ var onClick = function(event) {
+ event.stopPropagation();
+ reset();
+ handler.call(this, event);
+
+ if (event.type === 'touchend') {
+ $.clickbuster.preventGhostClick(startX, startY);
+ }
+ };
+
+ var onTouchMove = function(event) {
+ if (Math.abs(event.originalEvent.touches[0].clientX - startX) > 10 ||
+ Math.abs(event.originalEvent.touches[0].clientY - startY) > 10) {
+ reset();
+ }
+ };
+
+ var onTouchStart = function(event) {
+ event.stopPropagation();
+
+ $(element).bind('touchend', onClick);
+ $("body").bind('touchmove.fastClick', onTouchMove);
+
+ startX = event.originalEvent.touches[0].clientX;
+ startY = event.originalEvent.touches[0].clientY;
+ };
+
+ $(element).bind({
+ touchstart: onTouchStart,
+ click: onClick
+ });
+};
+
+$.clickbuster = {
+ coordinates: [],
+
+ preventGhostClick: function(x, y) {
+ $.clickbuster.coordinates.push(x, y);
+ window.setTimeout($.clickbuster.pop, 2500);
+ },
+
+ pop: function() {
+ $.clickbuster.coordinates.splice(0, 2);
+ },
+
+ onClick: function(event) {
+ var x, y, i;
+ for (i = 0; i < $.clickbuster.coordinates.length; i += 2) {
+ x = $.clickbuster.coordinates[i];
+ y = $.clickbuster.coordinates[i + 1];
+ if (Math.abs(event.clientX - x) < 25 && Math.abs(event.clientY - y) < 25) {
+ event.stopPropagation();
+ event.preventDefault();
+ }
+ }
+ }
+};
+
+$(function(){
+ document.addEventListener('click', $.clickbuster.onClick, true);
+});
+
+}(jQuery));