vendor/assets/javascripts/webshims/shims/combos/11.js in webshims-rails-1.14.1 vs vendor/assets/javascripts/webshims/shims/combos/11.js in webshims-rails-1.14.3
- old
+ new
@@ -9,10 +9,27 @@
return def;
}
return val * 1;
};
var createOpts = ['step', 'min', 'max', 'readonly', 'title', 'disabled', 'tabindex'];
+ var normalizeTouch = (function(){
+ var types = {
+ touchstart: 1,
+ touchend: 1,
+ touchmove: 1
+ };
+ var normalize = ['pageX', 'pageY'];
+ return function(e){
+ if(types[e.type] && e.originalEvent && e.originalEvent.touches && e.originalEvent.touches.length){
+ for(var i = 0; i < normalize.length; i++){
+ e[normalize[i]] = e.originalEvent.touches[0][normalize[i]];
+ }
+
+ }
+ return e;
+ };
+ })();
var rangeProto = {
_create: function(){
var i;
this.element.addClass(this.options.baseClass || 'ws-range ws-input').attr({role: 'slider'}).append('<span class="ws-range-rail ws-range-track"><span class="ws-range-min ws-range-progress" /><span class="ws-range-thumb"><span><span data-value="" data-valuetext="" /></span></span></span>');
@@ -327,27 +344,11 @@
}, 0);
}
}
};
})();
- var normalizeTouch = (function(){
- var types = {
- touchstart: 1,
- touchend: 1,
- touchmove: 1
- };
- var normalize = ['pageX', 'pageY'];
- return function(e){
- if(types[e.type] && e.originalEvent && e.originalEvent.touches && e.originalEvent.touches.length){
- for(var i = 0; i < normalize.length; i++){
- e[normalize[i]] = e.originalEvent.touches[0][normalize[i]];
- }
-
- }
- return e;
- };
- })();
+
var updateValue = function(val, animate){
if(val != o.value){
that.value(val, false, animate);
eventTimer.call('input', val);
}
@@ -363,11 +364,11 @@
if(e && e.type == 'mousemove'){
e.preventDefault();
}
};
var remove = function(e){
- if(e && e.type == 'mouseup'){
+ if(e && (e.type == 'mouseup' || e.type == 'touchend')){
eventTimer.call('input', o.value);
eventTimer.call('change', o.value);
}
that.addRemoveClass('ws-active');
$(document).off('mousemove touchmove', setValueFromPos).off('mouseup touchend', remove);
@@ -384,10 +385,12 @@
e.preventDefault();
$(document).off('mousemove touchmove', setValueFromPos).off('mouseup touchend', remove);
$(window).off('blur', removeWin);
if(!o.readonly && !o.disabled){
+ eventTimer.init('input', o.value);
+ eventTimer.init('change', o.value);
normalizeTouch(e);
that.element.trigger('focus');
that.addRemoveClass('ws-active', true);
leftOffset = that.element.offset();
widgetUnits = that.element[that.dirs.innerWidth]();
@@ -419,12 +422,14 @@
};
var elementEvts = {
'touchstart mousedown': add,
focus: function(e){
if(!o.disabled && !hasFocus){
- eventTimer.init('input', o.value);
- eventTimer.init('change', o.value);
+ if(!isActive){
+ eventTimer.init('input', o.value);
+ eventTimer.init('change', o.value);
+ }
that.addRemoveClass('ws-focus', true);
that.updateMetrics();
}
hasFocus = true;
},
@@ -606,10 +611,11 @@
var obj = $.extend(oCreate(rangeProto), {element: $(this)});
obj.options = opts;
obj._create.call(obj);
});
};
+ $.fn.rangeUI.normalizeTouch = normalizeTouch;
if(window.webshims && webshims.isReady){
webshims.isReady('range-ui', true);
}
})(window.webshims ? webshims.$ : jQuery);
;webshims.register('form-number-date-ui', function($, webshims, window, document, undefined, options){
@@ -1313,15 +1319,11 @@
}
if( steps[this.type] && typeof steps[this.type].start == 'object'){
steps[this.type].start = this.asNumber(steps[this.type].start);
}
-
- if(!webshims.picker[this.type]){
- o.buttonOnly = false;
- }
-
+
for(i = 0; i < createOpts.length; i++){
if(o[createOpts[i]] != null){
this[createOpts[i]](o[createOpts[i]], o[createOpts[i]]);
}
}
@@ -1547,11 +1549,11 @@
wsWidgetProto._create.apply(this, arguments);
this._init = false;
- this.buttonWrapper.html('<span unselectable="on" class="step-controls"><span class="step-up"></span><span class="step-down"></span></span>');
+ this.buttonWrapper.html('<span unselectable="on" class="step-controls"><span class="step-up step-control"></span><span class="step-down step-control"></span></span>');
if(this.type == 'number'){
this.inputElements.attr('inputmode', 'numeric');
}
@@ -1730,11 +1732,11 @@
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 > 600){
+ 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);
@@ -1928,11 +1930,11 @@
if(popover.isVisible){
popover.element.triggerHandler('updatepickercontent');
}
};
return function(prop){
- if(prop == 'value' && !data.options.inlinePicker){return;}
+ if(prop == 'value' && (!data.options.inlinePicker || data._handledValue )){return;}
popover.isDirty = true;
if(popover.isVisible){
clearTimeout(timer);
timer = setTimeout(update, 9);
@@ -1987,10 +1989,17 @@
popover.openedByFocus = false;
popover.activeElement.focus();
}
show();
};
+ var toogle = function(){
+ if(popover.openedByFocus || !popover.isVisible){
+ open();
+ } else {
+ popover.hide();
+ }
+ }
options.containerElements.push(popover.element[0]);
popover.element
@@ -2027,11 +2036,11 @@
if(options.disabled){
opener.prop({disabled: true});
}
- opener.wsTouchClick(open);
+ opener.wsTouchClick(toogle);
if(options.inlinePicker){
popover.openedByFocus = true;
} else {
opener
@@ -2379,13 +2388,13 @@
if(opts.splitInput || type == 'range'){
cNames = cNames.replace('form-control', '');
}
data.shim.element.on('change input', stopPropagation).addClass(cNames+' '+webshims.shadowClass);
-
+
if(data.shim.buttonWrapper){
-
+
data.shim.buttonWrapper.addClass('input-button-size-'+(data.shim.buttonWrapper.children().filter(isVisible).length)+' '+webshims.shadowClass);
if(data.shim.buttonWrapper.filter(isVisible).length){
data.shim.element.addClass('has-input-buttons');
}
@@ -2538,9 +2547,35 @@
.add(contextElem.filter('input'))
.each(implementType)
;
});
};
+
+
+ if($('<input />').prop('labels') == null){
+ webshims.defineNodeNamesProperty('button, input, keygen, meter, output, progress, select, textarea', 'labels', {
+ prop: {
+ get: function(){
+ if(this.type == 'hidden'){return null;}
+ var id = this.id;
+ var labels = $(this)
+ .closest('label')
+ .filter(function(){
+ var hFor = (this.attributes['for'] || {});
+ return (!hFor.specified || hFor.value == id);
+ })
+ ;
+
+ if(id) {
+ labels = labels.add('label[for="'+ id +'"]');
+ }
+ return labels.get();
+ },
+ writeable: false
+ }
+ });
+ }
+
if(formcfg._isLoading){
$(formcfg).one('change', init);
} else {
init();
}