diff options
author | Scott González <scott.gonzalez@gmail.com> | 2011-07-25 11:53:14 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2011-07-25 11:53:14 -0400 |
commit | 19a9de7e668cdb3b76c3b733d0147f1853cb38a5 (patch) | |
tree | a259b421dd77cbec27e55db9b4d1104bf5214a2a /ui | |
parent | daadc343be2f139e82719e2e5ff466aa19ec166f (diff) | |
parent | 51ee3be39829e339c8e4bccb532347944e600ca5 (diff) | |
download | jquery-ui-19a9de7e668cdb3b76c3b733d0147f1853cb38a5.tar.gz jquery-ui-19a9de7e668cdb3b76c3b733d0147f1853cb38a5.zip |
Merge branch 'master' into core-1.6.1
Conflicts:
demos/menubar/default.html
tests/unit/autocomplete/autocomplete.html
tests/visual/effects/effects.all.html
ui/jquery.ui.menu.js
ui/jquery.ui.popup.js
Diffstat (limited to 'ui')
-rw-r--r-- | ui/i18n/jquery.ui.datepicker-nl.js | 2 | ||||
-rw-r--r-- | ui/jquery.effects.blind.js | 109 | ||||
-rw-r--r-- | ui/jquery.effects.bounce.js | 185 | ||||
-rw-r--r-- | ui/jquery.effects.clip.js | 85 | ||||
-rw-r--r-- | ui/jquery.effects.core.js | 34 | ||||
-rw-r--r-- | ui/jquery.effects.drop.js | 87 | ||||
-rw-r--r-- | ui/jquery.effects.explode.js | 139 | ||||
-rw-r--r-- | ui/jquery.effects.fade.js | 37 | ||||
-rw-r--r-- | ui/jquery.effects.fold.js | 99 | ||||
-rw-r--r-- | ui/jquery.effects.highlight.js | 60 | ||||
-rw-r--r-- | ui/jquery.effects.pulsate.js | 83 | ||||
-rw-r--r-- | ui/jquery.effects.scale.js | 467 | ||||
-rw-r--r-- | ui/jquery.effects.shake.js | 102 | ||||
-rw-r--r-- | ui/jquery.effects.slide.js | 88 | ||||
-rw-r--r-- | ui/jquery.effects.transfer.js | 58 | ||||
-rw-r--r-- | ui/jquery.ui.accordion.js | 36 | ||||
-rw-r--r-- | ui/jquery.ui.datepicker.js | 47 | ||||
-rw-r--r-- | ui/jquery.ui.dialog.js | 5 | ||||
-rw-r--r-- | ui/jquery.ui.menu.js | 287 | ||||
-rw-r--r-- | ui/jquery.ui.menubar.js | 48 | ||||
-rw-r--r-- | ui/jquery.ui.popup.js | 102 | ||||
-rw-r--r-- | ui/jquery.ui.position.js | 135 | ||||
-rw-r--r-- | ui/jquery.ui.spinner.js | 25 | ||||
-rw-r--r-- | ui/jquery.ui.tooltip.js | 11 | ||||
-rw-r--r-- | ui/jquery.ui.widget.js | 14 |
25 files changed, 1308 insertions, 1037 deletions
diff --git a/ui/i18n/jquery.ui.datepicker-nl.js b/ui/i18n/jquery.ui.datepicker-nl.js index 09634088b..781fe6191 100644 --- a/ui/i18n/jquery.ui.datepicker-nl.js +++ b/ui/i18n/jquery.ui.datepicker-nl.js @@ -8,7 +8,7 @@ jQuery(function($){ currentText: 'Vandaag', monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'], - monthNamesShort: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun', + monthNamesShort: ['jan', 'feb', 'mrt', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'], dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'], dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'], diff --git a/ui/jquery.effects.blind.js b/ui/jquery.effects.blind.js index 8ef544faa..5f86bed7b 100644 --- a/ui/jquery.effects.blind.js +++ b/ui/jquery.effects.blind.js @@ -11,74 +11,67 @@ * jquery.effects.core.js */ (function( $, undefined ) { - -var rvertical = /up|down|vertical/; -var rpositivemotion = /up|left|vertical|horizontal/; -$.effects.effect.blind = function( o ) { +var rvertical = /up|down|vertical/, + rpositivemotion = /up|left|vertical|horizontal/; - return this.queue( function() { +$.effects.effect.blind = function( o, done ) { + // Create element + var el = $( this ), + props = [ "position", "top", "bottom", "left", "right", "height", "width" ], + mode = $.effects.setMode( el, o.mode || "hide" ), + direction = o.direction || "up", + vertical = rvertical.test( direction ), + ref = vertical ? "height" : "width", + ref2 = vertical ? "top" : "left", + motion = rpositivemotion.test( direction ), + animation = {}, + show = mode === "show", + wrapper, distance; - // Create element - var el = $( this ), - props = [ "position", "top", "bottom", "left", "right" ], - mode = $.effects.setMode( el, o.mode || "hide" ), - direction = o.direction || "up", - vertical = rvertical.test( direction ), - ref = vertical ? "height" : "width", - ref2 = vertical ? "top" : "left", - motion = rpositivemotion.test( direction ), - animation = {}, - wrapper, distance; + // if already wrapped, the wrapper's properties are my property. #6245 + if ( el.parent().is( ".ui-effects-wrapper" ) ) { + $.effects.save( el.parent(), props ); + } else { + $.effects.save( el, props ); + } + el.show(); + wrapper = $.effects.createWrapper( el ).css({ + overflow: "hidden" + }); - // if already wrapped, the wrapper's properties are my property. #6245 - if ( el.parent().is( ".ui-effects-wrapper" ) ) { - $.effects.save( el.parent(), props ); - } else { - $.effects.save( el, props ); - } - el.show(); - wrapper = $.effects.createWrapper( el ).css({ - overflow: "hidden" - }); + distance = wrapper[ ref ](); - distance = wrapper[ ref ](); + animation[ ref ] = show ? distance : 0; + if ( !motion ) { + el + .css( vertical ? "bottom" : "right", 0 ) + .css( vertical ? "top" : "left", "" ) + .css({ position: "absolute" }); + animation[ ref2 ] = show ? 0 : distance; + } - animation[ ref ] = ( mode === "show" ? distance : 0 ); - if ( !motion ) { - el - .css( vertical ? "bottom" : "right", 0 ) - .css( vertical ? "top" : "left", "" ) - .css({ position: "absolute" }); - animation[ ref2 ] = ( mode === "show" ) ? 0 : distance; + // start at 0 if we are showing + if ( show ) { + wrapper.css( ref, 0 ); + if ( ! motion ) { + wrapper.css( ref2, distance ); } + } - // start at 0 if we are showing - if ( mode == "show" ) { - wrapper.css( ref, 0 ); - if ( ! motion ) { - wrapper.css( ref2, distance ); + // Animate + wrapper.animate( animation, { + duration: o.duration, + easing: o.easing, + queue: false, + complete: function() { + if ( mode === "hide" ) { + el.hide(); } + $.effects.restore( el, props ); + $.effects.removeWrapper( el ); + done(); } - - // Animate - wrapper.animate( animation, { - duration: o.duration, - easing: o.easing, - queue: false, - complete: function() { - if ( mode == "hide" ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - if ( $.isFunction( o.complete ) ) { - o.complete.apply( el[ 0 ], arguments ); - } - el.dequeue(); - } - }); - }); }; diff --git a/ui/jquery.effects.bounce.js b/ui/jquery.effects.bounce.js index 9e1117ce9..41ee34f64 100644 --- a/ui/jquery.effects.bounce.js +++ b/ui/jquery.effects.bounce.js @@ -12,108 +12,101 @@ */ (function( $, undefined ) { -$.effects.effect.bounce = function(o) { - - return this.queue( function( next ) { - var el = $( this ), - props = [ "position", "top", "bottom", "left", "right" ], - - // defaults: - mode = $.effects.setMode( el, o.mode || "effect" ), - hide = mode === "hide", - show = mode === "show", - direction = o.direction || "up", - distance = o.distance, - times = o.times || 5, - - // number of internal animations - anims = times * 2 + ( show || hide ? 1 : 0 ), - speed = o.duration / anims, - easing = o.easing, - - // utility: - ref = ( direction === "up" || direction === "down" ) ? "top" : "left", - motion = ( direction === "up" || direction === "left" ), - i, - upAnim, - downAnim, - - // we will need to re-assemble the queue to stack our animations in place - queue = el.queue(), - queuelen = queue.length; - - // Avoid touching opacity to prevent clearType and PNG issues in IE - if ( show || hide ) { - props.push( "opacity" ); - } - - $.effects.save( el, props ); - el.show(); - $.effects.createWrapper( el ); // Create Wrapper - - // default distance for the BIGGEST bounce is the outer Distance / 3 - if ( !distance ) { - distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3; - } - - if ( show ) { - downAnim = { opacity: 1 }; - downAnim[ ref ] = 0; - - // if we are showing, force opacity 0 and set the initial position - // then do the "first" animation - el.css( "opacity", 0 ) - .css( ref, motion ? -distance*2 : distance*2 ) - .animate( downAnim, speed, easing ); - } - - // start at the smallest distance if we are hiding - if ( hide ) { - distance = distance / Math.pow( 2, times - 1 ); - } - - downAnim = {}; +$.effects.effect.bounce = function( o, done ) { + var el = $( this ), + props = [ "position", "top", "bottom", "left", "right", "height", "width" ], + + // defaults: + mode = $.effects.setMode( el, o.mode || "effect" ), + hide = mode === "hide", + show = mode === "show", + direction = o.direction || "up", + distance = o.distance, + times = o.times || 5, + + // number of internal animations + anims = times * 2 + ( show || hide ? 1 : 0 ), + speed = o.duration / anims, + easing = o.easing, + + // utility: + ref = ( direction === "up" || direction === "down" ) ? "top" : "left", + motion = ( direction === "up" || direction === "left" ), + i, + upAnim, + downAnim, + + // we will need to re-assemble the queue to stack our animations in place + queue = el.queue(), + queuelen = queue.length; + + // Avoid touching opacity to prevent clearType and PNG issues in IE + if ( show || hide ) { + props.push( "opacity" ); + } + + $.effects.save( el, props ); + el.show(); + $.effects.createWrapper( el ); // Create Wrapper + + // default distance for the BIGGEST bounce is the outer Distance / 3 + if ( !distance ) { + distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3; + } + + if ( show ) { + downAnim = { opacity: 1 }; downAnim[ ref ] = 0; - // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here - for ( i = 0; i < times; i++ ) { - upAnim = {}; - upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; - el.animate( upAnim, speed, easing ) - .animate( downAnim, speed, easing ); - - distance = hide ? distance * 2 : distance / 2; - } - - // Last Bounce when Hiding + // if we are showing, force opacity 0 and set the initial position + // then do the "first" animation + el.css( "opacity", 0 ) + .css( ref, motion ? -distance * 2 : distance * 2 ) + .animate( downAnim, speed, easing ); + } + + // start at the smallest distance if we are hiding + if ( hide ) { + distance = distance / Math.pow( 2, times - 1 ); + } + + downAnim = {}; + downAnim[ ref ] = 0; + // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here + for ( i = 0; i < times; i++ ) { + upAnim = {}; + upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; + + el.animate( upAnim, speed, easing ) + .animate( downAnim, speed, easing ); + + distance = hide ? distance * 2 : distance / 2; + } + + // Last Bounce when Hiding + if ( hide ) { + upAnim = { opacity: 0 }; + upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; + + el.animate( upAnim, speed, easing ); + } + + el.queue(function() { if ( hide ) { - upAnim = { opacity: 0 }; - upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance; - - el.animate( upAnim, speed, easing ); + el.hide(); } - - el.queue( function( next ) { - if ( hide ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - if ( o.complete ) { - o.complete.apply( el[ 0 ] ); - } - next(); - }); - - // inject all the animations we just queued to be first in line (after "inprogress") - if ( queuelen > 1) { - queue.splice.apply( queue, - [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); - } - next(); - + $.effects.restore( el, props ); + $.effects.removeWrapper( el ); + done(); }); + // inject all the animations we just queued to be first in line (after "inprogress") + if ( queuelen > 1) { + queue.splice.apply( queue, + [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); + } + el.dequeue(); + }; })(jQuery); diff --git a/ui/jquery.effects.clip.js b/ui/jquery.effects.clip.js index 14b358dfa..c6eecc671 100644 --- a/ui/jquery.effects.clip.js +++ b/ui/jquery.effects.clip.js @@ -12,56 +12,53 @@ */ (function( $, undefined ) { -$.effects.effect.clip = function( o ) { +$.effects.effect.clip = function( o, done ) { + // Create element + var el = $( this ), + props = [ "position", "top", "bottom", "left", "right", "height", "width" ], + mode = $.effects.setMode( el, o.mode || "hide" ), + show = mode === "show", + direction = o.direction || "vertical", + vert = direction === "vertical", + size = vert ? "height" : "width", + position = vert ? "top" : "left", + animation = {}, + wrapper, animate, distance; - return this.queue( function() { + // Save & Show + $.effects.save( el, props ); + el.show(); - // Create element - var el = $( this ), - props = ['position','top','bottom','left','right','height','width'], - mode = $.effects.setMode( el, o.mode || 'hide' ), - direction = o.direction || 'vertical', - ref = { - size: (direction == 'vertical') ? 'height' : 'width', - position: (direction == 'vertical') ? 'top' : 'left' - }, - animation = {}, - wrapper, animate, distance; - - // Save & Show - $.effects.save( el, props ); el.show(); - - // Create Wrapper - wrapper = $.effects.createWrapper( el ).css({ - overflow: 'hidden' - }); - animate = ( el[0].tagName == 'IMG' ) ? wrapper : el; - distance = animate[ ref.size ](); + // Create Wrapper + wrapper = $.effects.createWrapper( el ).css({ + overflow: "hidden" + }); + animate = ( el[0].tagName === "IMG" ) ? wrapper : el; + distance = animate[ size ](); - // Shift - if ( mode == 'show' ) { - animate.css( ref.size, 0 ); - animate.css( ref.position, distance / 2 ); - } + // Shift + if ( show ) { + animate.css( size, 0 ); + animate.css( position, distance / 2 ); + } - // Create Animation Object: - animation[ ref.size ] = mode == 'show' ? distance : 0; - animation[ ref.position ] = mode == 'show' ? 0 : distance / 2; + // Create Animation Object: + animation[ size ] = show ? distance : 0; + animation[ position ] = show ? 0 : distance / 2; - // Animate - animate.animate( animation, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: function() { - mode == 'hide' && el.hide(); - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - $.isFunction( o.complete ) && o.complete.apply( el[ 0 ], arguments ); - el.dequeue(); + // Animate + animate.animate( animation, { + queue: false, + duration: o.duration, + easing: o.easing, + complete: function() { + if ( !show ) { + el.hide(); } - }); - + $.effects.restore( el, props ); + $.effects.removeWrapper( el ); + done(); + } }); }; diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js index 7650aa8f4..b08cd6cf4 100644 --- a/ui/jquery.effects.core.js +++ b/ui/jquery.effects.core.js @@ -410,7 +410,12 @@ $.extend( $.effects, { border: "none", margin: 0, padding: 0 - }); + }), + // Store the size in case width/height are defined in % - Fixes #5245 + size = { + width: element.width(), + height: element.height() + }; element.wrap( wrapper ); wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually loose the reference to the wrapped element @@ -438,6 +443,7 @@ $.extend( $.effects, { bottom: "auto" }); } + element.css(size); return wrapper.css( props ).show(); }, @@ -530,6 +536,7 @@ $.fn.extend({ effect: function( effect, options, speed, callback ) { var args = _normalizeArguments.apply( this, arguments ), mode = args.mode, + queue = args.queue, effectMethod = $.effects.effect[ args.effect ], // DEPRECATED: remove in 2.0 (#7115) @@ -548,9 +555,32 @@ $.fn.extend({ } } + function run( next ) { + var elem = $( this ), + complete = args.complete, + mode = args.mode; + + function done() { + if ( $.isFunction( complete ) ) { + complete.call( elem[0] ); + } + if ( $.isFunction( next ) ) { + next(); + } + } + + // if the element is hiddden and mode is hide, + // or element is visible and mode is show + if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) { + done(); + } else { + effectMethod.call( elem[0], args, done ); + } + } + // TODO: remove this check in 2.0, effectMethod will always be true if ( effectMethod ) { - return effectMethod.call( this, args ); + return queue === false ? this.each( run ) : this.queue( queue || "fx", run ); } else { // DEPRECATED: remove in 2.0 (#7115) return oldEffectMethod.call(this, { diff --git a/ui/jquery.effects.drop.js b/ui/jquery.effects.drop.js index 24fb89db0..2e7a6ec0f 100644 --- a/ui/jquery.effects.drop.js +++ b/ui/jquery.effects.drop.js @@ -12,51 +12,50 @@ */ (function( $, undefined ) { -$.effects.effect.drop = function( o ) { - - return this.queue( function() { - - var el = $( this ), - props = [ 'position', 'top', 'bottom', 'left', 'right', 'opacity' ], - mode = $.effects.setMode( el, o.mode || 'hide' ), - direction = o.direction || 'left', - ref = ( direction == 'up' || direction == 'down' ) ? 'top' : 'left', - motion = ( direction == 'up' || direction == 'left' ) ? 'pos' : 'neg', - animation = { - opacity: mode == 'show' ? 1 : 0 - }, - distance; - - // Adjust - $.effects.save( el, props ); - el.show(); - $.effects.createWrapper( el ); - - distance = o.distance || el[ ref == 'top' ? 'outerHeight': 'outerWidth' ]({ margin: true }) / 2; - - if ( mode == 'show' ) { - el - .css( 'opacity', 0 ) - .css( ref, motion == 'pos' ? -distance : distance ); +$.effects.effect.drop = function( o, done ) { + + var el = $( this ), + props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ], + mode = $.effects.setMode( el, o.mode || "hide" ), + show = mode === "show", + direction = o.direction || "left", + ref = ( direction === "up" || direction === "down" ) ? "top" : "left", + motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg", + animation = { + opacity: show ? 1 : 0 + }, + distance; + + // Adjust + $.effects.save( el, props ); + el.show(); + $.effects.createWrapper( el ); + + distance = o.distance || el[ ref == "top" ? "outerHeight": "outerWidth" ]({ margin: true }) / 2; + + if ( show ) { + el + .css( "opacity", 0 ) + .css( ref, motion == "pos" ? -distance : distance ); + } + + // Animation + animation[ ref ] = ( show ? + ( motion === "pos" ? "+=" : "-=" ) : + ( motion === "pos" ? "-=" : "+=" ) ) + + distance; + + // Animate + el.animate( animation, { + queue: false, + duration: o.duration, + easing: o.easing, + complete: function() { + mode == "hide" && el.hide(); + $.effects.restore( el, props ); + $.effects.removeWrapper( el ); + done(); } - - // Animation - animation[ ref ] = ((mode == 'show') ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance; - - // Animate - el.animate( animation, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: function() { - mode == 'hide' && el.hide(); - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - $.isFunction( o.complete ) && o.complete.apply(this, arguments); - el.dequeue(); - } - }); - }); }; diff --git a/ui/jquery.effects.explode.js b/ui/jquery.effects.explode.js index f5217ecb5..22f506045 100644 --- a/ui/jquery.effects.explode.js +++ b/ui/jquery.effects.explode.js @@ -12,92 +12,85 @@ */ (function( $, undefined ) { -$.effects.effect.explode = function( o ) { +$.effects.effect.explode = function( o, done ) { - return this.queue( function( next ) { + var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3, + cells = rows, + el = $( this ), + mode = $.effects.setMode( el, o.mode || "hide" ), + show = mode === "show", - var rows = o.pieces ? Math.round(Math.sqrt(o.pieces)) : 3, - cells = rows, - el = $( this ), - mode = $.effects.setMode( el, o.mode || 'hide' ), - show = ( mode == 'show' ), + // show and then visibility:hidden the element before calculating offset + offset = el.show().css( "visibility", "hidden" ).offset(), - // show and then visibility:hidden the element before calculating offset - offset = el.show().css( 'visibility', 'hidden' ).offset(), + // width and height of a piece + width = Math.ceil( el.outerWidth() / cells ), + height = Math.ceil( el.outerHeight() / rows ), + pieces = [], - // width and height of a piece - width = Math.ceil( el.outerWidth() / cells ), - height = Math.ceil( el.outerHeight() / rows ), - pieces = [], + // loop + i, j, left, top, mx, my; - // loop - i, j, left, top, mx, my; + // clone the element for each row and cell. + for( i = 0; i < rows ; i++ ) { // ===> + top = offset.top + i * height; + my = i - ( rows - 1 ) / 2 ; - // clone the element for each row and cell. - for( i = 0; i < rows ; i++ ) { // ===> - top = offset.top + i * height; - my = i - ( rows - 1 ) / 2 ; + for( j = 0; j < cells ; j++ ) { // ||| + left = offset.left + j * width; + mx = j - ( cells - 1 ) / 2 ; - for( j = 0; j < cells ; j++ ) { // ||| - left = offset.left + j * width; - mx = j - ( cells - 1 ) / 2 ; + // Create a clone of the now hidden main element that will be absolute positioned + // within a wrapper div off the -left and -top equal to size of our pieces + el + .clone() + .appendTo( "body" ) + .wrap( "<div></div>" ) + .css({ + position: "absolute", + visibility: "visible", + left: -j * width, + top: -i * height + }) - // Create a clone of the now hidden main element that will be absolute positioned - // within a wrapper div off the -left and -top equal to size of our pieces - el - .clone() - .appendTo( 'body' ) - .wrap( '<div></div>' ) - .css({ - position: 'absolute', - visibility: 'visible', - left: -j * width, - top: -i * height - }) - - // select the wrapper - make it overflow: hidden and absolute positioned based on - // where the original was located +left and +top equal to the size of pieces - .parent() - .addClass( 'ui-effects-explode' ) - .css({ - position: 'absolute', - overflow: 'hidden', - width: width, - height: height, - left: left + ( show ? mx * width : 0 ), - top: top + ( show ? my * height : 0 ), - opacity: show ? 0 : 1 - }).animate({ - left: left + ( show ? 0 : mx * width ), - top: top + ( show ? 0 : my * height ), - opacity: show ? 1 : 0 - }, o.duration || 500, o.easing, childComplete ); - } + // select the wrapper - make it overflow: hidden and absolute positioned based on + // where the original was located +left and +top equal to the size of pieces + .parent() + .addClass( "ui-effects-explode" ) + .css({ + position: "absolute", + overflow: "hidden", + width: width, + height: height, + left: left + ( show ? mx * width : 0 ), + top: top + ( show ? my * height : 0 ), + opacity: show ? 0 : 1 + }).animate({ + left: left + ( show ? 0 : mx * width ), + top: top + ( show ? 0 : my * height ), + opacity: show ? 1 : 0 + }, o.duration || 500, o.easing, childComplete ); } + } - // children animate complete: - function childComplete() { - pieces.push( this ); - if ( pieces.length == rows * cells ) { - animComplete(); - } + // children animate complete: + function childComplete() { + pieces.push( this ); + if ( pieces.length == rows * cells ) { + animComplete(); } + } - function animComplete() { - el.css({ - visibility: 'visible' - }); - $( pieces ).remove(); - if ( !show ) { - el.hide(); - } - if ( $.isFunction( o.complete ) ) { - o.complete.apply( el[ 0 ] ); - } - next(); + function animComplete() { + el.css({ + visibility: "visible" + }); + $( pieces ).remove(); + if ( !show ) { + el.hide(); } - }); - + done(); + } }; })(jQuery); diff --git a/ui/jquery.effects.fade.js b/ui/jquery.effects.fade.js index ff1cba5f8..9b79ad3bc 100644 --- a/ui/jquery.effects.fade.js +++ b/ui/jquery.effects.fade.js @@ -12,29 +12,24 @@ */ (function( $, undefined ) { -$.effects.effect.fade = function( o ) { - return this.queue( function( next ) { - var el = $( this ), - mode = $.effects.setMode( el, o.mode || 'toggle' ), - hide = mode === "hide"; +$.effects.effect.fade = function( o, done ) { + var el = $( this ), + mode = $.effects.setMode( el, o.mode || "toggle" ), + hide = mode === "hide"; - el.show(); - el.animate({ - opacity: hide ? 0 : 1 - }, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: function() { - if ( hide ) { - el.hide(); - } - if ( o.complete ) { - o.complete.call( this ); - } - next(); + el.show(); + el.animate({ + opacity: hide ? 0 : 1 + }, { + queue: false, + duration: o.duration, + easing: o.easing, + complete: function() { + if ( hide ) { + el.hide(); } - }); + done(); + } }); }; diff --git a/ui/jquery.effects.fold.js b/ui/jquery.effects.fold.js index 29da090cb..7c4f583c1 100644 --- a/ui/jquery.effects.fold.js +++ b/ui/jquery.effects.fold.js @@ -12,61 +12,62 @@ */ (function( $, undefined ) { -$.effects.effect.fold = function( o ) { +$.effects.effect.fold = function( o, done ) { - return this.queue( function() { + // Create element + var el = $( this ), + props = [ "position", "top", "bottom", "left", "right", "height", "width" ], + mode = $.effects.setMode( el, o.mode || "hide" ), + show = mode === "show", + hide = mode === "hide", + size = o.size || 15, + percent = /([0-9]+)%/.exec( size ), + horizFirst = !!o.horizFirst, + widthFirst = show != horizFirst, + ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ], + duration = o.duration / 2, + wrapper, distance, + animation1 = {}, animation2 = {}; - // Create element - var el = $( this ), - props = ['position','top','bottom','left','right'], - mode = $.effects.setMode(el, o.mode || 'hide'), - size = o.size || 15, - percent = /([0-9]+)%/.exec(size), - horizFirst = !!o.horizFirst, - widthFirst = ((mode == 'show') != horizFirst), - ref = widthFirst ? ['width', 'height'] : ['height', 'width'], - duration = o.duration / 2, - wrapper, distance; + $.effects.save( el, props ); + el.show(); - $.effects.save( el, props ); - el.show(); - - // Create Wrapper - wrapper = $.effects.createWrapper( el ).css({ - overflow: 'hidden' - }); - distance = widthFirst ? - [ wrapper.width(), wrapper.height() ] : - [ wrapper.height(), wrapper.width() ]; - - if ( percent ) { - size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ ( mode == 'hide') ? 0 : 1 ]; - } - mode == 'show' && wrapper.css( horizFirst ? { - height: 0, - width: size - } : { - height: size, - width: 0 - }); + // Create Wrapper + wrapper = $.effects.createWrapper( el ).css({ + overflow: "hidden" + }); + distance = widthFirst ? + [ wrapper.width(), wrapper.height() ] : + [ wrapper.height(), wrapper.width() ]; - // Animation - var animation1 = {}, animation2 = {}; - animation1[ ref[ 0 ] ] = mode == 'show' ? distance[ 0 ] : size; - animation2[ ref[ 1 ] ] = mode == 'show' ? distance[ 1 ] : 0; + if ( percent ) { + size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ]; + } + if ( show ) { + wrapper.css( horizFirst ? { + height: 0, + width: size + } : { + height: size, + width: 0 + }); + } - // Animate - wrapper - .animate( animation1, duration, o.easing ) - .animate( animation2, duration, o.easing, function() { - (mode == 'hide') && el.hide(); - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - jQuery.isFunction(o.complete) && o.complete.apply( el[ 0 ], arguments ); - el.dequeue(); - }); + // Animation + animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size; + animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0; - }); + // Animate + wrapper + .animate( animation1, duration, o.easing ) + .animate( animation2, duration, o.easing, function() { + if ( hide ) { + el.hide(); + } + $.effects.restore( el, props ); + $.effects.removeWrapper( el ); + done(); + }); }; diff --git a/ui/jquery.effects.highlight.js b/ui/jquery.effects.highlight.js index cd4f0705a..edde845a3 100644 --- a/ui/jquery.effects.highlight.js +++ b/ui/jquery.effects.highlight.js @@ -12,40 +12,38 @@ */ (function( $, undefined ) { -$.effects.effect.highlight = function( o ) { - return this.queue( function() { - var elem = $( this ), - props = [ 'backgroundImage', 'backgroundColor', 'opacity' ], - mode = $.effects.setMode( elem, o.mode || 'show' ), - animation = { - backgroundColor: elem.css( 'backgroundColor' ) - }; +$.effects.effect.highlight = function( o, done ) { + var elem = $( this ), + props = [ "backgroundImage", "backgroundColor", "opacity" ], + mode = $.effects.setMode( elem, o.mode || "show" ), + animation = { + backgroundColor: elem.css( "backgroundColor" ) + }; - if (mode == 'hide') { - animation.opacity = 0; - } + if (mode === "hide") { + animation.opacity = 0; + } - $.effects.save( elem, props ); - - elem - .show() - .css({ - backgroundImage: 'none', - backgroundColor: o.color || '#ffff99' - }) - .animate( animation, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: function() { - (mode == 'hide' && elem.hide()); - $.effects.restore( elem, props ); - (mode == 'show' && !$.support.opacity && this.style.removeAttribute( 'filter' )); - jQuery.isFunction(o.complete) && o.complete.apply(this, arguments); - elem.dequeue(); + $.effects.save( elem, props ); + + elem + .show() + .css({ + backgroundImage: "none", + backgroundColor: o.color || "#ffff99" + }) + .animate( animation, { + queue: false, + duration: o.duration, + easing: o.easing, + complete: function() { + if ( mode === "hide" ) { + elem.hide(); } - }); - }); + $.effects.restore( elem, props ); + done(); + } + }); }; })(jQuery); diff --git a/ui/jquery.effects.pulsate.js b/ui/jquery.effects.pulsate.js index a0ddf51fd..7d6e9328f 100644 --- a/ui/jquery.effects.pulsate.js +++ b/ui/jquery.effects.pulsate.js @@ -12,56 +12,51 @@ */ (function( $, undefined ) { -$.effects.effect.pulsate = function( o ) { - return this.queue( function( next ) { - var elem = $( this ), - mode = $.effects.setMode( elem, o.mode || "show" ), - show = mode === "show", - hide = mode === "hide", - showhide = ( show || mode === "hide" ), - - // showing or hiding leaves of the "last" animation - anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ), - duration = o.duration / anims, - animateTo = 0, - queue = elem.queue(), - queuelen = queue.length, - i; - - if ( show || !elem.is(':visible')) { - elem.css( "opacity", 0 ).show(); - animateTo = 1; - } - - // anims - 1 opacity "toggles" - for ( i = 1; i < anims; i++ ) { - elem.animate({ - opacity: animateTo - }, duration, o.easing ); - animateTo = 1 - animateTo; - } - +$.effects.effect.pulsate = function( o, done ) { + var elem = $( this ), + mode = $.effects.setMode( elem, o.mode || "show" ), + show = mode === "show", + hide = mode === "hide", + showhide = ( show || mode === "hide" ), + + // showing or hiding leaves of the "last" animation + anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ), + duration = o.duration / anims, + animateTo = 0, + queue = elem.queue(), + queuelen = queue.length, + i; + + if ( show || !elem.is(":visible")) { + elem.css( "opacity", 0 ).show(); + animateTo = 1; + } + + // anims - 1 opacity "toggles" + for ( i = 1; i < anims; i++ ) { elem.animate({ opacity: animateTo - }, duration, o.easing); + }, duration, o.easing ); + animateTo = 1 - animateTo; + } - elem.queue( function( next ) { - if ( hide ) { - elem.hide(); - } - if ( o.complete ) { - o.complete.apply( this ); - } - next(); - }); + elem.animate({ + opacity: animateTo + }, duration, o.easing); - // We just queued up "anims" animations, we need to put them next in the queue - if ( queuelen > 1) { - queue.splice.apply( queue, - [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); + elem.queue(function() { + if ( hide ) { + elem.hide(); } - next(); + done(); }); + + // We just queued up "anims" animations, we need to put them next in the queue + if ( queuelen > 1 ) { + queue.splice.apply( queue, + [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); + } + elem.dequeue(); }; })(jQuery); diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js index 00f0151af..000fdee28 100644 --- a/ui/jquery.effects.scale.js +++ b/ui/jquery.effects.scale.js @@ -12,250 +12,289 @@ */ (function( $, undefined ) { -$.effects.effect.puff = function( o ) { - return this.queue( function() { - var elem = $( this ), - mode = $.effects.setMode( elem, o.mode || 'hide' ), - percent = parseInt( o.percent, 10 ) || 150, - factor = percent / 100, - original = { - height: elem.height(), - width: elem.width() - }; - - $.extend(o, { - effect: 'scale', - queue: false, - fade: true, - mode: mode, - percent: mode == 'hide' ? percent : 100, - from: mode == 'hide' - ? original - : { - height: original.height * factor, - width: original.width * factor - } - }); +$.effects.effect.puff = function( o, done ) { + var elem = $( this ), + mode = $.effects.setMode( elem, o.mode || "hide" ), + hide = mode === "hide", + percent = parseInt( o.percent, 10 ) || 150, + factor = percent / 100, + original = { + height: elem.height(), + width: elem.width() + }; - elem.effect( o ); + $.extend( o, { + effect: "scale", + queue: false, + fade: true, + mode: mode, + complete: done, + percent: hide ? percent : 100, + from: hide + ? original + : { + height: original.height * factor, + width: original.width * factor + } }); + + elem.effect( o ); }; -$.effects.effect.scale = function( o ) { - - return this[ o.queue === false ? "each" : "queue" ]( function() { - - // Create element - var el = $( this ), - options = $.extend( true, {}, o ), - mode = $.effects.setMode( el, o.mode || 'effect' ), - percent = parseInt( o.percent, 10 ) || ( parseInt( o.percent, 10 ) == 0 ? 0 : ( mode == 'hide' ? 0 : 100 ) ), - direction = o.direction || 'both', - origin = o.origin, - original = { - height: el.height(), - width: el.width(), - outerHeight: el.outerHeight(), - outerWidth: el.outerWidth() - }, - factor = { - y: direction != 'horizontal' ? (percent / 100) : 1, - x: direction != 'vertical' ? (percent / 100) : 1 - }; - - // We are going to pass this effect to the size effect: - options.effect = "size"; - options.queue = false; - - // Set default origin and restore for show/hide - if ( mode != 'effect' ) { - options.origin = origin || ['middle','center']; - options.restore = true; - } +$.effects.effect.scale = function( o, done ) { - options.from = o.from || ( mode == 'show' ? { height: 0, width: 0 } : original ); - options.to = { - height: original.height * factor.y, - width: original.width * factor.x, - outerHeight: original.outerHeight * factor.y, - outerWidth: original.outerWidth * factor.x + // Create element + var el = $( this ), + options = $.extend( true, {}, o ), + mode = $.effects.setMode( el, o.mode || "effect" ), + percent = parseInt( o.percent, 10 ) || ( parseInt( o.percent, 10 ) == 0 ? 0 : ( mode == "hide" ? 0 : 100 ) ), + direction = o.direction || "both", + origin = o.origin, + original = { + height: el.height(), + width: el.width(), + outerHeight: el.outerHeight(), + outerWidth: el.outerWidth() + }, + factor = { + y: direction != "horizontal" ? (percent / 100) : 1, + x: direction != "vertical" ? (percent / 100) : 1 }; - if ( options.fade ) { // Fade option to support puff - if ( mode == 'show' ) { - options.from.opacity = 0; - options.to.opacity = 1; - } - if ( mode == 'hide' ) { - options.from.opacity = 1; - options.to.opacity = 0; - } - }; + // We are going to pass this effect to the size effect: + options.effect = "size"; + options.queue = false; + options.complete = done; + + // Set default origin and restore for show/hide + if ( mode != "effect" ) { + options.origin = origin || ["middle","center"]; + options.restore = true; + } + + options.from = o.from || ( mode == "show" ? { height: 0, width: 0 } : original ); + options.to = { + height: original.height * factor.y, + width: original.width * factor.x, + outerHeight: original.outerHeight * factor.y, + outerWidth: original.outerWidth * factor.x + }; + + if ( options.fade ) { // Fade option to support puff + if ( mode == "show" ) { + options.from.opacity = 0; + options.to.opacity = 1; + } + if ( mode == "hide" ) { + options.from.opacity = 1; + options.to.opacity = 0; + } + }; - // Animate - el.effect(options); - }); + // Animate + el.effect( options ); }; -$.effects.effect.size = function( o ) { - - return this[ o.queue === false ? "each" : "queue" ]( function() { - // Create element - var el = $( this ), - props = [ 'position', 'top', 'bottom', 'left', 'right', 'width', 'height', 'overflow', 'opacity' ], - - // Always restore - props1 = [ 'position', 'top', 'bottom', 'left', 'right', 'overflow', 'opacity' ], - - // Copy for children - props2 = [ 'width', 'height', 'overflow' ], - cProps = [ 'fontSize' ], - vProps = [ 'borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom' ], - hProps = [ 'borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight' ], +$.effects.effect.size = function( o, done ) { + + // Create element + var el = $( this ), + props = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ], + + // Always restore + props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ], + + // Copy for children + props2 = [ "width", "height", "overflow" ], + cProps = [ "fontSize" ], + vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ], + hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ], + + // Set options + mode = $.effects.setMode( el, o.mode || "effect" ), + restore = o.restore || mode !== "effect", + scale = o.scale || "both", + origin = o.origin || [ "middle", "center" ], + original, baseline, factor, + position = el.css( "position" ), + originalVerticalPositioning = el.css( "bottom" ) !== "auto" ? "bottom" : "top"; + originalHorizontalPositioning = el.css( "right" ) !== "auto" ? "right" : "left"; + + if ( mode === "show" ) { + el.show(); + } + original = { + height: el.height(), + width: el.width(), + outerHeight: el.outerHeight(), + outerWidth: el.outerWidth() + }; + + el.from = o.from || original; + el.to = o.to || original; + + // Set scaling factor + factor = { + from: { + y: el.from.height / original.height, + x: el.from.width / original.width + }, + to: { + y: el.to.height / original.height, + x: el.to.width / original.width + } + }; - // Set options - mode = $.effects.setMode( el, o.mode || 'effect' ), - restore = o.restore || false, - scale = o.scale || 'both', - origin = o.origin, - original, baseline, factor; + // Scale the css box + if ( scale == "box" || scale == "both" ) { - if ( mode === "show" ) { - el.show(); - } - original = { - height: el.height(), - width: el.width(), - outerHeight: el.outerHeight(), - outerWidth: el.outerWidth() + // Vertical props scaling + if ( factor.from.y !== factor.to.y ) { + props = props.concat( vProps ); + el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from ); + el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to ); }; - el.from = o.from || original; - el.to = o.to || original; - - // Set scaling factor - factor = { - from: { - y: el.from.height / original.height, - x: el.from.width / original.width - }, - to: { - y: el.to.height / original.height, - x: el.to.width / original.width - } + // Horizontal props scaling + if ( factor.from.x !== factor.to.x ) { + props = props.concat( hProps ); + el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from ); + el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to ); }; + }; - // Scale the css box - if ( scale == 'box' || scale == 'both' ) { + // Scale the content + if ( scale == "content" || scale == "both" ) { - // Vertical props scaling - if ( factor.from.y !== factor.to.y ) { - props = props.concat( vProps ); - el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from ); - el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to ); + // Vertical props scaling + if ( factor.from.y !== factor.to.y ) { + props = props.concat( cProps ); + el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from ); + el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to ); + }; + }; + + $.effects.save( el, restore ? props : props1 ); + el.show(); + $.effects.createWrapper( el ); + el.css( "overflow", "hidden" ).css( el.from ); + + // Adjust + if (origin) { // Calculate baseline shifts + baseline = $.effects.getBaseline( origin, original ); + el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y; + el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x; + el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y; + el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x; + } + el.css( el.from ); // set top & left + + // Animate + if ( scale == "content" || scale == "both" ) { // Scale the children + + // Add margins/font-size + vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps); + hProps = hProps.concat([ "marginLeft", "marginRight" ]); + props2 = props.concat(vProps).concat(hProps); + + el.find( "*[width]" ).each( function(){ + var child = $( this ), + c_original = { + height: child.height(), + width: child.width() + }; + if (restore) $.effects.save(child, props2); + + child.from = { + height: c_original.height * factor.from.y, + width: c_original.width * factor.from.x }; - - // Horizontal props scaling - if ( factor.from.x !== factor.to.x ) { - props = props.concat( hProps ); - el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from ); - el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to ); + child.to = { + height: c_original.height * factor.to.y, + width: c_original.width * factor.to.x }; - }; - - // Scale the content - if ( scale == 'content' || scale == 'both' ) { // Vertical props scaling - if ( factor.from.y !== factor.to.y ) { - props = props.concat( cProps ); - el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from ); - el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to ); + if ( factor.from.y != factor.to.y ) { + child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from ); + child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to ); }; - }; - - $.effects.save( el, restore ? props : props1 ); - el.show(); - $.effects.createWrapper( el ); - el.css( 'overflow', 'hidden' ).css( el.from ); - - // Adjust - if (origin) { // Calculate baseline shifts - baseline = $.effects.getBaseline( origin, original ); - el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y; - el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x; - el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y; - el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x; - } - el.css( el.from ); // set top & left - - // Animate - if ( scale == 'content' || scale == 'both' ) { // Scale the children - - // Add margins/font-size - vProps = vProps.concat([ 'marginTop', 'marginBottom' ]).concat(cProps); - hProps = hProps.concat([ 'marginLeft', 'marginRight' ]); - props2 = props.concat(vProps).concat(hProps); - - el.find( "*[width]" ).each( function(){ - var child = $( this ), - c_original = { - height: child.height(), - width: child.width() - }; - if (restore) $.effects.save(child, props2); - - child.from = { - height: c_original.height * factor.from.y, - width: c_original.width * factor.from.x - }; - child.to = { - height: c_original.height * factor.to.y, - width: c_original.width * factor.to.x - }; - // Vertical props scaling - if ( factor.from.y != factor.to.y ) { - child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from ); - child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to ); - }; - - // Horizontal props scaling - if ( factor.from.x != factor.to.x ) { - child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from ); - child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to ); - }; + // Horizontal props scaling + if ( factor.from.x != factor.to.x ) { + child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from ); + child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to ); + }; - // Animate children - child.css( child.from ); - child.animate( child.to, o.duration, o.easing, function() { + // Animate children + child.css( child.from ); + child.animate( child.to, o.duration, o.easing, function() { - // Restore children - if (restore) $.effects.restore( child, props2 ); - }); + // Restore children + if (restore) $.effects.restore( child, props2 ); }); - }; - - // Animate - el.animate( el.to, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: function() { - if ( el.to.opacity === 0 ) { - el.css( 'opacity', el.from.opacity ); - } - if( mode == 'hide' ) { - el.hide(); + }); + }; + + // Animate + el.animate( el.to, { + queue: false, + duration: o.duration, + easing: o.easing, + complete: function() { + if ( el.to.opacity === 0 ) { + el.css( "opacity", el.from.opacity ); + } + if( mode == "hide" ) { + el.hide(); + } + $.effects.restore( el, restore ? props : props1 ); + if ( !restore ) { + + // we need to calculate our new positioning based on the scaling + if ( position === "static" ) { + el.css({ + position: "relative", + top: el.to.top, + left: el.to.left + }); + } else { + $.each([ originalVerticalPositioning, originalHorizontalPositioning ], function( idx, pos ) { + el.css( pos, function( _, str ) { + var val = parseInt( str, 10 ), + toRef = idx ? el.to.left : el.to.top, + delta = idx ? el.to.outerWidth - el.from.outerWidth: el.to.outerHeight - el.from.outerHeight, + same = origin[ idx ] === pos, + mid = origin[ idx ] === "middle" || origin[ idx ] === "center", + direction = pos == "left" || pos == "top"; + + // if original was "auto", recalculate the new value from wrapper + if ( str === "auto" ) { + return toRef + "px"; + } + + // if not setting left or top + if ( !direction ) { + + // if the position is relative, bottom/right are reversed meaning + if ( position === "relative" ) { + toRef *= -1; + + // otherwise, if its NOT a midpoint origin, compensate for the outerWidth difference + } else if ( !mid ) { + toRef -= delta * ( same ? -1 : 1 ); + } + } + return val + toRef + "px"; + }); + }); } - $.effects.restore( el, restore ? props : props1 ); - $.effects.removeWrapper( el ); - $.isFunction( o.complete ) && o.complete.apply( this, arguments ); // Callback - el.dequeue(); } - }); + $.effects.removeWrapper( el ); + done(); + } }); }; diff --git a/ui/jquery.effects.shake.js b/ui/jquery.effects.shake.js index 550329ca4..7d83a9bb8 100644 --- a/ui/jquery.effects.shake.js +++ b/ui/jquery.effects.shake.js @@ -12,66 +12,62 @@ */ (function( $, undefined ) { -$.effects.effect.shake = function( o ) { +$.effects.effect.shake = function( o, done ) { - return this.queue( function() { + var el = $( this ), + props = [ "position", "top", "bottom", "left", "right", "height", "width" ], + mode = $.effects.setMode( el, o.mode || "effect" ), + direction = o.direction || "left", + distance = o.distance || 20, + times = o.times || 3, + anims = times * 2 + 1, + speed = o.duration, + ref = (direction == "up" || direction == "down") ? "top" : "left", + positiveMotion = (direction == "up" || direction == "left"), + animation = {}, + animation1 = {}, + animation2 = {}, + i, - var el = $( this ), - props = [ "position", "top", "bottom", "left", "right" ], - mode = $.effects.setMode( el, o.mode || "effect" ), - direction = o.direction || "left", - distance = o.distance || 20, - times = o.times || 3, - anims = times * 2 + 1, - speed = o.duration, - ref = (direction == "up" || direction == "down") ? "top" : "left", - motion = (direction == "up" || direction == "left") ? "pos" : "neg", - animation = {}, - animation1 = {}, - animation2 = {}, - i, + // we will need to re-assemble the queue to stack our animations in place + queue = el.queue(), + queuelen = queue.length; + - // we will need to re-assemble the queue to stack our animations in place - queue = el.queue(), - queuelen = queue.length; - + $.effects.save( el, props ); + el.show(); + $.effects.createWrapper( el ); - $.effects.save( el, props ); - el.show(); - $.effects.createWrapper( el ); + // Animation + animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance; + animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2; + animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2; - // Animation - animation[ ref ] = ( motion == "pos" ? "-=" : "+=" ) + distance; - animation1[ ref ] = ( motion == "pos" ? "+=" : "-=" ) + distance * 2; - animation2[ ref ] = ( motion == "pos" ? "-=" : "+=" ) + distance * 2; + // Animate + el.animate( animation, speed, o.easing ); - // Animate - el.animate( animation, speed, o.easing ); + // Shakes + for ( i = 1; i < times; i++ ) { + el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing ); + }; + el + .animate( animation1, speed, o.easing ) + .animate( animation, speed / 2, o.easing ) + .queue(function() { + if ( mode === "hide" ) { + el.hide(); + } + $.effects.restore( el, props ); + $.effects.removeWrapper( el ); + done(); + }); - // Shakes - for ( i = 1; i < times; i++ ) { - el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing ); - }; - el - .animate( animation1, speed, o.easing ) - .animate( animation, speed / 2, o.easing ) - .queue( function( next ) { - if ( mode === "hide" ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - $.isFunction( o.complete ) && o.complete.apply( this, arguments ); - next(); - }); - - // inject all the animations we just queued to be first in line (after "inprogress") - if ( queuelen > 1) { - queue.splice.apply( queue, - [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); - } - el.dequeue(); - }); + // inject all the animations we just queued to be first in line (after "inprogress") + if ( queuelen > 1) { + queue.splice.apply( queue, + [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) ); + } + el.dequeue(); }; diff --git a/ui/jquery.effects.slide.js b/ui/jquery.effects.slide.js index 6b0296754..de393c779 100644 --- a/ui/jquery.effects.slide.js +++ b/ui/jquery.effects.slide.js @@ -12,56 +12,54 @@ */ (function( $, undefined ) { -$.effects.effect.slide = function( o ) { +$.effects.effect.slide = function( o, done ) { - return this.queue( function() { + // Create element + var el = $( this ), + props = [ "position", "top", "bottom", "left", "right", "width", "height" ], + mode = $.effects.setMode( el, o.mode || "show" ), + show = mode === "show", + direction = o.direction || "left", + ref = (direction == "up" || direction == "down") ? "top" : "left", + positiveMotion = (direction == "up" || direction == "left"), + distance, + animation = {}, + size; - // Create element - var el = $( this ), - props = ['position','top','bottom','left','right'], - mode = $.effects.setMode( el, o.mode || 'show' ), - direction = o.direction || 'left', - ref = (direction == 'up' || direction == 'down') ? 'top' : 'left', - motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg', - distance, - animation = {}; - - // Adjust - $.effects.save( el, props ); - el.show(); - $.effects.createWrapper( el ).css({ - overflow: 'hidden' - }); - - distance = o.distance || el[ ref == 'top' ? "outerHeight" : "outerWidth" ]({ - margin: true - }); - if (mode == 'show') { - el.css( ref, motion == 'pos' ? (isNaN(distance) ? "-" + distance : -distance) : distance ); - } + // Adjust + $.effects.save( el, props ); + el.show(); + distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]({ + margin: true + }); + + $.effects.createWrapper( el ).css({ + overflow: "hidden" + }); + + if ( show ) { + el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance ); + } - // Animation - animation[ ref ] = ( mode == 'show' ? - (motion == 'pos' ? '+=' : '-=') : - (motion == 'pos' ? '-=' : '+=')) - + distance; + // Animation + animation[ ref ] = ( show ? + ( positiveMotion ? "+=" : "-=") : + ( positiveMotion ? "-=" : "+=")) + + distance; - // Animate - el.animate( animation, { - queue: false, - duration: o.duration, - easing: o.easing, - complete: function() { - if ( mode == 'hide' ) { - el.hide(); - } - $.effects.restore( el, props ); - $.effects.removeWrapper( el ); - $.isFunction(o.complete) && o.complete.apply( this, arguments ); - el.dequeue(); + // Animate + el.animate( animation, { + queue: false, + duration: o.duration, + easing: o.easing, + complete: function() { + if ( mode === "hide" ) { + el.hide(); } - }); - + $.effects.restore( el, props ); + $.effects.removeWrapper( el ); + done(); + } }); }; diff --git a/ui/jquery.effects.transfer.js b/ui/jquery.effects.transfer.js index 17d23c5fa..1fa291228 100644 --- a/ui/jquery.effects.transfer.js +++ b/ui/jquery.effects.transfer.js @@ -12,35 +12,35 @@ */ (function( $, undefined ) { -$.effects.effect.transfer = function( o ) { - - return this.queue( function() { - var elem = $( this ), - target = $( o.to ), - endPosition = target.offset(), - animation = { - top: endPosition.top, - left: endPosition.left, - height: target.innerHeight(), - width: target.innerWidth() - }, - startPosition = elem.offset(), - transfer = $( '<div class="ui-effects-transfer"></div>' ) - .appendTo( document.body ) - .addClass( o.className ) - .css({ - top: startPosition.top, - left: startPosition.left, - height: elem.innerHeight(), - width: elem.innerWidth(), - position: 'absolute' - }) - .animate( animation, o.duration, o.easing, function() { - transfer.remove(); - $.isFunction( o.complete ) && o.complete.apply(elem[0], arguments); - elem.dequeue(); - }); - }); +$.effects.effect.transfer = function( o, done ) { + var elem = $( this ), + target = $( o.to ), + targetFixed = target.css( "position" ) === "fixed", + body = $("body"), + fixTop = targetFixed ? body.scrollTop() : 0, + fixLeft = targetFixed ? body.scrollLeft() : 0, + endPosition = target.offset(), + animation = { + top: endPosition.top - fixTop , + left: endPosition.left - fixLeft , + height: target.innerHeight(), + width: target.innerWidth() + }, + startPosition = elem.offset(), + transfer = $( '<div class="ui-effects-transfer"></div>' ) + .appendTo( document.body ) + .addClass( o.className ) + .css({ + top: startPosition.top - fixTop , + left: startPosition.left - fixLeft , + height: elem.innerHeight(), + width: elem.innerWidth(), + position: targetFixed ? "fixed" : "absolute" + }) + .animate( animation, o.duration, o.easing, function() { + transfer.remove(); + done(); + }); }; })(jQuery); diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 14b67586e..c976e3e69 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -12,6 +12,8 @@ * jquery.ui.widget.js */ (function( $, undefined ) { + +var lastToggle = {}; // TODO: use ui-accordion-header-active class and fix styling $.widget( "ui.accordion", { @@ -37,8 +39,6 @@ $.widget( "ui.accordion", { var self = this, options = self.options; - self.running = false; - self.element.addClass( "ui-accordion ui-widget ui-helper-reset" ); self.headers = self.element.find( options.header ) @@ -161,6 +161,13 @@ $.widget( "ui.accordion", { return; } + if ( key === "event" ) { + if ( this.options.event ) { + this.headers.unbind( this.options.event + ".accordion", this._eventHandler ); + } + this._setupEvents( value ); + } + this._super( "_setOption", key, value ); // setting collapsible: false while collapsed; open first panel @@ -168,10 +175,6 @@ $.widget( "ui.accordion", { this._activate( 0 ); } - if ( key === "event" ) { - this._setupEvents( value ); - } - if ( key === "icons" ) { this._destroyIcons(); if ( value ) { @@ -293,7 +296,6 @@ $.widget( "ui.accordion", { }, _setupEvents: function( event ) { - this.headers.unbind( ".accordion" ); if ( event ) { this.headers.bind( event.split( " " ).join( ".accordion " ) + ".accordion", $.proxy( this, "_eventHandler" ) ); @@ -318,8 +320,6 @@ $.widget( "ui.accordion", { event.preventDefault(); if ( options.disabled || - // can't switch during an animation - this.running || // click on active header, but not collapsible ( clickedIsActive && !options.collapsible ) || // allow canceling activation @@ -360,7 +360,6 @@ $.widget( "ui.accordion", { toShow = data.newContent, toHide = data.oldContent; - self.running = true; function complete() { self._completed( data ); } @@ -381,6 +380,8 @@ $.widget( "ui.accordion", { animations[ animation ]({ toShow: toShow, toHide: toHide, + prevShow: lastToggle.toShow, + prevHide: lastToggle.toHide, complete: complete, down: toShow.length && ( !toHide.length || ( toShow.index() < toHide.index() ) ) }, additional ); @@ -411,8 +412,6 @@ $.widget( "ui.accordion", { var toShow = data.newContent, toHide = data.oldContent; - this.running = false; - if ( this.options.heightStyle === "content" ) { toShow.add( toHide ).css({ height: "", @@ -434,6 +433,11 @@ $.widget( "ui.accordion", { $.extend( $.ui.accordion, { animations: { slide: function( options, additions ) { + if ( options.prevShow || options.prevHide ) { + options.prevHide.stop( true, true ); + options.toHide = options.prevShow; + } + var showOverflow = options.toShow.css( "overflow" ), hideOverflow = options.toHide.css( "overflow" ), percentDone = 0, @@ -445,6 +449,9 @@ $.extend( $.ui.accordion, { easing: "swing", duration: 300 }, options, additions ); + + lastToggle = options; + if ( !options.toHide.size() ) { originalWidth = options.toShow[0].style.width; options.toShow @@ -501,10 +508,7 @@ $.extend( $.ui.accordion, { .filter( ":visible" ) .animate( hideProps, { step: function( now, settings ) { - // only calculate the percent when animating height - // IE gets very inconsistent results when animating elements - // with small values, which is common for padding - if ( settings.prop == "height" ) { + if ( settings.prop == "height" || settings.prop == "paddingTop" || settings.prop == "paddingBottom" ) { percentDone = ( settings.end - settings.start === 0 ) ? 0 : ( settings.now - settings.start ) / ( settings.end - settings.start ); } diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index aa42c972e..9f7f0b6e1 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -105,7 +105,8 @@ function Datepicker() { altFormat: '', // The date format to use for the alternate field constrainInput: true, // The input is constrained by the current date format showButtonPanel: false, // True to show button panel, false to not show it - autoSize: false // True to size the input for the date format, false to leave as is + autoSize: false, // True to size the input for the date format, false to leave as is + disabled: false // The initial disabled state }; $.extend(this._defaults, this.regional['']); this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')); @@ -114,6 +115,9 @@ function Datepicker() { $.extend(Datepicker.prototype, { /* Class name added to elements to indicate already configured with a date picker. */ markerClassName: 'hasDatepicker', + + //Keep track of the maximum number of rows displayed (see #7043) + maxRows: 4, /* Debug logging (if enabled). */ log: function () { @@ -194,6 +198,10 @@ $.extend(Datepicker.prototype, { }); this._autoSize(inst); $.data(target, PROP_NAME, inst); + //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665) + if( inst.settings.disabled ) { + this._disableDatepicker( target ); + } }, /* Make attachments based on settings. */ @@ -273,7 +281,13 @@ $.extend(Datepicker.prototype, { this._setDate(inst, this._getDefaultDate(inst), true); this._updateDatepicker(inst); this._updateAlternate(inst); - inst.dpDiv.show(); + //If disabled option is true, disable the datepicker before showing it (see ticket #5665) + if( inst.settings.disabled ) { + this._disableDatepicker( target ); + } + // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements + // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height + inst.dpDiv.css( "display", "block" ); }, /* Pop-up the date picker in a "dialog" box. @@ -517,6 +531,13 @@ $.extend(Datepicker.prototype, { $.datepicker._currentClass + ')', inst.dpDiv); if (sel[0]) $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]); + var onSelect = $.datepicker._get(inst, 'onSelect'); + if (onSelect) { + var dateStr = $.datepicker._formatDate(inst); + + // trigger custom callback + onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); + } else $.datepicker._hideDatepicker(); return false; // don't submit the form @@ -682,6 +703,7 @@ $.extend(Datepicker.prototype, { /* Generate the date picker content. */ _updateDatepicker: function(inst) { var self = this; + self.maxRows = 4; //Reset the max number of rows being displayed (see #7043) var borders = $.datepicker._getBorders(inst.dpDiv); instActive = inst; // for delegate hover events inst.dpDiv.empty().append(this._generateHTML(inst)); @@ -919,8 +941,7 @@ $.extend(Datepicker.prototype, { else { this._hideDatepicker(); this._lastInput = inst.input[0]; - if (typeof(inst.input[0]) != 'object') - inst.input.focus(); // restore focus + inst.input.focus(); // restore focus this._lastInput = null; } }, @@ -1083,7 +1104,10 @@ $.extend(Datepicker.prototype, { } } if (iValue < value.length){ - throw "Extra/unparsed characters found in date: " + value.substring(iValue); + var extra = value.substr(iValue); + if (!/^\s+/.test(extra)) { + throw "Extra/unparsed characters found in date: " + extra; + } } if (year == -1) year = new Date().getFullYear(); @@ -1380,6 +1404,14 @@ $.extend(Datepicker.prototype, { if (inst.input) { inst.input.val(clear ? '' : this._formatDate(inst)); } + + var onSelect = this._get(inst, 'onSelect'); + if (onSelect) { + var dateStr = this._formatDate(inst); + + // trigger custom callback + onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); + } }, /* Retrieve the date(s) directly. */ @@ -1471,6 +1503,7 @@ $.extend(Datepicker.prototype, { var html = ''; for (var row = 0; row < numMonths[0]; row++) { var group = ''; + this.maxRows = 4; for (var col = 0; col < numMonths[1]; col++) { var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay)); var cornerClass = ' ui-corner-all'; @@ -1505,7 +1538,9 @@ $.extend(Datepicker.prototype, { if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth) inst.selectedDay = Math.min(inst.selectedDay, daysInMonth); var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7; - var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7)); // calculate the number of rows to generate + var curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate + var numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043) + this.maxRows = numRows; var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays)); for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows calender += '<tr>'; diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 89ccdf734..493ed07e6 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -108,7 +108,8 @@ $.widget("ui.dialog", { }) .mousedown(function( event ) { self.moveToTop( false, event ); - }), + }) + .appendTo( "body" ), uiDialogContent = self.element .show() @@ -155,8 +156,6 @@ $.widget("ui.dialog", { self._createButtons( options.buttons ); self._isOpen = false; - uiDialog.appendTo( document.body ); - if ( $.fn.bgiframe ) { uiDialog.bgiframe(); } diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index aa01e91b9..61efae7aa 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -1,6 +1,6 @@ /* * jQuery UI Menu @VERSION - * + * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license @@ -12,10 +12,10 @@ * jquery.ui.widget.js */ (function($) { - + var idIncrement = 0; -$.widget("ui.menu", { +$.widget( "ui.menu", { version: "@VERSION", defaultElement: "<ul>", delay: 150, @@ -29,8 +29,8 @@ $.widget("ui.menu", { var self = this; this.activeMenu = this.element; this.menuId = this.element.attr( "id" ) || "ui-menu-" + idIncrement++; - if (this.element.find(".ui-icon").length) { - this.element.addClass("ui-menu-icons"); + if ( this.element.find( ".ui-icon" ).length ) { + this.element.addClass( "ui-menu-icons" ); } this.element .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) @@ -58,10 +58,12 @@ $.widget("ui.menu", { } var target = $( event.target ).closest( ".ui-menu-item" ); if ( target.length ) { + //Remove ui-state-active class from siblings of the newly focused menu item to avoid a jump caused by adjacent elements both having a class with a border + target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" ); self.focus( event, target ); } }) - .bind("mouseout.menu", function( event ) { + .bind( "mouseout.menu", function( event ) { if ( self.options.disabled ) { return; } @@ -71,7 +73,7 @@ $.widget("ui.menu", { } }); this.refresh(); - + this.element.attr( "tabIndex", 0 ).bind( "keydown.menu", function( event ) { if ( self.options.disabled ) { return; @@ -98,20 +100,20 @@ $.widget("ui.menu", { event.stopImmediatePropagation(); break; case $.ui.keyCode.LEFT: - if (self.left( event )) { + if (self.collapse( event )) { event.stopImmediatePropagation(); } event.preventDefault(); break; case $.ui.keyCode.RIGHT: - if (self.right( event )) { + if (self.expand( event )) { event.stopImmediatePropagation(); } event.preventDefault(); break; case $.ui.keyCode.ENTER: - if (self.active.children("a[aria-haspopup='true']").length) { - if (self.right( event )) { + if ( self.active.children( "a[aria-haspopup='true']" ).length ) { + if ( self.expand( event ) ) { event.stopImmediatePropagation(); } } @@ -122,42 +124,46 @@ $.widget("ui.menu", { event.preventDefault(); break; case $.ui.keyCode.ESCAPE: - if ( self.left( event ) ) { + if ( self.collapse( event ) ) { event.stopImmediatePropagation(); } event.preventDefault(); break; default: event.stopPropagation(); - clearTimeout(self.filterTimer); - var prev = self.previousFilter || ""; - var character = String.fromCharCode(event.keyCode); - var skip = false; + clearTimeout( self.filterTimer ); + var match, + prev = self.previousFilter || "", + character = String.fromCharCode( event.keyCode ), + skip = false; + if (character == prev) { skip = true; } else { character = prev + character; } - function escape(value) { - return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); + function escape( value ) { + return value.replace( /[-[\]{}()*+?.,\\^$|#\s]/g , "\\$&" ); } - var match = self.activeMenu.children(".ui-menu-item").filter(function() { - return new RegExp("^" + escape(character), "i").test($(this).children("a").text()); + match = self.activeMenu.children( ".ui-menu-item" ).filter( function() { + return new RegExp("^" + escape(character), "i") + .test( $( this ).children( "a" ).text() ); }); - var match = skip && match.index(self.active.next()) != -1 ? self.active.nextAll(".ui-menu-item") : match; - if (!match.length) { + match = skip && match.index(self.active.next()) != -1 ? self.active.nextAll(".ui-menu-item") : match; + if ( !match.length ) { character = String.fromCharCode(event.keyCode); - match = self.activeMenu.children(".ui-menu-item").filter(function() { - return new RegExp("^" + escape(character), "i").test($(this).children("a").text()); + match = self.activeMenu.children(".ui-menu-item").filter( function() { + return new RegExp("^" + escape(character), "i") + .test( $( this ).children( "a" ).text() ); }); } - if (match.length) { - self.focus(event, match); + if ( match.length ) { + self.focus( event, match ); if (match.length > 1) { self.previousFilter = character; - self.filterTimer = setTimeout(function() { + self.filterTimer = setTimeout( function() { delete self.previousFilter; - }, 1000); + }, 1000 ); } else { delete self.previousFilter; } @@ -166,22 +172,30 @@ $.widget("ui.menu", { } } }); + + this._bind( document, { + click: function( event ) { + if ( !$( event.target ).closest( ".ui-menu" ).length ) { + this.collapseAll( event ); + } + } + }); }, - + _destroy: function() { //destroy (sub)menus this.element .removeAttr( "aria-activedescendant" ) - .find("ul") + .find( "ul" ) .andSelf() .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) .removeAttr( "role" ) - .removeAttr("tabIndex") + .removeAttr( "tabIndex" ) .removeAttr( "aria-labelledby" ) .removeAttr( "aria-expanded" ) .removeAttr( "aria-hidden" ) .show(); - + //destroy menu items this.element.find( ".ui-menu-item" ) .unbind( ".menu" ) @@ -193,144 +207,185 @@ $.widget("ui.menu", { .removeAttr( "role" ) .removeAttr( "aria-haspopup" ) .removeAttr( "id" ) - .children(".ui-icon").remove(); + .children( ".ui-icon" ) + .remove(); }, - + refresh: function() { - var self = this; - // initialize nested menus - var submenus = this.element.find("ul:not(.ui-menu)") - .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) - .attr("role", "menu") - .hide() - .attr({ - "aria-hidden": "true", - "aria-expanded": "false" - }); - + var self = this, + + // initialize nested menus + submenus = this.element.find( "ul:not(.ui-menu)" ) + .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) + .attr( "role", "menu" ) + .hide() + .attr( "aria-hidden", "true" ) + .attr( "aria-expanded", "false" ), + // don't refresh list items that are already adapted - var items = submenus.add(this.element).children( "li:not(.ui-menu-item):has(a)" ) - .addClass( "ui-menu-item" ) - .attr( "role", "presentation" ); - + items = submenus.add( this.element ).children( "li:not(.ui-menu-item):has(a)" ) + .addClass( "ui-menu-item" ) + .attr( "role", "presentation" ); + items.children( "a" ) .addClass( "ui-corner-all" ) .attr( "tabIndex", -1 ) .attr( "role", "menuitem" ) - .attr("id", function(i) {return self.element.attr("id") + "-" + i}); - - submenus.each(function() { - var menu = $(this); - var item = menu.prev("a") - item.attr("aria-haspopup", "true") - .prepend('<span class="ui-menu-icon ui-icon ui-icon-carat-1-e"></span>'); - menu.attr("aria-labelledby", item.attr("id")); + .attr( "id", function( i ) { + return self.element.attr( "id" ) + "-" + i; + }); + + submenus.each( function() { + var menu = $( this ), + item = menu.prev( "a" ); + + item.attr( "aria-haspopup", "true" ) + .prepend( '<span class="ui-menu-icon ui-icon ui-icon-carat-1-e"></span>' ); + menu.attr( "aria-labelledby", item.attr( "id" ) ); }); }, focus: function( event, item ) { - var self = this; - - this.blur(); - + var nested, + self = this; + + this.blur( event ); + if ( this._hasScroll() ) { - var borderTop = parseFloat( $.curCSS( this.element[0], "borderTopWidth", true) ) || 0, - paddingTop = parseFloat( $.curCSS( this.element[0], "paddingTop", true) ) || 0, + var borderTop = parseFloat( $.curCSS( this.element[0], "borderTopWidth", true ) ) || 0, + paddingTop = parseFloat( $.curCSS( this.element[0], "paddingTop", true ) ) || 0, offset = item.offset().top - this.element.offset().top - borderTop - paddingTop, scroll = this.element.scrollTop(), elementHeight = this.element.height(), itemHeight = item.height(); + if ( offset < 0 ) { this.element.scrollTop( scroll + offset ); } else if ( offset + itemHeight > elementHeight ) { this.element.scrollTop( scroll + offset - elementHeight + itemHeight ); } } - + this.active = item.first() .children( "a" ) .addClass( "ui-state-focus" ) .end(); - self.element.attr("aria-activedescendant", self.active.children("a").attr("id")) + self.element.attr( "aria-activedescendant", self.active.children("a").attr("id") ); // highlight active parent menu item, if any this.active.parent().closest(".ui-menu-item").children("a:first").addClass("ui-state-active"); - - self.timer = setTimeout(function() { + + self.timer = setTimeout( function() { self._close(); - }, self.delay) - var nested = $(">ul", item); - if (nested.length && /^mouse/.test(event.type)) { + }, self.delay ); + + nested = $( ">ul", item ); + if ( nested.length && ( /^mouse/.test( event.type ) ) ) { self._startOpening(nested); } this.activeMenu = item.parent(); - + this._trigger( "focus", event, { item: item } ); }, - blur: function(event) { - if (!this.active) { + blur: function( event ) { + if ( !this.active ) { return; } - - clearTimeout(this.timer); - + + clearTimeout( this.timer ); + this.active.children( "a" ).removeClass( "ui-state-focus" ); this.active = null; + + this._trigger( "blur", event, { item: this.active } ); }, - _startOpening: function(submenu) { - clearTimeout(this.timer); + _startOpening: function( submenu ) { + clearTimeout( this.timer ); + + // Don't open if already open fixes a Firefox bug that caused a .5 pixel + // shift in the submenu position when mousing over the carat icon + if ( submenu.attr( "aria-hidden" ) !== "true" ) { + return; + } + var self = this; - self.timer = setTimeout(function() { + self.timer = setTimeout( function() { self._close(); - self._open(submenu); - }, self.delay); + self._open( submenu ); + }, self.delay ); }, - - _open: function(submenu) { - clearTimeout(this.timer); - this.element.find(".ui-menu").not(submenu.parents()).hide().attr("aria-hidden", "true"); + + _open: function( submenu ) { + clearTimeout( this.timer ); + this.element + .find( ".ui-menu" ) + .not( submenu.parents() ) + .hide() + .attr( "aria-hidden", "true" ); + var position = $.extend({}, { - of: this.active - }, $.type(this.options.position) == "function" - ? this.options.position(this.active) - : this.options.position - ); - submenu.show().removeAttr("aria-hidden").attr("aria-expanded", "true").position(position); + of: this.active + }, $.type(this.options.position) == "function" + ? this.options.position(this.active) + : this.options.position + ); + + submenu.show() + .removeAttr( "aria-hidden" ) + .attr( "aria-expanded", "true" ) + .position( position ); }, - - closeAll: function() { + + collapseAll: function( event ) { this.element - .find("ul").hide().attr("aria-hidden", "true").attr("aria-expanded", "false").end() - .find("a.ui-state-active").removeClass("ui-state-active"); - this.blur(); + .find( "ul" ) + .hide() + .attr( "aria-hidden", "true" ) + .attr( "aria-expanded", "false" ) + .end() + .find( "a.ui-state-active" ) + .removeClass( "ui-state-active" ); + + this.blur( event ); this.activeMenu = this.element; }, - + _close: function() { this.active.parent() - .find("ul").hide().attr("aria-hidden", "true").attr("aria-expanded", "false").end() - .find("a.ui-state-active").removeClass("ui-state-active"); + .find( "ul" ) + .hide() + .attr( "aria-hidden", "true" ) + .attr( "aria-expanded", "false" ) + .end() + .find( "a.ui-state-active" ) + .removeClass( "ui-state-active" ); }, - left: function(event) { + collapse: function( event ) { var newItem = this.active && this.active.parents("li:not(.ui-menubar-item)").first(); - if (newItem && newItem.length) { - this.active.parent().attr("aria-hidden", "true").attr("aria-expanded", "false").hide(); - this.focus(event, newItem); + if ( newItem && newItem.length ) { + this.active.parent() + .attr("aria-hidden", "true") + .attr("aria-expanded", "false") + .hide(); + this.focus( event, newItem ); return true; } }, - right: function(event) { - var self= this; - var newItem = this.active && this.active.children("ul").children("li").first(); - if (newItem && newItem.length) { - this._open(newItem.parent()); - var current = this.active; + expand: function( event ) { + var self = this, + newItem = this.active && this.active.children("ul").children("li").first(); + + if ( newItem && newItem.length ) { + this._open( newItem.parent() ); + //timeout so Firefox will not hide activedescendant change in expanding submenu from AT - setTimeout(function(){self.focus(event, newItem)}, 20); + setTimeout( function() { + self.focus( event, newItem ); + }, 20 ); return true; } }, @@ -351,19 +406,19 @@ $.widget("ui.menu", { return this.active && !this.active.nextAll( ".ui-menu-item" ).length; }, - _move: function(direction, edge, filter, event) { + _move: function( direction, edge, filter, event ) { if ( !this.active ) { - this.focus( event, this.activeMenu.children(edge)[filter]() ); + this.focus( event, this.activeMenu.children( edge )[ filter ]() ); return; } var next = this.active[ direction + "All" ]( ".ui-menu-item" ).eq( 0 ); if ( next.length ) { this.focus( event, next ); } else { - this.focus( event, this.activeMenu.children(edge)[filter]() ); + this.focus( event, this.activeMenu.children( edge )[ filter ]() ); } }, - + nextPage: function( event ) { if ( this._hasScroll() ) { if ( !this.active || this.last() ) { @@ -412,11 +467,11 @@ $.widget("ui.menu", { }, select: function( event ) { - // save active reference before closeAll triggers blur + // save active reference before collapseAll triggers blur var ui = { item: this.active }; - this.closeAll(); + this.collapseAll( event ); this._trigger( "select", event, ui ); } }); diff --git a/ui/jquery.ui.menubar.js b/ui/jquery.ui.menubar.js index 0f80f4fda..9af3aa080 100644 --- a/ui/jquery.ui.menubar.js +++ b/ui/jquery.ui.menubar.js @@ -20,8 +20,13 @@ $.widget( "ui.menubar", { version: "@VERSION", options: { + autoExpand: false, buttons: false, - menuIcon: false + menuIcon: false, + position: { + my: "left top", + at: "left bottom" + } }, _create: function() { var that = this; @@ -39,12 +44,15 @@ $.widget( "ui.menubar", { this._hoverable( items ); items.next( "ul" ) .menu({ + position: { + within: this.options.position.within + }, select: function( event, ui ) { ui.item.parents( "ul.ui-menu:last" ).hide(); - that._trigger( "select", event, ui ); that._close(); // TODO what is this targetting? there's probably a better way to access it $(event.target).prev().focus(); + that._trigger( "select", event, ui ); } }) .hide() @@ -84,7 +92,11 @@ $.widget( "ui.menubar", { that._close(); return; } - if ( ( that.open && event.type == "mouseenter" ) || event.type == "click" ) { + if ( ( that.open && event.type == "mouseenter" ) || event.type == "click" || that.options.autoExpand ) { + if( that.options.autoExpand ) { + clearTimeout( that.timer ); + } + that._open( event, menu ); } }) @@ -111,6 +123,22 @@ $.widget( "ui.menubar", { .attr( "aria-haspopup", "true" ) .wrapInner( "<span class='ui-button-text'></span>" ); + if ( that.options.autoExpand ) { + input.bind( "mouseleave.menubar", function( event ) { + that.timer = setTimeout( function() { + that._close(); + }, 150 ); + }); + menu.bind( "mouseleave.menubar", function( event ) { + that.timer = setTimeout( function() { + that._close(); + }, 150 ); + }) + .bind( "mouseenter.menubar", function( event ) { + clearTimeout( that.timer ); + }); + } + // TODO review if these options are a good choice, maybe they can be merged if ( that.options.menuIcon ) { input.addClass( "ui-state-default" ).append( "<span class='ui-button-icon-secondary ui-icon ui-icon-triangle-1-s'></span>" ); @@ -121,11 +149,11 @@ $.widget( "ui.menubar", { // TODO ui-menubar-link is added above, not needed here? input.addClass( "ui-menubar-link" ).removeClass( "ui-state-default" ); }; - + }); that._bind( { keydown: function( event ) { - if ( event.keyCode == $.ui.keyCode.ESCAPE && that.active && that.active.menu( "left", event ) !== true ) { + if ( event.keyCode == $.ui.keyCode.ESCAPE && that.active && that.active.menu( "collapse", event ) !== true ) { var active = that.active; that.active.blur(); that._close( event ); @@ -180,7 +208,7 @@ $.widget( "ui.menubar", { if ( !this.active || !this.active.length ) return; this.active - .menu( "closeAll" ) + .menu( "collapseAll" ) .hide() .attr({ "aria-hidden": "true", @@ -202,7 +230,7 @@ $.widget( "ui.menubar", { // TODO refactor, almost the same as _close above, but don't remove tabIndex if ( this.active ) { this.active - .menu( "closeAll" ) + .menu( "collapseAll" ) .hide() .attr({ "aria-hidden": "true", @@ -216,11 +244,9 @@ $.widget( "ui.menubar", { var button = menu.prev().addClass( "ui-state-active" ).attr( "tabIndex", -1 ); this.active = menu .show() - .position( { - my: "left top", - at: "left bottom", + .position( $.extend({ of: button - }) + }, this.options.position ) ) .removeAttr( "aria-hidden" ) .attr( "aria-expanded", "true" ) .menu("focus", event, menu.children( "li" ).first() ) diff --git a/ui/jquery.ui.popup.js b/ui/jquery.ui.popup.js index b506a641f..508209a55 100644 --- a/ui/jquery.ui.popup.js +++ b/ui/jquery.ui.popup.js @@ -13,7 +13,7 @@ * jquery.ui.position.js */ (function($) { - + var idIncrement = 0; $.widget( "ui.popup", { @@ -28,34 +28,34 @@ $.widget( "ui.popup", { if ( !this.options.trigger ) { this.options.trigger = this.element.prev(); } - + if ( !this.element.attr( "id" ) ) { this.element.attr( "id", "ui-popup-" + idIncrement++ ); this.generatedId = true; } - + if ( !this.element.attr( "role" ) ) { // TODO alternatives to tooltip are dialog and menu, all three aren't generic popups - this.element.attr( "role", "tooltip" ); + this.element.attr( "role", "dialog" ); this.generatedRole = true; } - + this.options.trigger .attr( "aria-haspopup", "true" ) .attr( "aria-owns", this.element.attr( "id" ) ); - + this.element - .addClass("ui-popup") + .addClass( "ui-popup" ) this.close(); this._bind(this.options.trigger, { keydown: function( event ) { - // prevent space-to-open to scroll the page, only hapens for anchor ui.button - if ( this.options.trigger.is( "a:ui-button" ) && event.keyCode == $.ui.keyCode.SPACE) { - event.preventDefault() + // prevent space-to-open to scroll the page, only happens for anchor ui.button + if ( this.options.trigger.is( "a:ui-button" ) && event.keyCode == $.ui.keyCode.SPACE ) { + event.preventDefault(); } // TODO handle SPACE to open popup? only when not handled by ui.button - if ( event.keyCode == $.ui.keyCode.SPACE && this.options.trigger.is("a:not(:ui-button)") ) { + if ( event.keyCode == $.ui.keyCode.SPACE && this.options.trigger.is( "a:not(:ui-button)" ) ) { this.options.trigger.trigger( "click", event ); } // translate keydown to click @@ -79,52 +79,75 @@ $.widget( "ui.popup", { }, 1); } }); - - this._bind(this.element, { - // TODO use focusout so that element itself doesn't need to be focussable - blur: function( event ) { + + if ( !this.element.is( ":ui-menu" ) ) { + //default use case, wrap tab order in popup + this._bind({ keydown : function( event ) { + if ( event.keyCode !== $.ui.keyCode.TAB ) { + return; + } + var tabbables = $( ":tabbable", this.element ), + first = tabbables.first(), + last = tabbables.last(); + if ( event.target === last[ 0 ] && !event.shiftKey ) { + first.focus( 1 ); + event.preventDefault(); + } else if ( event.target === first[ 0 ] && event.shiftKey ) { + last.focus( 1 ); + event.preventDefault(); + } + } + }); + } + + this._bind({ + focusout: function( event ) { var that = this; // use a timer to allow click to clear it and letting that // handle the closing instead of opening again that.closeTimer = setTimeout( function() { that.close( event ); }, 100); + }, + focusin: function( event ) { + clearTimeout( this.closeTimer ); } }); this._bind({ - // TODO only triggerd on element if it can receive focus + // TODO only triggered on element if it can receive focus // bind to document instead? // either element itself or a child should be focusable keyup: function( event ) { - if (event.keyCode == $.ui.keyCode.ESCAPE && this.element.is( ":visible" )) { + if ( event.keyCode == $.ui.keyCode.ESCAPE && this.element.is( ":visible" ) ) { this.close( event ); // TODO move this to close()? would allow menu.select to call popup.close, and get focus back to trigger this.options.trigger.focus(); } } }); - + this._bind(document, { click: function( event ) { - if (this.isOpen && !$(event.target).closest(".ui-popup").length) { + if ( this.isOpen && !$(event.target).closest(".ui-popup").length ) { this.close( event ); } } }) }, - + _destroy: function() { this.element .show() .removeClass( "ui-popup" ) .removeAttr( "aria-hidden" ) - .removeAttr( "aria-expanded" ); + .removeAttr( "aria-expanded" ) + .unbind( "keypress.ui-popup"); this.options.trigger .removeAttr( "aria-haspopup" ) .removeAttr( "aria-owns" ); - + if ( this.generatedId ) { this.element.removeAttr( "id" ); } @@ -132,7 +155,7 @@ $.widget( "ui.popup", { this.element.removeAttr( "role" ); } }, - + open: function( event ) { var position = $.extend( {}, { of: this.options.trigger @@ -142,17 +165,28 @@ $.widget( "ui.popup", { .show() .attr( "aria-hidden", "false" ) .attr( "aria-expanded", "true" ) - .position( position ) - // TODO find a focussable child, otherwise put focus on element, add tabIndex=0 if not focussable - .focus(); + .position( position ); - if (this.element.is(":ui-menu")) { - this.element.menu("focus", event, this.element.children( "li" ).first() ); + if (this.element.is( ":ui-menu" )) { //popup is a menu + this.element.menu( "focus", event, this.element.children( "li" ).first() ); + this.element.focus(); + } else { + // set focus to the first tabbable element in the popup container + // if there are no tabbable elements, set focus on the popup itself + var tabbables = this.element.find( ":tabbable" ); + this.removeTabIndex = false; + if ( !tabbables.length ) { + if ( !this.element.is(":tabbable") ) { + this.element.attr("tabindex", "0"); + this.removeTabIndex = true; + } + tabbables = tabbables.add( this.element[ 0 ] ); + } + tabbables.first().focus( 1 ); } // take trigger out of tab order to allow shift-tab to skip trigger - this.options.trigger.attr("tabindex", -1); - + this.options.trigger.attr( "tabindex", -1 ); this.isOpen = true; this._trigger( "open", event ); }, @@ -163,13 +197,13 @@ $.widget( "ui.popup", { .attr( "aria-hidden", "true" ) .attr( "aria-expanded", "false" ); - this.options.trigger.attr("tabindex", 0); - + this.options.trigger.attr( "tabindex" , 0 ); + if ( this.removeTabIndex ) { + this.element.removeAttr( "tabindex" ); + } this.isOpen = false; this._trigger( "close", event ); } - - }); }(jQuery)); diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index 98b8198e2..23a98b491 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -19,6 +19,39 @@ var rhorizontal = /left|center|right/, center = "center", _position = $.fn.position; +$.position = { + scrollbarWidth: function() { + var w1, w2, + div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ), + innerDiv = div.children()[0]; + + $( "body" ).append( div ); + w1 = innerDiv.offsetWidth; + div.css( "overflow", "scroll" ); + + w2 = innerDiv.offsetWidth; + + if ( w1 === w2 ) { + w2 = div[0].clientWidth; + } + + div.remove(); + + return w1 - w2; + }, + getScrollInfo: function( within ) { + var that = within[0], + scrollHeight = within.height() < that.scrollHeight, + scrollWidth = within.width() < that.scrollWidth, + scrollbarWidth = $.position.scrollbarWidth(); + + return { + height: scrollHeight ? scrollbarWidth : 0, + width : scrollWidth ? scrollbarWidth : 0 + }; + } +}; + $.fn.position = function( options ) { if ( !options || !options.of ) { return _position.apply( this, arguments ); @@ -28,6 +61,7 @@ $.fn.position = function( options ) { options = $.extend( {}, options ); var target = $( options.of ), + within = $( options.within || window ), targetElem = target[0], collision = ( options.collision || "flip" ).split( " " ), offsets = {}, @@ -56,7 +90,7 @@ $.fn.position = function( options ) { } // force my and at to have valid horizontal and vertical positions - // if a value is missing or invalid, it will be converted to center + // if a value is missing or invalid, it will be converted to center $.each( [ "my", "at" ], function() { var pos = ( options[ this ] || "" ).split( " " ), horizontalOffset, @@ -110,7 +144,7 @@ $.fn.position = function( options ) { parseInt( offsets.at[ 1 ], 10 ) * ( rpercent.test( offsets.at[ 1 ] ) ? targetHeight / 100 : 1 ) ]; - basePosition.left += atOffset[ 0 ], + basePosition.left += atOffset[ 0 ]; basePosition.top += atOffset[ 1 ]; return this.each(function() { @@ -119,10 +153,11 @@ $.fn.position = function( options ) { elemHeight = elem.outerHeight(), marginLeft = parseInt( $.curCSS( this, "marginLeft", true ) ) || 0, marginTop = parseInt( $.curCSS( this, "marginTop", true ) ) || 0, + scrollInfo = $.position.getScrollInfo( within ), collisionWidth = elemWidth + marginLeft + - ( parseInt( $.curCSS( this, "marginRight", true ) ) || 0 ), + ( parseInt( $.curCSS( this, "marginRight", true ) ) || 0 ) + scrollInfo.width, collisionHeight = elemHeight + marginTop + - ( parseInt( $.curCSS( this, "marginBottom", true ) ) || 0 ), + ( parseInt( $.curCSS( this, "marginBottom", true ) ) || 0 ) + scrollInfo.height, position = $.extend( {}, basePosition ), myOffset = [ parseInt( offsets.my[ 0 ], 10 ) * @@ -168,7 +203,9 @@ $.fn.position = function( options ) { collisionHeight: collisionHeight, offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ], my: options.my, - at: options.at + at: options.at, + within: within, + elem : elem }); } }); @@ -183,32 +220,40 @@ $.fn.position = function( options ) { $.ui.position = { fit: { left: function( position, data ) { - var win = $( window ), - overLeft = win.scrollLeft() - data.collisionPosition.left, - overRight = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(); + var within = data.within, + win = $( window ), + isWindow = $.isWindow( data.within[0] ), + withinOffset = isWindow ? win.scrollLeft() : within.offset().left, + outerWidth = isWindow ? win.width() : within.outerWidth(), + overLeft = withinOffset - data.collisionPosition.left, + overRight = data.collisionPosition.left + data.collisionWidth - outerWidth - withinOffset; // element is wider than window or too far left -> align with left edge - if ( data.collisionWidth > win.width() || overLeft > 0 ) { - position.left = position.left + overLeft; + if ( data.collisionWidth > outerWidth || overLeft > 0 ) { + position.left += overLeft; // too far right -> align with right edge } else if ( overRight > 0 ) { - position.left = position.left - overRight; + position.left -= overRight; // adjust based on position and margin } else { position.left = Math.max( position.left - data.collisionPosition.left, position.left ); } }, top: function( position, data ) { - var win = $( window ), - overTop = win.scrollTop() - data.collisionPosition.top, - overBottom = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(); + var within = data.within, + win = $( window ), + isWindow = $.isWindow( data.within[0] ), + withinOffset = isWindow ? win.scrollTop() : within.offset().top, + outerHeight = isWindow ? win.height() : within.outerHeight(), + overTop = withinOffset - data.collisionPosition.top, + overBottom = data.collisionPosition.top + data.collisionHeight - outerHeight - withinOffset; // element is taller than window or too far up -> align with top edge - if ( data.collisionHeight > win.height() || overTop > 0 ) { - position.top = position.top + overTop; + if ( data.collisionHeight > outerHeight || overTop > 0 ) { + position.top += overTop; // too far down -> align with bottom edge } else if ( overBottom > 0 ) { - position.top = position.top - overBottom; + position.top -= overBottom; // adjust based on position and margin } else { position.top = Math.max( position.top - data.collisionPosition.top, position.top ); @@ -220,8 +265,18 @@ $.ui.position = { if ( data.at[ 0 ] === center ) { return; } - var win = $( window ), - over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(), + + data.elem + .removeClass( "ui-flipped-left ui-flipped-right" ); + + var within = data.within, + win = $( window ), + isWindow = $.isWindow( data.within[0] ), + withinOffset = isWindow ? 0 : within.offset().left, + outerWidth = isWindow ? within.width() : within.outerWidth(), + overLeft = data.collisionPosition.left - withinOffset, + overRight = data.collisionPosition.left + data.collisionWidth - outerWidth - withinOffset, + left = data.my[ 0 ] === "left", myOffset = data.my[ 0 ] === "left" ? -data.elemWidth : data.my[ 0 ] === "right" ? @@ -231,19 +286,31 @@ $.ui.position = { data.targetWidth : -data.targetWidth, offset = -2 * data.offset[ 0 ]; - position.left += data.collisionPosition.left < 0 ? - myOffset + atOffset + offset : - over > 0 ? - myOffset + atOffset + offset : - 0; + if ( overLeft < 0 || overRight > 0 ) { + + data.elem + .addClass( "ui-flipped-" + ( overLeft < 0 ? "right" : "left" ) ); + + position.left += myOffset + atOffset + offset; + } }, top: function( position, data ) { if ( data.at[ 1 ] === center ) { return; } - var win = $( window ), - over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(), - myOffset = data.my[ 1 ] === "top" ? + + data.elem + .removeClass( "ui-flipped-top ui-flipped-bottom" ); + + var within = data.within, + win = $( window ), + isWindow = $.isWindow( data.within[0] ), + withinOffset = isWindow ? 0 : within.offset().top, + outerHeight = isWindow ? within.height() : within.outerHeight(), + overTop = data.collisionPosition.top - withinOffset, + overBottom = data.collisionPosition.top + data.collisionHeight - outerHeight - withinOffset, + top = data.my[ 1 ] === "top", + myOffset = top ? -data.elemHeight : data.my[ 1 ] === "bottom" ? data.elemHeight : @@ -252,11 +319,13 @@ $.ui.position = { data.targetHeight : -data.targetHeight, offset = -2 * data.offset[ 1 ]; - position.top += data.collisionPosition.top < 0 ? - myOffset + atOffset + offset : - over > 0 ? - myOffset + atOffset + offset : - 0; + if ( overTop < 0 || overBottom > 0 ) { + + data.elem + .addClass( "ui-flipped-" + ( overTop < 0 ? "bottom" : "top" ) ); + + position.top += myOffset + atOffset + offset; + } } } }; @@ -267,7 +336,7 @@ if ( $.uiBackCompat !== false ) { (function( $ ) { var _position = $.fn.position; $.fn.position = function( options ) { - if ( !options || !( "offset" in options ) ) { + if ( !options || !options.offset ) { return _position.call( this, options ); } var offset = options.offset.split( " " ), diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index 87da9ac05..b03c59709 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -258,12 +258,29 @@ $.widget( "ui.spinner", { : 2 : 1); + // clamp the new value + newVal = this._trimValue( newVal ); + if ( this._trigger( "spin", event, { value: newVal } ) !== false) { this.value( newVal ); this.counter++; } }, + _trimValue: function( value ) { + var options = this.options; + + if ( value > options.max) { + return options.max; + } + + if ( value < options.min ) { + return options.min; + } + + return value; + }, + _stop: function( event ) { this.counter = 0; if ( this.timer ) { @@ -280,13 +297,7 @@ $.widget( "ui.spinner", { _setOption: function( key, value ) { if ( key === "value") { - value = this._parse( value ); - if ( value < this.options.min ) { - value = this.options.min; - } - if ( value > this.options.max ) { - value = this.options.max; - } + value = this._trimValue( this._parse(value) ); } if ( key === "disabled" ) { diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index f19061bc3..5e32459fc 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -148,7 +148,14 @@ $.widget( "ui.tooltip", { this._bind( target, { mouseleave: "close", - blur: "close" + blur: "close", + keyup: function( event ) { + if ( event.keyCode == $.ui.keyCode.ESCAPE ) { + var fakeEvent = $.Event(event); + fakeEvent.currentTarget = target[0]; + this.close( fakeEvent, true ); + } + } }); }, @@ -176,7 +183,7 @@ $.widget( "ui.tooltip", { delete that.tooltips[ this.id ]; }); - target.unbind( "mouseleave.tooltip blur.tooltip" ); + target.unbind( "mouseleave.tooltip blur.tooltip keyup.tooltip" ); this._trigger( "close", event, { tooltip: tooltip } ); }, diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 00bc07c4f..59d110b6a 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -133,7 +133,7 @@ $.widget.bridge = function( name, object ) { } var methodValue = instance[ options ].apply( instance, args ); if ( methodValue !== instance && methodValue !== undefined ) { - returnValue = methodValue.jquery ? + returnValue = methodValue && methodValue.jquery ? returnValue.pushStack( methodValue.get() ) : methodValue; return false; @@ -239,9 +239,6 @@ $.Widget.prototype = { } if ( typeof key === "string" ) { - if ( value === undefined ) { - return this.options[ key ]; - } // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } options = {}; parts = key.split( "." ); @@ -252,8 +249,15 @@ $.Widget.prototype = { curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {}; curOption = curOption[ parts[ i ] ]; } - curOption[ parts.pop() ] = value; + key = parts.pop(); + if ( value === undefined ) { + return curOption[ key ] === undefined ? null : curOption[ key ]; + } + curOption[ key ] = value; } else { + if ( value === undefined ) { + return this.options[ key ] === undefined ? null : this.options[ key ]; + } options[ key ] = value; } } |