Merge pull request #257 from wvengen/feature-touchclick
Better workaround for touch devices
This commit is contained in:
commit
6e0489b25f
7 changed files with 84 additions and 24 deletions
|
|
@ -19,19 +19,7 @@
|
|||
//= require_self
|
||||
//= require ordering
|
||||
//= require stupidtable
|
||||
|
||||
// allow touch devices to work on click events
|
||||
// http://stackoverflow.com/a/16221066
|
||||
$.fn.extend({ _on: (function(){ return $.fn.on; })() });
|
||||
$.fn.extend({
|
||||
on: (function(){
|
||||
var isTouchSupported = 'ontouchstart' in window || window.DocumentTouch && document instanceof DocumentTouch;
|
||||
return function( types, selector, data, fn, one ) {
|
||||
if (typeof types == 'string' && isTouchSupported && !(types.match(/touch/gi))) types = types.replace(/click/gi, 'touchstart');
|
||||
return this._on( types, selector, data, fn, one );
|
||||
};
|
||||
}()),
|
||||
});
|
||||
//= require touchclick
|
||||
|
||||
// Load following statements, when DOM is ready
|
||||
$(function() {
|
||||
|
|
|
|||
|
|
@ -164,20 +164,20 @@ function updateBalance() {
|
|||
}
|
||||
|
||||
$(function() {
|
||||
$('input[data-increase_quantity]').click(function() {
|
||||
$('input[data-increase_quantity]').on('touchclick', function() {
|
||||
increaseQuantity($(this).data('increase_quantity'));
|
||||
});
|
||||
$('input[data-decrease_quantity]').click(function() {
|
||||
$('input[data-decrease_quantity]').on('touchclick', function() {
|
||||
decreaseQuantity($(this).data('decrease_quantity'));
|
||||
});
|
||||
$('input[data-increase_tolerance]').click(function() {
|
||||
$('input[data-increase_tolerance]').on('touchclick', function() {
|
||||
increaseTolerance($(this).data('increase_tolerance'));
|
||||
});
|
||||
$('input[data-decrease_tolerance]').click(function() {
|
||||
$('input[data-decrease_tolerance]').on('touchclick', function() {
|
||||
decreaseTolerance($(this).data('decrease_tolerance'));
|
||||
});
|
||||
|
||||
$('a[data-confirm_switch_order]').click(function() {
|
||||
$('a[data-confirm_switch_order]').on('touchclick', function() {
|
||||
return (!modified || confirm(I18n.t('js.ordering.confirm_change')));
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue