vendor/assets/javascripts/webshims/shims/combos/11.js in webshims-rails-1.10.9 vs vendor/assets/javascripts/webshims/shims/combos/11.js in webshims-rails-1.10.10

- old
+ new

@@ -491,18 +491,18 @@ }); if(webshims._polyfill){ webshims._polyfill(['es5']); } } -})(jQuery); +})(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 stopPropagation = function(e){ - e.stopImmediatePropagation(e); + e.stopImmediatePropagation(); }; var createFormat = function(name){ if(!curCfg.patterns[name+'Obj']){ var obj = {}; $.each(curCfg.patterns[name].split(curCfg[name+'Format']), function(i, name){ @@ -569,10 +569,14 @@ var nowDate = new Date().getTime() - (new Date().getTimezoneOffset() * 60 * 1000 ); var steps = { number: { step: 1 }, +// week: { +// step: 1, +// start: new Date(nowDate) +// }, time: { step: 60 }, month: { step: 1, @@ -771,10 +775,13 @@ return (val+'').replace(/\,/g, '').replace(/\./, curCfg.numberFormat['.']); }, time: function(val){ return val; }, + week: function(val){ + return val; + }, //todo empty val for month/split month: function(val, options){ var names; var p = val.split('-'); if(p[0] && p[1]){ @@ -820,10 +827,13 @@ var parseVal = { number: function(val){ return (val+'').replace(curCfg.numberFormat[','], '').replace(curCfg.numberFormat['.'], '.'); }, +// week: function(val){ +// return val; +// }, time: function(val){ return val; }, month: function(val, opts, noCorrect){ @@ -956,10 +966,14 @@ 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]]); } } @@ -967,10 +981,15 @@ this.inputElements.prop('maxLength', 7); } this.addBindings(); $(this.element).data('wsWidget'+o.type, this); + + if(o.buttonOnly){ + this.inputElements.prop({readOnly: true}); + } + this._init = true; if(o.mirrorValidity){ that = this; timedMirror = function(){ @@ -1047,11 +1066,11 @@ var preventBlur = function(e){ if(preventBlur.prevent){ e.preventDefault(); (isFocused || that.element.getShadowFocusElement()).focus(); - e.stopImmediatePropagation(); + stopPropagation(e); return true; } }; var callSplitChange = (function(){ var timer; @@ -1419,16 +1438,22 @@ ['readonly', 'disabled'].forEach(function(name){ var isDisabled = name == 'disabled'; wsWidgetProto[name] = function(val, boolVal){ - if(this.options[name] != boolVal || !this._init){ - this.options[name] = !!boolVal; - this.inputElements.prop(name, this.options[name]); - this.buttonWrapper[this.options[name] ? 'addClass' : 'removeClass']('ws-'+name); + var options = this.options; + if(options[name] != boolVal || !this._init){ + options[name] = !!boolVal; + + if(!isDisabled && options.buttonOnly){ + this.inputElements.attr({'aria-readonly': options[name]}); + } else { + this.inputElements.prop(name, options[name]); + } + this.buttonWrapper[options[name] ? 'addClass' : 'removeClass']('ws-'+name); if(isDisabled){ - $('button', this.buttonWrapper).prop('disabled', this.options[name]); + $('button', this.buttonWrapper).prop('disabled', options[name]); } } }; }); @@ -1711,14 +1736,15 @@ }); }; picker._common = function(data){ - var popover = webshims.objectCreate(webshims.wsPopover, {}, {prepareFor: data.element}); - var opener = $('<button type="button" class="ws-popover-opener"><span /></button>').appendTo(data.buttonWrapper); var options = data.options; + var popover = webshims.objectCreate(webshims.wsPopover, {}, {prepareFor: data.element, position: options.widgetPosition}); + var opener = $('<button type="button" class="ws-popover-opener"><span /></button>').appendTo(data.buttonWrapper); + var showPickerContent = function(){ (picker[data.type].showPickerContent || picker.showPickerContent)(data, popover); }; var show = function(){ var type = loadPicker(data.type, 'DOM'); @@ -1802,42 +1828,52 @@ var resetMouseFocus = function(){ mouseFocus = false; }; data.inputElements.on({ focus: function(){ - if(!popover.stopOpen && (data.options.openOnFocus || (mouseFocus && options.openOnMouseFocus))){ - popover.openedByFocus = !options.noInput; + if(!popover.stopOpen && (options.buttonOnly || options.openOnFocus || (mouseFocus && options.openOnMouseFocus))){ + popover.openedByFocus = options.buttonOnly ? false : !options.noInput; show(); } else { popover.preventBlur(); } }, mousedown: function(){ mouseFocus = true; setTimeout(resetMouseFocus, 9); + if(options.buttonOnly && popover.isVisible && popover.activeElement){ + popover.openedByFocus = false; + setTimeout(function(){ + popover.openedByFocus = false; + popover.activeElement.focus(); + }, 4); + } if(data.element.is(':focus')){ - popover.openedByFocus = !options.noInput; + popover.openedByFocus = options.buttonOnly ? false : !options.noInput; show(); } popover.preventBlur(); } }); })(); data.popover = popover; data.opener = opener; $(data.orig).on('remove', function(e){ if(!e.originalEvent){ - opener.remove(); - popover.element.remove(); + setTimeout(function(){ + opener.remove(); + popover.element.remove(); + }, 4); } }); loadPicker(data.type, 'WINDOWLOAD'); }; picker.month = picker._common; picker.date = picker._common; +// picker.week = picker._common; picker.color = function(data){ var ret = picker._common.apply(this, arguments); var alpha = $(data.orig).data('alphacontrol'); var colorIndicator = data.opener .prepend('<span class="ws-color-indicator-bg"><span class="ws-color-indicator" /></span>') @@ -2085,13 +2121,15 @@ if(data.shim.buttonWrapper && data.shim.buttonWrapper.filter(isVisible).length){ data.shim.element.addClass('has-input-buttons'); } + data.shim.element.addClass($.prop(this, 'className')); + if(opts.calculateWidth){ sizeInput(data.shim); } else { - $(this).css({display: 'none'}); + $(this).addClass('ws-important-hide'); } } };