vendor/assets/javascripts/webshims/shims/combos/17.js in webshims-rails-1.14.3 vs vendor/assets/javascripts/webshims/shims/combos/17.js in webshims-rails-1.14.4
- old
+ new
@@ -1237,11 +1237,11 @@
})(window.webshims ? webshims.$ : jQuery);
;webshims.register('form-number-date-ui', function($, webshims, window, document, undefined, options){
"use strict";
var curCfg;
var formcfg = webshims.formcfg;
- var hasFormValidation = Modernizr.formvalidation && !webshims.bugs.bustedValidity;
+ var hasFormValidation = webshims.support.formvalidation && !webshims.bugs.bustedValidity;
var monthDigits = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'];
var stopPropagation = function(e){
e.stopImmediatePropagation();
};
var getMonthOptions = function(opts){
@@ -1290,11 +1290,11 @@
}
})
;
}
};
- var numericType = Modernizr.inputtypes.tel && navigator.userAgent.indexOf('Mobile') != -1 && !('inputMode' in document.createElement('input') && !('inputmode' in document.createElement('input'))) ?
+ var numericType = webshims.support.inputtypes.tel && navigator.userAgent.indexOf('Mobile') != -1 && !('inputMode' in document.createElement('input') && !('inputmode' in document.createElement('input'))) ?
'tel' : 'text';
var splitInputs = {
date: {
_create: function(opts){
var obj = {
@@ -2331,78 +2331,90 @@
webshims._format = formatVal;
})();
- $.fn.wsTouchClick = (function(){
- var supportsTouchaction = ('touchAction' in document.documentElement.style);
- var addTouch = !supportsTouchaction && ('ontouchstart' in window) && document.addEventListener;
- return function(target, handler){
- var touchData, touchEnd, touchStart;
- if(addTouch){
+ if(!$.fn.wsTouchClick){
- touchEnd = function(e){
- var ret, touch;
- e = e.originalEvent || {};
- $(this).off('touchend touchcancel', touchEnd);
- var changedTouches = e.changedTouches || e.touches;
- if(e.type == 'touchcancel' || !touchData || !changedTouches || changedTouches.length != 1){
- return;
+ $.fn.wsTouchClick = (function(){
+ var supportsTouchaction = ('touchAction' in document.documentElement.style);
+ var addTouch = !supportsTouchaction && ('ontouchstart' in window) && document.addEventListener;
+ return function(target, handler){
+ var touchData, touchEnd, touchStart, stopClick, allowClick;
+ var runHandler = function(){
+ if(!stopClick){
+ return handler.apply(this, arguments);
}
+ };
+ if(addTouch){
+ allowClick = function(){
+ stopClick = false;
+ };
+ touchEnd = function(e){
+ var ret, touch;
+ e = e.originalEvent || {};
+ $(this).off('touchend touchcancel', touchEnd);
+ var changedTouches = e.changedTouches || e.touches;
+ if(e.type == 'touchcancel' || !touchData || !changedTouches || changedTouches.length != 1){
+ return;
+ }
- touch = changedTouches[0];
- if(Math.abs(touchData.x - touch.pageX) > 40 || Math.abs(touchData.y - touch.pageY) > 40 || Date.now() - touchData.now > 300){
- return;
- }
- e.preventDefault();
- ret = handler.apply(this, arguments);
+ touch = changedTouches[0];
+ if(Math.abs(touchData.x - touch.pageX) > 40 || Math.abs(touchData.y - touch.pageY) > 40 || Date.now() - touchData.now > 300){
+ return;
+ }
- return ret;
- };
+ e.preventDefault();
+ stopClick = true;
+ setTimeout(allowClick, 400);
- touchStart = function(e){
- var touch, elemTarget;
+ ret = handler.apply(this, arguments);
+ return ret;
+ };
- if((!e || e.touches.length != 1)){
- return;
- }
- touch = e.touches[0];
- elemTarget = target ? $(touch.target).closest(target) : $(this);
- if(!elemTarget.length){
- return;
- }
- touchData = {
- x: touch.pageX,
- y: touch.pageY,
- now: Date.now()
+ touchStart = function(e){
+ var touch, elemTarget;
+ if((!e || e.touches.length != 1)){
+ return;
+ }
+ touch = e.touches[0];
+ elemTarget = target ? $(touch.target).closest(target) : $(this);
+ if(!elemTarget.length){
+ return;
+ }
+ touchData = {
+ x: touch.pageX,
+ y: touch.pageY,
+ now: Date.now()
+ };
+ elemTarget.on('touchend touchcancel', touchEnd);
};
- elemTarget.on('touchend touchcancel', touchEnd);
- };
- this.each(function(){
- this.addEventListener('touchstart', touchStart, true);
- });
- } else if(supportsTouchaction){
- this.css('touch-action', 'manipulation');
- }
+ this.each(function(){
+ this.addEventListener('touchstart', touchStart, true);
+ });
+ } else if(supportsTouchaction){
+ this.css('touch-action', 'manipulation');
+ }
- if($.isFunction(target)){
- handler = target;
- target = false;
- this.on('click', handler);
- } else {
- this.on('click', target, handler);
- }
- return this;
- };
- })();
+ if($.isFunction(target)){
+ handler = target;
+ target = false;
+ this.on('click', runHandler);
+ } else {
+ this.on('click', target, runHandler);
+ }
+ return this;
+ };
+ })();
+ }
(function(){
var picker = {};
- var assumeVirtualKeyBoard = Modernizr.touchevents || Modernizr.touch || (/android|iphone|ipad|ipod|blackberry|iemobile/i.test(navigator.userAgent.toLowerCase()));
+ var assumeVirtualKeyBoard = (window.Modernizr && (Modernizr.touchevents || Modernizr.touch)) || (/android|iphone|ipad|ipod|blackberry|iemobile/i.test(navigator.userAgent.toLowerCase()));
webshims.inlinePopover = {
_create: function(){
this.element = $('<div class="ws-inline-picker"><div class="ws-po-box" /></div>').data('wspopover', this);
this.contentElement = $('.ws-po-box', this.element);
this.element.insertAfter(this.options.prepareFor);
@@ -2788,11 +2800,11 @@
(function(){
var stopCircular, isCheckValidity;
- var modernizrInputTypes = Modernizr.inputtypes;
+ var supportInputTypes = webshims.support.inputtypes;
var inputTypes = {
};
var boolAttrs = {disabled: 1, required: 1, readonly: 1};
var copyProps = [
@@ -2942,11 +2954,11 @@
var implementType = function(){
var type = $.prop(this, 'type');
var i, opts, data, optsName, labels, cNames, hasInitialFocus;
- if(inputTypes[type] && webshims.implement(this, 'inputwidgets') && (!modernizrInputTypes[type] || !$(this).hasClass('ws-noreplace'))){
+ if(inputTypes[type] && webshims.implement(this, 'inputwidgets') && (!supportInputTypes[type] || !$(this).hasClass('ws-noreplace'))){
data = {};
optsName = type;
hasInitialFocus = $(this).is(':focus');
labels = $(this).jProp('labels');
@@ -3113,25 +3125,25 @@
'color': 1,
'datetime-local': 1
});
}
}
- if(modernizrInputTypes.number && navigator.userAgent.indexOf('Touch') == -1 && ((/MSIE 1[0|1]\.\d/.test(navigator.userAgent)) || (/Trident\/7\.0/.test(navigator.userAgent)))){
+ if(supportInputTypes.number && navigator.userAgent.indexOf('Touch') == -1 && ((/MSIE 1[0|1]\.\d/.test(navigator.userAgent)) || (/Trident\/7\.0/.test(navigator.userAgent)))){
replace.number = 1;
}
- if(!modernizrInputTypes.range || replace.range){
+ if(!supportInputTypes.range || replace.range){
extendType('range', {
_create: function(opts, set){
var data = $('<span />').insertAfter(opts.orig).rangeUI(opts).data('rangeUi');
return data;
}
});
}
['number', 'time', 'month', 'date', 'color', 'datetime-local'].forEach(function(name){
- if(!modernizrInputTypes[name] || replace[name]){
+ if(!supportInputTypes[name] || replace[name]){
extendType(name, {
_create: function(opts, set){
if(opts.monthSelect || opts.daySelect || opts.yearSelect){
opts.splitInput = true;
}