summaryrefslogtreecommitdiff
path: root/lib/scripts/jquery/jquery-ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/scripts/jquery/jquery-ui.js')
-rwxr-xr-x[-rw-r--r--]lib/scripts/jquery/jquery-ui.js11873
1 files changed, 7509 insertions, 4364 deletions
diff --git a/lib/scripts/jquery/jquery-ui.js b/lib/scripts/jquery/jquery-ui.js
index cd515f361..2f83e5a2a 100644..100755
--- a/lib/scripts/jquery/jquery-ui.js
+++ b/lib/scripts/jquery/jquery-ui.js
@@ -1,14 +1,13 @@
-/*!
- * jQuery UI 1.8.16
- *
- * Copyright 2011, 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
- */
+/*! jQuery UI - v1.9.2 - 2012-11-23
+* http://jqueryui.com
+* Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.effect.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js, jquery.ui.menu.js, jquery.ui.position.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js
+* Copyright 2012 jQuery Foundation and other contributors; Licensed MIT */
+
(function( $, undefined ) {
+var uuid = 0,
+ runiqueId = /^ui-id-\d+$/;
+
// prevent duplicate loading
// this is only a problem because we proxy existing functions
// and we don't want to double proxy them
@@ -18,26 +17,18 @@ if ( $.ui.version ) {
}
$.extend( $.ui, {
- version: "1.8.16",
+ version: "1.9.2",
keyCode: {
- ALT: 18,
BACKSPACE: 8,
- CAPS_LOCK: 20,
COMMA: 188,
- COMMAND: 91,
- COMMAND_LEFT: 91, // COMMAND
- COMMAND_RIGHT: 93,
- CONTROL: 17,
DELETE: 46,
DOWN: 40,
END: 35,
ENTER: 13,
ESCAPE: 27,
HOME: 36,
- INSERT: 45,
LEFT: 37,
- MENU: 93, // COMMAND_RIGHT
NUMPAD_ADD: 107,
NUMPAD_DECIMAL: 110,
NUMPAD_DIVIDE: 111,
@@ -48,18 +39,14 @@ $.extend( $.ui, {
PAGE_UP: 33,
PERIOD: 190,
RIGHT: 39,
- SHIFT: 16,
SPACE: 32,
TAB: 9,
- UP: 38,
- WINDOWS: 91 // COMMAND
+ UP: 38
}
});
// plugins
$.fn.extend({
- propAttr: $.fn.prop || $.fn.attr,
-
_focus: $.fn.focus,
focus: function( delay, fn ) {
return typeof delay === "number" ?
@@ -77,13 +64,13 @@ $.fn.extend({
scrollParent: function() {
var scrollParent;
- if (($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
+ if (($.ui.ie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
scrollParent = this.parents().filter(function() {
- return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ return (/(relative|absolute|fixed)/).test($.css(this,'position')) && (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));
}).eq(0);
} else {
scrollParent = this.parents().filter(function() {
- return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
+ return (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));
}).eq(0);
}
@@ -119,95 +106,63 @@ $.fn.extend({
return 0;
},
- disableSelection: function() {
- return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
- ".ui-disableSelection", function( event ) {
- event.preventDefault();
- });
- },
-
- enableSelection: function() {
- return this.unbind( ".ui-disableSelection" );
- }
-});
-
-$.each( [ "Width", "Height" ], function( i, name ) {
- var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
- type = name.toLowerCase(),
- orig = {
- innerWidth: $.fn.innerWidth,
- innerHeight: $.fn.innerHeight,
- outerWidth: $.fn.outerWidth,
- outerHeight: $.fn.outerHeight
- };
-
- function reduce( elem, size, border, margin ) {
- $.each( side, function() {
- size -= parseFloat( $.curCSS( elem, "padding" + this, true) ) || 0;
- if ( border ) {
- size -= parseFloat( $.curCSS( elem, "border" + this + "Width", true) ) || 0;
- }
- if ( margin ) {
- size -= parseFloat( $.curCSS( elem, "margin" + this, true) ) || 0;
- }
- });
- return size;
- }
-
- $.fn[ "inner" + name ] = function( size ) {
- if ( size === undefined ) {
- return orig[ "inner" + name ].call( this );
- }
-
+ uniqueId: function() {
return this.each(function() {
- $( this ).css( type, reduce( this, size ) + "px" );
+ if ( !this.id ) {
+ this.id = "ui-id-" + (++uuid);
+ }
});
- };
-
- $.fn[ "outer" + name] = function( size, margin ) {
- if ( typeof size !== "number" ) {
- return orig[ "outer" + name ].call( this, size );
- }
+ },
+ removeUniqueId: function() {
return this.each(function() {
- $( this).css( type, reduce( this, size, true, margin ) + "px" );
+ if ( runiqueId.test( this.id ) ) {
+ $( this ).removeAttr( "id" );
+ }
});
- };
+ }
});
// selectors
function focusable( element, isTabIndexNotNaN ) {
- var nodeName = element.nodeName.toLowerCase();
+ var map, mapName, img,
+ nodeName = element.nodeName.toLowerCase();
if ( "area" === nodeName ) {
- var map = element.parentNode,
- mapName = map.name,
- img;
+ map = element.parentNode;
+ mapName = map.name;
if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
return false;
}
img = $( "img[usemap=#" + mapName + "]" )[0];
return !!img && visible( img );
}
- return ( /input|select|textarea|button|object/.test( nodeName )
- ? !element.disabled
- : "a" == nodeName
- ? element.href || isTabIndexNotNaN
- : isTabIndexNotNaN)
+ return ( /input|select|textarea|button|object/.test( nodeName ) ?
+ !element.disabled :
+ "a" === nodeName ?
+ element.href || isTabIndexNotNaN :
+ isTabIndexNotNaN) &&
// the element and all of its ancestors must be visible
- && visible( element );
+ visible( element );
}
function visible( element ) {
- return !$( element ).parents().andSelf().filter(function() {
- return $.curCSS( this, "visibility" ) === "hidden" ||
- $.expr.filters.hidden( this );
- }).length;
+ return $.expr.filters.visible( element ) &&
+ !$( element ).parents().andSelf().filter(function() {
+ return $.css( this, "visibility" ) === "hidden";
+ }).length;
}
$.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" ) ) );
@@ -225,6 +180,11 @@ $(function() {
var body = document.body,
div = body.appendChild( div = document.createElement( "div" ) );
+ // access offsetHeight before setting the style to prevent a layout bug
+ // in IE 9 which causes the element to continue to take up space even
+ // after it is removed from the DOM (#8026)
+ div.offsetHeight;
+
$.extend( div.style, {
minHeight: "100px",
height: "auto",
@@ -240,57 +200,134 @@ $(function() {
body.removeChild( div ).style.display = "none";
});
+// support: jQuery <1.8
+if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
+ $.each( [ "Width", "Height" ], function( i, name ) {
+ var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
+ type = name.toLowerCase(),
+ orig = {
+ innerWidth: $.fn.innerWidth,
+ innerHeight: $.fn.innerHeight,
+ outerWidth: $.fn.outerWidth,
+ outerHeight: $.fn.outerHeight
+ };
+
+ function reduce( elem, size, border, margin ) {
+ $.each( side, function() {
+ size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
+ if ( border ) {
+ size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
+ }
+ if ( margin ) {
+ size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
+ }
+ });
+ return size;
+ }
+
+ $.fn[ "inner" + name ] = function( size ) {
+ if ( size === undefined ) {
+ return orig[ "inner" + name ].call( this );
+ }
+
+ return this.each(function() {
+ $( this ).css( type, reduce( this, size ) + "px" );
+ });
+ };
+
+ $.fn[ "outer" + name] = function( size, margin ) {
+ if ( typeof size !== "number" ) {
+ return orig[ "outer" + name ].call( this, size );
+ }
+
+ return this.each(function() {
+ $( this).css( type, reduce( this, size, true, margin ) + "px" );
+ });
+ };
+ });
+}
+
+// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
+if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
+ $.fn.removeData = (function( removeData ) {
+ return function( key ) {
+ if ( arguments.length ) {
+ return removeData.call( this, $.camelCase( key ) );
+ } else {
+ return removeData.call( this );
+ }
+ };
+ })( $.fn.removeData );
+}
+
// deprecated
+
+(function() {
+ var uaMatch = /msie ([\w.]+)/.exec( navigator.userAgent.toLowerCase() ) || [];
+ $.ui.ie = uaMatch.length ? true : false;
+ $.ui.ie6 = parseFloat( uaMatch[ 1 ], 10 ) === 6;
+})();
+
+$.fn.extend({
+ disableSelection: function() {
+ return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
+ ".ui-disableSelection", function( event ) {
+ event.preventDefault();
+ });
+ },
+
+ enableSelection: function() {
+ return this.unbind( ".ui-disableSelection" );
+ }
+});
+
$.extend( $.ui, {
// $.ui.plugin is deprecated. Use the proxy pattern instead.
plugin: {
add: function( module, option, set ) {
- var proto = $.ui[ module ].prototype;
- for ( var i in set ) {
+ var i,
+ proto = $.ui[ module ].prototype;
+ for ( i in set ) {
proto.plugins[ i ] = proto.plugins[ i ] || [];
proto.plugins[ i ].push( [ option, set[ i ] ] );
}
},
call: function( instance, name, args ) {
- var set = instance.plugins[ name ];
- if ( !set || !instance.element[ 0 ].parentNode ) {
+ var i,
+ set = instance.plugins[ name ];
+ if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
return;
}
-
- for ( var i = 0; i < set.length; i++ ) {
+
+ for ( i = 0; i < set.length; i++ ) {
if ( instance.options[ set[ i ][ 0 ] ] ) {
set[ i ][ 1 ].apply( instance.element, args );
}
}
}
},
-
- // will be deprecated when we switch to jQuery 1.4 - use jQuery.contains()
- contains: function( a, b ) {
- return document.compareDocumentPosition ?
- a.compareDocumentPosition( b ) & 16 :
- a !== b && a.contains( b );
- },
-
+
+ contains: $.contains,
+
// only used by resizable
hasScroll: function( el, a ) {
-
+
//If overflow is hidden, the element might have extra content, but the user wants to hide it
if ( $( el ).css( "overflow" ) === "hidden") {
return false;
}
-
+
var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
has = false;
-
+
if ( el[ scroll ] > 0 ) {
return true;
}
-
+
// TODO: determine which cases actually cause this to happen
// if the element doesn't have the scroll set, see if it's possible to
// set the scroll
@@ -299,7 +336,7 @@ $.extend( $.ui, {
el[ scroll ] = 0;
return has;
},
-
+
// these are odd functions, fix the API or move into individual plugins
isOverAxis: function( x, reference, size ) {
//Determines when x coordinate is over "b" element axis
@@ -312,51 +349,26 @@ $.extend( $.ui, {
});
})( jQuery );
-/*!
- * jQuery UI Widget 1.8.16
- *
- * Copyright 2011, 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/Widget
- */
+
(function( $, undefined ) {
-// jQuery 1.4+
-if ( $.cleanData ) {
- var _cleanData = $.cleanData;
- $.cleanData = function( elems ) {
- for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
- try {
- $( elem ).triggerHandler( "remove" );
- // http://bugs.jquery.com/ticket/8235
- } catch( e ) {}
- }
- _cleanData( elems );
- };
-} else {
- var _remove = $.fn.remove;
- $.fn.remove = function( selector, keepData ) {
- return this.each(function() {
- if ( !keepData ) {
- if ( !selector || $.filter( selector, [ this ] ).length ) {
- $( "*", this ).add( [ this ] ).each(function() {
- try {
- $( this ).triggerHandler( "remove" );
- // http://bugs.jquery.com/ticket/8235
- } catch( e ) {}
- });
- }
- }
- return _remove.call( $(this), selector, keepData );
- });
- };
-}
+var uuid = 0,
+ slice = Array.prototype.slice,
+ _cleanData = $.cleanData;
+$.cleanData = function( elems ) {
+ for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
+ try {
+ $( elem ).triggerHandler( "remove" );
+ // http://bugs.jquery.com/ticket/8235
+ } catch( e ) {}
+ }
+ _cleanData( elems );
+};
$.widget = function( name, base, prototype ) {
- var namespace = name.split( "." )[ 0 ],
- fullName;
+ var fullName, existingConstructor, constructor, basePrototype,
+ namespace = name.split( "." )[ 0 ];
+
name = name.split( "." )[ 1 ];
fullName = namespace + "-" + name;
@@ -366,81 +378,167 @@ $.widget = function( name, base, prototype ) {
}
// create selector for plugin
- $.expr[ ":" ][ fullName ] = function( elem ) {
- return !!$.data( elem, name );
+ $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
+ return !!$.data( elem, fullName );
};
$[ namespace ] = $[ namespace ] || {};
- $[ namespace ][ name ] = function( options, element ) {
+ existingConstructor = $[ namespace ][ name ];
+ constructor = $[ namespace ][ name ] = function( options, element ) {
+ // allow instantiation without "new" keyword
+ if ( !this._createWidget ) {
+ return new constructor( options, element );
+ }
+
// allow instantiation without initializing for simple inheritance
+ // must use "new" keyword (the code above always passes args)
if ( arguments.length ) {
this._createWidget( options, element );
}
};
+ // extend with the existing constructor to carry over any static properties
+ $.extend( constructor, existingConstructor, {
+ version: prototype.version,
+ // copy the object used to create the prototype in case we need to
+ // redefine the widget later
+ _proto: $.extend( {}, prototype ),
+ // track widgets that inherit from this widget in case this widget is
+ // redefined after a widget inherits from it
+ _childConstructors: []
+ });
- var basePrototype = new base();
+ basePrototype = new base();
// we need to make the options hash a property directly on the new instance
// otherwise we'll modify the options hash on the prototype that we're
// inheriting from
-// $.each( basePrototype, function( key, val ) {
-// if ( $.isPlainObject(val) ) {
-// basePrototype[ key ] = $.extend( {}, val );
-// }
-// });
- basePrototype.options = $.extend( true, {}, basePrototype.options );
- $[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
+ basePrototype.options = $.widget.extend( {}, basePrototype.options );
+ $.each( prototype, function( prop, value ) {
+ if ( $.isFunction( value ) ) {
+ prototype[ prop ] = (function() {
+ var _super = function() {
+ return base.prototype[ prop ].apply( this, arguments );
+ },
+ _superApply = function( args ) {
+ return base.prototype[ prop ].apply( this, args );
+ };
+ return function() {
+ var __super = this._super,
+ __superApply = this._superApply,
+ returnValue;
+
+ this._super = _super;
+ this._superApply = _superApply;
+
+ returnValue = value.apply( this, arguments );
+
+ this._super = __super;
+ this._superApply = __superApply;
+
+ return returnValue;
+ };
+ })();
+ }
+ });
+ constructor.prototype = $.widget.extend( basePrototype, {
+ // TODO: remove support for widgetEventPrefix
+ // always use the name + a colon as the prefix, e.g., draggable:start
+ // don't prefix for widgets that aren't DOM-based
+ widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
+ }, prototype, {
+ constructor: constructor,
namespace: namespace,
widgetName: name,
- widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name,
- widgetBaseClass: fullName
- }, prototype );
+ // TODO remove widgetBaseClass, see #8155
+ widgetBaseClass: fullName,
+ widgetFullName: fullName
+ });
+
+ // If this widget is being redefined then we need to find all widgets that
+ // are inheriting from it and redefine all of them so that they inherit from
+ // the new version of this widget. We're essentially trying to replace one
+ // level in the prototype chain.
+ if ( existingConstructor ) {
+ $.each( existingConstructor._childConstructors, function( i, child ) {
+ var childPrototype = child.prototype;
+
+ // redefine the child widget using the same prototype that was
+ // originally used, but inherit from the new version of the base
+ $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
+ });
+ // remove the list of existing child constructors from the old constructor
+ // so the old child constructors can be garbage collected
+ delete existingConstructor._childConstructors;
+ } else {
+ base._childConstructors.push( constructor );
+ }
- $.widget.bridge( name, $[ namespace ][ name ] );
+ $.widget.bridge( name, constructor );
+};
+
+$.widget.extend = function( target ) {
+ var input = slice.call( arguments, 1 ),
+ inputIndex = 0,
+ inputLength = input.length,
+ key,
+ value;
+ for ( ; inputIndex < inputLength; inputIndex++ ) {
+ for ( key in input[ inputIndex ] ) {
+ value = input[ inputIndex ][ key ];
+ if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
+ // Clone objects
+ if ( $.isPlainObject( value ) ) {
+ target[ key ] = $.isPlainObject( target[ key ] ) ?
+ $.widget.extend( {}, target[ key ], value ) :
+ // Don't extend strings, arrays, etc. with objects
+ $.widget.extend( {}, value );
+ // Copy everything else by reference
+ } else {
+ target[ key ] = value;
+ }
+ }
+ }
+ }
+ return target;
};
$.widget.bridge = function( name, object ) {
+ var fullName = object.prototype.widgetFullName || name;
$.fn[ name ] = function( options ) {
var isMethodCall = typeof options === "string",
- args = Array.prototype.slice.call( arguments, 1 ),
+ args = slice.call( arguments, 1 ),
returnValue = this;
// allow multiple hashes to be passed on init
options = !isMethodCall && args.length ?
- $.extend.apply( null, [ true, options ].concat(args) ) :
+ $.widget.extend.apply( null, [ options ].concat(args) ) :
options;
- // prevent calls to internal methods
- if ( isMethodCall && options.charAt( 0 ) === "_" ) {
- return returnValue;
- }
-
if ( isMethodCall ) {
this.each(function() {
- var instance = $.data( this, name ),
- methodValue = instance && $.isFunction( instance[options] ) ?
- instance[ options ].apply( instance, args ) :
- instance;
- // TODO: add this back in 1.9 and use $.error() (see #5972)
-// if ( !instance ) {
-// throw "cannot call methods on " + name + " prior to initialization; " +
-// "attempted to call method '" + options + "'";
-// }
-// if ( !$.isFunction( instance[options] ) ) {
-// throw "no such method '" + options + "' for " + name + " widget instance";
-// }
-// var methodValue = instance[ options ].apply( instance, args );
+ var methodValue,
+ instance = $.data( this, fullName );
+ if ( !instance ) {
+ return $.error( "cannot call methods on " + name + " prior to initialization; " +
+ "attempted to call method '" + options + "'" );
+ }
+ if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
+ return $.error( "no such method '" + options + "' for " + name + " widget instance" );
+ }
+ methodValue = instance[ options ].apply( instance, args );
if ( methodValue !== instance && methodValue !== undefined ) {
- returnValue = methodValue;
+ returnValue = methodValue && methodValue.jquery ?
+ returnValue.pushStack( methodValue.get() ) :
+ methodValue;
return false;
}
});
} else {
this.each(function() {
- var instance = $.data( this, name );
+ var instance = $.data( this, fullName );
if ( instance ) {
instance.option( options || {} )._init();
} else {
- $.data( this, name, new object( options, this ) );
+ $.data( this, fullName, new object( options, this ) );
}
});
}
@@ -449,74 +547,126 @@ $.widget.bridge = function( name, object ) {
};
};
-$.Widget = function( options, element ) {
- // allow instantiation without initializing for simple inheritance
- if ( arguments.length ) {
- this._createWidget( options, element );
- }
-};
+$.Widget = function( /* options, element */ ) {};
+$.Widget._childConstructors = [];
$.Widget.prototype = {
widgetName: "widget",
widgetEventPrefix: "",
+ defaultElement: "<div>",
options: {
- disabled: false
+ disabled: false,
+
+ // callbacks
+ create: null
},
_createWidget: function( options, element ) {
- // $.widget.bridge stores the plugin instance, but we do it anyway
- // so that it's stored even before the _create function runs
- $.data( element, this.widgetName, this );
+ element = $( element || this.defaultElement || this )[ 0 ];
this.element = $( element );
- this.options = $.extend( true, {},
+ this.uuid = uuid++;
+ this.eventNamespace = "." + this.widgetName + this.uuid;
+ this.options = $.widget.extend( {},
this.options,
this._getCreateOptions(),
options );
- var self = this;
- this.element.bind( "remove." + this.widgetName, function() {
- self.destroy();
- });
+ this.bindings = $();
+ this.hoverable = $();
+ this.focusable = $();
+
+ if ( element !== this ) {
+ // 1.9 BC for #7810
+ // TODO remove dual storage
+ $.data( element, this.widgetName, this );
+ $.data( element, this.widgetFullName, this );
+ this._on( true, this.element, {
+ remove: function( event ) {
+ if ( event.target === element ) {
+ this.destroy();
+ }
+ }
+ });
+ this.document = $( element.style ?
+ // element within the document
+ element.ownerDocument :
+ // element is window or document
+ element.document || element );
+ this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
+ }
this._create();
- this._trigger( "create" );
+ this._trigger( "create", null, this._getCreateEventData() );
this._init();
},
- _getCreateOptions: function() {
- return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
- },
- _create: function() {},
- _init: function() {},
+ _getCreateOptions: $.noop,
+ _getCreateEventData: $.noop,
+ _create: $.noop,
+ _init: $.noop,
destroy: function() {
+ this._destroy();
+ // we can probably remove the unbind calls in 2.0
+ // all event bindings should go through this._on()
this.element
- .unbind( "." + this.widgetName )
- .removeData( this.widgetName );
+ .unbind( this.eventNamespace )
+ // 1.9 BC for #7810
+ // TODO remove dual storage
+ .removeData( this.widgetName )
+ .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.widgetBaseClass + "-disabled " +
+ this.widgetFullName + "-disabled " +
"ui-state-disabled" );
+
+ // clean up events and states
+ this.bindings.unbind( this.eventNamespace );
+ this.hoverable.removeClass( "ui-state-hover" );
+ this.focusable.removeClass( "ui-state-focus" );
},
+ _destroy: $.noop,
widget: function() {
return this.element;
},
option: function( key, value ) {
- var options = key;
+ var options = key,
+ parts,
+ curOption,
+ i;
if ( arguments.length === 0 ) {
// don't return a reference to the internal hash
- return $.extend( {}, this.options );
+ return $.widget.extend( {}, this.options );
}
- if (typeof key === "string" ) {
- if ( value === undefined ) {
- return this.options[ key ];
- }
+ if ( typeof key === "string" ) {
+ // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
options = {};
- options[ key ] = value;
+ parts = key.split( "." );
+ key = parts.shift();
+ if ( parts.length ) {
+ curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
+ for ( i = 0; i < parts.length - 1; i++ ) {
+ curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
+ curOption = curOption[ parts[ i ] ];
+ }
+ key = parts.pop();
+ if ( value === undefined ) {
+ return curOption[ key ] === undefined ? null : curOption[ key ];
+ }
+ curOption[ key ] = value;
+ } else {
+ if ( value === undefined ) {
+ return this.options[ key ] === undefined ? null : this.options[ key ];
+ }
+ options[ key ] = value;
+ }
}
this._setOptions( options );
@@ -524,10 +674,11 @@ $.Widget.prototype = {
return this;
},
_setOptions: function( options ) {
- var self = this;
- $.each( options, function( key, value ) {
- self._setOption( key, value );
- });
+ var key;
+
+ for ( key in options ) {
+ this._setOption( key, options[ key ] );
+ }
return this;
},
@@ -536,10 +687,10 @@ $.Widget.prototype = {
if ( key === "disabled" ) {
this.widget()
- [ value ? "addClass" : "removeClass"](
- this.widgetBaseClass + "-disabled" + " " +
- "ui-state-disabled" )
+ .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
.attr( "aria-disabled", value );
+ this.hoverable.removeClass( "ui-state-hover" );
+ this.focusable.removeClass( "ui-state-focus" );
}
return this;
@@ -552,46 +703,172 @@ $.Widget.prototype = {
return this._setOption( "disabled", true );
},
+ _on: function( suppressDisabledCheck, element, handlers ) {
+ var delegateElement,
+ instance = this;
+
+ // no suppressDisabledCheck flag, shuffle arguments
+ if ( typeof suppressDisabledCheck !== "boolean" ) {
+ handlers = element;
+ element = suppressDisabledCheck;
+ suppressDisabledCheck = false;
+ }
+
+ // no element argument, shuffle and use this.element
+ if ( !handlers ) {
+ handlers = element;
+ element = this.element;
+ delegateElement = this.widget();
+ } else {
+ // accept selectors, DOM elements
+ element = delegateElement = $( element );
+ this.bindings = this.bindings.add( element );
+ }
+
+ $.each( handlers, function( event, handler ) {
+ function handlerProxy() {
+ // allow widgets to customize the disabled handling
+ // - disabled as an array instead of boolean
+ // - disabled class as method for disabling individual parts
+ if ( !suppressDisabledCheck &&
+ ( instance.options.disabled === true ||
+ $( this ).hasClass( "ui-state-disabled" ) ) ) {
+ return;
+ }
+ return ( typeof handler === "string" ? instance[ handler ] : handler )
+ .apply( instance, arguments );
+ }
+
+ // copy the guid so direct unbinding works
+ if ( typeof handler !== "string" ) {
+ handlerProxy.guid = handler.guid =
+ handler.guid || handlerProxy.guid || $.guid++;
+ }
+
+ var match = event.match( /^(\w+)\s*(.*)$/ ),
+ eventName = match[1] + instance.eventNamespace,
+ selector = match[2];
+ if ( selector ) {
+ delegateElement.delegate( selector, eventName, handlerProxy );
+ } else {
+ element.bind( eventName, handlerProxy );
+ }
+ });
+ },
+
+ _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 )
+ .apply( instance, arguments );
+ }
+ var instance = this;
+ return setTimeout( handlerProxy, delay || 0 );
+ },
+
+ _hoverable: function( element ) {
+ this.hoverable = this.hoverable.add( element );
+ this._on( element, {
+ mouseenter: function( event ) {
+ $( event.currentTarget ).addClass( "ui-state-hover" );
+ },
+ mouseleave: function( event ) {
+ $( event.currentTarget ).removeClass( "ui-state-hover" );
+ }
+ });
+ },
+
+ _focusable: function( element ) {
+ this.focusable = this.focusable.add( element );
+ this._on( element, {
+ focusin: function( event ) {
+ $( event.currentTarget ).addClass( "ui-state-focus" );
+ },
+ focusout: function( event ) {
+ $( event.currentTarget ).removeClass( "ui-state-focus" );
+ }
+ });
+ },
+
_trigger: function( type, event, data ) {
- var callback = this.options[ type ];
+ var prop, orig,
+ callback = this.options[ type ];
+ data = data || {};
event = $.Event( event );
event.type = ( type === this.widgetEventPrefix ?
type :
this.widgetEventPrefix + type ).toLowerCase();
- data = data || {};
+ // the original event may come from any element
+ // so we need to reset the target on the new event
+ event.target = this.element[ 0 ];
// copy original event properties over to the new event
- // this would happen if we could call $.event.fix instead of $.Event
- // but we don't have a way to force an event to be fixed multiple times
- if ( event.originalEvent ) {
- for ( var i = $.event.props.length, prop; i; ) {
- prop = $.event.props[ --i ];
- event[ prop ] = event.originalEvent[ prop ];
+ orig = event.originalEvent;
+ if ( orig ) {
+ for ( prop in orig ) {
+ if ( !( prop in event ) ) {
+ event[ prop ] = orig[ prop ];
+ }
}
}
this.element.trigger( event, data );
-
- return !( $.isFunction(callback) &&
- callback.call( this.element[0], event, data ) === false ||
+ return !( $.isFunction( callback ) &&
+ callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
event.isDefaultPrevented() );
}
};
+$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
+ $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
+ if ( typeof options === "string" ) {
+ options = { effect: options };
+ }
+ var hasOptions,
+ effectName = !options ?
+ method :
+ options === true || typeof options === "number" ?
+ defaultEffect :
+ options.effect || defaultEffect;
+ options = options || {};
+ if ( typeof options === "number" ) {
+ options = { duration: options };
+ }
+ hasOptions = !$.isEmptyObject( options );
+ options.complete = callback;
+ if ( options.delay ) {
+ element.delay( options.delay );
+ }
+ if ( hasOptions && $.effects && ( $.effects.effect[ effectName ] || $.uiBackCompat !== false && $.effects[ effectName ] ) ) {
+ element[ method ]( options );
+ } else if ( effectName !== method && element[ effectName ] ) {
+ element[ effectName ]( options.duration, options.easing, callback );
+ } else {
+ element.queue(function( next ) {
+ $( this )[ method ]();
+ if ( callback ) {
+ callback.call( element[ 0 ] );
+ }
+ next();
+ });
+ }
+ };
+});
+
+// DEPRECATED
+if ( $.uiBackCompat !== false ) {
+ $.Widget.prototype._getCreateOptions = function() {
+ return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
+ };
+}
+
})( jQuery );
-/*!
- * jQuery UI Mouse 1.8.16
- *
- * Copyright 2011, 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/Mouse
- *
- * Depends:
- * jquery.ui.widget.js
- */
+
(function( $, undefined ) {
var mouseHandled = false;
@@ -600,21 +877,22 @@ $( document ).mouseup( function( e ) {
});
$.widget("ui.mouse", {
+ version: "1.9.2",
options: {
- cancel: ':input,option',
+ cancel: 'input,textarea,button,select,option',
distance: 1,
delay: 0
},
_mouseInit: function() {
- var self = this;
+ var that = this;
this.element
.bind('mousedown.'+this.widgetName, function(event) {
- return self._mouseDown(event);
+ return that._mouseDown(event);
})
.bind('click.'+this.widgetName, function(event) {
- if (true === $.data(event.target, self.widgetName + '.preventClickEvent')) {
- $.removeData(event.target, self.widgetName + '.preventClickEvent');
+ if (true === $.data(event.target, that.widgetName + '.preventClickEvent')) {
+ $.removeData(event.target, that.widgetName + '.preventClickEvent');
event.stopImmediatePropagation();
return false;
}
@@ -627,22 +905,27 @@ $.widget("ui.mouse", {
// other instances of mouse
_mouseDestroy: function() {
this.element.unbind('.'+this.widgetName);
+ if ( this._mouseMoveDelegate ) {
+ $(document)
+ .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
+ .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
+ }
},
_mouseDown: function(event) {
// don't let more than one widget handle mouseStart
- if( mouseHandled ) { return };
+ if( mouseHandled ) { return; }
// we may have missed mouseup (out of window)
(this._mouseStarted && this._mouseUp(event));
this._mouseDownEvent = event;
- var self = this,
- btnIsLeft = (event.which == 1),
+ var that = this,
+ btnIsLeft = (event.which === 1),
// event.target.nodeName works around a bug in IE 8 with
// disabled inputs (#7620)
- elIsCancel = (typeof this.options.cancel == "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
+ elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
return true;
}
@@ -650,7 +933,7 @@ $.widget("ui.mouse", {
this.mouseDelayMet = !this.options.delay;
if (!this.mouseDelayMet) {
this._mouseDelayTimer = setTimeout(function() {
- self.mouseDelayMet = true;
+ that.mouseDelayMet = true;
}, this.options.delay);
}
@@ -669,24 +952,24 @@ $.widget("ui.mouse", {
// these delegates are required to keep context
this._mouseMoveDelegate = function(event) {
- return self._mouseMove(event);
+ return that._mouseMove(event);
};
this._mouseUpDelegate = function(event) {
- return self._mouseUp(event);
+ return that._mouseUp(event);
};
$(document)
.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
event.preventDefault();
-
+
mouseHandled = true;
return true;
},
_mouseMove: function(event) {
// IE mouseup check - mouseup happened when mouse was out of window
- if ($.browser.msie && !(document.documentMode >= 9) && !event.button) {
+ if ($.ui.ie && !(document.documentMode >= 9) && !event.button) {
return this._mouseUp(event);
}
@@ -712,8 +995,8 @@ $.widget("ui.mouse", {
if (this._mouseStarted) {
this._mouseStarted = false;
- if (event.target == this._mouseDownEvent.target) {
- $.data(event.target, this.widgetName + '.preventClickEvent', true);
+ if (event.target === this._mouseDownEvent.target) {
+ $.data(event.target, this.widgetName + '.preventClickEvent', true);
}
this._mouseStop(event);
@@ -742,23 +1025,11 @@ $.widget("ui.mouse", {
});
})(jQuery);
-/*
- * jQuery UI Draggable 1.8.16
- *
- * Copyright 2011, 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/Draggables
- *
- * Depends:
- * jquery.ui.core.js
- * jquery.ui.mouse.js
- * jquery.ui.widget.js
- */
+
(function( $, undefined ) {
$.widget("ui.draggable", $.ui.mouse, {
+ version: "1.9.2",
widgetEventPrefix: "drag",
options: {
addClasses: true,
@@ -798,17 +1069,9 @@ $.widget("ui.draggable", $.ui.mouse, {
},
- destroy: function() {
- if(!this.element.data('draggable')) return;
- this.element
- .removeData("draggable")
- .unbind(".draggable")
- .removeClass("ui-draggable"
- + " ui-draggable-dragging"
- + " ui-draggable-disabled");
+ _destroy: function() {
+ this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
this._mouseDestroy();
-
- return this;
},
_mouseCapture: function(event) {
@@ -823,18 +1086,16 @@ $.widget("ui.draggable", $.ui.mouse, {
this.handle = this._getHandle(event);
if (!this.handle)
return false;
-
- if ( o.iframeFix ) {
- $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
- $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
- .css({
- width: this.offsetWidth+"px", height: this.offsetHeight+"px",
- position: "absolute", opacity: "0.001", zIndex: 1000
- })
- .css($(this).offset())
- .appendTo("body");
- });
- }
+
+ $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
+ $('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>')
+ .css({
+ width: this.offsetWidth+"px", height: this.offsetHeight+"px",
+ position: "absolute", opacity: "0.001", zIndex: 1000
+ })
+ .css($(this).offset())
+ .appendTo("body");
+ });
return true;
@@ -847,6 +1108,8 @@ $.widget("ui.draggable", $.ui.mouse, {
//Create and append the visible helper
this.helper = this._createHelper(event);
+ this.helper.addClass("ui-draggable-dragging");
+
//Cache the helper size
this._cacheHelperProportions();
@@ -907,12 +1170,12 @@ $.widget("ui.draggable", $.ui.mouse, {
if ($.ui.ddmanager && !o.dropBehaviour)
$.ui.ddmanager.prepareOffsets(this, event);
- this.helper.addClass("ui-draggable-dragging");
+
this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
-
+
//If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
if ( $.ui.ddmanager ) $.ui.ddmanager.dragStart(this, event);
-
+
return true;
},
@@ -951,16 +1214,22 @@ $.widget("ui.draggable", $.ui.mouse, {
dropped = this.dropped;
this.dropped = false;
}
-
- //if the original element is removed, don't bother to continue if helper is set to "original"
- if((!this.element[0] || !this.element[0].parentNode) && this.options.helper == "original")
+
+ //if the original element is no longer in the DOM don't bother to continue (see #8269)
+ var element = this.element[0], elementInDom = false;
+ while ( element && (element = element.parentNode) ) {
+ if (element == document ) {
+ elementInDom = true;
+ }
+ }
+ if ( !elementInDom && this.options.helper === "original" )
return false;
if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
- var self = this;
+ var that = this;
$(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
- if(self._trigger("stop", event) !== false) {
- self._clear();
+ if(that._trigger("stop", event) !== false) {
+ that._clear();
}
});
} else {
@@ -971,30 +1240,29 @@ $.widget("ui.draggable", $.ui.mouse, {
return false;
},
-
+
_mouseUp: function(event) {
- if (this.options.iframeFix === true) {
- $("div.ui-draggable-iframeFix").each(function() {
- this.parentNode.removeChild(this);
- }); //Remove frame helpers
- }
-
+ //Remove frame helpers
+ $("div.ui-draggable-iframeFix").each(function() {
+ this.parentNode.removeChild(this);
+ });
+
//If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
if( $.ui.ddmanager ) $.ui.ddmanager.dragStop(this, event);
-
+
return $.ui.mouse.prototype._mouseUp.call(this, event);
},
-
+
cancel: function() {
-
+
if(this.helper.is(".ui-draggable-dragging")) {
this._mouseUp({});
} else {
this._clear();
}
-
+
return this;
-
+
},
_getHandle: function(event) {
@@ -1057,13 +1325,13 @@ $.widget("ui.draggable", $.ui.mouse, {
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
- if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
+ if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
po.left += this.scrollParent.scrollLeft();
po.top += this.scrollParent.scrollTop();
}
if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
- || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
+ || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.ui.ie)) //Ugly IE fix
po = { top: 0, left: 0 };
return {
@@ -1115,7 +1383,7 @@ $.widget("ui.draggable", $.ui.mouse, {
];
if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) {
- var c = $(o.containment);
+ var c = $(o.containment);
var ce = c[0]; if(!ce) return;
var co = c.offset();
var over = ($(ce).css("overflow") != 'hidden');
@@ -1138,20 +1406,20 @@ $.widget("ui.draggable", $.ui.mouse, {
if(!pos) pos = this.position;
var mod = d == "absolute" ? 1 : -1;
- var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
return {
top: (
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)
)
};
@@ -1159,7 +1427,7 @@ $.widget("ui.draggable", $.ui.mouse, {
_generatePosition: function(event) {
- var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
var pageX = event.pageX;
var pageY = event.pageY;
@@ -1169,18 +1437,18 @@ $.widget("ui.draggable", $.ui.mouse, {
*/
if(this.originalPosition) { //If we are not dragging yet, we won't check for options
- var containment;
- if(this.containment) {
- if (this.relative_container){
- var co = this.relative_container.offset();
- containment = [ this.containment[0] + co.left,
- this.containment[1] + co.top,
- this.containment[2] + co.left,
- this.containment[3] + co.top ];
- }
- else {
- containment = this.containment;
- }
+ var containment;
+ if(this.containment) {
+ if (this.relative_container){
+ var co = this.relative_container.offset();
+ containment = [ this.containment[0] + co.left,
+ this.containment[1] + co.top,
+ this.containment[2] + co.left,
+ this.containment[3] + co.top ];
+ }
+ else {
+ containment = this.containment;
+ }
if(event.pageX - this.offset.click.left < containment[0]) pageX = containment[0] + this.offset.click.left;
if(event.pageY - this.offset.click.top < containment[1]) pageY = containment[1] + this.offset.click.top;
@@ -1205,14 +1473,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() ))
)
};
@@ -1248,10 +1516,6 @@ $.widget("ui.draggable", $.ui.mouse, {
});
-$.extend($.ui.draggable, {
- version: "1.8.16"
-});
-
$.ui.plugin.add("draggable", "connectToSortable", {
start: function(event, ui) {
@@ -1307,7 +1571,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
},
drag: function(event, ui) {
- var inst = $(this).data("draggable"), self = this;
+ var inst = $(this).data("draggable"), that = this;
var checkPos = function(o) {
var dyClick = this.offset.click.top, dxClick = this.offset.click.left;
@@ -1319,14 +1583,30 @@ $.ui.plugin.add("draggable", "connectToSortable", {
};
$.each(inst.sortables, function(i) {
-
+
+ var innermostIntersecting = false;
+ var thisSortable = this;
//Copy over some variables to allow calling the sortable's native _intersectsWith
this.instance.positionAbs = inst.positionAbs;
this.instance.helperProportions = inst.helperProportions;
this.instance.offset.click = inst.offset.click;
-
+
if(this.instance._intersectsWith(this.instance.containerCache)) {
+ innermostIntersecting = true;
+ $.each(inst.sortables, function () {
+ this.instance.positionAbs = inst.positionAbs;
+ this.instance.helperProportions = inst.helperProportions;
+ this.instance.offset.click = inst.offset.click;
+ if (this != thisSortable
+ && this.instance._intersectsWith(this.instance.containerCache)
+ && $.ui.contains(thisSortable.instance.element[0], this.instance.element[0]))
+ innermostIntersecting = false;
+ return innermostIntersecting;
+ });
+ }
+
+ if(innermostIntersecting) {
//If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
if(!this.instance.isOver) {
@@ -1334,7 +1614,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
//Now we fake the start of dragging for the sortable instance,
//by cloning the list group item, appending it to the sortable and using it as inst.currentItem
//We can then fire the start event of the sortable with our passed browser event, and our own helper (so it doesn't create a new one)
- this.instance.currentItem = $(self).clone().removeAttr('id').appendTo(this.instance.element).data("sortable-item", true);
+ this.instance.currentItem = $(that).clone().removeAttr('id').appendTo(this.instance.element).data("sortable-item", true);
this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
this.instance.options.helper = function() { return ui.helper[0]; };
@@ -1367,13 +1647,13 @@ $.ui.plugin.add("draggable", "connectToSortable", {
this.instance.isOver = 0;
this.instance.cancelHelperRemoval = true;
-
+
//Prevent reverting on this forced stop
this.instance.options.revert = false;
-
+
// The out event needs to be triggered independently
this.instance._trigger('out', event, this.instance._uiHash(this.instance));
-
+
this.instance._mouseStop(event, true);
this.instance.options.helper = this.instance.options._helper;
@@ -1543,7 +1823,7 @@ $.ui.plugin.add("draggable", "stack", {
return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
});
if (!group.length) { return; }
-
+
var min = parseInt(group[0].style.zIndex) || 0;
$(group).each(function(i) {
this.style.zIndex = min + i;
@@ -1567,24 +1847,11 @@ $.ui.plugin.add("draggable", "zIndex", {
});
})(jQuery);
-/*
- * jQuery UI Droppable 1.8.16
- *
- * Copyright 2011, 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/Droppables
- *
- * Depends:
- * jquery.ui.core.js
- * jquery.ui.widget.js
- * jquery.ui.mouse.js
- * jquery.ui.draggable.js
- */
+
(function( $, undefined ) {
$.widget("ui.droppable", {
+ version: "1.9.2",
widgetEventPrefix: "drop",
options: {
accept: '*',
@@ -1615,18 +1882,13 @@ $.widget("ui.droppable", {
},
- destroy: function() {
+ _destroy: function() {
var drop = $.ui.ddmanager.droppables[this.options.scope];
for ( var i = 0; i < drop.length; i++ )
if ( drop[i] == this )
drop.splice(i, 1);
- this.element
- .removeClass("ui-droppable ui-droppable-disabled")
- .removeData("droppable")
- .unbind(".droppable");
-
- return this;
+ this.element.removeClass("ui-droppable ui-droppable-disabled");
},
_setOption: function(key, value) {
@@ -1715,10 +1977,6 @@ $.widget("ui.droppable", {
});
-$.extend($.ui.droppable, {
- version: "1.8.16"
-});
-
$.ui.intersect = function(draggable, droppable, toleranceMode) {
if (!droppable.offset) return false;
@@ -1796,7 +2054,7 @@ $.ui.ddmanager = {
if(!this.options) return;
if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
- dropped = dropped || this._drop.call(this, event);
+ dropped = this._drop.call(this, event) || dropped;
if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
this.isout = 1; this.isover = 0;
@@ -1809,7 +2067,7 @@ $.ui.ddmanager = {
},
dragStart: function( draggable, event ) {
//Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
- draggable.element.parents( ":not(body,html)" ).bind( "scroll.droppable", function() {
+ draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
});
},
@@ -1829,7 +2087,12 @@ $.ui.ddmanager = {
var parentInstance;
if (this.options.greedy) {
- var parent = this.element.parents(':data(droppable):eq(0)');
+ // find droppable parents with same scope
+ var scope = this.options.scope;
+ var parent = this.element.parents(':data(droppable)').filter(function () {
+ return $.data(this, 'droppable').options.scope === scope;
+ });
+
if (parent.length) {
parentInstance = $.data(parent[0], 'droppable');
parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
@@ -1856,30 +2119,18 @@ $.ui.ddmanager = {
},
dragStop: function( draggable, event ) {
- draggable.element.parents( ":not(body,html)" ).unbind( "scroll.droppable" );
+ draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
//Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event );
}
};
})(jQuery);
-/*
- * jQuery UI Resizable 1.8.16
- *
- * Copyright 2011, 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/Resizables
- *
- * Depends:
- * jquery.ui.core.js
- * jquery.ui.mouse.js
- * jquery.ui.widget.js
- */
+
(function( $, undefined ) {
$.widget("ui.resizable", $.ui.mouse, {
+ version: "1.9.2",
widgetEventPrefix: "resize",
options: {
alsoResize: false,
@@ -1901,7 +2152,7 @@ $.widget("ui.resizable", $.ui.mouse, {
},
_create: function() {
- var self = this, o = this.options;
+ var that = this, o = this.options;
this.element.addClass("ui-resizable");
$.extend(this, {
@@ -1915,10 +2166,6 @@ $.widget("ui.resizable", $.ui.mouse, {
//Wrap the element if it cannot hold child nodes
if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
- //Opera fix for relative positioning
- if (/relative/.test(this.element.css('position')) && $.browser.opera)
- this.element.css({ position: 'relative', top: 'auto', left: 'auto' });
-
//Create a wrapper element and set the wrapper to the new current internal element
this.element.wrap(
$('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({
@@ -1967,9 +2214,8 @@ $.widget("ui.resizable", $.ui.mouse, {
var handle = $.trim(n[i]), hname = 'ui-resizable-'+handle;
var axis = $('<div class="ui-resizable-handle ' + hname + '"></div>');
- // increase zIndex of sw, se, ne, nw axis
- //TODO : this modifies original option
- if(/sw|se|ne|nw/.test(handle)) axis.css({ zIndex: ++o.zIndex });
+ // Apply zIndex to all handles - see #7960
+ axis.css({ zIndex: o.zIndex });
//TODO : What's going on here?
if ('se' == handle) {
@@ -2027,11 +2273,11 @@ $.widget("ui.resizable", $.ui.mouse, {
//Matching axis name
this._handles.mouseover(function() {
- if (!self.resizing) {
+ if (!that.resizing) {
if (this.className)
var axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
//Axis, default = se
- self.axis = axis && axis[1] ? axis[1] : 'se';
+ that.axis = axis && axis[1] ? axis[1] : 'se';
}
});
@@ -2040,16 +2286,16 @@ $.widget("ui.resizable", $.ui.mouse, {
this._handles.hide();
$(this.element)
.addClass("ui-resizable-autohide")
- .hover(function() {
+ .mouseenter(function() {
if (o.disabled) return;
$(this).removeClass("ui-resizable-autohide");
- self._handles.show();
- },
- function(){
+ that._handles.show();
+ })
+ .mouseleave(function(){
if (o.disabled) return;
- if (!self.resizing) {
+ if (!that.resizing) {
$(this).addClass("ui-resizable-autohide");
- self._handles.hide();
+ that._handles.hide();
}
});
}
@@ -2059,28 +2305,27 @@ $.widget("ui.resizable", $.ui.mouse, {
},
- destroy: function() {
+ _destroy: function() {
this._mouseDestroy();
var _destroy = function(exp) {
$(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
- .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
+ .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find('.ui-resizable-handle').remove();
};
//TODO: Unwrap at same DOM position
if (this.elementIsWrapper) {
_destroy(this.element);
var wrapper = this.element;
- wrapper.after(
- this.originalElement.css({
- position: wrapper.css('position'),
- width: wrapper.outerWidth(),
- height: wrapper.outerHeight(),
- top: wrapper.css('top'),
- left: wrapper.css('left')
- })
- ).remove();
+ this.originalElement.css({
+ position: wrapper.css('position'),
+ width: wrapper.outerWidth(),
+ height: wrapper.outerHeight(),
+ top: wrapper.css('top'),
+ left: wrapper.css('left')
+ }).insertAfter( wrapper );
+ wrapper.remove();
}
this.originalElement.css('resize', this.originalResizeStyle);
@@ -2112,10 +2357,6 @@ $.widget("ui.resizable", $.ui.mouse, {
el.css({ position: 'absolute', top: iniPos.top, left: iniPos.left });
}
- //Opera fixing relative position
- if ($.browser.opera && (/relative/).test(el.css('position')))
- el.css({ position: 'relative', top: 'auto', left: 'auto' });
-
this._renderProxy();
var curleft = num(this.helper.css('left')), curtop = num(this.helper.css('top'));
@@ -2137,8 +2378,8 @@ $.widget("ui.resizable", $.ui.mouse, {
//Aspect Ratio
this.aspectRatio = (typeof o.aspectRatio == 'number') ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
- var cursor = $('.ui-resizable-' + this.axis).css('cursor');
- $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor);
+ var cursor = $('.ui-resizable-' + this.axis).css('cursor');
+ $('body').css('cursor', cursor == 'auto' ? this.axis + '-resize' : cursor);
el.addClass("ui-resizable-resizing");
this._propagate("start", event);
@@ -2149,14 +2390,14 @@ $.widget("ui.resizable", $.ui.mouse, {
//Increase performance, avoid regex
var el = this.helper, o = this.options, props = {},
- self = this, smp = this.originalMousePosition, a = this.axis;
+ that = this, smp = this.originalMousePosition, a = this.axis;
var dx = (event.pageX-smp.left)||0, dy = (event.pageY-smp.top)||0;
var trigger = this._change[a];
if (!trigger) return false;
// Calculate the attrs that will be change
- var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff;
+ var data = trigger.apply(this, [event, dx, dy]);
// Put this in the mouseDrag handler since the user can start pressing shift while resizing
this._updateVirtualBoundaries(event.shiftKey);
@@ -2187,22 +2428,22 @@ $.widget("ui.resizable", $.ui.mouse, {
_mouseStop: function(event) {
this.resizing = false;
- var o = this.options, self = this;
+ var o = this.options, that = this;
if(this._helper) {
var pr = this._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
- soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
- soffsetw = ista ? 0 : self.sizeDiff.width;
+ soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
+ soffsetw = ista ? 0 : that.sizeDiff.width;
- var s = { width: (self.helper.width() - soffsetw), height: (self.helper.height() - soffseth) },
- left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
- top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
+ var s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) },
+ left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null,
+ top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
if (!o.animate)
this.element.css($.extend(s, { top: top, left: left }));
- self.helper.height(self.size.height);
- self.helper.width(self.size.width);
+ that.helper.height(that.size.height);
+ that.helper.width(that.size.width);
if (this._helper && !o.animate) this._proportionallyResize();
}
@@ -2218,31 +2459,31 @@ $.widget("ui.resizable", $.ui.mouse, {
},
- _updateVirtualBoundaries: function(forceAspectRatio) {
- var o = this.options, pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b;
+ _updateVirtualBoundaries: function(forceAspectRatio) {
+ var o = this.options, pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b;
- b = {
- minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
- maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
- minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
- maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
- };
+ b = {
+ minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
+ maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
+ minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
+ maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
+ };
- if(this._aspectRatio || forceAspectRatio) {
- // We want to create an enclosing box whose aspect ration is the requested one
- // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
- pMinWidth = b.minHeight * this.aspectRatio;
- pMinHeight = b.minWidth / this.aspectRatio;
- pMaxWidth = b.maxHeight * this.aspectRatio;
- pMaxHeight = b.maxWidth / this.aspectRatio;
+ if(this._aspectRatio || forceAspectRatio) {
+ // We want to create an enclosing box whose aspect ration is the requested one
+ // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
+ pMinWidth = b.minHeight * this.aspectRatio;
+ pMinHeight = b.minWidth / this.aspectRatio;
+ pMaxWidth = b.maxHeight * this.aspectRatio;
+ pMaxHeight = b.maxWidth / this.aspectRatio;
- if(pMinWidth > b.minWidth) b.minWidth = pMinWidth;
- if(pMinHeight > b.minHeight) b.minHeight = pMinHeight;
- if(pMaxWidth < b.maxWidth) b.maxWidth = pMaxWidth;
- if(pMaxHeight < b.maxHeight) b.maxHeight = pMaxHeight;
- }
- this._vBoundaries = b;
- },
+ if(pMinWidth > b.minWidth) b.minWidth = pMinWidth;
+ if(pMinHeight > b.minHeight) b.minHeight = pMinHeight;
+ if(pMaxWidth < b.maxWidth) b.maxWidth = pMaxWidth;
+ if(pMaxHeight < b.maxHeight) b.maxHeight = pMaxHeight;
+ }
+ this._vBoundaries = b;
+ },
_updateCache: function(data) {
var o = this.options;
@@ -2319,9 +2560,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
@@ -2341,8 +2579,8 @@ $.widget("ui.resizable", $.ui.mouse, {
this.helper = this.helper || $('<div style="overflow:hidden;"></div>');
// fix ie6 offset TODO: This seems broken
- var ie6 = $.browser.msie && $.browser.version < 7, ie6offset = (ie6 ? 1 : 0),
- pxyoffset = ( ie6 ? 2 : -1 );
+ var ie6offset = ($.ui.ie6 ? 1 : 0),
+ pxyoffset = ( $.ui.ie6 ? 2 : -1 );
this.helper.addClass(this._helper).css({
width: this.element.outerWidth() + pxyoffset,
@@ -2413,10 +2651,6 @@ $.widget("ui.resizable", $.ui.mouse, {
});
-$.extend($.ui.resizable, {
- version: "1.8.16"
-});
-
/*
* Resizable Extensions
*/
@@ -2424,15 +2658,14 @@ $.extend($.ui.resizable, {
$.ui.plugin.add("resizable", "alsoResize", {
start: function (event, ui) {
- var self = $(this).data("resizable"), o = self.options;
+ var that = $(this).data("resizable"), o = that.options;
var _store = function (exp) {
$(exp).each(function() {
var el = $(this);
el.data("resizable-alsoresize", {
width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
- left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10),
- position: el.css('position') // to reset Opera on stop()
+ left: parseInt(el.css('left'), 10), top: parseInt(el.css('top'), 10)
});
});
};
@@ -2446,16 +2679,16 @@ $.ui.plugin.add("resizable", "alsoResize", {
},
resize: function (event, ui) {
- var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition;
+ var that = $(this).data("resizable"), o = that.options, os = that.originalSize, op = that.originalPosition;
var delta = {
- height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0,
- top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0
+ height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
+ top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
},
_alsoResize = function (exp, c) {
$(exp).each(function() {
- var el = $(this), start = $(this).data("resizable-alsoresize"), style = {},
+ var el = $(this), start = $(this).data("resizable-alsoresize"), style = {},
css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ['width', 'height'] : ['width', 'height', 'top', 'left'];
$.each(css, function (i, prop) {
@@ -2464,12 +2697,6 @@ $.ui.plugin.add("resizable", "alsoResize", {
style[prop] = sum || null;
});
- // Opera fixing relative position
- if ($.browser.opera && /relative/.test(el.css('position'))) {
- self._revertToRelativePosition = true;
- el.css({ position: 'absolute', top: 'auto', left: 'auto' });
- }
-
el.css(style);
});
};
@@ -2482,25 +2709,6 @@ $.ui.plugin.add("resizable", "alsoResize", {
},
stop: function (event, ui) {
- var self = $(this).data("resizable"), o = self.options;
-
- var _reset = function (exp) {
- $(exp).each(function() {
- var el = $(this);
- // reset position for Opera - no need to verify it was changed
- el.css({ position: el.data("resizable-alsoresize").position });
- });
- };
-
- if (self._revertToRelativePosition) {
- self._revertToRelativePosition = false;
- if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) {
- $.each(o.alsoResize, function (exp) { _reset(exp); });
- }else{
- _reset(o.alsoResize);
- }
- }
-
$(this).removeData("resizable-alsoresize");
}
});
@@ -2508,34 +2716,34 @@ $.ui.plugin.add("resizable", "alsoResize", {
$.ui.plugin.add("resizable", "animate", {
stop: function(event, ui) {
- var self = $(this).data("resizable"), o = self.options;
+ var that = $(this).data("resizable"), o = that.options;
- var pr = self._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
- soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : self.sizeDiff.height,
- soffsetw = ista ? 0 : self.sizeDiff.width;
+ var pr = that._proportionallyResizeElements, ista = pr.length && (/textarea/i).test(pr[0].nodeName),
+ soffseth = ista && $.ui.hasScroll(pr[0], 'left') /* TODO - jump height */ ? 0 : that.sizeDiff.height,
+ soffsetw = ista ? 0 : that.sizeDiff.width;
- var style = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) },
- left = (parseInt(self.element.css('left'), 10) + (self.position.left - self.originalPosition.left)) || null,
- top = (parseInt(self.element.css('top'), 10) + (self.position.top - self.originalPosition.top)) || null;
+ var style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
+ left = (parseInt(that.element.css('left'), 10) + (that.position.left - that.originalPosition.left)) || null,
+ top = (parseInt(that.element.css('top'), 10) + (that.position.top - that.originalPosition.top)) || null;
- self.element.animate(
+ that.element.animate(
$.extend(style, top && left ? { top: top, left: left } : {}), {
duration: o.animateDuration,
easing: o.animateEasing,
step: function() {
var data = {
- width: parseInt(self.element.css('width'), 10),
- height: parseInt(self.element.css('height'), 10),
- top: parseInt(self.element.css('top'), 10),
- left: parseInt(self.element.css('left'), 10)
+ width: parseInt(that.element.css('width'), 10),
+ height: parseInt(that.element.css('height'), 10),
+ top: parseInt(that.element.css('top'), 10),
+ left: parseInt(that.element.css('left'), 10)
};
if (pr && pr.length) $(pr[0]).css({ width: data.width, height: data.height });
// propagating resize, and updating values for each animation step
- self._updateCache(data);
- self._propagate("resize", event);
+ that._updateCache(data);
+ that._propagate("resize", event);
}
}
@@ -2547,17 +2755,17 @@ $.ui.plugin.add("resizable", "animate", {
$.ui.plugin.add("resizable", "containment", {
start: function(event, ui) {
- var self = $(this).data("resizable"), o = self.options, el = self.element;
+ var that = $(this).data("resizable"), o = that.options, el = that.element;
var oc = o.containment, ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
if (!ce) return;
- self.containerElement = $(ce);
+ that.containerElement = $(ce);
if (/document/.test(oc) || oc == document) {
- self.containerOffset = { left: 0, top: 0 };
- self.containerPosition = { left: 0, top: 0 };
+ that.containerOffset = { left: 0, top: 0 };
+ that.containerPosition = { left: 0, top: 0 };
- self.parentData = {
+ that.parentData = {
element: $(document), left: 0, top: 0,
width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
};
@@ -2568,70 +2776,70 @@ $.ui.plugin.add("resizable", "containment", {
var element = $(ce), p = [];
$([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
- self.containerOffset = element.offset();
- self.containerPosition = element.position();
- self.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
+ that.containerOffset = element.offset();
+ that.containerPosition = element.position();
+ that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
- var co = self.containerOffset, ch = self.containerSize.height, cw = self.containerSize.width,
+ var co = that.containerOffset, ch = that.containerSize.height, cw = that.containerSize.width,
width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw ), height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
- self.parentData = {
+ that.parentData = {
element: ce, left: co.left, top: co.top, width: width, height: height
};
}
},
resize: function(event, ui) {
- var self = $(this).data("resizable"), o = self.options,
- ps = self.containerSize, co = self.containerOffset, cs = self.size, cp = self.position,
- pRatio = self._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = self.containerElement;
+ var that = $(this).data("resizable"), o = that.options,
+ ps = that.containerSize, co = that.containerOffset, cs = that.size, cp = that.position,
+ pRatio = that._aspectRatio || event.shiftKey, cop = { top:0, left:0 }, ce = that.containerElement;
if (ce[0] != document && (/static/).test(ce.css('position'))) cop = co;
- if (cp.left < (self._helper ? co.left : 0)) {
- self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left));
- if (pRatio) self.size.height = self.size.width / o.aspectRatio;
- self.position.left = o.helper ? co.left : 0;
+ if (cp.left < (that._helper ? co.left : 0)) {
+ that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
+ if (pRatio) that.size.height = that.size.width / that.aspectRatio;
+ that.position.left = o.helper ? co.left : 0;
}
- if (cp.top < (self._helper ? co.top : 0)) {
- self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top);
- if (pRatio) self.size.width = self.size.height * o.aspectRatio;
- self.position.top = self._helper ? co.top : 0;
+ if (cp.top < (that._helper ? co.top : 0)) {
+ that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
+ if (pRatio) that.size.width = that.size.height * that.aspectRatio;
+ that.position.top = that._helper ? co.top : 0;
}
- self.offset.left = self.parentData.left+self.position.left;
- self.offset.top = self.parentData.top+self.position.top;
+ that.offset.left = that.parentData.left+that.position.left;
+ that.offset.top = that.parentData.top+that.position.top;
- var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ),
- hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height );
+ var woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width ),
+ hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
- var isParent = self.containerElement.get(0) == self.element.parent().get(0),
- isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position'));
+ var isParent = that.containerElement.get(0) == that.element.parent().get(0),
+ isOffsetRelative = /relative|absolute/.test(that.containerElement.css('position'));
- if(isParent && isOffsetRelative) woset -= self.parentData.left;
+ if(isParent && isOffsetRelative) woset -= that.parentData.left;
- if (woset + self.size.width >= self.parentData.width) {
- self.size.width = self.parentData.width - woset;
- if (pRatio) self.size.height = self.size.width / self.aspectRatio;
+ if (woset + that.size.width >= that.parentData.width) {
+ that.size.width = that.parentData.width - woset;
+ if (pRatio) that.size.height = that.size.width / that.aspectRatio;
}
- if (hoset + self.size.height >= self.parentData.height) {
- self.size.height = self.parentData.height - hoset;
- if (pRatio) self.size.width = self.size.height * self.aspectRatio;
+ if (hoset + that.size.height >= that.parentData.height) {
+ that.size.height = that.parentData.height - hoset;
+ if (pRatio) that.size.width = that.size.height * that.aspectRatio;
}
},
stop: function(event, ui){
- var self = $(this).data("resizable"), o = self.options, cp = self.position,
- co = self.containerOffset, cop = self.containerPosition, ce = self.containerElement;
+ var that = $(this).data("resizable"), o = that.options, cp = that.position,
+ co = that.containerOffset, cop = that.containerPosition, ce = that.containerElement;
- var helper = $(self.helper), ho = helper.offset(), w = helper.outerWidth() - self.sizeDiff.width, h = helper.outerHeight() - self.sizeDiff.height;
+ var helper = $(that.helper), ho = helper.offset(), w = helper.outerWidth() - that.sizeDiff.width, h = helper.outerHeight() - that.sizeDiff.height;
- if (self._helper && !o.animate && (/relative/).test(ce.css('position')))
+ if (that._helper && !o.animate && (/relative/).test(ce.css('position')))
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
- if (self._helper && !o.animate && (/static/).test(ce.css('position')))
+ if (that._helper && !o.animate && (/static/).test(ce.css('position')))
$(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
}
@@ -2641,26 +2849,26 @@ $.ui.plugin.add("resizable", "ghost", {
start: function(event, ui) {
- var self = $(this).data("resizable"), o = self.options, cs = self.size;
+ var that = $(this).data("resizable"), o = that.options, cs = that.size;
- self.ghost = self.originalElement.clone();
- self.ghost
+ that.ghost = that.originalElement.clone();
+ that.ghost
.css({ opacity: .25, display: 'block', position: 'relative', height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
.addClass('ui-resizable-ghost')
.addClass(typeof o.ghost == 'string' ? o.ghost : '');
- self.ghost.appendTo(self.helper);
+ that.ghost.appendTo(that.helper);
},
resize: function(event, ui){
- var self = $(this).data("resizable"), o = self.options;
- if (self.ghost) self.ghost.css({ position: 'relative', height: self.size.height, width: self.size.width });
+ var that = $(this).data("resizable"), o = that.options;
+ if (that.ghost) that.ghost.css({ position: 'relative', height: that.size.height, width: that.size.width });
},
stop: function(event, ui){
- var self = $(this).data("resizable"), o = self.options;
- if (self.ghost && self.helper) self.helper.get(0).removeChild(self.ghost.get(0));
+ var that = $(this).data("resizable"), o = that.options;
+ if (that.ghost && that.helper) that.helper.get(0).removeChild(that.ghost.get(0));
}
});
@@ -2668,29 +2876,29 @@ $.ui.plugin.add("resizable", "ghost", {
$.ui.plugin.add("resizable", "grid", {
resize: function(event, ui) {
- var self = $(this).data("resizable"), o = self.options, cs = self.size, os = self.originalSize, op = self.originalPosition, a = self.axis, ratio = o._aspectRatio || event.shiftKey;
+ var that = $(this).data("resizable"), o = that.options, cs = that.size, os = that.originalSize, op = that.originalPosition, a = that.axis, ratio = o._aspectRatio || event.shiftKey;
o.grid = typeof o.grid == "number" ? [o.grid, o.grid] : o.grid;
var ox = Math.round((cs.width - os.width) / (o.grid[0]||1)) * (o.grid[0]||1), oy = Math.round((cs.height - os.height) / (o.grid[1]||1)) * (o.grid[1]||1);
if (/^(se|s|e)$/.test(a)) {
- self.size.width = os.width + ox;
- self.size.height = os.height + oy;
+ that.size.width = os.width + ox;
+ that.size.height = os.height + oy;
}
else if (/^(ne)$/.test(a)) {
- self.size.width = os.width + ox;
- self.size.height = os.height + oy;
- self.position.top = op.top - oy;
+ that.size.width = os.width + ox;
+ that.size.height = os.height + oy;
+ that.position.top = op.top - oy;
}
else if (/^(sw)$/.test(a)) {
- self.size.width = os.width + ox;
- self.size.height = os.height + oy;
- self.position.left = op.left - ox;
+ that.size.width = os.width + ox;
+ that.size.height = os.height + oy;
+ that.position.left = op.left - ox;
}
else {
- self.size.width = os.width + ox;
- self.size.height = os.height + oy;
- self.position.top = op.top - oy;
- self.position.left = op.left - ox;
+ that.size.width = os.width + ox;
+ that.size.height = os.height + oy;
+ that.position.top = op.top - oy;
+ that.position.left = op.left - ox;
}
}
@@ -2705,23 +2913,11 @@ var isNumber = function(value) {
};
})(jQuery);
-/*
- * jQuery UI Selectable 1.8.16
- *
- * Copyright 2011, 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/Selectables
- *
- * Depends:
- * jquery.ui.core.js
- * jquery.ui.mouse.js
- * jquery.ui.widget.js
- */
+
(function( $, undefined ) {
$.widget("ui.selectable", $.ui.mouse, {
+ version: "1.9.2",
options: {
appendTo: 'body',
autoRefresh: true,
@@ -2730,7 +2926,7 @@ $.widget("ui.selectable", $.ui.mouse, {
tolerance: 'touch'
},
_create: function() {
- var self = this;
+ var that = this;
this.element.addClass("ui-selectable");
@@ -2739,7 +2935,8 @@ $.widget("ui.selectable", $.ui.mouse, {
// cache selectee children based on filter
var selectees;
this.refresh = function() {
- selectees = $(self.options.filter, self.element[0]);
+ selectees = $(that.options.filter, that.element[0]);
+ selectees.addClass("ui-selectee");
selectees.each(function() {
var $this = $(this);
var pos = $this.offset();
@@ -2766,21 +2963,17 @@ $.widget("ui.selectable", $.ui.mouse, {
this.helper = $("<div class='ui-selectable-helper'></div>");
},
- destroy: function() {
+ _destroy: function() {
this.selectees
.removeClass("ui-selectee")
.removeData("selectable-item");
this.element
- .removeClass("ui-selectable ui-selectable-disabled")
- .removeData("selectable")
- .unbind(".selectable");
+ .removeClass("ui-selectable ui-selectable-disabled");
this._mouseDestroy();
-
- return this;
},
_mouseStart: function(event) {
- var self = this;
+ var that = this;
this.opos = [event.pageX, event.pageY];
@@ -2809,13 +3002,13 @@ $.widget("ui.selectable", $.ui.mouse, {
this.selectees.filter('.ui-selected').each(function() {
var selectee = $.data(this, "selectable-item");
selectee.startselected = true;
- if (!event.metaKey) {
+ if (!event.metaKey && !event.ctrlKey) {
selectee.$element.removeClass('ui-selected');
selectee.selected = false;
selectee.$element.addClass('ui-unselecting');
selectee.unselecting = true;
// selectable UNSELECTING callback
- self._trigger("unselecting", event, {
+ that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
@@ -2824,7 +3017,7 @@ $.widget("ui.selectable", $.ui.mouse, {
$(event.target).parents().andSelf().each(function() {
var selectee = $.data(this, "selectable-item");
if (selectee) {
- var doSelect = !event.metaKey || !selectee.$element.hasClass('ui-selected');
+ var doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass('ui-selected');
selectee.$element
.removeClass(doSelect ? "ui-unselecting" : "ui-selected")
.addClass(doSelect ? "ui-selecting" : "ui-unselecting");
@@ -2833,11 +3026,11 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.selected = doSelect;
// selectable (UN)SELECTING callback
if (doSelect) {
- self._trigger("selecting", event, {
+ that._trigger("selecting", event, {
selecting: selectee.element
});
} else {
- self._trigger("unselecting", event, {
+ that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
@@ -2848,7 +3041,7 @@ $.widget("ui.selectable", $.ui.mouse, {
},
_mouseDrag: function(event) {
- var self = this;
+ var that = this;
this.dragged = true;
if (this.options.disabled)
@@ -2864,7 +3057,7 @@ $.widget("ui.selectable", $.ui.mouse, {
this.selectees.each(function() {
var selectee = $.data(this, "selectable-item");
//prevent helper from being selected if appendTo: selectable
- if (!selectee || selectee.element == self.element[0])
+ if (!selectee || selectee.element == that.element[0])
return;
var hit = false;
if (options.tolerance == 'touch') {
@@ -2887,14 +3080,14 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.$element.addClass('ui-selecting');
selectee.selecting = true;
// selectable SELECTING callback
- self._trigger("selecting", event, {
+ that._trigger("selecting", event, {
selecting: selectee.element
});
}
} else {
// UNSELECT
if (selectee.selecting) {
- if (event.metaKey && selectee.startselected) {
+ if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
selectee.$element.removeClass('ui-selecting');
selectee.selecting = false;
selectee.$element.addClass('ui-selected');
@@ -2907,20 +3100,20 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.unselecting = true;
}
// selectable UNSELECTING callback
- self._trigger("unselecting", event, {
+ that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
}
if (selectee.selected) {
- if (!event.metaKey && !selectee.startselected) {
+ if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
selectee.$element.removeClass('ui-selected');
selectee.selected = false;
selectee.$element.addClass('ui-unselecting');
selectee.unselecting = true;
// selectable UNSELECTING callback
- self._trigger("unselecting", event, {
+ that._trigger("unselecting", event, {
unselecting: selectee.element
});
}
@@ -2932,7 +3125,7 @@ $.widget("ui.selectable", $.ui.mouse, {
},
_mouseStop: function(event) {
- var self = this;
+ var that = this;
this.dragged = false;
@@ -2943,7 +3136,7 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.$element.removeClass('ui-unselecting');
selectee.unselecting = false;
selectee.startselected = false;
- self._trigger("unselected", event, {
+ that._trigger("unselected", event, {
unselected: selectee.element
});
});
@@ -2953,7 +3146,7 @@ $.widget("ui.selectable", $.ui.mouse, {
selectee.selecting = false;
selectee.selected = true;
selectee.startselected = true;
- self._trigger("selected", event, {
+ that._trigger("selected", event, {
selected: selectee.element
});
});
@@ -2966,29 +3159,14 @@ $.widget("ui.selectable", $.ui.mouse, {
});
-$.extend($.ui.selectable, {
- version: "1.8.16"
-});
-
})(jQuery);
-/*
- * jQuery UI Sortable 1.8.16
- *
- * Copyright 2011, 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/Sortables
- *
- * Depends:
- * jquery.ui.core.js
- * jquery.ui.mouse.js
- * jquery.ui.widget.js
- */
+
(function( $, undefined ) {
$.widget("ui.sortable", $.ui.mouse, {
+ version: "1.9.2",
widgetEventPrefix: "sort",
+ ready: false,
options: {
appendTo: "parent",
axis: false,
@@ -3031,17 +3209,18 @@ $.widget("ui.sortable", $.ui.mouse, {
//Initialize mouse events for interaction
this._mouseInit();
+ //We're ready to go
+ this.ready = true
+
},
- destroy: function() {
+ _destroy: function() {
this.element
- .removeClass("ui-sortable ui-sortable-disabled")
- .removeData("sortable")
- .unbind(".sortable");
+ .removeClass("ui-sortable ui-sortable-disabled");
this._mouseDestroy();
for ( var i = this.items.length - 1; i >= 0; i-- )
- this.items[i].item.removeData("sortable-item");
+ this.items[i].item.removeData(this.widgetName + "-item");
return this;
},
@@ -3049,9 +3228,8 @@ $.widget("ui.sortable", $.ui.mouse, {
_setOption: function(key, value){
if ( key === "disabled" ) {
this.options[ key ] = value;
-
- this.widget()
- [ value ? "addClass" : "removeClass"]( "ui-sortable-disabled" );
+
+ this.widget().toggleClass( "ui-sortable-disabled", !!value );
} else {
// Don't call widget base _setOption for disable as it adds ui-state-disabled class
$.Widget.prototype._setOption.apply(this, arguments);
@@ -3059,6 +3237,7 @@ $.widget("ui.sortable", $.ui.mouse, {
},
_mouseCapture: function(event, overrideHandle) {
+ var that = this;
if (this.reverting) {
return false;
@@ -3070,13 +3249,13 @@ $.widget("ui.sortable", $.ui.mouse, {
this._refreshItems(event);
//Find out if the clicked node (or one of its parents) is a actual item in this.items
- var currentItem = null, self = this, nodes = $(event.target).parents().each(function() {
- if($.data(this, 'sortable-item') == self) {
+ var currentItem = null, nodes = $(event.target).parents().each(function() {
+ if($.data(this, that.widgetName + '-item') == that) {
currentItem = $(this);
return false;
}
});
- if($.data(event.target, 'sortable-item') == self) currentItem = $(event.target);
+ if($.data(event.target, that.widgetName + '-item') == that) currentItem = $(event.target);
if(!currentItem) return false;
if(this.options.handle && !overrideHandle) {
@@ -3094,7 +3273,7 @@ $.widget("ui.sortable", $.ui.mouse, {
_mouseStart: function(event, overrideHandle, noActivation) {
- var o = this.options, self = this;
+ var o = this.options;
this.currentContainer = this;
//We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
@@ -3124,11 +3303,6 @@ $.widget("ui.sortable", $.ui.mouse, {
left: this.offset.left - this.margins.left
};
- // Only after we got the offset, we can change the helper's position to absolute
- // TODO: Still need to figure out a way to make relative sorting possible
- this.helper.css("position", "absolute");
- this.cssPosition = this.helper.css("position");
-
$.extend(this.offset, {
click: { //Where the click happened, relative to the element
left: event.pageX - this.offset.left,
@@ -3138,6 +3312,11 @@ $.widget("ui.sortable", $.ui.mouse, {
relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
});
+ // Only after we got the offset, we can change the helper's position to absolute
+ // TODO: Still need to figure out a way to make relative sorting possible
+ this.helper.css("position", "absolute");
+ this.cssPosition = this.helper.css("position");
+
//Generate the original position
this.originalPosition = this._generatePosition(event);
this.originalPageX = event.pageX;
@@ -3190,7 +3369,7 @@ $.widget("ui.sortable", $.ui.mouse, {
//Post 'activate' events to possible containers
if(!noActivation) {
- for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, self._uiHash(this)); }
+ for (var i = this.containers.length - 1; i >= 0; i--) { this.containers[i]._trigger("activate", event, this._uiHash(this)); }
}
//Prepare possible droppables
@@ -3265,10 +3444,19 @@ $.widget("ui.sortable", $.ui.mouse, {
var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
if (!intersection) continue;
- if(itemElement != this.currentItem[0] //cannot intersect with itself
+ // Only put the placeholder inside the current Container, skip all
+ // items form other containers. This works because when moving
+ // an item from one container to another the
+ // currentContainer is switched before the placeholder is moved.
+ //
+ // Without this moving items in "sub-sortables" can cause the placeholder to jitter
+ // beetween the outer and inner container.
+ if (item.instance !== this.currentContainer) continue;
+
+ if (itemElement != this.currentItem[0] //cannot intersect with itself
&& this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
- && !$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
- && (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true)
+ && !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
+ && (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true)
//&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
) {
@@ -3308,16 +3496,16 @@ $.widget("ui.sortable", $.ui.mouse, {
$.ui.ddmanager.drop(this, event);
if(this.options.revert) {
- var self = this;
- var cur = self.placeholder.offset();
+ var that = this;
+ var cur = this.placeholder.offset();
- self.reverting = true;
+ this.reverting = true;
$(this.helper).animate({
- left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
- top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
+ left: cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
+ top: cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
}, parseInt(this.options.revert, 10) || 500, function() {
- self._clear(event);
+ that._clear(event);
});
} else {
this._clear(event, noPropagation);
@@ -3329,8 +3517,6 @@ $.widget("ui.sortable", $.ui.mouse, {
cancel: function() {
- var self = this;
-
if(this.dragging) {
this._mouseUp({ target: null });
@@ -3342,9 +3528,9 @@ $.widget("ui.sortable", $.ui.mouse, {
//Post deactivating events to containers
for (var i = this.containers.length - 1; i >= 0; i--){
- this.containers[i]._trigger("deactivate", null, self._uiHash(this));
+ this.containers[i]._trigger("deactivate", null, this._uiHash(this));
if(this.containers[i].containerCache.over) {
- this.containers[i]._trigger("out", null, self._uiHash(this));
+ this.containers[i]._trigger("out", null, this._uiHash(this));
this.containers[i].containerCache.over = 0;
}
}
@@ -3437,8 +3623,8 @@ $.widget("ui.sortable", $.ui.mouse, {
_intersectsWithPointer: function(item) {
- var isOverElementHeight = $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
- isOverElementWidth = $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
+ var isOverElementHeight = (this.options.axis === 'x') || $.ui.isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
+ isOverElementWidth = (this.options.axis === 'y') || $.ui.isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
isOverElement = isOverElementHeight && isOverElementWidth,
verticalDirection = this._getDragVerticalDirection(),
horizontalDirection = this._getDragHorizontalDirection();
@@ -3489,10 +3675,9 @@ $.widget("ui.sortable", $.ui.mouse, {
? [options.connectWith]
: options.connectWith;
},
-
+
_getItemsAsjQuery: function(connected) {
- var self = this;
var items = [];
var queries = [];
var connectWith = this._connectWith();
@@ -3501,7 +3686,7 @@ $.widget("ui.sortable", $.ui.mouse, {
for (var i = connectWith.length - 1; i >= 0; i--){
var cur = $(connectWith[i]);
for (var j = cur.length - 1; j >= 0; j--){
- var inst = $.data(cur[j], 'sortable');
+ var inst = $.data(cur[j], this.widgetName);
if(inst && inst != this && !inst.options.disabled) {
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element) : $(inst.options.items, inst.element).not(".ui-sortable-helper").not('.ui-sortable-placeholder'), inst]);
}
@@ -3523,16 +3708,15 @@ $.widget("ui.sortable", $.ui.mouse, {
_removeCurrentsFromItems: function() {
- var list = this.currentItem.find(":data(sortable-item)");
-
- for (var i=0; i < this.items.length; i++) {
+ var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
+ this.items = $.grep(this.items, function (item) {
for (var j=0; j < list.length; j++) {
- if(list[j] == this.items[i].item[0])
- this.items.splice(i,1);
+ if(list[j] == item.item[0])
+ return false;
};
-
- };
+ return true;
+ });
},
@@ -3541,15 +3725,14 @@ $.widget("ui.sortable", $.ui.mouse, {
this.items = [];
this.containers = [this];
var items = this.items;
- var self = this;
var queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]];
var connectWith = this._connectWith();
- if(connectWith) {
+ if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
for (var i = connectWith.length - 1; i >= 0; i--){
var cur = $(connectWith[i]);
for (var j = cur.length - 1; j >= 0; j--){
- var inst = $.data(cur[j], 'sortable');
+ var inst = $.data(cur[j], this.widgetName);
if(inst && inst != this && !inst.options.disabled) {
queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
this.containers.push(inst);
@@ -3565,7 +3748,7 @@ $.widget("ui.sortable", $.ui.mouse, {
for (var j=0, queriesLength = _queries.length; j < queriesLength; j++) {
var item = $(_queries[j]);
- item.data('sortable-item', targetData); // Data for target checking (mouse manager)
+ item.data(this.widgetName + '-item', targetData); // Data for target checking (mouse manager)
items.push({
item: item,
@@ -3620,16 +3803,16 @@ $.widget("ui.sortable", $.ui.mouse, {
},
_createPlaceholder: function(that) {
-
- var self = that || this, o = self.options;
+ that = that || this;
+ var o = that.options;
if(!o.placeholder || o.placeholder.constructor == String) {
var className = o.placeholder;
o.placeholder = {
element: function() {
- var el = $(document.createElement(self.currentItem[0].nodeName))
- .addClass(className || self.currentItem[0].className+" ui-sortable-placeholder")
+ var el = $(document.createElement(that.currentItem[0].nodeName))
+ .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
.removeClass("ui-sortable-helper")[0];
if(!className)
@@ -3644,46 +3827,46 @@ $.widget("ui.sortable", $.ui.mouse, {
if(className && !o.forcePlaceholderSize) return;
//If the element doesn't have a actual height by itself (without styles coming from a stylesheet), it receives the inline height from the dragged item
- if(!p.height()) { p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10)); };
- if(!p.width()) { p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10)); };
+ if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css('paddingTop')||0, 10) - parseInt(that.currentItem.css('paddingBottom')||0, 10)); };
+ if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css('paddingLeft')||0, 10) - parseInt(that.currentItem.css('paddingRight')||0, 10)); };
}
};
}
//Create the placeholder
- self.placeholder = $(o.placeholder.element.call(self.element, self.currentItem));
+ that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
//Append it after the actual current item
- self.currentItem.after(self.placeholder);
+ that.currentItem.after(that.placeholder);
//Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
- o.placeholder.update(self, self.placeholder);
+ o.placeholder.update(that, that.placeholder);
},
_contactContainers: function(event) {
-
- // get innermost container that intersects with item
- var innermostContainer = null, innermostIndex = null;
-
-
+
+ // get innermost container that intersects with item
+ var innermostContainer = null, innermostIndex = null;
+
+
for (var i = this.containers.length - 1; i >= 0; i--){
- // never consider a container that's located within the item itself
- if($.ui.contains(this.currentItem[0], this.containers[i].element[0]))
+ // never consider a container that's located within the item itself
+ if($.contains(this.currentItem[0], this.containers[i].element[0]))
continue;
if(this._intersectsWith(this.containers[i].containerCache)) {
- // if we've already found a container and it's more "inner" than this, then continue
- if(innermostContainer && $.ui.contains(this.containers[i].element[0], innermostContainer.element[0]))
+ // if we've already found a container and it's more "inner" than this, then continue
+ if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0]))
continue;
- innermostContainer = this.containers[i];
+ innermostContainer = this.containers[i];
innermostIndex = i;
-
+
} else {
- // container doesn't intersect. trigger "out" event if necessary
+ // container doesn't intersect. trigger "out" event if necessary
if(this.containers[i].containerCache.over) {
this.containers[i]._trigger("out", event, this._uiHash(this));
this.containers[i].containerCache.over = 0;
@@ -3691,42 +3874,53 @@ $.widget("ui.sortable", $.ui.mouse, {
}
}
-
- // if no intersecting containers found, return
- if(!innermostContainer) return;
+
+ // if no intersecting containers found, return
+ if(!innermostContainer) return;
// move the item into the container if it's not there already
if(this.containers.length === 1) {
this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
this.containers[innermostIndex].containerCache.over = 1;
- } else if(this.currentContainer != this.containers[innermostIndex]) {
-
- //When entering a new container, we will find the item with the least distance and append our item near it
- var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
- for (var j = this.items.length - 1; j >= 0; j--) {
- if(!$.ui.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
- var cur = this.items[j][this.containers[innermostIndex].floating ? 'left' : 'top'];
- if(Math.abs(cur - base) < dist) {
- dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
- }
- }
-
- if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
- return;
-
- this.currentContainer = this.containers[innermostIndex];
- itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
- this._trigger("change", event, this._uiHash());
- this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
-
- //Update the placeholder
- this.options.placeholder.update(this.currentContainer, this.placeholder);
-
- this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
+ } else {
+
+ //When entering a new container, we will find the item with the least distance and append our item near it
+ var dist = 10000; var itemWithLeastDistance = null;
+ var posProperty = this.containers[innermostIndex].floating ? 'left' : 'top';
+ var sizeProperty = this.containers[innermostIndex].floating ? 'width' : 'height';
+ var base = this.positionAbs[posProperty] + this.offset.click[posProperty];
+ for (var j = this.items.length - 1; j >= 0; j--) {
+ if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
+ if(this.items[j].item[0] == this.currentItem[0]) continue;
+ var cur = this.items[j].item.offset()[posProperty];
+ var nearBottom = false;
+ if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
+ nearBottom = true;
+ cur += this.items[j][sizeProperty];
+ }
+
+ if(Math.abs(cur - base) < dist) {
+ dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
+ this.direction = nearBottom ? "up": "down";
+ }
+ }
+
+ if(!itemWithLeastDistance && !this.options.dropOnEmpty) //Check if dropOnEmpty is enabled
+ return;
+
+ this.currentContainer = this.containers[innermostIndex];
+ itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
+ this._trigger("change", event, this._uiHash());
+ this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
+
+ //Update the placeholder
+ this.options.placeholder.update(this.currentContainer, this.placeholder);
+
+ this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
this.containers[innermostIndex].containerCache.over = 1;
- }
-
-
+ }
+
+
},
_createHelper: function(event) {
@@ -3779,13 +3973,13 @@ $.widget("ui.sortable", $.ui.mouse, {
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
- if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
+ if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
po.left += this.scrollParent.scrollLeft();
po.top += this.scrollParent.scrollTop();
}
if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
- || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
+ || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.ui.ie)) //Ugly IE fix
po = { top: 0, left: 0 };
return {
@@ -3853,20 +4047,20 @@ $.widget("ui.sortable", $.ui.mouse, {
if(!pos) pos = this.position;
var mod = d == "absolute" ? 1 : -1;
- var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
return {
top: (
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)
)
};
@@ -3874,7 +4068,7 @@ $.widget("ui.sortable", $.ui.mouse, {
_generatePosition: function(event) {
- var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
// This is another very weird special case that only happens for relative elements:
// 1. If the css position is relative
@@ -3917,14 +4111,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() ))
)
};
@@ -3940,11 +4134,11 @@ $.widget("ui.sortable", $.ui.mouse, {
// 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
// 4. this lets only the last addition to the timeout stack through
this.counter = this.counter ? ++this.counter : 1;
- var self = this, counter = this.counter;
+ var counter = this.counter;
- window.setTimeout(function() {
- if(counter == self.counter) self.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
- },0);
+ this._delay(function() {
+ if(counter == this.counter) this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
+ });
},
@@ -3953,7 +4147,7 @@ $.widget("ui.sortable", $.ui.mouse, {
this.reverting = false;
// We delay all events that have to be triggered to after the point where the placeholder has been removed and
// everything else normalized again
- var delayedTriggers = [], self = this;
+ var delayedTriggers = [];
// We first have to update the dom position of the actual currentItem
// Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
@@ -3971,15 +4165,17 @@ $.widget("ui.sortable", $.ui.mouse, {
if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
if((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !noPropagation) delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
- if(!$.ui.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
- if(!noPropagation) delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
- for (var i = this.containers.length - 1; i >= 0; i--){
- if($.ui.contains(this.containers[i].element[0], this.currentItem[0]) && !noPropagation) {
- delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
- delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
- }
- };
- };
+
+ // Check if the items Container has Changed and trigger appropriate
+ // events.
+ if (this !== this.currentContainer) {
+ if(!noPropagation) {
+ delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
+ delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
+ delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
+ }
+ }
+
//Post events to containers
for (var i = this.containers.length - 1; i >= 0; i--){
@@ -4002,6 +4198,8 @@ $.widget("ui.sortable", $.ui.mouse, {
for (var i=0; i < delayedTriggers.length; i++) { delayedTriggers[i].call(this, event); }; //Trigger all delayed events
this._trigger("stop", event, this._uiHash());
}
+
+ this.fromOutside = false;
return false;
}
@@ -4028,173 +4226,696 @@ $.widget("ui.sortable", $.ui.mouse, {
}
},
- _uiHash: function(inst) {
- var self = inst || this;
+ _uiHash: function(_inst) {
+ var inst = _inst || this;
return {
- helper: self.helper,
- placeholder: self.placeholder || $([]),
- position: self.position,
- originalPosition: self.originalPosition,
- offset: self.positionAbs,
- item: self.currentItem,
- sender: inst ? inst.element : null
+ helper: inst.helper,
+ placeholder: inst.placeholder || $([]),
+ position: inst.position,
+ originalPosition: inst.originalPosition,
+ offset: inst.positionAbs,
+ item: inst.currentItem,
+ sender: _inst ? _inst.element : null
};
}
});
-$.extend($.ui.sortable, {
- version: "1.8.16"
-});
-
})(jQuery);
-/*
- * jQuery UI Effects 1.8.16
+
+;(jQuery.effects || (function($, undefined) {
+
+var backCompat = $.uiBackCompat !== false,
+ // prefix used for storing data on .data()
+ dataSpace = "ui-effects-";
+
+$.effects = {
+ effect: {}
+};
+
+/*!
+ * jQuery Color Animations v2.0.0
+ * http://jquery.com/
*
- * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
- * Dual licensed under the MIT or GPL Version 2 licenses.
+ * Copyright 2012 jQuery Foundation and other contributors
+ * Released under the MIT license.
* http://jquery.org/license
*
- * http://docs.jquery.com/UI/Effects/
+ * Date: Mon Aug 13 13:41:02 2012 -0500
*/
-;jQuery.effects || (function($, undefined) {
+(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"
+ }
+ }
+ },
-$.effects = {};
+ 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,
-/******************************************************************************/
-/****************************** COLOR ANIMATIONS ******************************/
-/******************************************************************************/
+ // local aliases of functions called often
+ each = jQuery.each;
-// 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;
- }
+// determine rgba support immediately
+supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
+support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
- 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) + ')';
+// 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
};
});
-// Color Conversion functions from highlightFade
-// By Blair Mitchelmore
-// http://jquery.offput.ca/highlightFade/
+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;
+}
-// Parse strings looking for color tuples [255,255,255]
-function getRGB(color) {
- var result;
+function stringParse( string ) {
+ var inst = color(),
+ rgba = inst._rgba = [];
- // Check if we're already dealing with an array of colors
- if ( color && color.constructor == Array && color.length == 3 )
- return color;
+ string = string.toLowerCase();
- // 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)];
+ each( stringParsers, function( i, parser ) {
+ var parsed,
+ match = parser.re.exec( string ),
+ values = match && parser.parse( match ),
+ spaceName = parser.space || "rgba";
- // 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];
+ if ( values ) {
+ parsed = inst[ spaceName ]( values );
- // 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)];
+ // 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;
+ }
+ });
- // 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)];
+ // Found a stringParser that handled it
+ if ( rgba.length ) {
- // Look for rgba(0, 0, 0, 0) == transparent in Safari 3
- if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
- return colors['transparent'];
+ // 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;
+ }
- // Otherwise, we're most likely dealing with a named color
- return colors[$.trim(color).toLowerCase()];
+ // named colors
+ return colors[ string ];
}
-function getColor(elem, attr) {
- var color;
+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;
+ }
- do {
- color = $.curCSS(elem, attr);
+ var inst = this,
+ type = jQuery.type( red ),
+ rgba = this._rgba = [];
- // Keep going until we find an element that has color, or we hit the body
- if ( color != '' && color != 'transparent' || $.nodeName(elem, "body") )
- break;
+ // 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 ) {
+ var cache = space.cache;
+ each( space.props, function( key, prop ) {
+
+ // 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 );
+ });
+
+ // everything defined but alpha?
+ if ( inst[ cache ] && $.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
+ // use the default of 1
+ inst[ cache ][ 3 ] = 1;
+ if ( space.from ) {
+ inst._rgba = space.from( inst[ cache ] );
+ }
+ }
+ });
+ }
+ 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;
+ }
- attr = "backgroundColor";
- } while ( elem = elem.parentNode );
+ // 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();
- return getRGB(color);
+ if ( includeAlpha ) {
+ rgba.push( ~~( alpha * 255 ) );
+ }
+
+ return "#" + jQuery.map( rgba, function( v ) {
+
+ // 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 ];
};
-// 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]
+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;
+
+ 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, curElem,
+ backgroundColor = "";
+
+ 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;
+ while (
+ (backgroundColor === "" || backgroundColor === "transparent") &&
+ curElem && curElem.style
+ ) {
+ try {
+ backgroundColor = jQuery.css( curElem, "backgroundColor" );
+ curElem = curElem.parentNode;
+ } catch ( e ) {
+ }
+ }
+
+ value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
+ backgroundColor :
+ "_default" );
+ }
+
+ value = value.toRgbaString();
+ }
+ try {
+ elem.style[ hook ] = value;
+ } catch( error ) {
+ // 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 ) );
+ };
+});
+
+jQuery.cssHooks.borderColor = {
+ expand: function( value ) {
+ var expanded = {};
+
+ each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
+ expanded[ "border" + part + "Color" ] = value;
+ });
+ return expanded;
+ }
+};
+
+// 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'],
+var classAnimationActions = [ "add", "remove", "toggle" ],
shorthandStyles = {
border: 1,
borderBottom: 1,
@@ -4207,199 +4928,253 @@ var classAnimationActions = ['add', 'remove', 'toggle'],
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 = document.defaultView
- ? document.defaultView.getComputedStyle(this, null)
- : this.currentStyle,
+ 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]]) {
- var len = style.length;
- while (len--) {
- key = style[len];
- if (typeof style[key] == 'string') {
- camelCase = key.replace(/\-(\w)/g, function(all, letter){
- return letter.toUpperCase();
- });
- newStyle[camelCase] = style[key];
+ 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];
+ for ( key in style ) {
+ if ( typeof style[ key ] === "string" ) {
+ newStyle[ key ] = style[ key ];
}
}
}
-
+
return newStyle;
}
-function filterStyles(styles) {
- var name, value;
- for (name in styles) {
- value = styles[name];
- if (
- // ignore null and undefined values
- value == null ||
- // ignore functions (when does this occur?)
- $.isFunction(value) ||
- // shorthand styles that need to be expanded
- name in shorthandStyles ||
- // ignore scrollbars (break in IE)
- (/scrollbar/).test(name) ||
-
- // only colors or values that can be converted to numbers
- (!(/color/i).test(name) && isNaN(parseFloat(value)))
- ) {
- delete styles[name];
- }
- }
-
- return styles;
-}
-function styleDifference(oldStyle, newStyle) {
- var diff = { _: 0 }, // http://dev.jquery.com/ticket/5459
- name;
+function styleDifference( oldStyle, newStyle ) {
+ var diff = {},
+ name, value;
- for (name in newStyle) {
- if (oldStyle[name] != newStyle[name]) {
- diff[name] = newStyle[name];
+ 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) {
- if ($.isFunction(easing)) {
- callback = easing;
- easing = null;
- }
+$.effects.animateClass = function( value, duration, easing, callback ) {
+ var o = $.speed( duration, easing, callback );
- return this.queue(function() {
- var that = $(this),
- originalStyleAttr = that.attr('style') || ' ',
- originalStyle = filterStyles(getElementStyles.call(this)),
- newStyle,
- className = that.attr('class');
+ return this.queue( function() {
+ var animated = $( this ),
+ baseClass = animated.attr( "class" ) || "",
+ applyClassChange,
+ allAnimations = o.children ? animated.find( "*" ).andSelf() : animated;
- $.each(classAnimationActions, function(i, action) {
- if (value[action]) {
- that[action + 'Class'](value[action]);
- }
+ // map the animated objects to store the original styles.
+ allAnimations = allAnimations.map(function() {
+ var el = $( this );
+ return {
+ el: el,
+ start: getElementStyles.call( this )
+ };
});
- newStyle = filterStyles(getElementStyles.call(this));
- that.attr('class', className);
- that.animate(styleDifference(originalStyle, newStyle), {
- queue: false,
- duration: duration,
- easing: easing,
- complete: function() {
- $.each(classAnimationActions, function(i, action) {
- if (value[action]) { that[action + 'Class'](value[action]); }
- });
- // work around bug in IE by clearing the cssText before setting it
- if (typeof that.attr('style') == 'object') {
- that.attr('style').cssText = '';
- that.attr('style').cssText = originalStyleAttr;
- } else {
- that.attr('style', originalStyleAttr);
+ // apply class change
+ applyClassChange = function() {
+ $.each( classAnimationActions, function(i, action) {
+ if ( value[ action ] ) {
+ animated[ action + "Class" ]( value[ action ] );
}
- if (callback) { callback.apply(this, arguments); }
- $.dequeue( this );
- }
+ });
+ };
+ 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);
+ addClass: function( classNames, speed, easing, callback ) {
+ return speed ?
+ $.effects.animateClass.call( 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);
+ removeClass: function( classNames, speed, easing, callback ) {
+ return speed ?
+ $.effects.animateClass.call( 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 ) {
+ toggleClass: function( classNames, force, speed, easing, callback ) {
+ if ( typeof force === "boolean" || force === undefined ) {
if ( !speed ) {
- // without speed parameter;
- return this._toggleClass(classNames, force);
+ // without speed parameter
+ return this._toggleClass( classNames, force );
} else {
- return $.effects.animateClass.apply(this, [(force?{add:classNames}:{remove:classNames}),speed,easing,callback]);
+ return $.effects.animateClass.call( this,
+ (force ? { add: classNames } : { remove: classNames }),
+ speed, easing, callback );
}
} else {
- // without switch parameter;
- return $.effects.animateClass.apply(this, [{ toggle: classNames },force,speed,easing]);
+ // without force parameter
+ return $.effects.animateClass.call( 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]);
+ switchClass: function( remove, add, speed, easing, callback) {
+ return $.effects.animateClass.call( this, {
+ add: add,
+ remove: remove
+ }, speed, easing, callback );
}
});
-
+})();
/******************************************************************************/
/*********************************** EFFECTS **********************************/
/******************************************************************************/
-$.extend($.effects, {
- version: "1.8.16",
+(function() {
+
+$.extend( $.effects, {
+ version: "1.9.2",
// 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("ec.storage."+set[i], element[0].style[set[i]]);
+ 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("ec.storage."+set[i]));
+ 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'; // Set for toggle
+ setMode: function( el, mode ) {
+ if (mode === "toggle") {
+ mode = el.is( ":hidden" ) ? "show" : "hide";
+ }
return mode;
},
- getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value
- // this should be a little more flexible in the future to handle a string & hash
+ // 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;
+ 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
};
- return {x: x, y: y};
},
// Wraps the element around a wrapper that copies position properties
- createWrapper: function(element) {
+ createWrapper: function( element ) {
// if the element is already wrapped, return it
- if (element.parent().is('.ui-effects-wrapper')) {
+ if ( element.parent().is( ".ui-effects-wrapper" )) {
return element.parent();
}
@@ -4407,108 +5182,149 @@ $.extend($.effects, {
var props = {
width: element.outerWidth(true),
height: element.outerHeight(true),
- 'float': element.css('float')
+ "float": element.css( "float" )
},
- wrapper = $('<div></div>')
- .addClass('ui-effects-wrapper')
+ wrapper = $( "<div></div>" )
+ .addClass( "ui-effects-wrapper" )
.css({
- fontSize: '100%',
- background: 'transparent',
- border: 'none',
+ 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;
- element.wrap(wrapper);
+ // 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 loose the reference to the wrapped element
+
+ 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' });
+ 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')
+ $.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';
+ $.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({
+ position: "relative",
+ top: 0,
+ left: 0,
+ right: "auto",
+ bottom: "auto"
+ });
}
+ element.css(size);
- return wrapper.css(props).show();
+ return wrapper.css( props ).show();
},
- removeWrapper: function(element) {
- var parent,
- active = document.activeElement;
-
- if (element.parent().is('.ui-effects-wrapper')) {
- parent = element.parent().replaceWith(element);
+ 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 parent;
}
-
+
+
return element;
},
- setTransition: function(element, list, factor, value) {
+ setTransition: function( element, list, factor, value ) {
value = value || {};
- $.each(list, function(i, x){
- unit = element.cssUnit(x);
- if (unit[0] > 0) value[x] = unit[0] * factor + unit[1];
+ $.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 ) {
-function _normalizeArguments(effect, options, speed, callback) {
- // shift params for method overloading
- if (typeof effect == 'object') {
- callback = options;
- speed = null;
+ // allow passing all options as the first parameter
+ if ( $.isPlainObject( effect ) ) {
options = effect;
- effect = options.effect;
+ effect = effect.effect;
+ }
+
+ // convert to an object
+ effect = { effect: effect };
+
+ // catch (effect, null, ...)
+ if ( options == null ) {
+ options = {};
}
- if ($.isFunction(options)) {
+
+ // catch (effect, callback)
+ if ( $.isFunction( options ) ) {
callback = options;
speed = null;
options = {};
}
- if (typeof options == 'number' || $.fx.speeds[options]) {
+
+ // catch (effect, speed, ?)
+ if ( typeof options === "number" || $.fx.speeds[ options ] ) {
callback = speed;
speed = options;
options = {};
}
- if ($.isFunction(speed)) {
+
+ // catch (effect, options, callback)
+ if ( $.isFunction( speed ) ) {
callback = speed;
speed = null;
}
- options = options || {};
+ // add options to effect
+ if ( options ) {
+ $.extend( effect, options );
+ }
speed = speed || options.duration;
- speed = $.fx.off ? 0 : typeof speed == 'number'
- ? speed : speed in $.fx.speeds ? $.fx.speeds[speed] : $.fx.speeds._default;
+ effect.duration = $.fx.off ? 0 :
+ typeof speed === "number" ? speed :
+ speed in $.fx.speeds ? $.fx.speeds[ speed ] :
+ $.fx.speeds._default;
- callback = callback || options.complete;
+ effect.complete = callback || options.complete;
- return [effect, options, speed, callback];
+ return effect;
}
function standardSpeed( speed ) {
@@ -4516,1346 +5332,411 @@ function standardSpeed( speed ) {
if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) {
return true;
}
-
+
// invalid strings - treat as "normal" speed
- if ( typeof speed === "string" && !$.effects[ 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),
- // TODO: make effects take actual parameters instead of a hash
- args2 = {
- options: args[1],
- duration: args[2],
- callback: args[3]
- },
- mode = args2.options.mode,
- effectMethod = $.effects[effect];
-
- if ( $.fx.off || !effectMethod ) {
+ 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 ]( args2.duration, args2.callback );
+ return this[ mode ]( args.duration, args.complete );
} else {
- return this.each(function() {
- if ( args2.callback ) {
- args2.callback.call( this );
+ return this.each( function() {
+ if ( args.complete ) {
+ args.complete.call( this );
}
});
}
}
-
- return effectMethod.call(this, args2);
+
+ 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) {
+ show: function( speed ) {
if ( standardSpeed( speed ) ) {
- return this._show.apply(this, arguments);
+ return this._show.apply( this, arguments );
} else {
- var args = _normalizeArguments.apply(this, arguments);
- args[1].mode = 'show';
- return this.effect.apply(this, args);
+ var args = _normalizeArguments.apply( this, arguments );
+ args.mode = "show";
+ return this.effect.call( this, args );
}
},
_hide: $.fn.hide,
- hide: function(speed) {
+ hide: function( speed ) {
if ( standardSpeed( speed ) ) {
- return this._hide.apply(this, arguments);
+ return this._hide.apply( this, arguments );
} else {
- var args = _normalizeArguments.apply(this, arguments);
- args[1].mode = 'hide';
- return this.effect.apply(this, args);
+ 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) {
+ toggle: function( speed ) {
if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) {
- return this.__toggle.apply(this, arguments);
+ return this.__toggle.apply( this, arguments );
} else {
- var args = _normalizeArguments.apply(this, arguments);
- args[1].mode = 'toggle';
- return this.effect.apply(this, args);
+ 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];
+ 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 ***********************************/
/******************************************************************************/
-/*
- * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
- *
- * Uses the built in easing capabilities added In jQuery 1.1
- * to offer multiple easing options
- *
- * TERMS OF USE - jQuery Easing
- *
- * Open source under the BSD License.
- *
- * Copyright 2008 George McGinley Smith
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * Neither the name of the author nor the names of contributors may be used to endorse
- * or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
-*/
+(function() {
-// t: current time, b: begInnIng value, c: change In value, d: duration
-$.easing.jswing = $.easing.swing;
+// based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
-$.extend($.easing,
-{
- def: 'easeOutQuad',
- swing: function (x, t, b, c, d) {
- //alert($.easing.default);
- return $.easing[$.easing.def](x, t, b, c, d);
- },
- easeInQuad: function (x, t, b, c, d) {
- return c*(t/=d)*t + b;
- },
- easeOutQuad: function (x, t, b, c, d) {
- return -c *(t/=d)*(t-2) + b;
- },
- easeInOutQuad: function (x, t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t + b;
- return -c/2 * ((--t)*(t-2) - 1) + b;
- },
- easeInCubic: function (x, t, b, c, d) {
- return c*(t/=d)*t*t + b;
- },
- easeOutCubic: function (x, t, b, c, d) {
- return c*((t=t/d-1)*t*t + 1) + b;
- },
- easeInOutCubic: function (x, t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t*t + b;
- return c/2*((t-=2)*t*t + 2) + b;
- },
- easeInQuart: function (x, t, b, c, d) {
- return c*(t/=d)*t*t*t + b;
- },
- easeOutQuart: function (x, t, b, c, d) {
- return -c * ((t=t/d-1)*t*t*t - 1) + b;
- },
- easeInOutQuart: function (x, t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
- return -c/2 * ((t-=2)*t*t*t - 2) + b;
- },
- easeInQuint: function (x, t, b, c, d) {
- return c*(t/=d)*t*t*t*t + b;
- },
- easeOutQuint: function (x, t, b, c, d) {
- return c*((t=t/d-1)*t*t*t*t + 1) + b;
- },
- easeInOutQuint: function (x, t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
- return c/2*((t-=2)*t*t*t*t + 2) + b;
- },
- easeInSine: function (x, t, b, c, d) {
- return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
- },
- easeOutSine: function (x, t, b, c, d) {
- return c * Math.sin(t/d * (Math.PI/2)) + b;
- },
- easeInOutSine: function (x, t, b, c, d) {
- return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
- },
- easeInExpo: function (x, t, b, c, d) {
- return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
- },
- easeOutExpo: function (x, t, b, c, d) {
- return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
- },
- easeInOutExpo: function (x, t, b, c, d) {
- if (t==0) return b;
- if (t==d) return b+c;
- if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
- return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
- },
- easeInCirc: function (x, t, b, c, d) {
- return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
- },
- easeOutCirc: function (x, t, b, c, d) {
- return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
- },
- easeInOutCirc: function (x, t, b, c, d) {
- if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
- return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
- },
- easeInElastic: function (x, t, b, c, d) {
- var s=1.70158;var p=0;var a=c;
- if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
- if (a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
+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 );
},
- easeOutElastic: function (x, t, b, c, d) {
- var s=1.70158;var p=0;var a=c;
- if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
- if (a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
+ Circ: function ( p ) {
+ return 1 - Math.sqrt( 1 - p * p );
},
- easeInOutElastic: function (x, t, b, c, d) {
- var s=1.70158;var p=0;var a=c;
- if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
- if (a < Math.abs(c)) { a=c; var s=p/4; }
- else var s = p/(2*Math.PI) * Math.asin (c/a);
- if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
- return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
- },
- easeInBack: function (x, t, b, c, d, s) {
- if (s == undefined) s = 1.70158;
- return c*(t/=d)*t*((s+1)*t - s) + b;
- },
- easeOutBack: function (x, t, b, c, d, s) {
- if (s == undefined) s = 1.70158;
- return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
- },
- easeInOutBack: function (x, t, b, c, d, s) {
- if (s == undefined) s = 1.70158;
- if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
- return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
+ 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 );
},
- easeInBounce: function (x, t, b, c, d) {
- return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b;
- },
- easeOutBounce: function (x, t, b, c, d) {
- if ((t/=d) < (1/2.75)) {
- return c*(7.5625*t*t) + b;
- } else if (t < (2/2.75)) {
- return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
- } else if (t < (2.5/2.75)) {
- return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
- } else {
- return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
- }
+ Back: function( p ) {
+ return p * p * ( 3 * p - 2 );
},
- easeInOutBounce: function (x, t, b, c, d) {
- if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
- return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
- }
-});
+ Bounce: function ( p ) {
+ var pow2,
+ bounce = 4;
-/*
- *
- * TERMS OF USE - EASING EQUATIONS
- *
- * Open source under the BSD License.
- *
- * Copyright 2001 Robert Penner
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * Neither the name of the author nor the names of contributors may be used to endorse
- * or promote products derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-})(jQuery);
-/*
- * jQuery UI Effects Blind 1.8.16
- *
- * Copyright 2011, 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/Blind
- *
- * Depends:
- * jquery.effects.core.js
- */
-(function( $, undefined ) {
-
-$.effects.blind = function(o) {
-
- return this.queue(function() {
-
- // Create element
- var el = $(this), props = ['position','top','bottom','left','right'];
-
- // Set options
- var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
- var direction = o.options.direction || 'vertical'; // Default direction
-
- // Adjust
- $.effects.save(el, props); el.show(); // Save & Show
- var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
- var ref = (direction == 'vertical') ? 'height' : 'width';
- var distance = (direction == 'vertical') ? wrapper.height() : wrapper.width();
- if(mode == 'show') wrapper.css(ref, 0); // Shift
-
- // Animation
- var animation = {};
- animation[ref] = mode == 'show' ? distance : 0;
-
- // Animate
- wrapper.animate(animation, o.duration, o.options.easing, function() {
- if(mode == 'hide') el.hide(); // Hide
- $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
- if(o.callback) o.callback.apply(el[0], arguments); // Callback
- el.dequeue();
- });
-
- });
-
-};
-
-})(jQuery);
-/*
- * jQuery UI Effects Bounce 1.8.16
- *
- * Copyright 2011, 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/Bounce
- *
- * Depends:
- * jquery.effects.core.js
- */
-(function( $, undefined ) {
-
-$.effects.bounce = function(o) {
-
- return this.queue(function() {
-
- // Create element
- var el = $(this), props = ['position','top','bottom','left','right'];
-
- // Set options
- var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
- var direction = o.options.direction || 'up'; // Default direction
- var distance = o.options.distance || 20; // Default distance
- var times = o.options.times || 5; // Default # of times
- var speed = o.duration || 250; // Default speed per bounce
- if (/show|hide/.test(mode)) props.push('opacity'); // Avoid touching opacity to prevent clearType and PNG issues in IE
-
- // Adjust
- $.effects.save(el, props); el.show(); // Save & Show
- $.effects.createWrapper(el); // Create Wrapper
- var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
- var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
- var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 3 : el.outerWidth({margin:true}) / 3);
- if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
- if (mode == 'hide') distance = distance / (times * 2);
- if (mode != 'hide') times--;
-
- // Animate
- if (mode == 'show') { // Show Bounce
- var animation = {opacity: 1};
- animation[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
- el.animate(animation, speed / 2, o.options.easing);
- distance = distance / 2;
- times--;
- };
- for (var i = 0; i < times; i++) { // Bounces
- var animation1 = {}, animation2 = {};
- animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
- animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
- el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing);
- distance = (mode == 'hide') ? distance * 2 : distance / 2;
- };
- if (mode == 'hide') { // Last Bounce
- var animation = {opacity: 0};
- animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
- el.animate(animation, speed / 2, o.options.easing, function(){
- el.hide(); // Hide
- $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
- if(o.callback) o.callback.apply(this, arguments); // Callback
- });
- } else {
- var animation1 = {}, animation2 = {};
- animation1[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
- animation2[ref] = (motion == 'pos' ? '+=' : '-=') + distance;
- el.animate(animation1, speed / 2, o.options.easing).animate(animation2, speed / 2, o.options.easing, function(){
- $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
- if(o.callback) o.callback.apply(this, arguments); // Callback
- });
- };
- el.queue('fx', function() { el.dequeue(); });
- el.dequeue();
- });
-
-};
-
-})(jQuery);
-/*
- * jQuery UI Effects Clip 1.8.16
- *
- * Copyright 2011, 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/Clip
- *
- * Depends:
- * jquery.effects.core.js
- */
-(function( $, undefined ) {
-
-$.effects.clip = function(o) {
-
- return this.queue(function() {
-
- // Create element
- var el = $(this), props = ['position','top','bottom','left','right','height','width'];
-
- // Set options
- var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
- var direction = o.options.direction || 'vertical'; // Default direction
-
- // Adjust
- $.effects.save(el, props); el.show(); // Save & Show
- var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
- var animate = el[0].tagName == 'IMG' ? wrapper : el;
- var ref = {
- size: (direction == 'vertical') ? 'height' : 'width',
- position: (direction == 'vertical') ? 'top' : 'left'
- };
- var distance = (direction == 'vertical') ? animate.height() : animate.width();
- if(mode == 'show') { animate.css(ref.size, 0); animate.css(ref.position, distance / 2); } // Shift
-
- // Animation
- var animation = {};
- animation[ref.size] = mode == 'show' ? distance : 0;
- animation[ref.position] = mode == 'show' ? 0 : distance / 2;
-
- // Animate
- animate.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
- if(mode == 'hide') el.hide(); // Hide
- $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
- if(o.callback) o.callback.apply(el[0], arguments); // Callback
- el.dequeue();
- }});
-
- });
-
-};
-
-})(jQuery);
-/*
- * jQuery UI Effects Drop 1.8.16
- *
- * Copyright 2011, 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/Drop
- *
- * Depends:
- * jquery.effects.core.js
- */
-(function( $, undefined ) {
-
-$.effects.drop = function(o) {
-
- return this.queue(function() {
-
- // Create element
- var el = $(this), props = ['position','top','bottom','left','right','opacity'];
-
- // Set options
- var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
- var direction = o.options.direction || 'left'; // Default Direction
-
- // Adjust
- $.effects.save(el, props); el.show(); // Save & Show
- $.effects.createWrapper(el); // Create Wrapper
- var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
- var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
- var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 2 : el.outerWidth({margin:true}) / 2);
- if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
-
- // Animation
- var animation = {opacity: mode == 'show' ? 1 : 0};
- animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
-
- // Animate
- el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
- if(mode == 'hide') el.hide(); // Hide
- $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
- if(o.callback) o.callback.apply(this, arguments); // Callback
- el.dequeue();
- }});
-
- });
-
-};
-
-})(jQuery);
-/*
- * jQuery UI Effects Explode 1.8.16
- *
- * Copyright 2011, 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/Explode
- *
- * Depends:
- * jquery.effects.core.js
- */
-(function( $, undefined ) {
-
-$.effects.explode = function(o) {
-
- return this.queue(function() {
-
- var rows = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
- var cells = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
-
- o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode;
- var el = $(this).show().css('visibility', 'hidden');
- var offset = el.offset();
-
- //Substract the margins - not fixing the problem yet.
- offset.top -= parseInt(el.css("marginTop"),10) || 0;
- offset.left -= parseInt(el.css("marginLeft"),10) || 0;
-
- var width = el.outerWidth(true);
- var height = el.outerHeight(true);
-
- for(var i=0;i<rows;i++) { // =
- for(var j=0;j<cells;j++) { // ||
- el
- .clone()
- .appendTo('body')
- .wrap('<div></div>')
- .css({
- position: 'absolute',
- visibility: 'visible',
- left: -j*(width/cells),
- top: -i*(height/rows)
- })
- .parent()
- .addClass('ui-effects-explode')
- .css({
- position: 'absolute',
- overflow: 'hidden',
- width: width/cells,
- height: height/rows,
- left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0),
- top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0),
- opacity: o.options.mode == 'show' ? 0 : 1
- }).animate({
- left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)),
- top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)),
- opacity: o.options.mode == 'show' ? 1 : 0
- }, o.duration || 500);
- }
+ 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 );
}
+});
- // Set a timeout, to call the callback approx. when the other animations have finished
- setTimeout(function() {
-
- o.options.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide();
- if(o.callback) o.callback.apply(el[0]); // Callback
- el.dequeue();
-
- $('div.ui-effects-explode').remove();
-
- }, o.duration || 500);
-
-
- });
-
-};
-
-})(jQuery);
-/*
- * jQuery UI Effects Fade 1.8.16
- *
- * Copyright 2011, 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/Fade
- *
- * Depends:
- * jquery.effects.core.js
- */
-(function( $, undefined ) {
-
-$.effects.fade = function(o) {
- return this.queue(function() {
- var elem = $(this),
- mode = $.effects.setMode(elem, o.options.mode || 'hide');
-
- elem.animate({ opacity: mode }, {
- queue: false,
- duration: o.duration,
- easing: o.options.easing,
- complete: function() {
- (o.callback && o.callback.apply(this, arguments));
- elem.dequeue();
- }
- });
- });
-};
-
-})(jQuery);
-/*
- * jQuery UI Effects Fold 1.8.16
- *
- * Copyright 2011, 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/Fold
- *
- * Depends:
- * jquery.effects.core.js
- */
-(function( $, undefined ) {
-
-$.effects.fold = function(o) {
-
- return this.queue(function() {
-
- // Create element
- var el = $(this), props = ['position','top','bottom','left','right'];
-
- // Set options
- var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
- var size = o.options.size || 15; // Default fold size
- var horizFirst = !(!o.options.horizFirst); // Ensure a boolean value
- var duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2;
-
- // Adjust
- $.effects.save(el, props); el.show(); // Save & Show
- var wrapper = $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
- var widthFirst = ((mode == 'show') != horizFirst);
- var ref = widthFirst ? ['width', 'height'] : ['height', 'width'];
- var distance = widthFirst ? [wrapper.width(), wrapper.height()] : [wrapper.height(), wrapper.width()];
- var percent = /([0-9]+)%/.exec(size);
- if(percent) size = parseInt(percent[1],10) / 100 * distance[mode == 'hide' ? 0 : 1];
- if(mode == 'show') wrapper.css(horizFirst ? {height: 0, width: size} : {height: size, width: 0}); // Shift
-
- // Animation
- var animation1 = {}, animation2 = {};
- animation1[ref[0]] = mode == 'show' ? distance[0] : size;
- animation2[ref[1]] = mode == 'show' ? distance[1] : 0;
-
- // Animate
- wrapper.animate(animation1, duration, o.options.easing)
- .animate(animation2, duration, o.options.easing, function() {
- if(mode == 'hide') el.hide(); // Hide
- $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
- if(o.callback) o.callback.apply(el[0], arguments); // Callback
- el.dequeue();
- });
-
- });
-
-};
-
-})(jQuery);
-/*
- * jQuery UI Effects Highlight 1.8.16
- *
- * Copyright 2011, 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/Highlight
- *
- * Depends:
- * jquery.effects.core.js
- */
-(function( $, undefined ) {
-
-$.effects.highlight = function(o) {
- return this.queue(function() {
- var elem = $(this),
- props = ['backgroundImage', 'backgroundColor', 'opacity'],
- mode = $.effects.setMode(elem, o.options.mode || 'show'),
- animation = {
- backgroundColor: elem.css('backgroundColor')
- };
-
- if (mode == 'hide') {
- animation.opacity = 0;
- }
-
- $.effects.save(elem, props);
- elem
- .show()
- .css({
- backgroundImage: 'none',
- backgroundColor: o.options.color || '#ffff99'
- })
- .animate(animation, {
- queue: false,
- duration: o.duration,
- easing: o.options.easing,
- complete: function() {
- (mode == 'hide' && elem.hide());
- $.effects.restore(elem, props);
- (mode == 'show' && !$.support.opacity && this.style.removeAttribute('filter'));
- (o.callback && o.callback.apply(this, arguments));
- elem.dequeue();
- }
- });
- });
-};
-
-})(jQuery);
-/*
- * jQuery UI Effects Pulsate 1.8.16
- *
- * Copyright 2011, 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/Pulsate
- *
- * Depends:
- * jquery.effects.core.js
- */
-(function( $, undefined ) {
-
-$.effects.pulsate = function(o) {
- return this.queue(function() {
- var elem = $(this),
- mode = $.effects.setMode(elem, o.options.mode || 'show');
- times = ((o.options.times || 5) * 2) - 1;
- duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2,
- isVisible = elem.is(':visible'),
- animateTo = 0;
-
- if (!isVisible) {
- elem.css('opacity', 0).show();
- animateTo = 1;
- }
-
- if ((mode == 'hide' && isVisible) || (mode == 'show' && !isVisible)) {
- times--;
- }
-
- for (var i = 0; i < times; i++) {
- elem.animate({ opacity: animateTo }, duration, o.options.easing);
- animateTo = (animateTo + 1) % 2;
- }
-
- elem.animate({ opacity: animateTo }, duration, o.options.easing, function() {
- if (animateTo == 0) {
- elem.hide();
- }
- (o.callback && o.callback.apply(this, arguments));
- });
-
- elem
- .queue('fx', function() { elem.dequeue(); })
- .dequeue();
- });
-};
-
-})(jQuery);
-/*
- * jQuery UI Effects Scale 1.8.16
- *
- * Copyright 2011, 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/Scale
- *
- * Depends:
- * jquery.effects.core.js
- */
-(function( $, undefined ) {
-
-$.effects.puff = function(o) {
- return this.queue(function() {
- var elem = $(this),
- mode = $.effects.setMode(elem, o.options.mode || 'hide'),
- percent = parseInt(o.options.percent, 10) || 150,
- factor = percent / 100,
- original = { height: elem.height(), width: elem.width() };
-
- $.extend(o.options, {
- fade: true,
- mode: mode,
- percent: mode == 'hide' ? percent : 100,
- from: mode == 'hide'
- ? original
- : {
- height: original.height * factor,
- width: original.width * factor
- }
- });
-
- elem.effect('scale', o.options, o.duration, o.callback);
- elem.dequeue();
- });
-};
-
-$.effects.scale = function(o) {
-
- return this.queue(function() {
-
- // Create element
- var el = $(this);
-
- // Set options
- var options = $.extend(true, {}, o.options);
- var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
- var percent = parseInt(o.options.percent,10) || (parseInt(o.options.percent,10) == 0 ? 0 : (mode == 'hide' ? 0 : 100)); // Set default scaling percent
- var direction = o.options.direction || 'both'; // Set default axis
- var origin = o.options.origin; // The origin of the scaling
- if (mode != 'effect') { // Set default origin and restore for show/hide
- options.origin = origin || ['middle','center'];
- options.restore = true;
- }
- var original = {height: el.height(), width: el.width()}; // Save original
- el.from = o.options.from || (mode == 'show' ? {height: 0, width: 0} : original); // Default from state
-
- // Adjust
- var factor = { // Set scaling factor
- y: direction != 'horizontal' ? (percent / 100) : 1,
- x: direction != 'vertical' ? (percent / 100) : 1
- };
- el.to = {height: original.height * factor.y, width: original.width * factor.x}; // Set to state
-
- if (o.options.fade) { // Fade option to support puff
- if (mode == 'show') {el.from.opacity = 0; el.to.opacity = 1;};
- if (mode == 'hide') {el.from.opacity = 1; el.to.opacity = 0;};
- };
-
- // Animation
- options.from = el.from; options.to = el.to; options.mode = mode;
-
- // Animate
- el.effect('size', options, o.duration, o.callback);
- el.dequeue();
- });
-
-};
-
-$.effects.size = function(o) {
-
- return this.queue(function() {
-
- // Create element
- var el = $(this), props = ['position','top','bottom','left','right','width','height','overflow','opacity'];
- var props1 = ['position','top','bottom','left','right','overflow','opacity']; // Always restore
- var props2 = ['width','height','overflow']; // Copy for children
- var cProps = ['fontSize'];
- var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom'];
- var hProps = ['borderLeftWidth', 'borderRightWidth', 'paddingLeft', 'paddingRight'];
-
- // Set options
- var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
- var restore = o.options.restore || false; // Default restore
- var scale = o.options.scale || 'both'; // Default scale mode
- var origin = o.options.origin; // The origin of the sizing
- var original = {height: el.height(), width: el.width()}; // Save original
- el.from = o.options.from || original; // Default from state
- el.to = o.options.to || original; // Default to state
- // Adjust
- if (origin) { // Calculate baseline shifts
- var baseline = $.effects.getBaseline(origin, original);
- el.from.top = (original.height - el.from.height) * baseline.y;
- el.from.left = (original.width - el.from.width) * baseline.x;
- el.to.top = (original.height - el.to.height) * baseline.y;
- el.to.left = (original.width - el.to.width) * baseline.x;
- };
- var factor = { // Set scaling factor
- from: {y: el.from.height / original.height, x: el.from.width / original.width},
- to: {y: el.to.height / original.height, x: el.to.width / original.width}
- };
- if (scale == 'box' || scale == 'both') { // Scale the css box
- if (factor.from.y != factor.to.y) { // Vertical props scaling
- props = props.concat(vProps);
- el.from = $.effects.setTransition(el, vProps, factor.from.y, el.from);
- el.to = $.effects.setTransition(el, vProps, factor.to.y, el.to);
- };
- if (factor.from.x != factor.to.x) { // Horizontal props scaling
- props = props.concat(hProps);
- el.from = $.effects.setTransition(el, hProps, factor.from.x, el.from);
- el.to = $.effects.setTransition(el, hProps, factor.to.x, el.to);
- };
- };
- if (scale == 'content' || scale == 'both') { // Scale the content
- if (factor.from.y != factor.to.y) { // Vertical props scaling
- props = props.concat(cProps);
- el.from = $.effects.setTransition(el, cProps, factor.from.y, el.from);
- el.to = $.effects.setTransition(el, cProps, factor.to.y, el.to);
- };
- };
- $.effects.save(el, restore ? props : props1); el.show(); // Save & Show
- $.effects.createWrapper(el); // Create Wrapper
- el.css('overflow','hidden').css(el.from); // Shift
-
- // Animate
- if (scale == 'content' || scale == 'both') { // Scale the children
- vProps = vProps.concat(['marginTop','marginBottom']).concat(cProps); // Add margins/font-size
- hProps = hProps.concat(['marginLeft','marginRight']); // Add margins
- props2 = props.concat(vProps).concat(hProps); // Concat
- el.find("*[width]").each(function(){
- child = $(this);
- if (restore) $.effects.save(child, props2);
- var c_original = {height: child.height(), width: child.width()}; // Save original
- child.from = {height: c_original.height * factor.from.y, width: c_original.width * factor.from.x};
- child.to = {height: c_original.height * factor.to.y, width: c_original.width * factor.to.x};
- if (factor.from.y != factor.to.y) { // Vertical props scaling
- child.from = $.effects.setTransition(child, vProps, factor.from.y, child.from);
- child.to = $.effects.setTransition(child, vProps, factor.to.y, child.to);
- };
- if (factor.from.x != factor.to.x) { // Horizontal props scaling
- child.from = $.effects.setTransition(child, hProps, factor.from.x, child.from);
- child.to = $.effects.setTransition(child, hProps, factor.to.x, child.to);
- };
- child.css(child.from); // Shift children
- child.animate(child.to, o.duration, o.options.easing, function(){
- if (restore) $.effects.restore(child, props2); // Restore children
- }); // Animate children
- });
- };
-
- // Animate
- el.animate(el.to, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
- if (el.to.opacity === 0) {
- el.css('opacity', el.from.opacity);
- }
- if(mode == 'hide') el.hide(); // Hide
- $.effects.restore(el, restore ? props : props1); $.effects.removeWrapper(el); // Restore
- if(o.callback) o.callback.apply(this, arguments); // Callback
- el.dequeue();
- }});
-
- });
-
-};
-
-})(jQuery);
-/*
- * jQuery UI Effects Shake 1.8.16
- *
- * Copyright 2011, 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/Shake
- *
- * Depends:
- * jquery.effects.core.js
- */
-(function( $, undefined ) {
-
-$.effects.shake = function(o) {
-
- return this.queue(function() {
-
- // Create element
- var el = $(this), props = ['position','top','bottom','left','right'];
-
- // Set options
- var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
- var direction = o.options.direction || 'left'; // Default direction
- var distance = o.options.distance || 20; // Default distance
- var times = o.options.times || 3; // Default # of times
- var speed = o.duration || o.options.duration || 140; // Default speed per shake
-
- // Adjust
- $.effects.save(el, props); el.show(); // Save & Show
- $.effects.createWrapper(el); // Create Wrapper
- var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
- var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
-
- // Animation
- var animation = {}, animation1 = {}, animation2 = {};
- animation[ref] = (motion == 'pos' ? '-=' : '+=') + distance;
- animation1[ref] = (motion == 'pos' ? '+=' : '-=') + distance * 2;
- animation2[ref] = (motion == 'pos' ? '-=' : '+=') + distance * 2;
-
- // Animate
- el.animate(animation, speed, o.options.easing);
- for (var i = 1; i < times; i++) { // Shakes
- el.animate(animation1, speed, o.options.easing).animate(animation2, speed, o.options.easing);
- };
- el.animate(animation1, speed, o.options.easing).
- animate(animation, speed / 2, o.options.easing, function(){ // Last shake
- $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
- if(o.callback) o.callback.apply(this, arguments); // Callback
- });
- el.queue('fx', function() { el.dequeue(); });
- el.dequeue();
- });
-
-};
-
-})(jQuery);
-/*
- * jQuery UI Effects Slide 1.8.16
- *
- * Copyright 2011, 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/Slide
- *
- * Depends:
- * jquery.effects.core.js
- */
-(function( $, undefined ) {
-
-$.effects.slide = function(o) {
-
- return this.queue(function() {
-
- // Create element
- var el = $(this), props = ['position','top','bottom','left','right'];
-
- // Set options
- var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
- var direction = o.options.direction || 'left'; // Default Direction
-
- // Adjust
- $.effects.save(el, props); el.show(); // Save & Show
- $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
- var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
- var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
- var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) : el.outerWidth({margin:true}));
- if (mode == 'show') el.css(ref, motion == 'pos' ? (isNaN(distance) ? "-" + distance : -distance) : distance); // Shift
-
- // Animation
- var animation = {};
- animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
-
- // Animate
- el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
- if(mode == 'hide') el.hide(); // Hide
- $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
- if(o.callback) o.callback.apply(this, arguments); // Callback
- el.dequeue();
- }});
+$.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));
-})(jQuery);
-/*
- * jQuery UI Effects Transfer 1.8.16
- *
- * Copyright 2011, 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/Transfer
- *
- * Depends:
- * jquery.effects.core.js
- */
(function( $, undefined ) {
-$.effects.transfer = function(o) {
- return this.queue(function() {
- var elem = $(this),
- target = $(o.options.to),
- endPosition = target.offset(),
- animation = {
- top: endPosition.top,
- left: endPosition.left,
- height: target.innerHeight(),
- width: target.innerWidth()
- },
- startPosition = elem.offset(),
- transfer = $('<div class="ui-effects-transfer"></div>')
- .appendTo(document.body)
- .addClass(o.options.className)
- .css({
- top: startPosition.top,
- left: startPosition.left,
- height: elem.innerHeight(),
- width: elem.innerWidth(),
- position: 'absolute'
- })
- .animate(animation, o.duration, o.options.easing, function() {
- transfer.remove();
- (o.callback && o.callback.apply(elem[0], arguments));
- elem.dequeue();
- });
- });
-};
+var uid = 0,
+ hideProps = {},
+ showProps = {};
-})(jQuery);
-/*
- * jQuery UI Accordion 1.8.16
- *
- * Copyright 2011, 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/Accordion
- *
- * Depends:
- * jquery.ui.core.js
- * jquery.ui.widget.js
- */
-(function( $, undefined ) {
+hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
+ hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
+showProps.height = showProps.paddingTop = showProps.paddingBottom =
+ showProps.borderTopWidth = showProps.borderBottomWidth = "show";
$.widget( "ui.accordion", {
+ version: "1.9.2",
options: {
active: 0,
- animated: "slide",
- autoHeight: true,
- clearStyle: false,
+ animate: {},
collapsible: false,
event: "click",
- fillSpace: false,
header: "> li > :first-child,> :not(li):even",
+ heightStyle: "auto",
icons: {
- header: "ui-icon-triangle-1-e",
- headerSelected: "ui-icon-triangle-1-s"
+ activeHeader: "ui-icon-triangle-1-s",
+ header: "ui-icon-triangle-1-e"
},
- navigation: false,
- navigationFilter: function() {
- return this.href.toLowerCase() === location.href.toLowerCase();
- }
+
+ // callbacks
+ activate: null,
+ beforeActivate: null
},
_create: function() {
- var self = this,
- options = self.options;
-
- self.running = 0;
-
- self.element
- .addClass( "ui-accordion ui-widget ui-helper-reset" )
- // in lack of child-selectors in CSS
- // we need to mark top-LIs in a UL-accordion for some IE-fix
- .children( "li" )
- .addClass( "ui-accordion-li-fix" );
-
- self.headers = self.element.find( options.header )
- .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" )
- .bind( "mouseenter.accordion", function() {
- if ( options.disabled ) {
- return;
- }
- $( this ).addClass( "ui-state-hover" );
- })
- .bind( "mouseleave.accordion", function() {
- if ( options.disabled ) {
- return;
- }
- $( this ).removeClass( "ui-state-hover" );
- })
- .bind( "focus.accordion", function() {
- if ( options.disabled ) {
- return;
- }
- $( this ).addClass( "ui-state-focus" );
- })
- .bind( "blur.accordion", function() {
- if ( options.disabled ) {
- return;
- }
- $( this ).removeClass( "ui-state-focus" );
- });
-
- self.headers.next()
- .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" );
-
- if ( options.navigation ) {
- var current = self.element.find( "a" ).filter( options.navigationFilter ).eq( 0 );
- if ( current.length ) {
- var header = current.closest( ".ui-accordion-header" );
- if ( header.length ) {
- // anchor within header
- self.active = header;
- } else {
- // anchor within content
- self.active = current.closest( ".ui-accordion-content" ).prev();
- }
- }
- }
-
- self.active = self._findActive( self.active || options.active )
- .addClass( "ui-state-default ui-state-active" )
- .toggleClass( "ui-corner-all" )
- .toggleClass( "ui-corner-top" );
- self.active.next().addClass( "ui-accordion-content-active" );
+ var accordionId = this.accordionId = "ui-accordion-" +
+ (this.element.attr( "id" ) || ++uid),
+ options = this.options;
+
+ this.prevShow = this.prevHide = $();
+ this.element.addClass( "ui-accordion ui-widget ui-helper-reset" );
+
+ this.headers = this.element.find( options.header )
+ .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
+ this._hoverable( this.headers );
+ this._focusable( this.headers );
+
+ this.headers.next()
+ .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
+ .hide();
+
+ // don't allow collapsible: false and active: false / null
+ if ( !options.collapsible && (options.active === false || options.active == null) ) {
+ options.active = 0;
+ }
+ // handle negative values
+ if ( options.active < 0 ) {
+ options.active += this.headers.length;
+ }
+ this.active = this._findActive( options.active )
+ .addClass( "ui-accordion-header-active ui-state-active" )
+ .toggleClass( "ui-corner-all ui-corner-top" );
+ this.active.next()
+ .addClass( "ui-accordion-content-active" )
+ .show();
+
+ this._createIcons();
+ this.refresh();
- self._createIcons();
- self.resize();
-
// ARIA
- self.element.attr( "role", "tablist" );
+ this.element.attr( "role", "tablist" );
- self.headers
+ this.headers
.attr( "role", "tab" )
- .bind( "keydown.accordion", function( event ) {
- return self._keydown( event );
+ .each(function( i ) {
+ var header = $( this ),
+ headerId = header.attr( "id" ),
+ panel = header.next(),
+ panelId = panel.attr( "id" );
+ if ( !headerId ) {
+ headerId = accordionId + "-header-" + i;
+ header.attr( "id", headerId );
+ }
+ if ( !panelId ) {
+ panelId = accordionId + "-panel-" + i;
+ panel.attr( "id", panelId );
+ }
+ header.attr( "aria-controls", panelId );
+ panel.attr( "aria-labelledby", headerId );
})
.next()
.attr( "role", "tabpanel" );
- self.headers
- .not( self.active || "" )
+ this.headers
+ .not( this.active )
.attr({
- "aria-expanded": "false",
"aria-selected": "false",
tabIndex: -1
})
.next()
+ .attr({
+ "aria-expanded": "false",
+ "aria-hidden": "true"
+ })
.hide();
// make sure at least one header is in the tab order
- if ( !self.active.length ) {
- self.headers.eq( 0 ).attr( "tabIndex", 0 );
+ if ( !this.active.length ) {
+ this.headers.eq( 0 ).attr( "tabIndex", 0 );
} else {
- self.active
+ this.active.attr({
+ "aria-selected": "true",
+ tabIndex: 0
+ })
+ .next()
.attr({
"aria-expanded": "true",
- "aria-selected": "true",
- tabIndex: 0
+ "aria-hidden": "false"
});
}
- // only need links in tab order for Safari
- if ( !$.browser.safari ) {
- self.headers.find( "a" ).attr( "tabIndex", -1 );
- }
+ this._on( this.headers, { keydown: "_keydown" });
+ this._on( this.headers.next(), { keydown: "_panelKeyDown" });
+ this._setupEvents( options.event );
+ },
- if ( options.event ) {
- self.headers.bind( options.event.split(" ").join(".accordion ") + ".accordion", function(event) {
- self._clickHandler.call( self, event, this );
- event.preventDefault();
- });
- }
+ _getCreateEventData: function() {
+ return {
+ header: this.active,
+ content: !this.active.length ? $() : this.active.next()
+ };
},
_createIcons: function() {
- var options = this.options;
- if ( options.icons ) {
- $( "<span></span>" )
- .addClass( "ui-icon " + options.icons.header )
+ var icons = this.options.icons;
+ if ( icons ) {
+ $( "<span>" )
+ .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
.prependTo( this.headers );
- this.active.children( ".ui-icon" )
- .toggleClass(options.icons.header)
- .toggleClass(options.icons.headerSelected);
- this.element.addClass( "ui-accordion-icons" );
+ this.active.children( ".ui-accordion-header-icon" )
+ .removeClass( icons.header )
+ .addClass( icons.activeHeader );
+ this.headers.addClass( "ui-accordion-icons" );
}
},
_destroyIcons: function() {
- this.headers.children( ".ui-icon" ).remove();
- this.element.removeClass( "ui-accordion-icons" );
+ this.headers
+ .removeClass( "ui-accordion-icons" )
+ .children( ".ui-accordion-header-icon" )
+ .remove();
},
- destroy: function() {
- var options = this.options;
+ _destroy: function() {
+ var contents;
+ // clean up main element
this.element
.removeClass( "ui-accordion ui-widget ui-helper-reset" )
.removeAttr( "role" );
+ // clean up headers
this.headers
- .unbind( ".accordion" )
- .removeClass( "ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
+ .removeClass( "ui-accordion-header ui-accordion-header-active ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
.removeAttr( "role" )
- .removeAttr( "aria-expanded" )
.removeAttr( "aria-selected" )
- .removeAttr( "tabIndex" );
-
- this.headers.find( "a" ).removeAttr( "tabIndex" );
+ .removeAttr( "aria-controls" )
+ .removeAttr( "tabIndex" )
+ .each(function() {
+ if ( /^ui-accordion/.test( this.id ) ) {
+ this.removeAttribute( "id" );
+ }
+ });
this._destroyIcons();
- var contents = this.headers.next()
+
+ // clean up content panels
+ contents = this.headers.next()
.css( "display", "" )
.removeAttr( "role" )
- .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled" );
- if ( options.autoHeight || options.fillHeight ) {
+ .removeAttr( "aria-expanded" )
+ .removeAttr( "aria-hidden" )
+ .removeAttr( "aria-labelledby" )
+ .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
+ .each(function() {
+ if ( /^ui-accordion/.test( this.id ) ) {
+ this.removeAttribute( "id" );
+ }
+ });
+ if ( this.options.heightStyle !== "content" ) {
contents.css( "height", "" );
}
-
- return $.Widget.prototype.destroy.call( this );
},
_setOption: function( key, value ) {
- $.Widget.prototype._setOption.apply( this, arguments );
-
- if ( key == "active" ) {
- this.activate( value );
+ if ( key === "active" ) {
+ // _activate() will handle invalid values and update this.options
+ this._activate( value );
+ return;
+ }
+
+ if ( key === "event" ) {
+ if ( this.options.event ) {
+ this._off( this.headers, this.options.event );
+ }
+ this._setupEvents( value );
+ }
+
+ 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 == "icons" ) {
+
+ if ( key === "icons" ) {
this._destroyIcons();
if ( value ) {
this._createIcons();
}
}
+
// #5332 - opacity doesn't cascade to positioned elements in IE
// so we need to add the disabled class to the headers and panels
- if ( key == "disabled" ) {
- this.headers.add(this.headers.next())
- [ value ? "addClass" : "removeClass" ](
- "ui-accordion-disabled ui-state-disabled" );
+ if ( key === "disabled" ) {
+ this.headers.add( this.headers.next() )
+ .toggleClass( "ui-state-disabled", !!value );
}
},
_keydown: function( event ) {
- if ( this.options.disabled || event.altKey || event.ctrlKey ) {
+ if ( event.altKey || event.ctrlKey ) {
return;
}
@@ -5875,32 +5756,57 @@ $.widget( "ui.accordion", {
break;
case keyCode.SPACE:
case keyCode.ENTER:
- this._clickHandler( { target: event.target }, event.target );
- event.preventDefault();
+ this._eventHandler( event );
+ break;
+ case keyCode.HOME:
+ toFocus = this.headers[ 0 ];
+ break;
+ case keyCode.END:
+ toFocus = this.headers[ length - 1 ];
+ break;
}
if ( toFocus ) {
$( event.target ).attr( "tabIndex", -1 );
$( toFocus ).attr( "tabIndex", 0 );
toFocus.focus();
- return false;
+ event.preventDefault();
}
-
- return true;
},
- resize: function() {
- var options = this.options,
- maxHeight;
+ _panelKeyDown : function( event ) {
+ if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
+ $( event.currentTarget ).prev().focus();
+ }
+ },
- if ( options.fillSpace ) {
- if ( $.browser.msie ) {
- var defOverflow = this.element.parent().css( "overflow" );
- this.element.parent().css( "overflow", "hidden");
- }
- maxHeight = this.element.parent().height();
- if ($.browser.msie) {
- this.element.parent().css( "overflow", defOverflow );
+ refresh: function() {
+ var maxHeight, overflow,
+ heightStyle = this.options.heightStyle,
+ parent = this.element.parent();
+
+
+ if ( heightStyle === "fill" ) {
+ // IE 6 treats height like minHeight, so we need to turn off overflow
+ // in order to get a reliable height
+ // we use the minHeight support test because we assume that only
+ // browsers that don't support minHeight will treat height as minHeight
+ if ( !$.support.minHeight ) {
+ overflow = parent.css( "overflow" );
+ parent.css( "overflow", "hidden");
+ }
+ maxHeight = parent.height();
+ this.element.siblings( ":visible" ).each(function() {
+ var elem = $( this ),
+ position = elem.css( "position" );
+
+ if ( position === "absolute" || position === "fixed" ) {
+ return;
+ }
+ maxHeight -= elem.outerHeight( true );
+ });
+ if ( overflow ) {
+ parent.css( "overflow", overflow );
}
this.headers.each(function() {
@@ -5913,364 +5819,423 @@ $.widget( "ui.accordion", {
$( this ).innerHeight() + $( this ).height() ) );
})
.css( "overflow", "auto" );
- } else if ( options.autoHeight ) {
+ } else if ( heightStyle === "auto" ) {
maxHeight = 0;
this.headers.next()
.each(function() {
- maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
+ maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
})
.height( maxHeight );
}
-
- return this;
},
- activate: function( index ) {
- // TODO this gets called on init, changing the option without an explicit call for that
- this.options.active = index;
- // call clickHandler with custom event
+ _activate: function( index ) {
var active = this._findActive( index )[ 0 ];
- this._clickHandler( { target: active }, active );
- return this;
+ // trying to activate the already active panel
+ if ( active === this.active[ 0 ] ) {
+ return;
+ }
+
+ // trying to collapse, simulate a click on the currently active header
+ active = active || this.active[ 0 ];
+
+ this._eventHandler({
+ target: active,
+ currentTarget: active,
+ preventDefault: $.noop
+ });
},
_findActive: function( selector ) {
- return selector
- ? typeof selector === "number"
- ? this.headers.filter( ":eq(" + selector + ")" )
- : this.headers.not( this.headers.not( selector ) )
- : selector === false
- ? $( [] )
- : this.headers.filter( ":eq(0)" );
+ return typeof selector === "number" ? this.headers.eq( selector ) : $();
},
- // TODO isn't event.target enough? why the separate target argument?
- _clickHandler: function( event, target ) {
- var options = this.options;
- if ( options.disabled ) {
- return;
- }
-
- // called only when using activate(false) to close all parts programmatically
- if ( !event.target ) {
- if ( !options.collapsible ) {
- return;
- }
- this.active
- .removeClass( "ui-state-active ui-corner-top" )
- .addClass( "ui-state-default ui-corner-all" )
- .children( ".ui-icon" )
- .removeClass( options.icons.headerSelected )
- .addClass( options.icons.header );
- this.active.next().addClass( "ui-accordion-content-active" );
- var toHide = this.active.next(),
- data = {
- options: options,
- newHeader: $( [] ),
- oldHeader: options.active,
- newContent: $( [] ),
- oldContent: toHide
- },
- toShow = ( this.active = $( [] ) );
- this._toggle( toShow, toHide, data );
+ _setupEvents: function( event ) {
+ var events = {};
+ if ( !event ) {
return;
}
+ $.each( event.split(" "), function( index, eventName ) {
+ events[ eventName ] = "_eventHandler";
+ });
+ this._on( this.headers, events );
+ },
- // get the click target
- var clicked = $( event.currentTarget || target ),
- clickedIsActive = clicked[0] === this.active[0];
+ _eventHandler: function( event ) {
+ var options = this.options,
+ active = this.active,
+ clicked = $( event.currentTarget ),
+ clickedIsActive = clicked[ 0 ] === active[ 0 ],
+ collapsing = clickedIsActive && options.collapsible,
+ toShow = collapsing ? $() : clicked.next(),
+ toHide = active.next(),
+ eventData = {
+ oldHeader: active,
+ oldPanel: toHide,
+ newHeader: collapsing ? $() : clicked,
+ newPanel: toShow
+ };
- // TODO the option is changed, is that correct?
- // TODO if it is correct, shouldn't that happen after determining that the click is valid?
- options.active = options.collapsible && clickedIsActive ?
- false :
- this.headers.index( clicked );
+ event.preventDefault();
- // if animations are still active, or the active header is the target, ignore click
- if ( this.running || ( !options.collapsible && clickedIsActive ) ) {
+ if (
+ // click on active header, but not collapsible
+ ( clickedIsActive && !options.collapsible ) ||
+ // allow canceling activation
+ ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
return;
}
- // find elements to show and hide
- var active = this.active,
- toShow = clicked.next(),
- toHide = this.active.next(),
- data = {
- options: options,
- newHeader: clickedIsActive && options.collapsible ? $([]) : clicked,
- oldHeader: this.active,
- newContent: clickedIsActive && options.collapsible ? $([]) : toShow,
- oldContent: toHide
- },
- down = this.headers.index( this.active[0] ) > this.headers.index( clicked[0] );
+ options.active = collapsing ? false : this.headers.index( clicked );
// when the call to ._toggle() comes after the class changes
// it causes a very odd bug in IE 8 (see #6720)
- this.active = clickedIsActive ? $([]) : clicked;
- this._toggle( toShow, toHide, data, clickedIsActive, down );
+ this.active = clickedIsActive ? $() : clicked;
+ this._toggle( eventData );
// switch classes
- active
- .removeClass( "ui-state-active ui-corner-top" )
- .addClass( "ui-state-default ui-corner-all" )
- .children( ".ui-icon" )
- .removeClass( options.icons.headerSelected )
+ // corner classes on the previously active header stay after the animation
+ active.removeClass( "ui-accordion-header-active ui-state-active" );
+ if ( options.icons ) {
+ active.children( ".ui-accordion-header-icon" )
+ .removeClass( options.icons.activeHeader )
.addClass( options.icons.header );
+ }
+
if ( !clickedIsActive ) {
clicked
- .removeClass( "ui-state-default ui-corner-all" )
- .addClass( "ui-state-active ui-corner-top" )
- .children( ".ui-icon" )
+ .removeClass( "ui-corner-all" )
+ .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
+ if ( options.icons ) {
+ clicked.children( ".ui-accordion-header-icon" )
.removeClass( options.icons.header )
- .addClass( options.icons.headerSelected );
+ .addClass( options.icons.activeHeader );
+ }
+
clicked
.next()
.addClass( "ui-accordion-content-active" );
}
-
- return;
},
- _toggle: function( toShow, toHide, data, clickedIsActive, down ) {
- var self = this,
- options = self.options;
+ _toggle: function( data ) {
+ var toShow = data.newPanel,
+ toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
- self.toShow = toShow;
- self.toHide = toHide;
- self.data = data;
+ // handle activating a panel during the animation for another activation
+ this.prevShow.add( this.prevHide ).stop( true, true );
+ this.prevShow = toShow;
+ this.prevHide = toHide;
- var complete = function() {
- if ( !self ) {
- return;
- }
- return self._completed.apply( self, arguments );
- };
+ if ( this.options.animate ) {
+ this._animate( toShow, toHide, data );
+ } else {
+ toHide.hide();
+ toShow.show();
+ this._toggleComplete( data );
+ }
- // trigger changestart event
- self._trigger( "changestart", null, self.data );
+ toHide.attr({
+ "aria-expanded": "false",
+ "aria-hidden": "true"
+ });
+ toHide.prev().attr( "aria-selected", "false" );
+ // if we're switching panels, remove the old header from the tab order
+ // if we're opening from collapsed state, remove the previous header from the tab order
+ // if we're collapsing, then keep the collapsing header in the tab order
+ if ( toShow.length && toHide.length ) {
+ toHide.prev().attr( "tabIndex", -1 );
+ } else if ( toShow.length ) {
+ this.headers.filter(function() {
+ return $( this ).attr( "tabIndex" ) === 0;
+ })
+ .attr( "tabIndex", -1 );
+ }
- // count elements to animate
- self.running = toHide.size() === 0 ? toShow.size() : toHide.size();
+ toShow
+ .attr({
+ "aria-expanded": "true",
+ "aria-hidden": "false"
+ })
+ .prev()
+ .attr({
+ "aria-selected": "true",
+ tabIndex: 0
+ });
+ },
- if ( options.animated ) {
- var animOptions = {};
+ _animate: function( toShow, toHide, data ) {
+ var total, easing, duration,
+ that = this,
+ adjust = 0,
+ down = toShow.length &&
+ ( !toHide.length || ( toShow.index() < toHide.index() ) ),
+ animate = this.options.animate || {},
+ options = down && animate.down || animate,
+ complete = function() {
+ that._toggleComplete( data );
+ };
- if ( options.collapsible && clickedIsActive ) {
- animOptions = {
- toShow: $( [] ),
- toHide: toHide,
- complete: complete,
- down: down,
- autoHeight: options.autoHeight || options.fillSpace
- };
- } else {
- animOptions = {
- toShow: toShow,
- toHide: toHide,
- complete: complete,
- down: down,
- autoHeight: options.autoHeight || options.fillSpace
- };
- }
+ if ( typeof options === "number" ) {
+ duration = options;
+ }
+ if ( typeof options === "string" ) {
+ easing = options;
+ }
+ // fall back from options to animation in case of partial down settings
+ easing = easing || options.easing || animate.easing;
+ duration = duration || options.duration || animate.duration;
- if ( !options.proxied ) {
- options.proxied = options.animated;
- }
+ if ( !toHide.length ) {
+ return toShow.animate( showProps, duration, easing, complete );
+ }
+ if ( !toShow.length ) {
+ return toHide.animate( hideProps, duration, easing, complete );
+ }
- if ( !options.proxiedDuration ) {
- options.proxiedDuration = options.duration;
+ total = toShow.show().outerHeight();
+ toHide.animate( hideProps, {
+ duration: duration,
+ easing: easing,
+ step: function( now, fx ) {
+ fx.now = Math.round( now );
}
+ });
+ toShow
+ .hide()
+ .animate( showProps, {
+ duration: duration,
+ easing: easing,
+ complete: complete,
+ step: function( now, fx ) {
+ fx.now = Math.round( now );
+ if ( fx.prop !== "height" ) {
+ adjust += fx.now;
+ } else if ( that.options.heightStyle !== "content" ) {
+ fx.now = Math.round( total - toHide.outerHeight() - adjust );
+ adjust = 0;
+ }
+ }
+ });
+ },
- options.animated = $.isFunction( options.proxied ) ?
- options.proxied( animOptions ) :
- options.proxied;
+ _toggleComplete: function( data ) {
+ var toHide = data.oldPanel;
- options.duration = $.isFunction( options.proxiedDuration ) ?
- options.proxiedDuration( animOptions ) :
- options.proxiedDuration;
+ toHide
+ .removeClass( "ui-accordion-content-active" )
+ .prev()
+ .removeClass( "ui-corner-top" )
+ .addClass( "ui-corner-all" );
- var animations = $.ui.accordion.animations,
- duration = options.duration,
- easing = options.animated;
+ // Work around for rendering bug in IE (#5421)
+ if ( toHide.length ) {
+ toHide.parent()[0].className = toHide.parent()[0].className;
+ }
- if ( easing && !animations[ easing ] && !$.easing[ easing ] ) {
- easing = "slide";
+ this._trigger( "activate", null, data );
+ }
+});
+
+
+
+// DEPRECATED
+if ( $.uiBackCompat !== false ) {
+ // navigation options
+ (function( $, prototype ) {
+ $.extend( prototype.options, {
+ navigation: false,
+ navigationFilter: function() {
+ return this.href.toLowerCase() === location.href.toLowerCase();
}
- if ( !animations[ easing ] ) {
- animations[ easing ] = function( options ) {
- this.slide( options, {
- easing: easing,
- duration: duration || 700
+ });
+
+ var _create = prototype._create;
+ prototype._create = function() {
+ if ( this.options.navigation ) {
+ var that = this,
+ headers = this.element.find( this.options.header ),
+ content = headers.next(),
+ current = headers.add( content )
+ .find( "a" )
+ .filter( this.options.navigationFilter )
+ [ 0 ];
+ if ( current ) {
+ headers.add( content ).each( function( index ) {
+ if ( $.contains( this, current ) ) {
+ that.options.active = Math.floor( index / 2 );
+ return false;
+ }
});
- };
+ }
}
+ _create.call( this );
+ };
+ }( jQuery, jQuery.ui.accordion.prototype ) );
+
+ // height options
+ (function( $, prototype ) {
+ $.extend( prototype.options, {
+ heightStyle: null, // remove default so we fall back to old values
+ autoHeight: true, // use heightStyle: "auto"
+ clearStyle: false, // use heightStyle: "content"
+ fillSpace: false // use heightStyle: "fill"
+ });
- animations[ easing ]( animOptions );
- } else {
- if ( options.collapsible && clickedIsActive ) {
- toShow.toggle();
- } else {
- toHide.hide();
- toShow.show();
+ var _create = prototype._create,
+ _setOption = prototype._setOption;
+
+ $.extend( prototype, {
+ _create: function() {
+ this.options.heightStyle = this.options.heightStyle ||
+ this._mergeHeightStyle();
+
+ _create.call( this );
+ },
+
+ _setOption: function( key ) {
+ if ( key === "autoHeight" || key === "clearStyle" || key === "fillSpace" ) {
+ this.options.heightStyle = this._mergeHeightStyle();
+ }
+ _setOption.apply( this, arguments );
+ },
+
+ _mergeHeightStyle: function() {
+ var options = this.options;
+
+ if ( options.fillSpace ) {
+ return "fill";
+ }
+
+ if ( options.clearStyle ) {
+ return "content";
+ }
+
+ if ( options.autoHeight ) {
+ return "auto";
+ }
}
+ });
+ }( jQuery, jQuery.ui.accordion.prototype ) );
- complete( true );
- }
+ // icon options
+ (function( $, prototype ) {
+ $.extend( prototype.options.icons, {
+ activeHeader: null, // remove default so we fall back to old values
+ headerSelected: "ui-icon-triangle-1-s"
+ });
- // TODO assert that the blur and focus triggers are really necessary, remove otherwise
- toHide.prev()
- .attr({
- "aria-expanded": "false",
- "aria-selected": "false",
- tabIndex: -1
- })
- .blur();
- toShow.prev()
- .attr({
- "aria-expanded": "true",
- "aria-selected": "true",
- tabIndex: 0
- })
- .focus();
- },
+ var _createIcons = prototype._createIcons;
+ prototype._createIcons = function() {
+ if ( this.options.icons ) {
+ this.options.icons.activeHeader = this.options.icons.activeHeader ||
+ this.options.icons.headerSelected;
+ }
+ _createIcons.call( this );
+ };
+ }( jQuery, jQuery.ui.accordion.prototype ) );
- _completed: function( cancel ) {
- this.running = cancel ? 0 : --this.running;
- if ( this.running ) {
- return;
- }
+ // expanded active option, activate method
+ (function( $, prototype ) {
+ prototype.activate = prototype._activate;
- if ( this.options.clearStyle ) {
- this.toShow.add( this.toHide ).css({
- height: "",
- overflow: ""
- });
- }
+ var _findActive = prototype._findActive;
+ prototype._findActive = function( index ) {
+ if ( index === -1 ) {
+ index = false;
+ }
+ if ( index && typeof index !== "number" ) {
+ index = this.headers.index( this.headers.filter( index ) );
+ if ( index === -1 ) {
+ index = false;
+ }
+ }
+ return _findActive.call( this, index );
+ };
+ }( jQuery, jQuery.ui.accordion.prototype ) );
- // other classes are removed before the animation; this one needs to stay until completed
- this.toHide.removeClass( "ui-accordion-content-active" );
- // Work around for rendering bug in IE (#5421)
- if ( this.toHide.length ) {
- this.toHide.parent()[0].className = this.toHide.parent()[0].className;
- }
+ // resize method
+ jQuery.ui.accordion.prototype.resize = jQuery.ui.accordion.prototype.refresh;
- this._trigger( "change", null, this.data );
- }
-});
+ // change events
+ (function( $, prototype ) {
+ $.extend( prototype.options, {
+ change: null,
+ changestart: null
+ });
-$.extend( $.ui.accordion, {
- version: "1.8.16",
- animations: {
- slide: function( options, additions ) {
- options = $.extend({
- easing: "swing",
- duration: 300
- }, options, additions );
- if ( !options.toHide.size() ) {
- options.toShow.animate({
- height: "show",
- paddingTop: "show",
- paddingBottom: "show"
- }, options );
- return;
+ var _trigger = prototype._trigger;
+ prototype._trigger = function( type, event, data ) {
+ var ret = _trigger.apply( this, arguments );
+ if ( !ret ) {
+ return false;
}
- if ( !options.toShow.size() ) {
- options.toHide.animate({
- height: "hide",
- paddingTop: "hide",
- paddingBottom: "hide"
- }, options );
- return;
+
+ if ( type === "beforeActivate" ) {
+ ret = _trigger.call( this, "changestart", event, {
+ oldHeader: data.oldHeader,
+ oldContent: data.oldPanel,
+ newHeader: data.newHeader,
+ newContent: data.newPanel
+ });
+ } else if ( type === "activate" ) {
+ ret = _trigger.call( this, "change", event, {
+ oldHeader: data.oldHeader,
+ oldContent: data.oldPanel,
+ newHeader: data.newHeader,
+ newContent: data.newPanel
+ });
}
- var overflow = options.toShow.css( "overflow" ),
- percentDone = 0,
- showProps = {},
- hideProps = {},
- fxAttrs = [ "height", "paddingTop", "paddingBottom" ],
- originalWidth;
- // fix width before calculating height of hidden element
- var s = options.toShow;
- originalWidth = s[0].style.width;
- s.width( parseInt( s.parent().width(), 10 )
- - parseInt( s.css( "paddingLeft" ), 10 )
- - parseInt( s.css( "paddingRight" ), 10 )
- - ( parseInt( s.css( "borderLeftWidth" ), 10 ) || 0 )
- - ( parseInt( s.css( "borderRightWidth" ), 10) || 0 ) );
-
- $.each( fxAttrs, function( i, prop ) {
- hideProps[ prop ] = "hide";
-
- var parts = ( "" + $.css( options.toShow[0], prop ) ).match( /^([\d+-.]+)(.*)$/ );
- showProps[ prop ] = {
- value: parts[ 1 ],
- unit: parts[ 2 ] || "px"
- };
- });
- options.toShow.css({ height: 0, overflow: "hidden" }).show();
- options.toHide
- .filter( ":hidden" )
- .each( options.complete )
- .end()
- .filter( ":visible" )
- .animate( hideProps, {
- step: function( now, settings ) {
- // only calculate the percent when animating height
- // IE gets very inconsistent results when animating elements
- // with small values, which is common for padding
- if ( settings.prop == "height" ) {
- percentDone = ( settings.end - settings.start === 0 ) ? 0 :
- ( settings.now - settings.start ) / ( settings.end - settings.start );
- }
+ return ret;
+ };
+ }( jQuery, jQuery.ui.accordion.prototype ) );
+
+ // animated option
+ // NOTE: this only provides support for "slide", "bounceslide", and easings
+ // not the full $.ui.accordion.animations API
+ (function( $, prototype ) {
+ $.extend( prototype.options, {
+ animate: null,
+ animated: "slide"
+ });
- options.toShow[ 0 ].style[ settings.prop ] =
- ( percentDone * showProps[ settings.prop ].value )
- + showProps[ settings.prop ].unit;
- },
- duration: options.duration,
- easing: options.easing,
- complete: function() {
- if ( !options.autoHeight ) {
- options.toShow.css( "height", "" );
- }
- options.toShow.css({
- width: originalWidth,
- overflow: overflow
- });
- options.complete();
+ var _create = prototype._create;
+ prototype._create = function() {
+ var options = this.options;
+ if ( options.animate === null ) {
+ if ( !options.animated ) {
+ options.animate = false;
+ } else if ( options.animated === "slide" ) {
+ options.animate = 300;
+ } else if ( options.animated === "bounceslide" ) {
+ options.animate = {
+ duration: 200,
+ down: {
+ easing: "easeOutBounce",
+ duration: 1000
+ }
+ };
+ } else {
+ options.animate = options.animated;
}
- });
- },
- bounceslide: function( options ) {
- this.slide( options, {
- easing: options.down ? "easeOutBounce" : "swing",
- duration: options.down ? 1000 : 200
- });
- }
- }
-});
+ }
+
+ _create.call( this );
+ };
+ }( jQuery, jQuery.ui.accordion.prototype ) );
+}
})( jQuery );
-/*
- * jQuery UI Autocomplete 1.8.16
- *
- * Copyright 2011, 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/Autocomplete
- *
- * Depends:
- * jquery.ui.core.js
- * jquery.ui.widget.js
- * jquery.ui.position.js
- */
+
(function( $, undefined ) {
// used to prevent race conditions with remote data sources
var requestIndex = 0;
$.widget( "ui.autocomplete", {
+ version: "1.9.2",
+ defaultElement: "<input>",
options: {
appendTo: "body",
autoFocus: false,
@@ -6281,248 +6246,339 @@ $.widget( "ui.autocomplete", {
at: "left bottom",
collision: "none"
},
- source: null
+ source: null,
+
+ // callbacks
+ change: null,
+ close: null,
+ focus: null,
+ open: null,
+ response: null,
+ search: null,
+ select: null
},
pending: 0,
_create: function() {
- var self = this,
- doc = this.element[ 0 ].ownerDocument,
- suppressKeyPress;
+ // Some browsers only repeat keydown events, not keypress events,
+ // so we use the suppressKeyPress flag to determine if we've already
+ // handled the keydown event. #7269
+ // Unfortunately the code for & in keypress is the same as the up arrow,
+ // so we use the suppressKeyPressRepeat flag to avoid handling keypress
+ // events when we know the keydown event was used to modify the
+ // search term. #7799
+ var suppressKeyPress, suppressKeyPressRepeat, suppressInput;
+
+ this.isMultiLine = this._isMultiLine();
+ this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ];
+ this.isNewMenu = true;
this.element
.addClass( "ui-autocomplete-input" )
- .attr( "autocomplete", "off" )
- // TODO verify these actually work as intended
- .attr({
- role: "textbox",
- "aria-autocomplete": "list",
- "aria-haspopup": "true"
- })
- .bind( "keydown.autocomplete", function( event ) {
- if ( self.options.disabled || self.element.propAttr( "readOnly" ) ) {
+ .attr( "autocomplete", "off" );
+
+ this._on( this.element, {
+ keydown: function( event ) {
+ if ( this.element.prop( "readOnly" ) ) {
+ suppressKeyPress = true;
+ suppressInput = true;
+ suppressKeyPressRepeat = true;
return;
}
suppressKeyPress = false;
+ suppressInput = false;
+ suppressKeyPressRepeat = false;
var keyCode = $.ui.keyCode;
switch( event.keyCode ) {
case keyCode.PAGE_UP:
- self._move( "previousPage", event );
+ suppressKeyPress = true;
+ this._move( "previousPage", event );
break;
case keyCode.PAGE_DOWN:
- self._move( "nextPage", event );
+ suppressKeyPress = true;
+ this._move( "nextPage", event );
break;
case keyCode.UP:
- self._move( "previous", event );
- // prevent moving cursor to beginning of text field in some browsers
- event.preventDefault();
+ suppressKeyPress = true;
+ this._keyEvent( "previous", event );
break;
case keyCode.DOWN:
- self._move( "next", event );
- // prevent moving cursor to end of text field in some browsers
- event.preventDefault();
+ suppressKeyPress = true;
+ this._keyEvent( "next", event );
break;
case keyCode.ENTER:
case keyCode.NUMPAD_ENTER:
// when menu is open and has focus
- if ( self.menu.active ) {
+ if ( this.menu.active ) {
// #6055 - Opera still allows the keypress to occur
// which causes forms to submit
suppressKeyPress = true;
event.preventDefault();
+ this.menu.select( event );
}
- //passthrough - ENTER and TAB both select the current element
+ break;
case keyCode.TAB:
- if ( !self.menu.active ) {
- return;
+ if ( this.menu.active ) {
+ this.menu.select( event );
}
- self.menu.select( event );
break;
case keyCode.ESCAPE:
- self.element.val( self.term );
- self.close( event );
+ if ( this.menu.element.is( ":visible" ) ) {
+ this._value( this.term );
+ this.close( event );
+ // Different browsers have different default behavior for escape
+ // Single press can mean undo or clear
+ // Double press in IE means clear the whole form
+ event.preventDefault();
+ }
break;
default:
- // keypress is triggered before the input value is changed
- clearTimeout( self.searching );
- self.searching = setTimeout(function() {
- // only search if the value has changed
- if ( self.term != self.element.val() ) {
- self.selectedItem = null;
- self.search( null, event );
- }
- }, self.options.delay );
+ suppressKeyPressRepeat = true;
+ // search timeout should be triggered before the input value is changed
+ this._searchTimeout( event );
break;
}
- })
- .bind( "keypress.autocomplete", function( event ) {
+ },
+ keypress: function( event ) {
if ( suppressKeyPress ) {
suppressKeyPress = false;
event.preventDefault();
+ return;
}
- })
- .bind( "focus.autocomplete", function() {
- if ( self.options.disabled ) {
+ if ( suppressKeyPressRepeat ) {
return;
}
- self.selectedItem = null;
- self.previous = self.element.val();
- })
- .bind( "blur.autocomplete", function( event ) {
- if ( self.options.disabled ) {
+ // replicate some key handlers to allow them to repeat in Firefox and Opera
+ var keyCode = $.ui.keyCode;
+ switch( event.keyCode ) {
+ case keyCode.PAGE_UP:
+ this._move( "previousPage", event );
+ break;
+ case keyCode.PAGE_DOWN:
+ this._move( "nextPage", event );
+ break;
+ case keyCode.UP:
+ this._keyEvent( "previous", event );
+ break;
+ case keyCode.DOWN:
+ this._keyEvent( "next", event );
+ break;
+ }
+ },
+ input: function( event ) {
+ if ( suppressInput ) {
+ suppressInput = false;
+ event.preventDefault();
+ return;
+ }
+ this._searchTimeout( event );
+ },
+ focus: function() {
+ this.selectedItem = null;
+ this.previous = this._value();
+ },
+ blur: function( event ) {
+ if ( this.cancelBlur ) {
+ delete this.cancelBlur;
return;
}
- clearTimeout( self.searching );
- // clicks on the menu (or a button to trigger a search) will cause a blur event
- self.closing = setTimeout(function() {
- self.close( event );
- self._change( event );
- }, 150 );
- });
+ clearTimeout( this.searching );
+ this.close( event );
+ this._change( event );
+ }
+ });
+
this._initSource();
- this.response = function() {
- return self._response.apply( self, arguments );
- };
- this.menu = $( "<ul></ul>" )
+ this.menu = $( "<ul>" )
.addClass( "ui-autocomplete" )
- .appendTo( $( this.options.appendTo || "body", doc )[0] )
- // prevent the close-on-blur in case of a "slow" click on the menu (long mousedown)
- .mousedown(function( event ) {
+ .appendTo( this.document.find( this.options.appendTo || "body" )[ 0 ] )
+ .menu({
+ // custom key handling for now
+ input: $(),
+ // disable ARIA support, the live region takes care of that
+ role: null
+ })
+ .zIndex( this.element.zIndex() + 1 )
+ .hide()
+ .data( "menu" );
+
+ this._on( this.menu.element, {
+ mousedown: function( event ) {
+ // prevent moving focus out of the text field
+ event.preventDefault();
+
+ // IE doesn't prevent moving focus even with event.preventDefault()
+ // so we set a flag to know when we should ignore the blur event
+ this.cancelBlur = true;
+ this._delay(function() {
+ delete this.cancelBlur;
+ });
+
// clicking on the scrollbar causes focus to shift to the body
// but we can't detect a mouseup or a click immediately afterward
// so we have to track the next mousedown and close the menu if
// the user clicks somewhere outside of the autocomplete
- var menuElement = self.menu.element[ 0 ];
+ var menuElement = this.menu.element[ 0 ];
if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
- setTimeout(function() {
- $( document ).one( 'mousedown', function( event ) {
- if ( event.target !== self.element[ 0 ] &&
- event.target !== menuElement &&
- !$.ui.contains( menuElement, event.target ) ) {
- self.close();
+ this._delay(function() {
+ var that = this;
+ this.document.one( "mousedown", function( event ) {
+ if ( event.target !== that.element[ 0 ] &&
+ event.target !== menuElement &&
+ !$.contains( menuElement, event.target ) ) {
+ that.close();
}
});
- }, 1 );
+ });
}
+ },
+ menufocus: function( event, ui ) {
+ // #7024 - Prevent accidental activation of menu items in Firefox
+ if ( this.isNewMenu ) {
+ this.isNewMenu = false;
+ if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
+ this.menu.blur();
+
+ this.document.one( "mousemove", function() {
+ $( event.target ).trigger( event.originalEvent );
+ });
- // use another timeout to make sure the blur-event-handler on the input was already triggered
- setTimeout(function() {
- clearTimeout( self.closing );
- }, 13);
- })
- .menu({
- focus: function( event, ui ) {
- var item = ui.item.data( "item.autocomplete" );
- if ( false !== self._trigger( "focus", event, { item: item } ) ) {
- // use value to match what will end up in the input, if it was a key event
- if ( /^key/.test(event.originalEvent.type) ) {
- self.element.val( item.value );
- }
- }
- },
- selected: function( event, ui ) {
- var item = ui.item.data( "item.autocomplete" ),
- previous = self.previous;
-
- // only trigger when focus was lost (click on menu)
- if ( self.element[0] !== doc.activeElement ) {
- self.element.focus();
- self.previous = previous;
- // #6109 - IE triggers two focus events and the second
- // is asynchronous, so we need to reset the previous
- // term synchronously and asynchronously :-(
- setTimeout(function() {
- self.previous = previous;
- self.selectedItem = item;
- }, 1);
+ return;
}
+ }
- if ( false !== self._trigger( "select", event, { item: item } ) ) {
- self.element.val( item.value );
+ // back compat for _renderItem using item.autocomplete, via #7810
+ // TODO remove the fallback, see #8156
+ var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" );
+ if ( false !== this._trigger( "focus", event, { item: item } ) ) {
+ // use value to match what will end up in the input, if it was a key event
+ if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
+ this._value( item.value );
}
- // reset the term after the select event
- // this allows custom select handling to work properly
- self.term = self.element.val();
+ } else {
+ // Normally the input is populated with the item's value as the
+ // menu is navigated, causing screen readers to notice a change and
+ // announce the item. Since the focus event was canceled, this doesn't
+ // happen, so we update the live region so that screen readers can
+ // still notice the change and announce it.
+ this.liveRegion.text( item.value );
+ }
+ },
+ menuselect: function( event, ui ) {
+ // back compat for _renderItem using item.autocomplete, via #7810
+ // TODO remove the fallback, see #8156
+ var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" ),
+ previous = this.previous;
+
+ // only trigger when focus was lost (click on menu)
+ if ( this.element[0] !== this.document[0].activeElement ) {
+ this.element.focus();
+ this.previous = previous;
+ // #6109 - IE triggers two focus events and the second
+ // is asynchronous, so we need to reset the previous
+ // term synchronously and asynchronously :-(
+ this._delay(function() {
+ this.previous = previous;
+ this.selectedItem = item;
+ });
+ }
- self.close( event );
- self.selectedItem = item;
- },
- blur: function( event, ui ) {
- // don't set the value of the text field if it's already correct
- // this prevents moving the cursor unnecessarily
- if ( self.menu.element.is(":visible") &&
- ( self.element.val() !== self.term ) ) {
- self.element.val( self.term );
- }
+ if ( false !== this._trigger( "select", event, { item: item } ) ) {
+ this._value( item.value );
}
+ // reset the term after the select event
+ // this allows custom select handling to work properly
+ this.term = this._value();
+
+ this.close( event );
+ this.selectedItem = item;
+ }
+ });
+
+ this.liveRegion = $( "<span>", {
+ role: "status",
+ "aria-live": "polite"
})
- .zIndex( this.element.zIndex() + 1 )
- // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
- .css({ top: 0, left: 0 })
- .hide()
- .data( "menu" );
+ .addClass( "ui-helper-hidden-accessible" )
+ .insertAfter( this.element );
+
if ( $.fn.bgiframe ) {
- this.menu.element.bgiframe();
+ this.menu.element.bgiframe();
}
+
+ // 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._on( this.window, {
+ beforeunload: function() {
+ this.element.removeAttr( "autocomplete" );
+ }
+ });
},
- destroy: function() {
+ _destroy: function() {
+ clearTimeout( this.searching );
this.element
.removeClass( "ui-autocomplete-input" )
- .removeAttr( "autocomplete" )
- .removeAttr( "role" )
- .removeAttr( "aria-autocomplete" )
- .removeAttr( "aria-haspopup" );
+ .removeAttr( "autocomplete" );
this.menu.element.remove();
- $.Widget.prototype.destroy.call( this );
+ this.liveRegion.remove();
},
_setOption: function( key, value ) {
- $.Widget.prototype._setOption.apply( this, arguments );
+ this._super( key, value );
if ( key === "source" ) {
this._initSource();
}
if ( key === "appendTo" ) {
- this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] )
+ this.menu.element.appendTo( this.document.find( value || "body" )[0] );
}
if ( key === "disabled" && value && this.xhr ) {
this.xhr.abort();
}
},
+ _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 self = this,
- array,
- url;
+ var array, url,
+ that = this;
if ( $.isArray(this.options.source) ) {
array = this.options.source;
this.source = function( request, response ) {
- response( $.ui.autocomplete.filter(array, request.term) );
+ response( $.ui.autocomplete.filter( array, request.term ) );
};
} else if ( typeof this.options.source === "string" ) {
url = this.options.source;
this.source = function( request, response ) {
- if ( self.xhr ) {
- self.xhr.abort();
+ if ( that.xhr ) {
+ that.xhr.abort();
}
- self.xhr = $.ajax({
+ that.xhr = $.ajax({
url: url,
data: request,
dataType: "json",
- autocompleteRequest: ++requestIndex,
- success: function( data, status ) {
- if ( this.autocompleteRequest === requestIndex ) {
- response( data );
- }
+ success: function( data ) {
+ response( data );
},
error: function() {
- if ( this.autocompleteRequest === requestIndex ) {
- response( [] );
- }
+ response( [] );
}
});
};
@@ -6531,17 +6587,27 @@ $.widget( "ui.autocomplete", {
}
},
+ _searchTimeout: function( event ) {
+ clearTimeout( this.searching );
+ this.searching = this._delay(function() {
+ // only search if the value has changed
+ if ( this.term !== this._value() ) {
+ this.selectedItem = null;
+ this.search( null, event );
+ }
+ }, this.options.delay );
+ },
+
search: function( value, event ) {
- value = value != null ? value : this.element.val();
+ value = value != null ? value : this._value();
// always save the actual value, not the one passed as an argument
- this.term = this.element.val();
+ this.term = this._value();
if ( value.length < this.options.minLength ) {
return this.close( event );
}
- clearTimeout( this.closing );
if ( this._trigger( "search", event ) === false ) {
return;
}
@@ -6552,35 +6618,57 @@ $.widget( "ui.autocomplete", {
_search: function( value ) {
this.pending++;
this.element.addClass( "ui-autocomplete-loading" );
+ this.cancelSearch = false;
- this.source( { term: value }, this.response );
+ this.source( { term: value }, this._response() );
},
- _response: function( content ) {
- if ( !this.options.disabled && content && content.length ) {
+ _response: function() {
+ var that = this,
+ index = ++requestIndex;
+
+ return function( content ) {
+ if ( index === requestIndex ) {
+ that.__response( content );
+ }
+
+ that.pending--;
+ if ( !that.pending ) {
+ that.element.removeClass( "ui-autocomplete-loading" );
+ }
+ };
+ },
+
+ __response: function( content ) {
+ if ( content ) {
content = this._normalize( content );
+ }
+ this._trigger( "response", null, { content: content } );
+ if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
this._suggest( content );
this._trigger( "open" );
} else {
- this.close();
- }
- this.pending--;
- if ( !this.pending ) {
- this.element.removeClass( "ui-autocomplete-loading" );
+ // use ._close() instead of .close() so we don't cancel future searches
+ this._close();
}
},
close: function( event ) {
- clearTimeout( this.closing );
- if ( this.menu.element.is(":visible") ) {
+ this.cancelSearch = true;
+ this._close( event );
+ },
+
+ _close: function( event ) {
+ if ( this.menu.element.is( ":visible" ) ) {
this.menu.element.hide();
- this.menu.deactivate();
+ this.menu.blur();
+ this.isNewMenu = true;
this._trigger( "close", event );
}
},
-
+
_change: function( event ) {
- if ( this.previous !== this.element.val() ) {
+ if ( this.previous !== this._value() ) {
this._trigger( "change", event, { item: this.selectedItem } );
}
},
@@ -6590,7 +6678,7 @@ $.widget( "ui.autocomplete", {
if ( items.length && items[0].label && items[0].value ) {
return items;
}
- return $.map( items, function(item) {
+ return $.map( items, function( item ) {
if ( typeof item === "string" ) {
return {
label: item,
@@ -6609,8 +6697,6 @@ $.widget( "ui.autocomplete", {
.empty()
.zIndex( this.element.zIndex() + 1 );
this._renderMenu( ul, items );
- // TODO refresh should check if the active item is still in the dom, removing the need for a manual deactivate
- this.menu.deactivate();
this.menu.refresh();
// size and position menu
@@ -6621,41 +6707,46 @@ $.widget( "ui.autocomplete", {
}, this.options.position ));
if ( this.options.autoFocus ) {
- this.menu.next( new $.Event("mouseover") );
+ this.menu.next();
}
},
_resizeMenu: function() {
var ul = this.menu.element;
ul.outerWidth( Math.max(
- ul.width( "" ).outerWidth(),
+ // Firefox wraps long text (possibly a rounding bug)
+ // so we add 1px to avoid the wrapping (#7513)
+ ul.width( "" ).outerWidth() + 1,
this.element.outerWidth()
) );
},
_renderMenu: function( ul, items ) {
- var self = this;
+ var that = this;
$.each( items, function( index, item ) {
- self._renderItem( ul, item );
+ that._renderItemData( ul, item );
});
},
- _renderItem: function( ul, item) {
- return $( "<li></li>" )
- .data( "item.autocomplete", item )
- .append( $( "<a></a>" ).text( item.label ) )
+ _renderItemData: function( ul, item ) {
+ return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
+ },
+
+ _renderItem: function( ul, item ) {
+ return $( "<li>" )
+ .append( $( "<a>" ).text( item.label ) )
.appendTo( ul );
},
_move: function( direction, event ) {
- if ( !this.menu.element.is(":visible") ) {
+ if ( !this.menu.element.is( ":visible" ) ) {
this.search( null, event );
return;
}
- if ( this.menu.first() && /^previous/.test(direction) ||
- this.menu.last() && /^next/.test(direction) ) {
- this.element.val( this.term );
- this.menu.deactivate();
+ if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
+ this.menu.isLastItem() && /^next/.test( direction ) ) {
+ this._value( this.term );
+ this.menu.blur();
return;
}
this.menu[ direction ]( event );
@@ -6663,12 +6754,25 @@ $.widget( "ui.autocomplete", {
widget: function() {
return this.menu.element;
+ },
+
+ _value: function() {
+ return this.valueMethod.apply( this.element, arguments );
+ },
+
+ _keyEvent: function( keyEvent, event ) {
+ if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
+ this._move( keyEvent, event );
+
+ // prevents moving cursor to beginning/end of the text field in some browsers
+ event.preventDefault();
+ }
}
});
$.extend( $.ui.autocomplete, {
escapeRegex: function( value ) {
- return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
+ return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
},
filter: function(array, term) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
@@ -6678,204 +6782,39 @@ $.extend( $.ui.autocomplete, {
}
});
-}( jQuery ));
-
-/*
- * jQuery UI Menu (not officially released)
- *
- * This widget isn't yet finished and the API is subject to change. We plan to finish
- * it for the next release. You're welcome to give it a try anyway and give us feedback,
- * as long as you're okay with migrating your code later on. We can help with that, too.
- *
- * Copyright 2010, 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/Menu
- *
- * Depends:
- * jquery.ui.core.js
- * jquery.ui.widget.js
- */
-(function($) {
-$.widget("ui.menu", {
- _create: function() {
- var self = this;
- this.element
- .addClass("ui-menu ui-widget ui-widget-content ui-corner-all")
- .attr({
- role: "listbox",
- "aria-activedescendant": "ui-active-menuitem"
- })
- .click(function( event ) {
- if ( !$( event.target ).closest( ".ui-menu-item a" ).length ) {
- return;
- }
- // temporary
- event.preventDefault();
- self.select( event );
- });
- this.refresh();
- },
-
- refresh: function() {
- var self = this;
-
- // don't refresh list items that are already adapted
- var items = this.element.children("li:not(.ui-menu-item):has(a)")
- .addClass("ui-menu-item")
- .attr("role", "menuitem");
-
- items.children("a")
- .addClass("ui-corner-all")
- .attr("tabindex", -1)
- // mouseenter doesn't work with event delegation
- .mouseenter(function( event ) {
- self.activate( event, $(this).parent() );
- })
- .mouseleave(function() {
- self.deactivate();
- });
- },
-
- activate: function( event, item ) {
- this.deactivate();
- if (this.hasScroll()) {
- var offset = item.offset().top - this.element.offset().top,
- scroll = this.element.scrollTop(),
- elementHeight = this.element.height();
- if (offset < 0) {
- this.element.scrollTop( scroll + offset);
- } else if (offset >= elementHeight) {
- this.element.scrollTop( scroll + offset - elementHeight + item.height());
+// live region extension, adding a `messages` option
+// NOTE: This is an experimental API. We are still investigating
+// a full solution for string manipulation and internationalization.
+$.widget( "ui.autocomplete", $.ui.autocomplete, {
+ options: {
+ messages: {
+ noResults: "No search results.",
+ results: function( amount ) {
+ return amount + ( amount > 1 ? " results are" : " result is" ) +
+ " available, use up and down arrow keys to navigate.";
}
}
- this.active = item.eq(0)
- .children("a")
- .addClass("ui-state-hover")
- .attr("id", "ui-active-menuitem")
- .end();
- this._trigger("focus", event, { item: item });
- },
-
- deactivate: function() {
- if (!this.active) { return; }
-
- this.active.children("a")
- .removeClass("ui-state-hover")
- .removeAttr("id");
- this._trigger("blur");
- this.active = null;
- },
-
- next: function(event) {
- this.move("next", ".ui-menu-item:first", event);
- },
-
- previous: function(event) {
- this.move("prev", ".ui-menu-item:last", event);
- },
-
- first: function() {
- return this.active && !this.active.prevAll(".ui-menu-item").length;
- },
-
- last: function() {
- return this.active && !this.active.nextAll(".ui-menu-item").length;
},
- move: function(direction, edge, event) {
- if (!this.active) {
- this.activate(event, this.element.children(edge));
+ __response: function( content ) {
+ var message;
+ this._superApply( arguments );
+ if ( this.options.disabled || this.cancelSearch ) {
return;
}
- var next = this.active[direction + "All"](".ui-menu-item").eq(0);
- if (next.length) {
- this.activate(event, next);
- } else {
- this.activate(event, this.element.children(edge));
- }
- },
-
- // TODO merge with previousPage
- nextPage: function(event) {
- if (this.hasScroll()) {
- // TODO merge with no-scroll-else
- if (!this.active || this.last()) {
- this.activate(event, this.element.children(".ui-menu-item:first"));
- return;
- }
- var base = this.active.offset().top,
- height = this.element.height(),
- result = this.element.children(".ui-menu-item").filter(function() {
- var close = $(this).offset().top - base - height + $(this).height();
- // TODO improve approximation
- return close < 10 && close > -10;
- });
-
- // TODO try to catch this earlier when scrollTop indicates the last page anyway
- if (!result.length) {
- result = this.element.children(".ui-menu-item:last");
- }
- this.activate(event, result);
- } else {
- this.activate(event, this.element.children(".ui-menu-item")
- .filter(!this.active || this.last() ? ":first" : ":last"));
- }
- },
-
- // TODO merge with nextPage
- previousPage: function(event) {
- if (this.hasScroll()) {
- // TODO merge with no-scroll-else
- if (!this.active || this.first()) {
- this.activate(event, this.element.children(".ui-menu-item:last"));
- return;
- }
-
- var base = this.active.offset().top,
- height = this.element.height();
- result = this.element.children(".ui-menu-item").filter(function() {
- var close = $(this).offset().top - base + height - $(this).height();
- // TODO improve approximation
- return close < 10 && close > -10;
- });
-
- // TODO try to catch this earlier when scrollTop indicates the last page anyway
- if (!result.length) {
- result = this.element.children(".ui-menu-item:first");
- }
- this.activate(event, result);
+ if ( content && content.length ) {
+ message = this.options.messages.results( content.length );
} else {
- this.activate(event, this.element.children(".ui-menu-item")
- .filter(!this.active || this.first() ? ":last" : ":first"));
+ message = this.options.messages.noResults;
}
- },
-
- hasScroll: function() {
- return this.element.height() < this.element[ $.fn.prop ? "prop" : "attr" ]("scrollHeight");
- },
-
- select: function( event ) {
- this._trigger("selected", event, { item: this.active });
+ this.liveRegion.text( message );
}
});
-}(jQuery));
-/*
- * jQuery UI Button 1.8.16
- *
- * Copyright 2011, 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/Button
- *
- * Depends:
- * jquery.ui.core.js
- * jquery.ui.widget.js
- */
+
+}( jQuery ));
+
(function( $, undefined ) {
var lastActive, startXPos, startYPos, clickDragged,
@@ -6906,6 +6845,8 @@ var lastActive, startXPos, startYPos, clickDragged,
};
$.widget( "ui.button", {
+ version: "1.9.2",
+ defaultElement: "<button>",
options: {
disabled: null,
text: true,
@@ -6917,49 +6858,48 @@ $.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.propAttr( "disabled" );
+ this.options.disabled = !!this.element.prop( "disabled" );
+ } else {
+ this.element.prop( "disabled", this.options.disabled );
}
this._determineButtonType();
this.hasTitle = !!this.buttonElement.attr( "title" );
- var self = this,
+ var that = this,
options = this.options,
toggleButton = this.type === "checkbox" || this.type === "radio",
- hoverClass = "ui-state-hover" + ( !toggleButton ? " ui-state-active" : "" ),
+ activeClass = !toggleButton ? "ui-state-active" : "",
focusClass = "ui-state-focus";
if ( options.label === null ) {
- options.label = this.buttonElement.html();
+ options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
}
- if ( this.element.is( ":disabled" ) ) {
- options.disabled = true;
- }
+ this._hoverable( this.buttonElement );
this.buttonElement
.addClass( baseClasses )
.attr( "role", "button" )
- .bind( "mouseenter.button", function() {
+ .bind( "mouseenter" + this.eventNamespace, function() {
if ( options.disabled ) {
return;
}
- $( this ).addClass( "ui-state-hover" );
if ( this === lastActive ) {
$( this ).addClass( "ui-state-active" );
}
})
- .bind( "mouseleave.button", function() {
+ .bind( "mouseleave" + this.eventNamespace, function() {
if ( options.disabled ) {
return;
}
- $( this ).removeClass( hoverClass );
+ $( this ).removeClass( activeClass );
})
- .bind( "click.button", function( event ) {
+ .bind( "click" + this.eventNamespace, function( event ) {
if ( options.disabled ) {
event.preventDefault();
event.stopImmediatePropagation();
@@ -6967,26 +6907,26 @@ $.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
- self.buttonElement.addClass( focusClass );
+ that.buttonElement.addClass( focusClass );
})
- .bind( "blur.button", function() {
- self.buttonElement.removeClass( focusClass );
+ .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;
}
- self.refresh();
+ that.refresh();
});
// if mouse moves between mousedown and mouseup (drag) set clickDragged flag
// 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;
}
@@ -6994,7 +6934,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;
}
@@ -7005,22 +6945,22 @@ $.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;
}
$( this ).toggleClass( "ui-state-active" );
- self.buttonElement.attr( "aria-pressed", self.element[0].checked );
+ 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;
}
$( this ).addClass( "ui-state-active" );
- self.buttonElement.attr( "aria-pressed", "true" );
+ that.buttonElement.attr( "aria-pressed", "true" );
- var radio = self.element[ 0 ];
+ var radio = that.element[ 0 ];
radioGroup( radio )
.not( radio )
.map(function() {
@@ -7031,31 +6971,31 @@ $.widget( "ui.button", {
});
} else {
this.buttonElement
- .bind( "mousedown.button", function() {
+ .bind( "mousedown" + this.eventNamespace, function() {
if ( options.disabled ) {
return false;
}
$( this ).addClass( "ui-state-active" );
lastActive = this;
- $( document ).one( "mouseup", function() {
+ that.document.one( "mouseup", function() {
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;
}
- if ( event.keyCode == $.ui.keyCode.SPACE || event.keyCode == $.ui.keyCode.ENTER ) {
+ if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
$( this ).addClass( "ui-state-active" );
}
})
- .bind( "keyup.button", function() {
+ .bind( "keyup" + this.eventNamespace, function() {
$( this ).removeClass( "ui-state-active" );
});
@@ -7077,10 +7017,11 @@ $.widget( "ui.button", {
},
_determineButtonType: function() {
+ var ancestor, labelSelector, checked;
- if ( this.element.is(":checkbox") ) {
+ if ( this.element.is("[type=checkbox]") ) {
this.type = "checkbox";
- } else if ( this.element.is(":radio") ) {
+ } else if ( this.element.is("[type=radio]") ) {
this.type = "radio";
} else if ( this.element.is("input") ) {
this.type = "input";
@@ -7091,8 +7032,8 @@ $.widget( "ui.button", {
if ( this.type === "checkbox" || this.type === "radio" ) {
// we don't search against the document in case the element
// is disconnected from the DOM
- var ancestor = this.element.parents().filter(":last"),
- labelSelector = "label[for='" + this.element.attr("id") + "']";
+ ancestor = this.element.parents().last();
+ labelSelector = "label[for='" + this.element.attr("id") + "']";
this.buttonElement = ancestor.find( labelSelector );
if ( !this.buttonElement.length ) {
ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
@@ -7103,11 +7044,11 @@ $.widget( "ui.button", {
}
this.element.addClass( "ui-helper-hidden-accessible" );
- var checked = this.element.is( ":checked" );
+ checked = this.element.is( ":checked" );
if ( checked ) {
this.buttonElement.addClass( "ui-state-active" );
}
- this.buttonElement.attr( "aria-pressed", checked );
+ this.buttonElement.prop( "aria-pressed", checked );
} else {
this.buttonElement = this.element;
}
@@ -7117,7 +7058,7 @@ $.widget( "ui.button", {
return this.buttonElement;
},
- destroy: function() {
+ _destroy: function() {
this.element
.removeClass( "ui-helper-hidden-accessible" );
this.buttonElement
@@ -7129,17 +7070,15 @@ $.widget( "ui.button", {
if ( !this.hasTitle ) {
this.buttonElement.removeAttr( "title" );
}
-
- $.Widget.prototype.destroy.call( this );
},
_setOption: function( key, value ) {
- $.Widget.prototype._setOption.apply( this, arguments );
+ this._super( key, value );
if ( key === "disabled" ) {
if ( value ) {
- this.element.propAttr( "disabled", true );
+ this.element.prop( "disabled", true );
} else {
- this.element.propAttr( "disabled", false );
+ this.element.prop( "disabled", false );
}
return;
}
@@ -7147,7 +7086,9 @@ $.widget( "ui.button", {
},
refresh: function() {
- var isDisabled = this.element.is( ":disabled" );
+ //See #8237 & #8828
+ var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
+
if ( isDisabled !== this.options.disabled ) {
this._setOption( "disabled", isDisabled );
}
@@ -7184,14 +7125,14 @@ $.widget( "ui.button", {
return;
}
var buttonElement = this.buttonElement.removeClass( typeClasses ),
- buttonText = $( "<span></span>" )
+ buttonText = $( "<span></span>", this.document[0] )
.addClass( "ui-button-text" )
.html( this.options.label )
.appendTo( buttonElement.empty() )
.text(),
icons = this.options.icons,
multipleIcons = icons.primary && icons.secondary,
- buttonClasses = [];
+ buttonClasses = [];
if ( icons.primary || icons.secondary ) {
if ( this.options.text ) {
@@ -7210,7 +7151,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 {
@@ -7221,14 +7162,15 @@ $.widget( "ui.button", {
});
$.widget( "ui.buttonset", {
+ version: "1.9.2",
options: {
- items: ":button, :submit, :reset, :checkbox, :radio, a, :data(button)"
+ items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(button)"
},
_create: function() {
this.element.addClass( "ui-buttonset" );
},
-
+
_init: function() {
this.refresh();
},
@@ -7238,12 +7180,12 @@ $.widget( "ui.buttonset", {
this.buttons.button( "option", key, value );
}
- $.Widget.prototype._setOption.apply( this, arguments );
+ this._super( key, value );
},
-
+
refresh: function() {
- var ltr = this.element.css( "direction" ) === "ltr";
-
+ var rtl = this.element.css( "direction" ) === "rtl";
+
this.buttons = this.element.find( this.options.items )
.filter( ":ui-button" )
.button( "refresh" )
@@ -7256,15 +7198,15 @@ $.widget( "ui.buttonset", {
})
.removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
.filter( ":first" )
- .addClass( ltr ? "ui-corner-left" : "ui-corner-right" )
+ .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
.end()
.filter( ":last" )
- .addClass( ltr ? "ui-corner-right" : "ui-corner-left" )
+ .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
.end()
.end();
},
- destroy: function() {
+ _destroy: function() {
this.element.removeClass( "ui-buttonset" );
this.buttons
.map(function() {
@@ -7273,27 +7215,14 @@ $.widget( "ui.buttonset", {
.removeClass( "ui-corner-left ui-corner-right" )
.end()
.button( "destroy" );
-
- $.Widget.prototype.destroy.call( this );
}
});
}( jQuery ) );
-/*
- * jQuery UI Datepicker 1.8.16
- *
- * Copyright 2011, 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/Datepicker
- *
- * Depends:
- * jquery.ui.core.js
- */
+
(function( $, undefined ) {
-$.extend($.ui, { datepicker: { version: "1.8.16" } });
+$.extend($.ui, { datepicker: { version: "1.9.2" } });
var PROP_NAME = 'datepicker';
var dpuuid = new Date().getTime();
@@ -7396,7 +7325,7 @@ function Datepicker() {
$.extend(Datepicker.prototype, {
/* Class name added to elements to indicate already configured with a date picker. */
markerClassName: 'hasDatepicker',
-
+
//Keep track of the maximum number of rows displayed (see #7043)
maxRows: 4,
@@ -7405,7 +7334,7 @@ $.extend(Datepicker.prototype, {
if (this.debug)
console.log.apply('', arguments);
},
-
+
// TODO rename to "widget" when switching to widget factory
_widgetDatepicker: function() {
return this.dpDiv;
@@ -7514,7 +7443,10 @@ $.extend(Datepicker.prototype, {
inst.trigger.click(function() {
if ($.datepicker._datepickerShowing && $.datepicker._lastInput == input[0])
$.datepicker._hideDatepicker();
- else
+ else if ($.datepicker._datepickerShowing && $.datepicker._lastInput != input[0]) {
+ $.datepicker._hideDatepicker();
+ $.datepicker._showDatepicker(input[0]);
+ } else
$.datepicker._showDatepicker(input[0]);
return false;
});
@@ -7586,7 +7518,7 @@ $.extend(Datepicker.prototype, {
this.uuid += 1;
var id = 'dp' + this.uuid;
this._dialogInput = $('<input type="text" id="' + id +
- '" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>');
+ '" style="position: absolute; top: -100px; width: 0px;"/>');
this._dialogInput.keydown(this._doKeyDown);
$('body').append(this._dialogInput);
inst = this._dialogInst = this._newInst(this._dialogInput, false);
@@ -7660,7 +7592,7 @@ $.extend(Datepicker.prototype, {
var inline = $target.children('.' + this._inlineClass);
inline.children().removeClass('ui-state-disabled');
inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
- removeAttr("disabled");
+ prop("disabled", false);
}
this._disabledInputs = $.map(this._disabledInputs,
function(value) { return (value == target ? null : value); }); // delete entry
@@ -7685,7 +7617,7 @@ $.extend(Datepicker.prototype, {
var inline = $target.children('.' + this._inlineClass);
inline.children().addClass('ui-state-disabled');
inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
- attr("disabled", "disabled");
+ prop("disabled", true);
}
this._disabledInputs = $.map(this._disabledInputs,
function(value) { return (value == target ? null : value); }); // delete entry
@@ -7808,7 +7740,7 @@ $.extend(Datepicker.prototype, {
case 9: $.datepicker._hideDatepicker();
handled = false;
break; // hide on tab out
- case 13: var sel = $('td.' + $.datepicker._dayOverClass + ':not(.' +
+ case 13: var sel = $('td.' + $.datepicker._dayOverClass + ':not(.' +
$.datepicker._currentClass + ')', inst.dpDiv);
if (sel[0])
$.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
@@ -7898,15 +7830,15 @@ $.extend(Datepicker.prototype, {
$.datepicker._updateDatepicker(inst);
}
}
- catch (event) {
- $.datepicker.log(event);
+ catch (err) {
+ $.datepicker.log(err);
}
}
return true;
},
/* Pop-up the date picker for a given input field.
- If false returned from beforeShow event handler do not show.
+ If false returned from beforeShow event handler do not show.
@param input element - the input field attached to the date picker or
event - if triggered by focus */
_showDatepicker: function(input) {
@@ -7917,15 +7849,15 @@ $.extend(Datepicker.prototype, {
return;
var inst = $.datepicker._getInst(input);
if ($.datepicker._curInst && $.datepicker._curInst != inst) {
- if ( $.datepicker._datepickerShowing ) {
- $.datepicker._triggerOnClose($.datepicker._curInst);
- }
$.datepicker._curInst.dpDiv.stop(true, true);
+ if ( inst && $.datepicker._datepickerShowing ) {
+ $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
+ }
}
var beforeShow = $.datepicker._get(inst, 'beforeShow');
var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
if(beforeShowSettings === false){
- //false
+ //false
return;
}
extendRemove(inst.settings, beforeShowSettings);
@@ -7943,10 +7875,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
@@ -7973,7 +7901,9 @@ $.extend(Datepicker.prototype, {
};
inst.dpDiv.zIndex($(input).zIndex()+1);
$.datepicker._datepickerShowing = true;
- if ($.effects && $.effects[showAnim])
+
+ // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
+ if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) )
inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
else
inst.dpDiv[showAnim || 'show']((showAnim ? duration : null), postProcess);
@@ -7987,11 +7917,11 @@ $.extend(Datepicker.prototype, {
/* Generate the date picker content. */
_updateDatepicker: function(inst) {
- var self = this;
- self.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
+ this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
var borders = $.datepicker._getBorders(inst.dpDiv);
instActive = inst; // for delegate hover events
inst.dpDiv.empty().append(this._generateHTML(inst));
+ 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()})
@@ -8012,7 +7942,7 @@ $.extend(Datepicker.prototype, {
// this breaks the change event in IE
inst.input.is(':visible') && !inst.input.is(':disabled') && inst.input[0] != document.activeElement)
inst.input.focus();
- // deffered render of the years select (to avoid flashes on Firefox)
+ // deffered render of the years select (to avoid flashes on Firefox)
if( inst.yearshtml ){
var origyearshtml = inst.yearshtml;
setTimeout(function(){
@@ -8042,8 +7972,8 @@ $.extend(Datepicker.prototype, {
var dpHeight = inst.dpDiv.outerHeight();
var inputWidth = inst.input ? inst.input.outerWidth() : 0;
var inputHeight = inst.input ? inst.input.outerHeight() : 0;
- var viewWidth = document.documentElement.clientWidth + $(document).scrollLeft();
- var viewHeight = document.documentElement.clientHeight + $(document).scrollTop();
+ var viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft());
+ var viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
offset.left -= (this._get(inst, 'isRTL') ? (dpWidth - inputWidth) : 0);
offset.left -= (isFixed && offset.left == inst.input.offset().left) ? $(document).scrollLeft() : 0;
@@ -8062,19 +7992,11 @@ $.extend(Datepicker.prototype, {
_findPos: function(obj) {
var inst = this._getInst(obj);
var isRTL = this._get(inst, 'isRTL');
- while (obj && (obj.type == 'hidden' || obj.nodeType != 1 || $.expr.filters.hidden(obj))) {
- obj = obj[isRTL ? 'previousSibling' : 'nextSibling'];
- }
- var position = $(obj).offset();
- return [position.left, position.top];
- },
-
- /* Trigger custom callback of onClose. */
- _triggerOnClose: function(inst) {
- var onClose = this._get(inst, 'onClose');
- if (onClose)
- onClose.apply((inst.input ? inst.input[0] : null),
- [(inst.input ? inst.input.val() : ''), inst]);
+ while (obj && (obj.type == 'hidden' || obj.nodeType != 1 || $.expr.filters.hidden(obj))) {
+ obj = obj[isRTL ? 'previousSibling' : 'nextSibling'];
+ }
+ var position = $(obj).offset();
+ return [position.left, position.top];
},
/* Hide the date picker from view.
@@ -8088,17 +8010,21 @@ $.extend(Datepicker.prototype, {
var duration = this._get(inst, 'duration');
var postProcess = function() {
$.datepicker._tidyDialog(inst);
- this._curInst = null;
};
- if ($.effects && $.effects[showAnim])
+
+ // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
+ if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) )
inst.dpDiv.hide(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess);
else
inst.dpDiv[(showAnim == 'slideDown' ? 'slideUp' :
(showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess);
if (!showAnim)
postProcess();
- $.datepicker._triggerOnClose(inst);
this._datepickerShowing = false;
+ var onClose = this._get(inst, 'onClose');
+ if (onClose)
+ onClose.apply((inst.input ? inst.input[0] : null),
+ [(inst.input ? inst.input.val() : ''), inst]);
this._lastInput = null;
if (this._inDialog) {
this._dialogInput.css({ position: 'absolute', left: '0', top: '-100px' });
@@ -8120,12 +8046,16 @@ $.extend(Datepicker.prototype, {
_checkExternalClick: function(event) {
if (!$.datepicker._curInst)
return;
- var $target = $(event.target);
- if ($target[0].id != $.datepicker._mainDivId &&
+
+ var $target = $(event.target),
+ inst = $.datepicker._getInst($target[0]);
+
+ if ( ( ( $target[0].id != $.datepicker._mainDivId &&
$target.parents('#' + $.datepicker._mainDivId).length == 0 &&
!$target.hasClass($.datepicker.markerClassName) &&
- !$target.hasClass($.datepicker._triggerClass) &&
- $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))
+ !$target.closest("." + $.datepicker._triggerClass).length &&
+ $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
+ ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst != inst ) )
$.datepicker._hideDatepicker();
},
@@ -8375,7 +8305,10 @@ $.extend(Datepicker.prototype, {
}
}
if (iValue < value.length){
- throw "Extra/unparsed characters found in date: " + value.substring(iValue);
+ var extra = value.substr(iValue);
+ if (!/^\s+/.test(extra)) {
+ throw "Extra/unparsed characters found in date: " + extra;
+ }
}
if (year == -1)
year = new Date().getFullYear();
@@ -8682,6 +8615,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.replace( /\\\\/g, "\\" );
+ 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();
@@ -8724,8 +8694,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');
@@ -8733,19 +8702,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);
@@ -8824,8 +8791,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 ? '&#xa0;' : // 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' : '') +
@@ -8842,13 +8808,13 @@ $.extend(Datepicker.prototype, {
drawMonth = 0;
drawYear++;
}
- calender += '</tbody></table>' + (isMultiMonth ? '</div>' +
+ calender += '</tbody></table>' + (isMultiMonth ? '</div>' +
((numMonths[0] > 0 && col == numMonths[1]-1) ? '<div class="ui-datepicker-row-break"></div>' : '') : '');
group += calender;
}
html += group;
}
- html += buttonPanel + ($.browser.msie && parseInt($.browser.version,10) < 7 && !inst.inline ?
+ html += buttonPanel + ($.ui.ie6 && !inst.inline ?
'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>' : '');
inst._keyEvent = false;
return html;
@@ -8868,9 +8834,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()))
@@ -8901,16 +8865,14 @@ $.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"' : '') +
'>' + year + '</option>';
}
inst.yearshtml += '</select>';
-
+
html += inst.yearshtml;
inst.yearshtml = null;
}
@@ -9021,26 +8983,21 @@ $.extend(Datepicker.prototype, {
* Bind hover events for datepicker elements.
* Done via delegate so the binding only occurs once in the lifetime of the parent div.
* Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
- */
+ */
function bindHover(dpDiv) {
var selector = 'button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a';
- return dpDiv.bind('mouseout', function(event) {
- var elem = $( event.target ).closest( selector );
- if ( !elem.length ) {
- return;
- }
- elem.removeClass( "ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover" );
+ return dpDiv.delegate(selector, 'mouseout', function() {
+ $(this).removeClass('ui-state-hover');
+ if (this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover');
+ if (this.className.indexOf('ui-datepicker-next') != -1) $(this).removeClass('ui-datepicker-next-hover');
})
- .bind('mouseover', function(event) {
- var elem = $( event.target ).closest( selector );
- if ($.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0]) ||
- !elem.length ) {
- return;
+ .delegate(selector, 'mouseover', function(){
+ if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
+ $(this).parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');
+ $(this).addClass('ui-state-hover');
+ if (this.className.indexOf('ui-datepicker-prev') != -1) $(this).addClass('ui-datepicker-prev-hover');
+ if (this.className.indexOf('ui-datepicker-next') != -1) $(this).addClass('ui-datepicker-next-hover');
}
- elem.parents('.ui-datepicker-calendar').find('a').removeClass('ui-state-hover');
- elem.addClass('ui-state-hover');
- if (elem.hasClass('ui-datepicker-prev')) elem.addClass('ui-datepicker-prev-hover');
- if (elem.hasClass('ui-datepicker-next')) elem.addClass('ui-datepicker-next-hover');
});
}
@@ -9053,27 +9010,21 @@ 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
+ Object - settings for attaching new datepicker functionality
@return jQuery object */
$.fn.datepicker = function(options){
-
+
/* Verify an empty collection wasn't passed - Fixes #6976 */
if ( !this.length ) {
return this;
}
-
+
/* Initialise the date picker. */
if (!$.datepicker.initialized) {
$(document).mousedown($.datepicker._checkExternalClick).
- find('body').append($.datepicker.dpDiv);
+ find(document.body).append($.datepicker.dpDiv);
$.datepicker.initialized = true;
}
@@ -9095,38 +9046,17 @@ $.fn.datepicker = function(options){
$.datepicker = new Datepicker(); // singleton instance
$.datepicker.initialized = false;
$.datepicker.uuid = new Date().getTime();
-$.datepicker.version = "1.8.16";
+$.datepicker.version = "1.9.2";
// Workaround for #4055
// Add another global to avoid noConflict issues with inline event handlers
window['DP_jQuery_' + dpuuid] = $;
})(jQuery);
-/*
- * jQuery UI Dialog 1.8.16
- *
- * Copyright 2011, 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/Dialog
- *
- * Depends:
- * jquery.ui.core.js
- * jquery.ui.widget.js
- * jquery.ui.button.js
- * jquery.ui.draggable.js
- * jquery.ui.mouse.js
- * jquery.ui.position.js
- * jquery.ui.resizable.js
- */
+
(function( $, undefined ) {
-var uiDialogClasses =
- 'ui-dialog ' +
- 'ui-widget ' +
- 'ui-widget-content ' +
- 'ui-corner-all ',
+var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ",
sizeRelatedOptions = {
buttons: true,
height: true,
@@ -9141,173 +9071,170 @@ var uiDialogClasses =
maxWidth: true,
minHeight: true,
minWidth: true
- },
- // support for jQuery 1.3.2 - handle common attrFn methods for dialog
- attrFn = $.attrFn || {
- val: true,
- css: true,
- html: true,
- text: true,
- data: true,
- width: true,
- height: true,
- offset: true,
- click: true
};
$.widget("ui.dialog", {
+ version: "1.9.2",
options: {
autoOpen: true,
buttons: {},
closeOnEscape: true,
- closeText: 'close',
- dialogClass: '',
+ closeText: "close",
+ dialogClass: "",
draggable: true,
hide: null,
- height: 'auto',
+ height: "auto",
maxHeight: false,
maxWidth: false,
minHeight: 150,
minWidth: 150,
modal: false,
position: {
- my: 'center',
- at: 'center',
- collision: 'fit',
+ my: "center",
+ at: "center",
+ of: window,
+ collision: "fit",
// ensure that the titlebar is never outside the document
- using: function(pos) {
- var topOffset = $(this).css(pos).offset().top;
- if (topOffset < 0) {
- $(this).css('top', pos.top - topOffset);
+ using: function( pos ) {
+ var topOffset = $( this ).css( pos ).offset().top;
+ if ( topOffset < 0 ) {
+ $( this ).css( "top", pos.top - topOffset );
}
}
},
resizable: true,
show: null,
stack: true,
- title: '',
+ title: "",
width: 300,
zIndex: 1000
},
_create: function() {
- this.originalTitle = this.element.attr('title');
+ this.originalTitle = this.element.attr( "title" );
// #5742 - .attr() might return a DOMElement
if ( typeof this.originalTitle !== "string" ) {
this.originalTitle = "";
}
-
+ this.oldPosition = {
+ parent: this.element.parent(),
+ index: this.element.parent().children().index( this.element )
+ };
this.options.title = this.options.title || this.originalTitle;
- var self = this,
- options = self.options,
+ var that = this,
+ options = this.options,
- title = options.title || '&#160;',
- titleId = $.ui.dialog.getTitleId(self.element),
+ title = options.title || "&#160;",
+ uiDialog,
+ uiDialogTitlebar,
+ uiDialogTitlebarClose,
+ uiDialogTitle,
+ uiDialogButtonPane;
- uiDialog = (self.uiDialog = $('<div></div>'))
- .appendTo(document.body)
- .hide()
- .addClass(uiDialogClasses + options.dialogClass)
+ uiDialog = ( this.uiDialog = $( "<div>" ) )
+ .addClass( uiDialogClasses + options.dialogClass )
.css({
+ display: "none",
+ outline: 0, // TODO: move to stylesheet
zIndex: options.zIndex
})
// setting tabIndex makes the div focusable
- // setting outline to 0 prevents a border on focus in Mozilla
- .attr('tabIndex', -1).css('outline', 0).keydown(function(event) {
- if (options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
- event.keyCode === $.ui.keyCode.ESCAPE) {
-
- self.close(event);
+ .attr( "tabIndex", -1)
+ .keydown(function( event ) {
+ if ( options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
+ event.keyCode === $.ui.keyCode.ESCAPE ) {
+ that.close( event );
event.preventDefault();
}
})
- .attr({
- role: 'dialog',
- 'aria-labelledby': titleId
+ .mousedown(function( event ) {
+ that.moveToTop( false, event );
})
- .mousedown(function(event) {
- self.moveToTop(false, event);
- }),
+ .appendTo( "body" );
- uiDialogContent = self.element
+ this.element
.show()
- .removeAttr('title')
- .addClass(
- 'ui-dialog-content ' +
- 'ui-widget-content')
- .appendTo(uiDialog),
-
- uiDialogTitlebar = (self.uiDialogTitlebar = $('<div></div>'))
- .addClass(
- 'ui-dialog-titlebar ' +
- 'ui-widget-header ' +
- 'ui-corner-all ' +
- 'ui-helper-clearfix'
- )
- .prependTo(uiDialog),
-
- uiDialogTitlebarClose = $('<a href="#"></a>')
- .addClass(
- 'ui-dialog-titlebar-close ' +
- 'ui-corner-all'
- )
- .attr('role', 'button')
- .hover(
- function() {
- uiDialogTitlebarClose.addClass('ui-state-hover');
- },
- function() {
- uiDialogTitlebarClose.removeClass('ui-state-hover');
- }
- )
- .focus(function() {
- uiDialogTitlebarClose.addClass('ui-state-focus');
- })
- .blur(function() {
- uiDialogTitlebarClose.removeClass('ui-state-focus');
+ .removeAttr( "title" )
+ .addClass( "ui-dialog-content ui-widget-content" )
+ .appendTo( uiDialog );
+
+ uiDialogTitlebar = ( this.uiDialogTitlebar = $( "<div>" ) )
+ .addClass( "ui-dialog-titlebar ui-widget-header " +
+ "ui-corner-all ui-helper-clearfix" )
+ .bind( "mousedown", function() {
+ // Dialog isn't getting focus when dragging (#8063)
+ uiDialog.focus();
})
- .click(function(event) {
- self.close(event);
- return false;
+ .prependTo( uiDialog );
+
+ uiDialogTitlebarClose = $( "<a href='#'></a>" )
+ .addClass( "ui-dialog-titlebar-close ui-corner-all" )
+ .attr( "role", "button" )
+ .click(function( event ) {
+ event.preventDefault();
+ that.close( event );
})
- .appendTo(uiDialogTitlebar),
+ .appendTo( uiDialogTitlebar );
- uiDialogTitlebarCloseText = (self.uiDialogTitlebarCloseText = $('<span></span>'))
- .addClass(
- 'ui-icon ' +
- 'ui-icon-closethick'
- )
- .text(options.closeText)
- .appendTo(uiDialogTitlebarClose),
+ ( this.uiDialogTitlebarCloseText = $( "<span>" ) )
+ .addClass( "ui-icon ui-icon-closethick" )
+ .text( options.closeText )
+ .appendTo( uiDialogTitlebarClose );
- uiDialogTitle = $('<span></span>')
- .addClass('ui-dialog-title')
- .attr('id', titleId)
- .html(title)
- .prependTo(uiDialogTitlebar);
+ uiDialogTitle = $( "<span>" )
+ .uniqueId()
+ .addClass( "ui-dialog-title" )
+ .html( title )
+ .prependTo( uiDialogTitlebar );
- //handling of deprecated beforeclose (vs beforeClose) option
- //Ticket #4669 http://dev.jqueryui.com/ticket/4669
- //TODO: remove in 1.9pre
- if ($.isFunction(options.beforeclose) && !$.isFunction(options.beforeClose)) {
- options.beforeClose = options.beforeclose;
- }
+ uiDialogButtonPane = ( this.uiDialogButtonPane = $( "<div>" ) )
+ .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
+
+ ( this.uiButtonSet = $( "<div>" ) )
+ .addClass( "ui-dialog-buttonset" )
+ .appendTo( uiDialogButtonPane );
- uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();
+ uiDialog.attr({
+ role: "dialog",
+ "aria-labelledby": uiDialogTitle.attr( "id" )
+ });
+
+ uiDialogTitlebar.find( "*" ).add( uiDialogTitlebar ).disableSelection();
+ this._hoverable( uiDialogTitlebarClose );
+ this._focusable( uiDialogTitlebarClose );
- if (options.draggable && $.fn.draggable) {
- self._makeDraggable();
+ if ( options.draggable && $.fn.draggable ) {
+ this._makeDraggable();
}
- if (options.resizable && $.fn.resizable) {
- self._makeResizable();
+ if ( options.resizable && $.fn.resizable ) {
+ this._makeResizable();
}
- self._createButtons(options.buttons);
- self._isOpen = false;
+ this._createButtons( options.buttons );
+ this._isOpen = false;
- if ($.fn.bgiframe) {
+ if ( $.fn.bgiframe ) {
uiDialog.bgiframe();
}
+
+ // prevent tabbing out of modal dialogs
+ this._on( uiDialog, { keydown: function( event ) {
+ if ( !options.modal || event.keyCode !== $.ui.keyCode.TAB ) {
+ return;
+ }
+
+ var tabbables = $( ":tabbable", uiDialog ),
+ first = tabbables.filter( ":first" ),
+ last = tabbables.filter( ":last" );
+
+ if ( event.target === last[0] && !event.shiftKey ) {
+ first.focus( 1 );
+ return false;
+ } else if ( event.target === first[0] && event.shiftKey ) {
+ last.focus( 1 );
+ return false;
+ }
+ }});
},
_init: function() {
@@ -9316,72 +9243,81 @@ $.widget("ui.dialog", {
}
},
- destroy: function() {
- var self = this;
-
- if (self.overlay) {
- self.overlay.destroy();
+ _destroy: function() {
+ var next,
+ oldPosition = this.oldPosition;
+
+ if ( this.overlay ) {
+ this.overlay.destroy();
}
- self.uiDialog.hide();
- self.element
- .unbind('.dialog')
- .removeData('dialog')
- .removeClass('ui-dialog-content ui-widget-content')
- .hide().appendTo('body');
- self.uiDialog.remove();
+ this.uiDialog.hide();
+ this.element
+ .removeClass( "ui-dialog-content ui-widget-content" )
+ .hide()
+ .appendTo( "body" );
+ this.uiDialog.remove();
- if (self.originalTitle) {
- self.element.attr('title', self.originalTitle);
+ if ( this.originalTitle ) {
+ this.element.attr( "title", this.originalTitle );
}
- return self;
+ next = oldPosition.parent.children().eq( oldPosition.index );
+ // Don't try to place the dialog next to itself (#8613)
+ if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
+ next.before( this.element );
+ } else {
+ oldPosition.parent.append( this.element );
+ }
},
widget: function() {
return this.uiDialog;
},
- close: function(event) {
- var self = this,
+ close: function( event ) {
+ var that = this,
maxZ, thisZ;
-
- if (false === self._trigger('beforeClose', event)) {
+
+ if ( !this._isOpen ) {
return;
}
- if (self.overlay) {
- self.overlay.destroy();
+ if ( false === this._trigger( "beforeClose", event ) ) {
+ return;
}
- self.uiDialog.unbind('keypress.ui-dialog');
- self._isOpen = false;
+ this._isOpen = false;
- if (self.options.hide) {
- self.uiDialog.hide(self.options.hide, function() {
- self._trigger('close', event);
+ if ( this.overlay ) {
+ this.overlay.destroy();
+ }
+
+ if ( this.options.hide ) {
+ this._hide( this.uiDialog, this.options.hide, function() {
+ that._trigger( "close", event );
});
} else {
- self.uiDialog.hide();
- self._trigger('close', event);
+ this.uiDialog.hide();
+ this._trigger( "close", event );
}
$.ui.dialog.overlay.resize();
// adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
- if (self.options.modal) {
+ if ( this.options.modal ) {
maxZ = 0;
- $('.ui-dialog').each(function() {
- if (this !== self.uiDialog[0]) {
- thisZ = $(this).css('z-index');
- if(!isNaN(thisZ)) {
- maxZ = Math.max(maxZ, thisZ);
+ $( ".ui-dialog" ).each(function() {
+ if ( this !== that.uiDialog[0] ) {
+ thisZ = $( this ).css( "z-index" );
+ if ( !isNaN( thisZ ) ) {
+ maxZ = Math.max( maxZ, thisZ );
}
}
});
$.ui.dialog.maxZ = maxZ;
}
- return self;
+ return this;
},
isOpen: function() {
@@ -9390,179 +9326,158 @@ $.widget("ui.dialog", {
// the force parameter allows us to move modal dialogs to their correct
// position on open
- moveToTop: function(force, event) {
- var self = this,
- options = self.options,
+ moveToTop: function( force, event ) {
+ var options = this.options,
saveScroll;
- if ((options.modal && !force) ||
- (!options.stack && !options.modal)) {
- return self._trigger('focus', event);
+ if ( ( options.modal && !force ) ||
+ ( !options.stack && !options.modal ) ) {
+ return this._trigger( "focus", event );
}
- if (options.zIndex > $.ui.dialog.maxZ) {
+ if ( options.zIndex > $.ui.dialog.maxZ ) {
$.ui.dialog.maxZ = options.zIndex;
}
- if (self.overlay) {
+ if ( this.overlay ) {
$.ui.dialog.maxZ += 1;
- self.overlay.$el.css('z-index', $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ);
+ $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ;
+ this.overlay.$el.css( "z-index", $.ui.dialog.overlay.maxZ );
}
- //Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed.
- // http://ui.jquery.com/bugs/ticket/3193
- saveScroll = { scrollTop: self.element.scrollTop(), scrollLeft: self.element.scrollLeft() };
+ // Save and then restore scroll
+ // Opera 9.5+ resets when parent z-index is changed.
+ // http://bugs.jqueryui.com/ticket/3193
+ saveScroll = {
+ scrollTop: this.element.scrollTop(),
+ scrollLeft: this.element.scrollLeft()
+ };
$.ui.dialog.maxZ += 1;
- self.uiDialog.css('z-index', $.ui.dialog.maxZ);
- self.element.attr(saveScroll);
- self._trigger('focus', event);
+ this.uiDialog.css( "z-index", $.ui.dialog.maxZ );
+ this.element.attr( saveScroll );
+ this._trigger( "focus", event );
- return self;
+ return this;
},
open: function() {
- if (this._isOpen) { return; }
+ if ( this._isOpen ) {
+ return;
+ }
- var self = this,
- options = self.options,
- uiDialog = self.uiDialog;
+ var hasFocus,
+ options = this.options,
+ uiDialog = this.uiDialog;
- self.overlay = options.modal ? new $.ui.dialog.overlay(self) : null;
- self._size();
- self._position(options.position);
- uiDialog.show(options.show);
- self.moveToTop(true);
+ this._size();
+ this._position( options.position );
+ uiDialog.show( options.show );
+ this.overlay = options.modal ? new $.ui.dialog.overlay( this ) : null;
+ this.moveToTop( true );
- // prevent tabbing out of modal dialogs
- if (options.modal) {
- uiDialog.bind('keypress.ui-dialog', function(event) {
- if (event.keyCode !== $.ui.keyCode.TAB) {
- return;
- }
+ // set focus to the first tabbable element in the content area or the first button
+ // if there are no tabbable elements, set focus on the dialog itself
+ hasFocus = this.element.find( ":tabbable" );
+ if ( !hasFocus.length ) {
+ hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
+ if ( !hasFocus.length ) {
+ hasFocus = uiDialog;
+ }
+ }
+ hasFocus.eq( 0 ).focus();
- var tabbables = $(':tabbable', this),
- first = tabbables.filter(':first'),
- last = tabbables.filter(':last');
+ this._isOpen = true;
+ this._trigger( "open" );
- if (event.target === last[0] && !event.shiftKey) {
- first.focus(1);
- return false;
- } else if (event.target === first[0] && event.shiftKey) {
- last.focus(1);
- return false;
- }
- });
- }
+ return this;
+ },
- // set focus to the first tabbable element in the content area or the first button
- // if there are no tabbable elements, set focus on the dialog itself
- $(self.element.find(':tabbable').get().concat(
- uiDialog.find('.ui-dialog-buttonpane :tabbable').get().concat(
- uiDialog.get()))).eq(0).focus();
-
- self._isOpen = true;
- self._trigger('open');
-
- return self;
- },
-
- _createButtons: function(buttons) {
- var self = this,
- hasButtons = false,
- uiDialogButtonPane = $('<div></div>')
- .addClass(
- 'ui-dialog-buttonpane ' +
- 'ui-widget-content ' +
- 'ui-helper-clearfix'
- ),
- uiButtonSet = $( "<div></div>" )
- .addClass( "ui-dialog-buttonset" )
- .appendTo( uiDialogButtonPane );
+ _createButtons: function( buttons ) {
+ var that = this,
+ hasButtons = false;
// if we already have a button pane, remove it
- self.uiDialog.find('.ui-dialog-buttonpane').remove();
+ this.uiDialogButtonPane.remove();
+ this.uiButtonSet.empty();
- if (typeof buttons === 'object' && buttons !== null) {
- $.each(buttons, function() {
+ if ( typeof buttons === "object" && buttons !== null ) {
+ $.each( buttons, function() {
return !(hasButtons = true);
});
}
- if (hasButtons) {
- $.each(buttons, function(name, props) {
+ if ( hasButtons ) {
+ $.each( buttons, function( name, props ) {
+ var button, click;
props = $.isFunction( props ) ?
{ click: props, text: name } :
props;
- var button = $('<button type="button"></button>')
- .click(function() {
- props.click.apply(self.element[0], arguments);
- })
- .appendTo(uiButtonSet);
- // can't use .attr( props, true ) with jQuery 1.3.2.
- $.each( props, function( key, value ) {
- if ( key === "click" ) {
- return;
- }
- if ( key in attrFn ) {
- button[ key ]( value );
- } else {
- button.attr( key, value );
- }
- });
- if ($.fn.button) {
+ // Default to a non-submitting button
+ props = $.extend( { type: "button" }, props );
+ // Change the context for the click callback to be the main element
+ click = props.click;
+ props.click = function() {
+ click.apply( that.element[0], arguments );
+ };
+ button = $( "<button></button>", props )
+ .appendTo( that.uiButtonSet );
+ if ( $.fn.button ) {
button.button();
}
});
- uiDialogButtonPane.appendTo(self.uiDialog);
+ this.uiDialog.addClass( "ui-dialog-buttons" );
+ this.uiDialogButtonPane.appendTo( this.uiDialog );
+ } else {
+ this.uiDialog.removeClass( "ui-dialog-buttons" );
}
},
_makeDraggable: function() {
- var self = this,
- options = self.options,
- doc = $(document),
- heightBeforeDrag;
+ var that = this,
+ options = this.options;
- function filteredUi(ui) {
+ function filteredUi( ui ) {
return {
position: ui.position,
offset: ui.offset
};
}
- self.uiDialog.draggable({
- cancel: '.ui-dialog-content, .ui-dialog-titlebar-close',
- handle: '.ui-dialog-titlebar',
- containment: 'document',
- start: function(event, ui) {
- heightBeforeDrag = options.height === "auto" ? "auto" : $(this).height();
- $(this).height($(this).height()).addClass("ui-dialog-dragging");
- self._trigger('dragStart', event, filteredUi(ui));
+ this.uiDialog.draggable({
+ cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
+ handle: ".ui-dialog-titlebar",
+ containment: "document",
+ start: function( event, ui ) {
+ $( this )
+ .addClass( "ui-dialog-dragging" );
+ that._trigger( "dragStart", event, filteredUi( ui ) );
},
- drag: function(event, ui) {
- self._trigger('drag', event, filteredUi(ui));
+ drag: function( event, ui ) {
+ that._trigger( "drag", event, filteredUi( ui ) );
},
- stop: function(event, ui) {
- options.position = [ui.position.left - doc.scrollLeft(),
- ui.position.top - doc.scrollTop()];
- $(this).removeClass("ui-dialog-dragging").height(heightBeforeDrag);
- self._trigger('dragStop', event, filteredUi(ui));
+ stop: function( event, ui ) {
+ options.position = [
+ ui.position.left - that.document.scrollLeft(),
+ ui.position.top - that.document.scrollTop()
+ ];
+ $( this )
+ .removeClass( "ui-dialog-dragging" );
+ that._trigger( "dragStop", event, filteredUi( ui ) );
$.ui.dialog.overlay.resize();
}
});
},
- _makeResizable: function(handles) {
+ _makeResizable: function( handles ) {
handles = (handles === undefined ? this.options.resizable : handles);
- var self = this,
- options = self.options,
+ var that = this,
+ options = this.options,
// .ui-resizable has position: relative defined in the stylesheet
// but dialogs have to use absolute or fixed positioning
- position = self.uiDialog.css('position'),
- resizeHandles = (typeof handles === 'string' ?
+ position = this.uiDialog.css( "position" ),
+ resizeHandles = typeof handles === 'string' ?
handles :
- 'n,e,s,w,se,sw,ne,nw'
- );
+ "n,e,s,w,se,sw,ne,nw";
- function filteredUi(ui) {
+ function filteredUi( ui ) {
return {
originalPosition: ui.originalPosition,
originalSize: ui.originalSize,
@@ -9571,101 +9486,99 @@ $.widget("ui.dialog", {
};
}
- self.uiDialog.resizable({
- cancel: '.ui-dialog-content',
- containment: 'document',
- alsoResize: self.element,
+ this.uiDialog.resizable({
+ cancel: ".ui-dialog-content",
+ containment: "document",
+ alsoResize: this.element,
maxWidth: options.maxWidth,
maxHeight: options.maxHeight,
minWidth: options.minWidth,
- minHeight: self._minHeight(),
+ minHeight: this._minHeight(),
handles: resizeHandles,
- start: function(event, ui) {
- $(this).addClass("ui-dialog-resizing");
- self._trigger('resizeStart', event, filteredUi(ui));
+ start: function( event, ui ) {
+ $( this ).addClass( "ui-dialog-resizing" );
+ that._trigger( "resizeStart", event, filteredUi( ui ) );
},
- resize: function(event, ui) {
- self._trigger('resize', event, filteredUi(ui));
+ resize: function( event, ui ) {
+ that._trigger( "resize", event, filteredUi( ui ) );
},
- stop: function(event, ui) {
- $(this).removeClass("ui-dialog-resizing");
- options.height = $(this).height();
- options.width = $(this).width();
- self._trigger('resizeStop', event, filteredUi(ui));
+ stop: function( event, ui ) {
+ $( this ).removeClass( "ui-dialog-resizing" );
+ options.height = $( this ).height();
+ options.width = $( this ).width();
+ that._trigger( "resizeStop", event, filteredUi( ui ) );
$.ui.dialog.overlay.resize();
}
})
- .css('position', position)
- .find('.ui-resizable-se').addClass('ui-icon ui-icon-grip-diagonal-se');
+ .css( "position", position )
+ .find( ".ui-resizable-se" )
+ .addClass( "ui-icon ui-icon-grip-diagonal-se" );
},
_minHeight: function() {
var options = this.options;
- if (options.height === 'auto') {
+ if ( options.height === "auto" ) {
return options.minHeight;
} else {
- return Math.min(options.minHeight, options.height);
+ return Math.min( options.minHeight, options.height );
}
},
- _position: function(position) {
+ _position: function( position ) {
var myAt = [],
- offset = [0, 0],
+ offset = [ 0, 0 ],
isVisible;
- if (position) {
+ if ( position ) {
// deep extending converts arrays to objects in jQuery <= 1.3.2 :-(
// if (typeof position == 'string' || $.isArray(position)) {
// myAt = $.isArray(position) ? position : position.split(' ');
- if (typeof position === 'string' || (typeof position === 'object' && '0' in position)) {
- myAt = position.split ? position.split(' ') : [position[0], position[1]];
- if (myAt.length === 1) {
- myAt[1] = myAt[0];
+ if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
+ myAt = position.split ? position.split( " " ) : [ position[ 0 ], position[ 1 ] ];
+ if ( myAt.length === 1 ) {
+ myAt[ 1 ] = myAt[ 0 ];
}
- $.each(['left', 'top'], function(i, offsetPosition) {
- if (+myAt[i] === myAt[i]) {
- offset[i] = myAt[i];
- myAt[i] = offsetPosition;
+ $.each( [ "left", "top" ], function( i, offsetPosition ) {
+ if ( +myAt[ i ] === myAt[ i ] ) {
+ offset[ i ] = myAt[ i ];
+ myAt[ i ] = offsetPosition;
}
});
position = {
- my: myAt.join(" "),
- at: myAt.join(" "),
- offset: offset.join(" ")
+ my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
+ myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
+ at: myAt.join( " " )
};
- }
+ }
- position = $.extend({}, $.ui.dialog.prototype.options.position, position);
+ position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
} else {
position = $.ui.dialog.prototype.options.position;
}
// need to show the dialog to get the actual offset in the position plugin
- isVisible = this.uiDialog.is(':visible');
- if (!isVisible) {
+ isVisible = this.uiDialog.is( ":visible" );
+ if ( !isVisible ) {
this.uiDialog.show();
}
- this.uiDialog
- // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
- .css({ top: 0, left: 0 })
- .position($.extend({ of: window }, position));
- if (!isVisible) {
+ this.uiDialog.position( position );
+ if ( !isVisible ) {
this.uiDialog.hide();
}
},
_setOptions: function( options ) {
- var self = this,
+ var that = this,
resizableOptions = {},
resize = false;
$.each( options, function( key, value ) {
- self._setOption( key, value );
-
+ that._setOption( key, value );
+
if ( key in sizeRelatedOptions ) {
resize = true;
}
@@ -9682,104 +9595,98 @@ $.widget("ui.dialog", {
}
},
- _setOption: function(key, value){
- var self = this,
- uiDialog = self.uiDialog;
-
- switch (key) {
- //handling of deprecated beforeclose (vs beforeClose) option
- //Ticket #4669 http://dev.jqueryui.com/ticket/4669
- //TODO: remove in 1.9pre
- case "beforeclose":
- key = "beforeClose";
- break;
+ _setOption: function( key, value ) {
+ var isDraggable, isResizable,
+ uiDialog = this.uiDialog;
+
+ switch ( key ) {
case "buttons":
- self._createButtons(value);
+ this._createButtons( value );
break;
case "closeText":
// ensure that we always pass a string
- self.uiDialogTitlebarCloseText.text("" + value);
+ this.uiDialogTitlebarCloseText.text( "" + value );
break;
case "dialogClass":
uiDialog
- .removeClass(self.options.dialogClass)
- .addClass(uiDialogClasses + value);
+ .removeClass( this.options.dialogClass )
+ .addClass( uiDialogClasses + value );
break;
case "disabled":
- if (value) {
- uiDialog.addClass('ui-dialog-disabled');
+ if ( value ) {
+ uiDialog.addClass( "ui-dialog-disabled" );
} else {
- uiDialog.removeClass('ui-dialog-disabled');
+ uiDialog.removeClass( "ui-dialog-disabled" );
}
break;
case "draggable":
- var isDraggable = uiDialog.is( ":data(draggable)" );
+ isDraggable = uiDialog.is( ":data(draggable)" );
if ( isDraggable && !value ) {
uiDialog.draggable( "destroy" );
}
-
+
if ( !isDraggable && value ) {
- self._makeDraggable();
+ this._makeDraggable();
}
break;
case "position":
- self._position(value);
+ this._position( value );
break;
case "resizable":
// currently resizable, becoming non-resizable
- var isResizable = uiDialog.is( ":data(resizable)" );
- if (isResizable && !value) {
- uiDialog.resizable('destroy');
+ isResizable = uiDialog.is( ":data(resizable)" );
+ if ( isResizable && !value ) {
+ uiDialog.resizable( "destroy" );
}
// currently resizable, changing handles
- if (isResizable && typeof value === 'string') {
- uiDialog.resizable('option', 'handles', value);
+ if ( isResizable && typeof value === "string" ) {
+ uiDialog.resizable( "option", "handles", value );
}
// currently non-resizable, becoming resizable
- if (!isResizable && value !== false) {
- self._makeResizable(value);
+ if ( !isResizable && value !== false ) {
+ this._makeResizable( value );
}
break;
case "title":
// convert whatever was passed in o a string, for html() to not throw up
- $(".ui-dialog-title", self.uiDialogTitlebar).html("" + (value || '&#160;'));
+ $( ".ui-dialog-title", this.uiDialogTitlebar )
+ .html( "" + ( value || "&#160;" ) );
break;
}
- $.Widget.prototype._setOption.apply(self, arguments);
+ this._super( key, value );
},
_size: function() {
/* If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
* divs will both have width and height set, so we need to reset them
*/
- var options = this.options,
- nonContentHeight,
- minContentHeight,
+ var nonContentHeight, minContentHeight, autoHeight,
+ options = this.options,
isVisible = this.uiDialog.is( ":visible" );
// reset content sizing
this.element.show().css({
- width: 'auto',
+ width: "auto",
minHeight: 0,
height: 0
});
- if (options.minWidth > options.width) {
+ if ( options.minWidth > options.width ) {
options.width = options.minWidth;
}
// reset wrapper sizing
// determine the height of all the non-content elements
nonContentHeight = this.uiDialog.css({
- height: 'auto',
+ height: "auto",
width: options.width
})
- .height();
+ .outerHeight();
minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
-
+
if ( options.height === "auto" ) {
// only needed for IE6 support
if ( $.support.minHeight ) {
@@ -9789,7 +9696,7 @@ $.widget("ui.dialog", {
});
} else {
this.uiDialog.show();
- var autoHeight = this.element.css( "height", "auto" ).height();
+ autoHeight = this.element.css( "height", "auto" ).height();
if ( !isVisible ) {
this.uiDialog.hide();
}
@@ -9799,102 +9706,108 @@ $.widget("ui.dialog", {
this.element.height( Math.max( options.height - nonContentHeight, 0 ) );
}
- if (this.uiDialog.is(':data(resizable)')) {
- this.uiDialog.resizable('option', 'minHeight', this._minHeight());
+ if (this.uiDialog.is( ":data(resizable)" ) ) {
+ this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
}
}
});
$.extend($.ui.dialog, {
- version: "1.8.16",
-
uuid: 0,
maxZ: 0,
getTitleId: function($el) {
- var id = $el.attr('id');
- if (!id) {
+ var id = $el.attr( "id" );
+ if ( !id ) {
this.uuid += 1;
id = this.uuid;
}
- return 'ui-dialog-title-' + id;
+ return "ui-dialog-title-" + id;
},
- overlay: function(dialog) {
- this.$el = $.ui.dialog.overlay.create(dialog);
+ overlay: function( dialog ) {
+ this.$el = $.ui.dialog.overlay.create( dialog );
}
});
-$.extend($.ui.dialog.overlay, {
+$.extend( $.ui.dialog.overlay, {
instances: [],
// reuse old instances due to IE memory leak with alpha transparency (see #5185)
oldInstances: [],
maxZ: 0,
- events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
- function(event) { return event + '.dialog-overlay'; }).join(' '),
- create: function(dialog) {
- if (this.instances.length === 0) {
+ events: $.map(
+ "focus,mousedown,mouseup,keydown,keypress,click".split( "," ),
+ function( event ) {
+ return event + ".dialog-overlay";
+ }
+ ).join( " " ),
+ create: function( dialog ) {
+ if ( this.instances.length === 0 ) {
// prevent use of anchors and inputs
// we use a setTimeout in case the overlay is created from an
// event that we're going to be cancelling (see #2804)
setTimeout(function() {
// handle $(el).dialog().dialog('close') (see #4065)
- if ($.ui.dialog.overlay.instances.length) {
- $(document).bind($.ui.dialog.overlay.events, function(event) {
+ if ( $.ui.dialog.overlay.instances.length ) {
+ $( document ).bind( $.ui.dialog.overlay.events, function( event ) {
// stop events if the z-index of the target is < the z-index of the overlay
// we cannot return true when we don't want to cancel the event (#3523)
- if ($(event.target).zIndex() < $.ui.dialog.overlay.maxZ) {
+ if ( $( event.target ).zIndex() < $.ui.dialog.overlay.maxZ ) {
return false;
}
});
}
- }, 1);
-
- // allow closing by pressing the escape key
- $(document).bind('keydown.dialog-overlay', function(event) {
- if (dialog.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
- event.keyCode === $.ui.keyCode.ESCAPE) {
-
- dialog.close(event);
- event.preventDefault();
- }
- });
+ }, 1 );
// handle window resize
- $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);
+ $( window ).bind( "resize.dialog-overlay", $.ui.dialog.overlay.resize );
}
- var $el = (this.oldInstances.pop() || $('<div></div>').addClass('ui-widget-overlay'))
- .appendTo(document.body)
- .css({
- width: this.width(),
- height: this.height()
- });
+ var $el = ( this.oldInstances.pop() || $( "<div>" ).addClass( "ui-widget-overlay" ) );
+
+ // allow closing by pressing the escape key
+ $( document ).bind( "keydown.dialog-overlay", function( event ) {
+ var instances = $.ui.dialog.overlay.instances;
+ // only react to the event if we're the top overlay
+ if ( instances.length !== 0 && instances[ instances.length - 1 ] === $el &&
+ dialog.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
+ event.keyCode === $.ui.keyCode.ESCAPE ) {
+
+ dialog.close( event );
+ event.preventDefault();
+ }
+ });
+
+ $el.appendTo( document.body ).css({
+ width: this.width(),
+ height: this.height()
+ });
- if ($.fn.bgiframe) {
+ if ( $.fn.bgiframe ) {
$el.bgiframe();
}
- this.instances.push($el);
+ this.instances.push( $el );
return $el;
},
- destroy: function($el) {
- var indexOf = $.inArray($el, this.instances);
- if (indexOf != -1){
- this.oldInstances.push(this.instances.splice(indexOf, 1)[0]);
+ destroy: function( $el ) {
+ var indexOf = $.inArray( $el, this.instances ),
+ maxZ = 0;
+
+ if ( indexOf !== -1 ) {
+ this.oldInstances.push( this.instances.splice( indexOf, 1 )[ 0 ] );
}
- if (this.instances.length === 0) {
- $([document, window]).unbind('.dialog-overlay');
+ if ( this.instances.length === 0 ) {
+ $( [ document, window ] ).unbind( ".dialog-overlay" );
}
- $el.remove();
-
+ $el.height( 0 ).width( 0 ).remove();
+
// adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
- var maxZ = 0;
- $.each(this.instances, function() {
- maxZ = Math.max(maxZ, this.css('z-index'));
+ $.each( this.instances, function() {
+ maxZ = Math.max( maxZ, this.css( "z-index" ) );
});
this.maxZ = maxZ;
},
@@ -9902,8 +9815,8 @@ $.extend($.ui.dialog.overlay, {
height: function() {
var scrollHeight,
offsetHeight;
- // handle IE 6
- if ($.browser.msie && $.browser.version < 7) {
+ // handle IE
+ if ( $.ui.ie ) {
scrollHeight = Math.max(
document.documentElement.scrollHeight,
document.body.scrollHeight
@@ -9913,14 +9826,14 @@ $.extend($.ui.dialog.overlay, {
document.body.offsetHeight
);
- if (scrollHeight < offsetHeight) {
- return $(window).height() + 'px';
+ if ( scrollHeight < offsetHeight ) {
+ return $( window ).height() + "px";
} else {
- return scrollHeight + 'px';
+ return scrollHeight + "px";
}
// handle "good" browsers
} else {
- return $(document).height() + 'px';
+ return $( document ).height() + "px";
}
},
@@ -9928,7 +9841,7 @@ $.extend($.ui.dialog.overlay, {
var scrollWidth,
offsetWidth;
// handle IE
- if ( $.browser.msie ) {
+ if ( $.ui.ie ) {
scrollWidth = Math.max(
document.documentElement.scrollWidth,
document.body.scrollWidth
@@ -9938,14 +9851,14 @@ $.extend($.ui.dialog.overlay, {
document.body.offsetWidth
);
- if (scrollWidth < offsetWidth) {
- return $(window).width() + 'px';
+ if ( scrollWidth < offsetWidth ) {
+ return $( window ).width() + "px";
} else {
- return scrollWidth + 'px';
+ return scrollWidth + "px";
}
// handle "good" browsers
} else {
- return $(document).width() + 'px';
+ return $( document ).width() + "px";
}
},
@@ -9958,9 +9871,9 @@ $.extend($.ui.dialog.overlay, {
* This is handled by shrinking the overlay before setting it
* to the full document size.
*/
- var $overlays = $([]);
- $.each($.ui.dialog.overlay.instances, function() {
- $overlays = $overlays.add(this);
+ var $overlays = $( [] );
+ $.each( $.ui.dialog.overlay.instances, function() {
+ $overlays = $overlays.add( this );
});
$overlays.css({
@@ -9973,31 +9886,1674 @@ $.extend($.ui.dialog.overlay, {
}
});
-$.extend($.ui.dialog.overlay.prototype, {
+$.extend( $.ui.dialog.overlay.prototype, {
destroy: function() {
- $.ui.dialog.overlay.destroy(this.$el);
+ $.ui.dialog.overlay.destroy( this.$el );
}
});
-}(jQuery));
-/*
- * jQuery UI Position 1.8.16
- *
- * Copyright 2011, 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/Position
- */
+}( jQuery ) );
+
+(function( $, undefined ) {
+
+var rvertical = /up|down|vertical/,
+ rpositivemotion = /up|left|vertical|horizontal/;
+
+$.effects.effect.blind = function( o, done ) {
+ // Create element
+ var el = $( this ),
+ props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
+ mode = $.effects.setMode( el, o.mode || "hide" ),
+ direction = o.direction || "up",
+ vertical = rvertical.test( direction ),
+ ref = vertical ? "height" : "width",
+ ref2 = vertical ? "top" : "left",
+ motion = rpositivemotion.test( direction ),
+ animation = {},
+ show = mode === "show",
+ wrapper, distance, margin;
+
+ // if already wrapped, the wrapper's properties are my property. #6245
+ if ( el.parent().is( ".ui-effects-wrapper" ) ) {
+ $.effects.save( el.parent(), props );
+ } else {
+ $.effects.save( el, props );
+ }
+ el.show();
+ wrapper = $.effects.createWrapper( el ).css({
+ overflow: "hidden"
+ });
+
+ distance = wrapper[ ref ]();
+ margin = parseFloat( wrapper.css( ref2 ) ) || 0;
+
+ animation[ ref ] = show ? distance : 0;
+ if ( !motion ) {
+ el
+ .css( vertical ? "bottom" : "right", 0 )
+ .css( vertical ? "top" : "left", "auto" )
+ .css({ position: "absolute" });
+
+ animation[ ref2 ] = show ? margin : distance + margin;
+ }
+
+ // start at 0 if we are showing
+ if ( show ) {
+ wrapper.css( ref, 0 );
+ if ( ! motion ) {
+ wrapper.css( ref2, margin + distance );
+ }
+ }
+
+ // Animate
+ wrapper.animate( animation, {
+ duration: o.duration,
+ easing: o.easing,
+ queue: false,
+ complete: function() {
+ if ( mode === "hide" ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
+ done();
+ }
+ });
+
+};
+
+})(jQuery);
+
+(function( $, undefined ) {
+
+$.effects.effect.bounce = function( o, done ) {
+ var el = $( this ),
+ props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
+
+ // defaults:
+ mode = $.effects.setMode( el, o.mode || "effect" ),
+ hide = mode === "hide",
+ show = mode === "show",
+ direction = o.direction || "up",
+ distance = o.distance,
+ times = o.times || 5,
+
+ // number of internal animations
+ anims = times * 2 + ( show || hide ? 1 : 0 ),
+ speed = o.duration / anims,
+ easing = o.easing,
+
+ // utility:
+ ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
+ motion = ( direction === "up" || direction === "left" ),
+ i,
+ upAnim,
+ downAnim,
+
+ // we will need to re-assemble the queue to stack our animations in place
+ queue = el.queue(),
+ queuelen = queue.length;
+
+ // Avoid touching opacity to prevent clearType and PNG issues in IE
+ if ( show || hide ) {
+ props.push( "opacity" );
+ }
+
+ $.effects.save( el, props );
+ el.show();
+ $.effects.createWrapper( el ); // Create Wrapper
+
+ // default distance for the BIGGEST bounce is the outer Distance / 3
+ if ( !distance ) {
+ distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
+ }
+
+ if ( show ) {
+ downAnim = { opacity: 1 };
+ downAnim[ ref ] = 0;
+
+ // if we are showing, force opacity 0 and set the initial position
+ // then do the "first" animation
+ el.css( "opacity", 0 )
+ .css( ref, motion ? -distance * 2 : distance * 2 )
+ .animate( downAnim, speed, easing );
+ }
+
+ // start at the smallest distance if we are hiding
+ if ( hide ) {
+ distance = distance / Math.pow( 2, times - 1 );
+ }
+
+ downAnim = {};
+ downAnim[ ref ] = 0;
+ // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
+ for ( i = 0; i < times; i++ ) {
+ upAnim = {};
+ upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
+
+ el.animate( upAnim, speed, easing )
+ .animate( downAnim, speed, easing );
+
+ distance = hide ? distance * 2 : distance / 2;
+ }
+
+ // Last Bounce when Hiding
+ if ( hide ) {
+ upAnim = { opacity: 0 };
+ upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
+
+ el.animate( upAnim, speed, easing );
+ }
+
+ el.queue(function() {
+ if ( hide ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
+ done();
+ });
+
+ // inject all the animations we just queued to be first in line (after "inprogress")
+ if ( queuelen > 1) {
+ queue.splice.apply( queue,
+ [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
+ }
+ el.dequeue();
+
+};
+
+})(jQuery);
+
+(function( $, undefined ) {
+
+$.effects.effect.clip = function( o, done ) {
+ // Create element
+ var el = $( this ),
+ props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
+ mode = $.effects.setMode( el, o.mode || "hide" ),
+ show = mode === "show",
+ direction = o.direction || "vertical",
+ vert = direction === "vertical",
+ size = vert ? "height" : "width",
+ position = vert ? "top" : "left",
+ animation = {},
+ wrapper, animate, distance;
+
+ // Save & Show
+ $.effects.save( el, props );
+ el.show();
+
+ // Create Wrapper
+ wrapper = $.effects.createWrapper( el ).css({
+ overflow: "hidden"
+ });
+ animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
+ distance = animate[ size ]();
+
+ // Shift
+ if ( show ) {
+ animate.css( size, 0 );
+ animate.css( position, distance / 2 );
+ }
+
+ // Create Animation Object:
+ animation[ size ] = show ? distance : 0;
+ animation[ position ] = show ? 0 : distance / 2;
+
+ // Animate
+ animate.animate( animation, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
+ complete: function() {
+ if ( !show ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
+ done();
+ }
+ });
+
+};
+
+})(jQuery);
+
+(function( $, undefined ) {
+
+$.effects.effect.drop = function( o, done ) {
+
+ var el = $( this ),
+ props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
+ mode = $.effects.setMode( el, o.mode || "hide" ),
+ show = mode === "show",
+ direction = o.direction || "left",
+ ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
+ motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
+ animation = {
+ opacity: show ? 1 : 0
+ },
+ distance;
+
+ // Adjust
+ $.effects.save( el, props );
+ el.show();
+ $.effects.createWrapper( el );
+
+ distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
+
+ if ( show ) {
+ el
+ .css( "opacity", 0 )
+ .css( ref, motion === "pos" ? -distance : distance );
+ }
+
+ // Animation
+ animation[ ref ] = ( show ?
+ ( motion === "pos" ? "+=" : "-=" ) :
+ ( motion === "pos" ? "-=" : "+=" ) ) +
+ distance;
+
+ // Animate
+ el.animate( animation, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
+ complete: function() {
+ if ( mode === "hide" ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
+ done();
+ }
+ });
+};
+
+})(jQuery);
+
+(function( $, undefined ) {
+
+$.effects.effect.explode = function( o, done ) {
+
+ var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
+ cells = rows,
+ el = $( this ),
+ mode = $.effects.setMode( el, o.mode || "hide" ),
+ show = mode === "show",
+
+ // show and then visibility:hidden the element before calculating offset
+ offset = el.show().css( "visibility", "hidden" ).offset(),
+
+ // width and height of a piece
+ width = Math.ceil( el.outerWidth() / cells ),
+ height = Math.ceil( el.outerHeight() / rows ),
+ pieces = [],
+
+ // loop
+ i, j, left, top, mx, my;
+
+ // children animate complete:
+ function childComplete() {
+ pieces.push( this );
+ if ( pieces.length === rows * cells ) {
+ animComplete();
+ }
+ }
+
+ // clone the element for each row and cell.
+ for( i = 0; i < rows ; i++ ) { // ===>
+ top = offset.top + i * height;
+ my = i - ( rows - 1 ) / 2 ;
+
+ for( j = 0; j < cells ; j++ ) { // |||
+ left = offset.left + j * width;
+ mx = j - ( cells - 1 ) / 2 ;
+
+ // Create a clone of the now hidden main element that will be absolute positioned
+ // within a wrapper div off the -left and -top equal to size of our pieces
+ el
+ .clone()
+ .appendTo( "body" )
+ .wrap( "<div></div>" )
+ .css({
+ position: "absolute",
+ visibility: "visible",
+ left: -j * width,
+ top: -i * height
+ })
+
+ // select the wrapper - make it overflow: hidden and absolute positioned based on
+ // where the original was located +left and +top equal to the size of pieces
+ .parent()
+ .addClass( "ui-effects-explode" )
+ .css({
+ position: "absolute",
+ overflow: "hidden",
+ width: width,
+ height: height,
+ left: left + ( show ? mx * width : 0 ),
+ top: top + ( show ? my * height : 0 ),
+ opacity: show ? 0 : 1
+ }).animate({
+ left: left + ( show ? 0 : mx * width ),
+ top: top + ( show ? 0 : my * height ),
+ opacity: show ? 1 : 0
+ }, o.duration || 500, o.easing, childComplete );
+ }
+ }
+
+ function animComplete() {
+ el.css({
+ visibility: "visible"
+ });
+ $( pieces ).remove();
+ if ( !show ) {
+ el.hide();
+ }
+ done();
+ }
+};
+
+})(jQuery);
+
+(function( $, undefined ) {
+
+$.effects.effect.fade = function( o, done ) {
+ var el = $( this ),
+ mode = $.effects.setMode( el, o.mode || "toggle" );
+
+ el.animate({
+ opacity: mode
+ }, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
+ complete: done
+ });
+};
+
+})( jQuery );
+
+(function( $, undefined ) {
+
+$.effects.effect.fold = function( o, done ) {
+
+ // Create element
+ var el = $( this ),
+ props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
+ mode = $.effects.setMode( el, o.mode || "hide" ),
+ show = mode === "show",
+ hide = mode === "hide",
+ size = o.size || 15,
+ percent = /([0-9]+)%/.exec( size ),
+ horizFirst = !!o.horizFirst,
+ widthFirst = show !== horizFirst,
+ ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
+ duration = o.duration / 2,
+ wrapper, distance,
+ animation1 = {},
+ animation2 = {};
+
+ $.effects.save( el, props );
+ el.show();
+
+ // Create Wrapper
+ wrapper = $.effects.createWrapper( el ).css({
+ overflow: "hidden"
+ });
+ distance = widthFirst ?
+ [ wrapper.width(), wrapper.height() ] :
+ [ wrapper.height(), wrapper.width() ];
+
+ if ( percent ) {
+ size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
+ }
+ if ( show ) {
+ wrapper.css( horizFirst ? {
+ height: 0,
+ width: size
+ } : {
+ height: size,
+ width: 0
+ });
+ }
+
+ // Animation
+ animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
+ animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
+
+ // Animate
+ wrapper
+ .animate( animation1, duration, o.easing )
+ .animate( animation2, duration, o.easing, function() {
+ if ( hide ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
+ done();
+ });
+
+};
+
+})(jQuery);
+
+(function( $, undefined ) {
+
+$.effects.effect.highlight = function( o, done ) {
+ var elem = $( this ),
+ props = [ "backgroundImage", "backgroundColor", "opacity" ],
+ mode = $.effects.setMode( elem, o.mode || "show" ),
+ animation = {
+ backgroundColor: elem.css( "backgroundColor" )
+ };
+
+ if (mode === "hide") {
+ animation.opacity = 0;
+ }
+
+ $.effects.save( elem, props );
+
+ elem
+ .show()
+ .css({
+ backgroundImage: "none",
+ backgroundColor: o.color || "#ffff99"
+ })
+ .animate( animation, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
+ complete: function() {
+ if ( mode === "hide" ) {
+ elem.hide();
+ }
+ $.effects.restore( elem, props );
+ done();
+ }
+ });
+};
+
+})(jQuery);
+
+(function( $, undefined ) {
+
+$.effects.effect.pulsate = function( o, done ) {
+ var elem = $( this ),
+ mode = $.effects.setMode( elem, o.mode || "show" ),
+ show = mode === "show",
+ hide = mode === "hide",
+ showhide = ( show || mode === "hide" ),
+
+ // showing or hiding leaves of the "last" animation
+ anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
+ duration = o.duration / anims,
+ animateTo = 0,
+ queue = elem.queue(),
+ queuelen = queue.length,
+ i;
+
+ if ( show || !elem.is(":visible")) {
+ elem.css( "opacity", 0 ).show();
+ animateTo = 1;
+ }
+
+ // anims - 1 opacity "toggles"
+ for ( i = 1; i < anims; i++ ) {
+ elem.animate({
+ opacity: animateTo
+ }, duration, o.easing );
+ animateTo = 1 - animateTo;
+ }
+
+ elem.animate({
+ opacity: animateTo
+ }, duration, o.easing);
+
+ elem.queue(function() {
+ if ( hide ) {
+ elem.hide();
+ }
+ done();
+ });
+
+ // We just queued up "anims" animations, we need to put them next in the queue
+ if ( queuelen > 1 ) {
+ queue.splice.apply( queue,
+ [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
+ }
+ elem.dequeue();
+};
+
+})(jQuery);
+
+(function( $, undefined ) {
+
+$.effects.effect.puff = function( o, done ) {
+ var elem = $( this ),
+ mode = $.effects.setMode( elem, o.mode || "hide" ),
+ hide = mode === "hide",
+ percent = parseInt( o.percent, 10 ) || 150,
+ factor = percent / 100,
+ original = {
+ height: elem.height(),
+ width: elem.width(),
+ outerHeight: elem.outerHeight(),
+ outerWidth: elem.outerWidth()
+ };
+
+ $.extend( o, {
+ effect: "scale",
+ queue: false,
+ fade: true,
+ mode: mode,
+ complete: done,
+ percent: hide ? percent : 100,
+ from: hide ?
+ original :
+ {
+ height: original.height * factor,
+ width: original.width * factor,
+ outerHeight: original.outerHeight * factor,
+ outerWidth: original.outerWidth * factor
+ }
+ });
+
+ elem.effect( o );
+};
+
+$.effects.effect.scale = function( o, done ) {
+
+ // Create element
+ var el = $( this ),
+ options = $.extend( true, {}, o ),
+ mode = $.effects.setMode( el, o.mode || "effect" ),
+ percent = parseInt( o.percent, 10 ) ||
+ ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
+ direction = o.direction || "both",
+ origin = o.origin,
+ original = {
+ height: el.height(),
+ width: el.width(),
+ outerHeight: el.outerHeight(),
+ outerWidth: el.outerWidth()
+ },
+ factor = {
+ y: direction !== "horizontal" ? (percent / 100) : 1,
+ x: direction !== "vertical" ? (percent / 100) : 1
+ };
+
+ // We are going to pass this effect to the size effect:
+ options.effect = "size";
+ options.queue = false;
+ options.complete = done;
+
+ // Set default origin and restore for show/hide
+ if ( mode !== "effect" ) {
+ options.origin = origin || ["middle","center"];
+ options.restore = true;
+ }
+
+ options.from = o.from || ( mode === "show" ? {
+ height: 0,
+ width: 0,
+ outerHeight: 0,
+ outerWidth: 0
+ } : original );
+ options.to = {
+ height: original.height * factor.y,
+ width: original.width * factor.x,
+ outerHeight: original.outerHeight * factor.y,
+ outerWidth: original.outerWidth * factor.x
+ };
+
+ // Fade option to support puff
+ if ( options.fade ) {
+ if ( mode === "show" ) {
+ options.from.opacity = 0;
+ options.to.opacity = 1;
+ }
+ if ( mode === "hide" ) {
+ options.from.opacity = 1;
+ options.to.opacity = 0;
+ }
+ }
+
+ // Animate
+ el.effect( options );
+
+};
+
+$.effects.effect.size = function( o, done ) {
+
+ // Create element
+ var original, baseline, factor,
+ el = $( this ),
+ props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
+
+ // Always restore
+ props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
+
+ // Copy for children
+ props2 = [ "width", "height", "overflow" ],
+ cProps = [ "fontSize" ],
+ vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
+ hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
+
+ // Set options
+ mode = $.effects.setMode( el, o.mode || "effect" ),
+ restore = o.restore || mode !== "effect",
+ scale = o.scale || "both",
+ origin = o.origin || [ "middle", "center" ],
+ position = el.css( "position" ),
+ props = restore ? props0 : props1,
+ zero = {
+ height: 0,
+ width: 0,
+ outerHeight: 0,
+ outerWidth: 0
+ };
+
+ if ( mode === "show" ) {
+ el.show();
+ }
+ original = {
+ height: el.height(),
+ width: el.width(),
+ outerHeight: el.outerHeight(),
+ outerWidth: el.outerWidth()
+ };
+
+ if ( o.mode === "toggle" && mode === "show" ) {
+ el.from = o.to || zero;
+ el.to = o.from || original;
+ } else {
+ el.from = o.from || ( mode === "show" ? zero : original );
+ el.to = o.to || ( mode === "hide" ? zero : original );
+ }
+
+ // Set scaling factor
+ factor = {
+ from: {
+ y: el.from.height / original.height,
+ x: el.from.width / original.width
+ },
+ to: {
+ y: el.to.height / original.height,
+ x: el.to.width / original.width
+ }
+ };
+
+ // Scale the css box
+ if ( scale === "box" || scale === "both" ) {
+
+ // Vertical props scaling
+ if ( factor.from.y !== factor.to.y ) {
+ props = props.concat( vProps );
+ el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
+ el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
+ }
+
+ // Horizontal props scaling
+ if ( factor.from.x !== factor.to.x ) {
+ props = props.concat( hProps );
+ el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
+ el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
+ }
+ }
+
+ // Scale the content
+ if ( scale === "content" || scale === "both" ) {
+
+ // Vertical props scaling
+ if ( factor.from.y !== factor.to.y ) {
+ props = props.concat( cProps ).concat( props2 );
+ el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
+ el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
+ }
+ }
+
+ $.effects.save( el, props );
+ el.show();
+ $.effects.createWrapper( el );
+ el.css( "overflow", "hidden" ).css( el.from );
+
+ // Adjust
+ if (origin) { // Calculate baseline shifts
+ baseline = $.effects.getBaseline( origin, original );
+ el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
+ el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
+ el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
+ el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
+ }
+ el.css( el.from ); // set top & left
+
+ // Animate
+ if ( scale === "content" || scale === "both" ) { // Scale the children
+
+ // Add margins/font-size
+ vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
+ hProps = hProps.concat([ "marginLeft", "marginRight" ]);
+ props2 = props0.concat(vProps).concat(hProps);
+
+ el.find( "*[width]" ).each( function(){
+ var child = $( this ),
+ c_original = {
+ height: child.height(),
+ width: child.width(),
+ outerHeight: child.outerHeight(),
+ outerWidth: child.outerWidth()
+ };
+ if (restore) {
+ $.effects.save(child, props2);
+ }
+
+ child.from = {
+ height: c_original.height * factor.from.y,
+ width: c_original.width * factor.from.x,
+ outerHeight: c_original.outerHeight * factor.from.y,
+ outerWidth: c_original.outerWidth * factor.from.x
+ };
+ child.to = {
+ height: c_original.height * factor.to.y,
+ width: c_original.width * factor.to.x,
+ outerHeight: c_original.height * factor.to.y,
+ outerWidth: c_original.width * factor.to.x
+ };
+
+ // Vertical props scaling
+ if ( factor.from.y !== factor.to.y ) {
+ child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
+ child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
+ }
+
+ // Horizontal props scaling
+ if ( factor.from.x !== factor.to.x ) {
+ child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
+ child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
+ }
+
+ // Animate children
+ child.css( child.from );
+ child.animate( child.to, o.duration, o.easing, function() {
+
+ // Restore children
+ if ( restore ) {
+ $.effects.restore( child, props2 );
+ }
+ });
+ });
+ }
+
+ // Animate
+ el.animate( el.to, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
+ complete: function() {
+ if ( el.to.opacity === 0 ) {
+ el.css( "opacity", el.from.opacity );
+ }
+ if( mode === "hide" ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ if ( !restore ) {
+
+ // we need to calculate our new positioning based on the scaling
+ if ( position === "static" ) {
+ el.css({
+ position: "relative",
+ top: el.to.top,
+ left: el.to.left
+ });
+ } else {
+ $.each([ "top", "left" ], function( idx, pos ) {
+ el.css( pos, function( _, str ) {
+ var val = parseInt( str, 10 ),
+ toRef = idx ? el.to.left : el.to.top;
+
+ // if original was "auto", recalculate the new value from wrapper
+ if ( str === "auto" ) {
+ return toRef + "px";
+ }
+
+ return val + toRef + "px";
+ });
+ });
+ }
+ }
+
+ $.effects.removeWrapper( el );
+ done();
+ }
+ });
+
+};
+
+})(jQuery);
+
+(function( $, undefined ) {
+
+$.effects.effect.shake = function( o, done ) {
+
+ var el = $( this ),
+ props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
+ mode = $.effects.setMode( el, o.mode || "effect" ),
+ direction = o.direction || "left",
+ distance = o.distance || 20,
+ times = o.times || 3,
+ anims = times * 2 + 1,
+ speed = Math.round(o.duration/anims),
+ ref = (direction === "up" || direction === "down") ? "top" : "left",
+ positiveMotion = (direction === "up" || direction === "left"),
+ animation = {},
+ animation1 = {},
+ animation2 = {},
+ i,
+
+ // we will need to re-assemble the queue to stack our animations in place
+ queue = el.queue(),
+ queuelen = queue.length;
+
+ $.effects.save( el, props );
+ el.show();
+ $.effects.createWrapper( el );
+
+ // Animation
+ animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
+ animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
+ animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
+
+ // Animate
+ el.animate( animation, speed, o.easing );
+
+ // Shakes
+ for ( i = 1; i < times; i++ ) {
+ el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
+ }
+ el
+ .animate( animation1, speed, o.easing )
+ .animate( animation, speed / 2, o.easing )
+ .queue(function() {
+ if ( mode === "hide" ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
+ done();
+ });
+
+ // inject all the animations we just queued to be first in line (after "inprogress")
+ if ( queuelen > 1) {
+ queue.splice.apply( queue,
+ [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
+ }
+ el.dequeue();
+
+};
+
+})(jQuery);
+
+(function( $, undefined ) {
+
+$.effects.effect.slide = function( o, done ) {
+
+ // Create element
+ var el = $( this ),
+ props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
+ mode = $.effects.setMode( el, o.mode || "show" ),
+ show = mode === "show",
+ direction = o.direction || "left",
+ ref = (direction === "up" || direction === "down") ? "top" : "left",
+ positiveMotion = (direction === "up" || direction === "left"),
+ distance,
+ animation = {};
+
+ // Adjust
+ $.effects.save( el, props );
+ el.show();
+ distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
+
+ $.effects.createWrapper( el ).css({
+ overflow: "hidden"
+ });
+
+ if ( show ) {
+ el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
+ }
+
+ // Animation
+ animation[ ref ] = ( show ?
+ ( positiveMotion ? "+=" : "-=") :
+ ( positiveMotion ? "-=" : "+=")) +
+ distance;
+
+ // Animate
+ el.animate( animation, {
+ queue: false,
+ duration: o.duration,
+ easing: o.easing,
+ complete: function() {
+ if ( mode === "hide" ) {
+ el.hide();
+ }
+ $.effects.restore( el, props );
+ $.effects.removeWrapper( el );
+ done();
+ }
+ });
+};
+
+})(jQuery);
+
+(function( $, undefined ) {
+
+$.effects.effect.transfer = function( o, done ) {
+ var elem = $( this ),
+ target = $( o.to ),
+ targetFixed = target.css( "position" ) === "fixed",
+ body = $("body"),
+ fixTop = targetFixed ? body.scrollTop() : 0,
+ fixLeft = targetFixed ? body.scrollLeft() : 0,
+ endPosition = target.offset(),
+ animation = {
+ top: endPosition.top - fixTop ,
+ left: endPosition.left - fixLeft ,
+ height: target.innerHeight(),
+ width: target.innerWidth()
+ },
+ startPosition = elem.offset(),
+ transfer = $( '<div class="ui-effects-transfer"></div>' )
+ .appendTo( document.body )
+ .addClass( o.className )
+ .css({
+ top: startPosition.top - fixTop ,
+ left: startPosition.left - fixLeft ,
+ height: elem.innerHeight(),
+ width: elem.innerWidth(),
+ position: targetFixed ? "fixed" : "absolute"
+ })
+ .animate( animation, o.duration, o.easing, function() {
+ transfer.remove();
+ done();
+ });
+};
+
+})(jQuery);
+
+(function( $, undefined ) {
+
+var mouseHandled = false;
+
+$.widget( "ui.menu", {
+ version: "1.9.2",
+ defaultElement: "<ul>",
+ delay: 300,
+ options: {
+ icons: {
+ submenu: "ui-icon-carat-1-e"
+ },
+ menus: "ul",
+ position: {
+ my: "left top",
+ at: "right top"
+ },
+ role: "menu",
+
+ // callbacks
+ blur: null,
+ focus: null,
+ select: null
+ },
+
+ _create: function() {
+ this.activeMenu = this.element;
+ this.element
+ .uniqueId()
+ .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
+ .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
+ .attr({
+ role: this.options.role,
+ tabIndex: 0
+ })
+ // need to catch all clicks on disabled menu
+ // not possible through _on
+ .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
+ if ( this.options.disabled ) {
+ event.preventDefault();
+ }
+ }, this ));
+
+ if ( this.options.disabled ) {
+ this.element
+ .addClass( "ui-state-disabled" )
+ .attr( "aria-disabled", "true" );
+ }
+
+ 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 ) {
+ event.preventDefault();
+ },
+ "click .ui-state-disabled > a": function( event ) {
+ event.preventDefault();
+ },
+ "click .ui-menu-item:has(a)": function( event ) {
+ var target = $( event.target ).closest( ".ui-menu-item" );
+ if ( !mouseHandled && target.not( ".ui-state-disabled" ).length ) {
+ mouseHandled = true;
+
+ this.select( event );
+ // Open submenu on click
+ if ( target.has( ".ui-menu" ).length ) {
+ this.expand( event );
+ } else if ( !this.element.is( ":focus" ) ) {
+ // Redirect focus to the menu
+ this.element.trigger( "focus", [ true ] );
+
+ // If the active item is on the top level, let it stay active.
+ // Otherwise, blur the active item since it is no longer visible.
+ if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
+ clearTimeout( this.timer );
+ }
+ }
+ }
+ },
+ "mouseenter .ui-menu-item": function( event ) {
+ var target = $( event.currentTarget );
+ // Remove ui-state-active class from siblings of the newly focused menu item
+ // to avoid a jump caused by adjacent elements both having a class with a border
+ target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
+ this.focus( event, target );
+ },
+ mouseleave: "collapseAll",
+ "mouseleave .ui-menu": "collapseAll",
+ focus: function( event, keepActiveItem ) {
+ // 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 );
+
+ if ( !keepActiveItem ) {
+ this.focus( event, item );
+ }
+ },
+ blur: function( event ) {
+ this._delay(function() {
+ if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
+ this.collapseAll( event );
+ }
+ });
+ },
+ keydown: "_keydown"
+ });
+
+ this.refresh();
+
+ // 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 );
+ }
+
+ // Reset the mouseHandled flag
+ mouseHandled = false;
+ }
+ });
+ },
+
+ _destroy: function() {
+ // Destroy (sub)menus
+ this.element
+ .removeAttr( "aria-activedescendant" )
+ .find( ".ui-menu" ).andSelf()
+ .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
+ .removeAttr( "role" )
+ .removeAttr( "tabIndex" )
+ .removeAttr( "aria-labelledby" )
+ .removeAttr( "aria-expanded" )
+ .removeAttr( "aria-hidden" )
+ .removeAttr( "aria-disabled" )
+ .removeUniqueId()
+ .show();
+
+ // Destroy menu items
+ this.element.find( ".ui-menu-item" )
+ .removeClass( "ui-menu-item" )
+ .removeAttr( "role" )
+ .removeAttr( "aria-disabled" )
+ .children( "a" )
+ .removeUniqueId()
+ .removeClass( "ui-corner-all ui-state-hover" )
+ .removeAttr( "tabIndex" )
+ .removeAttr( "role" )
+ .removeAttr( "aria-haspopup" )
+ .children().each( function() {
+ var elem = $( this );
+ if ( elem.data( "ui-menu-submenu-carat" ) ) {
+ elem.remove();
+ }
+ });
+
+ // Destroy menu dividers
+ this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
+ },
+
+ _keydown: function( event ) {
+ var match, prev, character, skip, regex,
+ preventDefault = true;
+
+ function escape( value ) {
+ return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
+ }
+
+ switch ( event.keyCode ) {
+ case $.ui.keyCode.PAGE_UP:
+ this.previousPage( event );
+ break;
+ case $.ui.keyCode.PAGE_DOWN:
+ this.nextPage( event );
+ break;
+ case $.ui.keyCode.HOME:
+ this._move( "first", "first", event );
+ break;
+ case $.ui.keyCode.END:
+ this._move( "last", "last", event );
+ break;
+ case $.ui.keyCode.UP:
+ this.previous( event );
+ break;
+ case $.ui.keyCode.DOWN:
+ this.next( event );
+ break;
+ case $.ui.keyCode.LEFT:
+ this.collapse( event );
+ break;
+ case $.ui.keyCode.RIGHT:
+ if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
+ this.expand( event );
+ }
+ break;
+ case $.ui.keyCode.ENTER:
+ case $.ui.keyCode.SPACE:
+ this._activate( event );
+ break;
+ case $.ui.keyCode.ESCAPE:
+ this.collapse( event );
+ break;
+ default:
+ preventDefault = false;
+ prev = this.previousFilter || "";
+ character = String.fromCharCode( event.keyCode );
+ skip = false;
+
+ clearTimeout( this.filterTimer );
+
+ if ( character === prev ) {
+ skip = true;
+ } else {
+ character = prev + character;
+ }
+
+ regex = new RegExp( "^" + escape( character ), "i" );
+ match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
+ return regex.test( $( this ).children( "a" ).text() );
+ });
+ match = skip && match.index( this.active.next() ) !== -1 ?
+ this.active.nextAll( ".ui-menu-item" ) :
+ match;
+
+ // 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 regex.test( $( this ).children( "a" ).text() );
+ });
+ }
+
+ if ( match.length ) {
+ this.focus( event, match );
+ if ( match.length > 1 ) {
+ this.previousFilter = character;
+ this.filterTimer = this._delay(function() {
+ delete this.previousFilter;
+ }, 1000 );
+ } else {
+ delete this.previousFilter;
+ }
+ } else {
+ delete this.previousFilter;
+ }
+ }
+
+ if ( preventDefault ) {
+ event.preventDefault();
+ }
+ },
+
+ _activate: function( event ) {
+ if ( !this.active.is( ".ui-state-disabled" ) ) {
+ if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
+ this.expand( event );
+ } else {
+ this.select( event );
+ }
+ }
+ },
+
+ refresh: function() {
+ var menus,
+ icon = this.options.icons.submenu,
+ submenus = this.element.find( this.options.menus );
+
+ // Initialize nested menus
+ submenus.filter( ":not(.ui-menu)" )
+ .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
+ .hide()
+ .attr({
+ role: this.options.role,
+ "aria-hidden": "true",
+ "aria-expanded": "false"
+ })
+ .each(function() {
+ var menu = $( this ),
+ 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( submenuCarat );
+ menu.attr( "aria-labelledby", item.attr( "id" ) );
+ });
+
+ menus = submenus.add( this.element );
+
+ // Don't refresh list items that are already adapted
+ menus.children( ":not(.ui-menu-item):has(a)" )
+ .addClass( "ui-menu-item" )
+ .attr( "role", "presentation" )
+ .children( "a" )
+ .uniqueId()
+ .addClass( "ui-corner-all" )
+ .attr({
+ tabIndex: -1,
+ role: this._itemRole()
+ });
+
+ // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
+ menus.children( ":not(.ui-menu-item)" ).each(function() {
+ var item = $( this );
+ // 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
+ menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
+
+ // If the active item has been removed, blur the menu
+ if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
+ this.blur();
+ }
+ },
+
+ _itemRole: function() {
+ return {
+ menu: "menuitem",
+ listbox: "option"
+ }[ this.options.role ];
+ },
+
+ focus: function( event, item ) {
+ var nested, focused;
+ this.blur( event, event && event.type === "focus" );
+
+ this._scrollIntoView( item );
+
+ this.active = item.first();
+ focused = this.active.children( "a" ).addClass( "ui-state-focus" );
+ // 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
+ this.active
+ .parent()
+ .closest( ".ui-menu-item" )
+ .children( "a:first" )
+ .addClass( "ui-state-active" );
+
+ if ( event && event.type === "keydown" ) {
+ this._close();
+ } else {
+ this.timer = this._delay(function() {
+ this._close();
+ }, this.delay );
+ }
+
+ nested = item.children( ".ui-menu" );
+ if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
+ this._startOpening(nested);
+ }
+ this.activeMenu = item.parent();
+
+ this._trigger( "focus", event, { item: item } );
+ },
+
+ _scrollIntoView: function( item ) {
+ var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
+ if ( this._hasScroll() ) {
+ borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
+ paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
+ offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
+ scroll = this.activeMenu.scrollTop();
+ elementHeight = this.activeMenu.height();
+ itemHeight = item.height();
+
+ if ( offset < 0 ) {
+ this.activeMenu.scrollTop( scroll + offset );
+ } else if ( offset + itemHeight > elementHeight ) {
+ this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
+ }
+ }
+ },
+
+ blur: function( event, fromFocus ) {
+ if ( !fromFocus ) {
+ clearTimeout( this.timer );
+ }
+
+ if ( !this.active ) {
+ return;
+ }
+
+ this.active.children( "a" ).removeClass( "ui-state-focus" );
+ this.active = null;
+
+ this._trigger( "blur", event, { item: this.active } );
+ },
+
+ _startOpening: function( submenu ) {
+ clearTimeout( this.timer );
+
+ // Don't open if already open fixes a Firefox bug that caused a .5 pixel
+ // shift in the submenu position when mousing over the carat icon
+ if ( submenu.attr( "aria-hidden" ) !== "true" ) {
+ return;
+ }
+
+ this.timer = this._delay(function() {
+ this._close();
+ this._open( submenu );
+ }, this.delay );
+ },
+
+ _open: function( submenu ) {
+ var position = $.extend({
+ of: this.active
+ }, this.options.position );
+
+ clearTimeout( this.timer );
+ this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
+ .hide()
+ .attr( "aria-hidden", "true" );
+
+ submenu
+ .show()
+ .removeAttr( "aria-hidden" )
+ .attr( "aria-expanded", "true" )
+ .position( position );
+ },
+
+ 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
+ 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 ( !currentMenu.length ) {
+ currentMenu = this.element;
+ }
+
+ this._close( currentMenu );
+
+ this.blur( event );
+ this.activeMenu = currentMenu;
+ }, this.delay );
+ },
+
+ // With no arguments, closes the currently active menu - if nothing is active
+ // it closes all menus. If passed an argument, it will search for menus BELOW
+ _close: function( startMenu ) {
+ if ( !startMenu ) {
+ startMenu = this.active ? this.active.parent() : this.element;
+ }
+
+ startMenu
+ .find( ".ui-menu" )
+ .hide()
+ .attr( "aria-hidden", "true" )
+ .attr( "aria-expanded", "false" )
+ .end()
+ .find( "a.ui-state-active" )
+ .removeClass( "ui-state-active" );
+ },
+
+ collapse: function( event ) {
+ var newItem = this.active &&
+ this.active.parent().closest( ".ui-menu-item", this.element );
+ if ( newItem && newItem.length ) {
+ this._close();
+ this.focus( event, newItem );
+ }
+ },
+
+ expand: function( event ) {
+ var newItem = this.active &&
+ this.active
+ .children( ".ui-menu " )
+ .children( ".ui-menu-item" )
+ .first();
+
+ if ( newItem && newItem.length ) {
+ this._open( newItem.parent() );
+
+ // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
+ this._delay(function() {
+ this.focus( event, newItem );
+ });
+ }
+ },
+
+ next: function( event ) {
+ this._move( "next", "first", event );
+ },
+
+ previous: function( event ) {
+ this._move( "prev", "last", event );
+ },
+
+ isFirstItem: function() {
+ return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
+ },
+
+ isLastItem: function() {
+ return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
+ },
+
+ _move: function( direction, filter, event ) {
+ var next;
+ if ( this.active ) {
+ if ( direction === "first" || direction === "last" ) {
+ next = this.active
+ [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
+ .eq( -1 );
+ } else {
+ next = this.active
+ [ direction + "All" ]( ".ui-menu-item" )
+ .eq( 0 );
+ }
+ }
+ if ( !next || !next.length || !this.active ) {
+ next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
+ }
+
+ this.focus( event, next );
+ },
+
+ nextPage: function( event ) {
+ var item, base, height;
+
+ if ( !this.active ) {
+ this.next( event );
+ return;
+ }
+ if ( this.isLastItem() ) {
+ return;
+ }
+ if ( this._hasScroll() ) {
+ base = this.active.offset().top;
+ height = this.element.height();
+ this.active.nextAll( ".ui-menu-item" ).each(function() {
+ item = $( this );
+ return item.offset().top - base - height < 0;
+ });
+
+ this.focus( event, item );
+ } else {
+ this.focus( event, this.activeMenu.children( ".ui-menu-item" )
+ [ !this.active ? "first" : "last" ]() );
+ }
+ },
+
+ previousPage: function( event ) {
+ var item, base, height;
+ if ( !this.active ) {
+ this.next( event );
+ return;
+ }
+ if ( this.isFirstItem() ) {
+ return;
+ }
+ if ( this._hasScroll() ) {
+ base = this.active.offset().top;
+ height = this.element.height();
+ this.active.prevAll( ".ui-menu-item" ).each(function() {
+ item = $( this );
+ return item.offset().top - base + height > 0;
+ });
+
+ this.focus( event, item );
+ } else {
+ this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
+ }
+ },
+
+ _hasScroll: function() {
+ return this.element.outerHeight() < this.element.prop( "scrollHeight" );
+ },
+
+ select: function( event ) {
+ // TODO: It should never be possible to not have an active item at this
+ // point, but the tests don't trigger mouseenter before click.
+ this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
+ var ui = { item: this.active };
+ if ( !this.active.has( ".ui-menu" ).length ) {
+ this.collapseAll( event, true );
+ }
+ this._trigger( "select", event, ui );
+ }
+});
+
+}( jQuery ));
+
(function( $, undefined ) {
$.ui = $.ui || {};
-var horizontalPositions = /left|center|right/,
- verticalPositions = /top|center|bottom/,
- center = "center",
- _position = $.fn.position,
- _offset = $.fn.offset;
+var cachedScrollbarWidth,
+ max = Math.max,
+ abs = Math.abs,
+ round = Math.round,
+ rhorizontal = /left|center|right/,
+ rvertical = /top|center|bottom/,
+ roffset = /[\+\-]\d+%?/,
+ rposition = /^\w+/,
+ rpercent = /%$/,
+ _position = $.fn.position;
+
+function getOffsets( offsets, width, height ) {
+ return [
+ parseInt( offsets[ 0 ], 10 ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
+ parseInt( offsets[ 1 ], 10 ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
+ ];
+}
+function parseCss( element, property ) {
+ return parseInt( $.css( element, property ), 10 ) || 0;
+}
+
+$.position = {
+ scrollbarWidth: function() {
+ if ( cachedScrollbarWidth !== undefined ) {
+ return cachedScrollbarWidth;
+ }
+ var w1, w2,
+ div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
+ innerDiv = div.children()[0];
+
+ $( "body" ).append( div );
+ w1 = innerDiv.offsetWidth;
+ div.css( "overflow", "scroll" );
+
+ w2 = innerDiv.offsetWidth;
+
+ if ( w1 === w2 ) {
+ w2 = div[0].clientWidth;
+ }
+
+ div.remove();
+
+ return (cachedScrollbarWidth = w1 - w2);
+ },
+ getScrollInfo: function( within ) {
+ var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
+ overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
+ hasOverflowX = overflowX === "scroll" ||
+ ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
+ hasOverflowY = overflowY === "scroll" ||
+ ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
+ return {
+ width: hasOverflowX ? $.position.scrollbarWidth() : 0,
+ height: hasOverflowY ? $.position.scrollbarWidth() : 0
+ };
+ },
+ getWithinInfo: function( element ) {
+ var withinElement = $( element || window ),
+ isWindow = $.isWindow( withinElement[0] );
+ return {
+ element: withinElement,
+ isWindow: isWindow,
+ offset: withinElement.offset() || { left: 0, top: 0 },
+ scrollLeft: withinElement.scrollLeft(),
+ scrollTop: withinElement.scrollTop(),
+ width: isWindow ? withinElement.width() : withinElement.outerWidth(),
+ height: isWindow ? withinElement.height() : withinElement.outerHeight()
+ };
+ }
+};
$.fn.position = function( options ) {
if ( !options || !options.of ) {
@@ -10007,48 +11563,65 @@ $.fn.position = function( options ) {
// make a copy, we don't want to modify arguments
options = $.extend( {}, options );
- var target = $( options.of ),
+ var atOffset, targetWidth, targetHeight, targetOffset, basePosition,
+ target = $( options.of ),
+ within = $.position.getWithinInfo( options.within ),
+ scrollInfo = $.position.getScrollInfo( within ),
targetElem = target[0],
collision = ( options.collision || "flip" ).split( " " ),
- offset = options.offset ? options.offset.split( " " ) : [ 0, 0 ],
- targetWidth,
- targetHeight,
- basePosition;
+ offsets = {};
if ( targetElem.nodeType === 9 ) {
targetWidth = target.width();
targetHeight = target.height();
- basePosition = { top: 0, left: 0 };
- // TODO: use $.isWindow() in 1.9
- } else if ( targetElem.setTimeout ) {
+ targetOffset = { top: 0, left: 0 };
+ } else if ( $.isWindow( targetElem ) ) {
targetWidth = target.width();
targetHeight = target.height();
- basePosition = { top: target.scrollTop(), left: target.scrollLeft() };
+ targetOffset = { top: target.scrollTop(), left: target.scrollLeft() };
} else if ( targetElem.preventDefault ) {
// force left top to allow flipping
options.at = "left top";
targetWidth = targetHeight = 0;
- basePosition = { top: options.of.pageY, left: options.of.pageX };
+ targetOffset = { top: targetElem.pageY, left: targetElem.pageX };
} else {
targetWidth = target.outerWidth();
targetHeight = target.outerHeight();
- basePosition = target.offset();
+ targetOffset = target.offset();
}
+ // clone to reuse original targetOffset later
+ basePosition = $.extend( {}, targetOffset );
- // force my and at to have valid horizontal and veritcal positions
- // if a value is missing or invalid, it will be converted to center
+ // force my and at to have valid horizontal and vertical positions
+ // if a value is missing or invalid, it will be converted to center
$.each( [ "my", "at" ], function() {
- var pos = ( options[this] || "" ).split( " " );
+ var pos = ( options[ this ] || "" ).split( " " ),
+ horizontalOffset,
+ verticalOffset;
+
if ( pos.length === 1) {
- pos = horizontalPositions.test( pos[0] ) ?
- pos.concat( [center] ) :
- verticalPositions.test( pos[0] ) ?
- [ center ].concat( pos ) :
- [ center, center ];
- }
- pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : center;
- pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : center;
- options[ this ] = pos;
+ pos = rhorizontal.test( pos[ 0 ] ) ?
+ pos.concat( [ "center" ] ) :
+ rvertical.test( pos[ 0 ] ) ?
+ [ "center" ].concat( pos ) :
+ [ "center", "center" ];
+ }
+ pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
+ pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
+
+ // calculate offsets
+ horizontalOffset = roffset.exec( pos[ 0 ] );
+ verticalOffset = roffset.exec( pos[ 1 ] );
+ offsets[ this ] = [
+ horizontalOffset ? horizontalOffset[ 0 ] : 0,
+ verticalOffset ? verticalOffset[ 0 ] : 0
+ ];
+
+ // reduce to just the positions without the offsets
+ options[ this ] = [
+ rposition.exec( pos[ 0 ] )[ 0 ],
+ rposition.exec( pos[ 1 ] )[ 0 ]
+ ];
});
// normalize collision option
@@ -10056,65 +11629,63 @@ $.fn.position = function( options ) {
collision[ 1 ] = collision[ 0 ];
}
- // normalize offset option
- offset[ 0 ] = parseInt( offset[0], 10 ) || 0;
- if ( offset.length === 1 ) {
- offset[ 1 ] = offset[ 0 ];
- }
- offset[ 1 ] = parseInt( offset[1], 10 ) || 0;
-
- if ( options.at[0] === "right" ) {
+ if ( options.at[ 0 ] === "right" ) {
basePosition.left += targetWidth;
- } else if ( options.at[0] === center ) {
+ } else if ( options.at[ 0 ] === "center" ) {
basePosition.left += targetWidth / 2;
}
- if ( options.at[1] === "bottom" ) {
+ if ( options.at[ 1 ] === "bottom" ) {
basePosition.top += targetHeight;
- } else if ( options.at[1] === center ) {
+ } else if ( options.at[ 1 ] === "center" ) {
basePosition.top += targetHeight / 2;
}
- basePosition.left += offset[ 0 ];
- basePosition.top += offset[ 1 ];
+ atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
+ basePosition.left += atOffset[ 0 ];
+ basePosition.top += atOffset[ 1 ];
return this.each(function() {
- var elem = $( this ),
+ var collisionPosition, using,
+ elem = $( this ),
elemWidth = elem.outerWidth(),
elemHeight = elem.outerHeight(),
- marginLeft = parseInt( $.curCSS( this, "marginLeft", true ) ) || 0,
- marginTop = parseInt( $.curCSS( this, "marginTop", true ) ) || 0,
- collisionWidth = elemWidth + marginLeft +
- ( parseInt( $.curCSS( this, "marginRight", true ) ) || 0 ),
- collisionHeight = elemHeight + marginTop +
- ( parseInt( $.curCSS( this, "marginBottom", true ) ) || 0 ),
+ marginLeft = parseCss( this, "marginLeft" ),
+ marginTop = parseCss( this, "marginTop" ),
+ collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
+ collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
position = $.extend( {}, basePosition ),
- collisionPosition;
+ myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
- if ( options.my[0] === "right" ) {
+ if ( options.my[ 0 ] === "right" ) {
position.left -= elemWidth;
- } else if ( options.my[0] === center ) {
+ } else if ( options.my[ 0 ] === "center" ) {
position.left -= elemWidth / 2;
}
- if ( options.my[1] === "bottom" ) {
+ if ( options.my[ 1 ] === "bottom" ) {
position.top -= elemHeight;
- } else if ( options.my[1] === center ) {
+ } else if ( options.my[ 1 ] === "center" ) {
position.top -= elemHeight / 2;
}
- // prevent fractions (see #5280)
- position.left = Math.round( position.left );
- position.top = Math.round( position.top );
+ position.left += myOffset[ 0 ];
+ position.top += myOffset[ 1 ];
+
+ // if the browser doesn't support fractions, then round for consistent results
+ if ( !$.support.offsetFractions ) {
+ position.left = round( position.left );
+ position.top = round( position.top );
+ }
collisionPosition = {
- left: position.left - marginLeft,
- top: position.top - marginTop
+ marginLeft: marginLeft,
+ marginTop: marginTop
};
$.each( [ "left", "top" ], function( i, dir ) {
- if ( $.ui.position[ collision[i] ] ) {
- $.ui.position[ collision[i] ][ dir ]( position, {
+ if ( $.ui.position[ collision[ i ] ] ) {
+ $.ui.position[ collision[ i ] ][ dir ]( position, {
targetWidth: targetWidth,
targetHeight: targetHeight,
elemWidth: elemWidth,
@@ -10122,9 +11693,11 @@ $.fn.position = function( options ) {
collisionPosition: collisionPosition,
collisionWidth: collisionWidth,
collisionHeight: collisionHeight,
- offset: offset,
+ offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
my: options.my,
- at: options.at
+ at: options.at,
+ within: within,
+ elem : elem
});
}
});
@@ -10132,31 +11705,137 @@ $.fn.position = function( options ) {
if ( $.fn.bgiframe ) {
elem.bgiframe();
}
- elem.offset( $.extend( position, { using: options.using } ) );
+
+ if ( options.using ) {
+ // adds feedback as second argument to using callback, if present
+ using = function( props ) {
+ var left = targetOffset.left - position.left,
+ right = left + targetWidth - elemWidth,
+ top = targetOffset.top - position.top,
+ bottom = top + targetHeight - elemHeight,
+ feedback = {
+ target: {
+ element: target,
+ left: targetOffset.left,
+ top: targetOffset.top,
+ width: targetWidth,
+ height: targetHeight
+ },
+ element: {
+ element: elem,
+ left: position.left,
+ top: position.top,
+ width: elemWidth,
+ height: elemHeight
+ },
+ horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
+ vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
+ };
+ if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
+ feedback.horizontal = "center";
+ }
+ if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
+ feedback.vertical = "middle";
+ }
+ if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
+ feedback.important = "horizontal";
+ } else {
+ feedback.important = "vertical";
+ }
+ options.using.call( this, props, feedback );
+ };
+ }
+
+ elem.offset( $.extend( position, { using: using } ) );
});
};
$.ui.position = {
fit: {
left: function( position, data ) {
- var win = $( window ),
- over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft();
- position.left = over > 0 ? position.left - over : Math.max( position.left - data.collisionPosition.left, position.left );
+ var within = data.within,
+ withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
+ outerWidth = within.width,
+ collisionPosLeft = position.left - data.collisionPosition.marginLeft,
+ overLeft = withinOffset - collisionPosLeft,
+ overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
+ newOverRight;
+
+ // element is wider than within
+ if ( data.collisionWidth > outerWidth ) {
+ // element is initially over the left side of within
+ if ( overLeft > 0 && overRight <= 0 ) {
+ newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
+ position.left += overLeft - newOverRight;
+ // element is initially over right side of within
+ } else if ( overRight > 0 && overLeft <= 0 ) {
+ position.left = withinOffset;
+ // element is initially over both left and right sides of within
+ } else {
+ if ( overLeft > overRight ) {
+ position.left = withinOffset + outerWidth - data.collisionWidth;
+ } else {
+ position.left = withinOffset;
+ }
+ }
+ // too far left -> align with left edge
+ } else if ( overLeft > 0 ) {
+ position.left += overLeft;
+ // too far right -> align with right edge
+ } else if ( overRight > 0 ) {
+ position.left -= overRight;
+ // adjust based on position and margin
+ } else {
+ position.left = max( position.left - collisionPosLeft, position.left );
+ }
},
top: function( position, data ) {
- var win = $( window ),
- over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop();
- position.top = over > 0 ? position.top - over : Math.max( position.top - data.collisionPosition.top, position.top );
+ var within = data.within,
+ withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
+ outerHeight = data.within.height,
+ collisionPosTop = position.top - data.collisionPosition.marginTop,
+ overTop = withinOffset - collisionPosTop,
+ overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
+ newOverBottom;
+
+ // element is taller than within
+ if ( data.collisionHeight > outerHeight ) {
+ // element is initially over the top of within
+ if ( overTop > 0 && overBottom <= 0 ) {
+ newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
+ position.top += overTop - newOverBottom;
+ // element is initially over bottom of within
+ } else if ( overBottom > 0 && overTop <= 0 ) {
+ position.top = withinOffset;
+ // element is initially over both top and bottom of within
+ } else {
+ if ( overTop > overBottom ) {
+ position.top = withinOffset + outerHeight - data.collisionHeight;
+ } else {
+ position.top = withinOffset;
+ }
+ }
+ // too far up -> align with top
+ } else if ( overTop > 0 ) {
+ position.top += overTop;
+ // too far down -> align with bottom edge
+ } else if ( overBottom > 0 ) {
+ position.top -= overBottom;
+ // adjust based on position and margin
+ } else {
+ position.top = max( position.top - collisionPosTop, position.top );
+ }
}
},
-
flip: {
left: function( position, data ) {
- if ( data.at[0] === center ) {
- return;
- }
- var win = $( window ),
- over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(),
+ var within = data.within,
+ withinOffset = within.offset.left + within.scrollLeft,
+ outerWidth = within.width,
+ offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
+ collisionPosLeft = position.left - data.collisionPosition.marginLeft,
+ overLeft = collisionPosLeft - offsetLeft,
+ overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
myOffset = data.my[ 0 ] === "left" ?
-data.elemWidth :
data.my[ 0 ] === "right" ?
@@ -10164,90 +11843,155 @@ $.ui.position = {
0,
atOffset = data.at[ 0 ] === "left" ?
data.targetWidth :
- -data.targetWidth,
- offset = -2 * data.offset[ 0 ];
- position.left += data.collisionPosition.left < 0 ?
- myOffset + atOffset + offset :
- over > 0 ?
- myOffset + atOffset + offset :
- 0;
+ data.at[ 0 ] === "right" ?
+ -data.targetWidth :
+ 0,
+ offset = -2 * data.offset[ 0 ],
+ newOverRight,
+ newOverLeft;
+
+ if ( overLeft < 0 ) {
+ newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
+ if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
+ position.left += myOffset + atOffset + offset;
+ }
+ }
+ else if ( overRight > 0 ) {
+ newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
+ if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
+ position.left += myOffset + atOffset + offset;
+ }
+ }
},
top: function( position, data ) {
- if ( data.at[1] === center ) {
- return;
- }
- var win = $( window ),
- over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(),
- myOffset = data.my[ 1 ] === "top" ?
+ var within = data.within,
+ withinOffset = within.offset.top + within.scrollTop,
+ outerHeight = within.height,
+ offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
+ collisionPosTop = position.top - data.collisionPosition.marginTop,
+ overTop = collisionPosTop - offsetTop,
+ overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
+ top = data.my[ 1 ] === "top",
+ myOffset = top ?
-data.elemHeight :
data.my[ 1 ] === "bottom" ?
data.elemHeight :
0,
atOffset = data.at[ 1 ] === "top" ?
data.targetHeight :
- -data.targetHeight,
- offset = -2 * data.offset[ 1 ];
- position.top += data.collisionPosition.top < 0 ?
- myOffset + atOffset + offset :
- over > 0 ?
- myOffset + atOffset + offset :
- 0;
+ data.at[ 1 ] === "bottom" ?
+ -data.targetHeight :
+ 0,
+ offset = -2 * data.offset[ 1 ],
+ newOverTop,
+ newOverBottom;
+ if ( overTop < 0 ) {
+ newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
+ if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
+ position.top += myOffset + atOffset + offset;
+ }
+ }
+ else if ( overBottom > 0 ) {
+ newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
+ if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
+ position.top += myOffset + atOffset + offset;
+ }
+ }
+ }
+ },
+ flipfit: {
+ left: function() {
+ $.ui.position.flip.left.apply( this, arguments );
+ $.ui.position.fit.left.apply( this, arguments );
+ },
+ top: function() {
+ $.ui.position.flip.top.apply( this, arguments );
+ $.ui.position.fit.top.apply( this, arguments );
}
}
};
-// offset setter from jQuery 1.4
-if ( !$.offset.setOffset ) {
- $.offset.setOffset = function( elem, options ) {
- // set position first, in-case top/left are set even on static elem
- if ( /static/.test( $.curCSS( elem, "position" ) ) ) {
- elem.style.position = "relative";
- }
- var curElem = $( elem ),
- curOffset = curElem.offset(),
- curTop = parseInt( $.curCSS( elem, "top", true ), 10 ) || 0,
- curLeft = parseInt( $.curCSS( elem, "left", true ), 10) || 0,
- props = {
- top: (options.top - curOffset.top) + curTop,
- left: (options.left - curOffset.left) + curLeft
- };
-
- if ( 'using' in options ) {
- options.using.call( elem, props );
- } else {
- curElem.css( props );
- }
- };
-
- $.fn.offset = function( options ) {
- var elem = this[ 0 ];
- if ( !elem || !elem.ownerDocument ) { return null; }
- if ( options ) {
- return this.each(function() {
- $.offset.setOffset( this, options );
- });
- }
- return _offset.call( this );
+// fraction support test
+(function () {
+ var testElement, testElementParent, testElementStyle, offsetLeft, i,
+ body = document.getElementsByTagName( "body" )[ 0 ],
+ div = document.createElement( "div" );
+
+ //Create a "fake body" for testing based on method used in jQuery.support
+ testElement = document.createElement( body ? "div" : "body" );
+ testElementStyle = {
+ visibility: "hidden",
+ width: 0,
+ height: 0,
+ border: 0,
+ margin: 0,
+ background: "none"
};
+ if ( body ) {
+ $.extend( testElementStyle, {
+ position: "absolute",
+ left: "-1000px",
+ top: "-1000px"
+ });
+ }
+ for ( i in testElementStyle ) {
+ testElement.style[ i ] = testElementStyle[ i ];
+ }
+ testElement.appendChild( div );
+ testElementParent = body || document.documentElement;
+ testElementParent.insertBefore( testElement, testElementParent.firstChild );
+
+ div.style.cssText = "position: absolute; left: 10.7432222px;";
+
+ offsetLeft = $( div ).offset().left;
+ $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
+
+ testElement.innerHTML = "";
+ testElementParent.removeChild( testElement );
+})();
+
+// DEPRECATED
+if ( $.uiBackCompat !== false ) {
+ // offset option
+ (function( $ ) {
+ var _position = $.fn.position;
+ $.fn.position = function( options ) {
+ if ( !options || !options.offset ) {
+ return _position.call( this, options );
+ }
+ var offset = options.offset.split( " " ),
+ at = options.at.split( " " );
+ if ( offset.length === 1 ) {
+ offset[ 1 ] = offset[ 0 ];
+ }
+ if ( /^\d/.test( offset[ 0 ] ) ) {
+ offset[ 0 ] = "+" + offset[ 0 ];
+ }
+ if ( /^\d/.test( offset[ 1 ] ) ) {
+ offset[ 1 ] = "+" + offset[ 1 ];
+ }
+ if ( at.length === 1 ) {
+ if ( /left|center|right/.test( at[ 0 ] ) ) {
+ at[ 1 ] = "center";
+ } else {
+ at[ 1 ] = at[ 0 ];
+ at[ 0 ] = "center";
+ }
+ }
+ return _position.call( this, $.extend( options, {
+ at: at[ 0 ] + offset[ 0 ] + " " + at[ 1 ] + offset[ 1 ],
+ offset: undefined
+ } ) );
+ };
+ }( jQuery ) );
}
-}( jQuery ));
-/*
- * jQuery UI Progressbar 1.8.16
- *
- * Copyright 2011, 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/Progressbar
- *
- * Depends:
- * jquery.ui.core.js
- * jquery.ui.widget.js
- */
+}( jQuery ) );
+
(function( $, undefined ) {
$.widget( "ui.progressbar", {
+ version: "1.9.2",
options: {
value: 0,
max: 100
@@ -10272,7 +12016,7 @@ $.widget( "ui.progressbar", {
this._refreshValue();
},
- destroy: function() {
+ _destroy: function() {
this.element
.removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
.removeAttr( "role" )
@@ -10281,8 +12025,6 @@ $.widget( "ui.progressbar", {
.removeAttr( "aria-valuenow" );
this.valueDiv.remove();
-
- $.Widget.prototype.destroy.apply( this, arguments );
},
value: function( newValue ) {
@@ -10303,7 +12045,7 @@ $.widget( "ui.progressbar", {
}
}
- $.Widget.prototype._setOption.apply( this, arguments );
+ this._super( key, value );
},
_value: function() {
@@ -10320,8 +12062,8 @@ $.widget( "ui.progressbar", {
},
_refreshValue: function() {
- var value = this.value();
- var percentage = this._percentage();
+ var value = this.value(),
+ percentage = this._percentage();
if ( this.oldValue !== value ) {
this.oldValue = value;
@@ -10336,25 +12078,8 @@ $.widget( "ui.progressbar", {
}
});
-$.extend( $.ui.progressbar, {
- version: "1.8.16"
-});
-
})( jQuery );
-/*
- * jQuery UI Slider 1.8.16
- *
- * Copyright 2011, 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/Slider
- *
- * Depends:
- * jquery.ui.core.js
- * jquery.ui.mouse.js
- * jquery.ui.widget.js
- */
+
(function( $, undefined ) {
// number of pages in a slider
@@ -10362,7 +12087,7 @@ $.extend( $.ui.progressbar, {
var numPages = 5;
$.widget( "ui.slider", $.ui.mouse, {
-
+ version: "1.9.2",
widgetEventPrefix: "slide",
options: {
@@ -10378,11 +12103,10 @@ $.widget( "ui.slider", $.ui.mouse, {
},
_create: function() {
- var self = this,
+ var i, handleCount,
o = this.options,
existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
- handleCount = ( o.values && o.values.length ) || 1,
handles = [];
this._keySliding = false;
@@ -10417,15 +12141,17 @@ $.widget( "ui.slider", $.ui.mouse, {
.addClass( "ui-slider-range" +
// note: this isn't the most fittingly semantic framework class for this element,
// but worked best visually with a variety of themes
- " ui-widget-header" +
+ " ui-widget-header" +
( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) );
}
- for ( var i = existingHandles.length; i < handleCount; i += 1 ) {
+ handleCount = ( o.values && o.values.length ) || 1;
+
+ for ( i = existingHandles.length; i < handleCount; i++ ) {
handles.push( handle );
}
- this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( self.element ) );
+ this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
this.handle = this.handles.eq( 0 );
@@ -10433,11 +12159,12 @@ $.widget( "ui.slider", $.ui.mouse, {
.click(function( event ) {
event.preventDefault();
})
- .hover(function() {
+ .mouseenter(function() {
if ( !o.disabled ) {
$( this ).addClass( "ui-state-hover" );
}
- }, function() {
+ })
+ .mouseleave(function() {
$( this ).removeClass( "ui-state-hover" );
})
.focus(function() {
@@ -10453,22 +12180,14 @@ $.widget( "ui.slider", $.ui.mouse, {
});
this.handles.each(function( i ) {
- $( this ).data( "index.ui-slider-handle", i );
+ $( this ).data( "ui-slider-handle-index", i );
});
- this.handles
- .keydown(function( event ) {
- var ret = true,
- index = $( this ).data( "index.ui-slider-handle" ),
- allowed,
- curVal,
- newVal,
- step;
-
- if ( self.options.disabled ) {
- return;
- }
-
+ this._on( this.handles, {
+ keydown: function( event ) {
+ var allowed, curVal, newVal, step,
+ index = $( event.target ).data( "ui-slider-handle-index" );
+
switch ( event.keyCode ) {
case $.ui.keyCode.HOME:
case $.ui.keyCode.END:
@@ -10478,77 +12197,74 @@ $.widget( "ui.slider", $.ui.mouse, {
case $.ui.keyCode.RIGHT:
case $.ui.keyCode.DOWN:
case $.ui.keyCode.LEFT:
- ret = false;
- if ( !self._keySliding ) {
- self._keySliding = true;
- $( this ).addClass( "ui-state-active" );
- allowed = self._start( event, index );
+ event.preventDefault();
+ if ( !this._keySliding ) {
+ this._keySliding = true;
+ $( event.target ).addClass( "ui-state-active" );
+ allowed = this._start( event, index );
if ( allowed === false ) {
return;
}
}
break;
}
-
- step = self.options.step;
- if ( self.options.values && self.options.values.length ) {
- curVal = newVal = self.values( index );
+
+ step = this.options.step;
+ if ( this.options.values && this.options.values.length ) {
+ curVal = newVal = this.values( index );
} else {
- curVal = newVal = self.value();
+ curVal = newVal = this.value();
}
-
+
switch ( event.keyCode ) {
case $.ui.keyCode.HOME:
- newVal = self._valueMin();
+ newVal = this._valueMin();
break;
case $.ui.keyCode.END:
- newVal = self._valueMax();
+ newVal = this._valueMax();
break;
case $.ui.keyCode.PAGE_UP:
- newVal = self._trimAlignValue( curVal + ( (self._valueMax() - self._valueMin()) / numPages ) );
+ newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
break;
case $.ui.keyCode.PAGE_DOWN:
- newVal = self._trimAlignValue( curVal - ( (self._valueMax() - self._valueMin()) / numPages ) );
+ newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
break;
case $.ui.keyCode.UP:
case $.ui.keyCode.RIGHT:
- if ( curVal === self._valueMax() ) {
+ if ( curVal === this._valueMax() ) {
return;
}
- newVal = self._trimAlignValue( curVal + step );
+ newVal = this._trimAlignValue( curVal + step );
break;
case $.ui.keyCode.DOWN:
case $.ui.keyCode.LEFT:
- if ( curVal === self._valueMin() ) {
+ if ( curVal === this._valueMin() ) {
return;
}
- newVal = self._trimAlignValue( curVal - step );
+ newVal = this._trimAlignValue( curVal - step );
break;
}
-
- self._slide( event, index, newVal );
-
- return ret;
-
- })
- .keyup(function( event ) {
- var index = $( this ).data( "index.ui-slider-handle" );
-
- if ( self._keySliding ) {
- self._keySliding = false;
- self._stop( event, index );
- self._change( event, index );
- $( this ).removeClass( "ui-state-active" );
+
+ this._slide( event, index, newVal );
+ },
+ keyup: function( event ) {
+ var index = $( event.target ).data( "ui-slider-handle-index" );
+
+ if ( this._keySliding ) {
+ this._keySliding = false;
+ this._stop( event, index );
+ this._change( event, index );
+ $( event.target ).removeClass( "ui-state-active" );
}
-
- });
+ }
+ });
this._refreshValue();
this._animateOff = false;
},
- destroy: function() {
+ _destroy: function() {
this.handles.remove();
this.range.remove();
@@ -10559,26 +12275,15 @@ $.widget( "ui.slider", $.ui.mouse, {
" ui-slider-disabled" +
" ui-widget" +
" ui-widget-content" +
- " ui-corner-all" )
- .removeData( "slider" )
- .unbind( ".slider" );
+ " ui-corner-all" );
this._mouseDestroy();
-
- return this;
},
_mouseCapture: function( event ) {
- var o = this.options,
- position,
- normValue,
- distance,
- closestHandle,
- self,
- index,
- allowed,
- offset,
- mouseOverHandle;
+ var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
+ that = this,
+ o = this.options;
if ( o.disabled ) {
return false;
@@ -10593,9 +12298,8 @@ $.widget( "ui.slider", $.ui.mouse, {
position = { x: event.pageX, y: event.pageY };
normValue = this._normValueFromMouse( position );
distance = this._valueMax() - this._valueMin() + 1;
- self = this;
this.handles.each(function( i ) {
- var thisDistance = Math.abs( normValue - self.values(i) );
+ var thisDistance = Math.abs( normValue - that.values(i) );
if ( distance > thisDistance ) {
distance = thisDistance;
closestHandle = $( this );
@@ -10617,12 +12321,12 @@ $.widget( "ui.slider", $.ui.mouse, {
}
this._mouseSliding = true;
- self._handleIndex = index;
+ this._handleIndex = index;
closestHandle
.addClass( "ui-state-active" )
.focus();
-
+
offset = closestHandle.offset();
mouseOverHandle = !$( event.target ).parents().andSelf().is( ".ui-slider-handle" );
this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
@@ -10641,14 +12345,14 @@ $.widget( "ui.slider", $.ui.mouse, {
return true;
},
- _mouseStart: function( event ) {
+ _mouseStart: function() {
return true;
},
_mouseDrag: function( event ) {
var position = { x: event.pageX, y: event.pageY },
normValue = this._normValueFromMouse( position );
-
+
this._slide( event, this._handleIndex, normValue );
return false;
@@ -10667,7 +12371,7 @@ $.widget( "ui.slider", $.ui.mouse, {
return false;
},
-
+
_detectOrientation: function() {
this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
},
@@ -10724,7 +12428,7 @@ $.widget( "ui.slider", $.ui.mouse, {
if ( this.options.values && this.options.values.length ) {
otherVal = this.values( index ? 0 : 1 );
- if ( ( this.options.values.length === 2 && this.options.range === true ) &&
+ if ( ( this.options.values.length === 2 && this.options.range === true ) &&
( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
) {
newVal = otherVal;
@@ -10845,10 +12549,10 @@ $.widget( "ui.slider", $.ui.mouse, {
if ( value ) {
this.handles.filter( ".ui-state-focus" ).blur();
this.handles.removeClass( "ui-state-hover" );
- this.handles.propAttr( "disabled", true );
+ this.handles.prop( "disabled", true );
this.element.addClass( "ui-disabled" );
} else {
- this.handles.propAttr( "disabled", false );
+ this.handles.prop( "disabled", false );
this.element.removeClass( "ui-disabled" );
}
break;
@@ -10873,6 +12577,12 @@ $.widget( "ui.slider", $.ui.mouse, {
}
this._animateOff = false;
break;
+ case "min":
+ case "max":
+ this._animateOff = true;
+ this._refreshValue();
+ this._animateOff = false;
+ break;
}
},
@@ -10909,7 +12619,7 @@ $.widget( "ui.slider", $.ui.mouse, {
return vals;
}
},
-
+
// returns the step-aligned value that val is closest to, between (inclusive) min and max
_trimAlignValue: function( val ) {
if ( val <= this._valueMin() ) {
@@ -10938,38 +12648,34 @@ $.widget( "ui.slider", $.ui.mouse, {
_valueMax: function() {
return this.options.max;
},
-
+
_refreshValue: function() {
- var oRange = this.options.range,
+ var lastValPercent, valPercent, value, valueMin, valueMax,
+ oRange = this.options.range,
o = this.options,
- self = this,
+ that = this,
animate = ( !this._animateOff ) ? o.animate : false,
- valPercent,
- _set = {},
- lastValPercent,
- value,
- valueMin,
- valueMax;
+ _set = {};
if ( this.options.values && this.options.values.length ) {
- this.handles.each(function( i, j ) {
- valPercent = ( self.values(i) - self._valueMin() ) / ( self._valueMax() - self._valueMin() ) * 100;
- _set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
+ this.handles.each(function( i ) {
+ valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
+ _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
$( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
- if ( self.options.range === true ) {
- if ( self.orientation === "horizontal" ) {
+ if ( that.options.range === true ) {
+ if ( that.orientation === "horizontal" ) {
if ( i === 0 ) {
- self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
+ that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
}
if ( i === 1 ) {
- self.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
+ that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
}
} else {
if ( i === 0 ) {
- self.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
+ that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
}
if ( i === 1 ) {
- self.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
+ that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
}
}
}
@@ -10982,7 +12688,7 @@ $.widget( "ui.slider", $.ui.mouse, {
valPercent = ( valueMax !== valueMin ) ?
( value - valueMin ) / ( valueMax - valueMin ) * 100 :
0;
- _set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
+ _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
if ( oRange === "min" && this.orientation === "horizontal" ) {
@@ -11002,766 +12708,2205 @@ $.widget( "ui.slider", $.ui.mouse, {
});
-$.extend( $.ui.slider, {
- version: "1.8.16"
+}(jQuery));
+
+(function( $ ) {
+
+function modifier( fn ) {
+ return function() {
+ var previous = this.element.val();
+ fn.apply( this, arguments );
+ this._refresh();
+ if ( previous !== this.element.val() ) {
+ this._trigger( "change" );
+ }
+ };
+}
+
+$.widget( "ui.spinner", {
+ version: "1.9.2",
+ defaultElement: "<input>",
+ widgetEventPrefix: "spin",
+ options: {
+ culture: null,
+ icons: {
+ down: "ui-icon-triangle-1-s",
+ up: "ui-icon-triangle-1-n"
+ },
+ incremental: true,
+ max: null,
+ min: null,
+ numberFormat: null,
+ page: 10,
+ step: 1,
+
+ change: null,
+ spin: null,
+ start: null,
+ stop: null
+ },
+
+ _create: function() {
+ // handle string values that need to be parsed
+ this._setOption( "max", this.options.max );
+ this._setOption( "min", this.options.min );
+ this._setOption( "step", this.options.step );
+
+ // format the value, but don't constrain
+ this._value( this.element.val(), true );
+
+ this._draw();
+ 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._on( this.window, {
+ beforeunload: function() {
+ this.element.removeAttr( "autocomplete" );
+ }
+ });
+ },
+
+ _getCreateOptions: function() {
+ var options = {},
+ element = this.element;
+
+ $.each( [ "min", "max", "step" ], function( i, option ) {
+ var value = element.attr( option );
+ if ( value !== undefined && value.length ) {
+ options[ option ] = value;
+ }
+ });
+
+ return options;
+ },
+
+ _events: {
+ keydown: function( event ) {
+ if ( this._start( event ) && this._keydown( event ) ) {
+ event.preventDefault();
+ }
+ },
+ keyup: "_stop",
+ focus: function() {
+ this.previous = this.element.val();
+ },
+ blur: function( event ) {
+ if ( this.cancelBlur ) {
+ delete this.cancelBlur;
+ return;
+ }
+
+ this._refresh();
+ if ( this.previous !== this.element.val() ) {
+ this._trigger( "change", event );
+ }
+ },
+ mousewheel: function( event, delta ) {
+ if ( !delta ) {
+ return;
+ }
+ if ( !this.spinning && !this._start( event ) ) {
+ return false;
+ }
+
+ this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
+ clearTimeout( this.mousewheelTimer );
+ this.mousewheelTimer = this._delay(function() {
+ if ( this.spinning ) {
+ this._stop( event );
+ }
+ }, 100 );
+ event.preventDefault();
+ },
+ "mousedown .ui-spinner-button": function( event ) {
+ var previous;
+
+ // We never want the buttons to have focus; whenever the user is
+ // interacting with the spinner, the focus should be on the input.
+ // If the input is focused then this.previous is properly set from
+ // when the input first received focus. If the input is not focused
+ // then we need to set this.previous based on the value before spinning.
+ previous = this.element[0] === this.document[0].activeElement ?
+ this.previous : this.element.val();
+ function checkFocus() {
+ var isActive = this.element[0] === this.document[0].activeElement;
+ if ( !isActive ) {
+ this.element.focus();
+ this.previous = previous;
+ // support: IE
+ // IE sets focus asynchronously, so we need to check if focus
+ // moved off of the input because the user clicked on the button.
+ this._delay(function() {
+ this.previous = previous;
+ });
+ }
+ }
+
+ // ensure focus is on (or stays on) the text field
+ event.preventDefault();
+ checkFocus.call( this );
+
+ // support: IE
+ // IE doesn't prevent moving focus even with event.preventDefault()
+ // so we set a flag to know when we should ignore the blur event
+ // and check (again) if focus moved off of the input.
+ this.cancelBlur = true;
+ this._delay(function() {
+ delete this.cancelBlur;
+ checkFocus.call( this );
+ });
+
+ if ( this._start( event ) === false ) {
+ return;
+ }
+
+ this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
+ },
+ "mouseup .ui-spinner-button": "_stop",
+ "mouseenter .ui-spinner-button": function( event ) {
+ // button will add ui-state-active if mouse was down while mouseleave and kept down
+ if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
+ return;
+ }
+
+ if ( this._start( event ) === false ) {
+ return false;
+ }
+ this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
+ },
+ // TODO: do we really want to consider this a stop?
+ // shouldn't we just stop the repeater and wait until mouseup before
+ // we trigger the stop event?
+ "mouseleave .ui-spinner-button": "_stop"
+ },
+
+ _draw: function() {
+ var uiSpinner = this.uiSpinner = this.element
+ .addClass( "ui-spinner-input" )
+ .attr( "autocomplete", "off" )
+ .wrap( this._uiSpinnerHtml() )
+ .parent()
+ // add buttons
+ .append( this._buttonHtml() );
+
+ this.element.attr( "role", "spinbutton" );
+
+ // button bindings
+ this.buttons = uiSpinner.find( ".ui-spinner-button" )
+ .attr( "tabIndex", -1 )
+ .button()
+ .removeClass( "ui-corner-all" );
+
+ // IE 6 doesn't understand height: 50% for the buttons
+ // unless the wrapper has an explicit height
+ if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
+ uiSpinner.height() > 0 ) {
+ uiSpinner.height( uiSpinner.height() );
+ }
+
+ // disable spinner if element was already disabled
+ if ( this.options.disabled ) {
+ this.disable();
+ }
+ },
+
+ _keydown: function( event ) {
+ var options = this.options,
+ keyCode = $.ui.keyCode;
+
+ switch ( event.keyCode ) {
+ case keyCode.UP:
+ this._repeat( null, 1, event );
+ return true;
+ case keyCode.DOWN:
+ this._repeat( null, -1, event );
+ return true;
+ case keyCode.PAGE_UP:
+ this._repeat( null, options.page, event );
+ return true;
+ case keyCode.PAGE_DOWN:
+ this._repeat( null, -options.page, event );
+ return true;
+ }
+
+ return false;
+ },
+
+ _uiSpinnerHtml: function() {
+ return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
+ },
+
+ _buttonHtml: function() {
+ return "" +
+ "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
+ "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
+ "</a>" +
+ "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
+ "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
+ "</a>";
+ },
+
+ _start: function( event ) {
+ if ( !this.spinning && this._trigger( "start", event ) === false ) {
+ return false;
+ }
+
+ if ( !this.counter ) {
+ this.counter = 1;
+ }
+ this.spinning = true;
+ return true;
+ },
+
+ _repeat: function( i, steps, event ) {
+ i = i || 500;
+
+ clearTimeout( this.timer );
+ this.timer = this._delay(function() {
+ this._repeat( 40, steps, event );
+ }, i );
+
+ this._spin( steps * this.options.step, event );
+ },
+
+ _spin: function( step, event ) {
+ var value = this.value() || 0;
+
+ if ( !this.counter ) {
+ this.counter = 1;
+ }
+
+ value = this._adjustValue( value + step * this._increment( this.counter ) );
+
+ if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
+ this._value( value );
+ this.counter++;
+ }
+ },
+
+ _increment: function( i ) {
+ var incremental = this.options.incremental;
+
+ if ( incremental ) {
+ return $.isFunction( incremental ) ?
+ incremental( i ) :
+ Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
+ }
+
+ return 1;
+ },
+
+ _precision: function() {
+ var precision = this._precisionOf( this.options.step );
+ if ( this.options.min !== null ) {
+ precision = Math.max( precision, this._precisionOf( this.options.min ) );
+ }
+ return precision;
+ },
+
+ _precisionOf: function( num ) {
+ var str = num.toString(),
+ decimal = str.indexOf( "." );
+ return decimal === -1 ? 0 : str.length - decimal - 1;
+ },
+
+ _adjustValue: function( value ) {
+ var base, aboveMin,
+ options = this.options;
+
+ // make sure we're at a valid step
+ // - find out where we are relative to the base (min or 0)
+ base = options.min !== null ? options.min : 0;
+ aboveMin = value - base;
+ // - round to the nearest step
+ aboveMin = Math.round(aboveMin / options.step) * options.step;
+ // - rounding is based on 0, so adjust back to our base
+ value = base + aboveMin;
+
+ // fix precision from bad JS floating point math
+ value = parseFloat( value.toFixed( this._precision() ) );
+
+ // clamp the value
+ if ( options.max !== null && value > options.max) {
+ return options.max;
+ }
+ if ( options.min !== null && value < options.min ) {
+ return options.min;
+ }
+
+ return value;
+ },
+
+ _stop: function( event ) {
+ if ( !this.spinning ) {
+ return;
+ }
+
+ clearTimeout( this.timer );
+ clearTimeout( this.mousewheelTimer );
+ this.counter = 0;
+ this.spinning = false;
+ this._trigger( "stop", event );
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "culture" || key === "numberFormat" ) {
+ var prevValue = this._parse( this.element.val() );
+ this.options[ key ] = value;
+ this.element.val( this._format( prevValue ) );
+ return;
+ }
+
+ if ( key === "max" || key === "min" || key === "step" ) {
+ if ( typeof value === "string" ) {
+ value = this._parse( value );
+ }
+ }
+
+ this._super( key, value );
+
+ if ( key === "disabled" ) {
+ if ( value ) {
+ this.element.prop( "disabled", true );
+ this.buttons.button( "disable" );
+ } else {
+ this.element.prop( "disabled", false );
+ this.buttons.button( "enable" );
+ }
+ }
+ },
+
+ _setOptions: modifier(function( options ) {
+ this._super( options );
+ this._value( this.element.val() );
+ }),
+
+ _parse: function( val ) {
+ if ( typeof val === "string" && val !== "" ) {
+ val = window.Globalize && this.options.numberFormat ?
+ Globalize.parseFloat( val, 10, this.options.culture ) : +val;
+ }
+ return val === "" || isNaN( val ) ? null : val;
+ },
+
+ _format: function( value ) {
+ if ( value === "" ) {
+ return "";
+ }
+ return window.Globalize && this.options.numberFormat ?
+ Globalize.format( value, this.options.numberFormat, this.options.culture ) :
+ value;
+ },
+
+ _refresh: function() {
+ this.element.attr({
+ "aria-valuemin": this.options.min,
+ "aria-valuemax": this.options.max,
+ // TODO: what should we do with values that can't be parsed?
+ "aria-valuenow": this._parse( this.element.val() )
+ });
+ },
+
+ // update the value without triggering change
+ _value: function( value, allowAny ) {
+ var parsed;
+ if ( value !== "" ) {
+ parsed = this._parse( value );
+ if ( parsed !== null ) {
+ if ( !allowAny ) {
+ parsed = this._adjustValue( parsed );
+ }
+ value = this._format( parsed );
+ }
+ }
+ this.element.val( value );
+ this._refresh();
+ },
+
+ _destroy: function() {
+ this.element
+ .removeClass( "ui-spinner-input" )
+ .prop( "disabled", false )
+ .removeAttr( "autocomplete" )
+ .removeAttr( "role" )
+ .removeAttr( "aria-valuemin" )
+ .removeAttr( "aria-valuemax" )
+ .removeAttr( "aria-valuenow" );
+ this.uiSpinner.replaceWith( this.element );
+ },
+
+ stepUp: modifier(function( steps ) {
+ this._stepUp( steps );
+ }),
+ _stepUp: function( steps ) {
+ this._spin( (steps || 1) * this.options.step );
+ },
+
+ stepDown: modifier(function( steps ) {
+ this._stepDown( steps );
+ }),
+ _stepDown: function( steps ) {
+ this._spin( (steps || 1) * -this.options.step );
+ },
+
+ pageUp: modifier(function( pages ) {
+ this._stepUp( (pages || 1) * this.options.page );
+ }),
+
+ pageDown: modifier(function( pages ) {
+ this._stepDown( (pages || 1) * this.options.page );
+ }),
+
+ value: function( newVal ) {
+ if ( !arguments.length ) {
+ return this._parse( this.element.val() );
+ }
+ modifier( this._value ).call( this, newVal );
+ },
+
+ widget: function() {
+ return this.uiSpinner;
+ }
});
-}(jQuery));
-/*
- * jQuery UI Tabs 1.8.16
- *
- * Copyright 2011, 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/Tabs
- *
- * Depends:
- * jquery.ui.core.js
- * jquery.ui.widget.js
- */
+}( jQuery ) );
+
(function( $, undefined ) {
var tabId = 0,
- listId = 0;
+ rhash = /#.*$/;
function getNextTabId() {
return ++tabId;
}
-function getNextListId() {
- return ++listId;
+function isLocal( anchor ) {
+ return anchor.hash.length > 1 &&
+ anchor.href.replace( rhash, "" ) ===
+ location.href.replace( rhash, "" )
+ // support: Safari 5.1
+ // Safari 5.1 doesn't encode spaces in window.location
+ // but it does encode spaces from anchors (#8777)
+ .replace( /\s/g, "%20" );
}
$.widget( "ui.tabs", {
+ version: "1.9.2",
+ delay: 300,
options: {
- add: null,
- ajaxOptions: null,
- cache: false,
- cookie: null, // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
+ active: null,
collapsible: false,
- disable: null,
- disabled: [],
- enable: null,
event: "click",
- fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
- idPrefix: "ui-tabs-",
- load: null,
- panelTemplate: "<div></div>",
- remove: null,
- select: null,
+ heightStyle: "content",
+ hide: null,
show: null,
- spinner: "<em>Loading&#8230;</em>",
- tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
+
+ // callbacks
+ activate: null,
+ beforeActivate: null,
+ beforeLoad: null,
+ load: null
},
_create: function() {
- this._tabify( true );
- },
+ var that = this,
+ options = this.options,
+ active = options.active,
+ locationHash = location.hash.substring( 1 );
- _setOption: function( key, value ) {
- if ( key == "selected" ) {
- if (this.options.collapsible && value == this.options.selected ) {
- return;
+ this.running = false;
+
+ 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();
+
+ if ( active === null ) {
+ // check the fragment identifier in the URL
+ if ( locationHash ) {
+ this.tabs.each(function( i, tab ) {
+ if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
+ active = i;
+ return false;
+ }
+ });
}
- this.select( value );
+
+ // check for a tab marked active via a class
+ if ( active === null ) {
+ active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
+ }
+
+ // no active tab, set to false
+ if ( active === null || active === -1 ) {
+ active = this.tabs.length ? 0 : false;
+ }
+ }
+
+ // handle numbers: negative, out of range
+ if ( active !== false ) {
+ active = this.tabs.index( this.tabs.eq( active ) );
+ if ( active === -1 ) {
+ active = options.collapsible ? false : 0;
+ }
+ }
+ options.active = active;
+
+ // don't allow collapsible: false and active: false
+ if ( !options.collapsible && options.active === false && this.anchors.length ) {
+ options.active = 0;
+ }
+
+ // Take disabling tabs via class attribute from HTML
+ // into account and update option properly.
+ if ( $.isArray( options.disabled ) ) {
+ options.disabled = $.unique( options.disabled.concat(
+ $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
+ return that.tabs.index( li );
+ })
+ ) ).sort();
+ }
+
+ // check for length avoids error when initializing empty list
+ if ( this.options.active !== false && this.anchors.length ) {
+ this.active = this._findActive( this.options.active );
} else {
- this.options[ key ] = value;
- this._tabify();
+ this.active = $();
+ }
+
+ this._refresh();
+
+ if ( this.active.length ) {
+ this.load( options.active );
}
},
- _tabId: function( a ) {
- return a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF-]/g, "" ) ||
- this.options.idPrefix + getNextTabId();
+ _getCreateEventData: function() {
+ return {
+ tab: this.active,
+ panel: !this.active.length ? $() : this._getPanelForTab( this.active )
+ };
},
- _sanitizeSelector: function( hash ) {
- // we need this because an id may contain a ":"
- return hash.replace( /:/g, "\\:" );
+ _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 );
+ }
},
- _cookie: function() {
- var cookie = this.cookie ||
- ( this.cookie = this.options.cookie.name || "ui-tabs-" + getNextListId() );
- return $.cookie.apply( null, [ cookie ].concat( $.makeArray( arguments ) ) );
+ _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();
+ }
},
- _ui: function( tab, panel ) {
- return {
- tab: tab,
- panel: panel,
- index: this.anchors.index( tab )
- };
+ // 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;
+ }
},
- _cleanup: function() {
- // restore all former loading tabs labels
- this.lis.filter( ".ui-state-processing" )
- .removeClass( "ui-state-processing" )
- .find( "span:data(label.tabs)" )
- .each(function() {
- var el = $( this );
- el.html( el.data( "label.tabs" ) ).removeData( "label.tabs" );
- });
+ _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;
},
- _tabify: function( init ) {
- var self = this,
- o = this.options,
- fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash
+ _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
+ this._activate( value );
+ return;
+ }
- this.list = this.element.find( "ol,ul" ).eq( 0 );
- this.lis = $( " > li:has(a[href])", this.list );
- this.anchors = this.lis.map(function() {
- return $( "a", this )[ 0 ];
+ if ( key === "disabled" ) {
+ // don't use the widget factory's disabled handling
+ this._setupDisabled( value );
+ return;
+ }
+
+ this._super( key, value);
+
+ 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" ) {
+ this._setupEvents( value );
+ }
+
+ if ( key === "heightStyle" ) {
+ this._setupHeightStyle( value );
+ }
+ },
+
+ _tabId: function( tab ) {
+ return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
+ },
+
+ _sanitizeSelector: function( hash ) {
+ return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
+ },
+
+ refresh: function() {
+ var options = this.options,
+ 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()
+ options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
+ return lis.index( tab );
});
- this.panels = $( [] );
-
- this.anchors.each(function( i, a ) {
- var href = $( a ).attr( "href" );
- // For dynamically created HTML that contains a hash as href IE < 8 expands
- // such href to the full page url with hash and then misinterprets tab as ajax.
- // Same consideration applies for an added tab with a fragment identifier
- // since a[href=#fragment-identifier] does unexpectedly not match.
- // Thus normalize href attribute...
- var hrefBase = href.split( "#" )[ 0 ],
- baseEl;
- if ( hrefBase && ( hrefBase === location.toString().split( "#" )[ 0 ] ||
- ( baseEl = $( "base" )[ 0 ]) && hrefBase === baseEl.href ) ) {
- href = a.hash;
- a.href = href;
+
+ this._processTabs();
+
+ // 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.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
+ } 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.tabs.index( this.active );
+ }
+
+ this._refresh();
+ },
+
+ _refresh: function() {
+ 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.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, anchor ) {
+ var selector, panel, panelId,
+ anchorId = $( anchor ).uniqueId().attr( "id" ),
+ tab = $( anchor ).closest( "li" ),
+ originalAriaControls = tab.attr( "aria-controls" );
// inline tab
- if ( fragmentId.test( href ) ) {
- self.panels = self.panels.add( self.element.find( self._sanitizeSelector( href ) ) );
+ if ( isLocal( anchor ) ) {
+ selector = anchor.hash;
+ panel = that.element.find( that._sanitizeSelector( selector ) );
// remote tab
- // prevent loading the page itself if href is just "#"
- } else if ( href && href !== "#" ) {
- // required for restore on destroy
- $.data( a, "href.tabs", href );
-
- // TODO until #3808 is fixed strip fragment identifier from url
- // (IE fails to load from such url)
- $.data( a, "load.tabs", href.replace( /#.*$/, "" ) );
-
- var id = self._tabId( a );
- a.href = "#" + id;
- var $panel = self.element.find( "#" + id );
- if ( !$panel.length ) {
- $panel = $( o.panelTemplate )
- .attr( "id", id )
- .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
- .insertAfter( self.panels[ i - 1 ] || self.list );
- $panel.data( "destroy.tabs", true );
- }
- self.panels = self.panels.add( $panel );
- // invalid tab href
} else {
- o.disabled.push( i );
+ panelId = that._tabId( tab );
+ selector = "#" + panelId;
+ panel = that.element.find( selector );
+ if ( !panel.length ) {
+ 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 );
+ }
+ if ( originalAriaControls ) {
+ tab.data( "ui-tabs-aria-controls", originalAriaControls );
+ }
+ tab.attr({
+ "aria-controls": selector.substring( 1 ),
+ "aria-labelledby": anchorId
+ });
+ panel.attr( "aria-labelledby", anchorId );
});
- // initialization from scratch
- if ( init ) {
- // attach necessary classes for styling
- this.element.addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" );
- 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.panels.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" );
-
- // Selected tab
- // use "selected" option or try to retrieve:
- // 1. from fragment identifier in url
- // 2. from cookie
- // 3. from selected class attribute on <li>
- if ( o.selected === undefined ) {
- if ( location.hash ) {
- this.anchors.each(function( i, a ) {
- if ( a.hash == location.hash ) {
- o.selected = i;
- return false;
- }
- });
- }
- if ( typeof o.selected !== "number" && o.cookie ) {
- o.selected = parseInt( self._cookie(), 10 );
- }
- if ( typeof o.selected !== "number" && this.lis.filter( ".ui-tabs-selected" ).length ) {
- o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) );
- }
- o.selected = o.selected || ( this.lis.length ? 0 : -1 );
- } else if ( o.selected === null ) { // usage of null is deprecated, TODO remove in next release
- o.selected = -1;
+ 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)
+ _getList: function() {
+ return this.element.find( "ol,ul" ).eq( 0 );
+ },
+
+ _createPanel: function( id ) {
+ return $( "<div>" )
+ .attr( "id", id )
+ .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
+ .data( "ui-tabs-destroy", true );
+ },
+
+ _setupDisabled: function( disabled ) {
+ if ( $.isArray( disabled ) ) {
+ if ( !disabled.length ) {
+ disabled = false;
+ } else if ( disabled.length === this.anchors.length ) {
+ disabled = true;
}
+ }
- // sanity check - default to first tab...
- o.selected = ( ( o.selected >= 0 && this.anchors[ o.selected ] ) || o.selected < 0 )
- ? o.selected
- : 0;
+ // disable tabs
+ 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" );
+ }
+ }
- // Take disabling tabs via class attribute from HTML
- // into account and update option properly.
- // A selected tab cannot become disabled.
- o.disabled = $.unique( o.disabled.concat(
- $.map( this.lis.filter( ".ui-state-disabled" ), function( n, i ) {
- return self.lis.index( n );
- })
- ) ).sort();
+ this.options.disabled = disabled;
+ },
- if ( $.inArray( o.selected, o.disabled ) != -1 ) {
- o.disabled.splice( $.inArray( o.selected, o.disabled ), 1 );
+ _setupEvents: function( event ) {
+ var events = {
+ click: function( event ) {
+ event.preventDefault();
}
+ };
+ if ( event ) {
+ $.each( event.split(" "), function( index, eventName ) {
+ events[ eventName ] = "_eventHandler";
+ });
+ }
- // highlight selected tab
- this.panels.addClass( "ui-tabs-hide" );
- this.lis.removeClass( "ui-tabs-selected ui-state-active" );
- // check for length avoids error when initializing empty list
- if ( o.selected >= 0 && this.anchors.length ) {
- self.element.find( self._sanitizeSelector( self.anchors[ o.selected ].hash ) ).removeClass( "ui-tabs-hide" );
- this.lis.eq( o.selected ).addClass( "ui-tabs-selected ui-state-active" );
+ 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" } );
- // seems to be expected behavior that the show callback is fired
- self.element.queue( "tabs", function() {
- self._trigger( "show", null,
- self._ui( self.anchors[ o.selected ], self.element.find( self._sanitizeSelector( self.anchors[ o.selected ].hash ) )[ 0 ] ) );
- });
+ this._focusable( this.tabs );
+ this._hoverable( this.tabs );
+ },
- this.load( o.selected );
+ _setupHeightStyle: function( heightStyle ) {
+ var maxHeight, overflow,
+ parent = this.element.parent();
+
+ if ( heightStyle === "fill" ) {
+ // IE 6 treats height like minHeight, so we need to turn off overflow
+ // in order to get a reliable height
+ // we use the minHeight support test because we assume that only
+ // browsers that don't support minHeight will treat height as minHeight
+ if ( !$.support.minHeight ) {
+ overflow = parent.css( "overflow" );
+ parent.css( "overflow", "hidden");
}
+ maxHeight = parent.height();
+ this.element.siblings( ":visible" ).each(function() {
+ var elem = $( this ),
+ position = elem.css( "position" );
- // clean up to avoid memory leaks in certain versions of IE 6
- // TODO: namespace this event
- $( window ).bind( "unload", function() {
- self.lis.add( self.anchors ).unbind( ".tabs" );
- self.lis = self.anchors = self.panels = null;
+ if ( position === "absolute" || position === "fixed" ) {
+ return;
+ }
+ maxHeight -= elem.outerHeight( true );
});
- // update selected after add/remove
- } else {
- o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) );
+ if ( overflow ) {
+ parent.css( "overflow", overflow );
+ }
+
+ this.element.children().not( this.panels ).each(function() {
+ maxHeight -= $( this ).outerHeight( true );
+ });
+
+ this.panels.each(function() {
+ $( this ).height( Math.max( 0, maxHeight -
+ $( this ).innerHeight() + $( this ).height() ) );
+ })
+ .css( "overflow", "auto" );
+ } else if ( heightStyle === "auto" ) {
+ maxHeight = 0;
+ this.panels.each(function() {
+ maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
+ }).height( maxHeight );
}
+ },
- // update collapsible
- // TODO: use .toggleClass()
- this.element[ o.collapsible ? "addClass" : "removeClass" ]( "ui-tabs-collapsible" );
+ _eventHandler: function( event ) {
+ var options = this.options,
+ active = this.active,
+ anchor = $( event.currentTarget ),
+ tab = anchor.closest( "li" ),
+ clickedIsActive = tab[ 0 ] === active[ 0 ],
+ collapsing = clickedIsActive && options.collapsible,
+ toShow = collapsing ? $() : this._getPanelForTab( tab ),
+ toHide = !active.length ? $() : this._getPanelForTab( active ),
+ eventData = {
+ oldTab: active,
+ oldPanel: toHide,
+ newTab: collapsing ? $() : tab,
+ newPanel: toShow
+ };
+
+ event.preventDefault();
- // set or update cookie after init and add/remove respectively
- if ( o.cookie ) {
- this._cookie( o.selected, o.cookie );
+ if ( tab.hasClass( "ui-state-disabled" ) ||
+ // tab is already loading
+ tab.hasClass( "ui-tabs-loading" ) ||
+ // can't switch durning an animation
+ this.running ||
+ // click on active header, but not collapsible
+ ( clickedIsActive && !options.collapsible ) ||
+ // allow canceling activation
+ ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
+ return;
}
- // disable tabs
- for ( var i = 0, li; ( li = this.lis[ i ] ); i++ ) {
- $( li )[ $.inArray( i, o.disabled ) != -1 &&
- // TODO: use .toggleClass()
- !$( li ).hasClass( "ui-tabs-selected" ) ? "addClass" : "removeClass" ]( "ui-state-disabled" );
+ options.active = collapsing ? false : this.tabs.index( tab );
+
+ this.active = clickedIsActive ? $() : tab;
+ if ( this.xhr ) {
+ this.xhr.abort();
}
- // reset cache if switching from cached to not cached
- if ( o.cache === false ) {
- this.anchors.removeData( "cache.tabs" );
+ if ( !toHide.length && !toShow.length ) {
+ $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
}
- // remove all handlers before, tabify may run on existing tabs after add or option change
- this.lis.add( this.anchors ).unbind( ".tabs" );
+ if ( toShow.length ) {
+ this.load( this.tabs.index( tab ), event );
+ }
+ this._toggle( event, eventData );
+ },
- if ( o.event !== "mouseover" ) {
- var addState = function( state, el ) {
- if ( el.is( ":not(.ui-state-disabled)" ) ) {
- el.addClass( "ui-state-" + state );
- }
- };
- var removeState = function( state, el ) {
- el.removeClass( "ui-state-" + state );
- };
- this.lis.bind( "mouseover.tabs" , function() {
- addState( "hover", $( this ) );
- });
- this.lis.bind( "mouseout.tabs", function() {
- removeState( "hover", $( this ) );
- });
- this.anchors.bind( "focus.tabs", function() {
- addState( "focus", $( this ).closest( "li" ) );
- });
- this.anchors.bind( "blur.tabs", function() {
- removeState( "focus", $( this ).closest( "li" ) );
+ // handles show/hide for selecting tabs
+ _toggle: function( event, eventData ) {
+ var that = this,
+ toShow = eventData.newPanel,
+ toHide = eventData.oldPanel;
+
+ this.running = true;
+
+ function complete() {
+ that.running = false;
+ that._trigger( "activate", event, eventData );
+ }
+
+ function show() {
+ eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
+
+ if ( toShow.length && that.options.show ) {
+ that._show( toShow, that.options.show, complete );
+ } else {
+ toShow.show();
+ complete();
+ }
+ }
+
+ // start out by hiding, then showing, then completing
+ if ( toHide.length && this.options.hide ) {
+ this._hide( toHide, this.options.hide, function() {
+ eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
+ show();
});
+ } else {
+ eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
+ 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 ) {
+ var anchor,
+ active = this._findActive( index );
+
+ // trying to activate the already active panel
+ if ( active[ 0 ] === this.active[ 0 ] ) {
+ return;
+ }
+
+ // trying to collapse, simulate a click on the current active header
+ if ( !active.length ) {
+ active = this.active;
}
- // set up animations
- var hideFx, showFx;
- if ( o.fx ) {
- if ( $.isArray( o.fx ) ) {
- hideFx = o.fx[ 0 ];
- showFx = o.fx[ 1 ];
+ anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
+ this._eventHandler({
+ target: anchor,
+ currentTarget: anchor,
+ preventDefault: $.noop
+ });
+ },
+
+ _findActive: function( index ) {
+ return index === false ? $() : this.tabs.eq( index );
+ },
+
+ _getIndex: function( index ) {
+ // meta-function to give users option to provide a href string instead of a numerical index.
+ if ( typeof index === "string" ) {
+ index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
+ }
+
+ return index;
+ },
+
+ _destroy: function() {
+ if ( this.xhr ) {
+ this.xhr.abort();
+ }
+
+ this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
+
+ 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" )
+ .removeAttr( "role" )
+ .removeAttr( "tabIndex" )
+ .removeData( "href.tabs" )
+ .removeData( "load.tabs" )
+ .removeUniqueId();
+
+ this.tabs.add( this.panels ).each(function() {
+ if ( $.data( this, "ui-tabs-destroy" ) ) {
+ $( this ).remove();
} else {
- hideFx = showFx = o.fx;
+ $( 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.tabs.each(function() {
+ var li = $( this ),
+ prev = li.data( "ui-tabs-aria-controls" );
+ if ( prev ) {
+ li.attr( "aria-controls", prev );
+ } else {
+ li.removeAttr( "aria-controls" );
+ }
+ });
+
+ this.panels.show();
+
+ if ( this.options.heightStyle !== "content" ) {
+ this.panels.css( "height", "" );
+ }
+ },
+
+ enable: function( index ) {
+ var disabled = this.options.disabled;
+ if ( disabled === false ) {
+ return;
}
- // Reset certain styles left over from animation
- // and prevent IE's ClearType bug...
- function resetStyle( $el, fx ) {
- $el.css( "display", "" );
- if ( !$.support.opacity && fx.opacity ) {
- $el[ 0 ].style.removeAttribute( "filter" );
+ if ( index === undefined ) {
+ disabled = false;
+ } else {
+ index = this._getIndex( index );
+ if ( $.isArray( disabled ) ) {
+ disabled = $.map( disabled, function( num ) {
+ return num !== index ? num : null;
+ });
+ } else {
+ disabled = $.map( this.tabs, function( li, num ) {
+ return num !== index ? num : null;
+ });
}
}
+ this._setupDisabled( disabled );
+ },
- // Show a tab...
- var showTab = showFx
- ? function( clicked, $show ) {
- $( clicked ).closest( "li" ).addClass( "ui-tabs-selected ui-state-active" );
- $show.hide().removeClass( "ui-tabs-hide" ) // avoid flicker that way
- .animate( showFx, showFx.duration || "normal", function() {
- resetStyle( $show, showFx );
- self._trigger( "show", null, self._ui( clicked, $show[ 0 ] ) );
- });
+ disable: function( index ) {
+ var disabled = this.options.disabled;
+ if ( disabled === true ) {
+ return;
+ }
+
+ if ( index === undefined ) {
+ disabled = true;
+ } else {
+ index = this._getIndex( index );
+ if ( $.inArray( index, disabled ) !== -1 ) {
+ return;
}
- : function( clicked, $show ) {
- $( clicked ).closest( "li" ).addClass( "ui-tabs-selected ui-state-active" );
- $show.removeClass( "ui-tabs-hide" );
- self._trigger( "show", null, self._ui( clicked, $show[ 0 ] ) );
+ if ( $.isArray( disabled ) ) {
+ disabled = $.merge( [ index ], disabled ).sort();
+ } else {
+ disabled = [ index ];
+ }
+ }
+ this._setupDisabled( disabled );
+ },
+
+ load: function( index, event ) {
+ index = this._getIndex( index );
+ var that = this,
+ tab = this.tabs.eq( index ),
+ anchor = tab.find( ".ui-tabs-anchor" ),
+ panel = this._getPanelForTab( tab ),
+ eventData = {
+ tab: tab,
+ panel: panel
};
- // Hide a tab, $show is optional...
- var hideTab = hideFx
- ? function( clicked, $hide ) {
- $hide.animate( hideFx, hideFx.duration || "normal", function() {
- self.lis.removeClass( "ui-tabs-selected ui-state-active" );
- $hide.addClass( "ui-tabs-hide" );
- resetStyle( $hide, hideFx );
- self.element.dequeue( "tabs" );
+ // not remote
+ if ( isLocal( anchor[ 0 ] ) ) {
+ return;
+ }
+
+ this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
+
+ // support: jQuery <1.8
+ // jQuery <1.8 returns false if the request is canceled in beforeSend,
+ // 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 ) {
+ // support: jQuery <1.8
+ // http://bugs.jquery.com/ticket/11778
+ setTimeout(function() {
+ panel.html( response );
+ that._trigger( "load", event, eventData );
+ }, 1 );
+ })
+ .complete(function( jqXHR, status ) {
+ // support: jQuery <1.8
+ // http://bugs.jquery.com/ticket/11778
+ setTimeout(function() {
+ if ( status === "abort" ) {
+ that.panels.stop( false, true );
+ }
+
+ tab.removeClass( "ui-tabs-loading" );
+ panel.removeAttr( "aria-busy" );
+
+ if ( jqXHR === that.xhr ) {
+ delete that.xhr;
+ }
+ }, 1 );
});
- }
- : function( clicked, $hide, $show ) {
- self.lis.removeClass( "ui-tabs-selected ui-state-active" );
- $hide.addClass( "ui-tabs-hide" );
- self.element.dequeue( "tabs" );
- };
+ }
+ },
- // attach tab event handler, unbind to avoid duplicates from former tabifying...
- this.anchors.bind( o.event + ".tabs", function() {
- var el = this,
- $li = $(el).closest( "li" ),
- $hide = self.panels.filter( ":not(.ui-tabs-hide)" ),
- $show = self.element.find( self._sanitizeSelector( el.hash ) );
-
- // If tab is already selected and not collapsible or tab disabled or
- // or is already loading or click callback returns false stop here.
- // Check if click handler returns false last so that it is not executed
- // for a disabled or loading tab!
- if ( ( $li.hasClass( "ui-tabs-selected" ) && !o.collapsible) ||
- $li.hasClass( "ui-state-disabled" ) ||
- $li.hasClass( "ui-state-processing" ) ||
- self.panels.filter( ":animated" ).length ||
- self._trigger( "select", null, self._ui( this, $show[ 0 ] ) ) === false ) {
- this.blur();
- return false;
+ // TODO: Remove this function in 1.10 when ajaxOptions is removed
+ _ajaxSettings: function( anchor, event, eventData ) {
+ var that = this;
+ return {
+ url: anchor.attr( "href" ),
+ beforeSend: function( jqXHR, settings ) {
+ return that._trigger( "beforeLoad", event,
+ $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
}
+ };
+ },
+
+ _getPanelForTab: function( tab ) {
+ var id = $( tab ).attr( "aria-controls" );
+ return this.element.find( this._sanitizeSelector( "#" + id ) );
+ }
+});
+
+// DEPRECATED
+if ( $.uiBackCompat !== false ) {
+
+ // helper method for a lot of the back compat extensions
+ $.ui.tabs.prototype._ui = function( tab, panel ) {
+ return {
+ tab: tab,
+ panel: panel,
+ index: this.anchors.index( tab )
+ };
+ };
+
+ // url method
+ $.widget( "ui.tabs", $.ui.tabs, {
+ url: function( index, url ) {
+ this.anchors.eq( index ).attr( "href", url );
+ }
+ });
+
+ // TODO: Remove _ajaxSettings() method when removing this extension
+ // ajaxOptions and cache options
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ ajaxOptions: null,
+ cache: false
+ },
+
+ _create: function() {
+ this._super();
- o.selected = self.anchors.index( this );
+ var that = this;
- self.abort();
+ this._on({ tabsbeforeload: function( event, ui ) {
+ // tab is already cached
+ if ( $.data( ui.tab[ 0 ], "cache.tabs" ) ) {
+ event.preventDefault();
+ return;
+ }
- // if tab may be closed
- if ( o.collapsible ) {
- if ( $li.hasClass( "ui-tabs-selected" ) ) {
- o.selected = -1;
+ ui.jqXHR.success(function() {
+ if ( that.options.cache ) {
+ $.data( ui.tab[ 0 ], "cache.tabs", true );
+ }
+ });
+ }});
+ },
- if ( o.cookie ) {
- self._cookie( o.selected, o.cookie );
+ _ajaxSettings: function( anchor, event, ui ) {
+ var ajaxOptions = this.options.ajaxOptions;
+ return $.extend( {}, ajaxOptions, {
+ error: function( xhr, status ) {
+ try {
+ // Passing index avoid a race condition when this method is
+ // called after the user has selected another tab.
+ // Pass the anchor that initiated this request allows
+ // loadError to manipulate the tab content panel via $(a.hash)
+ ajaxOptions.error(
+ xhr, status, ui.tab.closest( "li" ).index(), ui.tab[ 0 ] );
}
+ catch ( error ) {}
+ }
+ }, this._superApply( arguments ) );
+ },
- self.element.queue( "tabs", function() {
- hideTab( el, $hide );
- }).dequeue( "tabs" );
+ _setOption: function( key, value ) {
+ // reset cache if switching from cached to not cached
+ if ( key === "cache" && value === false ) {
+ this.anchors.removeData( "cache.tabs" );
+ }
+ this._super( key, value );
+ },
- this.blur();
- return false;
- } else if ( !$hide.length ) {
- if ( o.cookie ) {
- self._cookie( o.selected, o.cookie );
+ _destroy: function() {
+ this.anchors.removeData( "cache.tabs" );
+ this._super();
+ },
+
+ url: function( index ){
+ this.anchors.eq( index ).removeData( "cache.tabs" );
+ this._superApply( arguments );
+ }
+ });
+
+ // abort method
+ $.widget( "ui.tabs", $.ui.tabs, {
+ abort: function() {
+ if ( this.xhr ) {
+ this.xhr.abort();
+ }
+ }
+ });
+
+ // spinner
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ spinner: "<em>Loading&#8230;</em>"
+ },
+ _create: function() {
+ this._super();
+ this._on({
+ tabsbeforeload: function( event, ui ) {
+ // Don't react to nested tabs or tabs that don't use a spinner
+ if ( event.target !== this.element[ 0 ] ||
+ !this.options.spinner ) {
+ return;
}
- self.element.queue( "tabs", function() {
- showTab( el, $show );
+ var span = ui.tab.find( "span" ),
+ html = span.html();
+ span.html( this.options.spinner );
+ ui.jqXHR.complete(function() {
+ span.html( html );
});
+ }
+ });
+ }
+ });
- // TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171
- self.load( self.anchors.index( this ) );
+ // enable/disable events
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ enable: null,
+ disable: null
+ },
- this.blur();
- return false;
- }
+ enable: function( index ) {
+ var options = this.options,
+ trigger;
+
+ if ( index && options.disabled === true ||
+ ( $.isArray( options.disabled ) && $.inArray( index, options.disabled ) !== -1 ) ) {
+ trigger = true;
+ }
+
+ this._superApply( arguments );
+
+ if ( trigger ) {
+ this._trigger( "enable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
}
+ },
+
+ disable: function( index ) {
+ var options = this.options,
+ trigger;
- if ( o.cookie ) {
- self._cookie( o.selected, o.cookie );
+ if ( index && options.disabled === false ||
+ ( $.isArray( options.disabled ) && $.inArray( index, options.disabled ) === -1 ) ) {
+ trigger = true;
}
- // show new tab
- if ( $show.length ) {
- if ( $hide.length ) {
- self.element.queue( "tabs", function() {
- hideTab( el, $hide );
- });
+ this._superApply( arguments );
+
+ if ( trigger ) {
+ this._trigger( "disable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
+ }
+ }
+ });
+
+ // add/remove methods and events
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ add: null,
+ remove: null,
+ tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>"
+ },
+
+ add: function( url, label, index ) {
+ if ( index === undefined ) {
+ index = this.anchors.length;
+ }
+
+ var doInsertAfter, panel,
+ options = this.options,
+ li = $( options.tabTemplate
+ .replace( /#\{href\}/g, url )
+ .replace( /#\{label\}/g, label ) ),
+ id = !url.indexOf( "#" ) ?
+ url.replace( "#", "" ) :
+ this._tabId( li );
+
+ li.addClass( "ui-state-default ui-corner-top" ).data( "ui-tabs-destroy", true );
+ li.attr( "aria-controls", id );
+
+ doInsertAfter = index >= this.tabs.length;
+
+ // try to find an existing element before creating a new one
+ panel = this.element.find( "#" + id );
+ if ( !panel.length ) {
+ panel = this._createPanel( id );
+ if ( doInsertAfter ) {
+ if ( index > 0 ) {
+ panel.insertAfter( this.panels.eq( -1 ) );
+ } else {
+ panel.appendTo( this.element );
+ }
+ } else {
+ panel.insertBefore( this.panels[ index ] );
}
- self.element.queue( "tabs", function() {
- showTab( el, $show );
- });
+ }
+ panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ).hide();
- self.load( self.anchors.index( this ) );
+ if ( doInsertAfter ) {
+ li.appendTo( this.tablist );
} else {
- throw "jQuery UI Tabs: Mismatching fragment identifier.";
+ li.insertBefore( this.tabs[ index ] );
}
- // Prevent IE from keeping other link focussed when using the back button
- // and remove dotted border from clicked link. This is controlled via CSS
- // in modern browsers; blur() removes focus from address bar in Firefox
- // which can become a usability and annoying problem with tabs('rotate').
- if ( $.browser.msie ) {
- this.blur();
+ options.disabled = $.map( options.disabled, function( n ) {
+ return n >= index ? ++n : n;
+ });
+
+ this.refresh();
+ if ( this.tabs.length === 1 && options.active === false ) {
+ this.option( "active", 0 );
}
- });
- // disable click in any case
- this.anchors.bind( "click.tabs", function(){
- return false;
- });
- },
+ this._trigger( "add", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
+ return this;
+ },
- _getIndex: function( index ) {
- // meta-function to give users option to provide a href string instead of a numerical index.
- // also sanitizes numerical indexes to valid values.
- if ( typeof index == "string" ) {
- index = this.anchors.index( this.anchors.filter( "[href$=" + index + "]" ) );
+ remove: function( index ) {
+ index = this._getIndex( index );
+ var options = this.options,
+ tab = this.tabs.eq( index ).remove(),
+ panel = this._getPanelForTab( tab ).remove();
+
+ // If selected tab was removed focus tab to the right or
+ // in case the last tab was removed the tab to the left.
+ // We check for more than 2 tabs, because if there are only 2,
+ // then when we remove this tab, there will only be one tab left
+ // so we don't need to detect which tab to activate.
+ if ( tab.hasClass( "ui-tabs-active" ) && this.anchors.length > 2 ) {
+ this._activate( index + ( index + 1 < this.anchors.length ? 1 : -1 ) );
+ }
+
+ options.disabled = $.map(
+ $.grep( options.disabled, function( n ) {
+ return n !== index;
+ }),
+ function( n ) {
+ return n >= index ? --n : n;
+ });
+
+ this.refresh();
+
+ this._trigger( "remove", null, this._ui( tab.find( "a" )[ 0 ], panel[ 0 ] ) );
+ return this;
}
+ });
- return index;
- },
+ // length method
+ $.widget( "ui.tabs", $.ui.tabs, {
+ length: function() {
+ return this.anchors.length;
+ }
+ });
- destroy: function() {
- var o = this.options;
+ // panel ids (idPrefix option + title attribute)
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ idPrefix: "ui-tabs-"
+ },
- this.abort();
+ _tabId: function( tab ) {
+ var a = tab.is( "li" ) ? tab.find( "a[href]" ) : tab;
+ a = a[0];
+ return $( a ).closest( "li" ).attr( "aria-controls" ) ||
+ a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF\-]/g, "" ) ||
+ this.options.idPrefix + getNextTabId();
+ }
+ });
- this.element
- .unbind( ".tabs" )
- .removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" )
- .removeData( "tabs" );
+ // _createPanel method
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ panelTemplate: "<div></div>"
+ },
- this.list.removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
+ _createPanel: function( id ) {
+ return $( this.options.panelTemplate )
+ .attr( "id", id )
+ .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
+ .data( "ui-tabs-destroy", true );
+ }
+ });
- this.anchors.each(function() {
- var href = $.data( this, "href.tabs" );
- if ( href ) {
- this.href = href;
+ // selected option
+ $.widget( "ui.tabs", $.ui.tabs, {
+ _create: function() {
+ var options = this.options;
+ if ( options.active === null && options.selected !== undefined ) {
+ options.active = options.selected === -1 ? false : options.selected;
}
- var $this = $( this ).unbind( ".tabs" );
- $.each( [ "href", "load", "cache" ], function( i, prefix ) {
- $this.removeData( prefix + ".tabs" );
- });
- });
+ this._super();
+ options.selected = options.active;
+ if ( options.selected === false ) {
+ options.selected = -1;
+ }
+ },
- this.lis.unbind( ".tabs" ).add( this.panels ).each(function() {
- if ( $.data( this, "destroy.tabs" ) ) {
- $( this ).remove();
- } else {
- $( this ).removeClass([
- "ui-state-default",
- "ui-corner-top",
- "ui-tabs-selected",
- "ui-state-active",
- "ui-state-hover",
- "ui-state-focus",
- "ui-state-disabled",
- "ui-tabs-panel",
- "ui-widget-content",
- "ui-corner-bottom",
- "ui-tabs-hide"
- ].join( " " ) );
+ _setOption: function( key, value ) {
+ if ( key !== "selected" ) {
+ return this._super( key, value );
}
- });
- if ( o.cookie ) {
- this._cookie( null, o.cookie );
+ var options = this.options;
+ this._super( "active", value === -1 ? false : value );
+ options.selected = options.active;
+ if ( options.selected === false ) {
+ options.selected = -1;
+ }
+ },
+
+ _eventHandler: function() {
+ this._superApply( arguments );
+ this.options.selected = this.options.active;
+ if ( this.options.selected === false ) {
+ this.options.selected = -1;
+ }
}
+ });
- return this;
- },
+ // show and select event
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ show: null,
+ select: null
+ },
+ _create: function() {
+ this._super();
+ if ( this.options.active !== false ) {
+ this._trigger( "show", null, this._ui(
+ this.active.find( ".ui-tabs-anchor" )[ 0 ],
+ this._getPanelForTab( this.active )[ 0 ] ) );
+ }
+ },
+ _trigger: function( type, event, data ) {
+ var tab, panel,
+ ret = this._superApply( arguments );
- add: function( url, label, index ) {
- if ( index === undefined ) {
- index = this.anchors.length;
+ if ( !ret ) {
+ return false;
+ }
+
+ if ( type === "beforeActivate" ) {
+ tab = data.newTab.length ? data.newTab : data.oldTab;
+ panel = data.newPanel.length ? data.newPanel : data.oldPanel;
+ ret = this._super( "select", event, {
+ tab: tab.find( ".ui-tabs-anchor" )[ 0],
+ panel: panel[ 0 ],
+ index: tab.closest( "li" ).index()
+ });
+ } else if ( type === "activate" && data.newTab.length ) {
+ ret = this._super( "show", event, {
+ tab: data.newTab.find( ".ui-tabs-anchor" )[ 0 ],
+ panel: data.newPanel[ 0 ],
+ index: data.newTab.closest( "li" ).index()
+ });
+ }
+ return ret;
}
+ });
- var self = this,
- o = this.options,
- $li = $( o.tabTemplate.replace( /#\{href\}/g, url ).replace( /#\{label\}/g, label ) ),
- id = !url.indexOf( "#" ) ? url.replace( "#", "" ) : this._tabId( $( "a", $li )[ 0 ] );
+ // select method
+ $.widget( "ui.tabs", $.ui.tabs, {
+ select: function( index ) {
+ index = this._getIndex( index );
+ if ( index === -1 ) {
+ if ( this.options.collapsible && this.options.selected !== -1 ) {
+ index = this.options.selected;
+ } else {
+ return;
+ }
+ }
+ this.anchors.eq( index ).trigger( this.options.event + this.eventNamespace );
+ }
+ });
- $li.addClass( "ui-state-default ui-corner-top" ).data( "destroy.tabs", true );
+ // cookie option
+ (function() {
- // try to find an existing element before creating a new one
- var $panel = self.element.find( "#" + id );
- if ( !$panel.length ) {
- $panel = $( o.panelTemplate )
- .attr( "id", id )
- .data( "destroy.tabs", true );
+ var listId = 0;
+
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ cookie: null // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true }
+ },
+ _create: function() {
+ var options = this.options,
+ active;
+ if ( options.active == null && options.cookie ) {
+ active = parseInt( this._cookie(), 10 );
+ if ( active === -1 ) {
+ active = false;
+ }
+ options.active = active;
+ }
+ this._super();
+ },
+ _cookie: function( active ) {
+ var cookie = [ this.cookie ||
+ ( this.cookie = this.options.cookie.name || "ui-tabs-" + (++listId) ) ];
+ if ( arguments.length ) {
+ cookie.push( active === false ? -1 : active );
+ cookie.push( this.options.cookie );
+ }
+ return $.cookie.apply( null, cookie );
+ },
+ _refresh: function() {
+ this._super();
+ if ( this.options.cookie ) {
+ this._cookie( this.options.active, this.options.cookie );
+ }
+ },
+ _eventHandler: function() {
+ this._superApply( arguments );
+ if ( this.options.cookie ) {
+ this._cookie( this.options.active, this.options.cookie );
+ }
+ },
+ _destroy: function() {
+ this._super();
+ if ( this.options.cookie ) {
+ this._cookie( null, this.options.cookie );
+ }
}
- $panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" );
+ });
- if ( index >= this.lis.length ) {
- $li.appendTo( this.list );
- $panel.appendTo( this.list[ 0 ].parentNode );
- } else {
- $li.insertBefore( this.lis[ index ] );
- $panel.insertBefore( this.panels[ index ] );
+ })();
+
+ // load event
+ $.widget( "ui.tabs", $.ui.tabs, {
+ _trigger: function( type, event, data ) {
+ var _data = $.extend( {}, data );
+ if ( type === "load" ) {
+ _data.panel = _data.panel[ 0 ];
+ _data.tab = _data.tab.find( ".ui-tabs-anchor" )[ 0 ];
+ }
+ return this._super( type, event, _data );
}
+ });
- o.disabled = $.map( o.disabled, function( n, i ) {
- return n >= index ? ++n : n;
- });
+ // fx option
+ // The new animation options (show, hide) conflict with the old show callback.
+ // The old fx option wins over show/hide anyway (always favor back-compat).
+ // If a user wants to use the new animation API, they must give up the old API.
+ $.widget( "ui.tabs", $.ui.tabs, {
+ options: {
+ fx: null // e.g. { height: "toggle", opacity: "toggle", duration: 200 }
+ },
- this._tabify();
+ _getFx: function() {
+ var hide, show,
+ fx = this.options.fx;
- if ( this.anchors.length == 1 ) {
- o.selected = 0;
- $li.addClass( "ui-tabs-selected ui-state-active" );
- $panel.removeClass( "ui-tabs-hide" );
- this.element.queue( "tabs", function() {
- self._trigger( "show", null, self._ui( self.anchors[ 0 ], self.panels[ 0 ] ) );
- });
+ if ( fx ) {
+ if ( $.isArray( fx ) ) {
+ hide = fx[ 0 ];
+ show = fx[ 1 ];
+ } else {
+ hide = show = fx;
+ }
+ }
+
+ return fx ? { show: show, hide: hide } : null;
+ },
+
+ _toggle: function( event, eventData ) {
+ var that = this,
+ toShow = eventData.newPanel,
+ toHide = eventData.oldPanel,
+ fx = this._getFx();
+
+ if ( !fx ) {
+ return this._super( event, eventData );
+ }
+
+ that.running = true;
- this.load( 0 );
+ function complete() {
+ that.running = false;
+ that._trigger( "activate", event, eventData );
+ }
+
+ function show() {
+ eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
+
+ if ( toShow.length && fx.show ) {
+ toShow
+ .animate( fx.show, fx.show.duration, function() {
+ complete();
+ });
+ } else {
+ toShow.show();
+ complete();
+ }
+ }
+
+ // start out by hiding, then showing, then completing
+ if ( toHide.length && fx.hide ) {
+ toHide.animate( fx.hide, fx.hide.duration, function() {
+ eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
+ show();
+ });
+ } else {
+ eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
+ toHide.hide();
+ show();
+ }
}
+ });
+}
- this._trigger( "add", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
- return this;
+})( jQuery );
+
+(function( $ ) {
+
+var increments = 0;
+
+function addDescribedBy( elem, id ) {
+ var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
+ describedby.push( id );
+ elem
+ .data( "ui-tooltip-id", id )
+ .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
+}
+
+function removeDescribedBy( elem ) {
+ var id = elem.data( "ui-tooltip-id" ),
+ describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
+ index = $.inArray( id, describedby );
+ if ( index !== -1 ) {
+ describedby.splice( index, 1 );
+ }
+
+ elem.removeData( "ui-tooltip-id" );
+ describedby = $.trim( describedby.join( " " ) );
+ if ( describedby ) {
+ elem.attr( "aria-describedby", describedby );
+ } else {
+ elem.removeAttr( "aria-describedby" );
+ }
+}
+
+$.widget( "ui.tooltip", {
+ version: "1.9.2",
+ options: {
+ content: function() {
+ return $( this ).attr( "title" );
+ },
+ hide: true,
+ // Disabled elements have inconsistent behavior across browsers (#8661)
+ items: "[title]:not([disabled])",
+ position: {
+ my: "left top+15",
+ at: "left bottom",
+ collision: "flipfit flip"
+ },
+ show: true,
+ tooltipClass: null,
+ track: false,
+
+ // callbacks
+ close: null,
+ open: null
},
- remove: function( index ) {
- index = this._getIndex( index );
- var o = this.options,
- $li = this.lis.eq( index ).remove(),
- $panel = this.panels.eq( index ).remove();
-
- // If selected tab was removed focus tab to the right or
- // in case the last tab was removed the tab to the left.
- if ( $li.hasClass( "ui-tabs-selected" ) && this.anchors.length > 1) {
- this.select( index + ( index + 1 < this.anchors.length ? 1 : -1 ) );
- }
-
- o.disabled = $.map(
- $.grep( o.disabled, function(n, i) {
- return n != index;
- }),
- function( n, i ) {
- return n >= index ? --n : n;
- });
+ _create: function() {
+ this._on({
+ mouseover: "open",
+ focusin: "open"
+ });
- this._tabify();
+ // IDs of generated tooltips, needed for destroy
+ this.tooltips = {};
+ // IDs of parent tooltips where we removed the title attribute
+ this.parents = {};
- this._trigger( "remove", null, this._ui( $li.find( "a" )[ 0 ], $panel[ 0 ] ) );
- return this;
+ if ( this.options.disabled ) {
+ this._disable();
+ }
},
- enable: function( index ) {
- index = this._getIndex( index );
- var o = this.options;
- if ( $.inArray( index, o.disabled ) == -1 ) {
+ _setOption: function( key, value ) {
+ var that = this;
+
+ if ( key === "disabled" ) {
+ this[ value ? "_disable" : "_enable" ]();
+ this.options[ key ] = value;
+ // disable element style changes
return;
}
- this.lis.eq( index ).removeClass( "ui-state-disabled" );
- o.disabled = $.grep( o.disabled, function( n, i ) {
- return n != index;
+ this._super( key, value );
+
+ if ( key === "content" ) {
+ $.each( this.tooltips, function( id, element ) {
+ that._updateContent( element );
+ });
+ }
+ },
+
+ _disable: function() {
+ var that = this;
+
+ // close open tooltips
+ $.each( this.tooltips, function( id, element ) {
+ var event = $.Event( "blur" );
+ event.target = event.currentTarget = element[0];
+ that.close( event, true );
});
- this._trigger( "enable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
- return this;
+ // remove title attributes to prevent native tooltips
+ this.element.find( this.options.items ).andSelf().each(function() {
+ var element = $( this );
+ if ( element.is( "[title]" ) ) {
+ element
+ .data( "ui-tooltip-title", element.attr( "title" ) )
+ .attr( "title", "" );
+ }
+ });
},
- disable: function( index ) {
- index = this._getIndex( index );
- var self = this, o = this.options;
- // cannot disable already selected tab
- if ( index != o.selected ) {
- this.lis.eq( index ).addClass( "ui-state-disabled" );
+ _enable: function() {
+ // restore title attributes
+ this.element.find( this.options.items ).andSelf().each(function() {
+ var element = $( this );
+ if ( element.data( "ui-tooltip-title" ) ) {
+ element.attr( "title", element.data( "ui-tooltip-title" ) );
+ }
+ });
+ },
- o.disabled.push( index );
- o.disabled.sort();
+ open: function( event ) {
+ var that = this,
+ target = $( event ? event.target : this.element )
+ // we need closest here due to mouseover bubbling,
+ // but always pointing at the same event target
+ .closest( this.options.items );
- this._trigger( "disable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
+ // No element to show a tooltip for or the tooltip is already open
+ if ( !target.length || target.data( "ui-tooltip-id" ) ) {
+ return;
}
- return this;
+ if ( target.attr( "title" ) ) {
+ target.data( "ui-tooltip-title", target.attr( "title" ) );
+ }
+
+ target.data( "ui-tooltip-open", true );
+
+ // kill parent tooltips, custom or native, for hover
+ if ( event && event.type === "mouseover" ) {
+ target.parents().each(function() {
+ var parent = $( this ),
+ blurEvent;
+ if ( parent.data( "ui-tooltip-open" ) ) {
+ blurEvent = $.Event( "blur" );
+ blurEvent.target = blurEvent.currentTarget = this;
+ that.close( blurEvent, true );
+ }
+ if ( parent.attr( "title" ) ) {
+ parent.uniqueId();
+ that.parents[ this.id ] = {
+ element: this,
+ title: parent.attr( "title" )
+ };
+ parent.attr( "title", "" );
+ }
+ });
+ }
+
+ this._updateContent( target, event );
},
- select: function( index ) {
- index = this._getIndex( index );
- if ( index == -1 ) {
- if ( this.options.collapsible && this.options.selected != -1 ) {
- index = this.options.selected;
- } else {
- return this;
+ _updateContent: function( target, event ) {
+ var content,
+ contentOption = this.options.content,
+ that = this,
+ eventType = event ? event.type : null;
+
+ if ( typeof contentOption === "string" ) {
+ return this._open( event, target, contentOption );
+ }
+
+ content = contentOption.call( target[0], function( response ) {
+ // ignore async response if tooltip was closed already
+ if ( !target.data( "ui-tooltip-open" ) ) {
+ return;
}
+ // IE may instantly serve a cached response for ajax requests
+ // delay this call to _open so the other call to _open runs first
+ that._delay(function() {
+ // jQuery creates a special event for focusin when it doesn't
+ // exist natively. To improve performance, the native event
+ // object is reused and the type is changed. Therefore, we can't
+ // rely on the type being correct after the event finished
+ // bubbling, so we set it back to the previous value. (#8740)
+ if ( event ) {
+ event.type = eventType;
+ }
+ this._open( event, target, response );
+ });
+ });
+ if ( content ) {
+ this._open( event, target, content );
}
- this.anchors.eq( index ).trigger( this.options.event + ".tabs" );
- return this;
},
- load: function( index ) {
- index = this._getIndex( index );
- var self = this,
- o = this.options,
- a = this.anchors.eq( index )[ 0 ],
- url = $.data( a, "load.tabs" );
-
- this.abort();
+ _open: function( event, target, content ) {
+ var tooltip, events, delayedShow,
+ positionOption = $.extend( {}, this.options.position );
- // not remote or from cache
- if ( !url || this.element.queue( "tabs" ).length !== 0 && $.data( a, "cache.tabs" ) ) {
- this.element.dequeue( "tabs" );
+ if ( !content ) {
return;
}
- // load remote from here on
- this.lis.eq( index ).addClass( "ui-state-processing" );
-
- if ( o.spinner ) {
- var span = $( "span", a );
- span.data( "label.tabs", span.html() ).html( o.spinner );
+ // 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;
}
- this.xhr = $.ajax( $.extend( {}, o.ajaxOptions, {
- url: url,
- success: function( r, s ) {
- self.element.find( self._sanitizeSelector( a.hash ) ).html( r );
+ // 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])
+ //
+ // We use removeAttr only for key events, to allow IE to export the correct
+ // accessible attributes. For mouse events, set to empty string to avoid
+ // native tooltip showing up (happens only when removing inside mouseover).
+ if ( target.is( "[title]" ) ) {
+ if ( event && event.type === "mouseover" ) {
+ target.attr( "title", "" );
+ } else {
+ target.removeAttr( "title" );
+ }
+ }
- // take care of tab labels
- self._cleanup();
+ tooltip = this._tooltip( target );
+ addDescribedBy( target, tooltip.attr( "id" ) );
+ tooltip.find( ".ui-tooltip-content" ).html( content );
- if ( o.cache ) {
- $.data( a, "cache.tabs", true );
+ function position( event ) {
+ positionOption.of = event;
+ if ( tooltip.is( ":hidden" ) ) {
+ return;
+ }
+ tooltip.position( positionOption );
+ }
+ if ( this.options.track && event && /^mouse/.test( event.type ) ) {
+ this._on( this.document, {
+ mousemove: position
+ });
+ // trigger once to override element-relative positioning
+ position( event );
+ } else {
+ tooltip.position( $.extend({
+ of: target
+ }, this.options.position ) );
+ }
+
+ tooltip.hide();
+
+ this._show( tooltip, this.options.show );
+ // Handle tracking tooltips that are shown with a delay (#8644). As soon
+ // as the tooltip is visible, position the tooltip using the most recent
+ // event.
+ if ( this.options.show && this.options.show.delay ) {
+ delayedShow = setInterval(function() {
+ if ( tooltip.is( ":visible" ) ) {
+ position( positionOption.of );
+ clearInterval( delayedShow );
}
+ }, $.fx.interval );
+ }
- self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
- try {
- o.ajaxOptions.success( r, s );
- }
- catch ( e ) {}
- },
- error: function( xhr, s, e ) {
- // take care of tab labels
- self._cleanup();
+ this._trigger( "open", event, { tooltip: tooltip } );
- self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) );
- try {
- // Passing index avoid a race condition when this method is
- // called after the user has selected another tab.
- // Pass the anchor that initiated this request allows
- // loadError to manipulate the tab content panel via $(a.hash)
- o.ajaxOptions.error( xhr, s, index, a );
+ events = {
+ keyup: function( event ) {
+ if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
+ var fakeEvent = $.Event(event);
+ fakeEvent.currentTarget = target[0];
+ this.close( fakeEvent, true );
}
- catch ( e ) {}
+ },
+ remove: function() {
+ this._removeTooltip( tooltip );
}
- } ) );
+ };
+ if ( !event || event.type === "mouseover" ) {
+ events.mouseleave = "close";
+ }
+ if ( !event || event.type === "focusin" ) {
+ events.focusout = "close";
+ }
+ this._on( true, target, events );
+ },
- // last, so that load event is fired before show...
- self.element.dequeue( "tabs" );
+ close: function( event ) {
+ var that = this,
+ target = $( event ? event.currentTarget : this.element ),
+ tooltip = this._find( target );
- return this;
- },
+ // disabling closes the tooltip, so we need to track when we're closing
+ // to avoid an infinite loop in case the tooltip becomes disabled on close
+ if ( this.closing ) {
+ return;
+ }
- abort: function() {
- // stop possibly running animations
- this.element.queue( [] );
- this.panels.stop( false, true );
+ // only set title if we had one before (see comment in _open())
+ if ( target.data( "ui-tooltip-title" ) ) {
+ target.attr( "title", target.data( "ui-tooltip-title" ) );
+ }
- // "tabs" queue must not contain more than two elements,
- // which are the callbacks for the latest clicked tab...
- this.element.queue( "tabs", this.element.queue( "tabs" ).splice( -2, 2 ) );
+ removeDescribedBy( target );
- // terminate pending requests from other tabs
- if ( this.xhr ) {
- this.xhr.abort();
- delete this.xhr;
+ tooltip.stop( true );
+ this._hide( tooltip, this.options.hide, function() {
+ that._removeTooltip( $( this ) );
+ });
+
+ target.removeData( "ui-tooltip-open" );
+ this._off( target, "mouseleave focusout keyup" );
+ // Remove 'remove' binding only on delegated targets
+ if ( target[0] !== this.element[0] ) {
+ this._off( target, "remove" );
}
+ this._off( this.document, "mousemove" );
- // take care of tab labels
- this._cleanup();
- return this;
+ if ( event && event.type === "mouseleave" ) {
+ $.each( this.parents, function( id, parent ) {
+ $( parent.element ).attr( "title", parent.title );
+ delete that.parents[ id ];
+ });
+ }
+
+ this.closing = true;
+ this._trigger( "close", event, { tooltip: tooltip } );
+ this.closing = false;
},
- url: function( index, url ) {
- this.anchors.eq( index ).removeData( "cache.tabs" ).data( "load.tabs", url );
- return this;
+ _tooltip: function( element ) {
+ var id = "ui-tooltip-" + increments++,
+ tooltip = $( "<div>" )
+ .attr({
+ id: id,
+ role: "tooltip"
+ })
+ .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
+ ( this.options.tooltipClass || "" ) );
+ $( "<div>" )
+ .addClass( "ui-tooltip-content" )
+ .appendTo( tooltip );
+ tooltip.appendTo( this.document[0].body );
+ if ( $.fn.bgiframe ) {
+ tooltip.bgiframe();
+ }
+ this.tooltips[ id ] = element;
+ return tooltip;
},
- length: function() {
- return this.anchors.length;
- }
-});
+ _find: function( target ) {
+ var id = target.data( "ui-tooltip-id" );
+ return id ? $( "#" + id ) : $();
+ },
-$.extend( $.ui.tabs, {
- version: "1.8.16"
-});
+ _removeTooltip: function( tooltip ) {
+ tooltip.remove();
+ delete this.tooltips[ tooltip.attr( "id" ) ];
+ },
-/*
- * Tabs Extensions
- */
+ _destroy: function() {
+ var that = this;
-/*
- * Rotate
- */
-$.extend( $.ui.tabs.prototype, {
- rotation: null,
- rotate: function( ms, continuing ) {
- var self = this,
- o = this.options;
+ // close open tooltips
+ $.each( this.tooltips, function( id, element ) {
+ // Delegate to close method to handle common cleanup
+ var event = $.Event( "blur" );
+ event.target = event.currentTarget = element[0];
+ that.close( event, true );
- var rotate = self._rotate || ( self._rotate = function( e ) {
- clearTimeout( self.rotation );
- self.rotation = setTimeout(function() {
- var t = o.selected;
- self.select( ++t < self.anchors.length ? t : 0 );
- }, ms );
-
- if ( e ) {
- e.stopPropagation();
- }
- });
+ // Remove immediately; destroying an open tooltip doesn't use the
+ // hide animation
+ $( "#" + id ).remove();
- var stop = self._unrotate || ( self._unrotate = !continuing
- ? function(e) {
- if (e.clientX) { // in case of a true click
- self.rotate(null);
- }
+ // Restore the title
+ if ( element.data( "ui-tooltip-title" ) ) {
+ element.attr( "title", element.data( "ui-tooltip-title" ) );
+ element.removeData( "ui-tooltip-title" );
}
- : function( e ) {
- t = o.selected;
- rotate();
- });
-
- // start rotation
- if ( ms ) {
- this.element.bind( "tabsshow", rotate );
- this.anchors.bind( o.event + ".tabs", stop );
- rotate();
- // stop rotation
- } else {
- clearTimeout( self.rotation );
- this.element.unbind( "tabsshow", rotate );
- this.anchors.unbind( o.event + ".tabs", stop );
- delete this._rotate;
- delete this._unrotate;
- }
-
- return this;
+ });
}
});
-})( jQuery );
+}( jQuery ) );