diff options
author | Felix Nagel <info@felixnagel.com> | 2012-07-12 23:57:55 +0200 |
---|---|---|
committer | Felix Nagel <info@felixnagel.com> | 2012-07-12 23:57:55 +0200 |
commit | 5092d0296a010280ee9d004f2fe06afbf1c45db5 (patch) | |
tree | ac6b97b4551b4aebf8d90cc35add82fc7088e0a3 /ui | |
parent | 39532f0a8e70e21e33aab03f08136f662d03a4a1 (diff) | |
parent | e054e28836e616ed03561d5a8195bbea525866d1 (diff) | |
download | jquery-ui-5092d0296a010280ee9d004f2fe06afbf1c45db5.tar.gz jquery-ui-5092d0296a010280ee9d004f2fe06afbf1c45db5.zip |
Merge branch 'master' into selectmenu
Diffstat (limited to 'ui')
-rw-r--r-- | ui/i18n/jquery.ui.datepicker-ar.js | 2 | ||||
-rw-r--r-- | ui/jquery.effects.core.js | 739 | ||||
-rw-r--r-- | ui/jquery.ui.accordion.js | 12 | ||||
-rw-r--r-- | ui/jquery.ui.autocomplete.js | 25 | ||||
-rw-r--r-- | ui/jquery.ui.button.js | 37 | ||||
-rw-r--r-- | ui/jquery.ui.core.js | 18 | ||||
-rw-r--r-- | ui/jquery.ui.datepicker.js | 75 | ||||
-rw-r--r-- | ui/jquery.ui.dialog.js | 11 | ||||
-rw-r--r-- | ui/jquery.ui.draggable.js | 11 | ||||
-rw-r--r-- | ui/jquery.ui.droppable.js | 3 | ||||
-rw-r--r-- | ui/jquery.ui.effect-blind.js (renamed from ui/jquery.effects.blind.js) | 5 | ||||
-rw-r--r-- | ui/jquery.ui.effect-bounce.js (renamed from ui/jquery.effects.bounce.js) | 5 | ||||
-rw-r--r-- | ui/jquery.ui.effect-clip.js (renamed from ui/jquery.effects.clip.js) | 5 | ||||
-rw-r--r-- | ui/jquery.ui.effect-drop.js (renamed from ui/jquery.effects.drop.js) | 5 | ||||
-rw-r--r-- | ui/jquery.ui.effect-explode.js (renamed from ui/jquery.effects.explode.js) | 5 | ||||
-rw-r--r-- | ui/jquery.ui.effect-fade.js (renamed from ui/jquery.effects.fade.js) | 20 | ||||
-rw-r--r-- | ui/jquery.ui.effect-fold.js (renamed from ui/jquery.effects.fold.js) | 5 | ||||
-rw-r--r-- | ui/jquery.ui.effect-highlight.js (renamed from ui/jquery.effects.highlight.js) | 5 | ||||
-rw-r--r-- | ui/jquery.ui.effect-pulsate.js (renamed from ui/jquery.effects.pulsate.js) | 5 | ||||
-rw-r--r-- | ui/jquery.ui.effect-scale.js (renamed from ui/jquery.effects.scale.js) | 5 | ||||
-rw-r--r-- | ui/jquery.ui.effect-shake.js (renamed from ui/jquery.effects.shake.js) | 5 | ||||
-rw-r--r-- | ui/jquery.ui.effect-slide.js (renamed from ui/jquery.effects.slide.js) | 5 | ||||
-rw-r--r-- | ui/jquery.ui.effect-transfer.js (renamed from ui/jquery.effects.transfer.js) | 5 | ||||
-rw-r--r-- | ui/jquery.ui.effect.js | 1248 | ||||
-rw-r--r-- | ui/jquery.ui.menu.js | 156 | ||||
-rw-r--r-- | ui/jquery.ui.mouse.js | 3 | ||||
-rw-r--r-- | ui/jquery.ui.position.js | 3 | ||||
-rw-r--r-- | ui/jquery.ui.progressbar.js | 3 | ||||
-rw-r--r-- | ui/jquery.ui.resizable.js | 6 | ||||
-rw-r--r-- | ui/jquery.ui.selectable.js | 3 | ||||
-rw-r--r-- | ui/jquery.ui.slider.js | 5 | ||||
-rw-r--r-- | ui/jquery.ui.sortable.js | 11 | ||||
-rw-r--r-- | ui/jquery.ui.spinner.js | 15 | ||||
-rw-r--r-- | ui/jquery.ui.tabs.js | 420 | ||||
-rw-r--r-- | ui/jquery.ui.tooltip.js | 65 | ||||
-rw-r--r-- | ui/jquery.ui.widget.js | 40 |
36 files changed, 1916 insertions, 1075 deletions
diff --git a/ui/i18n/jquery.ui.datepicker-ar.js b/ui/i18n/jquery.ui.datepicker-ar.js index f24b3ff5a..f0d009667 100644 --- a/ui/i18n/jquery.ui.datepicker-ar.js +++ b/ui/i18n/jquery.ui.datepicker-ar.js @@ -12,7 +12,7 @@ jQuery(function($){ monthNamesShort: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'], dayNames: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'], dayNamesShort: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'], - dayNamesMin: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'], + dayNamesMin: ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'], weekHeader: 'أسبوع', dateFormat: 'dd/mm/yy', firstDay: 6, diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js deleted file mode 100644 index 1bb1415a9..000000000 --- a/ui/jquery.effects.core.js +++ /dev/null @@ -1,739 +0,0 @@ -/*! - * jQuery UI Effects @VERSION - * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Effects/ - */ -;(jQuery.effects || (function($, undefined) { - -var backCompat = $.uiBackCompat !== false, - // prefix used for storing data on .data() - dataSpace = "ui-effects-"; - -$.effects = { - effect: {} -}; - -/******************************************************************************/ -/****************************** COLOR ANIMATIONS ******************************/ -/******************************************************************************/ -(function() { - -// override the animation for color styles -$.each(["backgroundColor", "borderBottomColor", "borderLeftColor", - "borderRightColor", "borderTopColor", "borderColor", "color", "outlineColor"], -function(i, attr) { - $.fx.step[attr] = function(fx) { - if (!fx.colorInit) { - fx.start = getColor(fx.elem, attr); - fx.end = getRGB(fx.end); - fx.colorInit = true; - } - - fx.elem.style[attr] = "rgb(" + - Math.max(Math.min(parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0], 10), 255), 0) + "," + - Math.max(Math.min(parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1], 10), 255), 0) + "," + - Math.max(Math.min(parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2], 10), 255), 0) + ")"; - }; -}); - -// Color Conversion functions from highlightFade -// By Blair Mitchelmore -// http://jquery.offput.ca/highlightFade/ - -// Parse strings looking for color tuples [255,255,255] -function getRGB(color) { - var result; - - // Check if we're already dealing with an array of colors - if ( color && color.constructor === Array && color.length === 3 ) { - return color; - } - - // Look for rgb(num,num,num) - if ( (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) ) { - return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)]; - } - - // Look for rgb(num%,num%,num%) - if ( (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) ) { - return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55]; - } - - // Look for #a0b1c2 - if ( (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) ) { - return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)]; - } - - // Look for #fff - if ( (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) ) { - return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)]; - } - - // Look for rgba(0, 0, 0, 0) == transparent in Safari 3 - if ( (result = /rgba\(0, 0, 0, 0\)/.exec(color)) ) { - return colors.transparent; - } - - // Otherwise, we're most likely dealing with a named color - return colors[$.trim(color).toLowerCase()]; -} - -function getColor(elem, attr) { - var color; - - do { - color = $.css(elem, attr); - - // Keep going until we find an element that has color, or we hit the body - if ( color && color !== "transparent" || $.nodeName(elem, "body") ) { - break; - } - - attr = "backgroundColor"; - } while ( (elem = elem.parentNode) ); - - return getRGB(color); -} - -// Some named colors to work with -// From Interface by Stefan Petre -// http://interface.eyecon.ro/ - -var colors = { - aqua:[0,255,255], - azure:[240,255,255], - beige:[245,245,220], - black:[0,0,0], - blue:[0,0,255], - brown:[165,42,42], - cyan:[0,255,255], - darkblue:[0,0,139], - darkcyan:[0,139,139], - darkgrey:[169,169,169], - darkgreen:[0,100,0], - darkkhaki:[189,183,107], - darkmagenta:[139,0,139], - darkolivegreen:[85,107,47], - darkorange:[255,140,0], - darkorchid:[153,50,204], - darkred:[139,0,0], - darksalmon:[233,150,122], - darkviolet:[148,0,211], - fuchsia:[255,0,255], - gold:[255,215,0], - green:[0,128,0], - indigo:[75,0,130], - khaki:[240,230,140], - lightblue:[173,216,230], - lightcyan:[224,255,255], - lightgreen:[144,238,144], - lightgrey:[211,211,211], - lightpink:[255,182,193], - lightyellow:[255,255,224], - lime:[0,255,0], - magenta:[255,0,255], - maroon:[128,0,0], - navy:[0,0,128], - olive:[128,128,0], - orange:[255,165,0], - pink:[255,192,203], - purple:[128,0,128], - violet:[128,0,128], - red:[255,0,0], - silver:[192,192,192], - white:[255,255,255], - yellow:[255,255,0], - transparent: [255,255,255] -}; - -})(); - -/******************************************************************************/ -/****************************** CLASS ANIMATIONS ******************************/ -/******************************************************************************/ -(function() { - -var classAnimationActions = [ "add", "remove", "toggle" ], - shorthandStyles = { - border: 1, - borderBottom: 1, - borderColor: 1, - borderLeft: 1, - borderRight: 1, - borderTop: 1, - borderWidth: 1, - margin: 1, - padding: 1 - }; - -$.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) { - $.fx.step[ prop ] = function( fx ) { - if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) { - jQuery.style( fx.elem, prop, fx.end ); - fx.setAttr = true; - } - }; -}); - -function getElementStyles() { - var style = this.ownerDocument.defaultView ? - this.ownerDocument.defaultView.getComputedStyle( this, null ) : - this.currentStyle, - newStyle = {}, - key, - camelCase, - len; - - // webkit enumerates style porperties - if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) { - len = style.length; - while ( len-- ) { - key = style[ len ]; - if ( typeof style[ key ] === "string" ) { - newStyle[ $.camelCase( key ) ] = style[ key ]; - } - } - } else { - for ( key in style ) { - if ( typeof style[ key ] === "string" ) { - newStyle[ key ] = style[ key ]; - } - } - } - - return newStyle; -} - - -function styleDifference( oldStyle, newStyle ) { - var diff = {}, - name, value; - - for ( name in newStyle ) { - value = newStyle[ name ]; - if ( oldStyle[ name ] !== value ) { - if ( !shorthandStyles[ name ] ) { - if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) { - diff[ name ] = value; - } - } - } - } - - return diff; -} - -$.effects.animateClass = function( value, duration, easing, callback ) { - var o = $.speed( duration, easing, callback ); - - return this.queue( function() { - var animated = $( this ), - baseClass = animated.attr( "class" ) || "", - applyClassChange, - allAnimations = o.children ? animated.find( "*" ).andSelf() : animated; - - // map the animated objects to store the original styles. - allAnimations = allAnimations.map(function() { - var el = $( this ); - return { - el: el, - start: getElementStyles.call( this ) - }; - }); - - // apply class change - applyClassChange = function() { - $.each( classAnimationActions, function(i, action) { - if ( value[ action ] ) { - animated[ action + "Class" ]( value[ action ] ); - } - }); - }; - applyClassChange(); - - // map all animated objects again - calculate new styles and diff - allAnimations = allAnimations.map(function() { - this.end = getElementStyles.call( this.el[ 0 ] ); - this.diff = styleDifference( this.start, this.end ); - return this; - }); - - // apply original class - animated.attr( "class", baseClass ); - - // map all animated objects again - this time collecting a promise - allAnimations = allAnimations.map(function() { - var styleInfo = this, - dfd = $.Deferred(), - opts = jQuery.extend({}, o, { - queue: false, - complete: function() { - dfd.resolve( styleInfo ); - } - }); - - this.el.animate( this.diff, opts ); - return dfd.promise(); - }); - - // once all animations have completed: - $.when.apply( $, allAnimations.get() ).done(function() { - - // set the final class - applyClassChange(); - - // for each animated element, - // clear all css properties that were animated - $.each( arguments, function() { - var el = this.el; - $.each( this.diff, function(key) { - el.css( key, '' ); - }); - }); - - // this is guarnteed to be there if you use jQuery.speed() - // it also handles dequeuing the next anim... - o.complete.call( animated[ 0 ] ); - }); - }); -}; - -$.fn.extend({ - _addClass: $.fn.addClass, - addClass: function( classNames, speed, easing, callback ) { - return speed ? - $.effects.animateClass.apply( this, [{ add: classNames }, speed, easing, callback ]) : - this._addClass(classNames); - }, - - _removeClass: $.fn.removeClass, - removeClass: function( classNames, speed, easing, callback ) { - return speed ? - $.effects.animateClass.apply( this, [{ remove: classNames }, speed, easing, callback ]) : - this._removeClass(classNames); - }, - - _toggleClass: $.fn.toggleClass, - toggleClass: function( classNames, force, speed, easing, callback ) { - if ( typeof force === "boolean" || force === undefined ) { - if ( !speed ) { - // without speed parameter; - return this._toggleClass( classNames, force ); - } else { - return $.effects.animateClass.apply( this, [( force ? { add:classNames } : { remove:classNames }), speed, easing, callback ]); - } - } else { - // without force parameter; - return $.effects.animateClass.apply( this, [{ toggle: classNames }, force, speed, easing ]); - } - }, - - switchClass: function( remove, add, speed, easing, callback) { - return $.effects.animateClass.apply( this, [{ - add: add, - remove: remove - }, speed, easing, callback ]); - } -}); - -})(); - -/******************************************************************************/ -/*********************************** EFFECTS **********************************/ -/******************************************************************************/ - -(function() { - -$.extend( $.effects, { - version: "@VERSION", - - // Saves a set of properties in a data storage - save: function( element, set ) { - for( var i=0; i < set.length; i++ ) { - if ( set[ i ] !== null ) { - element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] ); - } - } - }, - - // Restores a set of previously saved properties from a data storage - restore: function( element, set ) { - for( var i=0; i < set.length; i++ ) { - if ( set[ i ] !== null ) { - element.css( set[ i ], element.data( dataSpace + set[ i ] ) ); - } - } - }, - - setMode: function( el, mode ) { - if (mode === "toggle") { - mode = el.is( ":hidden" ) ? "show" : "hide"; - } - return mode; - }, - - // Translates a [top,left] array into a baseline value - // this should be a little more flexible in the future to handle a string & hash - getBaseline: function( origin, original ) { - var y, x; - switch ( origin[ 0 ] ) { - case "top": y = 0; break; - case "middle": y = 0.5; break; - case "bottom": y = 1; break; - default: y = origin[ 0 ] / original.height; - } - switch ( origin[ 1 ] ) { - case "left": x = 0; break; - case "center": x = 0.5; break; - case "right": x = 1; break; - default: x = origin[ 1 ] / original.width; - } - return { - x: x, - y: y - }; - }, - - // Wraps the element around a wrapper that copies position properties - createWrapper: function( element ) { - - // if the element is already wrapped, return it - if ( element.parent().is( ".ui-effects-wrapper" )) { - return element.parent(); - } - - // wrap the element - var props = { - width: element.outerWidth(true), - height: element.outerHeight(true), - "float": element.css( "float" ) - }, - wrapper = $( "<div></div>" ) - .addClass( "ui-effects-wrapper" ) - .css({ - fontSize: "100%", - background: "transparent", - 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() - }, - active = document.activeElement; - - // support: Firefox - // Firefox incorrectly exposes anonymous content - // https://bugzilla.mozilla.org/show_bug.cgi?id=561664 - try { - active.id; - } catch( e ) { - active = document.body; - } - - element.wrap( wrapper ); - - // Fixes #7595 - Elements lose focus when wrapped. - if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { - $( active ).focus(); - } - - wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element - - // transfer positioning properties to the wrapper - if ( element.css( "position" ) === "static" ) { - wrapper.css({ position: "relative" }); - element.css({ position: "relative" }); - } else { - $.extend( props, { - position: element.css( "position" ), - zIndex: element.css( "z-index" ) - }); - $.each([ "top", "left", "bottom", "right" ], function(i, pos) { - props[ pos ] = element.css( pos ); - if ( isNaN( parseInt( props[ pos ], 10 ) ) ) { - props[ pos ] = "auto"; - } - }); - element.css({ - position: "relative", - top: 0, - left: 0, - right: "auto", - bottom: "auto" - }); - } - element.css(size); - - return wrapper.css( props ).show(); - }, - - removeWrapper: function( element ) { - var active = document.activeElement; - - if ( element.parent().is( ".ui-effects-wrapper" ) ) { - element.parent().replaceWith( element ); - - // Fixes #7595 - Elements lose focus when wrapped. - if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { - $( active ).focus(); - } - } - - - return element; - }, - - setTransition: function( element, list, factor, value ) { - value = value || {}; - $.each( list, function( i, x ) { - var unit = element.cssUnit( x ); - if ( unit[ 0 ] > 0 ) { - value[ x ] = unit[ 0 ] * factor + unit[ 1 ]; - } - }); - return value; - } -}); - -// return an effect options object for the given parameters: -function _normalizeArguments( effect, options, speed, callback ) { - - // allow passing all optinos as the first parameter - if ( $.isPlainObject( effect ) ) { - options = effect; - effect = effect.effect; - } - - // convert to an object - effect = { effect: effect }; - - // catch (effect) - if ( options === undefined ) { - options = {}; - } - - // catch (effect, callback) - if ( $.isFunction( options ) ) { - callback = options; - speed = null; - options = {}; - } - - // catch (effect, speed, ?) - if ( typeof options === "number" || $.fx.speeds[ options ] ) { - callback = speed; - speed = options; - options = {}; - } - - // catch (effect, options, callback) - if ( $.isFunction( speed ) ) { - callback = speed; - speed = null; - } - - // add options to effect - if ( options ) { - $.extend( effect, options ); - } - - speed = speed || options.duration; - effect.duration = $.fx.off ? 0 : - typeof speed === "number" ? speed : - speed in $.fx.speeds ? $.fx.speeds[ speed ] : - $.fx.speeds._default; - - effect.complete = callback || options.complete; - - return effect; -} - -function standardSpeed( speed ) { - // valid standard speeds - if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) { - return true; - } - - // invalid strings - treat as "normal" speed - if ( typeof speed === "string" && !$.effects.effect[ speed ] ) { - // TODO: remove in 2.0 (#7115) - if ( backCompat && $.effects[ speed ] ) { - return false; - } - return true; - } - - return false; -} - -$.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) - oldEffectMethod = !effectMethod && backCompat && $.effects[ args.effect ]; - - if ( $.fx.off || !( effectMethod || oldEffectMethod ) ) { - // delegate to the original method (e.g., .show()) if possible - if ( mode ) { - return this[ mode ]( args.duration, args.complete ); - } else { - return this.each( function() { - if ( args.complete ) { - args.complete.call( this ); - } - }); - } - } - - 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 queue === false ? this.each( run ) : this.queue( queue || "fx", run ); - } else { - // DEPRECATED: remove in 2.0 (#7115) - return oldEffectMethod.call(this, { - options: args, - duration: args.duration, - callback: args.complete, - mode: args.mode - }); - } - }, - - _show: $.fn.show, - show: function( speed ) { - if ( standardSpeed( speed ) ) { - return this._show.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "show"; - return this.effect.call( this, args ); - } - }, - - _hide: $.fn.hide, - hide: function( speed ) { - if ( standardSpeed( speed ) ) { - return this._hide.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "hide"; - return this.effect.call( this, args ); - } - }, - - // jQuery core overloads toggle and creates _toggle - __toggle: $.fn.toggle, - toggle: function( speed ) { - if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) { - return this.__toggle.apply( this, arguments ); - } else { - var args = _normalizeArguments.apply( this, arguments ); - args.mode = "toggle"; - return this.effect.call( this, args ); - } - }, - - // helper functions - cssUnit: function(key) { - var style = this.css( key ), - val = []; - - $.each( [ "em", "px", "%", "pt" ], function( i, unit ) { - if ( style.indexOf( unit ) > 0 ) { - val = [ parseFloat( style ), unit ]; - } - }); - return val; - } -}); - -})(); - -/******************************************************************************/ -/*********************************** EASING ***********************************/ -/******************************************************************************/ - -(function() { - -// based on easing equations from Robert Penner (http://www.robertpenner.com/easing) - -var baseEasings = {}; - -$.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) { - baseEasings[ name ] = function( p ) { - return Math.pow( p, i + 2 ); - }; -}); - -$.extend( baseEasings, { - Sine: function ( p ) { - return 1 - Math.cos( p * Math.PI / 2 ); - }, - Circ: function ( p ) { - return 1 - Math.sqrt( 1 - p * p ); - }, - Elastic: function( p ) { - return p === 0 || p === 1 ? p : - -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 ); - }, - Back: function( p ) { - return p * p * ( 3 * p - 2 ); - }, - Bounce: function ( p ) { - var pow2, - bounce = 4; - - while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {} - return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 ); - } -}); - -$.each( baseEasings, function( name, easeIn ) { - $.easing[ "easeIn" + name ] = easeIn; - $.easing[ "easeOut" + name ] = function( p ) { - return 1 - easeIn( 1 - p ); - }; - $.easing[ "easeInOut" + name ] = function( p ) { - return p < 0.5 ? - easeIn( p * 2 ) / 2 : - 1 - easeIn( p * -2 + 2 ) / 2; - }; -}); - -})(); - -})(jQuery)); diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 856b3ba4b..7d98886e7 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -1,7 +1,8 @@ /*! * jQuery UI Accordion @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * @@ -137,8 +138,8 @@ $.widget( "ui.accordion", { }); } - this._bind( this.headers, { keydown: "_keydown" }); - this._bind( this.headers.next(), { keydown: "_panelKeyDown" }); + this._on( this.headers, { keydown: "_keydown" }); + this._on( this.headers.next(), { keydown: "_panelKeyDown" }); this._setupEvents( options.event ); }, @@ -219,8 +220,7 @@ $.widget( "ui.accordion", { if ( key === "event" ) { if ( this.options.event ) { - this.headers.unbind( - this.options.event.split( " " ).join( ".accordion " ) + ".accordion" ); + this._off( this.headers, this.options.event ); } this._setupEvents( value ); } @@ -376,7 +376,7 @@ $.widget( "ui.accordion", { $.each( event.split(" "), function( index, eventName ) { events[ eventName ] = "_eventHandler"; }); - this._bind( this.headers, events ); + this._on( this.headers, events ); }, _eventHandler: function( event ) { diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 2fb7e395c..25d909f8d 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -1,7 +1,8 @@ /*! * jQuery UI Autocomplete @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * @@ -55,7 +56,7 @@ $.widget( "ui.autocomplete", { // search term. #7799 var suppressKeyPress, suppressKeyPressRepeat, suppressInput; - this.isMultiLine = this.element.is( "textarea,[contenteditable]" ); + this.isMultiLine = this._isMultiLine(); this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ]; this.isNewMenu = true; @@ -63,7 +64,7 @@ $.widget( "ui.autocomplete", { .addClass( "ui-autocomplete-input" ) .attr( "autocomplete", "off" ); - this._bind({ + this._on({ keydown: function( event ) { if ( this.element.prop( "readOnly" ) ) { suppressKeyPress = true; @@ -190,7 +191,7 @@ $.widget( "ui.autocomplete", { .zIndex( this.element.zIndex() + 1 ) .hide() .data( "menu" ); - this._bind( this.menu.element, { + this._on( this.menu.element, { mousedown: function( event ) { // prevent moving focus out of the text field event.preventDefault(); @@ -297,7 +298,7 @@ $.widget( "ui.autocomplete", { // turning off autocomplete prevents the browser from remembering the // value when navigating through history, so we re-enable autocomplete // if the page is unloaded before the widget is destroyed. #7790 - this._bind( this.window, { + this._on( this.window, { beforeunload: function() { this.element.removeAttr( "autocomplete" ); } @@ -326,6 +327,20 @@ $.widget( "ui.autocomplete", { } }, + _isMultiLine: function() { + // Textareas are always multi-line + if ( this.element.is( "textarea" ) ) { + return true; + } + // Inputs are always single-line, even if inside a contentEditable element + // IE also treats inputs as contentEditable + if ( this.element.is( "input" ) ) { + return false; + } + // All other element types are determined by whether or not they're contentEditable + return this.element.prop( "isContentEditable" ); + }, + _initSource: function() { var array, url, that = this; diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index 810191775..1aa44abdd 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -1,7 +1,8 @@ /*! * jQuery UI Button @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * @@ -54,8 +55,8 @@ $.widget( "ui.button", { }, _create: function() { this.element.closest( "form" ) - .unbind( "reset.button" ) - .bind( "reset.button", formResetHandler ); + .unbind( "reset" + this.eventNamespace ) + .bind( "reset" + this.eventNamespace, formResetHandler ); if ( typeof this.options.disabled !== "boolean" ) { this.options.disabled = !!this.element.prop( "disabled" ); @@ -79,7 +80,7 @@ $.widget( "ui.button", { this.buttonElement .addClass( baseClasses ) .attr( "role", "button" ) - .bind( "mouseenter.button", function() { + .bind( "mouseenter" + this.eventNamespace, function() { if ( options.disabled ) { return; } @@ -88,13 +89,13 @@ $.widget( "ui.button", { $( this ).addClass( "ui-state-active" ); } }) - .bind( "mouseleave.button", function() { + .bind( "mouseleave" + this.eventNamespace, function() { if ( options.disabled ) { return; } $( this ).removeClass( hoverClass ); }) - .bind( "click.button", function( event ) { + .bind( "click" + this.eventNamespace, function( event ) { if ( options.disabled ) { event.preventDefault(); event.stopImmediatePropagation(); @@ -102,16 +103,16 @@ $.widget( "ui.button", { }); this.element - .bind( "focus.button", function() { + .bind( "focus" + this.eventNamespace, function() { // no need to check disabled, focus won't be triggered anyway that.buttonElement.addClass( focusClass ); }) - .bind( "blur.button", function() { + .bind( "blur" + this.eventNamespace, function() { that.buttonElement.removeClass( focusClass ); }); if ( toggleButton ) { - this.element.bind( "change.button", function() { + this.element.bind( "change" + this.eventNamespace, function() { if ( clickDragged ) { return; } @@ -121,7 +122,7 @@ $.widget( "ui.button", { // prevents issue where button state changes but checkbox/radio checked state // does not in Firefox (see ticket #6970) this.buttonElement - .bind( "mousedown.button", function( event ) { + .bind( "mousedown" + this.eventNamespace, function( event ) { if ( options.disabled ) { return; } @@ -129,7 +130,7 @@ $.widget( "ui.button", { startXPos = event.pageX; startYPos = event.pageY; }) - .bind( "mouseup.button", function( event ) { + .bind( "mouseup" + this.eventNamespace, function( event ) { if ( options.disabled ) { return; } @@ -140,7 +141,7 @@ $.widget( "ui.button", { } if ( this.type === "checkbox" ) { - this.buttonElement.bind( "click.button", function() { + this.buttonElement.bind( "click" + this.eventNamespace, function() { if ( options.disabled || clickDragged ) { return false; } @@ -148,7 +149,7 @@ $.widget( "ui.button", { that.buttonElement.attr( "aria-pressed", that.element[0].checked ); }); } else if ( this.type === "radio" ) { - this.buttonElement.bind( "click.button", function() { + this.buttonElement.bind( "click" + this.eventNamespace, function() { if ( options.disabled || clickDragged ) { return false; } @@ -166,7 +167,7 @@ $.widget( "ui.button", { }); } else { this.buttonElement - .bind( "mousedown.button", function() { + .bind( "mousedown" + this.eventNamespace, function() { if ( options.disabled ) { return false; } @@ -176,13 +177,13 @@ $.widget( "ui.button", { lastActive = null; }); }) - .bind( "mouseup.button", function() { + .bind( "mouseup" + this.eventNamespace, function() { if ( options.disabled ) { return false; } $( this ).removeClass( "ui-state-active" ); }) - .bind( "keydown.button", function(event) { + .bind( "keydown" + this.eventNamespace, function(event) { if ( options.disabled ) { return false; } @@ -190,7 +191,7 @@ $.widget( "ui.button", { $( this ).addClass( "ui-state-active" ); } }) - .bind( "keyup.button", function() { + .bind( "keyup" + this.eventNamespace, function() { $( this ).removeClass( "ui-state-active" ); }); @@ -344,7 +345,7 @@ $.widget( "ui.button", { buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" ); if ( !this.hasTitle ) { - buttonElement.attr( "title", buttonText ); + buttonElement.attr( "title", $.trim( buttonText ) ); } } } else { diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js index a511de24b..3e102f181 100644 --- a/ui/jquery.ui.core.js +++ b/ui/jquery.ui.core.js @@ -1,7 +1,8 @@ /*! - * jQuery UI @VERSION + * jQuery UI Core @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * @@ -215,9 +216,16 @@ function visible( element ) { } $.extend( $.expr[ ":" ], { - data: function( elem, i, match ) { - return !!$.data( elem, match[ 3 ] ); - }, + data: $.expr.createPseudo ? + $.expr.createPseudo(function( dataName ) { + return function( elem ) { + return !!$.data( elem, dataName ); + }; + }) : + // support: jQuery <1.8 + function( elem, i, match ) { + return !!$.data( elem, match[ 3 ] ); + }, focusable: function( element ) { return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) ); diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index a92c9fafa..06db79ba7 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -1,7 +1,8 @@ /*! * jQuery UI Datepicker @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * @@ -665,10 +666,6 @@ $.extend(Datepicker.prototype, { isFixed |= $(this).css('position') == 'fixed'; return !isFixed; }); - if (isFixed && $.browser.opera) { // correction for Opera when fixed and scrolled - $.datepicker._pos[0] -= document.documentElement.scrollLeft; - $.datepicker._pos[1] -= document.documentElement.scrollTop; - } var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]}; $.datepicker._pos = null; //to avoid flashes on Firefox @@ -715,6 +712,7 @@ $.extend(Datepicker.prototype, { var borders = $.datepicker._getBorders(inst.dpDiv); instActive = inst; // for delegate hover events inst.dpDiv.empty().append(this._generateHTML(inst)); + this._attachHandlers(inst); var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only if( !!cover.length ){ //avoid call to outerXXXX() when not in IE6 cover.css({left: -borders[0], top: -borders[1], width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()}) @@ -1408,6 +1406,43 @@ $.extend(Datepicker.prototype, { return startDate; }, + /* Attach the onxxx handlers. These are declared statically so + * they work with static code transformers like Caja. + */ + _attachHandlers: function(inst) { + var stepMonths = this._get(inst, 'stepMonths'); + var id = '#' + inst.id; + inst.dpDiv.find('[data-handler]').map(function () { + var handler = { + prev: function () { + window['DP_jQuery_' + dpuuid].datepicker._adjustDate(id, -stepMonths, 'M'); + }, + next: function () { + window['DP_jQuery_' + dpuuid].datepicker._adjustDate(id, +stepMonths, 'M'); + }, + hide: function () { + window['DP_jQuery_' + dpuuid].datepicker._hideDatepicker(); + }, + today: function () { + window['DP_jQuery_' + dpuuid].datepicker._gotoToday(id); + }, + selectDay: function () { + window['DP_jQuery_' + dpuuid].datepicker._selectDay(id, +this.getAttribute('data-month'), +this.getAttribute('data-year'), this); + return false; + }, + selectMonth: function () { + window['DP_jQuery_' + dpuuid].datepicker._selectMonthYear(id, this, 'M'); + return false; + }, + selectYear: function () { + window['DP_jQuery_' + dpuuid].datepicker._selectMonthYear(id, this, 'Y'); + return false; + } + }; + $(this).bind(this.getAttribute('data-event'), handler[this.getAttribute('data-handler')]); + }); + }, + /* Generate the HTML for the current state of the date picker. */ _generateHTML: function(inst) { var today = new Date(); @@ -1450,8 +1485,7 @@ $.extend(Datepicker.prototype, { this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)), this._getFormatConfig(inst))); var prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ? - '<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery_' + dpuuid + - '.datepicker._adjustDate(\'#' + inst.id + '\', -' + stepMonths + ', \'M\');"' + + '<a class="ui-datepicker-prev ui-corner-all" data-handler="prev" data-event="click"' + ' title="' + prevText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>' : (hideIfNoPrevNext ? '' : '<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+ prevText +'"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'e' : 'w') + '">' + prevText + '</span></a>')); var nextText = this._get(inst, 'nextText'); @@ -1459,19 +1493,17 @@ $.extend(Datepicker.prototype, { this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)), this._getFormatConfig(inst))); var next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ? - '<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery_' + dpuuid + - '.datepicker._adjustDate(\'#' + inst.id + '\', +' + stepMonths + ', \'M\');"' + + '<a class="ui-datepicker-next ui-corner-all" data-handler="next" data-event="click"' + ' title="' + nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>' : (hideIfNoPrevNext ? '' : '<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+ nextText + '"><span class="ui-icon ui-icon-circle-triangle-' + ( isRTL ? 'w' : 'e') + '">' + nextText + '</span></a>')); var currentText = this._get(inst, 'currentText'); var gotoDate = (this._get(inst, 'gotoCurrent') && inst.currentDay ? currentDate : today); currentText = (!navigationAsDateFormat ? currentText : this.formatDate(currentText, gotoDate, this._getFormatConfig(inst))); - var controls = (!inst.inline ? '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery_' + dpuuid + - '.datepicker._hideDatepicker();">' + this._get(inst, 'closeText') + '</button>' : ''); + var controls = (!inst.inline ? '<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" data-handler="hide" data-event="click">' + + this._get(inst, 'closeText') + '</button>' : ''); var buttonPanel = (showButtonPanel) ? '<div class="ui-datepicker-buttonpane ui-widget-content">' + (isRTL ? controls : '') + - (this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery_' + dpuuid + - '.datepicker._gotoToday(\'#' + inst.id + '\');"' + + (this._isInRange(inst, gotoDate) ? '<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" data-handler="today" data-event="click"' + '>' + currentText + '</button>' : '') + (isRTL ? '' : controls) + '</div>' : ''; var firstDay = parseInt(this._get(inst, 'firstDay'),10); firstDay = (isNaN(firstDay) ? 0 : firstDay); @@ -1550,8 +1582,7 @@ $.extend(Datepicker.prototype, { (printDate.getTime() == currentDate.getTime() ? ' ' + this._currentClass : '') + // highlight selected day (printDate.getTime() == today.getTime() ? ' ui-datepicker-today' : '')) + '"' + // highlight today (if different) ((!otherMonth || showOtherMonths) && daySettings[2] ? ' title="' + daySettings[2] + '"' : '') + // cell title - (unselectable ? '' : ' onclick="DP_jQuery_' + dpuuid + '.datepicker._selectDay(\'#' + - inst.id + '\',' + printDate.getMonth() + ',' + printDate.getFullYear() + ', this);return false;"') + '>' + // actions + (unselectable ? '' : ' data-handler="selectDay" data-event="click" data-month="' + printDate.getMonth() + '" data-year="' + printDate.getFullYear() + '"') + '>' + // actions (otherMonth && !showOtherMonths ? ' ' : // display for other months (unselectable ? '<span class="ui-state-default">' + printDate.getDate() + '</span>' : '<a class="ui-state-default' + (printDate.getTime() == today.getTime() ? ' ui-state-highlight' : '') + @@ -1594,9 +1625,7 @@ $.extend(Datepicker.prototype, { else { var inMinYear = (minDate && minDate.getFullYear() == drawYear); var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear); - monthHtml += '<select class="ui-datepicker-month" ' + - 'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'M\');" ' + - '>'; + monthHtml += '<select class="ui-datepicker-month" data-handler="selectMonth" data-event="change">'; for (var month = 0; month < 12; month++) { if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) @@ -1627,9 +1656,7 @@ $.extend(Datepicker.prototype, { var endYear = Math.max(year, determineYear(years[1] || '')); year = (minDate ? Math.max(year, minDate.getFullYear()) : year); endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear); - inst.yearshtml += '<select class="ui-datepicker-year" ' + - 'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' + - '>'; + inst.yearshtml += '<select class="ui-datepicker-year" data-handler="selectYear" data-event="change">'; for (; year <= endYear; year++) { inst.yearshtml += '<option value="' + year + '"' + (year == drawYear ? ' selected="selected"' : '') + @@ -1774,12 +1801,6 @@ function extendRemove(target, props) { return target; }; -/* Determine whether an object is an array. */ -function isArray(a) { - return (a && (($.browser.safari && typeof a == 'object' && a.length) || - (a.constructor && a.constructor.toString().match(/\Array\(\)/)))); -}; - /* Invoke the datepicker functionality. @param options string - a command, optionally followed by additional parameters or Object - settings for attaching new datepicker functionality diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 4ef8a20cb..85e4b3e2b 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -1,7 +1,8 @@ /*! * jQuery UI Dialog @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * @@ -224,7 +225,7 @@ $.widget("ui.dialog", { if ( this.overlay ) { this.overlay.destroy(); } - this.uiDialog.unbind( "keypress.ui-dialog" ); + this._off( this.uiDialog, "keypress" ); if ( this.options.hide ) { this.uiDialog.hide( this.options.hide, function() { @@ -310,12 +311,12 @@ $.widget("ui.dialog", { // prevent tabbing out of modal dialogs if ( options.modal ) { - uiDialog.bind( "keydown.ui-dialog", function( event ) { + this._on( uiDialog, { keydown: function( event ) { if ( event.keyCode !== $.ui.keyCode.TAB ) { return; } - var tabbables = $( ":tabbable", this ), + var tabbables = $( ":tabbable", uiDialog ), first = tabbables.filter( ":first" ), last = tabbables.filter( ":last" ); @@ -326,7 +327,7 @@ $.widget("ui.dialog", { last.focus( 1 ); return false; } - }); + }}); } // set focus to the first tabbable element in the content area or the first button diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js index 1845f0891..2f05ad6a4 100644 --- a/ui/jquery.ui.draggable.js +++ b/ui/jquery.ui.draggable.js @@ -1,7 +1,8 @@ /*! * jQuery UI Draggable @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * @@ -400,13 +401,13 @@ $.widget("ui.draggable", $.ui.mouse, { pos.top // The absolute mouse position + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border) - - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod) + - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod) ), left: ( pos.left // The absolute mouse position + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border) - - ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod) + - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod) ) }; @@ -460,14 +461,14 @@ $.widget("ui.draggable", $.ui.mouse, { - this.offset.click.top // Click offset (relative to the element) - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.top // The offsetParent's offset without borders (offset + border) - + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )) + + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )) ), left: ( pageX // The absolute mouse position - this.offset.click.left // Click offset (relative to the element) - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.left // The offsetParent's offset without borders (offset + border) - + ($.browser.safari && $.browser.version < 526 && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )) + + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )) ) }; diff --git a/ui/jquery.ui.droppable.js b/ui/jquery.ui.droppable.js index e2ad221e1..17a56787a 100644 --- a/ui/jquery.ui.droppable.js +++ b/ui/jquery.ui.droppable.js @@ -1,7 +1,8 @@ /*! * jQuery UI Droppable @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * diff --git a/ui/jquery.effects.blind.js b/ui/jquery.ui.effect-blind.js index 005b59ad6..7cc353525 100644 --- a/ui/jquery.effects.blind.js +++ b/ui/jquery.ui.effect-blind.js @@ -1,14 +1,15 @@ /*! * jQuery UI Effects Blind @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Effects/Blind * * Depends: - * jquery.effects.core.js + * jquery.ui.effect.js */ (function( $, undefined ) { diff --git a/ui/jquery.effects.bounce.js b/ui/jquery.ui.effect-bounce.js index 934fb16ef..0a93bda08 100644 --- a/ui/jquery.effects.bounce.js +++ b/ui/jquery.ui.effect-bounce.js @@ -1,14 +1,15 @@ /*! * jQuery UI Effects Bounce @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Effects/Bounce * * Depends: - * jquery.effects.core.js + * jquery.ui.effect.js */ (function( $, undefined ) { diff --git a/ui/jquery.effects.clip.js b/ui/jquery.ui.effect-clip.js index 861508cd0..6539acf24 100644 --- a/ui/jquery.effects.clip.js +++ b/ui/jquery.ui.effect-clip.js @@ -1,14 +1,15 @@ /*! * jQuery UI Effects Clip @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Effects/Clip * * Depends: - * jquery.effects.core.js + * jquery.ui.effect.js */ (function( $, undefined ) { diff --git a/ui/jquery.effects.drop.js b/ui/jquery.ui.effect-drop.js index ea8d242d5..3246c09b0 100644 --- a/ui/jquery.effects.drop.js +++ b/ui/jquery.ui.effect-drop.js @@ -1,14 +1,15 @@ /*! * jQuery UI Effects Drop @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Effects/Drop * * Depends: - * jquery.effects.core.js + * jquery.ui.effect.js */ (function( $, undefined ) { diff --git a/ui/jquery.effects.explode.js b/ui/jquery.ui.effect-explode.js index ae3efb21e..1048b0a42 100644 --- a/ui/jquery.effects.explode.js +++ b/ui/jquery.ui.effect-explode.js @@ -1,14 +1,15 @@ /*! * jQuery UI Effects Explode @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Effects/Explode * * Depends: - * jquery.effects.core.js + * jquery.ui.effect.js */ (function( $, undefined ) { diff --git a/ui/jquery.effects.fade.js b/ui/jquery.ui.effect-fade.js index 66029b51c..ee031fcd8 100644 --- a/ui/jquery.effects.fade.js +++ b/ui/jquery.ui.effect-fade.js @@ -1,36 +1,30 @@ /*! * jQuery UI Effects Fade @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Effects/Fade * * Depends: - * jquery.effects.core.js + * jquery.ui.effect.js */ (function( $, undefined ) { $.effects.effect.fade = function( o, done ) { var el = $( this ), - mode = $.effects.setMode( el, o.mode || "toggle" ), - hide = mode === "hide"; + mode = $.effects.setMode( el, o.mode || "toggle" ); - el.show(); el.animate({ - opacity: hide ? 0 : 1 + opacity: mode }, { queue: false, duration: o.duration, easing: o.easing, - complete: function() { - if ( hide ) { - el.hide(); - } - done(); - } + complete: done }); }; -})(jQuery); +})( jQuery ); diff --git a/ui/jquery.effects.fold.js b/ui/jquery.ui.effect-fold.js index 17aa9a36b..7619285c2 100644 --- a/ui/jquery.effects.fold.js +++ b/ui/jquery.ui.effect-fold.js @@ -1,14 +1,15 @@ /*! * jQuery UI Effects Fold @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Effects/Fold * * Depends: - * jquery.effects.core.js + * jquery.ui.effect.js */ (function( $, undefined ) { diff --git a/ui/jquery.effects.highlight.js b/ui/jquery.ui.effect-highlight.js index ac6c269e5..f6868d136 100644 --- a/ui/jquery.effects.highlight.js +++ b/ui/jquery.ui.effect-highlight.js @@ -1,14 +1,15 @@ /*! * jQuery UI Effects Highlight @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Effects/Highlight * * Depends: - * jquery.effects.core.js + * jquery.ui.effect.js */ (function( $, undefined ) { diff --git a/ui/jquery.effects.pulsate.js b/ui/jquery.ui.effect-pulsate.js index 5b27bb324..543f6310d 100644 --- a/ui/jquery.effects.pulsate.js +++ b/ui/jquery.ui.effect-pulsate.js @@ -1,14 +1,15 @@ /*! * jQuery UI Effects Pulsate @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Effects/Pulsate * * Depends: - * jquery.effects.core.js + * jquery.ui.effect.js */ (function( $, undefined ) { diff --git a/ui/jquery.effects.scale.js b/ui/jquery.ui.effect-scale.js index 5352bde77..5e1dc8540 100644 --- a/ui/jquery.effects.scale.js +++ b/ui/jquery.ui.effect-scale.js @@ -1,14 +1,15 @@ /*! * jQuery UI Effects Scale @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Effects/Scale * * Depends: - * jquery.effects.core.js + * jquery.ui.effect.js */ (function( $, undefined ) { diff --git a/ui/jquery.effects.shake.js b/ui/jquery.ui.effect-shake.js index 700c6df3d..51d8e1129 100644 --- a/ui/jquery.effects.shake.js +++ b/ui/jquery.ui.effect-shake.js @@ -1,14 +1,15 @@ /*! * jQuery UI Effects Shake @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Effects/Shake * * Depends: - * jquery.effects.core.js + * jquery.ui.effect.js */ (function( $, undefined ) { diff --git a/ui/jquery.effects.slide.js b/ui/jquery.ui.effect-slide.js index ae25a187e..d61047b8b 100644 --- a/ui/jquery.effects.slide.js +++ b/ui/jquery.ui.effect-slide.js @@ -1,14 +1,15 @@ /*! * jQuery UI Effects Slide @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Effects/Slide * * Depends: - * jquery.effects.core.js + * jquery.ui.effect.js */ (function( $, undefined ) { diff --git a/ui/jquery.effects.transfer.js b/ui/jquery.ui.effect-transfer.js index 3368fb18e..7d6c10933 100644 --- a/ui/jquery.effects.transfer.js +++ b/ui/jquery.ui.effect-transfer.js @@ -1,14 +1,15 @@ /*! * jQuery UI Effects Transfer @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Effects/Transfer * * Depends: - * jquery.effects.core.js + * jquery.ui.effect.js */ (function( $, undefined ) { diff --git a/ui/jquery.ui.effect.js b/ui/jquery.ui.effect.js new file mode 100644 index 000000000..7cabe5849 --- /dev/null +++ b/ui/jquery.ui.effect.js @@ -0,0 +1,1248 @@ +/*! + * jQuery UI Effects @VERSION + * http://jqueryui.com + * + * Copyright 2012 jQuery Foundation and other contributors + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Effects/ + */ +;(jQuery.effects || (function($, undefined) { + +var backCompat = $.uiBackCompat !== false, + // prefix used for storing data on .data() + dataSpace = "ui-effects-"; + +$.effects = { + effect: {} +}; + +/*! + * jQuery Color Animations + * http://jquery.com/ + * + * Copyright 2012 jQuery Foundation and other contributors + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + */ +(function( jQuery, undefined ) { + + var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor".split(" "), + + // plusequals test for += 100 -= 100 + rplusequals = /^([\-+])=\s*(\d+\.?\d*)/, + // a set of RE's that can match strings and generate color tuples. + stringParsers = [{ + re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/, + parse: function( execResult ) { + return [ + execResult[ 1 ], + execResult[ 2 ], + execResult[ 3 ], + execResult[ 4 ] + ]; + } + }, { + re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/, + parse: function( execResult ) { + return [ + execResult[ 1 ] * 2.55, + execResult[ 2 ] * 2.55, + execResult[ 3 ] * 2.55, + execResult[ 4 ] + ]; + } + }, { + // this regex ignores A-F because it's compared against an already lowercased string + re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/, + parse: function( execResult ) { + return [ + parseInt( execResult[ 1 ], 16 ), + parseInt( execResult[ 2 ], 16 ), + parseInt( execResult[ 3 ], 16 ) + ]; + } + }, { + // this regex ignores A-F because it's compared against an already lowercased string + re: /#([a-f0-9])([a-f0-9])([a-f0-9])/, + parse: function( execResult ) { + return [ + parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ), + parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ), + parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ) + ]; + } + }, { + re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/, + space: "hsla", + parse: function( execResult ) { + return [ + execResult[ 1 ], + execResult[ 2 ] / 100, + execResult[ 3 ] / 100, + execResult[ 4 ] + ]; + } + }], + + // jQuery.Color( ) + color = jQuery.Color = function( color, green, blue, alpha ) { + return new jQuery.Color.fn.parse( color, green, blue, alpha ); + }, + spaces = { + rgba: { + props: { + red: { + idx: 0, + type: "byte" + }, + green: { + idx: 1, + type: "byte" + }, + blue: { + idx: 2, + type: "byte" + } + } + }, + + hsla: { + props: { + hue: { + idx: 0, + type: "degrees" + }, + saturation: { + idx: 1, + type: "percent" + }, + lightness: { + idx: 2, + type: "percent" + } + } + } + }, + propTypes = { + "byte": { + floor: true, + max: 255 + }, + "percent": { + max: 1 + }, + "degrees": { + mod: 360, + floor: true + } + }, + support = color.support = {}, + + // element for support tests + supportElem = jQuery( "<p>" )[ 0 ], + + // colors = jQuery.Color.names + colors, + + // local aliases of functions called often + each = jQuery.each; + +// determine rgba support immediately +supportElem.style.cssText = "background-color:rgba(1,1,1,.5)"; +support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1; + +// define cache name and alpha properties +// for rgba and hsla spaces +each( spaces, function( spaceName, space ) { + space.cache = "_" + spaceName; + space.props.alpha = { + idx: 3, + type: "percent", + def: 1 + }; +}); + +function clamp( value, prop, allowEmpty ) { + var type = propTypes[ prop.type ] || {}; + + if ( value == null ) { + return (allowEmpty || !prop.def) ? null : prop.def; + } + + // ~~ is an short way of doing floor for positive numbers + value = type.floor ? ~~value : parseFloat( value ); + + // IE will pass in empty strings as value for alpha, + // which will hit this case + if ( isNaN( value ) ) { + return prop.def; + } + + if ( type.mod ) { + // we add mod before modding to make sure that negatives values + // get converted properly: -10 -> 350 + return (value + type.mod) % type.mod; + } + + // for now all property types without mod have min and max + return 0 > value ? 0 : type.max < value ? type.max : value; +} + +function stringParse( string ) { + var inst = color(), + rgba = inst._rgba = []; + + string = string.toLowerCase(); + + each( stringParsers, function( i, parser ) { + var parsed, + match = parser.re.exec( string ), + values = match && parser.parse( match ), + spaceName = parser.space || "rgba"; + + if ( values ) { + parsed = inst[ spaceName ]( values ); + + // if this was an rgba parse the assignment might happen twice + // oh well.... + inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ]; + rgba = inst._rgba = parsed._rgba; + + // exit each( stringParsers ) here because we matched + return false; + } + }); + + // Found a stringParser that handled it + if ( rgba.length ) { + + // if this came from a parsed string, force "transparent" when alpha is 0 + // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0) + if ( rgba.join() === "0,0,0,0" ) { + jQuery.extend( rgba, colors.transparent ); + } + return inst; + } + + // named colors + return colors[ string ]; +} + +color.fn = jQuery.extend( color.prototype, { + parse: function( red, green, blue, alpha ) { + if ( red === undefined ) { + this._rgba = [ null, null, null, null ]; + return this; + } + if ( red.jquery || red.nodeType ) { + red = jQuery( red ).css( green ); + green = undefined; + } + + var inst = this, + type = jQuery.type( red ), + rgba = this._rgba = [], + source; + + // more than 1 argument specified - assume ( red, green, blue, alpha ) + if ( green !== undefined ) { + red = [ red, green, blue, alpha ]; + type = "array"; + } + + if ( type === "string" ) { + return this.parse( stringParse( red ) || colors._default ); + } + + if ( type === "array" ) { + each( spaces.rgba.props, function( key, prop ) { + rgba[ prop.idx ] = clamp( red[ prop.idx ], prop ); + }); + return this; + } + + if ( type === "object" ) { + if ( red instanceof color ) { + each( spaces, function( spaceName, space ) { + if ( red[ space.cache ] ) { + inst[ space.cache ] = red[ space.cache ].slice(); + } + }); + } else { + each( spaces, function( spaceName, space ) { + each( space.props, function( key, prop ) { + var cache = space.cache; + + // if the cache doesn't exist, and we know how to convert + if ( !inst[ cache ] && space.to ) { + + // if the value was null, we don't need to copy it + // if the key was alpha, we don't need to copy it either + if ( key === "alpha" || red[ key ] == null ) { + return; + } + inst[ cache ] = space.to( inst._rgba ); + } + + // this is the only case where we allow nulls for ALL properties. + // call clamp with alwaysAllowEmpty + inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true ); + }); + }); + } + return this; + } + }, + is: function( compare ) { + var is = color( compare ), + same = true, + inst = this; + + each( spaces, function( _, space ) { + var localCache, + isCache = is[ space.cache ]; + if (isCache) { + localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || []; + each( space.props, function( _, prop ) { + if ( isCache[ prop.idx ] != null ) { + same = ( isCache[ prop.idx ] === localCache[ prop.idx ] ); + return same; + } + }); + } + return same; + }); + return same; + }, + _space: function() { + var used = [], + inst = this; + each( spaces, function( spaceName, space ) { + if ( inst[ space.cache ] ) { + used.push( spaceName ); + } + }); + return used.pop(); + }, + transition: function( other, distance ) { + var end = color( other ), + spaceName = end._space(), + space = spaces[ spaceName ], + startColor = this.alpha() === 0 ? color( "transparent" ) : this, + start = startColor[ space.cache ] || space.to( startColor._rgba ), + result = start.slice(); + + end = end[ space.cache ]; + each( space.props, function( key, prop ) { + var index = prop.idx, + startValue = start[ index ], + endValue = end[ index ], + type = propTypes[ prop.type ] || {}; + + // if null, don't override start value + if ( endValue === null ) { + return; + } + // if null - use end + if ( startValue === null ) { + result[ index ] = endValue; + } else { + if ( type.mod ) { + if ( endValue - startValue > type.mod / 2 ) { + startValue += type.mod; + } else if ( startValue - endValue > type.mod / 2 ) { + startValue -= type.mod; + } + } + result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop ); + } + }); + return this[ spaceName ]( result ); + }, + blend: function( opaque ) { + // if we are already opaque - return ourself + if ( this._rgba[ 3 ] === 1 ) { + return this; + } + + var rgb = this._rgba.slice(), + a = rgb.pop(), + blend = color( opaque )._rgba; + + return color( jQuery.map( rgb, function( v, i ) { + return ( 1 - a ) * blend[ i ] + a * v; + })); + }, + toRgbaString: function() { + var prefix = "rgba(", + rgba = jQuery.map( this._rgba, function( v, i ) { + return v == null ? ( i > 2 ? 1 : 0 ) : v; + }); + + if ( rgba[ 3 ] === 1 ) { + rgba.pop(); + prefix = "rgb("; + } + + return prefix + rgba.join() + ")"; + }, + toHslaString: function() { + var prefix = "hsla(", + hsla = jQuery.map( this.hsla(), function( v, i ) { + if ( v == null ) { + v = i > 2 ? 1 : 0; + } + + // catch 1 and 2 + if ( i && i < 3 ) { + v = Math.round( v * 100 ) + "%"; + } + return v; + }); + + if ( hsla[ 3 ] === 1 ) { + hsla.pop(); + prefix = "hsl("; + } + return prefix + hsla.join() + ")"; + }, + toHexString: function( includeAlpha ) { + var rgba = this._rgba.slice(), + alpha = rgba.pop(); + + if ( includeAlpha ) { + rgba.push( ~~( alpha * 255 ) ); + } + + return "#" + jQuery.map( rgba, function( v, i ) { + + // default to 0 when nulls exist + v = ( v || 0 ).toString( 16 ); + return v.length === 1 ? "0" + v : v; + }).join(""); + }, + toString: function() { + return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString(); + } +}); +color.fn.parse.prototype = color.fn; + +// hsla conversions adapted from: +// https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021 + +function hue2rgb( p, q, h ) { + h = ( h + 1 ) % 1; + if ( h * 6 < 1 ) { + return p + (q - p) * h * 6; + } + if ( h * 2 < 1) { + return q; + } + if ( h * 3 < 2 ) { + return p + (q - p) * ((2/3) - h) * 6; + } + return p; +} + +spaces.hsla.to = function ( rgba ) { + if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) { + return [ null, null, null, rgba[ 3 ] ]; + } + var r = rgba[ 0 ] / 255, + g = rgba[ 1 ] / 255, + b = rgba[ 2 ] / 255, + a = rgba[ 3 ], + max = Math.max( r, g, b ), + min = Math.min( r, g, b ), + diff = max - min, + add = max + min, + l = add * 0.5, + h, s; + + if ( min === max ) { + h = 0; + } else if ( r === max ) { + h = ( 60 * ( g - b ) / diff ) + 360; + } else if ( g === max ) { + h = ( 60 * ( b - r ) / diff ) + 120; + } else { + h = ( 60 * ( r - g ) / diff ) + 240; + } + + if ( l === 0 || l === 1 ) { + s = l; + } else if ( l <= 0.5 ) { + s = diff / add; + } else { + s = diff / ( 2 - add ); + } + return [ Math.round(h) % 360, s, l, a == null ? 1 : a ]; +}; + +spaces.hsla.from = function ( hsla ) { + if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) { + return [ null, null, null, hsla[ 3 ] ]; + } + var h = hsla[ 0 ] / 360, + s = hsla[ 1 ], + l = hsla[ 2 ], + a = hsla[ 3 ], + q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s, + p = 2 * l - q, + r, g, b; + + return [ + Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ), + Math.round( hue2rgb( p, q, h ) * 255 ), + Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ), + a + ]; +}; + + +each( spaces, function( spaceName, space ) { + var props = space.props, + cache = space.cache, + to = space.to, + from = space.from; + + // makes rgba() and hsla() + color.fn[ spaceName ] = function( value ) { + + // generate a cache for this space if it doesn't exist + if ( to && !this[ cache ] ) { + this[ cache ] = to( this._rgba ); + } + if ( value === undefined ) { + return this[ cache ].slice(); + } + + var ret, + type = jQuery.type( value ), + arr = ( type === "array" || type === "object" ) ? value : arguments, + local = this[ cache ].slice(); + + each( props, function( key, prop ) { + var val = arr[ type === "object" ? key : prop.idx ]; + if ( val == null ) { + val = local[ prop.idx ]; + } + local[ prop.idx ] = clamp( val, prop ); + }); + + if ( from ) { + ret = color( from( local ) ); + ret[ cache ] = local; + return ret; + } else { + return color( local ); + } + }; + + // makes red() green() blue() alpha() hue() saturation() lightness() + each( props, function( key, prop ) { + // alpha is included in more than one space + if ( color.fn[ key ] ) { + return; + } + color.fn[ key ] = function( value ) { + var vtype = jQuery.type( value ), + fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ), + local = this[ fn ](), + cur = local[ prop.idx ], + match; + + if ( vtype === "undefined" ) { + return cur; + } + + if ( vtype === "function" ) { + value = value.call( this, cur ); + vtype = jQuery.type( value ); + } + if ( value == null && prop.empty ) { + return this; + } + if ( vtype === "string" ) { + match = rplusequals.exec( value ); + if ( match ) { + value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 ); + } + } + local[ prop.idx ] = value; + return this[ fn ]( local ); + }; + }); +}); + +// add .fx.step functions +each( stepHooks, function( i, hook ) { + jQuery.cssHooks[ hook ] = { + set: function( elem, value ) { + var parsed, backgroundColor, curElem; + + if ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) { + value = color( parsed || value ); + if ( !support.rgba && value._rgba[ 3 ] !== 1 ) { + curElem = hook === "backgroundColor" ? elem.parentNode : elem; + do { + backgroundColor = jQuery.css( curElem, "backgroundColor" ); + } while ( + ( backgroundColor === "" || backgroundColor === "transparent" ) && + ( curElem = curElem.parentNode ) && + curElem.style + ); + + value = value.blend( backgroundColor && backgroundColor !== "transparent" ? + backgroundColor : + "_default" ); + } + + value = value.toRgbaString(); + } + try { + elem.style[ hook ] = value; + } catch( value ) { + // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit' + } + } + }; + jQuery.fx.step[ hook ] = function( fx ) { + if ( !fx.colorInit ) { + fx.start = color( fx.elem, hook ); + fx.end = color( fx.end ); + fx.colorInit = true; + } + jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) ); + }; +}); + +// Basic color names only. +// Usage of any of the other color names requires adding yourself or including +// jquery.color.svg-names.js. +colors = jQuery.Color.names = { + // 4.1. Basic color keywords + aqua: "#00ffff", + black: "#000000", + blue: "#0000ff", + fuchsia: "#ff00ff", + gray: "#808080", + green: "#008000", + lime: "#00ff00", + maroon: "#800000", + navy: "#000080", + olive: "#808000", + purple: "#800080", + red: "#ff0000", + silver: "#c0c0c0", + teal: "#008080", + white: "#ffffff", + yellow: "#ffff00", + + // 4.2.3. ‘transparent’ color keyword + transparent: [ null, null, null, 0 ], + + _default: "#ffffff" +}; + +})( jQuery ); + + + +/******************************************************************************/ +/****************************** CLASS ANIMATIONS ******************************/ +/******************************************************************************/ +(function() { + +var classAnimationActions = [ "add", "remove", "toggle" ], + shorthandStyles = { + border: 1, + borderBottom: 1, + borderColor: 1, + borderLeft: 1, + borderRight: 1, + borderTop: 1, + borderWidth: 1, + margin: 1, + padding: 1 + }; + +$.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) { + $.fx.step[ prop ] = function( fx ) { + if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) { + jQuery.style( fx.elem, prop, fx.end ); + fx.setAttr = true; + } + }; +}); + +function getElementStyles() { + var style = this.ownerDocument.defaultView ? + this.ownerDocument.defaultView.getComputedStyle( this, null ) : + this.currentStyle, + newStyle = {}, + key, + camelCase, + len; + + // webkit enumerates style porperties + if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) { + len = style.length; + while ( len-- ) { + key = style[ len ]; + if ( typeof style[ key ] === "string" ) { + newStyle[ $.camelCase( key ) ] = style[ key ]; + } + } + } else { + for ( key in style ) { + if ( typeof style[ key ] === "string" ) { + newStyle[ key ] = style[ key ]; + } + } + } + + return newStyle; +} + + +function styleDifference( oldStyle, newStyle ) { + var diff = {}, + name, value; + + for ( name in newStyle ) { + value = newStyle[ name ]; + if ( oldStyle[ name ] !== value ) { + if ( !shorthandStyles[ name ] ) { + if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) { + diff[ name ] = value; + } + } + } + } + + return diff; +} + +$.effects.animateClass = function( value, duration, easing, callback ) { + var o = $.speed( duration, easing, callback ); + + return this.queue( function() { + var animated = $( this ), + baseClass = animated.attr( "class" ) || "", + applyClassChange, + allAnimations = o.children ? animated.find( "*" ).andSelf() : animated; + + // map the animated objects to store the original styles. + allAnimations = allAnimations.map(function() { + var el = $( this ); + return { + el: el, + start: getElementStyles.call( this ) + }; + }); + + // apply class change + applyClassChange = function() { + $.each( classAnimationActions, function(i, action) { + if ( value[ action ] ) { + animated[ action + "Class" ]( value[ action ] ); + } + }); + }; + applyClassChange(); + + // map all animated objects again - calculate new styles and diff + allAnimations = allAnimations.map(function() { + this.end = getElementStyles.call( this.el[ 0 ] ); + this.diff = styleDifference( this.start, this.end ); + return this; + }); + + // apply original class + animated.attr( "class", baseClass ); + + // map all animated objects again - this time collecting a promise + allAnimations = allAnimations.map(function() { + var styleInfo = this, + dfd = $.Deferred(), + opts = jQuery.extend({}, o, { + queue: false, + complete: function() { + dfd.resolve( styleInfo ); + } + }); + + this.el.animate( this.diff, opts ); + return dfd.promise(); + }); + + // once all animations have completed: + $.when.apply( $, allAnimations.get() ).done(function() { + + // set the final class + applyClassChange(); + + // for each animated element, + // clear all css properties that were animated + $.each( arguments, function() { + var el = this.el; + $.each( this.diff, function(key) { + el.css( key, '' ); + }); + }); + + // this is guarnteed to be there if you use jQuery.speed() + // it also handles dequeuing the next anim... + o.complete.call( animated[ 0 ] ); + }); + }); +}; + +$.fn.extend({ + _addClass: $.fn.addClass, + addClass: function( classNames, speed, easing, callback ) { + return speed ? + $.effects.animateClass.apply( this, [{ add: classNames }, speed, easing, callback ]) : + this._addClass(classNames); + }, + + _removeClass: $.fn.removeClass, + removeClass: function( classNames, speed, easing, callback ) { + return speed ? + $.effects.animateClass.apply( this, [{ remove: classNames }, speed, easing, callback ]) : + this._removeClass(classNames); + }, + + _toggleClass: $.fn.toggleClass, + toggleClass: function( classNames, force, speed, easing, callback ) { + if ( typeof force === "boolean" || force === undefined ) { + if ( !speed ) { + // without speed parameter; + return this._toggleClass( classNames, force ); + } else { + return $.effects.animateClass.apply( this, [( force ? { add:classNames } : { remove:classNames }), speed, easing, callback ]); + } + } else { + // without force parameter; + return $.effects.animateClass.apply( this, [{ toggle: classNames }, force, speed, easing ]); + } + }, + + switchClass: function( remove, add, speed, easing, callback) { + return $.effects.animateClass.apply( this, [{ + add: add, + remove: remove + }, speed, easing, callback ]); + } +}); + +})(); + +/******************************************************************************/ +/*********************************** EFFECTS **********************************/ +/******************************************************************************/ + +(function() { + +$.extend( $.effects, { + version: "@VERSION", + + // Saves a set of properties in a data storage + save: function( element, set ) { + for( var i=0; i < set.length; i++ ) { + if ( set[ i ] !== null ) { + element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] ); + } + } + }, + + // Restores a set of previously saved properties from a data storage + restore: function( element, set ) { + var val, i; + for( i=0; i < set.length; i++ ) { + if ( set[ i ] !== null ) { + val = element.data( dataSpace + set[ i ] ); + // support: jQuery 1.6.2 + // http://bugs.jquery.com/ticket/9917 + // jQuery 1.6.2 incorrectly returns undefined for any falsy value. + // We can't differentiate between "" and 0 here, so we just assume + // empty string since it's likely to be a more common value... + if ( val === undefined ) { + val = ""; + } + element.css( set[ i ], val ); + } + } + }, + + setMode: function( el, mode ) { + if (mode === "toggle") { + mode = el.is( ":hidden" ) ? "show" : "hide"; + } + return mode; + }, + + // Translates a [top,left] array into a baseline value + // this should be a little more flexible in the future to handle a string & hash + getBaseline: function( origin, original ) { + var y, x; + switch ( origin[ 0 ] ) { + case "top": y = 0; break; + case "middle": y = 0.5; break; + case "bottom": y = 1; break; + default: y = origin[ 0 ] / original.height; + } + switch ( origin[ 1 ] ) { + case "left": x = 0; break; + case "center": x = 0.5; break; + case "right": x = 1; break; + default: x = origin[ 1 ] / original.width; + } + return { + x: x, + y: y + }; + }, + + // Wraps the element around a wrapper that copies position properties + createWrapper: function( element ) { + + // if the element is already wrapped, return it + if ( element.parent().is( ".ui-effects-wrapper" )) { + return element.parent(); + } + + // wrap the element + var props = { + width: element.outerWidth(true), + height: element.outerHeight(true), + "float": element.css( "float" ) + }, + wrapper = $( "<div></div>" ) + .addClass( "ui-effects-wrapper" ) + .css({ + fontSize: "100%", + background: "transparent", + 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() + }, + active = document.activeElement; + + // support: Firefox + // Firefox incorrectly exposes anonymous content + // https://bugzilla.mozilla.org/show_bug.cgi?id=561664 + try { + active.id; + } catch( e ) { + active = document.body; + } + + element.wrap( wrapper ); + + // Fixes #7595 - Elements lose focus when wrapped. + if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { + $( active ).focus(); + } + + wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element + + // transfer positioning properties to the wrapper + if ( element.css( "position" ) === "static" ) { + wrapper.css({ position: "relative" }); + element.css({ position: "relative" }); + } else { + $.extend( props, { + position: element.css( "position" ), + zIndex: element.css( "z-index" ) + }); + $.each([ "top", "left", "bottom", "right" ], function(i, pos) { + props[ pos ] = element.css( pos ); + if ( isNaN( parseInt( props[ pos ], 10 ) ) ) { + props[ pos ] = "auto"; + } + }); + element.css({ + position: "relative", + top: 0, + left: 0, + right: "auto", + bottom: "auto" + }); + } + element.css(size); + + return wrapper.css( props ).show(); + }, + + removeWrapper: function( element ) { + var active = document.activeElement; + + if ( element.parent().is( ".ui-effects-wrapper" ) ) { + element.parent().replaceWith( element ); + + // Fixes #7595 - Elements lose focus when wrapped. + if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { + $( active ).focus(); + } + } + + + return element; + }, + + setTransition: function( element, list, factor, value ) { + value = value || {}; + $.each( list, function( i, x ) { + var unit = element.cssUnit( x ); + if ( unit[ 0 ] > 0 ) { + value[ x ] = unit[ 0 ] * factor + unit[ 1 ]; + } + }); + return value; + } +}); + +// return an effect options object for the given parameters: +function _normalizeArguments( effect, options, speed, callback ) { + + // allow passing all optinos as the first parameter + if ( $.isPlainObject( effect ) ) { + options = effect; + effect = effect.effect; + } + + // convert to an object + effect = { effect: effect }; + + // catch (effect) + if ( options === undefined ) { + options = {}; + } + + // catch (effect, callback) + if ( $.isFunction( options ) ) { + callback = options; + speed = null; + options = {}; + } + + // catch (effect, speed, ?) + if ( typeof options === "number" || $.fx.speeds[ options ] ) { + callback = speed; + speed = options; + options = {}; + } + + // catch (effect, options, callback) + if ( $.isFunction( speed ) ) { + callback = speed; + speed = null; + } + + // add options to effect + if ( options ) { + $.extend( effect, options ); + } + + speed = speed || options.duration; + effect.duration = $.fx.off ? 0 : + typeof speed === "number" ? speed : + speed in $.fx.speeds ? $.fx.speeds[ speed ] : + $.fx.speeds._default; + + effect.complete = callback || options.complete; + + return effect; +} + +function standardSpeed( speed ) { + // valid standard speeds + if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) { + return true; + } + + // invalid strings - treat as "normal" speed + if ( typeof speed === "string" && !$.effects.effect[ speed ] ) { + // TODO: remove in 2.0 (#7115) + if ( backCompat && $.effects[ speed ] ) { + return false; + } + return true; + } + + return false; +} + +$.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) + oldEffectMethod = !effectMethod && backCompat && $.effects[ args.effect ]; + + if ( $.fx.off || !( effectMethod || oldEffectMethod ) ) { + // delegate to the original method (e.g., .show()) if possible + if ( mode ) { + return this[ mode ]( args.duration, args.complete ); + } else { + return this.each( function() { + if ( args.complete ) { + args.complete.call( this ); + } + }); + } + } + + 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 queue === false ? this.each( run ) : this.queue( queue || "fx", run ); + } else { + // DEPRECATED: remove in 2.0 (#7115) + return oldEffectMethod.call(this, { + options: args, + duration: args.duration, + callback: args.complete, + mode: args.mode + }); + } + }, + + _show: $.fn.show, + show: function( speed ) { + if ( standardSpeed( speed ) ) { + return this._show.apply( this, arguments ); + } else { + var args = _normalizeArguments.apply( this, arguments ); + args.mode = "show"; + return this.effect.call( this, args ); + } + }, + + _hide: $.fn.hide, + hide: function( speed ) { + if ( standardSpeed( speed ) ) { + return this._hide.apply( this, arguments ); + } else { + var args = _normalizeArguments.apply( this, arguments ); + args.mode = "hide"; + return this.effect.call( this, args ); + } + }, + + // jQuery core overloads toggle and creates _toggle + __toggle: $.fn.toggle, + toggle: function( speed ) { + if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) { + return this.__toggle.apply( this, arguments ); + } else { + var args = _normalizeArguments.apply( this, arguments ); + args.mode = "toggle"; + return this.effect.call( this, args ); + } + }, + + // helper functions + cssUnit: function(key) { + var style = this.css( key ), + val = []; + + $.each( [ "em", "px", "%", "pt" ], function( i, unit ) { + if ( style.indexOf( unit ) > 0 ) { + val = [ parseFloat( style ), unit ]; + } + }); + return val; + } +}); + +})(); + +/******************************************************************************/ +/*********************************** EASING ***********************************/ +/******************************************************************************/ + +(function() { + +// based on easing equations from Robert Penner (http://www.robertpenner.com/easing) + +var baseEasings = {}; + +$.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) { + baseEasings[ name ] = function( p ) { + return Math.pow( p, i + 2 ); + }; +}); + +$.extend( baseEasings, { + Sine: function ( p ) { + return 1 - Math.cos( p * Math.PI / 2 ); + }, + Circ: function ( p ) { + return 1 - Math.sqrt( 1 - p * p ); + }, + Elastic: function( p ) { + return p === 0 || p === 1 ? p : + -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 ); + }, + Back: function( p ) { + return p * p * ( 3 * p - 2 ); + }, + Bounce: function ( p ) { + var pow2, + bounce = 4; + + while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {} + return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 ); + } +}); + +$.each( baseEasings, function( name, easeIn ) { + $.easing[ "easeIn" + name ] = easeIn; + $.easing[ "easeOut" + name ] = function( p ) { + return 1 - easeIn( 1 - p ); + }; + $.easing[ "easeInOut" + name ] = function( p ) { + return p < 0.5 ? + easeIn( p * 2 ) / 2 : + 1 - easeIn( p * -2 + 2 ) / 2; + }; +}); + +})(); + +})(jQuery)); diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 54a85abf5..81fef2e7c 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -1,7 +1,8 @@ /*! * jQuery UI Menu @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * @@ -10,8 +11,9 @@ * Depends: * jquery.ui.core.js * jquery.ui.widget.js + * jquery.ui.position.js */ -(function($) { +(function( $, undefined ) { var currentEventTarget = null; @@ -20,6 +22,9 @@ $.widget( "ui.menu", { defaultElement: "<ul>", delay: 300, options: { + icons: { + submenu: "ui-icon-carat-1-e" + }, menus: "ul", position: { my: "left top", @@ -32,6 +37,7 @@ $.widget( "ui.menu", { focus: null, select: null }, + _create: function() { this.activeMenu = this.element; this.element @@ -43,8 +49,8 @@ $.widget( "ui.menu", { tabIndex: 0 }) // need to catch all clicks on disabled menu - // not possible through _bind - .bind( "click.menu", $.proxy(function( event ) { + // not possible through _on + .bind( "click" + this.eventNamespace, $.proxy(function( event ) { if ( this.options.disabled ) { event.preventDefault(); } @@ -56,7 +62,7 @@ $.widget( "ui.menu", { .attr( "aria-disabled", "true" ); } - this._bind({ + this._on({ // Prevent focus from sticking to links inside menu after clicking // them (focus should always stay on UL during navigation). "mousedown .ui-menu-item > a": function( event ) { @@ -69,7 +75,10 @@ $.widget( "ui.menu", { var target = $( event.target ); if ( target[0] !== currentEventTarget ) { currentEventTarget = target[0]; - target.one( "click.menu", function( event ) { + // TODO: What are we trying to accomplish with this check? + // Clicking a menu item twice results in a select event with + // an empty ui.item. + target.one( "click" + this.eventNamespace, function( event ) { currentEventTarget = null; }); // Don't select disabled menu items @@ -94,20 +103,11 @@ $.widget( "ui.menu", { mouseleave: "collapseAll", "mouseleave .ui-menu": "collapseAll", focus: function( event ) { - var menu = this.element, - firstItem = menu.children( ".ui-menu-item" ).eq( 0 ); - if ( this._hasScroll() && !this.active ) { - menu.children().each(function() { - var currentItem = $( this ); - if ( currentItem.offset().top - menu.offset().top >= 0 ) { - firstItem = currentItem; - return false; - } - }); - } else if ( this.active ) { - firstItem = this.active; - } - this.focus( event, firstItem ); + // If there's already an active item, keep it active + // If not, activate the first item + var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 ); + + this.focus( event, item ); }, blur: function( event ) { this._delay(function() { @@ -121,9 +121,8 @@ $.widget( "ui.menu", { this.refresh(); - // TODO: We probably shouldn't bind to document for each menu. - // TODO: This isn't being cleaned up on destroy. - this._bind( this.document, { + // Clicks outside of a menu collapse any open menus + this._on( this.document, { click: function( event ) { if ( !$( event.target ).closest( ".ui-menu" ).length ) { this.collapseAll( event ); @@ -133,11 +132,11 @@ $.widget( "ui.menu", { }, _destroy: function() { - // destroy (sub)menus + // Destroy (sub)menus this.element .removeAttr( "aria-activedescendant" ) .find( ".ui-menu" ).andSelf() - .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) + .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" ) .removeAttr( "role" ) .removeAttr( "tabIndex" ) .removeAttr( "aria-labelledby" ) @@ -147,7 +146,7 @@ $.widget( "ui.menu", { .removeUniqueId() .show(); - // destroy menu items + // Destroy menu items this.element.find( ".ui-menu-item" ) .removeClass( "ui-menu-item" ) .removeAttr( "role" ) @@ -158,16 +157,22 @@ $.widget( "ui.menu", { .removeAttr( "tabIndex" ) .removeAttr( "role" ) .removeAttr( "aria-haspopup" ) - // TODO: is this correct? Don't these exist in the original markup? - .children( ".ui-icon" ) - .remove(); + .children().each( function() { + var elem = $( this ); + if ( elem.data( "ui-menu-submenu-carat" ) ) { + elem.remove(); + } + }); - // unbind currentEventTarget click event handler - $( currentEventTarget ).unbind( "click.menu" ); + // Destroy menu dividers + this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" ); + + // Unbind currentEventTarget click event handler + this._off( $( currentEventTarget ), "click" ); }, _keydown: function( event ) { - var match, prev, character, skip, + var match, prev, character, skip, regex, preventDefault = true; function escape( value ) { @@ -202,8 +207,6 @@ $.widget( "ui.menu", { } break; case $.ui.keyCode.ENTER: - this._activate( event ); - break; case $.ui.keyCode.SPACE: this._activate( event ); break; @@ -224,20 +227,21 @@ $.widget( "ui.menu", { character = prev + character; } + regex = new RegExp( "^" + escape( character ), "i" ); match = this.activeMenu.children( ".ui-menu-item" ).filter(function() { - return new RegExp( "^" + escape( character ), "i" ) - .test( $( this ).children( "a" ).text() ); + return regex.test( $( this ).children( "a" ).text() ); }); match = skip && match.index( this.active.next() ) !== -1 ? this.active.nextAll( ".ui-menu-item" ) : match; - // TODO: document what's going on here, character is reset to the original value + // If no matches on the current filter, reset to the last character pressed + // to move down the menu to the first item that starts with that character if ( !match.length ) { character = String.fromCharCode( event.keyCode ); + regex = new RegExp( "^" + escape( character ), "i" ); match = this.activeMenu.children( ".ui-menu-item" ).filter(function() { - return new RegExp( "^" + escape(character), "i" ) - .test( $( this ).children( "a" ).text() ); + return regex.test( $( this ).children( "a" ).text() ); }); } @@ -272,8 +276,9 @@ $.widget( "ui.menu", { }, refresh: function() { - // initialize nested menus + // Initialize nested menus var menus, + icon = this.options.icons.submenu, submenus = this.element.find( this.options.menus + ":not(.ui-menu)" ) .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" ) .hide() @@ -283,10 +288,10 @@ $.widget( "ui.menu", { "aria-expanded": "false" }); - // don't refresh list items that are already adapted + // Don't refresh list items that are already adapted menus = submenus.add( this.element ); - menus.children( ":not( .ui-menu-item ):has( a )" ) + menus.children( ":not(.ui-menu-item):has(a)" ) .addClass( "ui-menu-item" ) .attr( "role", "presentation" ) .children( "a" ) @@ -297,25 +302,28 @@ $.widget( "ui.menu", { role: this._itemRole() }); - // initialize unlinked menu-items containing spaces and/or dashes only as dividers - menus.children( ":not(.ui-menu-item)" ).each( function() { + // Initialize unlinked menu-items containing spaces and/or dashes only as dividers + menus.children( ":not(.ui-menu-item)" ).each(function() { var item = $( this ); - // hypen, em dash, en dash + // hyphen, em dash, en dash if ( !/[^\-—–\s]/.test( item.text() ) ) { item.addClass( "ui-widget-content ui-menu-divider" ); } }); - // add aria-disabled attribute to any disabled menu item + // Add aria-disabled attribute to any disabled menu item menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" ); submenus.each(function() { var menu = $( this ), - item = menu.prev( "a" ); + item = menu.prev( "a" ), + submenuCarat = $( "<span>" ) + .addClass( "ui-menu-icon ui-icon " + icon ) + .data( "ui-menu-submenu-carat", true ); item .attr( "aria-haspopup", "true" ) - .prepend( '<span class="ui-menu-icon ui-icon ui-icon-carat-1-e"></span>' ); + .prepend( submenuCarat ); menu.attr( "aria-labelledby", item.attr( "id" ) ); }); }, @@ -335,13 +343,13 @@ $.widget( "ui.menu", { this.active = item.first(); focused = this.active.children( "a" ).addClass( "ui-state-focus" ); - // only update aria-activedescendant if there's a role + // Only update aria-activedescendant if there's a role // otherwise we assume focus is managed elsewhere if ( this.options.role ) { this.element.attr( "aria-activedescendant", focused.attr( "id" ) ); } - // highlight active parent menu item, if any + // Highlight active parent menu item, if any this.active .parent() .closest( ".ui-menu-item" ) @@ -356,7 +364,7 @@ $.widget( "ui.menu", { }, this.delay ); } - nested = $( "> .ui-menu", item ); + nested = item.children( ".ui-menu" ); if ( nested.length && ( /^mouse/.test( event.type ) ) ) { this._startOpening(nested); } @@ -416,13 +424,10 @@ $.widget( "ui.menu", { _open: function( submenu ) { var position = $.extend({ of: this.active - }, $.type( this.options.position ) === "function" ? - this.options.position( this.active ) : - this.options.position - ); + }, this.options.position ); clearTimeout( this.timer ); - this.element.find( ".ui-menu" ).not( submenu.parents() ) + this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) ) .hide() .attr( "aria-hidden", "true" ); @@ -436,11 +441,11 @@ $.widget( "ui.menu", { collapseAll: function( event, all ) { clearTimeout( this.timer ); this.timer = this._delay(function() { - // if we were passed an event, look for the submenu that contains the event + // If we were passed an event, look for the submenu that contains the event var currentMenu = all ? this.element : $( event && event.target ).closest( this.element.find( ".ui-menu" ) ); - // if we found no valid submenu ancestor, use the main menu to close all sub menus anyway + // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway if ( !currentMenu.length ) { currentMenu = this.element; } @@ -475,7 +480,6 @@ $.widget( "ui.menu", { if ( newItem && newItem.length ) { this._close(); this.focus( event, newItem ); - return true; } }, @@ -489,11 +493,10 @@ $.widget( "ui.menu", { if ( newItem && newItem.length ) { this._open( newItem.parent() ); - // timeout so Firefox will not hide activedescendant change in expanding submenu from AT + // Delay so Firefox will not hide activedescendant change in expanding submenu from AT this._delay(function() { this.focus( event, newItem ); }, 20 ); - return true; } }, @@ -534,23 +537,24 @@ $.widget( "ui.menu", { }, nextPage: function( event ) { + var item, base, height; + if ( !this.active ) { - this._move( "next", "first", event ); + this.next( event ); return; } if ( this.isLastItem() ) { return; } if ( this._hasScroll() ) { - var base = this.active.offset().top, - height = this.element.height(), - result; + base = this.active.offset().top; + height = this.element.height(); this.active.nextAll( ".ui-menu-item" ).each(function() { - result = $( this ); - return $( this ).offset().top - base - height < 0; + item = $( this ); + return item.offset().top - base - height < 0; }); - this.focus( event, result ); + this.focus( event, item ); } else { this.focus( event, this.activeMenu.children( ".ui-menu-item" ) [ !this.active ? "first" : "last" ]() ); @@ -558,23 +562,23 @@ $.widget( "ui.menu", { }, previousPage: function( event ) { + var item, base, height; if ( !this.active ) { - this._move( "next", "first", event ); + this.next( event ); return; } if ( this.isFirstItem() ) { return; } if ( this._hasScroll() ) { - var base = this.active.offset().top, - height = this.element.height(), - result; + base = this.active.offset().top; + height = this.element.height(); this.active.prevAll( ".ui-menu-item" ).each(function() { - result = $( this ); - return $(this).offset().top - base + height > 0; + item = $( this ); + return item.offset().top - base + height > 0; }); - this.focus( event, result ); + this.focus( event, item ); } else { this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() ); } @@ -585,7 +589,7 @@ $.widget( "ui.menu", { }, select: function( event ) { - // save active reference before collapseAll triggers blur + // Save active reference before collapseAll triggers blur var ui = { item: this.active }; diff --git a/ui/jquery.ui.mouse.js b/ui/jquery.ui.mouse.js index e2e06897c..6f95765f2 100644 --- a/ui/jquery.ui.mouse.js +++ b/ui/jquery.ui.mouse.js @@ -1,7 +1,8 @@ /*! * jQuery UI Mouse @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * diff --git a/ui/jquery.ui.position.js b/ui/jquery.ui.position.js index bd7bfb015..2802b2ce0 100644 --- a/ui/jquery.ui.position.js +++ b/ui/jquery.ui.position.js @@ -1,7 +1,8 @@ /*! * jQuery UI Position @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js index 68cccc554..74a2d6923 100644 --- a/ui/jquery.ui.progressbar.js +++ b/ui/jquery.ui.progressbar.js @@ -1,7 +1,8 @@ /*! * jQuery UI Progressbar @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js index f9330e843..be174dd7e 100644 --- a/ui/jquery.ui.resizable.js +++ b/ui/jquery.ui.resizable.js @@ -1,7 +1,8 @@ /*! * jQuery UI Resizable @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * @@ -446,9 +447,6 @@ $.widget("ui.resizable", $.ui.mouse, { }); } - if ($.browser.msie && !(!($(element).is(':hidden') || $(element).parents(':hidden').length))) - continue; - prel.css({ height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0, width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0 diff --git a/ui/jquery.ui.selectable.js b/ui/jquery.ui.selectable.js index 2db9a8886..1da7fffa3 100644 --- a/ui/jquery.ui.selectable.js +++ b/ui/jquery.ui.selectable.js @@ -1,7 +1,8 @@ /*! * jQuery UI Selectable @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js index c302bfe8b..adceb356c 100644 --- a/ui/jquery.ui.slider.js +++ b/ui/jquery.ui.slider.js @@ -1,7 +1,8 @@ /*! * jQuery UI Slider @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * @@ -114,7 +115,7 @@ $.widget( "ui.slider", $.ui.mouse, { $( this ).data( "ui-slider-handle-index", i ); }); - this._bind( this.handles, { + this._on( this.handles, { keydown: function( event ) { var allowed, curVal, newVal, step, index = $( event.target ).data( "ui-slider-handle-index" ); diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js index 88c8aa374..7e5875200 100644 --- a/ui/jquery.ui.sortable.js +++ b/ui/jquery.ui.sortable.js @@ -1,7 +1,8 @@ /*! * jQuery UI Sortable @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * @@ -887,13 +888,13 @@ $.widget("ui.sortable", $.ui.mouse, { pos.top // The absolute mouse position + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border) - - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod) + - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod) ), left: ( pos.left // The absolute mouse position + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border) - - ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod) + - ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod) ) }; @@ -944,14 +945,14 @@ $.widget("ui.sortable", $.ui.mouse, { - this.offset.click.top // Click offset (relative to the element) - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.top // The offsetParent's offset without borders (offset + border) - + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )) + + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) )) ), left: ( pageX // The absolute mouse position - this.offset.click.left // Click offset (relative to the element) - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent - this.offset.parent.left // The offsetParent's offset without borders (offset + border) - + ($.browser.safari && this.cssPosition == 'fixed' ? 0 : ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )) + + ( ( this.cssPosition == 'fixed' ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() )) ) }; diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index b01feec9a..ead3b17be 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -1,7 +1,8 @@ /*! * jQuery UI Spinner @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * @@ -31,6 +32,10 @@ $.widget( "ui.spinner", { widgetEventPrefix: "spin", options: { culture: null, + icons: { + down: "ui-icon-triangle-1-s", + up: "ui-icon-triangle-1-n" + }, incremental: true, max: null, min: null, @@ -54,13 +59,13 @@ $.widget( "ui.spinner", { this._value( this.element.val(), true ); this._draw(); - this._bind( this._events ); + this._on( this._events ); this._refresh(); // turning off autocomplete prevents the browser from remembering the // value when navigating through history, so we re-enable autocomplete // if the page is unloaded before the widget is destroyed. #7790 - this._bind( this.window, { + this._on( this.window, { beforeunload: function() { this.element.removeAttr( "autocomplete" ); } @@ -243,10 +248,10 @@ $.widget( "ui.spinner", { _buttonHtml: function() { return "" + "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" + - "<span class='ui-icon ui-icon-triangle-1-n'>▲</span>" + + "<span class='ui-icon " + this.options.icons.up + "'>▲</span>" + "</a>" + "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" + - "<span class='ui-icon ui-icon-triangle-1-s'>▼</span>" + + "<span class='ui-icon " + this.options.icons.down + "'>▼</span>" + "</a>"; }, diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index a64dca6e4..588b8cdb2 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -1,7 +1,8 @@ /*! * jQuery UI Tabs @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * @@ -30,6 +31,7 @@ function isLocal( anchor ) { $.widget( "ui.tabs", { version: "@VERSION", + delay: 300, options: { active: null, collapsible: false, @@ -53,7 +55,26 @@ $.widget( "ui.tabs", { this.running = false; - this.element.addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" ); + this.element + .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" ) + .toggleClass( "ui-tabs-collapsible", options.collapsible ) + // Prevent users from focusing disabled tabs via click + .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) { + if ( $( this ).is( ".ui-state-disabled" ) ) { + event.preventDefault(); + } + }) + // support: IE <9 + // Preventing the default action in mousedown doesn't prevent IE + // from focusing the element, so if the anchor gets focused, blur. + // We don't have to worry about focusing the previously focused + // element since clicking on a non-focusable element should focus + // the body anyway. + .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() { + if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) { + this.blur(); + } + }); this._processTabs(); @@ -70,18 +91,18 @@ $.widget( "ui.tabs", { // check for a tab marked active via a class if ( active === null ) { - active = this.lis.filter( ".ui-tabs-active" ).index(); + active = this.tabs.filter( ".ui-tabs-active" ).index(); } // no active tab, set to false if ( active === null || active === -1 ) { - active = this.lis.length ? 0 : false; + active = this.tabs.length ? 0 : false; } } // handle numbers: negative, out of range if ( active !== false ) { - active = this.lis.eq( active ).index(); + active = this.tabs.eq( active ).index(); if ( active === -1 ) { active = options.collapsible ? false : 0; } @@ -97,28 +118,24 @@ $.widget( "ui.tabs", { // into account and update option properly. if ( $.isArray( options.disabled ) ) { options.disabled = $.unique( options.disabled.concat( - $.map( this.lis.filter( ".ui-state-disabled" ), function( li ) { - return that.lis.index( li ); + $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) { + return that.tabs.index( li ); }) ) ).sort(); } - this._refresh(); - - // highlight selected tab - this.panels.hide(); - this.lis.removeClass( "ui-tabs-active ui-state-active" ); // check for length avoids error when initializing empty list - if ( options.active !== false && this.anchors.length ) { - this.active = this._findActive( options.active ); - panel = this._getPanelForTab( this.active ); - - panel.show(); - this.lis.eq( options.active ).addClass( "ui-tabs-active ui-state-active" ); - this.load( options.active ); + if ( this.options.active !== false && this.anchors.length ) { + this.active = this._findActive( this.options.active ); } else { this.active = $(); } + + this._refresh(); + + if ( this.active.length ) { + this.load( options.active ); + } }, _getCreateEventData: function() { @@ -128,6 +145,117 @@ $.widget( "ui.tabs", { }; }, + _tabKeydown: function( event ) { + var focusedTab = $( this.document[0].activeElement ).closest( "li" ), + selectedIndex = this.tabs.index( focusedTab ), + goingForward = true; + + if ( this._handlePageNav( event ) ) { + return; + } + + switch ( event.keyCode ) { + case $.ui.keyCode.RIGHT: + case $.ui.keyCode.DOWN: + selectedIndex++; + break; + case $.ui.keyCode.UP: + case $.ui.keyCode.LEFT: + goingForward = false; + selectedIndex--; + break; + case $.ui.keyCode.END: + selectedIndex = this.anchors.length - 1; + break; + case $.ui.keyCode.HOME: + selectedIndex = 0; + break; + case $.ui.keyCode.SPACE: + // Activate only, no collapsing + event.preventDefault(); + clearTimeout( this.activating ); + this._activate( selectedIndex ); + return; + case $.ui.keyCode.ENTER: + // Toggle (cancel delayed activation, allow collapsing) + event.preventDefault(); + clearTimeout( this.activating ); + // Determine if we should collapse or activate + this._activate( selectedIndex === this.options.active ? false : selectedIndex ); + return; + default: + return; + } + + // Focus the appropriate tab, based on which key was pressed + event.preventDefault(); + clearTimeout( this.activating ); + selectedIndex = this._focusNextTab( selectedIndex, goingForward ); + + // Navigating with control key will prevent automatic activation + if ( !event.ctrlKey ) { + // Update aria-selected immediately so that AT think the tab is already selected. + // Otherwise AT may confuse the user by stating that they need to activate the tab, + // but the tab will already be activated by the time the announcement finishes. + focusedTab.attr( "aria-selected", "false" ); + this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" ); + + this.activating = this._delay(function() { + this.option( "active", selectedIndex ); + }, this.delay ); + } + }, + + _panelKeydown: function( event ) { + if ( this._handlePageNav( event ) ) { + return; + } + + // Ctrl+up moves focus to the current tab + if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) { + event.preventDefault(); + this.active.focus(); + } + }, + + // Alt+page up/down moves focus to the previous/next tab (and activates) + _handlePageNav: function( event ) { + if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) { + this._activate( this._focusNextTab( this.options.active - 1, false ) ); + return true; + } + if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) { + this._activate( this._focusNextTab( this.options.active + 1, true ) ); + return true; + } + }, + + _findNextTab: function( index, goingForward ) { + var lastTabIndex = this.tabs.length - 1; + + function constrain() { + if ( index > lastTabIndex ) { + index = 0; + } + if ( index < 0 ) { + index = lastTabIndex; + } + return index; + } + + while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) { + index = goingForward ? index + 1 : index - 1; + } + + return index; + }, + + _focusNextTab: function( index, goingForward ) { + index = this._findNextTab( index, goingForward ); + this.tabs.eq( index ).focus(); + return index; + }, + _setOption: function( key, value ) { if ( key === "active" ) { // _activate() will handle invalid values and update this.options @@ -143,9 +271,12 @@ $.widget( "ui.tabs", { this._super( key, value); - // setting collapsible: false while collapsed; open first panel - if ( key === "collapsible" && !value && this.options.active === false ) { - this._activate( 0 ); + if ( key === "collapsible" ) { + this.element.toggleClass( "ui-tabs-collapsible", value ); + // Setting collapsible: false while collapsed; open first panel + if ( !value && this.options.active === false ) { + this._activate( 0 ); + } } if ( key === "event" ) { @@ -168,7 +299,7 @@ $.widget( "ui.tabs", { refresh: function() { var next, options = this.options, - lis = this.list.children( ":has(a[href])" ); + lis = this.tablist.children( ":has(a[href])" ); // get disabled tabs from class attribute from HTML // this will get converted to a boolean if needed in _refresh() @@ -177,80 +308,128 @@ $.widget( "ui.tabs", { }); this._processTabs(); - this._refresh(); - this.panels.not( this._getPanelForTab( this.active ) ).hide(); // was collapsed or no tabs if ( options.active === false || !this.anchors.length ) { options.active = false; this.active = $(); // was active, but active tab is gone - } else if ( this.active.length && !$.contains( this.list[ 0 ], this.active[ 0 ] ) ) { + } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) { + // all remaining tabs are disabled + if ( this.tabs.length === options.disabled.length ) { + options.active = false; + this.active = $(); // activate previous tab - next = options.active - 1; - this._activate( next >= 0 ? next : 0 ); + } else { + this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) ); + } // was active, active tab still exists } else { // make sure active index is correct - options.active = this.lis.index( this.active ); + options.active = this.tabs.index( this.active ); } + + this._refresh(); }, _refresh: function() { - var options = this.options; - - this.element.toggleClass( "ui-tabs-collapsible", options.collapsible ); - this.list.addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" ); - this.lis.addClass( "ui-state-default ui-corner-top" ); - this.anchors.addClass( "ui-tabs-anchor" ); - this.panels.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ); - - this._setupDisabled( options.disabled ); - this._setupEvents( options.event ); - this._setupHeightStyle( options.heightStyle ); - - // remove all handlers, may run on existing tabs - this.lis.unbind( ".tabs" ); - this._focusable( this.lis ); - this._hoverable( this.lis ); + this._setupDisabled( this.options.disabled ); + this._setupEvents( this.options.event ); + this._setupHeightStyle( this.options.heightStyle ); + + this.tabs.not( this.active ).attr({ + "aria-selected": "false", + tabIndex: -1 + }); + this.panels.not( this._getPanelForTab( this.active ) ) + .hide() + .attr({ + "aria-expanded": "false", + "aria-hidden": "true" + }); + + // Make sure one tab is in the tab order + if ( !this.active.length ) { + this.tabs.eq( 0 ).attr( "tabIndex", 0 ); + } else { + this.active + .addClass( "ui-tabs-active ui-state-active" ) + .attr({ + "aria-selected": "true", + tabIndex: 0 + }); + this._getPanelForTab( this.active ) + .show() + .attr({ + "aria-expanded": "true", + "aria-hidden": "false" + }); + } }, _processTabs: function() { var that = this; - this.list = this._getList(); - this.lis = this.list.find( "> li:has(a[href])" ); - this.anchors = this.lis.map(function() { - return $( "a", this )[ 0 ]; - }); + this.tablist = this._getList() + .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" ) + .attr( "role", "tablist" ); + + this.tabs = this.tablist.find( "> li:has(a[href])" ) + .addClass( "ui-state-default ui-corner-top" ) + .attr({ + role: "tab", + tabIndex: -1 + }); + + this.anchors = this.tabs.map(function() { + return $( "a", this )[ 0 ]; + }) + .addClass( "ui-tabs-anchor" ) + .attr({ + role: "presentation", + tabIndex: -1 + }); + this.panels = $(); - this.anchors.each(function( i, a ) { - var selector, panel, id, - tab = $( a ).closest( "li" ); + this.anchors.each(function( i, anchor ) { + var selector, panel, panelId, + anchorId = $( anchor ).uniqueId().attr( "id" ), + tab = $( anchor ).closest( "li" ), + originalAriaControls = tab.attr( "aria-controls" ); // inline tab - if ( isLocal( a ) ) { - selector = a.hash; + if ( isLocal( anchor ) ) { + selector = anchor.hash; panel = that.element.find( that._sanitizeSelector( selector ) ); // remote tab } else { - id = that._tabId( tab ); - selector = "#" + id; + panelId = that._tabId( tab ); + selector = "#" + panelId; panel = that.element.find( selector ); if ( !panel.length ) { - panel = that._createPanel( id ); - panel.insertAfter( that.panels[ i - 1 ] || that.list ); + panel = that._createPanel( panelId ); + panel.insertAfter( that.panels[ i - 1 ] || that.tablist ); } + panel.attr( "aria-live", "polite" ); } if ( panel.length) { that.panels = that.panels.add( panel ); } - tab - .data( "ui-tabs-aria-controls", tab.attr( "aria-controls" ) ) - .attr( "aria-controls", selector.substring( 1 ) ); + if ( originalAriaControls ) { + tab.data( "ui-tabs-aria-controls", originalAriaControls ); + } + tab.attr({ + "aria-controls": selector.substring( 1 ), + "aria-labelledby": anchorId + }); + panel.attr( "aria-labelledby", anchorId ); }); + + this.panels + .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ) + .attr( "role", "tabpanel" ); }, // allow overriding how to find the list for rare usage scenarios (#7715) @@ -275,9 +454,16 @@ $.widget( "ui.tabs", { } // disable tabs - for ( var i = 0, li; ( li = this.lis[ i ] ); i++ ) { - $( li ).toggleClass( "ui-state-disabled", - ( disabled === true || $.inArray( i, disabled ) !== -1 ) ); + for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) { + if ( disabled === true || $.inArray( i, disabled ) !== -1 ) { + $( li ) + .addClass( "ui-state-disabled" ) + .attr( "aria-disabled", "true" ); + } else { + $( li ) + .removeClass( "ui-state-disabled" ) + .removeAttr( "aria-disabled" ); + } } this.options.disabled = disabled; @@ -294,8 +480,14 @@ $.widget( "ui.tabs", { events[ eventName ] = "_eventHandler"; }); } - this.anchors.unbind( ".tabs" ); - this._bind( this.anchors, events ); + + this._off( this.anchors.add( this.tabs ).add( this.panels ) ); + this._on( this.anchors, events ); + this._on( this.tabs, { keydown: "_tabKeydown" } ); + this._on( this.panels, { keydown: "_panelKeydown" } ); + + this._focusable( this.tabs ); + this._hoverable( this.tabs ); }, _setupHeightStyle: function( heightStyle ) { @@ -372,7 +564,7 @@ $.widget( "ui.tabs", { return; } - options.active = collapsing ? false : this.lis.index( tab ); + options.active = collapsing ? false : this.tabs.index( tab ); this.active = clickedIsActive ? $() : tab; if ( this.xhr ) { @@ -384,8 +576,7 @@ $.widget( "ui.tabs", { } if ( toShow.length ) { - // TODO make passing in node possible - this.load( this.lis.index( tab ), event ); + this.load( this.tabs.index( tab ), event ); } this._toggle( event, eventData ); }, @@ -425,6 +616,32 @@ $.widget( "ui.tabs", { toHide.hide(); show(); } + + toHide.attr({ + "aria-expanded": "false", + "aria-hidden": "true" + }); + eventData.oldTab.attr( "aria-selected", "false" ); + // If we're switching tabs, remove the old tab from the tab order. + // If we're opening from collapsed state, remove the previous tab from the tab order. + // If we're collapsing, then keep the collapsing tab in the tab order. + if ( toShow.length && toHide.length ) { + eventData.oldTab.attr( "tabIndex", -1 ); + } else if ( toShow.length ) { + this.tabs.filter(function() { + return $( this ).attr( "tabIndex" ) === 0; + }) + .attr( "tabIndex", -1 ); + } + + toShow.attr({ + "aria-expanded": "true", + "aria-hidden": "false" + }); + eventData.newTab.attr({ + "aria-selected": "true", + tabIndex: 0 + }); }, _activate: function( index ) { @@ -450,7 +667,7 @@ $.widget( "ui.tabs", { }, _findActive: function( index ) { - return index === false ? $() : this.lis.eq( index ); + return index === false ? $() : this.tabs.eq( index ); }, _getIndex: function( index ) { @@ -469,32 +686,37 @@ $.widget( "ui.tabs", { this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" ); - this.list.removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" ); + this.tablist + .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" ) + .removeAttr( "role" ); this.anchors .removeClass( "ui-tabs-anchor" ) - .unbind( ".tabs" ) + .removeAttr( "role" ) + .removeAttr( "tabIndex" ) .removeData( "href.tabs" ) - .removeData( "load.tabs" ); + .removeData( "load.tabs" ) + .removeUniqueId(); - this.lis.unbind( ".tabs" ).add( this.panels ).each(function() { + this.tabs.add( this.panels ).each(function() { if ( $.data( this, "ui-tabs-destroy" ) ) { $( this ).remove(); } else { - $( this ).removeClass([ - "ui-state-default", - "ui-corner-top", - "ui-tabs-active", - "ui-state-active", - "ui-state-disabled", - "ui-tabs-panel", - "ui-widget-content", - "ui-corner-bottom" - ].join( " " ) ); + $( this ) + .removeClass( "ui-state-default ui-state-active ui-state-disabled " + + "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" ) + .removeAttr( "tabIndex" ) + .removeAttr( "aria-live" ) + .removeAttr( "aria-busy" ) + .removeAttr( "aria-selected" ) + .removeAttr( "aria-labelledby" ) + .removeAttr( "aria-hidden" ) + .removeAttr( "aria-expanded" ) + .removeAttr( "role" ); } }); - this.lis.each(function() { + this.tabs.each(function() { var li = $( this ), prev = li.data( "ui-tabs-aria-controls" ); if ( prev ) { @@ -507,8 +729,6 @@ $.widget( "ui.tabs", { if ( this.options.heightStyle !== "content" ) { this.panels.css( "height", "" ); } - - return this; }, enable: function( index ) { @@ -526,7 +746,7 @@ $.widget( "ui.tabs", { return num !== index ? num : null; }); } else { - disabled = $.map( this.lis, function( li, num ) { + disabled = $.map( this.tabs, function( li, num ) { return num !== index ? num : null; }); } @@ -559,7 +779,7 @@ $.widget( "ui.tabs", { load: function( index, event ) { index = this._getIndex( index ); var that = this, - tab = this.lis.eq( index ), + tab = this.tabs.eq( index ), anchor = tab.find( ".ui-tabs-anchor" ), panel = this._getPanelForTab( tab ), eventData = { @@ -585,6 +805,7 @@ $.widget( "ui.tabs", { // but as of 1.8, $.ajax() always returns a jqXHR object. if ( this.xhr && this.xhr.statusText !== "canceled" ) { tab.addClass( "ui-tabs-loading" ); + panel.attr( "aria-busy", "true" ); this.xhr .success(function( response ) { @@ -604,6 +825,7 @@ $.widget( "ui.tabs", { } tab.removeClass( "ui-tabs-loading" ); + panel.removeAttr( "aria-busy" ); if ( jqXHR === that.xhr ) { delete that.xhr; @@ -650,7 +872,7 @@ if ( $.uiBackCompat !== false ) { var that = this; - this.element.bind( "tabsbeforeload.tabs", function( event, ui ) { + this._on({ tabsbeforeload: function( event, ui ) { // tab is already cached if ( $.data( ui.tab[ 0 ], "cache.tabs" ) ) { event.preventDefault(); @@ -675,7 +897,7 @@ if ( $.uiBackCompat !== false ) { $.data( ui.tab[ 0 ], "cache.tabs", true ); } }); - }); + }}); }, _setOption: function( key, value ) { @@ -713,7 +935,7 @@ if ( $.uiBackCompat !== false ) { }, _create: function() { this._super(); - this._bind({ + this._on({ tabsbeforeload: function( event, ui ) { if ( !this.options.spinner ) { return; @@ -795,7 +1017,7 @@ if ( $.uiBackCompat !== false ) { li.addClass( "ui-state-default ui-corner-top" ).data( "ui-tabs-destroy", true ); li.attr( "aria-controls", id ); - doInsertAfter = index >= this.lis.length; + doInsertAfter = index >= this.tabs.length; // try to find an existing element before creating a new one panel = this.element.find( "#" + id ); @@ -814,9 +1036,9 @@ if ( $.uiBackCompat !== false ) { panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ).hide(); if ( doInsertAfter ) { - li.appendTo( this.list ); + li.appendTo( this.tablist ); } else { - li.insertBefore( this.lis[ index ] ); + li.insertBefore( this.tabs[ index ] ); } options.disabled = $.map( options.disabled, function( n ) { @@ -824,7 +1046,7 @@ if ( $.uiBackCompat !== false ) { }); this.refresh(); - if ( this.lis.length === 1 && options.active === false ) { + if ( this.tabs.length === 1 && options.active === false ) { this.option( "active", 0 ); } @@ -835,7 +1057,7 @@ if ( $.uiBackCompat !== false ) { remove: function( index ) { index = this._getIndex( index ); var options = this.options, - tab = this.lis.eq( index ).remove(), + tab = this.tabs.eq( index ).remove(), panel = this._getPanelForTab( tab ).remove(); // If selected tab was removed focus tab to the right or @@ -981,7 +1203,7 @@ if ( $.uiBackCompat !== false ) { return; } } - this.anchors.eq( index ).trigger( this.options.event + ".tabs" ); + this.anchors.eq( index ).trigger( this.options.event + this.eventNamespace ); } }); diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 1892d6555..8bfe78c05 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -1,7 +1,8 @@ /*! * jQuery UI Tooltip @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * @@ -54,6 +55,7 @@ $.widget( "ui.tooltip", { }, show: true, tooltipClass: null, + track: false, // callbacks close: null, @@ -61,7 +63,7 @@ $.widget( "ui.tooltip", { }, _create: function() { - this._bind({ + this._on({ mouseover: "open", focusin: "open" }); @@ -117,8 +119,18 @@ $.widget( "ui.tooltip", { target = $( event ? event.target : this.element ) .closest( this.options.items ); - // if ui-tooltip-id exists, then the tooltip is already open - if ( !target.length || target.data( "ui-tooltip-id" ) ) { + // No element to show a tooltip for + if ( !target.length ) { + return; + } + + // If the tooltip is open and we're tracking then reposition the tooltip. + // This makes sure that a tracking tooltip doesn't obscure a focused element + // if the user was hovering when the element gained focused. + if ( this.options.track && target.data( "ui-tooltip-id" ) ) { + this._find( target ).position( $.extend({ + of: target + }, this.options.position ) ); return; } @@ -145,10 +157,19 @@ $.widget( "ui.tooltip", { }, _open: function( event, target, content ) { + var tooltip, positionOption; if ( !content ) { return; } + // Content can be updated multiple times. If the tooltip already + // exists, then just update the content and bail. + tooltip = this._find( target ); + if ( tooltip.length ) { + tooltip.find( ".ui-tooltip-content" ).html( content ); + return; + } + // if we have a title, clear it to prevent the native tooltip // we have to check first to avoid defining a title if none exists // (we don't want to cause an element to start matching [title]) @@ -164,25 +185,34 @@ $.widget( "ui.tooltip", { } } - // ajaxy tooltip can update an existing one - var tooltip = this._find( target ); - if ( !tooltip.length ) { - tooltip = this._tooltip( target ); - addDescribedBy( target, tooltip.attr( "id" ) ); - } + tooltip = this._tooltip( target ); + addDescribedBy( target, tooltip.attr( "id" ) ); tooltip.find( ".ui-tooltip-content" ).html( content ); - tooltip - .stop( true ) - .position( $.extend({ + + function position( event ) { + positionOption.of = event; + tooltip.position( positionOption ); + } + if ( this.options.track && /^mouse/.test( event.originalEvent.type ) ) { + positionOption = $.extend( {}, this.options.position ); + this._on( this.document, { + mousemove: position + }); + // trigger once to override element-relative positioning + position( event ); + } else { + tooltip.position( $.extend({ of: target - }, this.options.position ) ) - .hide(); + }, this.options.position ) ); + } + + tooltip.hide(); this._show( tooltip, this.options.show ); this._trigger( "open", event, { tooltip: tooltip } ); - this._bind( target, { + this._on( target, { mouseleave: "close", focusout: "close", keyup: function( event ) { @@ -230,7 +260,8 @@ $.widget( "ui.tooltip", { }); target.removeData( "tooltip-open" ); - target.unbind( "mouseleave.tooltip focusout.tooltip keyup.tooltip" ); + this._off( target, "mouseleave focusout keyup" ); + this._off( this.document, "mousemove" ); this.closing = true; this._trigger( "close", event, { tooltip: tooltip } ); diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 3e3723398..b5dfaa344 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -1,7 +1,8 @@ /*! * jQuery UI Widget @VERSION + * http://jqueryui.com * - * Copyright 2012, AUTHORS.txt (http://jqueryui.com/about) + * Copyright 2012 jQuery Foundation and other contributors * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * @@ -9,7 +10,8 @@ */ (function( $, undefined ) { -var slice = Array.prototype.slice, +var uuid = 0, + slice = Array.prototype.slice, _cleanData = $.cleanData; $.cleanData = function( elems ) { for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { @@ -34,7 +36,7 @@ $.widget = function( name, base, prototype ) { } // create selector for plugin - $.expr[ ":" ][ fullName ] = function( elem ) { + $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) { return !!$.data( elem, fullName ); }; @@ -210,6 +212,8 @@ $.Widget.prototype = { _createWidget: function( options, element ) { element = $( element || this.defaultElement || this )[ 0 ]; this.element = $( element ); + this.uuid = uuid++; + this.eventNamespace = "." + this.widgetName + this.uuid; this.options = $.widget.extend( {}, this.options, this._getCreateOptions(), @@ -224,7 +228,7 @@ $.Widget.prototype = { // TODO remove dual storage $.data( element, this.widgetName, this ); $.data( element, this.widgetFullName, this ); - this._bind({ remove: "destroy" }); + this._on({ remove: "destroy" }); this.document = $( element.style ? // element within the document element.ownerDocument : @@ -245,22 +249,25 @@ $.Widget.prototype = { destroy: function() { this._destroy(); // we can probably remove the unbind calls in 2.0 - // all event bindings should go through this._bind() + // all event bindings should go through this._on() this.element - .unbind( "." + this.widgetName ) + .unbind( this.eventNamespace ) // 1.9 BC for #7810 // TODO remove dual storage .removeData( this.widgetName ) - .removeData( this.widgetFullName ); + .removeData( this.widgetFullName ) + // support: jquery <1.6.3 + // http://bugs.jquery.com/ticket/9413 + .removeData( $.camelCase( this.widgetFullName ) ); this.widget() - .unbind( "." + this.widgetName ) + .unbind( this.eventNamespace ) .removeAttr( "aria-disabled" ) .removeClass( this.widgetFullName + "-disabled " + "ui-state-disabled" ); // clean up events and states - this.bindings.unbind( "." + this.widgetName ); + this.bindings.unbind( this.eventNamespace ); this.hoverable.removeClass( "ui-state-hover" ); this.focusable.removeClass( "ui-state-focus" ); }, @@ -339,7 +346,7 @@ $.Widget.prototype = { return this._setOption( "disabled", true ); }, - _bind: function( element, handlers ) { + _on: function( element, handlers ) { // no element argument, shuffle and use this.element if ( !handlers ) { handlers = element; @@ -367,11 +374,11 @@ $.Widget.prototype = { // copy the guid so direct unbinding works if ( typeof handler !== "string" ) { handlerProxy.guid = handler.guid = - handler.guid || handlerProxy.guid || jQuery.guid++; + handler.guid || handlerProxy.guid || $.guid++; } var match = event.match( /^(\w+)\s*(.*)$/ ), - eventName = match[1] + "." + instance.widgetName, + eventName = match[1] + instance.eventNamespace, selector = match[2]; if ( selector ) { instance.widget().delegate( selector, eventName, handlerProxy ); @@ -381,6 +388,11 @@ $.Widget.prototype = { }); }, + _off: function( element, eventName ) { + eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace; + element.unbind( eventName ).undelegate( eventName ); + }, + _delay: function( handler, delay ) { function handlerProxy() { return ( typeof handler === "string" ? instance[ handler ] : handler ) @@ -392,7 +404,7 @@ $.Widget.prototype = { _hoverable: function( element ) { this.hoverable = this.hoverable.add( element ); - this._bind( element, { + this._on( element, { mouseenter: function( event ) { $( event.currentTarget ).addClass( "ui-state-hover" ); }, @@ -404,7 +416,7 @@ $.Widget.prototype = { _focusable: function( element ) { this.focusable = this.focusable.add( element ); - this._bind( element, { + this._on( element, { focusin: function( event ) { $( event.currentTarget ).addClass( "ui-state-focus" ); }, |