diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/jquery.ui.datepicker.js | 29 | ||||
-rw-r--r-- | ui/jquery.ui.position.js | 4 | ||||
-rw-r--r-- | ui/jquery.ui.spinner.js | 64 |
3 files changed, 60 insertions, 37 deletions
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index 0b6fb2218..e09dc5a50 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -636,10 +636,10 @@ $.extend(Datepicker.prototype, { return; var inst = $.datepicker._getInst(input); if ($.datepicker._curInst && $.datepicker._curInst != inst) { - if ( $.datepicker._datepickerShowing ) { - $.datepicker._triggerOnClose($.datepicker._curInst); - } $.datepicker._curInst.dpDiv.stop(true, true); + if ( inst && $.datepicker._datepickerShowing ) { + $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] ); + } } var beforeShow = $.datepicker._get(inst, 'beforeShow'); var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {}; @@ -790,14 +790,6 @@ $.extend(Datepicker.prototype, { return [position.left, position.top]; }, - /* Trigger custom callback of onClose. */ - _triggerOnClose: function(inst) { - var onClose = this._get(inst, 'onClose'); - if (onClose) - onClose.apply((inst.input ? inst.input[0] : null), - [(inst.input ? inst.input.val() : ''), inst]); - }, - /* Hide the date picker from view. @param input element - the input field attached to the date picker */ _hideDatepicker: function(input) { @@ -820,8 +812,11 @@ $.extend(Datepicker.prototype, { (showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess); if (!showAnim) postProcess(); - $.datepicker._triggerOnClose(inst); this._datepickerShowing = false; + var onClose = this._get(inst, 'onClose'); + if (onClose) + onClose.apply((inst.input ? inst.input[0] : null), + [(inst.input ? inst.input.val() : ''), inst]); this._lastInput = null; if (this._inDialog) { this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' }); @@ -843,12 +838,16 @@ $.extend(Datepicker.prototype, { _checkExternalClick: function(event) { if (!$.datepicker._curInst) return; - var $target = $(event.target); - if ($target[0].id != $.datepicker._mainDivId && + + var $target = $(event.target), + inst = $.datepicker._getInst($target[0]); + + if ( ( ( $target[0].id != $.datepicker._mainDivId && $target.parents('#' + $.datepicker._mainDivId).length == 0 && !$target.hasClass($.datepicker.markerClassName) && !$target.hasClass($.datepicker._triggerClass) && - $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI)) + $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) || + ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst != inst ) ) $.datepicker._hideDatepicker(); }, diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 24a033fc2..74530b948 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -376,7 +376,7 @@ $.ui.position = { newOverBottom; if ( overTop < 0 ) { newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset; - if ( newOverBottom < 0 || newOverBottom < Math.abs( overTop ) ) { + if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < Math.abs( overTop ) ) ) { data.elem .addClass( "ui-flipped-bottom" ); @@ -385,7 +385,7 @@ $.ui.position = { } else if ( overBottom > 0 ) { newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - withinOffset; - if ( newOverTop > 0 || Math.abs( newOverTop ) < overBottom ) { + if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || Math.abs( newOverTop ) < overBottom ) ) { data.elem .addClass( "ui-flipped-top" ); diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index d58665265..4b7239850 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -10,6 +10,7 @@ * Depends: * jquery.ui.core.js * jquery.ui.widget.js + * jquery.ui.button.js */ (function( $ ) { @@ -147,6 +148,12 @@ $.widget( "ui.spinner", { .button() .removeClass( "ui-corner-all" ); + // IE 6 doesn't understand height: 50% for the buttons + // unless the wrapper has an explicit height + if ( this.buttons.height() === uiSpinner.height() ) { + uiSpinner.height( uiSpinner.height() ); + } + // disable spinner if element was already disabled if ( this.options.disabled ) { this.disable(); @@ -213,20 +220,16 @@ $.widget( "ui.spinner", { }, _spin: function( step, event ) { + var value = this.value() || 0; + if ( !this.counter ) { this.counter = 1; } - var value = this.value(), - newVal = value + step * this._increment( this.counter ), - // fix precision from bad JS floating point math - precision = Math.max( this._precision( value ), - this._precision( this.options.step ) ); - // clamp the new value - newVal = this._trimValue( newVal.toFixed( precision ) ); + value = this._adjustValue( value + step * this._increment( this.counter ) ); - if ( !this.spinning || this._trigger( "spin", event, { value: newVal } ) !== false) { - this._value( newVal ); + if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) { + this._value( value ); this.counter++; } }, @@ -243,20 +246,41 @@ $.widget( "ui.spinner", { return 1; }, - _precision: function( num ) { + _precision: function() { + var precision = this._precisionOf( this.options.step ); + if ( this.options.min !== null ) { + precision = Math.max( precision, this._precisionOf( this.options.min ) ); + } + return precision; + }, + + _precisionOf: function( num ) { var str = num.toString(), decimal = str.indexOf( "." ); return decimal === -1 ? 0 : str.length - decimal - 1; }, - _trimValue: function( value ) { - var options = this.options; + _adjustValue: function( value ) { + var base, aboveMin, + options = this.options; + + // make sure we're at a valid step + // - find out where we are relative to the base (min or 0) + base = options.min !== null ? options.min : 0; + aboveMin = value - base; + // - round to the nearest step + aboveMin = Math.round(aboveMin / options.step) * options.step; + // - rounding is based on 0, so adjust back to our base + value = base + aboveMin; - if ( options.max != null && value > options.max) { + // fix precision from bad JS floating point math + value = parseFloat( value.toFixed( this._precision() ) ); + + // clamp the value + if ( options.max !== null && value > options.max) { return options.max; } - - if ( options.min != null && value < options.min ) { + if ( options.min !== null && value < options.min ) { return options.min; } @@ -295,10 +319,10 @@ $.widget( "ui.spinner", { }), _parse: function( val ) { - if ( typeof val === "string" ) { + if ( typeof val === "string" && val !== "" ) { val = window.Globalize && this.options.numberFormat ? Globalize.parseFloat( val ) : +val; } - return isNaN( val ) ? null : val; + return val === "" || isNaN( val ) ? null : val; }, _format: function( value ) { @@ -320,13 +344,13 @@ $.widget( "ui.spinner", { }, // update the value without triggering change - _value: function( value, ignoreRange ) { + _value: function( value, allowAny ) { var parsed; if ( value !== "" ) { parsed = this._parse( value ); if ( parsed !== null ) { - if ( !ignoreRange ) { - parsed = this._trimValue( parsed ); + if ( !allowAny ) { + parsed = this._adjustValue( parsed ); } value = this._format( parsed ); } |