vendor/assets/javascripts/webshims/shims/combos/17.js in webshims-rails-1.15.5 vs vendor/assets/javascripts/webshims/shims/combos/17.js in webshims-rails-1.15.6

- old
+ new

@@ -612,11 +612,11 @@ } }); } }); -;(function($){ +(function ($) { "use strict"; var isNumber = function(string){ return (typeof string == 'number' || (string && string == string * 1)); }; @@ -1232,11 +1232,11 @@ $.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){ +webshims.register('form-number-date-ui', function ($, webshims, window, document, undefined, options) { "use strict"; var curCfg; var formcfg = webshims.formcfg; var hasFormValidation = webshims.support.formvalidation && !webshims.bugs.bustedValidity; var monthDigits = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']; @@ -1797,13 +1797,13 @@ val = $.trim(val.replace(curCfg.meridian[0], '').replace(curCfg.meridian[1], '')); } return val; }, month: function(val, opts, noCorrect){ - - var p = (!opts.splitInput) ? val.trim().split(/[\.\s-\/\\]+/) : val; - + var regSplit = opts.monthNames == 'monthNamesShort' ? /[\s-\/\\]+/ : /[\.\s-\/\\]+/; + var p = (!opts.splitInput) ? val.trim().split(regSplit) : val; + if(p.length == 2 && p[0] && p[1]){ p[0] = !noCorrect && curCfg.date.monthkeys[p[0]] || p[0]; p[1] = !noCorrect && curCfg.date.monthkeys[p[1]] || p[1]; if(p[1].length == 2 && p[0].length > 3){ val = p[0]+'-'+p[1]; @@ -2271,38 +2271,39 @@ ['defaultValue', 'value'].forEach(function(name){ var isValue = name == 'value'; spinBtnProto[name] = function(val, force, isLive){ var selectionEnd; - if(isValue){ - this._beforeValue(val); - } else { - this.elemHelper.prop(name, val); - } + if(!this._init || force || val || this.options[name] !== val){ + if(isValue){ + this._beforeValue(val); + } else { + this.elemHelper.prop(name, val); + } - val = formatVal[this.type](val, this.options); - if(this.options.splitInput){ - $.each(this.splits, function(i, elem){ - var setOption; - if(!(name in elem) && !isValue && $.nodeName(elem, 'select')){ - $('option[value="'+ val[i] +'"]', elem).prop('defaultSelected', true); - } else { - $.prop(elem, name, val[i]); + val = formatVal[this.type](val, this.options); + if(this.options.splitInput){ + $.each(this.splits, function(i, elem){ + if(!(name in elem) && !isValue && $.nodeName(elem, 'select')){ + $('option[value="'+ val[i] +'"]', elem).prop('defaultSelected', true); + } else { + $.prop(elem, name, val[i]); + } + }); + } else { + val = this.toFixed(val); + if(isLive && this._getSelectionEnd){ + selectionEnd = this._getSelectionEnd(val); } - }); - } else { - val = this.toFixed(val); - if(isLive && this._getSelectionEnd){ - selectionEnd = this._getSelectionEnd(val); + this.element.prop(name, val); + if(selectionEnd != null){ + this.element.prop('selectionEnd', selectionEnd); + } } - this.element.prop(name, val); - if(selectionEnd != null){ - this.element.prop('selectionEnd', selectionEnd); - } + this._propertyChange(name); + this.mirrorValidity(); } - this._propertyChange(name); - this.mirrorValidity(); }; }); $.each({min: 1, max: -1}, function(name, factor){ var numName = name +'AsNumber'; @@ -2648,11 +2649,11 @@ if(popover.openedByFocus || !popover.isVisible){ open(); } else { popover.hide(); } - } + }; options.containerElements.push(popover.element[0]); popover.element @@ -2754,11 +2755,11 @@ setTimeout(function(){ popover.openedByFocus = false; popover.activeElement.focus(); }, 4); } - if(data.element.is(':focus') && !$.nodeName(e.target, 'select')){ + if(data.element.is(':focus') && !$.nodeName(e.target, 'select')){ popover.openedByFocus = options.buttonOnly ? false : !options.noInput; show(); } popover.preventBlur(); } @@ -3071,10 +3072,14 @@ var hasFocus = false; $(data.shim.options.containerElements) .on({ 'focusin focus focusout blur': function(e){ - e.stopImmediatePropagation(); + if(e.type == 'focus'){ + e.stopPropagation(); + } else { + e.stopImmediatePropagation(); + } hasFocus = has[e.type]; clearTimeout(timer); timer = setTimeout(function(){ if(hasFocus != hasFocusTriggered){ hasFocusTriggered = hasFocus;