The branch, master has been updated via d424a797d5dd9e25a3c4a0923d45efdcf9005981 (commit) via ac365e0262fa2323dc830bb563e8e97de3694781 (commit) from 4cef030dd4372e22f9ee791189b84bf0e68a6b77 (commit)
- Log ----------------------------------------------------------------- commit d424a797d5dd9e25a3c4a0923d45efdcf9005981 Author: Piotr Przybylski piotrprz@gmail.com Date: Mon Oct 10 22:37:27 2011 +0200
Make Create table dialog take up entire viewport The only scrollbars that now appear should be the ones around dialog's content
commit ac365e0262fa2323dc830bb563e8e97de3694781 Author: Piotr Przybylski piotrprz@gmail.com Date: Mon Oct 10 22:35:36 2011 +0200
Upgrade jQuery UI to 1.8.6
-----------------------------------------------------------------------
Summary of changes: db_create.php | 2 +- db_events.php | 2 +- db_operations.php | 2 +- db_routines.php | 2 +- db_structure.php | 2 +- db_tracking.php | 2 +- db_triggers.php | 2 +- js/functions.js | 53 +- ...-ui-1.8.custom.js => jquery-ui-1.8.6.custom.js} | 4610 ++++++++++++-------- libraries/common.inc.php | 2 +- libraries/header_meta_style.inc.php | 2 +- main.php | 2 +- navigation.php | 2 +- server_plugins.php | 2 +- server_privileges.php | 2 +- server_status.php | 2 +- setup/index.php | 2 +- sql.php | 2 +- tbl_change.php | 2 +- tbl_operations.php | 2 +- tbl_replace.php | 2 +- tbl_select.php | 2 +- tbl_structure.php | 2 +- tbl_zoom_select.php | 2 +- themes/original/css/theme_right.css.php | 4 + ...-1.8.custom.css => jquery-ui-1.8.16.custom.css} | 240 +- themes/pmahomme/css/theme_right.css.php | 4 + .../jquery/images/ui-bg_flat_0_aaaaaa_40x100.png | Bin 87 -> 180 bytes .../jquery/images/ui-bg_flat_75_ffffff_40x100.png | Bin 87 -> 178 bytes .../jquery/images/ui-bg_glass_65_ffffff_1x400.png | Bin 99 -> 105 bytes .../ui-bg_highlight-soft_75_cccccc_1x100.png | Bin 86 -> 101 bytes .../jquery/images/ui-icons_222222_256x240.png | Bin 4193 -> 4369 bytes .../jquery/images/ui-icons_2e83ff_256x240.png | Bin 4193 -> 4369 bytes .../jquery/images/ui-icons_454545_256x240.png | Bin 4193 -> 4369 bytes .../jquery/images/ui-icons_888888_256x240.png | Bin 4193 -> 4369 bytes .../jquery/images/ui-icons_cd0a0a_256x240.png | Bin 4193 -> 4369 bytes ...-1.8.custom.css => jquery-ui-1.8.16.custom.css} | 240 +- 37 files changed, 3136 insertions(+), 2059 deletions(-) rename js/jquery/{jquery-ui-1.8.custom.js => jquery-ui-1.8.6.custom.js} (73%) rename themes/original/jquery/{jquery-ui-1.8.custom.css => jquery-ui-1.8.16.custom.css} (71%) rename themes/pmahomme/jquery/{jquery-ui-1.8.custom.css => jquery-ui-1.8.16.custom.css} (71%)
diff --git a/db_create.php b/db_create.php index 3548f8f..c4465b0 100644 --- a/db_create.php +++ b/db_create.php @@ -10,7 +10,7 @@ */ require_once './libraries/common.inc.php'; $GLOBALS['js_include'][] = 'functions.js'; -$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js'; +$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.6.custom.js';
require_once './libraries/mysql_charsets.lib.php'; if (!PMA_DRIZZLE) { diff --git a/db_events.php b/db_events.php index 9991f83..e08663d 100644 --- a/db_events.php +++ b/db_events.php @@ -15,7 +15,7 @@ require_once './libraries/common.lib.php'; /** * Include JavaScript libraries */ -$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js'; +$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.6.custom.js'; $GLOBALS['js_include'][] = 'jquery/timepicker.js'; $GLOBALS['js_include'][] = 'rte/common.js'; $GLOBALS['js_include'][] = 'rte/events.js'; diff --git a/db_operations.php b/db_operations.php index fa0f108..9a4c7ff 100644 --- a/db_operations.php +++ b/db_operations.php @@ -23,7 +23,7 @@ require_once "./libraries/blobstreaming.lib.php";
// add a javascript file for jQuery functions to handle Ajax actions // also add jQueryUI -$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js'; +$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.6.custom.js'; $GLOBALS['js_include'][] = 'db_operations.js';
/** diff --git a/db_routines.php b/db_routines.php index da92c22..004d372 100644 --- a/db_routines.php +++ b/db_routines.php @@ -21,7 +21,7 @@ if (PMA_DRIZZLE) { /** * Include JavaScript libraries */ -$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js'; +$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.6.custom.js'; $GLOBALS['js_include'][] = 'jquery/timepicker.js'; $GLOBALS['js_include'][] = 'rte/common.js'; $GLOBALS['js_include'][] = 'rte/routines.js'; diff --git a/db_structure.php b/db_structure.php index faa5e02..897a664 100644 --- a/db_structure.php +++ b/db_structure.php @@ -10,7 +10,7 @@ */ require_once './libraries/common.inc.php';
-$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js'; +$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.6.custom.js'; $GLOBALS['js_include'][] = 'db_structure.js'; $GLOBALS['js_include'][] = 'tbl_change.js'; $GLOBALS['js_include'][] = 'jquery/timepicker.js'; diff --git a/db_tracking.php b/db_tracking.php index 2f5645a..89bcca2 100644 --- a/db_tracking.php +++ b/db_tracking.php @@ -10,7 +10,7 @@ require_once './libraries/common.inc.php';
//Get some js files needed for Ajax requests -$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js'; +$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.6.custom.js'; $GLOBALS['js_include'][] = 'db_structure.js';
/** diff --git a/db_triggers.php b/db_triggers.php index 4911f36..b9f3562 100644 --- a/db_triggers.php +++ b/db_triggers.php @@ -15,7 +15,7 @@ require_once './libraries/common.lib.php'; /** * Include JavaScript libraries */ -$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js'; +$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.6.custom.js'; $GLOBALS['js_include'][] = 'rte/common.js'; $GLOBALS['js_include'][] = 'rte/triggers.js'; $GLOBALS['js_include'][] = 'codemirror/lib/codemirror.js'; diff --git a/js/functions.js b/js/functions.js index f9a2494..e8b869d 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1433,6 +1433,8 @@ function PMA_ajaxRemoveMessage($this_msgbox) // due to a bug in qtip's implementation we can // only hide it without throwing JS errors. $this_msgbox.qtip('hide'); + } else { + $this_msgbox.remove(); } } } @@ -1485,10 +1487,10 @@ function PMA_createTableDialog( div, url , target) */ var button_options = {}; // in the following function we need to use $(this) - button_options[PMA_messages['strCancel']] = function() {$(this).parent().dialog('close').remove();} + button_options[PMA_messages['strCancel']] = function() {$(this).closest('.ui-dialog-content').dialog('close').remove();}
var button_options_error = {}; - button_options_error[PMA_messages['strOK']] = function() {$(this).parent().dialog('close').remove();} + button_options_error[PMA_messages['strOK']] = function() {$(this).closest('.ui-dialog-content').dialog('close').remove();}
var $msgbox = PMA_ajaxShowMessage();
@@ -1507,23 +1509,52 @@ function PMA_createTableDialog( div, url , target) //remove the redundant [Back] link in the error message. .find('fieldset').remove(); } else { + var timeout; div .append(data) .dialog({ title: PMA_messages['strCreateTable'], - /* - * Use a little less than the current value, otherwise there is i - * some overlap; 16 is a value found by experimenting - */ - height: $(window.document).height() - 16, - width: $(window.document).width() - 16, - open: PMA_verifyTypeOfAllColumns, - buttons : button_options + resizable: false, + draggable: false, + modal: true, + stack: false, + position: ['left','top'], + width: window.innerWidth-10, + height: window.innerHeight-10, + open: function(event) { + $(window).bind('resize.dialog-resizer', function() { + clearTimeout(timeout); + timeout = setTimeout(function() { + $(this).dialog('option', { + width: window.innerWidth-10, + height: window.innerHeight-10 + }); + }, 50); + }); + + var $wrapper = $('<div>', {'id': 'content-hide'}).hide(); + $('body > *:not(.ui-dialog)').wrapAll($wrapper); + + $(this).closest('.ui-dialog').css({ + left: 0, + top: 0 + }); + + // for Chrome + $(this).scrollTop(0); + + PMA_verifyTypeOfAllColumns(); + }, + close: function() { + $(window).unbind('resize.dialog-resizer'); + $('#content-hide > *').unwrap(); + }, + buttons: button_options }); // end dialog options } PMA_convertFootnotesToTooltips($(div)); PMA_ajaxRemoveMessage($msgbox); - }) // end $.get() + }); // end $.get()
}
diff --git a/js/jquery/jquery-ui-1.8.custom.js b/js/jquery/jquery-ui-1.8.6.custom.js similarity index 73% rename from js/jquery/jquery-ui-1.8.custom.js rename to js/jquery/jquery-ui-1.8.6.custom.js index 1c7f364..fc8d9d1 100644 --- a/js/jquery/jquery-ui-1.8.custom.js +++ b/js/jquery/jquery-ui-1.8.6.custom.js @@ -1,78 +1,33 @@ /*! - * jQuery UI 1.8 + * jQuery UI 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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 || (function($) { +(function( $, undefined ) {
-//Helper functions and ui object -$.ui = { - version: "1.8", - - // $.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) { - 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) { return; } - - for (var i = 0; i < set.length; i++) { - if (instance.options[set[i][0]]) { - set[i][1].apply(instance.element, args); - } - } - } - }, - - contains: function(a, b) { - return document.compareDocumentPosition - ? a.compareDocumentPosition(b) & 16 - : a !== b && a.contains(b); - }, - - 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 - el[scroll] = 1; - has = (el[scroll] > 0); - el[scroll] = 0; - return has; - }, - - isOverAxis: function(x, reference, size) { - //Determines when x coordinate is over "b" element axis - return (x > reference) && (x < (reference + size)); - }, +// prevent duplicate loading +// this is only a problem because we proxy existing functions +// and we don't want to double proxy them +$.ui = $.ui || {}; +if ( $.ui.version ) { + return; +}
- isOver: function(y, x, top, left, height, width) { - //Determines when x, y coordinates is over "b" element - return $.ui.isOverAxis(y, top, height) && $.ui.isOverAxis(x, left, width); - }, +$.extend( $.ui, { + version: "1.8.16",
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, @@ -82,6 +37,7 @@ $.ui = { HOME: 36, INSERT: 45, LEFT: 37, + MENU: 93, // COMMAND_RIGHT NUMPAD_ADD: 107, NUMPAD_DECIMAL: 110, NUMPAD_DIVIDE: 111, @@ -95,42 +51,33 @@ $.ui = { SHIFT: 16, SPACE: 32, TAB: 9, - UP: 38 + UP: 38, + WINDOWS: 91 // COMMAND } -}; +});
-//jQuery plugins +// plugins $.fn.extend({ + propAttr: $.fn.prop || $.fn.attr, + _focus: $.fn.focus, - focus: function(delay, fn) { - return typeof delay === 'number' - ? this.each(function() { + focus: function( delay, fn ) { + return typeof delay === "number" ? + this.each(function() { var elem = this; setTimeout(function() { - $(elem).focus(); - (fn && fn.call(elem)); - }, delay); - }) - : this._focus.apply(this, arguments); - }, - - enableSelection: function() { - return this - .attr('unselectable', 'off') - .css('MozUserSelect', '') - .unbind('selectstart.ui'); - }, - - disableSelection: function() { - return this - .attr('unselectable', 'on') - .css('MozUserSelect', 'none') - .bind('selectstart.ui', function() { return false; }); + $( elem ).focus(); + if ( fn ) { + fn.call( elem ); + } + }, delay ); + }) : + this._focus.apply( this, arguments ); },
scrollParent: function() { var scrollParent; - if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) { + if (($.browser.msie && (/(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)); }).eq(0); @@ -143,26 +90,25 @@ $.fn.extend({ return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent; },
- zIndex: function(zIndex) { - if (zIndex !== undefined) { - return this.css('zIndex', zIndex); + zIndex: function( zIndex ) { + if ( zIndex !== undefined ) { + return this.css( "zIndex", zIndex ); } - - if (this.length) { - var elem = $(this[0]), position, value; - while (elem.length && elem[0] !== document) { + + if ( this.length ) { + var elem = $( this[ 0 ] ), position, value; + while ( elem.length && elem[ 0 ] !== document ) { // Ignore z-index if position is set to a value where z-index is ignored by the browser // This makes behavior of this function consistent across browsers // WebKit always returns auto if the element is positioned - position = elem.css('position'); - if (position == 'absolute' || position == 'relative' || position == 'fixed') - { + position = elem.css( "position" ); + if ( position === "absolute" || position === "relative" || position === "fixed" ) { // IE returns 0 when zIndex is not specified // other browsers return a string // we ignore the case of nested elements with an explicit value of 0 // <div style="z-index: -10;"><div style="z-index: 0;"></div></div> - value = parseInt(elem.css('zIndex')); - if (!isNaN(value) && value != 0) { + value = parseInt( elem.css( "zIndex" ), 10 ); + if ( !isNaN( value ) && value !== 0 ) { return value; } } @@ -171,61 +117,242 @@ $.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 ); + } + + 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" ); + }); + }; });
+// selectors +function focusable( element, isTabIndexNotNaN ) { + var nodeName = element.nodeName.toLowerCase(); + if ( "area" === nodeName ) { + var map = element.parentNode, + mapName = map.name, + img; + 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) + // the element and all of its ancestors must be visible + && visible( element ); +} + +function visible( element ) { + return !$( element ).parents().andSelf().filter(function() { + return $.curCSS( this, "visibility" ) === "hidden" || + $.expr.filters.hidden( this ); + }).length; +}
-//Additional selectors -$.extend($.expr[':'], { - data: function(elem, i, match) { - return !!$.data(elem, match[3]); +$.extend( $.expr[ ":" ], { + data: function( elem, i, match ) { + return !!$.data( elem, match[ 3 ] ); },
- focusable: function(element) { - var nodeName = element.nodeName.toLowerCase(), - tabIndex = $.attr(element, 'tabindex'); - return (/input|select|textarea|button|object/.test(nodeName) - ? !element.disabled - : 'a' == nodeName || 'area' == nodeName - ? element.href || !isNaN(tabIndex) - : !isNaN(tabIndex)) - // the element and all of its ancestors must be visible - // the browser may report that the area is hidden - && !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length; + focusable: function( element ) { + return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) ); },
- tabbable: function(element) { - var tabIndex = $.attr(element, 'tabindex'); - return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable'); + tabbable: function( element ) { + var tabIndex = $.attr( element, "tabindex" ), + isTabIndexNaN = isNaN( tabIndex ); + return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN ); } });
-})(jQuery); +// support +$(function() { + var body = document.body, + div = body.appendChild( div = document.createElement( "div" ) ); + + $.extend( div.style, { + minHeight: "100px", + height: "auto", + padding: 0, + borderWidth: 0 + }); + + $.support.minHeight = div.offsetHeight === 100; + $.support.selectstart = "onselectstart" in div; + + // set display to none to avoid a layout bug in IE + // http://dev.jquery.com/ticket/4014 + body.removeChild( div ).style.display = "none"; +}); + + + + + +// deprecated +$.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 ) { + 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 ) { + return; + } + + for ( var 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 ); + }, + + // 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 + el[ scroll ] = 1; + has = ( el[ scroll ] > 0 ); + 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 + return ( x > reference ) && ( x < ( reference + size ) ); + }, + isOver: function( y, x, top, left, height, width ) { + //Determines when x, y coordinates is over "b" element + return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width ); + } +}); + +})( jQuery ); /*! - * jQuery UI Widget 1.8 + * jQuery UI Widget 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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( $ ) { - -var _remove = $.fn.remove; +(function( $, undefined ) {
-$.fn.remove = function( selector, keepData ) { - return this.each(function() { - if ( !keepData ) { - if ( !selector || $.filter( selector, [ this ] ).length ) { - $( "*", this ).add( this ).each(function() { - $( this ).triggerHandler( "remove" ); - }); - } +// 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 ) {} } - return _remove.call( $(this), selector, keepData ); - }); -}; + _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 ); + }); + }; +}
$.widget = function( name, base, prototype ) { var namespace = name.split( "." )[ 0 ], @@ -260,7 +387,7 @@ $.widget = function( name, base, prototype ) { // basePrototype[ key ] = $.extend( {}, val ); // } // }); - basePrototype.options = $.extend( {}, basePrototype.options ); + basePrototype.options = $.extend( true, {}, basePrototype.options ); $[ namespace ][ name ].prototype = $.extend( true, basePrototype, { namespace: namespace, widgetName: name, @@ -283,7 +410,7 @@ $.widget.bridge = function( name, object ) { options;
// prevent calls to internal methods - if ( isMethodCall && options.substring( 0, 1 ) === "_" ) { + if ( isMethodCall && options.charAt( 0 ) === "_" ) { return returnValue; }
@@ -293,6 +420,15 @@ $.widget.bridge = function( name, object ) { 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 ); if ( methodValue !== instance && methodValue !== undefined ) { returnValue = methodValue; return false; @@ -302,10 +438,7 @@ $.widget.bridge = function( name, object ) { this.each(function() { var instance = $.data( this, name ); if ( instance ) { - if ( options ) { - instance.option( options ); - } - instance._init(); + instance.option( options || {} )._init(); } else { $.data( this, name, new object( options, this ) ); } @@ -332,10 +465,11 @@ $.Widget.prototype = { _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 - this.element = $( element ).data( this.widgetName, this ); + $.data( element, this.widgetName, this ); + this.element = $( element ); this.options = $.extend( true, {}, this.options, - $.metadata && $.metadata.get( element )[ this.widgetName ], + this._getCreateOptions(), options );
var self = this; @@ -344,8 +478,12 @@ $.Widget.prototype = { });
this._create(); + this._trigger( "create" ); this._init(); }, + _getCreateOptions: function() { + return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ]; + }, _create: function() {}, _init: function() {},
@@ -358,7 +496,7 @@ $.Widget.prototype = { .removeAttr( "aria-disabled" ) .removeClass( this.widgetBaseClass + "-disabled " + - this.namespace + "-state-disabled" ); + "ui-state-disabled" ); },
widget: function() { @@ -366,12 +504,11 @@ $.Widget.prototype = { },
option: function( key, value ) { - var options = key, - self = this; + var options = key;
if ( arguments.length === 0 ) { // don't return a reference to the internal hash - return $.extend( {}, self.options ); + return $.extend( {}, this.options ); }
if (typeof key === "string" ) { @@ -382,11 +519,17 @@ $.Widget.prototype = { options[ key ] = value; }
+ this._setOptions( options ); + + return this; + }, + _setOptions: function( options ) { + var self = this; $.each( options, function( key, value ) { self._setOption( key, value ); });
- return self; + return this; }, _setOption: function( key, value ) { this.options[ key ] = value; @@ -395,7 +538,7 @@ $.Widget.prototype = { this.widget() [ value ? "addClass" : "removeClass"]( this.widgetBaseClass + "-disabled" + " " + - this.namespace + "-state-disabled" ) + "ui-state-disabled" ) .attr( "aria-disabled", value ); }
@@ -438,18 +581,23 @@ $.Widget.prototype = {
})( jQuery ); /*! - * jQuery UI Mouse 1.8 + * jQuery UI Mouse 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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($) { +(function( $, undefined ) { + +var mouseHandled = false; +$( document ).mouseup( function( e ) { + mouseHandled = false; +});
$.widget("ui.mouse", { options: { @@ -465,8 +613,8 @@ $.widget("ui.mouse", { return self._mouseDown(event); }) .bind('click.'+this.widgetName, function(event) { - if(self._preventClickEvent) { - self._preventClickEvent = false; + if (true === $.data(event.target, self.widgetName + '.preventClickEvent')) { + $.removeData(event.target, self.widgetName + '.preventClickEvent'); event.stopImmediatePropagation(); return false; } @@ -483,9 +631,7 @@ $.widget("ui.mouse", {
_mouseDown: function(event) { // don't let more than one widget handle mouseStart - // TODO: figure out why we have to use originalEvent - event.originalEvent = event.originalEvent || {}; - if (event.originalEvent.mouseHandled) { return; } + if( mouseHandled ) { return };
// we may have missed mouseup (out of window) (this._mouseStarted && this._mouseUp(event)); @@ -494,7 +640,9 @@ $.widget("ui.mouse", {
var self = this, btnIsLeft = (event.which == 1), - elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false); + // 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); if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { return true; } @@ -514,6 +662,11 @@ $.widget("ui.mouse", { } }
+ // Click event may never have fired (Gecko & Opera) + if (true === $.data(event.target, this.widgetName + '.preventClickEvent')) { + $.removeData(event.target, this.widgetName + '.preventClickEvent'); + } + // these delegates are required to keep context this._mouseMoveDelegate = function(event) { return self._mouseMove(event); @@ -525,18 +678,15 @@ $.widget("ui.mouse", { .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate) .bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
- // preventDefault() is used to prevent the selection of text here - - // however, in Safari, this causes select boxes not to be selectable - // anymore, so this fix is needed - ($.browser.safari || event.preventDefault()); - - event.originalEvent.mouseHandled = true; + event.preventDefault(); + + mouseHandled = true; return true; },
_mouseMove: function(event) { // IE mouseup check - mouseup happened when mouse was out of window - if ($.browser.msie && !event.button) { + if ($.browser.msie && !(document.documentMode >= 9) && !event.button) { return this._mouseUp(event); }
@@ -561,7 +711,11 @@ $.widget("ui.mouse", {
if (this._mouseStarted) { this._mouseStarted = false; - this._preventClickEvent = (event.target == this._mouseDownEvent.target); + + if (event.target == this._mouseDownEvent.target) { + $.data(event.target, this.widgetName + '.preventClickEvent', true); + } + this._mouseStop(event); }
@@ -589,22 +743,21 @@ $.widget("ui.mouse", {
})(jQuery); /* - * jQuery UI Position 1.8 + * jQuery UI Position 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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 */ -(function( $ ) { +(function( $, undefined ) {
$.ui = $.ui || {};
var horizontalPositions = /left|center|right/, - horizontalDefault = "center", verticalPositions = /top|center|bottom/, - verticalDefault = "center", + center = "center", _position = $.fn.position, _offset = $.fn.offset;
@@ -617,21 +770,23 @@ $.fn.position = function( options ) { options = $.extend( {}, options );
var target = $( options.of ), + targetElem = target[0], collision = ( options.collision || "flip" ).split( " " ), offset = options.offset ? options.offset.split( " " ) : [ 0, 0 ], targetWidth, targetHeight, basePosition;
- if ( options.of.nodeType === 9 ) { + if ( targetElem.nodeType === 9 ) { targetWidth = target.width(); targetHeight = target.height(); basePosition = { top: 0, left: 0 }; - } else if ( options.of.scrollTo && options.of.document ) { + // TODO: use $.isWindow() in 1.9 + } else if ( targetElem.setTimeout ) { targetWidth = target.width(); targetHeight = target.height(); basePosition = { top: target.scrollTop(), left: target.scrollLeft() }; - } else if ( options.of.preventDefault ) { + } else if ( targetElem.preventDefault ) { // force left top to allow flipping options.at = "left top"; targetWidth = targetHeight = 0; @@ -648,13 +803,13 @@ $.fn.position = function( options ) { var pos = ( options[this] || "" ).split( " " ); if ( pos.length === 1) { pos = horizontalPositions.test( pos[0] ) ? - pos.concat( [verticalDefault] ) : + pos.concat( [center] ) : verticalPositions.test( pos[0] ) ? - [ horizontalDefault ].concat( pos ) : - [ horizontalDefault, verticalDefault ]; + [ center ].concat( pos ) : + [ center, center ]; } - pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : horizontalDefault; - pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : verticalDefault; + pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : center; + pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : center; options[ this ] = pos; });
@@ -672,13 +827,13 @@ $.fn.position = function( options ) {
if ( options.at[0] === "right" ) { basePosition.left += targetWidth; - } else if (options.at[0] === horizontalDefault ) { + } else if ( options.at[0] === center ) { basePosition.left += targetWidth / 2; }
if ( options.at[1] === "bottom" ) { basePosition.top += targetHeight; - } else if ( options.at[1] === verticalDefault ) { + } else if ( options.at[1] === center ) { basePosition.top += targetHeight / 2; }
@@ -689,20 +844,36 @@ $.fn.position = function( options ) { var elem = $( this ), elemWidth = elem.outerWidth(), elemHeight = elem.outerHeight(), - position = $.extend( {}, basePosition ); + 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 ), + position = $.extend( {}, basePosition ), + collisionPosition;
if ( options.my[0] === "right" ) { position.left -= elemWidth; - } else if ( options.my[0] === horizontalDefault ) { + } else if ( options.my[0] === center ) { position.left -= elemWidth / 2; }
if ( options.my[1] === "bottom" ) { position.top -= elemHeight; - } else if ( options.my[1] === verticalDefault ) { + } 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 ); + + collisionPosition = { + left: position.left - marginLeft, + top: position.top - marginTop + }; + $.each( [ "left", "top" ], function( i, dir ) { if ( $.ui.position[ collision[i] ] ) { $.ui.position[ collision[i] ][ dir ]( position, { @@ -710,6 +881,9 @@ $.fn.position = function( options ) { targetHeight: targetHeight, elemWidth: elemWidth, elemHeight: elemHeight, + collisionPosition: collisionPosition, + collisionWidth: collisionWidth, + collisionHeight: collisionHeight, offset: offset, my: options.my, at: options.at @@ -728,41 +902,44 @@ $.ui.position = { fit: { left: function( position, data ) { var win = $( window ), - over = position.left + data.elemWidth - win.width() - win.scrollLeft(); - position.left = over > 0 ? position.left - over : Math.max( 0, position.left ); + 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 ); }, top: function( position, data ) { var win = $( window ), - over = position.top + data.elemHeight - win.height() - win.scrollTop(); - position.top = over > 0 ? position.top - over : Math.max( 0, position.top ); + 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 ); } },
flip: { left: function( position, data ) { - if ( data.at[0] === "center" ) { + if ( data.at[0] === center ) { return; } var win = $( window ), - over = position.left + data.elemWidth - win.width() - win.scrollLeft(), + over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(), myOffset = data.my[ 0 ] === "left" ? -data.elemWidth : data.my[ 0 ] === "right" ? data.elemWidth : 0, + atOffset = data.at[ 0 ] === "left" ? + data.targetWidth : + -data.targetWidth, offset = -2 * data.offset[ 0 ]; - position.left += position.left < 0 ? - myOffset + data.targetWidth + offset : + position.left += data.collisionPosition.left < 0 ? + myOffset + atOffset + offset : over > 0 ? - myOffset - data.targetWidth + offset : + myOffset + atOffset + offset : 0; }, top: function( position, data ) { - if ( data.at[1] === "center" ) { + if ( data.at[1] === center ) { return; } var win = $( window ), - over = position.top + data.elemHeight - win.height() - win.scrollTop(), + over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(), myOffset = data.my[ 1 ] === "top" ? -data.elemHeight : data.my[ 1 ] === "bottom" ? @@ -772,8 +949,8 @@ $.ui.position = { data.targetHeight : -data.targetHeight, offset = -2 * data.offset[ 1 ]; - position.top += position.top < 0 ? - myOffset + data.targetHeight + offset : + position.top += data.collisionPosition.top < 0 ? + myOffset + atOffset + offset : over > 0 ? myOffset + atOffset + offset : 0; @@ -818,11 +995,11 @@ if ( !$.offset.setOffset ) {
}( jQuery )); /* - * jQuery UI Draggable 1.8 + * jQuery UI Draggable 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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 * @@ -831,7 +1008,7 @@ if ( !$.offset.setOffset ) { * jquery.ui.mouse.js * jquery.ui.widget.js */ -(function($) { +(function( $, undefined ) {
$.widget("ui.draggable", $.ui.mouse, { widgetEventPrefix: "drag", @@ -898,6 +1075,18 @@ $.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"); + }); + }
return true;
@@ -972,6 +1161,10 @@ $.widget("ui.draggable", $.ui.mouse, {
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; },
@@ -1011,8 +1204,8 @@ $.widget("ui.draggable", $.ui.mouse, { this.dropped = false; } - //if the original element is removed, don't bother to continue - if(!this.element[0] || !this.element[0].parentNode) + //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") 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))) { @@ -1031,6 +1224,19 @@ $.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 + } + + //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")) { @@ -1060,7 +1266,7 @@ $.widget("ui.draggable", $.ui.mouse, { _createHelper: function(event) {
var o = this.options; - var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone() : this.element); + var helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper == 'clone' ? this.element.clone().removeAttr('id') : this.element);
if(!helper.parents('body').length) helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo)); @@ -1136,7 +1342,9 @@ $.widget("ui.draggable", $.ui.mouse, { _cacheMargins: function() { this.margins = { left: (parseInt(this.element.css("marginLeft"),10) || 0), - top: (parseInt(this.element.css("marginTop"),10) || 0) + top: (parseInt(this.element.css("marginTop"),10) || 0), + right: (parseInt(this.element.css("marginRight"),10) || 0), + bottom: (parseInt(this.element.css("marginBottom"),10) || 0) }; },
@@ -1152,23 +1360,26 @@ $.widget("ui.draggable", $.ui.mouse, { var o = this.options; if(o.containment == 'parent') o.containment = this.helper[0].parentNode; if(o.containment == 'document' || o.containment == 'window') this.containment = [ - 0 - this.offset.relative.left - this.offset.parent.left, - 0 - this.offset.relative.top - this.offset.parent.top, - $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left, - ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top + o.containment == 'document' ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left, + o.containment == 'document' ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top, + (o.containment == 'document' ? 0 : $(window).scrollLeft()) + $(o.containment == 'document' ? document : window).width() - this.helperProportions.width - this.margins.left, + (o.containment == 'document' ? 0 : $(window).scrollTop()) + ($(o.containment == 'document' ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top ];
if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor != Array) { - var ce = $(o.containment)[0]; if(!ce) return; - var co = $(o.containment).offset(); + var c = $(o.containment); + var ce = c[0]; if(!ce) return; + var co = c.offset(); var over = ($(ce).css("overflow") != 'hidden');
this.containment = [ - co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left, - co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top, - co.left+(over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left, - co.top+(over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0), + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0), + (over ? Math.max(ce.scrollWidth,ce.offsetWidth) : ce.offsetWidth) - (parseInt($(ce).css("borderLeftWidth"),10) || 0) - (parseInt($(ce).css("paddingRight"),10) || 0) - this.helperProportions.width - this.margins.left - this.margins.right, + (over ? Math.max(ce.scrollHeight,ce.offsetHeight) : ce.offsetHeight) - (parseInt($(ce).css("borderTopWidth"),10) || 0) - (parseInt($(ce).css("paddingBottom"),10) || 0) - this.helperProportions.height - this.margins.top - this.margins.bottom ]; + this.relative_container = c; + } else if(o.containment.constructor == Array) { this.containment = o.containment; } @@ -1210,20 +1421,32 @@ $.widget("ui.draggable", $.ui.mouse, { */
if(this.originalPosition) { //If we are not dragging yet, we won't check for options - - if(this.containment) { - if(event.pageX - this.offset.click.left < this.containment[0]) pageX = this.containment[0] + this.offset.click.left; - if(event.pageY - this.offset.click.top < this.containment[1]) pageY = this.containment[1] + this.offset.click.top; - if(event.pageX - this.offset.click.left > this.containment[2]) pageX = this.containment[2] + this.offset.click.left; - if(event.pageY - this.offset.click.top > this.containment[3]) pageY = this.containment[3] + this.offset.click.top; + 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; + if(event.pageX - this.offset.click.left > containment[2]) pageX = containment[2] + this.offset.click.left; + if(event.pageY - this.offset.click.top > containment[3]) pageY = containment[3] + this.offset.click.top; }
if(o.grid) { - var top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1]; - pageY = this.containment ? (!(top - this.offset.click.top < this.containment[1] || top - this.offset.click.top > this.containment[3]) ? top : (!(top - this.offset.click.top < this.containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top; + //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950) + var top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY; + pageY = containment ? (!(top - this.offset.click.top < containment[1] || top - this.offset.click.top > containment[3]) ? top : (!(top - this.offset.click.top < containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
- var left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0]; - pageX = this.containment ? (!(left - this.offset.click.left < this.containment[0] || left - this.offset.click.left > this.containment[2]) ? left : (!(left - this.offset.click.left < this.containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; + var left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX; + pageX = containment ? (!(left - this.offset.click.left < containment[0] || left - this.offset.click.left > containment[2]) ? left : (!(left - this.offset.click.left < containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left; }
} @@ -1278,7 +1501,7 @@ $.widget("ui.draggable", $.ui.mouse, { });
$.extend($.ui.draggable, { - version: "1.8" + version: "1.8.16" });
$.ui.plugin.add("draggable", "connectToSortable", { @@ -1294,7 +1517,7 @@ $.ui.plugin.add("draggable", "connectToSortable", { instance: sortable, shouldRevert: sortable.options.revert }); - sortable._refreshItems(); //Do a one-time refresh at start to refresh the containerCache + sortable.refreshPositions(); // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page). sortable._trigger("activate", event, uiSortable); } }); @@ -1363,7 +1586,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().appendTo(this.instance.element).data("sortable-item", true); + this.instance.currentItem = $(self).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]; };
@@ -1433,24 +1656,6 @@ $.ui.plugin.add("draggable", "cursor", { } });
-$.ui.plugin.add("draggable", "iframeFix", { - start: function(event, ui) { - var o = $(this).data('draggable').options; - $(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"); - }); - }, - stop: function(event, ui) { - $("div.ui-draggable-iframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers - } -}); - $.ui.plugin.add("draggable", "opacity", { start: function(event, ui) { var t = $(ui.helper), o = $(this).data('draggable').options; @@ -1615,11 +1820,11 @@ $.ui.plugin.add("draggable", "zIndex", {
})(jQuery); /* - * jQuery UI Droppable 1.8 + * jQuery UI Droppable 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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 * @@ -1629,7 +1834,7 @@ $.ui.plugin.add("draggable", "zIndex", { * jquery.ui.mouse.js * jquery.ui.draggable.js */ -(function($) { +(function( $, undefined ) {
$.widget("ui.droppable", { widgetEventPrefix: "drop", @@ -1763,7 +1968,7 @@ $.widget("ui.droppable", { });
$.extend($.ui.droppable, { - version: "1.8" + version: "1.8.16" });
$.ui.intersect = function(draggable, droppable, toleranceMode) { @@ -1777,8 +1982,8 @@ $.ui.intersect = function(draggable, droppable, toleranceMode) {
switch (toleranceMode) { case 'fit': - return (l < x1 && x2 < r - && t < y1 && y2 < b); + return (l <= x1 && x2 <= r + && t <= y1 && y2 <= b); break; case 'intersect': return (l < x1 + (draggable.helperProportions.width / 2) // Right Half @@ -1828,11 +2033,11 @@ $.ui.ddmanager = { for (var j=0; j < list.length; j++) { if(list[j] == m[i].element[0]) { m[i].proportions.height = 0; continue droppablesLoop; } }; //Filter out elements in the current dragged item m[i].visible = m[i].element.css("display") != "none"; if(!m[i].visible) continue; //If the element is not visible, continue
+ if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables + m[i].offset = m[i].element.offset(); m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
- if(type == "mousedown") m[i]._activate.call(m[i], event); //Activate the droppable if used directly from draggables - }
}, @@ -1854,6 +2059,12 @@ $.ui.ddmanager = { return dropped;
}, + 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() { + if( !draggable.options.refreshPositions ) $.ui.ddmanager.prepareOffsets( draggable, event ); + }); + }, drag: function(draggable, event) {
//If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse. @@ -1895,16 +2106,21 @@ $.ui.ddmanager = { } });
+ }, + dragStop: function( draggable, event ) { + draggable.element.parents( ":not(body,html)" ).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 + * jQuery UI Resizable 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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 * @@ -1913,7 +2129,7 @@ $.ui.ddmanager = { * jquery.ui.mouse.js * jquery.ui.widget.js */ -(function($) { +(function( $, undefined ) {
$.widget("ui.resizable", $.ui.mouse, { widgetEventPrefix: "resize", @@ -2077,10 +2293,12 @@ $.widget("ui.resizable", $.ui.mouse, { $(this.element) .addClass("ui-resizable-autohide") .hover(function() { + if (o.disabled) return; $(this).removeClass("ui-resizable-autohide"); self._handles.show(); }, function(){ + if (o.disabled) return; if (!self.resizing) { $(this).addClass("ui-resizable-autohide"); self._handles.hide(); @@ -2192,6 +2410,8 @@ $.widget("ui.resizable", $.ui.mouse, { // Calculate the attrs that will be change var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff;
+ // Put this in the mouseDrag handler since the user can start pressing shift while resizing + this._updateVirtualBoundaries(event.shiftKey); if (this._aspectRatio || event.shiftKey) data = this._updateRatio(data, event);
@@ -2223,10 +2443,10 @@ $.widget("ui.resizable", $.ui.mouse, {
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 : self.sizeDiff.height, + soffsetw = ista ? 0 : self.sizeDiff.width;
- var s = { width: (self.size.width - soffsetw), height: (self.size.height - soffseth) }, + 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;
@@ -2250,6 +2470,32 @@ $.widget("ui.resizable", $.ui.mouse, {
},
+ _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 + }; + + 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; + }, + _updateCache: function(data) { var o = this.options; this.offset = this.helper.offset(); @@ -2263,8 +2509,8 @@ $.widget("ui.resizable", $.ui.mouse, {
var o = this.options, cpos = this.position, csize = this.size, a = this.axis;
- if (data.height) data.width = (csize.height * this.aspectRatio); - else if (data.width) data.height = (csize.width / this.aspectRatio); + if (isNumber(data.height)) data.width = (data.height * this.aspectRatio); + else if (isNumber(data.width)) data.height = (data.width / this.aspectRatio);
if (a == 'sw') { data.left = cpos.left + (csize.width - data.width); @@ -2280,7 +2526,7 @@ $.widget("ui.resizable", $.ui.mouse, {
_respectSize: function(data, event) {
- var el = this.helper, o = this.options, pRatio = this._aspectRatio || event.shiftKey, a = this.axis, + var el = this.helper, o = this._vBoundaries, pRatio = this._aspectRatio || event.shiftKey, a = this.axis, ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height), isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height);
@@ -2420,7 +2666,7 @@ $.widget("ui.resizable", $.ui.mouse, { });
$.extend($.ui.resizable, { - version: "1.8" + version: "1.8.16" });
/* @@ -2429,28 +2675,29 @@ $.extend($.ui.resizable, {
$.ui.plugin.add("resizable", "alsoResize", {
- start: function(event, ui) { - + start: function (event, ui) { var self = $(this).data("resizable"), o = self.options;
- var _store = function(exp) { + var _store = function (exp) { $(exp).each(function() { - $(this).data("resizable-alsoresize", { - width: parseInt($(this).width(), 10), height: parseInt($(this).height(), 10), - left: parseInt($(this).css('left'), 10), top: parseInt($(this).css('top'), 10) + 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() }); }); };
if (typeof(o.alsoResize) == 'object' && !o.alsoResize.parentNode) { - if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); } - else { $.each(o.alsoResize, function(exp, c) { _store(exp); }); } + if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); } + else { $.each(o.alsoResize, function (exp) { _store(exp); }); } }else{ _store(o.alsoResize); } },
- resize: function(event, ui){ + resize: function (event, ui) { var self = $(this).data("resizable"), o = self.options, os = self.originalSize, op = self.originalPosition;
var delta = { @@ -2458,18 +2705,19 @@ $.ui.plugin.add("resizable", "alsoResize", { top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0 },
- _alsoResize = function(exp, c) { + _alsoResize = function (exp, c) { $(exp).each(function() { - var el = $(this), start = $(this).data("resizable-alsoresize"), style = {}, css = c && c.length ? c : ['width', 'height', 'top', 'left']; + 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 || ['width', 'height', 'top', 'left'], function(i, prop) { + $.each(css, function (i, prop) { var sum = (start[prop]||0) + (delta[prop]||0); if (sum && sum >= 0) style[prop] = sum || null; });
- //Opera fixing relative position - if (/relative/.test(el.css('position')) && $.browser.opera) { + // Opera fixing relative position + if ($.browser.opera && /relative/.test(el.css('position'))) { self._revertToRelativePosition = true; el.css({ position: 'absolute', top: 'auto', left: 'auto' }); } @@ -2479,22 +2727,33 @@ $.ui.plugin.add("resizable", "alsoResize", { };
if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) { - $.each(o.alsoResize, function(exp, c) { _alsoResize(exp, c); }); + $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); }); }else{ _alsoResize(o.alsoResize); } },
- stop: function(event, ui){ - var self = $(this).data("resizable"); + stop: function (event, ui) { + var self = $(this).data("resizable"), o = self.options;
- //Opera fixing relative position - if (self._revertToRelativePosition && $.browser.opera) { + 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; - el.css({ position: 'relative' }); + if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType) { + $.each(o.alsoResize, function (exp) { _reset(exp); }); + }else{ + _reset(o.alsoResize); + } }
- $(this).removeData("resizable-alsoresize-start"); + $(this).removeData("resizable-alsoresize"); } });
@@ -2699,11 +2958,11 @@ var isNumber = function(value) {
})(jQuery); /* - * jQuery UI Selectable 1.8 + * jQuery UI Selectable 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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 * @@ -2712,7 +2971,7 @@ var isNumber = function(value) { * jquery.ui.mouse.js * jquery.ui.widget.js */ -(function($) { +(function( $, undefined ) {
$.widget("ui.selectable", $.ui.mouse, { options: { @@ -2756,9 +3015,7 @@ $.widget("ui.selectable", $.ui.mouse, {
this._mouseInit();
- this.helper = $(document.createElement('div')) - .css({border:'1px dotted black'}) - .addClass("ui-selectable-helper"); + this.helper = $("<div class='ui-selectable-helper'></div>"); },
destroy: function() { @@ -2791,8 +3048,6 @@ $.widget("ui.selectable", $.ui.mouse, { $(options.appendTo).append(this.helper); // position helper (lasso) this.helper.css({ - "z-index": 100, - "position": "absolute", "left": event.clientX, "top": event.clientY, "width": 0, @@ -2821,14 +3076,23 @@ $.widget("ui.selectable", $.ui.mouse, { $(event.target).parents().andSelf().each(function() { var selectee = $.data(this, "selectable-item"); if (selectee) { - selectee.$element.removeClass("ui-unselecting").addClass('ui-selecting'); - selectee.unselecting = false; - selectee.selecting = true; - selectee.selected = true; - // selectable SELECTING callback - self._trigger("selecting", event, { - selecting: selectee.element - }); + var doSelect = !event.metaKey || !selectee.$element.hasClass('ui-selected'); + selectee.$element + .removeClass(doSelect ? "ui-unselecting" : "ui-selected") + .addClass(doSelect ? "ui-selecting" : "ui-unselecting"); + selectee.unselecting = !doSelect; + selectee.selecting = doSelect; + selectee.selected = doSelect; + // selectable (UN)SELECTING callback + if (doSelect) { + self._trigger("selecting", event, { + selecting: selectee.element + }); + } else { + self._trigger("unselecting", event, { + unselecting: selectee.element + }); + } return false; } }); @@ -2955,16 +3219,16 @@ $.widget("ui.selectable", $.ui.mouse, { });
$.extend($.ui.selectable, { - version: "1.8" + version: "1.8.16" });
})(jQuery); /* - * jQuery UI Sortable 1.8 + * jQuery UI Sortable 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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 * @@ -2973,7 +3237,7 @@ $.extend($.ui.selectable, { * jquery.ui.mouse.js * jquery.ui.widget.js */ -(function($) { +(function( $, undefined ) {
$.widget("ui.sortable", $.ui.mouse, { widgetEventPrefix: "sort", @@ -3010,8 +3274,8 @@ $.widget("ui.sortable", $.ui.mouse, { //Get the items this.refresh();
- //Let's determine if the items are floating - this.floating = this.items.length ? (/left|right/).test(this.items[0].item.css('float')) : false; + //Let's determine if the items are being displayed horizontally + this.floating = this.items.length ? o.axis === 'x' || (/left|right/).test(this.items[0].item.css('float')) || (/inline|table-cell/).test(this.items[0].item.css('display')) : false;
//Let's determine the parent's offset this.offset = this.element.offset(); @@ -3034,6 +3298,18 @@ $.widget("ui.sortable", $.ui.mouse, { return this; },
+ _setOption: function(key, value){ + if ( key === "disabled" ) { + this.options[ key ] = value; + + this.widget() + [ value ? "addClass" : "removeClass"]( "ui-sortable-disabled" ); + } else { + // Don't call widget base _setOption for disable as it adds ui-state-disabled class + $.Widget.prototype._setOption.apply(this, arguments); + } + }, + _mouseCapture: function(event, overrideHandle) {
if (this.reverting) { @@ -3309,7 +3585,7 @@ $.widget("ui.sortable", $.ui.mouse, {
if(this.dragging) {
- this._mouseUp(); + this._mouseUp({ target: null });
if(this.options.helper == "original") this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"); @@ -3327,21 +3603,23 @@ $.widget("ui.sortable", $.ui.mouse, {
}
- //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! - if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]); - if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove(); + if (this.placeholder) { + //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node! + if(this.placeholder[0].parentNode) this.placeholder[0].parentNode.removeChild(this.placeholder[0]); + if(this.options.helper != "original" && this.helper && this.helper[0].parentNode) this.helper.remove();
- $.extend(this, { - helper: null, - dragging: false, - reverting: false, - _noFinalSort: null - }); + $.extend(this, { + helper: null, + dragging: false, + reverting: false, + _noFinalSort: null + });
- if(this.domPosition.prev) { - $(this.domPosition.prev).after(this.currentItem); - } else { - $(this.domPosition.parent).prepend(this.currentItem); + if(this.domPosition.prev) { + $(this.domPosition.prev).after(this.currentItem); + } else { + $(this.domPosition.parent).prepend(this.currentItem); + } }
return this; @@ -3358,6 +3636,10 @@ $.widget("ui.sortable", $.ui.mouse, { if(res) str.push((o.key || res[1]+'[]')+'='+(o.key && o.expression ? res[1] : res[2])); });
+ if(!str.length && o.key) { + str.push(o.key + '='); + } + return str.join('&');
}, @@ -3558,6 +3840,10 @@ $.widget("ui.sortable", $.ui.mouse, { for (var i = this.items.length - 1; i >= 0; i--){ var item = this.items[i];
+ //We ignore calculating positions of all connected containers when we're not over them + if(item.instance != this.currentContainer && this.currentContainer && item.item[0] != this.currentItem[0]) + continue; + var t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
if (!fast) { @@ -3923,7 +4209,7 @@ $.widget("ui.sortable", $.ui.mouse, {
// 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) - if(!this._noFinalSort && this.currentItem[0].parentNode) this.placeholder.before(this.currentItem); + if(!this._noFinalSort && this.currentItem.parent().length) this.placeholder.before(this.currentItem); this._noFinalSort = null;
if(this.helper[0] == this.currentItem[0]) { @@ -4010,16 +4296,16 @@ $.widget("ui.sortable", $.ui.mouse, { });
$.extend($.ui.sortable, { - version: "1.8" + version: "1.8.16" });
})(jQuery); /* - * jQuery UI Accordion 1.8 + * jQuery UI Accordion 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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 * @@ -4027,12 +4313,12 @@ $.extend($.ui.sortable, { * jquery.ui.core.js * jquery.ui.widget.js */ -(function($) { +(function( $, undefined ) {
-$.widget("ui.accordion", { +$.widget( "ui.accordion", { options: { active: 0, - animated: 'slide', + animated: "slide", autoHeight: true, clearStyle: false, collapsible: false, @@ -4045,329 +4331,398 @@ $.widget("ui.accordion", { }, navigation: false, navigationFilter: function() { - return this.href.toLowerCase() == location.href.toLowerCase(); + return this.href.toLowerCase() === location.href.toLowerCase(); } }, - _create: function() {
- var o = this.options, self = this; - this.running = 0; + _create: function() { + var self = this, + options = self.options;
- this.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 - if (this.element[0].nodeName == "UL") { - this.element.children("li").addClass("ui-accordion-li-fix"); - } + self.running = 0;
- this.headers = this.element.find(o.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all") - .bind("mouseenter.accordion", function(){ $(this).addClass('ui-state-hover'); }) - .bind("mouseleave.accordion", function(){ $(this).removeClass('ui-state-hover'); }) - .bind("focus.accordion", function(){ $(this).addClass('ui-state-focus'); }) - .bind("blur.accordion", function(){ $(this).removeClass('ui-state-focus'); }); + 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" ); + });
- this.headers - .next() - .addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom"); + self.headers.next() + .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" );
- if ( o.navigation ) { - var current = this.element.find("a").filter(o.navigationFilter); + if ( options.navigation ) { + var current = self.element.find( "a" ).filter( options.navigationFilter ).eq( 0 ); if ( current.length ) { - var header = current.closest(".ui-accordion-header"); + var header = current.closest( ".ui-accordion-header" ); if ( header.length ) { // anchor within header - this.active = header; + self.active = header; } else { // anchor within content - this.active = current.closest(".ui-accordion-content").prev(); + self.active = current.closest( ".ui-accordion-content" ).prev(); } } }
- this.active = this._findActive(this.active || o.active).toggleClass("ui-state-default").toggleClass("ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top"); - this.active.next().addClass('ui-accordion-content-active'); - - //Append icon elements - this._createIcons(); - - // IE7-/Win - Extra vertical space in lists fixed - if ($.browser.msie) { - this.element.find('a').css('zoom', '1'); - } + 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" );
- this.resize(); - - //ARIA - this.element.attr('role','tablist'); + self._createIcons(); + self.resize(); + + // ARIA + self.element.attr( "role", "tablist" );
- this.headers - .attr('role','tab') - .bind('keydown', function(event) { return self._keydown(event); }) + self.headers + .attr( "role", "tab" ) + .bind( "keydown.accordion", function( event ) { + return self._keydown( event ); + }) .next() - .attr('role','tabpanel'); + .attr( "role", "tabpanel" );
- this.headers - .not(this.active || "") - .attr('aria-expanded','false') - .attr("tabIndex", "-1") + self.headers + .not( self.active || "" ) + .attr({ + "aria-expanded": "false", + "aria-selected": "false", + tabIndex: -1 + }) .next() - .hide(); + .hide();
// make sure at least one header is in the tab order - if (!this.active.length) { - this.headers.eq(0).attr('tabIndex','0'); + if ( !self.active.length ) { + self.headers.eq( 0 ).attr( "tabIndex", 0 ); } else { - this.active - .attr('aria-expanded','true') - .attr('tabIndex', '0'); + self.active + .attr({ + "aria-expanded": "true", + "aria-selected": "true", + tabIndex: 0 + }); }
- // only need links in taborder for Safari - if (!$.browser.safari) - this.headers.find('a').attr('tabIndex','-1'); + // only need links in tab order for Safari + if ( !$.browser.safari ) { + self.headers.find( "a" ).attr( "tabIndex", -1 ); + }
- if (o.event) { - this.headers.bind((o.event) + ".accordion", function(event) { - self._clickHandler.call(self, event, this); + if ( options.event ) { + self.headers.bind( options.event.split(" ").join(".accordion ") + ".accordion", function(event) { + self._clickHandler.call( self, event, this ); event.preventDefault(); }); } - }, - + _createIcons: function() { - var o = this.options; - if (o.icons) { - $("<span/>").addClass("ui-icon " + o.icons.header).prependTo(this.headers); - this.active.find(".ui-icon").toggleClass(o.icons.header).toggleClass(o.icons.headerSelected); - this.element.addClass("ui-accordion-icons"); + var options = this.options; + if ( options.icons ) { + $( "<span></span>" ) + .addClass( "ui-icon " + options.icons.header ) + .prependTo( this.headers ); + this.active.children( ".ui-icon" ) + .toggleClass(options.icons.header) + .toggleClass(options.icons.headerSelected); + this.element.addClass( "ui-accordion-icons" ); } }, - + _destroyIcons: function() { - this.headers.children(".ui-icon").remove(); - this.element.removeClass("ui-accordion-icons"); + this.headers.children( ".ui-icon" ).remove(); + this.element.removeClass( "ui-accordion-icons" ); },
destroy: function() { - var o = this.options; + var options = this.options;
this.element - .removeClass("ui-accordion ui-widget ui-helper-reset") - .removeAttr("role") - .unbind('.accordion') - .removeData('accordion'); + .removeClass( "ui-accordion ui-widget ui-helper-reset" ) + .removeAttr( "role" );
this.headers - .unbind(".accordion") - .removeClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-corner-top") - .removeAttr("role").removeAttr("aria-expanded").removeAttr("tabindex"); + .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" ) + .removeAttr( "role" ) + .removeAttr( "aria-expanded" ) + .removeAttr( "aria-selected" ) + .removeAttr( "tabIndex" );
- this.headers.find("a").removeAttr("tabindex"); + this.headers.find( "a" ).removeAttr( "tabIndex" ); this._destroyIcons(); - var 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"); - if (o.autoHeight || o.fillHeight) { - contents.css("height", ""); + var 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 ) { + contents.css( "height", "" ); }
- return this; + return $.Widget.prototype.destroy.call( this ); }, - - _setOption: function(key, value) { - $.Widget.prototype._setOption.apply(this, arguments); + + _setOption: function( key, value ) { + $.Widget.prototype._setOption.apply( this, arguments ); - if (key == "active") { - this.activate(value); + if ( key == "active" ) { + this.activate( value ); } - if (key == "icons") { + if ( key == "icons" ) { this._destroyIcons(); - if (value) { + 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" ); + } },
- _keydown: function(event) { - - var o = this.options, keyCode = $.ui.keyCode; - - if (o.disabled || event.altKey || event.ctrlKey) + _keydown: function( event ) { + if ( this.options.disabled || event.altKey || event.ctrlKey ) { return; + }
- var length = this.headers.length; - var currentIndex = this.headers.index(event.target); - var toFocus = false; + var keyCode = $.ui.keyCode, + length = this.headers.length, + currentIndex = this.headers.index( event.target ), + toFocus = false;
- switch(event.keyCode) { + switch ( event.keyCode ) { case keyCode.RIGHT: case keyCode.DOWN: - toFocus = this.headers[(currentIndex + 1) % length]; + toFocus = this.headers[ ( currentIndex + 1 ) % length ]; break; case keyCode.LEFT: case keyCode.UP: - toFocus = this.headers[(currentIndex - 1 + length) % length]; + toFocus = this.headers[ ( currentIndex - 1 + length ) % length ]; break; case keyCode.SPACE: case keyCode.ENTER: - this._clickHandler({ target: event.target }, event.target); + this._clickHandler( { target: event.target }, event.target ); event.preventDefault(); }
- if (toFocus) { - $(event.target).attr('tabIndex','-1'); - $(toFocus).attr('tabIndex','0'); + if ( toFocus ) { + $( event.target ).attr( "tabIndex", -1 ); + $( toFocus ).attr( "tabIndex", 0 ); toFocus.focus(); return false; }
return true; - },
resize: function() { + var options = this.options, + maxHeight;
- var o = this.options, maxHeight; - - if (o.fillSpace) { - - if($.browser.msie) { var defOverflow = this.element.parent().css('overflow'); this.element.parent().css('overflow', 'hidden'); } + 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); } - + if ($.browser.msie) { + this.element.parent().css( "overflow", defOverflow ); + } + this.headers.each(function() { - maxHeight -= $(this).outerHeight(true); + maxHeight -= $( this ).outerHeight( true ); });
- this.headers.next().each(function() { - $(this).height(Math.max(0, maxHeight - $(this).innerHeight() + $(this).height())); - }).css('overflow', 'auto'); - - } else if ( o.autoHeight ) { + this.headers.next() + .each(function() { + $( this ).height( Math.max( 0, maxHeight - + $( this ).innerHeight() + $( this ).height() ) ); + }) + .css( "overflow", "auto" ); + } else if ( options.autoHeight ) { maxHeight = 0; - this.headers.next().each(function() { - maxHeight = Math.max(maxHeight, $(this).height()); - }).height(maxHeight); + this.headers.next() + .each(function() { + maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() ); + }) + .height( maxHeight ); }
return this; },
- activate: function(index) { + 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 - var active = this._findActive(index)[0]; - this._clickHandler({ target: active }, active); + var active = this._findActive( index )[ 0 ]; + this._clickHandler( { target: active }, active );
return this; },
- _findActive: function(selector) { + _findActive: function( selector ) { return selector - ? typeof selector == "number" - ? this.headers.filter(":eq(" + selector + ")") - : this.headers.not(this.headers.not(selector)) + ? typeof selector === "number" + ? this.headers.filter( ":eq(" + selector + ")" ) + : this.headers.not( this.headers.not( selector ) ) : selector === false - ? $([]) - : this.headers.filter(":eq(0)"); + ? $( [] ) + : this.headers.filter( ":eq(0)" ); },
- // TODO isn't event.target enough? why the seperate target argument? - _clickHandler: function(event, target) { - - var o = this.options; - if (o.disabled) + // 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 (!o.collapsible) + if ( !event.target ) { + if ( !options.collapsible ) { return; - this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all") - .find(".ui-icon").removeClass(o.icons.headerSelected).addClass(o.icons.header); - this.active.next().addClass('ui-accordion-content-active'); + } + 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: o, - newHeader: $([]), - oldHeader: o.active, - newContent: $([]), + options: options, + newHeader: $( [] ), + oldHeader: options.active, + newContent: $( [] ), oldContent: toHide }, - toShow = (this.active = $([])); - this._toggle(toShow, toHide, data); + toShow = ( this.active = $( [] ) ); + this._toggle( toShow, toHide, data ); return; }
// get the click target - var clicked = $(event.currentTarget || target); - var clickedIsActive = clicked[0] == this.active[0]; - + var clicked = $( event.currentTarget || target ), + clickedIsActive = clicked[0] === this.active[0]; + // TODO the option is changed, is that correct? // TODO if it is correct, shouldn't that happen after determining that the click is valid? - o.active = o.collapsible && clickedIsActive ? false : $('.ui-accordion-header', this.element).index(clicked); + options.active = options.collapsible && clickedIsActive ? + false : + this.headers.index( clicked );
// if animations are still active, or the active header is the target, ignore click - if (this.running || (!o.collapsible && clickedIsActive)) { + if ( this.running || ( !options.collapsible && clickedIsActive ) ) { return; }
- // switch classes - this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all") - .find(".ui-icon").removeClass(o.icons.headerSelected).addClass(o.icons.header); - if (!clickedIsActive) { - clicked.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top") - .find(".ui-icon").removeClass(o.icons.header).addClass(o.icons.headerSelected); - clicked.next().addClass('ui-accordion-content-active'); - } - // find elements to show and hide - var toShow = clicked.next(), + var active = this.active, + toShow = clicked.next(), toHide = this.active.next(), data = { - options: o, - newHeader: clickedIsActive && o.collapsible ? $([]) : clicked, + options: options, + newHeader: clickedIsActive && options.collapsible ? $([]) : clicked, oldHeader: this.active, - newContent: clickedIsActive && o.collapsible ? $([]) : toShow, + newContent: clickedIsActive && options.collapsible ? $([]) : toShow, oldContent: toHide }, down = this.headers.index( this.active[0] ) > this.headers.index( clicked[0] );
+ // 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._toggle( toShow, toHide, data, clickedIsActive, down );
- return; + // switch classes + 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 ); + if ( !clickedIsActive ) { + clicked + .removeClass( "ui-state-default ui-corner-all" ) + .addClass( "ui-state-active ui-corner-top" ) + .children( ".ui-icon" ) + .removeClass( options.icons.header ) + .addClass( options.icons.headerSelected ); + clicked + .next() + .addClass( "ui-accordion-content-active" ); + }
+ return; },
- _toggle: function(toShow, toHide, data, clickedIsActive, down) { - - var o = this.options, self = this; + _toggle: function( toShow, toHide, data, clickedIsActive, down ) { + var self = this, + options = self.options;
- this.toShow = toShow; - this.toHide = toHide; - this.data = data; + self.toShow = toShow; + self.toHide = toHide; + self.data = data;
- var complete = function() { if(!self) return; return self._completed.apply(self, arguments); }; + var complete = function() { + if ( !self ) { + return; + } + return self._completed.apply( self, arguments ); + };
// trigger changestart event - this._trigger("changestart", null, this.data); + self._trigger( "changestart", null, self.data );
// count elements to animate - this.running = toHide.size() === 0 ? toShow.size() : toHide.size(); - - if (o.animated) { + self.running = toHide.size() === 0 ? toShow.size() : toHide.size();
+ if ( options.animated ) { var animOptions = {};
- if ( o.collapsible && clickedIsActive ) { + if ( options.collapsible && clickedIsActive ) { animOptions = { - toShow: $([]), + toShow: $( [] ), toHide: toHide, complete: complete, down: down, - autoHeight: o.autoHeight || o.fillSpace + autoHeight: options.autoHeight || options.fillSpace }; } else { animOptions = { @@ -4375,101 +4730,120 @@ $.widget("ui.accordion", { toHide: toHide, complete: complete, down: down, - autoHeight: o.autoHeight || o.fillSpace + autoHeight: options.autoHeight || options.fillSpace }; }
- if (!o.proxied) { - o.proxied = o.animated; + if ( !options.proxied ) { + options.proxied = options.animated; }
- if (!o.proxiedDuration) { - o.proxiedDuration = o.duration; + if ( !options.proxiedDuration ) { + options.proxiedDuration = options.duration; }
- o.animated = $.isFunction(o.proxied) ? - o.proxied(animOptions) : o.proxied; + options.animated = $.isFunction( options.proxied ) ? + options.proxied( animOptions ) : + options.proxied;
- o.duration = $.isFunction(o.proxiedDuration) ? - o.proxiedDuration(animOptions) : o.proxiedDuration; + options.duration = $.isFunction( options.proxiedDuration ) ? + options.proxiedDuration( animOptions ) : + options.proxiedDuration;
var animations = $.ui.accordion.animations, - duration = o.duration, - easing = o.animated; + duration = options.duration, + easing = options.animated;
- if (easing && !animations[easing] && !$.easing[easing]) { - easing = 'slide'; + if ( easing && !animations[ easing ] && !$.easing[ easing ] ) { + easing = "slide"; } - if (!animations[easing]) { - animations[easing] = function(options) { - this.slide(options, { + if ( !animations[ easing ] ) { + animations[ easing ] = function( options ) { + this.slide( options, { easing: easing, duration: duration || 700 }); }; }
- animations[easing](animOptions); - + animations[ easing ]( animOptions ); } else { - - if (o.collapsible && clickedIsActive) { + if ( options.collapsible && clickedIsActive ) { toShow.toggle(); } else { toHide.hide(); toShow.show(); }
- complete(true); - + complete( true ); }
// TODO assert that the blur and focus triggers are really necessary, remove otherwise - toHide.prev().attr('aria-expanded','false').attr("tabIndex", "-1").blur(); - toShow.prev().attr('aria-expanded','true').attr("tabIndex", "0").focus(); - + toHide.prev() + .attr({ + "aria-expanded": "false", + "aria-selected": "false", + tabIndex: -1 + }) + .blur(); + toShow.prev() + .attr({ + "aria-expanded": "true", + "aria-selected": "true", + tabIndex: 0 + }) + .focus(); },
- _completed: function(cancel) { - - var o = this.options; - + _completed: function( cancel ) { this.running = cancel ? 0 : --this.running; - if (this.running) return; + if ( this.running ) { + return; + }
- if (o.clearStyle) { - this.toShow.add(this.toHide).css({ + if ( this.options.clearStyle ) { + this.toShow.add( this.toHide ).css({ height: "", overflow: "" }); } - + // other classes are removed before the animation; this one needs to stay until completed - this.toHide.removeClass("ui-accordion-content-active"); + 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; + }
- this._trigger('change', null, this.data); + this._trigger( "change", null, this.data ); } - });
- -$.extend($.ui.accordion, { - version: "1.8", +$.extend( $.ui.accordion, { + version: "1.8.16", animations: { - slide: function(options, additions) { + slide: function( options, additions ) { options = $.extend({ easing: "swing", duration: 300 - }, options, additions); + }, options, additions ); if ( !options.toHide.size() ) { - options.toShow.animate({height: "show"}, options); + options.toShow.animate({ + height: "show", + paddingTop: "show", + paddingBottom: "show" + }, options ); return; } if ( !options.toShow.size() ) { - options.toHide.animate({height: "hide"}, options); + options.toHide.animate({ + height: "hide", + paddingTop: "hide", + paddingBottom: "hide" + }, options ); return; } - var overflow = options.toShow.css('overflow'), + var overflow = options.toShow.css( "overflow" ), percentDone = 0, showProps = {}, hideProps = {}, @@ -4478,45 +4852,57 @@ $.extend($.ui.accordion, { // 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' + 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) { + 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') { + if ( settings.prop == "height" ) { percentDone = ( settings.end - settings.start === 0 ) ? 0 : - (settings.now - settings.start) / (settings.end - settings.start); + ( settings.now - settings.start ) / ( settings.end - settings.start ); } - - options.toShow[0].style[settings.prop] = - (percentDone * showProps[settings.prop].value) + showProps[settings.prop].unit; + + 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( "height", "" ); } - options.toShow.css("width", originalWidth); - options.toShow.css({overflow: overflow}); + options.toShow.css({ + width: originalWidth, + overflow: overflow + }); options.complete(); } }); }, - bounceslide: function(options) { - this.slide(options, { + bounceslide: function( options ) { + this.slide( options, { easing: options.down ? "easeOutBounce" : "swing", duration: options.down ? 1000 : 200 }); @@ -4524,13 +4910,13 @@ $.extend($.ui.accordion, { } });
-})(jQuery); +})( jQuery ); /* - * jQuery UI Autocomplete 1.8 + * jQuery UI Autocomplete 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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 * @@ -4539,16 +4925,32 @@ $.extend($.ui.accordion, { * jquery.ui.widget.js * jquery.ui.position.js */ -(function( $ ) { +(function( $, undefined ) { + +// used to prevent race conditions with remote data sources +var requestIndex = 0;
$.widget( "ui.autocomplete", { options: { + appendTo: "body", + autoFocus: false, + delay: 300, minLength: 1, - delay: 300 + position: { + my: "left top", + at: "left bottom", + collision: "none" + }, + source: null }, + + pending: 0, + _create: function() { var self = this, - doc = this.element[ 0 ].ownerDocument; + doc = this.element[ 0 ].ownerDocument, + suppressKeyPress; + this.element .addClass( "ui-autocomplete-input" ) .attr( "autocomplete", "off" ) @@ -4559,6 +4961,11 @@ $.widget( "ui.autocomplete", { "aria-haspopup": "true" }) .bind( "keydown.autocomplete", function( event ) { + if ( self.options.disabled || self.element.propAttr( "readOnly" ) ) { + return; + } + + suppressKeyPress = false; var keyCode = $.ui.keyCode; switch( event.keyCode ) { case keyCode.PAGE_UP: @@ -4578,8 +4985,12 @@ $.widget( "ui.autocomplete", { event.preventDefault(); break; case keyCode.ENTER: - // when menu is open or has focus + case keyCode.NUMPAD_ENTER: + // when menu is open and has focus if ( self.menu.active ) { + // #6055 - Opera still allows the keypress to occur + // which causes forms to submit + suppressKeyPress = true; event.preventDefault(); } //passthrough - ENTER and TAB both select the current element @@ -4587,35 +4998,49 @@ $.widget( "ui.autocomplete", { if ( !self.menu.active ) { return; } - self.menu.select(); + self.menu.select( event ); break; case keyCode.ESCAPE: self.element.val( self.term ); self.close( event ); break; - case keyCode.SHIFT: - case keyCode.CONTROL: - case 18: - // ignore metakeys (shift, ctrl, alt) - break; default: // keypress is triggered before the input value is changed clearTimeout( self.searching ); self.searching = setTimeout(function() { - self.search( null, event ); + // only search if the value has changed + if ( self.term != self.element.val() ) { + self.selectedItem = null; + self.search( null, event ); + } }, self.options.delay ); break; } }) + .bind( "keypress.autocomplete", function( event ) { + if ( suppressKeyPress ) { + suppressKeyPress = false; + event.preventDefault(); + } + }) .bind( "focus.autocomplete", function() { + if ( self.options.disabled ) { + return; + } + + self.selectedItem = null; self.previous = self.element.val(); }) .bind( "blur.autocomplete", function( event ) { + if ( self.options.disabled ) { + return; + } + clearTimeout( self.searching ); // clicks on the menu (or a button to trigger a search) will cause a blur event - // TODO try to implement this without a timeout, see clearTimeout in search() self.closing = setTimeout(function() { self.close( event ); + self._change( event ); }, 150 ); }); this._initSource(); @@ -4624,29 +5049,73 @@ $.widget( "ui.autocomplete", { }; this.menu = $( "<ul></ul>" ) .addClass( "ui-autocomplete" ) - .appendTo( "body", doc ) + .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 ) { + // 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 ]; + 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(); + } + }); + }, 1 ); + } + + // 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", null, { item: item } ) ) { - // use value to match what will end up in the input - self.element.val( item.value ); + 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" ); - if ( false !== self._trigger( "select", event, { item: item } ) ) { - self.element.val( item.value ); - } - self.close( event ); - self.previous = self.element.val(); + 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); + } + + if ( false !== self._trigger( "select", event, { item: item } ) ) { + self.element.val( item.value ); } + // reset the term after the select event + // this allows custom select handling to work properly + self.term = self.element.val(); + + self.close( event ); + self.selectedItem = item; }, blur: function( event, ui ) { - if ( self.menu.element.is(":visible") ) { + // 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 ); } } @@ -4663,7 +5132,7 @@ $.widget( "ui.autocomplete", {
destroy: function() { this.element - .removeClass( "ui-autocomplete-input ui-widget ui-widget-content" ) + .removeClass( "ui-autocomplete-input" ) .removeAttr( "autocomplete" ) .removeAttr( "role" ) .removeAttr( "aria-autocomplete" ) @@ -4672,29 +5141,50 @@ $.widget( "ui.autocomplete", { $.Widget.prototype.destroy.call( this ); },
- _setOption: function( key ) { + _setOption: function( key, value ) { $.Widget.prototype._setOption.apply( this, arguments ); if ( key === "source" ) { this._initSource(); } + if ( key === "appendTo" ) { + this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] ) + } + if ( key === "disabled" && value && this.xhr ) { + this.xhr.abort(); + } },
_initSource: function() { - var array, + var self = this, + array, url; if ( $.isArray(this.options.source) ) { array = this.options.source; this.source = function( request, response ) { - // escape regex characters - var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" ); - response( $.grep( array, function(value) { - return matcher.test( value.label || value.value || value ); - }) ); + response( $.ui.autocomplete.filter(array, request.term) ); }; } else if ( typeof this.options.source === "string" ) { url = this.options.source; this.source = function( request, response ) { - $.getJSON( url, request, response ); + if ( self.xhr ) { + self.xhr.abort(); + } + self.xhr = $.ajax({ + url: url, + data: request, + dataType: "json", + autocompleteRequest: ++requestIndex, + success: function( data, status ) { + if ( this.autocompleteRequest === requestIndex ) { + response( data ); + } + }, + error: function() { + if ( this.autocompleteRequest === requestIndex ) { + response( [] ); + } + } + }); }; } else { this.source = this.options.source; @@ -4703,12 +5193,16 @@ $.widget( "ui.autocomplete", {
search: function( value, event ) { value = value != null ? value : this.element.val(); + + // always save the actual value, not the one passed as an argument + this.term = this.element.val(); + if ( value.length < this.options.minLength ) { return this.close( event ); }
clearTimeout( this.closing ); - if ( this._trigger("search") === false ) { + if ( this._trigger( "search", event ) === false ) { return; }
@@ -4716,34 +5210,38 @@ $.widget( "ui.autocomplete", { },
_search: function( value ) { - this.term = this.element - .addClass( "ui-autocomplete-loading" ) - // always save the actual value, not the one passed as an argument - .val(); + this.pending++; + this.element.addClass( "ui-autocomplete-loading" );
this.source( { term: value }, this.response ); },
_response: function( content ) { - if ( content.length ) { + if ( !this.options.disabled && content && content.length ) { content = this._normalize( content ); this._suggest( content ); this._trigger( "open" ); } else { this.close(); } - this.element.removeClass( "ui-autocomplete-loading" ); + this.pending--; + if ( !this.pending ) { + this.element.removeClass( "ui-autocomplete-loading" ); + } },
close: function( event ) { clearTimeout( this.closing ); if ( this.menu.element.is(":visible") ) { - this._trigger( "close", event ); this.menu.element.hide(); this.menu.deactivate(); + this._trigger( "close", event ); } + }, + + _change: function( event ) { if ( this.previous !== this.element.val() ) { - this._trigger( "change", event ); + this._trigger( "change", event, { item: this.selectedItem } ); } },
@@ -4768,26 +5266,33 @@ $.widget( "ui.autocomplete", {
_suggest: function( items ) { var ul = this.menu.element - .empty() - .zIndex( this.element.zIndex() + 1 ), - menuWidth, - textWidth; + .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(); - this.menu.element.show().position({ - my: "left top", - at: "left bottom", - of: this.element, - collision: "none" - });
- menuWidth = ul.width( "" ).width(); - textWidth = this.element.width(); - ul.width( Math.max( menuWidth, textWidth ) ); + // size and position menu + ul.show(); + this._resizeMenu(); + ul.position( $.extend({ + of: this.element + }, this.options.position )); + + if ( this.options.autoFocus ) { + this.menu.next( new $.Event("mouseover") ); + } }, - + + _resizeMenu: function() { + var ul = this.menu.element; + ul.outerWidth( Math.max( + ul.width( "" ).outerWidth(), + this.element.outerWidth() + ) ); + }, + _renderMenu: function( ul, items ) { var self = this; $.each( items, function( index, item ) { @@ -4798,7 +5303,7 @@ $.widget( "ui.autocomplete", { _renderItem: function( ul, item) { return $( "<li></li>" ) .data( "item.autocomplete", item ) - .append( "<a>" + item.label + "</a>" ) + .append( $( "<a></a>" ).text( item.label ) ) .appendTo( ul ); },
@@ -4813,7 +5318,7 @@ $.widget( "ui.autocomplete", { this.menu.deactivate(); return; } - this.menu[ direction ](); + this.menu[ direction ]( event ); },
widget: function() { @@ -4823,7 +5328,13 @@ $.widget( "ui.autocomplete", {
$.extend( $.ui.autocomplete, { escapeRegex: function( value ) { - return value.replace( /([^$()[]{}*.+?|\])/gi, "\$1" ); + return value.replace(/[-[]{}()*+?.,\^$|#\s]/g, "\$&"); + }, + filter: function(array, term) { + var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" ); + return $.grep( array, function(value) { + return matcher.test( value.label || value.value || value ); + }); } });
@@ -4836,9 +5347,9 @@ $.extend( $.ui.autocomplete, { * 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 (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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 * @@ -4857,10 +5368,13 @@ $.widget("ui.menu", { role: "listbox", "aria-activedescendant": "ui-active-menuitem" }) - .click(function(e) { + .click(function( event ) { + if ( !$( event.target ).closest( ".ui-menu-item a" ).length ) { + return; + } // temporary - e.preventDefault(); - self.select(); + event.preventDefault(); + self.select( event ); }); this.refresh(); }, @@ -4877,24 +5391,24 @@ $.widget("ui.menu", { .addClass("ui-corner-all") .attr("tabindex", -1) // mouseenter doesn't work with event delegation - .mouseenter(function() { - self.activate($(this).parent()); + .mouseenter(function( event ) { + self.activate( event, $(this).parent() ); }) .mouseleave(function() { self.deactivate(); }); },
- activate: function(item) { + activate: function( event, item ) { this.deactivate(); if (this.hasScroll()) { var offset = item.offset().top - this.element.offset().top, - scroll = this.element.attr("scrollTop"), + scroll = this.element.scrollTop(), elementHeight = this.element.height(); if (offset < 0) { - this.element.attr("scrollTop", scroll + offset); - } else if (offset > elementHeight) { - this.element.attr("scrollTop", scroll + offset - elementHeight + item.height()); + this.element.scrollTop( scroll + offset); + } else if (offset >= elementHeight) { + this.element.scrollTop( scroll + offset - elementHeight + item.height()); } } this.active = item.eq(0) @@ -4902,7 +5416,7 @@ $.widget("ui.menu", { .addClass("ui-state-hover") .attr("id", "ui-active-menuitem") .end(); - this._trigger("focus", null, { item: item }); + this._trigger("focus", event, { item: item }); },
deactivate: function() { @@ -4915,46 +5429,46 @@ $.widget("ui.menu", { this.active = null; },
- next: function() { - this.move("next", "li:first"); + next: function(event) { + this.move("next", ".ui-menu-item:first", event); },
- previous: function() { - this.move("prev", "li:last"); + previous: function(event) { + this.move("prev", ".ui-menu-item:last", event); },
first: function() { - return this.active && !this.active.prev().length; + return this.active && !this.active.prevAll(".ui-menu-item").length; },
last: function() { - return this.active && !this.active.next().length; + return this.active && !this.active.nextAll(".ui-menu-item").length; },
- move: function(direction, edge) { + move: function(direction, edge, event) { if (!this.active) { - this.activate(this.element.children(edge)); + this.activate(event, this.element.children(edge)); return; } - var next = this.active[direction](); + var next = this.active[direction + "All"](".ui-menu-item").eq(0); if (next.length) { - this.activate(next); + this.activate(event, next); } else { - this.activate(this.element.children(edge)); + this.activate(event, this.element.children(edge)); } },
// TODO merge with previousPage - nextPage: function() { + nextPage: function(event) { if (this.hasScroll()) { // TODO merge with no-scroll-else if (!this.active || this.last()) { - this.activate(this.element.children(":first")); + 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("li").filter(function() { + 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; @@ -4962,26 +5476,27 @@ $.widget("ui.menu", {
// TODO try to catch this earlier when scrollTop indicates the last page anyway if (!result.length) { - result = this.element.children(":last"); + result = this.element.children(".ui-menu-item:last"); } - this.activate(result); + this.activate(event, result); } else { - this.activate(this.element.children(!this.active || this.last() ? ":first" : ":last")); + this.activate(event, this.element.children(".ui-menu-item") + .filter(!this.active || this.last() ? ":first" : ":last")); } },
// TODO merge with nextPage - previousPage: function() { + previousPage: function(event) { if (this.hasScroll()) { // TODO merge with no-scroll-else if (!this.active || this.first()) { - this.activate(this.element.children(":last")); + 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("li").filter(function() { + 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; @@ -4989,30 +5504,31 @@ $.widget("ui.menu", {
// TODO try to catch this earlier when scrollTop indicates the last page anyway if (!result.length) { - result = this.element.children(":first"); + result = this.element.children(".ui-menu-item:first"); } - this.activate(result); + this.activate(event, result); } else { - this.activate(this.element.children(!this.active || this.first() ? ":last" : ":first")); + this.activate(event, this.element.children(".ui-menu-item") + .filter(!this.active || this.first() ? ":last" : ":first")); } },
hasScroll: function() { - return this.element.height() < this.element.attr("scrollHeight"); + return this.element.height() < this.element[ $.fn.prop ? "prop" : "attr" ]("scrollHeight"); },
- select: function() { - this._trigger("selected", null, { item: this.active }); + select: function( event ) { + this._trigger("selected", event, { item: this.active }); } });
}(jQuery)); /* - * jQuery UI Button 1.8 + * jQuery UI Button 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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 * @@ -5020,19 +5536,17 @@ $.widget("ui.menu", { * jquery.ui.core.js * jquery.ui.widget.js */ -(function( $ ) { +(function( $, undefined ) {
-var lastActive, +var lastActive, startXPos, startYPos, clickDragged, baseClasses = "ui-button ui-widget ui-state-default ui-corner-all", - otherClasses = "ui-state-hover ui-state-active " + - "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon ui-button-text-only", - formResetHandler = function( event ) { - $( ":ui-button", event.target.form ).each(function() { - var inst = $( this ).data( "button" ); - setTimeout(function() { - inst.refresh(); - }, 1 ); - }); + stateClasses = "ui-state-hover ui-state-active ", + typeClasses = "ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only", + formResetHandler = function() { + var buttons = $( this ).find( ":ui-button" ); + setTimeout(function() { + buttons.button( "refresh" ); + }, 1 ); }, radioGroup = function( radio ) { var name = radio.name, @@ -5053,6 +5567,7 @@ var lastActive,
$.widget( "ui.button", { options: { + disabled: null, text: true, label: null, icons: { @@ -5065,6 +5580,10 @@ $.widget( "ui.button", { .unbind( "reset.button" ) .bind( "reset.button", formResetHandler );
+ if ( typeof this.options.disabled !== "boolean" ) { + this.options.disabled = this.element.propAttr( "disabled" ); + } + this._determineButtonType(); this.hasTitle = !!this.buttonElement.attr( "title" );
@@ -5100,23 +5619,54 @@ $.widget( "ui.button", { } $( this ).removeClass( hoverClass ); }) + .bind( "click.button", function( event ) { + if ( options.disabled ) { + event.preventDefault(); + event.stopImmediatePropagation(); + } + }); + + this.element .bind( "focus.button", function() { // no need to check disabled, focus won't be triggered anyway - $( this ).addClass( focusClass ); + self.buttonElement.addClass( focusClass ); }) .bind( "blur.button", function() { - $( this ).removeClass( focusClass ); + self.buttonElement.removeClass( focusClass ); });
if ( toggleButton ) { this.element.bind( "change.button", function() { + if ( clickDragged ) { + return; + } self.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 ) { + if ( options.disabled ) { + return; + } + clickDragged = false; + startXPos = event.pageX; + startYPos = event.pageY; + }) + .bind( "mouseup.button", function( event ) { + if ( options.disabled ) { + return; + } + if ( startXPos !== event.pageX || startYPos !== event.pageY ) { + clickDragged = true; + } + }); }
if ( this.type === "checkbox" ) { this.buttonElement.bind( "click.button", function() { - if ( options.disabled ) { + if ( options.disabled || clickDragged ) { return false; } $( this ).toggleClass( "ui-state-active" ); @@ -5124,11 +5674,11 @@ $.widget( "ui.button", { }); } else if ( this.type === "radio" ) { this.buttonElement.bind( "click.button", function() { - if ( options.disabled ) { + if ( options.disabled || clickDragged ) { return false; } $( this ).addClass( "ui-state-active" ); - self.buttonElement.attr( "aria-pressed", true ); + self.buttonElement.attr( "aria-pressed", "true" );
var radio = self.element[ 0 ]; radioGroup( radio ) @@ -5137,7 +5687,7 @@ $.widget( "ui.button", { return $( this ).button( "widget" )[ 0 ]; }) .removeClass( "ui-state-active" ) - .attr( "aria-pressed", false ); + .attr( "aria-pressed", "false" ); }); } else { this.buttonElement @@ -5183,29 +5733,34 @@ $.widget( "ui.button", { // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can // be overridden by individual plugins this._setOption( "disabled", options.disabled ); + this._resetButton(); },
_determineButtonType: function() { - + if ( this.element.is(":checkbox") ) { this.type = "checkbox"; + } else if ( this.element.is(":radio") ) { + this.type = "radio"; + } else if ( this.element.is("input") ) { + this.type = "input"; } else { - if ( this.element.is(":radio") ) { - this.type = "radio"; - } else { - if ( this.element.is("input") ) { - this.type = "input"; - } else { - this.type = "button"; - } - } + this.type = "button"; } - + if ( this.type === "checkbox" || this.type === "radio" ) { // we don't search against the document in case the element // is disconnected from the DOM - this.buttonElement = this.element.parents().last() - .find( "[for=" + this.element.attr("id") + "]" ); + var ancestor = this.element.parents().filter(":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(); + this.buttonElement = ancestor.filter( labelSelector ); + if ( !this.buttonElement.length ) { + this.buttonElement = ancestor.find( labelSelector ); + } + } this.element.addClass( "ui-helper-hidden-accessible" );
var checked = this.element.is( ":checked" ); @@ -5226,7 +5781,7 @@ $.widget( "ui.button", { this.element .removeClass( "ui-helper-hidden-accessible" ); this.buttonElement - .removeClass( baseClasses + " " + otherClasses ) + .removeClass( baseClasses + " " + stateClasses + " " + typeClasses ) .removeAttr( "role" ) .removeAttr( "aria-pressed" ) .html( this.buttonElement.find(".ui-button-text").html() ); @@ -5242,10 +5797,11 @@ $.widget( "ui.button", { $.Widget.prototype._setOption.apply( this, arguments ); if ( key === "disabled" ) { if ( value ) { - this.element.attr( "disabled", true ); + this.element.propAttr( "disabled", true ); } else { - this.element.removeAttr( "disabled" ); + this.element.propAttr( "disabled", false ); } + return; } this._resetButton(); }, @@ -5260,22 +5816,22 @@ $.widget( "ui.button", { if ( $( this ).is( ":checked" ) ) { $( this ).button( "widget" ) .addClass( "ui-state-active" ) - .attr( "aria-pressed", true ); + .attr( "aria-pressed", "true" ); } else { $( this ).button( "widget" ) .removeClass( "ui-state-active" ) - .attr( "aria-pressed", false ); + .attr( "aria-pressed", "false" ); } }); } else if ( this.type === "checkbox" ) { if ( this.element.is( ":checked" ) ) { this.buttonElement .addClass( "ui-state-active" ) - .attr( "aria-pressed", true ); + .attr( "aria-pressed", "true" ); } else { this.buttonElement .removeClass( "ui-state-active" ) - .attr( "aria-pressed", false ); + .attr( "aria-pressed", "false" ); } } }, @@ -5287,41 +5843,50 @@ $.widget( "ui.button", { } return; } - var buttonElement = this.buttonElement, + var buttonElement = this.buttonElement.removeClass( typeClasses ), buttonText = $( "<span></span>" ) .addClass( "ui-button-text" ) .html( this.options.label ) .appendTo( buttonElement.empty() ) .text(), icons = this.options.icons, - multipleIcons = icons.primary && icons.secondary; + multipleIcons = icons.primary && icons.secondary, + buttonClasses = []; + if ( icons.primary || icons.secondary ) { - buttonElement.addClass( "ui-button-text-icon" + - ( multipleIcons ? "s" : "" ) ); + if ( this.options.text ) { + buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) ); + } + if ( icons.primary ) { buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" ); } + if ( icons.secondary ) { buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" ); } + if ( !this.options.text ) { - buttonElement - .addClass( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" ) - .removeClass( "ui-button-text-icons ui-button-text-icon" ); + buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" ); + if ( !this.hasTitle ) { buttonElement.attr( "title", buttonText ); } } } else { - buttonElement.addClass( "ui-button-text-only" ); + buttonClasses.push( "ui-button-text-only" ); } + buttonElement.addClass( buttonClasses.join( " " ) ); } });
$.widget( "ui.buttonset", { + options: { + items: ":button, :submit, :reset, :checkbox, :radio, a, :data(button)" + }, + _create: function() { this.element.addClass( "ui-buttonset" ); - this._init(); }, _init: function() { @@ -5337,7 +5902,9 @@ $.widget( "ui.buttonset", { }, refresh: function() { - this.buttons = this.element.find( ":button, :submit, :reset, :checkbox, :radio, a, :data(button)" ) + var ltr = this.element.css( "direction" ) === "ltr"; + + this.buttons = this.element.find( this.options.items ) .filter( ":ui-button" ) .button( "refresh" ) .end() @@ -5349,10 +5916,10 @@ $.widget( "ui.buttonset", { }) .removeClass( "ui-corner-all ui-corner-left ui-corner-right" ) .filter( ":first" ) - .addClass( "ui-corner-left" ) + .addClass( ltr ? "ui-corner-left" : "ui-corner-right" ) .end() .filter( ":last" ) - .addClass( "ui-corner-right" ) + .addClass( ltr ? "ui-corner-right" : "ui-corner-left" ) .end() .end(); }, @@ -5365,7 +5932,7 @@ $.widget( "ui.buttonset", { }) .removeClass( "ui-corner-left ui-corner-right" ) .end() - .button( "destroy" ) + .button( "destroy" );
$.Widget.prototype.destroy.call( this ); } @@ -5373,11 +5940,11 @@ $.widget( "ui.buttonset", {
}( jQuery ) ); /* - * jQuery UI Dialog 1.8 + * jQuery UI Dialog 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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 * @@ -5390,13 +5957,40 @@ $.widget( "ui.buttonset", { * jquery.ui.position.js * jquery.ui.resizable.js */ -(function($) { +(function( $, undefined ) {
var uiDialogClasses = - 'ui-dialog ' + - 'ui-widget ' + - 'ui-widget-content ' + - 'ui-corner-all '; + 'ui-dialog ' + + 'ui-widget ' + + 'ui-widget-content ' + + 'ui-corner-all ', + sizeRelatedOptions = { + buttons: true, + height: true, + maxHeight: true, + maxWidth: true, + minHeight: true, + minWidth: true, + width: true + }, + resizableRelatedOptions = { + maxHeight: true, + 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", { options: { @@ -5413,7 +6007,18 @@ $.widget("ui.dialog", { minHeight: 150, minWidth: 150, modal: false, - position: 'center', + position: { + my: 'center', + at: 'center', + 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); + } + } + }, resizable: true, show: null, stack: true, @@ -5421,13 +6026,19 @@ $.widget("ui.dialog", { width: 300, zIndex: 1000 }, + _create: function() { this.originalTitle = this.element.attr('title'); + // #5742 - .attr() might return a DOMElement + if ( typeof this.originalTitle !== "string" ) { + this.originalTitle = ""; + }
+ this.options.title = this.options.title || this.originalTitle; var self = this, options = self.options,
- title = options.title || self.originalTitle || ' ', + title = options.title || ' ', titleId = $.ui.dialog.getTitleId(self.element),
uiDialog = (self.uiDialog = $('<div></div>')) @@ -5440,7 +6051,7 @@ $.widget("ui.dialog", { // 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.keyCode && + if (options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode && event.keyCode === $.ui.keyCode.ESCAPE) { self.close(event); @@ -5535,6 +6146,7 @@ $.widget("ui.dialog", { uiDialog.bgiframe(); } }, + _init: function() { if ( this.options.autoOpen ) { this.open(); @@ -5561,14 +6173,14 @@ $.widget("ui.dialog", {
return self; }, - + widget: function() { return this.uiDialog; },
close: function(event) { var self = this, - maxZ; + maxZ, thisZ; if (false === self._trigger('beforeClose', event)) { return; @@ -5597,7 +6209,10 @@ $.widget("ui.dialog", { maxZ = 0; $('.ui-dialog').each(function() { if (this !== self.uiDialog[0]) { - maxZ = Math.max(maxZ, $(this).css('z-index')); + thisZ = $(this).css('z-index'); + if(!isNaN(thisZ)) { + maxZ = Math.max(maxZ, thisZ); + } } }); $.ui.dialog.maxZ = maxZ; @@ -5616,12 +6231,12 @@ $.widget("ui.dialog", { var self = this, options = self.options, saveScroll; - + if ((options.modal && !force) || (!options.stack && !options.modal)) { return self._trigger('focus', event); } - + if (options.zIndex > $.ui.dialog.maxZ) { $.ui.dialog.maxZ = options.zIndex; } @@ -5632,7 +6247,7 @@ $.widget("ui.dialog", {
//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.attr('scrollTop'), scrollLeft: self.element.attr('scrollLeft') }; + saveScroll = { scrollTop: self.element.scrollTop(), scrollLeft: self.element.scrollLeft() }; $.ui.dialog.maxZ += 1; self.uiDialog.css('z-index', $.ui.dialog.maxZ); self.element.attr(saveScroll); @@ -5649,9 +6264,6 @@ $.widget("ui.dialog", { uiDialog = self.uiDialog;
self.overlay = options.modal ? new $.ui.dialog.overlay(self) : null; - if (uiDialog.next().length) { - uiDialog.appendTo('body'); - } self._size(); self._position(options.position); uiDialog.show(options.show); @@ -5663,11 +6275,11 @@ $.widget("ui.dialog", { if (event.keyCode !== $.ui.keyCode.TAB) { return; } - + var tabbables = $(':tabbable', this), first = tabbables.filter(':first'), last = tabbables.filter(':last'); - + if (event.target === last[0] && !event.shiftKey) { first.focus(1); return false; @@ -5680,15 +6292,12 @@ $.widget("ui.dialog", {
// 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 - $([]) - .add(uiDialog.find('.ui-dialog-content :tabbable:first')) - .add(uiDialog.find('.ui-dialog-buttonpane :tabbable:first')) - .add(uiDialog) - .filter(':first') - .focus(); + $(self.element.find(':tabbable').get().concat( + uiDialog.find('.ui-dialog-buttonpane :tabbable').get().concat( + uiDialog.get()))).eq(0).focus();
- self._trigger('open'); self._isOpen = true; + self._trigger('open');
return self; }, @@ -5701,7 +6310,10 @@ $.widget("ui.dialog", { 'ui-dialog-buttonpane ' + 'ui-widget-content ' + 'ui-helper-clearfix' - ); + ), + uiButtonSet = $( "<div></div>" ) + .addClass( "ui-dialog-buttonset" ) + .appendTo( uiDialogButtonPane );
// if we already have a button pane, remove it self.uiDialog.find('.ui-dialog-buttonpane').remove(); @@ -5712,11 +6324,26 @@ $.widget("ui.dialog", { }); } if (hasButtons) { - $.each(buttons, function(name, fn) { + $.each(buttons, function(name, props) { + props = $.isFunction( props ) ? + { click: props, text: name } : + props; var button = $('<button type="button"></button>') - .text(name) - .click(function() { fn.apply(self.element[0], arguments); }) - .appendTo(uiDialogButtonPane); + .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) { button.button(); } @@ -5824,40 +6451,34 @@ $.widget("ui.dialog", { offset = [0, 0], isVisible;
- position = position || $.ui.dialog.prototype.options.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(' ');
- // 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; - } - }); - } else if (typeof position === 'object') { - if ('left' in position) { - myAt[0] = 'left'; - offset[0] = position.left; - } else if ('right' in position) { - myAt[0] = 'right'; - offset[0] = -position.right; - } + position = { + my: myAt.join(" "), + at: myAt.join(" "), + offset: offset.join(" ") + }; + }
- if ('top' in position) { - myAt[1] = 'top'; - offset[1] = position.top; - } else if ('bottom' in position) { - myAt[1] = 'bottom'; - offset[1] = -position.bottom; - } + 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 @@ -5868,31 +6489,40 @@ $.widget("ui.dialog", { this.uiDialog // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781 .css({ top: 0, left: 0 }) - .position({ - my: myAt.join(' '), - at: myAt.join(' '), - offset: offset.join(' '), - 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); - } - } - }); + .position($.extend({ of: window }, position)); if (!isVisible) { this.uiDialog.hide(); } },
- _setOption: function(key, value){ + _setOptions: function( options ) { var self = this, - uiDialog = self.uiDialog, - isResizable = uiDialog.is(':data(resizable)'), + resizableOptions = {}, resize = false; - + + $.each( options, function( key, value ) { + self._setOption( key, value ); + + if ( key in sizeRelatedOptions ) { + resize = true; + } + if ( key in resizableRelatedOptions ) { + resizableOptions[ key ] = value; + } + }); + + if ( resize ) { + this._size(); + } + if ( this.uiDialog.is( ":data(resizable)" ) ) { + this.uiDialog.resizable( "option", resizableOptions ); + } + }, + + _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 @@ -5904,7 +6534,7 @@ $.widget("ui.dialog", { self._createButtons(value); break; case "closeText": - // convert whatever was passed in to a string, for text() to not throw up + // ensure that we always pass a string self.uiDialogTitlebarCloseText.text("" + value); break; case "dialogClass": @@ -5920,44 +6550,21 @@ $.widget("ui.dialog", { } break; case "draggable": - if (value) { - self._makeDraggable(); - } else { - uiDialog.draggable('destroy'); - } - break; - case "height": - resize = true; - break; - case "maxHeight": - if (isResizable) { - uiDialog.resizable('option', 'maxHeight', value); + var isDraggable = uiDialog.is( ":data(draggable)" ); + if ( isDraggable && !value ) { + uiDialog.draggable( "destroy" ); } - resize = true; - break; - case "maxWidth": - if (isResizable) { - uiDialog.resizable('option', 'maxWidth', value); - } - resize = true; - break; - case "minHeight": - if (isResizable) { - uiDialog.resizable('option', 'minHeight', value); - } - resize = true; - break; - case "minWidth": - if (isResizable) { - uiDialog.resizable('option', 'minWidth', value); + + if ( !isDraggable && value ) { + self._makeDraggable(); } - resize = true; break; case "position": self._position(value); break; case "resizable": // currently resizable, becoming non-resizable + var isResizable = uiDialog.is( ":data(resizable)" ); if (isResizable && !value) { uiDialog.resizable('destroy'); } @@ -5976,15 +6583,9 @@ $.widget("ui.dialog", { // convert whatever was passed in o a string, for html() to not throw up $(".ui-dialog-title", self.uiDialogTitlebar).html("" + (value || ' ')); break; - case "width": - resize = true; - break; }
$.Widget.prototype._setOption.apply(self, arguments); - if (resize) { - self._size(); - } },
_size: function() { @@ -5992,12 +6593,20 @@ $.widget("ui.dialog", { * divs will both have width and height set, so we need to reset them */ var options = this.options, - nonContentHeight; + nonContentHeight, + minContentHeight, + isVisible = this.uiDialog.is( ":visible" );
// reset content sizing - // hide for non content measurement because height: 0 doesn't work in IE quirks mode (see #4350) - this.element.css('width', 'auto') - .hide(); + this.element.show().css({ + width: 'auto', + minHeight: 0, + height: 0 + }); + + if (options.minWidth > options.width) { + options.width = options.minWidth; + }
// reset wrapper sizing // determine the height of all the non-content elements @@ -6006,16 +6615,26 @@ $.widget("ui.dialog", { width: options.width }) .height(); - - this.element - .css(options.height === 'auto' ? { - minHeight: Math.max(options.minHeight - nonContentHeight, 0), - height: 'auto' - } : { - minHeight: 0, - height: Math.max(options.height - nonContentHeight, 0) - }) - .show(); + minContentHeight = Math.max( 0, options.minHeight - nonContentHeight ); + + if ( options.height === "auto" ) { + // only needed for IE6 support + if ( $.support.minHeight ) { + this.element.css({ + minHeight: minContentHeight, + height: "auto" + }); + } else { + this.uiDialog.show(); + var autoHeight = this.element.css( "height", "auto" ).height(); + if ( !isVisible ) { + this.uiDialog.hide(); + } + this.element.height( Math.max( autoHeight, minContentHeight ) ); + } + } else { + this.element.height( Math.max( options.height - nonContentHeight, 0 ) ); + }
if (this.uiDialog.is(':data(resizable)')) { this.uiDialog.resizable('option', 'minHeight', this._minHeight()); @@ -6024,7 +6643,7 @@ $.widget("ui.dialog", { });
$.extend($.ui.dialog, { - version: "1.8", + version: "1.8.16",
uuid: 0, maxZ: 0, @@ -6060,14 +6679,17 @@ $.extend($.ui.dialog.overlay, { 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 - return ($(event.target).zIndex() >= $.ui.dialog.overlay.maxZ); + // we cannot return true when we don't want to cancel the event (#3523) + 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.keyCode && + if (dialog.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode && event.keyCode === $.ui.keyCode.ESCAPE) { dialog.close(event); @@ -6095,7 +6717,10 @@ $.extend($.ui.dialog.overlay, { },
destroy: function($el) { - this.oldInstances.push(this.instances.splice($.inArray($el, this.instances), 1)[0]); + var indexOf = $.inArray($el, this.instances); + if (indexOf != -1){ + this.oldInstances.push(this.instances.splice(indexOf, 1)[0]); + }
if (this.instances.length === 0) { $([document, window]).unbind('.dialog-overlay'); @@ -6139,8 +6764,8 @@ $.extend($.ui.dialog.overlay, { width: function() { var scrollWidth, offsetWidth; - // handle IE 6 - if ($.browser.msie && $.browser.version < 7) { + // handle IE + if ( $.browser.msie ) { scrollWidth = Math.max( document.documentElement.scrollWidth, document.body.scrollWidth @@ -6193,11 +6818,11 @@ $.extend($.ui.dialog.overlay.prototype, {
}(jQuery)); /* - * jQuery UI Slider 1.8 + * jQuery UI Slider 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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 * @@ -6206,29 +6831,36 @@ $.extend($.ui.dialog.overlay.prototype, { * jquery.ui.mouse.js * jquery.ui.widget.js */ - -(function($) { +(function( $, undefined ) {
// number of pages in a slider // (how many times can you page up/down to go through the whole range) var numPages = 5;
-$.widget("ui.slider", $.ui.mouse, { +$.widget( "ui.slider", $.ui.mouse, { + widgetEventPrefix: "slide", + options: { animate: false, distance: 0, max: 100, min: 0, - orientation: 'horizontal', + orientation: "horizontal", range: false, step: 1, value: 0, values: null }, + _create: function() { + var self = this, + 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 = [];
- var self = this, o = this.options; this._keySliding = false; this._mouseSliding = false; this._animateOff = true; @@ -6237,197 +6869,196 @@ $.widget("ui.slider", $.ui.mouse, { this._mouseInit();
this.element - .addClass("ui-slider" - + " ui-slider-" + this.orientation - + " ui-widget" - + " ui-widget-content" - + " ui-corner-all"); - - if (o.disabled) { - this.element.addClass('ui-slider-disabled ui-disabled'); - } + .addClass( "ui-slider" + + " ui-slider-" + this.orientation + + " ui-widget" + + " ui-widget-content" + + " ui-corner-all" + + ( o.disabled ? " ui-slider-disabled ui-disabled" : "" ) );
this.range = $([]);
- if (o.range) { - - if (o.range === true) { - this.range = $('<div></div>'); - if (!o.values) o.values = [this._valueMin(), this._valueMin()]; - if (o.values.length && o.values.length != 2) { - o.values = [o.values[0], o.values[0]]; + if ( o.range ) { + if ( o.range === true ) { + if ( !o.values ) { + o.values = [ this._valueMin(), this._valueMin() ]; + } + if ( o.values.length && o.values.length !== 2 ) { + o.values = [ o.values[0], o.values[0] ]; } - } else { - this.range = $('<div></div>'); - } - - this.range - .appendTo(this.element) - .addClass("ui-slider-range"); - - if (o.range == "min" || o.range == "max") { - this.range.addClass("ui-slider-range-" + o.range); }
- // note: this isn't the most fittingly semantic framework class for this element, - // but worked best visually with a variety of themes - this.range.addClass("ui-widget-header"); - + this.range = $( "<div></div>" ) + .appendTo( this.element ) + .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" + + ( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) ); }
- if ($(".ui-slider-handle", this.element).length == 0) - $('<a href="#"></a>') - .appendTo(this.element) - .addClass("ui-slider-handle"); - - if (o.values && o.values.length) { - while ($(".ui-slider-handle", this.element).length < o.values.length) - $('<a href="#"></a>') - .appendTo(this.element) - .addClass("ui-slider-handle"); + for ( var i = existingHandles.length; i < handleCount; i += 1 ) { + handles.push( handle ); }
- this.handles = $(".ui-slider-handle", this.element) - .addClass("ui-state-default" - + " ui-corner-all"); + this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( self.element ) );
- this.handle = this.handles.eq(0); + this.handle = this.handles.eq( 0 );
- this.handles.add(this.range).filter("a") - .click(function(event) { + this.handles.add( this.range ).filter( "a" ) + .click(function( event ) { event.preventDefault(); }) .hover(function() { - if (!o.disabled) { - $(this).addClass('ui-state-hover'); + if ( !o.disabled ) { + $( this ).addClass( "ui-state-hover" ); } }, function() { - $(this).removeClass('ui-state-hover'); + $( this ).removeClass( "ui-state-hover" ); }) .focus(function() { - if (!o.disabled) { - $(".ui-slider .ui-state-focus").removeClass('ui-state-focus'); $(this).addClass('ui-state-focus'); + if ( !o.disabled ) { + $( ".ui-slider .ui-state-focus" ).removeClass( "ui-state-focus" ); + $( this ).addClass( "ui-state-focus" ); } else { - $(this).blur(); + $( this ).blur(); } }) .blur(function() { - $(this).removeClass('ui-state-focus'); + $( this ).removeClass( "ui-state-focus" ); });
- this.handles.each(function(i) { - $(this).data("index.ui-slider-handle", i); + this.handles.each(function( i ) { + $( this ).data( "index.ui-slider-handle", i ); });
- this.handles.keydown(function(event) { - - var ret = true; - - var index = $(this).data("index.ui-slider-handle"); - - if (self.options.disabled) - return; - - switch (event.keyCode) { - case $.ui.keyCode.HOME: - case $.ui.keyCode.END: - case $.ui.keyCode.PAGE_UP: - case $.ui.keyCode.PAGE_DOWN: - case $.ui.keyCode.UP: - 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"); - self._start(event, index); - } - break; - } - - var curVal, newVal, step = self._step(); - if (self.options.values && self.options.values.length) { - curVal = newVal = self.values(index); - } else { - curVal = newVal = self.value(); - } - - switch (event.keyCode) { - case $.ui.keyCode.HOME: - newVal = self._valueMin(); - break; - case $.ui.keyCode.END: - newVal = self._valueMax(); - break; - case $.ui.keyCode.PAGE_UP: - newVal = curVal + ((self._valueMax() - self._valueMin()) / numPages); - break; - case $.ui.keyCode.PAGE_DOWN: - newVal = curVal - ((self._valueMax() - self._valueMin()) / numPages); - break; - case $.ui.keyCode.UP: - case $.ui.keyCode.RIGHT: - if(curVal == self._valueMax()) return; - newVal = curVal + step; - break; - case $.ui.keyCode.DOWN: - case $.ui.keyCode.LEFT: - if(curVal == self._valueMin()) return; - newVal = 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.handles + .keydown(function( event ) { + var ret = true, + index = $( this ).data( "index.ui-slider-handle" ), + allowed, + curVal, + newVal, + step; + + if ( self.options.disabled ) { + return; + } + + switch ( event.keyCode ) { + case $.ui.keyCode.HOME: + case $.ui.keyCode.END: + case $.ui.keyCode.PAGE_UP: + case $.ui.keyCode.PAGE_DOWN: + case $.ui.keyCode.UP: + 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 ); + if ( allowed === false ) { + return; + } + } + break; + } + + step = self.options.step; + if ( self.options.values && self.options.values.length ) { + curVal = newVal = self.values( index ); + } else { + curVal = newVal = self.value(); + } + + switch ( event.keyCode ) { + case $.ui.keyCode.HOME: + newVal = self._valueMin(); + break; + case $.ui.keyCode.END: + newVal = self._valueMax(); + break; + case $.ui.keyCode.PAGE_UP: + newVal = self._trimAlignValue( curVal + ( (self._valueMax() - self._valueMin()) / numPages ) ); + break; + case $.ui.keyCode.PAGE_DOWN: + newVal = self._trimAlignValue( curVal - ( (self._valueMax() - self._valueMin()) / numPages ) ); + break; + case $.ui.keyCode.UP: + case $.ui.keyCode.RIGHT: + if ( curVal === self._valueMax() ) { + return; + } + newVal = self._trimAlignValue( curVal + step ); + break; + case $.ui.keyCode.DOWN: + case $.ui.keyCode.LEFT: + if ( curVal === self._valueMin() ) { + return; + } + newVal = self._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._refreshValue();
this._animateOff = false; - },
destroy: function() { - this.handles.remove(); this.range.remove();
this.element - .removeClass("ui-slider" - + " ui-slider-horizontal" - + " ui-slider-vertical" - + " ui-slider-disabled" - + " ui-widget" - + " ui-widget-content" - + " ui-corner-all") - .removeData("slider") - .unbind(".slider"); + .removeClass( "ui-slider" + + " ui-slider-horizontal" + + " ui-slider-vertical" + + " ui-slider-disabled" + + " ui-widget" + + " ui-widget-content" + + " ui-corner-all" ) + .removeData( "slider" ) + .unbind( ".slider" );
this._mouseDestroy();
return this; },
- _mouseCapture: function(event) { + _mouseCapture: function( event ) { + var o = this.options, + position, + normValue, + distance, + closestHandle, + self, + index, + allowed, + offset, + mouseOverHandle;
- var o = this.options; - - if (o.disabled) + if ( o.disabled ) { return false; + }
this.elementSize = { width: this.element.outerWidth(), @@ -6435,16 +7066,15 @@ $.widget("ui.slider", $.ui.mouse, { }; this.elementOffset = this.element.offset();
- var position = { x: event.pageX, y: event.pageY }; - var normValue = this._normValueFromMouse(position); - - var distance = this._valueMax() - this._valueMin() + 1, closestHandle; - var self = this, index; - this.handles.each(function(i) { - var thisDistance = Math.abs(normValue - self.values(i)); - if (distance > thisDistance) { + 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) ); + if ( distance > thisDistance ) { distance = thisDistance; - closestHandle = $(this); + closestHandle = $( this ); index = i; } }); @@ -6452,216 +7082,221 @@ $.widget("ui.slider", $.ui.mouse, { // workaround for bug #3736 (if both handles of a range are at 0, // the first is always used as the one with least distance, // and moving it is obviously prevented by preventing negative ranges) - if(o.range == true && this.values(1) == o.min) { - closestHandle = $(this.handles[++index]); + if( o.range === true && this.values(1) === o.min ) { + index += 1; + closestHandle = $( this.handles[index] ); }
- this._start(event, index); + allowed = this._start( event, index ); + if ( allowed === false ) { + return false; + } this._mouseSliding = true;
self._handleIndex = index;
closestHandle - .addClass("ui-state-active") + .addClass( "ui-state-active" ) .focus(); - var offset = closestHandle.offset(); - var mouseOverHandle = !$(event.target).parents().andSelf().is('.ui-slider-handle'); + offset = closestHandle.offset(); + mouseOverHandle = !$( event.target ).parents().andSelf().is( ".ui-slider-handle" ); this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : { - left: event.pageX - offset.left - (closestHandle.width() / 2), - top: event.pageY - offset.top - - (closestHandle.height() / 2) - - (parseInt(closestHandle.css('borderTopWidth'),10) || 0) - - (parseInt(closestHandle.css('borderBottomWidth'),10) || 0) - + (parseInt(closestHandle.css('marginTop'),10) || 0) + left: event.pageX - offset.left - ( closestHandle.width() / 2 ), + top: event.pageY - offset.top - + ( closestHandle.height() / 2 ) - + ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) - + ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) + + ( parseInt( closestHandle.css("marginTop"), 10 ) || 0) };
- normValue = this._normValueFromMouse(position); - this._slide(event, index, normValue); + if ( !this.handles.hasClass( "ui-state-hover" ) ) { + this._slide( event, index, normValue ); + } this._animateOff = true; return true; - },
- _mouseStart: function(event) { + _mouseStart: function( event ) { return true; },
- _mouseDrag: function(event) { - - var position = { x: event.pageX, y: event.pageY }; - var normValue = this._normValueFromMouse(position); + _mouseDrag: function( event ) { + var position = { x: event.pageX, y: event.pageY }, + normValue = this._normValueFromMouse( position ); - this._slide(event, this._handleIndex, normValue); + this._slide( event, this._handleIndex, normValue );
return false; - },
- _mouseStop: function(event) { - - this.handles.removeClass("ui-state-active"); + _mouseStop: function( event ) { + this.handles.removeClass( "ui-state-active" ); this._mouseSliding = false; - this._stop(event, this._handleIndex); - this._change(event, this._handleIndex); + + this._stop( event, this._handleIndex ); + this._change( event, this._handleIndex ); + this._handleIndex = null; this._clickOffset = null; - this._animateOff = false; - return false;
+ return false; }, _detectOrientation: function() { - this.orientation = this.options.orientation == 'vertical' ? 'vertical' : 'horizontal'; + this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal"; },
- _normValueFromMouse: function(position) { + _normValueFromMouse: function( position ) { + var pixelTotal, + pixelMouse, + percentMouse, + valueTotal, + valueMouse;
- var pixelTotal, pixelMouse; - if ('horizontal' == this.orientation) { + if ( this.orientation === "horizontal" ) { pixelTotal = this.elementSize.width; - pixelMouse = position.x - this.elementOffset.left - (this._clickOffset ? this._clickOffset.left : 0); + pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 ); } else { pixelTotal = this.elementSize.height; - pixelMouse = position.y - this.elementOffset.top - (this._clickOffset ? this._clickOffset.top : 0); + pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 ); }
- var percentMouse = (pixelMouse / pixelTotal); - if (percentMouse > 1) percentMouse = 1; - if (percentMouse < 0) percentMouse = 0; - if ('vertical' == this.orientation) + percentMouse = ( pixelMouse / pixelTotal ); + if ( percentMouse > 1 ) { + percentMouse = 1; + } + if ( percentMouse < 0 ) { + percentMouse = 0; + } + if ( this.orientation === "vertical" ) { percentMouse = 1 - percentMouse; + }
- var valueTotal = this._valueMax() - this._valueMin(), - valueMouse = percentMouse * valueTotal, - valueMouseModStep = valueMouse % this.options.step, - normValue = this._valueMin() + valueMouse - valueMouseModStep; - - if (valueMouseModStep > (this.options.step / 2)) - normValue += this.options.step; - - // Since JavaScript has problems with large floats, round - // the final value to 5 digits after the decimal point (see #4124) - return parseFloat(normValue.toFixed(5)); + valueTotal = this._valueMax() - this._valueMin(); + valueMouse = this._valueMin() + percentMouse * valueTotal;
+ return this._trimAlignValue( valueMouse ); },
- _start: function(event, index) { + _start: function( event, index ) { var uiHash = { - handle: this.handles[index], + handle: this.handles[ index ], value: this.value() }; - if (this.options.values && this.options.values.length) { - uiHash.value = this.values(index); + if ( this.options.values && this.options.values.length ) { + uiHash.value = this.values( index ); uiHash.values = this.values(); } - this._trigger("start", event, uiHash); + return this._trigger( "start", event, uiHash ); },
- _slide: function(event, index, newVal) { - - var handle = this.handles[index]; - - if (this.options.values && this.options.values.length) { + _slide: function( event, index, newVal ) { + var otherVal, + newValues, + allowed;
- var otherVal = this.values(index ? 0 : 1); + if ( this.options.values && this.options.values.length ) { + otherVal = this.values( index ? 0 : 1 );
- if ((this.options.values.length == 2 && this.options.range === true) && - ((index == 0 && newVal > otherVal) || (index == 1 && newVal < otherVal))){ - newVal = otherVal; + if ( ( this.options.values.length === 2 && this.options.range === true ) && + ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) ) + ) { + newVal = otherVal; }
- if (newVal != this.values(index)) { - var newValues = this.values(); - newValues[index] = newVal; + if ( newVal !== this.values( index ) ) { + newValues = this.values(); + newValues[ index ] = newVal; // A slide can be canceled by returning false from the slide callback - var allowed = this._trigger("slide", event, { - handle: this.handles[index], + allowed = this._trigger( "slide", event, { + handle: this.handles[ index ], value: newVal, values: newValues - }); - var otherVal = this.values(index ? 0 : 1); - if (allowed !== false) { - this.values(index, newVal, true); + } ); + otherVal = this.values( index ? 0 : 1 ); + if ( allowed !== false ) { + this.values( index, newVal, true ); } } - } else { - - if (newVal != this.value()) { + if ( newVal !== this.value() ) { // A slide can be canceled by returning false from the slide callback - var allowed = this._trigger("slide", event, { - handle: this.handles[index], + allowed = this._trigger( "slide", event, { + handle: this.handles[ index ], value: newVal - }); - if (allowed !== false) { - this.value(newVal); + } ); + if ( allowed !== false ) { + this.value( newVal ); } - } - } - },
- _stop: function(event, index) { + _stop: function( event, index ) { var uiHash = { - handle: this.handles[index], + handle: this.handles[ index ], value: this.value() }; - if (this.options.values && this.options.values.length) { - uiHash.value = this.values(index); + if ( this.options.values && this.options.values.length ) { + uiHash.value = this.values( index ); uiHash.values = this.values(); } - this._trigger("stop", event, uiHash); + + this._trigger( "stop", event, uiHash ); },
- _change: function(event, index) { - if (!this._keySliding && !this._mouseSliding) { + _change: function( event, index ) { + if ( !this._keySliding && !this._mouseSliding ) { var uiHash = { - handle: this.handles[index], + handle: this.handles[ index ], value: this.value() }; - if (this.options.values && this.options.values.length) { - uiHash.value = this.values(index); + if ( this.options.values && this.options.values.length ) { + uiHash.value = this.values( index ); uiHash.values = this.values(); } - this._trigger("change", event, uiHash); + + this._trigger( "change", event, uiHash ); } },
- value: function(newValue) { - - if (arguments.length) { - this.options.value = this._trimValue(newValue); + value: function( newValue ) { + if ( arguments.length ) { + this.options.value = this._trimAlignValue( newValue ); this._refreshValue(); - this._change(null, 0); + this._change( null, 0 ); + return; }
return this._value(); - },
- values: function(index, newValue) { + values: function( index, newValue ) { + var vals, + newValues, + i;
- if (arguments.length > 1) { - this.options.values[index] = this._trimValue(newValue); + if ( arguments.length > 1 ) { + this.options.values[ index ] = this._trimAlignValue( newValue ); this._refreshValue(); - this._change(null, index); + this._change( null, index ); + return; }
- if (arguments.length) { - if ($.isArray(arguments[0])) { - var vals = this.options.values, newValues = arguments[0]; - for (var i = 0, l = vals.length; i < l; i++) { - vals[i] = this._trimValue(newValues[i]); - this._change(null, i); + if ( arguments.length ) { + if ( $.isArray( arguments[ 0 ] ) ) { + vals = this.options.values; + newValues = arguments[ 0 ]; + for ( i = 0; i < vals.length; i += 1 ) { + vals[ i ] = this._trimAlignValue( newValues[ i ] ); + this._change( null, i ); } this._refreshValue(); } else { - if (this.options.values && this.options.values.length) { - return this._values(index); + if ( this.options.values && this.options.values.length ) { + return this._values( index ); } else { return this.value(); } @@ -6669,164 +7304,191 @@ $.widget("ui.slider", $.ui.mouse, { } else { return this._values(); } - },
- _setOption: function(key, value) { - + _setOption: function( key, value ) { var i, valsLength = 0; - if ( jQuery.isArray(this.options.values) ) { + + if ( $.isArray( this.options.values ) ) { valsLength = this.options.values.length; - }; + }
- $.Widget.prototype._setOption.apply(this, arguments); + $.Widget.prototype._setOption.apply( this, arguments );
- switch (key) { - case 'disabled': - if (value) { - this.handles.filter(".ui-state-focus").blur(); - this.handles.removeClass("ui-state-hover"); - this.handles.attr("disabled", "disabled"); - this.element.addClass("ui-disabled"); + switch ( key ) { + case "disabled": + if ( value ) { + this.handles.filter( ".ui-state-focus" ).blur(); + this.handles.removeClass( "ui-state-hover" ); + this.handles.propAttr( "disabled", true ); + this.element.addClass( "ui-disabled" ); } else { - this.handles.removeAttr("disabled"); - this.element.removeClass("ui-disabled"); + this.handles.propAttr( "disabled", false ); + this.element.removeClass( "ui-disabled" ); } - case 'orientation': - + break; + case "orientation": this._detectOrientation(); - this.element - .removeClass("ui-slider-horizontal ui-slider-vertical") - .addClass("ui-slider-" + this.orientation); + .removeClass( "ui-slider-horizontal ui-slider-vertical" ) + .addClass( "ui-slider-" + this.orientation ); this._refreshValue(); break; - case 'value': + case "value": this._animateOff = true; this._refreshValue(); - this._change(null, 0); + this._change( null, 0 ); this._animateOff = false; break; - case 'values': + case "values": this._animateOff = true; this._refreshValue(); - for (i = 0; i < valsLength; i++) { - this._change(null, i); + for ( i = 0; i < valsLength; i += 1 ) { + this._change( null, i ); } this._animateOff = false; break; } - - }, - - _step: function() { - var step = this.options.step; - return step; },
+ //internal value getter + // _value() returns value trimmed by min and max, aligned by step _value: function() { - //internal value getter - // _value() returns value trimmed by min and max var val = this.options.value; - val = this._trimValue(val); + val = this._trimAlignValue( val );
return val; },
- _values: function(index) { - //internal values getter - // _values() returns array of values trimmed by min and max - // _values(index) returns single value trimmed by min and max + //internal values getter + // _values() returns array of values trimmed by min and max, aligned by step + // _values( index ) returns single value trimmed by min and max, aligned by step + _values: function( index ) { + var val, + vals, + i;
- if (arguments.length) { - var val = this.options.values[index]; - val = this._trimValue(val); + if ( arguments.length ) { + val = this.options.values[ index ]; + val = this._trimAlignValue( val );
return val; } else { // .slice() creates a copy of the array // this copy gets trimmed by min and max and then returned - var vals = this.options.values.slice(); - for (var i = 0, l = vals.length; i < l; i++) { - vals[i] = this._trimValue(vals[i]); + vals = this.options.values.slice(); + for ( i = 0; i < vals.length; i+= 1) { + vals[ i ] = this._trimAlignValue( vals[ i ] ); }
return vals; } - }, - _trimValue: function(val) { - if (val < this._valueMin()) val = this._valueMin(); - if (val > this._valueMax()) val = this._valueMax(); + // returns the step-aligned value that val is closest to, between (inclusive) min and max + _trimAlignValue: function( val ) { + if ( val <= this._valueMin() ) { + return this._valueMin(); + } + if ( val >= this._valueMax() ) { + return this._valueMax(); + } + var step = ( this.options.step > 0 ) ? this.options.step : 1, + valModStep = (val - this._valueMin()) % step, + alignValue = val - valModStep;
- return val; + if ( Math.abs(valModStep) * 2 >= step ) { + alignValue += ( valModStep > 0 ) ? step : ( -step ); + } + + // Since JavaScript has problems with large floats, round + // the final value to 5 digits after the decimal point (see #4124) + return parseFloat( alignValue.toFixed(5) ); },
_valueMin: function() { - var valueMin = this.options.min; - return valueMin; + return this.options.min; },
_valueMax: function() { - var valueMax = this.options.max; - return valueMax; + return this.options.max; }, _refreshValue: function() { - - var oRange = this.options.range, o = this.options, self = this; - var animate = (!this._animateOff) ? o.animate : false; - - if (this.options.values && this.options.values.length) { - var vp0, vp1; - this.handles.each(function(i, j) { - var valPercent = (self.values(i) - self._valueMin()) / (self._valueMax() - self._valueMin()) * 100; - var _set = {}; _set[self.orientation == 'horizontal' ? 'left' : 'bottom'] = valPercent + '%'; - $(this).stop(1,1)[animate ? 'animate' : 'css'](_set, o.animate); - if (self.options.range === true) { - if (self.orientation == 'horizontal') { - (i == 0) && self.range.stop(1,1)[animate ? 'animate' : 'css']({ left: valPercent + '%' }, o.animate); - (i == 1) && self.range[animate ? 'animate' : 'css']({ width: (valPercent - lastValPercent) + '%' }, { queue: false, duration: o.animate }); + var oRange = this.options.range, + o = this.options, + self = this, + animate = ( !this._animateOff ) ? o.animate : false, + valPercent, + _set = {}, + lastValPercent, + value, + valueMin, + valueMax; + + 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 ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate ); + if ( self.options.range === true ) { + if ( self.orientation === "horizontal" ) { + if ( i === 0 ) { + self.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 } ); + } } else { - (i == 0) && self.range.stop(1,1)[animate ? 'animate' : 'css']({ bottom: (valPercent) + '%' }, o.animate); - (i == 1) && self.range[animate ? 'animate' : 'css']({ height: (valPercent - lastValPercent) + '%' }, { queue: false, duration: o.animate }); + if ( i === 0 ) { + self.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 } ); + } } } lastValPercent = valPercent; }); } else { - var value = this.value(), - valueMin = this._valueMin(), - valueMax = this._valueMax(), - valPercent = valueMax != valueMin - ? (value - valueMin) / (valueMax - valueMin) * 100 - : 0; - var _set = {}; _set[self.orientation == 'horizontal' ? 'left' : 'bottom'] = valPercent + '%'; - this.handle.stop(1,1)[animate ? 'animate' : 'css'](_set, o.animate); + value = this.value(); + valueMin = this._valueMin(); + valueMax = this._valueMax(); + valPercent = ( valueMax !== valueMin ) ? + ( value - valueMin ) / ( valueMax - valueMin ) * 100 : + 0; + _set[ self.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%"; + this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
- (oRange == "min") && (this.orientation == "horizontal") && this.range.stop(1,1)[animate ? 'animate' : 'css']({ width: valPercent + '%' }, o.animate); - (oRange == "max") && (this.orientation == "horizontal") && this.range[animate ? 'animate' : 'css']({ width: (100 - valPercent) + '%' }, { queue: false, duration: o.animate }); - (oRange == "min") && (this.orientation == "vertical") && this.range.stop(1,1)[animate ? 'animate' : 'css']({ height: valPercent + '%' }, o.animate); - (oRange == "max") && (this.orientation == "vertical") && this.range[animate ? 'animate' : 'css']({ height: (100 - valPercent) + '%' }, { queue: false, duration: o.animate }); + if ( oRange === "min" && this.orientation === "horizontal" ) { + this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate ); + } + if ( oRange === "max" && this.orientation === "horizontal" ) { + this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } ); + } + if ( oRange === "min" && this.orientation === "vertical" ) { + this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate ); + } + if ( oRange === "max" && this.orientation === "vertical" ) { + this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } ); + } } - } - + });
-$.extend($.ui.slider, { - version: "1.8" +$.extend( $.ui.slider, { + version: "1.8.16" });
-})(jQuery); +}(jQuery)); /* - * jQuery UI Tabs 1.8 + * jQuery UI Tabs 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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 * @@ -6834,12 +7496,20 @@ $.extend($.ui.slider, { * jquery.ui.core.js * jquery.ui.widget.js */ -(function($) { +(function( $, undefined ) {
var tabId = 0, listId = 0;
-$.widget("ui.tabs", { +function getNextTabId() { + return ++tabId; +} + +function getNextListId() { + return ++listId; +} + +$.widget( "ui.tabs", { options: { add: null, ajaxOptions: null, @@ -6849,619 +7519,650 @@ $.widget("ui.tabs", { disable: null, disabled: [], enable: null, - event: 'click', + event: "click", fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 } - idPrefix: 'ui-tabs-', + idPrefix: "ui-tabs-", load: null, - panelTemplate: '<div></div>', + panelTemplate: "<div></div>", remove: null, select: null, show: null, - spinner: '<em>Loading…</em>', - tabTemplate: '<li><a href="#{href}"><span>#{label}</span></a></li>' + spinner: "<em>Loading…</em>", + tabTemplate: "<li><a href='#{href}'><span>#{label}</span></a></li>" }, + _create: function() { - this._tabify(true); + this._tabify( true ); },
- _setOption: function(key, value) { - if (key == 'selected') { - if (this.options.collapsible && value == this.options.selected) { + _setOption: function( key, value ) { + if ( key == "selected" ) { + if (this.options.collapsible && value == this.options.selected ) { return; } - this.select(value); - } - else { - this.options[key] = value; + this.select( value ); + } else { + this.options[ key ] = value; this._tabify(); } },
- _tabId: function(a) { - return a.title && a.title.replace(/\s/g, '_').replace(/[^A-Za-z0-9-_:.]/g, '') || - this.options.idPrefix + (++tabId); + _tabId: function( a ) { + return a.title && a.title.replace( /\s/g, "_" ).replace( /[^\w\u00c0-\uFFFF-]/g, "" ) || + this.options.idPrefix + getNextTabId(); },
- _sanitizeSelector: function(hash) { - return hash.replace(/:/g, '\:'); // we need this because an id may contain a ":" + _sanitizeSelector: function( hash ) { + // we need this because an id may contain a ":" + return hash.replace( /:/g, "\:" ); },
_cookie: function() { - var cookie = this.cookie || (this.cookie = this.options.cookie.name || 'ui-tabs-' + (++listId)); - return $.cookie.apply(null, [cookie].concat($.makeArray(arguments))); + var cookie = this.cookie || + ( this.cookie = this.options.cookie.name || "ui-tabs-" + getNextListId() ); + return $.cookie.apply( null, [ cookie ].concat( $.makeArray( arguments ) ) ); },
- _ui: function(tab, panel) { + _ui: function( tab, panel ) { return { tab: tab, panel: panel, - index: this.anchors.index(tab) + index: this.anchors.index( tab ) }; },
_cleanup: function() { // restore all former loading tabs labels - this.lis.filter('.ui-state-processing').removeClass('ui-state-processing') - .find('span:data(label.tabs)') + 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'); + var el = $( this ); + el.html( el.data( "label.tabs" ) ).removeData( "label.tabs" ); }); },
- _tabify: function(init) { - - 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]; }); - this.panels = $([]); - - var self = this, o = this.options; + _tabify: function( init ) { + var self = this, + o = this.options, + fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash
- var fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash - this.anchors.each(function(i, a) { - var href = $(a).attr('href'); + 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 ]; + }); + 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)) { + 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; }
// inline tab - if (fragmentId.test(href)) { - self.panels = self.panels.add(self._sanitizeSelector(href)); - } - + if ( fragmentId.test( href ) ) { + self.panels = self.panels.add( self.element.find( self._sanitizeSelector( href ) ) ); // remote tab - else if (href != '#') { // prevent loading the page itself if href is just "#" - $.data(a, 'href.tabs', href); // required for restore on destroy + // 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(/#.*$/, '')); // mutable data - - var id = self._tabId(a); - a.href = '#' + id; - var $panel = $('#' + 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); + $.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); - } - + self.panels = self.panels.add( $panel ); // invalid tab href - else { - o.disabled.push(i); + } else { + o.disabled.push( i ); } });
// initialization from scratch - if (init) { - + 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'); + 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) { + if ( o.selected === undefined ) { + if ( location.hash ) { + this.anchors.each(function( i, a ) { + if ( a.hash == location.hash ) { o.selected = i; - return false; // break + return false; } }); } - if (typeof o.selected != 'number' && o.cookie) { - o.selected = parseInt(self._cookie(), 10); + 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')); + 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 = 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; }
// sanity check - default to first tab... - o.selected = ((o.selected >= 0 && this.anchors[o.selected]) || o.selected < 0) ? o.selected : 0; + o.selected = ( ( o.selected >= 0 && this.anchors[ o.selected ] ) || o.selected < 0 ) + ? o.selected + : 0;
// 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(); + o.disabled = $.unique( o.disabled.concat( + $.map( this.lis.filter( ".ui-state-disabled" ), function( n, i ) { + return self.lis.index( n ); + }) + ) ).sort();
- if ($.inArray(o.selected, o.disabled) != -1) { - o.disabled.splice($.inArray(o.selected, o.disabled), 1); + if ( $.inArray( o.selected, o.disabled ) != -1 ) { + o.disabled.splice( $.inArray( o.selected, o.disabled ), 1 ); }
// highlight selected tab - this.panels.addClass('ui-tabs-hide'); - this.lis.removeClass('ui-tabs-selected ui-state-active'); - if (o.selected >= 0 && this.anchors.length) { // check for length avoids error when initializing empty list - this.panels.eq(o.selected).removeClass('ui-tabs-hide'); - this.lis.eq(o.selected).addClass('ui-tabs-selected ui-state-active'); + 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" );
// 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.panels[o.selected])); + 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.load(o.selected); + + this.load( o.selected ); }
// clean up to avoid memory leaks in certain versions of IE 6 - $(window).bind('unload', function() { - self.lis.add(self.anchors).unbind('.tabs'); + // TODO: namespace this event + $( window ).bind( "unload", function() { + self.lis.add( self.anchors ).unbind( ".tabs" ); self.lis = self.anchors = self.panels = null; }); - - } // update selected after add/remove - else { - o.selected = this.lis.index(this.lis.filter('.ui-tabs-selected')); + } else { + o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) ); }
// update collapsible - this.element[o.collapsible ? 'addClass' : 'removeClass']('ui-tabs-collapsible'); + // TODO: use .toggleClass() + this.element[ o.collapsible ? "addClass" : "removeClass" ]( "ui-tabs-collapsible" );
// set or update cookie after init and add/remove respectively - if (o.cookie) { - this._cookie(o.selected, o.cookie); + if ( o.cookie ) { + this._cookie( o.selected, o.cookie ); }
// disable tabs - for (var i = 0, li; (li = this.lis[i]); i++) { - $(li)[$.inArray(i, o.disabled) != -1 && - !$(li).hasClass('ui-tabs-selected') ? 'addClass' : 'removeClass']('ui-state-disabled'); + 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" ); }
// reset cache if switching from cached to not cached - if (o.cache === false) { - this.anchors.removeData('cache.tabs'); + if ( o.cache === false ) { + this.anchors.removeData( "cache.tabs" ); }
// remove all handlers before, tabify may run on existing tabs after add or option change - this.lis.add(this.anchors).unbind('.tabs'); + this.lis.add( this.anchors ).unbind( ".tabs" );
- if (o.event != 'mouseover') { - var addState = function(state, el) { - if (el.is(':not(.ui-state-disabled)')) { - el.addClass('ui-state-' + state); + 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); + var removeState = function( state, el ) { + el.removeClass( "ui-state-" + state ); }; - this.lis.bind('mouseover.tabs', function() { - addState('hover', $(this)); + this.lis.bind( "mouseover.tabs" , function() { + addState( "hover", $( this ) ); }); - this.lis.bind('mouseout.tabs', function() { - removeState('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( "focus.tabs", function() { + addState( "focus", $( this ).closest( "li" ) ); }); - this.anchors.bind('blur.tabs', function() { - removeState('focus', $(this).closest('li')); + this.anchors.bind( "blur.tabs", function() { + removeState( "focus", $( this ).closest( "li" ) ); }); }
// set up animations var hideFx, showFx; - if (o.fx) { - if ($.isArray(o.fx)) { - hideFx = o.fx[0]; - showFx = o.fx[1]; - } - else { + if ( o.fx ) { + if ( $.isArray( o.fx ) ) { + hideFx = o.fx[ 0 ]; + showFx = o.fx[ 1 ]; + } else { hideFx = showFx = o.fx; } }
// 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'); + function resetStyle( $el, fx ) { + $el.css( "display", "" ); + if ( !$.support.opacity && fx.opacity ) { + $el[ 0 ].style.removeAttribute( "filter" ); } }
// 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])); + 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 ] ) ); }); - } : - 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])); + } + : 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 ] ) ); };
// 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"); + 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" ); }); - } : - function(clicked, $hide, $show) { - self.lis.removeClass('ui-tabs-selected ui-state-active'); - $hide.addClass('ui-tabs-hide'); - self.element.dequeue("tabs"); + } + : 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 = $(this).closest('li'), $hide = self.panels.filter(':not(.ui-tabs-hide)'), - $show = $(self._sanitizeSelector(this.hash)); + 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._trigger('select', null, self._ui(this, $show[0])) === false) { + 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; }
- o.selected = self.anchors.index(this); + o.selected = self.anchors.index( this );
self.abort();
// if tab may be closed - if (o.collapsible) { - if ($li.hasClass('ui-tabs-selected')) { + if ( o.collapsible ) { + if ( $li.hasClass( "ui-tabs-selected" ) ) { o.selected = -1;
- if (o.cookie) { - self._cookie(o.selected, o.cookie); + if ( o.cookie ) { + self._cookie( o.selected, o.cookie ); }
- self.element.queue("tabs", function() { - hideTab(el, $hide); - }).dequeue("tabs"); - + self.element.queue( "tabs", function() { + hideTab( el, $hide ); + }).dequeue( "tabs" ); + this.blur(); return false; - } - else if (!$hide.length) { - if (o.cookie) { - self._cookie(o.selected, o.cookie); + } else if ( !$hide.length ) { + if ( o.cookie ) { + self._cookie( o.selected, o.cookie ); } - - self.element.queue("tabs", function() { - showTab(el, $show); + + self.element.queue( "tabs", function() { + showTab( el, $show ); });
- self.load(self.anchors.index(this)); // TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171 - + // TODO make passing in node possible, see also http://dev.jqueryui.com/ticket/3171 + self.load( self.anchors.index( this ) ); + this.blur(); return false; } }
- if (o.cookie) { - self._cookie(o.selected, o.cookie); + if ( o.cookie ) { + self._cookie( o.selected, o.cookie ); }
// show new tab - if ($show.length) { - if ($hide.length) { - self.element.queue("tabs", function() { - hideTab(el, $hide); + if ( $show.length ) { + if ( $hide.length ) { + self.element.queue( "tabs", function() { + hideTab( el, $hide ); }); } - self.element.queue("tabs", function() { - showTab(el, $show); + self.element.queue( "tabs", function() { + showTab( el, $show ); }); - - self.load(self.anchors.index(this)); - } - else { - throw 'jQuery UI Tabs: Mismatching fragment identifier.'; + + self.load( self.anchors.index( this ) ); + } else { + throw "jQuery UI Tabs: Mismatching fragment identifier."; }
// 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) { + if ( $.browser.msie ) { this.blur(); } - });
// disable click in any case - this.anchors.bind('click.tabs', function(){return false;}); + this.anchors.bind( "click.tabs", function(){ + return false; + }); + }, + + _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 + "]" ) ); + }
+ return index; },
destroy: function() { var o = this.options;
this.abort(); - - this.element.unbind('.tabs') - .removeClass('ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible') - .removeData('tabs');
- this.list.removeClass('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all'); + this.element + .unbind( ".tabs" ) + .removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" ) + .removeData( "tabs" ); + + this.list.removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
this.anchors.each(function() { - var href = $.data(this, 'href.tabs'); - if (href) { + var href = $.data( this, "href.tabs" ); + if ( href ) { this.href = href; } - var $this = $(this).unbind('.tabs'); - $.each(['href', 'load', 'cache'], function(i, prefix) { - $this.removeData(prefix + '.tabs'); + var $this = $( this ).unbind( ".tabs" ); + $.each( [ "href", "load", "cache" ], function( i, prefix ) { + $this.removeData( prefix + ".tabs" ); }); });
- 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(' ')); + 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( " " ) ); } });
- if (o.cookie) { - this._cookie(null, o.cookie); + if ( o.cookie ) { + this._cookie( null, o.cookie ); }
return this; },
- add: function(url, label, index) { - if (index === undefined) { - index = this.anchors.length; // append by default + add: function( url, label, index ) { + if ( index === undefined ) { + index = this.anchors.length; }
- 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]); + 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 ] );
- $li.addClass('ui-state-default ui-corner-top').data('destroy.tabs', true); + $li.addClass( "ui-state-default ui-corner-top" ).data( "destroy.tabs", true );
// try to find an existing element before creating a new one - var $panel = $('#' + id); - if (!$panel.length) { - $panel = $(o.panelTemplate).attr('id', id).data('destroy.tabs', true); + var $panel = self.element.find( "#" + id ); + if ( !$panel.length ) { + $panel = $( o.panelTemplate ) + .attr( "id", id ) + .data( "destroy.tabs", true ); } - $panel.addClass('ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide'); + $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]); + 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 ] ); }
- o.disabled = $.map(o.disabled, - function(n, i) { return n >= index ? ++n : n; }); + o.disabled = $.map( o.disabled, function( n, i ) { + return n >= index ? ++n : n; + });
this._tabify();
- if (this.anchors.length == 1) { // after tabify + 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])); + $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 ] ) ); }); - - this.load(0); + + this.load( 0 ); }
- // callback - this._trigger('add', null, this._ui(this.anchors[index], this.panels[index])); + this._trigger( "add", null, this._ui( this.anchors[ index ], this.panels[ index ] ) ); return this; },
- remove: function(index) { - var o = this.options, $li = this.lis.eq(index).remove(), - $panel = this.panels.eq(index).remove(); + 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)); + 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; }); + o.disabled = $.map( + $.grep( o.disabled, function(n, i) { + return n != index; + }), + function( n, i ) { + return n >= index ? --n : n; + });
this._tabify();
- // callback - this._trigger('remove', null, this._ui($li.find('a')[0], $panel[0])); + this._trigger( "remove", null, this._ui( $li.find( "a" )[ 0 ], $panel[ 0 ] ) ); return this; },
- enable: function(index) { + enable: function( index ) { + index = this._getIndex( index ); var o = this.options; - if ($.inArray(index, o.disabled) == -1) { + if ( $.inArray( index, o.disabled ) == -1 ) { return; }
- this.lis.eq(index).removeClass('ui-state-disabled'); - o.disabled = $.grep(o.disabled, function(n, i) { return n != index; }); + this.lis.eq( index ).removeClass( "ui-state-disabled" ); + o.disabled = $.grep( o.disabled, function( n, i ) { + return n != index; + });
- // callback - this._trigger('enable', null, this._ui(this.anchors[index], this.panels[index])); + this._trigger( "enable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) ); return this; },
- disable: function(index) { + disable: function( index ) { + index = this._getIndex( index ); var self = this, o = this.options; - if (index != o.selected) { // cannot disable already selected tab - this.lis.eq(index).addClass('ui-state-disabled'); + // cannot disable already selected tab + if ( index != o.selected ) { + this.lis.eq( index ).addClass( "ui-state-disabled" );
- o.disabled.push(index); + o.disabled.push( index ); o.disabled.sort();
- // callback - this._trigger('disable', null, this._ui(this.anchors[index], this.panels[index])); + this._trigger( "disable", null, this._ui( this.anchors[ index ], this.panels[ index ] ) ); }
return this; },
- select: function(index) { - if (typeof index == 'string') { - index = this.anchors.index(this.anchors.filter('[href$=' + index + ']')); - } - else if (index === null) { // usage of null is deprecated, TODO remove in next release - index = -1; - } - if (index == -1 && this.options.collapsible) { - index = this.options.selected; + 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; + } } - - this.anchors.eq(index).trigger(this.options.event + '.tabs'); + this.anchors.eq( index ).trigger( this.options.event + ".tabs" ); return this; },
- load: function(index) { - var self = this, o = this.options, a = this.anchors.eq(index)[0], url = $.data(a, 'load.tabs'); + 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();
// not remote or from cache - if (!url || this.element.queue("tabs").length !== 0 && $.data(a, 'cache.tabs')) { - this.element.dequeue("tabs"); + if ( !url || this.element.queue( "tabs" ).length !== 0 && $.data( a, "cache.tabs" ) ) { + this.element.dequeue( "tabs" ); return; }
// load remote from here on - this.lis.eq(index).addClass('ui-state-processing'); + this.lis.eq( index ).addClass( "ui-state-processing" );
- if (o.spinner) { - var span = $('span', a); - span.data('label.tabs', span.html()).html(o.spinner); + if ( o.spinner ) { + var span = $( "span", a ); + span.data( "label.tabs", span.html() ).html( o.spinner ); }
- this.xhr = $.ajax($.extend({}, o.ajaxOptions, { + this.xhr = $.ajax( $.extend( {}, o.ajaxOptions, { url: url, - success: function(r, s) { - $(self._sanitizeSelector(a.hash)).html(r); + success: function( r, s ) { + self.element.find( self._sanitizeSelector( a.hash ) ).html( r );
// take care of tab labels self._cleanup();
- if (o.cache) { - $.data(a, 'cache.tabs', true); // if loaded once do not load them again + if ( o.cache ) { + $.data( a, "cache.tabs", true ); }
- // callbacks - self._trigger('load', null, self._ui(self.anchors[index], self.panels[index])); + self._trigger( "load", null, self._ui( self.anchors[ index ], self.panels[ index ] ) ); try { - o.ajaxOptions.success(r, s); + o.ajaxOptions.success( r, s ); } - catch (e) {} + catch ( e ) {} }, - error: function(xhr, s, e) { + error: function( xhr, s, e ) { // take care of tab labels self._cleanup();
- // callbacks - self._trigger('load', null, self._ui(self.anchors[index], self.panels[index])); + 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); + o.ajaxOptions.error( xhr, s, index, a ); } - catch (e) {} + catch ( e ) {} } - })); + } ) );
// last, so that load event is fired before show... - self.element.dequeue("tabs"); + self.element.dequeue( "tabs" );
return this; },
abort: function() { // stop possibly running animations - this.element.queue([]); - this.panels.stop(false, true); + this.element.queue( [] ); + this.panels.stop( false, true );
// "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)); + this.element.queue( "tabs", this.element.queue( "tabs" ).splice( -2, 2 ) );
// terminate pending requests from other tabs - if (this.xhr) { + if ( this.xhr ) { this.xhr.abort(); delete this.xhr; } @@ -7471,19 +8172,18 @@ $.widget("ui.tabs", { return this; },
- url: function(index, url) { - this.anchors.eq(index).removeData('cache.tabs').data('load.tabs', url); + url: function( index, url ) { + this.anchors.eq( index ).removeData( "cache.tabs" ).data( "load.tabs", url ); return this; },
length: function() { return this.anchors.length; } - });
-$.extend($.ui.tabs, { - version: '1.8' +$.extend( $.ui.tabs, { + version: "1.8.16" });
/* @@ -7493,46 +8193,45 @@ $.extend($.ui.tabs, { /* * Rotate */ -$.extend($.ui.tabs.prototype, { +$.extend( $.ui.tabs.prototype, { rotation: null, - rotate: function(ms, continuing) { + rotate: function( ms, continuing ) { + var self = this, + o = this.options;
- var self = this, o = this.options; - - var rotate = self._rotate || (self._rotate = function(e) { - clearTimeout(self.rotation); + 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); + }, ms ); - if (e) { + if ( e ) { e.stopPropagation(); } }); - - var stop = self._unrotate || (self._unrotate = !continuing ? - function(e) { + + var stop = self._unrotate || ( self._unrotate = !continuing + ? function(e) { if (e.clientX) { // in case of a true click self.rotate(null); } - } : - function(e) { + } + : function( e ) { t = o.selected; rotate(); });
// start rotation - if (ms) { - this.element.bind('tabsshow', rotate); - this.anchors.bind(o.event + '.tabs', stop); + 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); + } else { + clearTimeout( self.rotation ); + this.element.unbind( "tabsshow", rotate ); + this.anchors.unbind( o.event + ".tabs", stop ); delete this._rotate; delete this._unrotate; } @@ -7541,26 +8240,26 @@ $.extend($.ui.tabs.prototype, { } });
-})(jQuery); +})( jQuery ); /* - * jQuery UI Datepicker 1.8 + * jQuery UI Datepicker 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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 ) {
-(function($) { // hide the namespace - -$.extend($.ui, { datepicker: { version: "1.8" } }); +$.extend($.ui, { datepicker: { version: "1.8.16" } });
var PROP_NAME = 'datepicker'; var dpuuid = new Date().getTime(); +var instActive;
/* Date picker manager. Use the singleton instance of this class, $.datepicker, to interact with the date picker. @@ -7605,7 +8304,7 @@ function Datepicker() { this._defaults = { // Global defaults for all the date picker instances showOn: 'focus', // 'focus' for popup on focus, // 'button' for trigger button, or 'both' for either - showAnim: 'show', // Name of jQuery animation for popup + showAnim: 'fadeIn', // Name of jQuery animation for popup showOptions: {}, // Options for enhanced animations defaultDate: null, // Used when field is blank: actual date, // +/-number for offset from today, null for today @@ -7632,7 +8331,7 @@ function Datepicker() { // string value starting with '+' for current year + value minDate: null, // The earliest selectable date, or null for no limit maxDate: null, // The latest selectable date, or null for no limit - duration: '_default', // Duration of display/closure + duration: 'fast', // Duration of display/closure beforeShowDay: null, // Function that takes a date and returns an array with // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or '', // [2] = cell title (optional), e.g. $.datepicker.noWeekends @@ -7649,15 +8348,19 @@ function Datepicker() { altFormat: '', // The date format to use for the alternate field constrainInput: true, // The input is constrained by the current date format showButtonPanel: false, // True to show button panel, false to not show it - autoSize: false // True to size the input for the date format, false to leave as is + autoSize: false, // True to size the input for the date format, false to leave as is + disabled: false // The initial disabled state }; $.extend(this._defaults, this.regional['']); - this.dpDiv = $('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible"></div>'); + this.dpDiv = bindHover($('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')); }
$.extend(Datepicker.prototype, { /* Class name added to elements to indicate already configured with a date picker. */ markerClassName: 'hasDatepicker', + + //Keep track of the maximum number of rows displayed (see #7043) + maxRows: 4,
/* Debug logging (if enabled). */ log: function () { @@ -7697,8 +8400,10 @@ $.extend(Datepicker.prototype, { } var nodeName = target.nodeName.toLowerCase(); var inline = (nodeName == 'div' || nodeName == 'span'); - if (!target.id) - target.id = 'dp' + (++this.uuid); + if (!target.id) { + this.uuid += 1; + target.id = 'dp' + this.uuid; + } var inst = this._newInst($(target), inline); inst.settings = $.extend({}, settings || {}, inlineSettings || {}); if (nodeName == 'input') { @@ -7710,13 +8415,13 @@ $.extend(Datepicker.prototype, {
/* Create a new instance object. */ _newInst: function(target, inline) { - var id = target[0].id.replace(/([^A-Za-z0-9_])/g, '\\$1'); // escape jQuery meta chars + var id = target[0].id.replace(/([^A-Za-z0-9_-])/g, '\\$1'); // escape jQuery meta chars return {id: id, input: target, // associated target selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection drawMonth: 0, drawYear: 0, // month being drawn inline: inline, // is datepicker inline or not dpDiv: (!inline ? this.dpDiv : // presentation div - $('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))}; + bindHover($('<div class="' + this._inlineClass + ' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')))}; },
/* Attach the date picker to an input field. */ @@ -7736,6 +8441,10 @@ $.extend(Datepicker.prototype, { }); this._autoSize(inst); $.data(target, PROP_NAME, inst); + //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665) + if( inst.settings.disabled ) { + this._disableDatepicker( target ); + } },
/* Make attachments based on settings. */ @@ -7815,6 +8524,13 @@ $.extend(Datepicker.prototype, { this._setDate(inst, this._getDefaultDate(inst), true); this._updateDatepicker(inst); this._updateAlternate(inst); + //If disabled option is true, disable the datepicker before showing it (see ticket #5665) + if( inst.settings.disabled ) { + this._disableDatepicker( target ); + } + // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements + // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height + inst.dpDiv.css( "display", "block" ); },
/* Pop-up the date picker in a "dialog" box. @@ -7829,7 +8545,8 @@ $.extend(Datepicker.prototype, { _dialogDatepicker: function(input, date, onSelect, settings, pos) { var inst = this._dialogInst; // internal instance if (!inst) { - var id = 'dp' + (++this.uuid); + 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;"/>'); this._dialogInput.keydown(this._doKeyDown); @@ -7904,6 +8621,8 @@ $.extend(Datepicker.prototype, { else if (nodeName == 'div' || nodeName == 'span') { var inline = $target.children('.' + this._inlineClass); inline.children().removeClass('ui-state-disabled'); + inline.find("select.ui-datepicker-month, select.ui-datepicker-year"). + removeAttr("disabled"); } this._disabledInputs = $.map(this._disabledInputs, function(value) { return (value == target ? null : value); }); // delete entry @@ -7927,6 +8646,8 @@ $.extend(Datepicker.prototype, { else if (nodeName == 'div' || nodeName == 'span') { 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"); } this._disabledInputs = $.map(this._disabledInputs, function(value) { return (value == target ? null : value); }); // delete entry @@ -7985,10 +8706,18 @@ $.extend(Datepicker.prototype, { this._hideDatepicker(); } var date = this._getDateDatepicker(target, true); + var minDate = this._getMinMaxDate(inst, 'min'); + var maxDate = this._getMinMaxDate(inst, 'max'); extendRemove(inst.settings, settings); + // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided + if (minDate !== null && settings['dateFormat'] !== undefined && settings['minDate'] === undefined) + inst.settings.minDate = this._formatDate(inst, minDate); + if (maxDate !== null && settings['dateFormat'] !== undefined && settings['maxDate'] === undefined) + inst.settings.maxDate = this._formatDate(inst, maxDate); this._attachments($(target), inst); this._autoSize(inst); - this._setDateDatepicker(target, date); + this._setDate(inst, date); + this._updateAlternate(inst); this._updateDatepicker(inst); } }, @@ -8041,10 +8770,17 @@ $.extend(Datepicker.prototype, { case 9: $.datepicker._hideDatepicker(); handled = false; break; // hide on tab out - case 13: var sel = $('td.' + $.datepicker._dayOverClass, inst.dpDiv). - add($('td.' + $.datepicker._currentClass, inst.dpDiv)); + 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]); + var onSelect = $.datepicker._get(inst, 'onSelect'); + if (onSelect) { + var dateStr = $.datepicker._formatDate(inst); + + // trigger custom callback + onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); + } else $.datepicker._hideDatepicker(); return false; // don't submit the form @@ -8106,7 +8842,7 @@ $.extend(Datepicker.prototype, { if ($.datepicker._get(inst, 'constrainInput')) { var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')); var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode); - return event.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1); + return event.ctrlKey || event.metaKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1); } },
@@ -8132,6 +8868,7 @@ $.extend(Datepicker.prototype, { },
/* Pop-up the date picker for a given input field. + 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) { @@ -8142,10 +8879,18 @@ $.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); } var beforeShow = $.datepicker._get(inst, 'beforeShow'); - extendRemove(inst.settings, (beforeShow ? beforeShow.apply(input, [input, inst]) : {})); + var beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {}; + if(beforeShowSettings === false){ + //false + return; + } + extendRemove(inst.settings, beforeShowSettings); inst.lastVal = null; $.datepicker._lastInput = input; $.datepicker._setDateFromField(inst); @@ -8166,6 +8911,8 @@ $.extend(Datepicker.prototype, { } var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]}; $.datepicker._pos = null; + //to avoid flashes on Firefox + inst.dpDiv.empty(); // determine sizing offscreen inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'}); $.datepicker._updateDatepicker(inst); @@ -8179,13 +8926,15 @@ $.extend(Datepicker.prototype, { var showAnim = $.datepicker._get(inst, 'showAnim'); var duration = $.datepicker._get(inst, 'duration'); var postProcess = function() { - $.datepicker._datepickerShowing = true; - var borders = $.datepicker._getBorders(inst.dpDiv); - inst.dpDiv.find('iframe.ui-datepicker-cover'). // IE6- only - css({left: -borders[0], top: -borders[1], + var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only + if( !! cover.length ){ + var borders = $.datepicker._getBorders(inst.dpDiv); + cover.css({left: -borders[0], top: -borders[1], width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()}); + } }; inst.dpDiv.zIndex($(input).zIndex()+1); + $.datepicker._datepickerShowing = true; if ($.effects && $.effects[showAnim]) inst.dpDiv.show(showAnim, $.datepicker._get(inst, 'showOptions'), duration, postProcess); else @@ -8201,44 +8950,41 @@ $.extend(Datepicker.prototype, { /* Generate the date picker content. */ _updateDatepicker: function(inst) { var self = this; + self.maxRows = 4; //Reset the max number of rows being displayed (see #7043) var borders = $.datepicker._getBorders(inst.dpDiv); - inst.dpDiv.empty().append(this._generateHTML(inst)) - .find('iframe.ui-datepicker-cover') // IE6- only - .css({left: -borders[0], top: -borders[1], - width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()}) - .end() - .find('button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a') - .bind('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(){ - if (!self._isDisabledDatepicker( inst.inline ? inst.dpDiv.parent()[0] : inst.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'); - } - }) - .end() - .find('.' + this._dayOverClass + ' a') - .trigger('mouseover') - .end(); + instActive = inst; // for delegate hover events + inst.dpDiv.empty().append(this._generateHTML(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()}) + } + inst.dpDiv.find('.' + this._dayOverClass + ' a').mouseover(); var numMonths = this._getNumberOfMonths(inst); var cols = numMonths[1]; var width = 17; + inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width(''); if (cols > 1) inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em'); - else - inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width(''); inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') + 'Class']('ui-datepicker-multi'); inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') + 'Class']('ui-datepicker-rtl'); if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input && - inst.input.is(':visible') && !inst.input.is(':disabled')) + // #6694 - don't focus the input if it's already focused + // 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) + if( inst.yearshtml ){ + var origyearshtml = inst.yearshtml; + setTimeout(function(){ + //assure that inst.yearshtml didn't change. + if( origyearshtml === inst.yearshtml && inst.yearshtml ){ + inst.dpDiv.find('select.ui-datepicker-year:first').replaceWith(inst.yearshtml); + } + origyearshtml = inst.yearshtml = null; + }, 0); + } },
/* Retrieve the size of left and top borders for an element. @@ -8278,13 +9024,21 @@ $.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)) { + 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]); + }, + /* Hide the date picker from view. @param input element - the input field attached to the date picker */ _hideDatepicker: function(input) { @@ -8305,10 +9059,7 @@ $.extend(Datepicker.prototype, { (showAnim == 'fadeIn' ? 'fadeOut' : 'hide'))]((showAnim ? duration : null), postProcess); if (!showAnim) postProcess(); - var onClose = this._get(inst, 'onClose'); - if (onClose) - onClose.apply((inst.input ? inst.input[0] : null), - [(inst.input ? inst.input.val() : ''), inst]); // trigger custom callback + $.datepicker._triggerOnClose(inst); this._datepickerShowing = false; this._lastInput = null; if (this._inDialog) { @@ -8376,7 +9127,6 @@ $.extend(Datepicker.prototype, { _selectMonthYear: function(id, select, period) { var target = $(id); var inst = this._getInst(target[0]); - inst._selectingMonthYear = false; inst['selected' + (period == 'M' ? 'Month' : 'Year')] = inst['draw' + (period == 'M' ? 'Month' : 'Year')] = parseInt(select.options[select.selectedIndex].value,10); @@ -8384,15 +9134,6 @@ $.extend(Datepicker.prototype, { this._adjustDate(target); },
- /* Restore input focus after not changing month/year. */ - _clickMonthYear: function(id) { - var target = $(id); - var inst = this._getInst(target[0]); - if (inst.input && inst._selectingMonthYear && !$.browser.msie) - inst.input.focus(); - inst._selectingMonthYear = !inst._selectingMonthYear; - }, - /* Action for selecting a day. */ _selectDay: function(id, month, year, td) { var target = $(id); @@ -8489,6 +9230,8 @@ $.extend(Datepicker.prototype, { if (value == '') return null; var shortYearCutoff = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff; + shortYearCutoff = (typeof shortYearCutoff != 'string' ? shortYearCutoff : + new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10)); var dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort; var dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames; var monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort; @@ -8507,9 +9250,9 @@ $.extend(Datepicker.prototype, { }; // Extract a number from the string value var getNumber = function(match) { - lookAhead(match); + var isDoubled = lookAhead(match); var size = (match == '@' ? 14 : (match == '!' ? 20 : - (match == 'y' ? 4 : (match == 'o' ? 3 : 2)))); + (match == 'y' && isDoubled ? 4 : (match == 'o' ? 3 : 2)))); var digits = new RegExp('^\d{1,' + size + '}'); var num = value.substring(iValue).match(digits); if (!num) @@ -8519,14 +9262,24 @@ $.extend(Datepicker.prototype, { }; // Extract a name from the string value and convert to an index var getName = function(match, shortNames, longNames) { - var names = (lookAhead(match) ? longNames : shortNames); - for (var i = 0; i < names.length; i++) { - if (value.substr(iValue, names[i].length) == names[i]) { - iValue += names[i].length; - return i + 1; + var names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) { + return [ [k, v] ]; + }).sort(function (a, b) { + return -(a[1].length - b[1].length); + }); + var index = -1; + $.each(names, function (i, pair) { + var name = pair[1]; + if (value.substr(iValue, name.length).toLowerCase() == name.toLowerCase()) { + index = pair[0]; + iValue += name.length; + return false; } - } - throw 'Unknown name at position ' + iValue; + }); + if (index != -1) + return index + 1; + else + throw 'Unknown name at position ' + iValue; }; // Confirm that a literal character matches the string value var checkLiteral = function() { @@ -8583,6 +9336,9 @@ $.extend(Datepicker.prototype, { checkLiteral(); } } + if (iValue < value.length){ + throw "Extra/unparsed characters found in date: " + value.substring(iValue); + } if (year == -1) year = new Date().getFullYear(); else if (year < 100) @@ -8601,7 +9357,7 @@ $.extend(Datepicker.prototype, { } var date = this._daylightSavingAdjust(new Date(year, month - 1, day)); if (date.getFullYear() != year || date.getMonth() + 1 != month || date.getDate() != day) - throw 'Invalid date'; // E.g. 31/02/* + throw 'Invalid date'; // E.g. 31/02/00 return date; },
@@ -8694,7 +9450,7 @@ $.extend(Datepicker.prototype, { break; case 'o': output += formatNumber('o', - (date.getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000, 3); + Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3); break; case 'm': output += formatNumber('m', date.getMonth() + 1, 2); @@ -8839,16 +9595,16 @@ $.extend(Datepicker.prototype, { } return new Date(year, month, day); }; - date = (date == null ? defaultDate : (typeof date == 'string' ? offsetString(date) : - (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : date))); - date = (date && date.toString() == 'Invalid Date' ? defaultDate : date); - if (date) { - date.setHours(0); - date.setMinutes(0); - date.setSeconds(0); - date.setMilliseconds(0); + var newDate = (date == null || date === '' ? defaultDate : (typeof date == 'string' ? offsetString(date) : + (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime())))); + newDate = (newDate && newDate.toString() == 'Invalid Date' ? defaultDate : newDate); + if (newDate) { + newDate.setHours(0); + newDate.setMinutes(0); + newDate.setSeconds(0); + newDate.setMilliseconds(0); } - return this._daylightSavingAdjust(date); + return this._daylightSavingAdjust(newDate); },
/* Handle switch to/from daylight saving. @@ -8865,13 +9621,13 @@ $.extend(Datepicker.prototype, {
/* Set the date(s) directly. */ _setDate: function(inst, date, noChange) { - var clear = !(date); + var clear = !date; var origMonth = inst.selectedMonth; var origYear = inst.selectedYear; - date = this._restrictMinMax(inst, this._determineDate(inst, date, new Date())); - inst.selectedDay = inst.currentDay = date.getDate(); - inst.drawMonth = inst.selectedMonth = inst.currentMonth = date.getMonth(); - inst.drawYear = inst.selectedYear = inst.currentYear = date.getFullYear(); + var newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date())); + inst.selectedDay = inst.currentDay = newDate.getDate(); + inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth(); + inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear(); if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange) this._notifyChange(inst); this._adjustInstDate(inst); @@ -8969,6 +9725,7 @@ $.extend(Datepicker.prototype, { var html = ''; for (var row = 0; row < numMonths[0]; row++) { var group = ''; + this.maxRows = 4; for (var col = 0; col < numMonths[1]; col++) { var selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay)); var cornerClass = ' ui-corner-all'; @@ -9003,7 +9760,9 @@ $.extend(Datepicker.prototype, { if (drawYear == inst.selectedYear && drawMonth == inst.selectedMonth) inst.selectedDay = Math.min(inst.selectedDay, daysInMonth); var leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7; - var numRows = (isMultiMonth ? 6 : Math.ceil((leadDays + daysInMonth) / 7)); // calculate the number of rows to generate + var curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate + var numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043) + this.maxRows = numRows; var printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays)); for (var dRow = 0; dRow < numRows; dRow++) { // create date picker rows calender += '<tr>'; @@ -9073,7 +9832,6 @@ $.extend(Datepicker.prototype, { var inMaxYear = (maxDate && maxDate.getFullYear() == drawYear); monthHtml += '<select class="ui-datepicker-month" ' + 'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear('#' + inst.id + '', this, 'M');" ' + - 'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear('#' + inst.id + '');"' + '>'; for (var month = 0; month < 12; month++) { if ((!inMinYear || month >= minDate.getMonth()) && @@ -9087,32 +9845,37 @@ $.extend(Datepicker.prototype, { if (!showMonthAfterYear) html += monthHtml + (secondary || !(changeMonth && changeYear) ? ' ' : ''); // year selection - if (secondary || !changeYear) - html += '<span class="ui-datepicker-year">' + drawYear + '</span>'; - else { - // determine range of years to display - var years = this._get(inst, 'yearRange').split(':'); - var thisYear = new Date().getFullYear(); - var determineYear = function(value) { - var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) : - (value.match(/[+-].*/) ? thisYear + parseInt(value, 10) : - parseInt(value, 10))); - return (isNaN(year) ? thisYear : year); - }; - var year = determineYear(years[0]); - var endYear = Math.max(year, determineYear(years[1] || '')); - year = (minDate ? Math.max(year, minDate.getFullYear()) : year); - endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear); - html += '<select class="ui-datepicker-year" ' + - 'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear('#' + inst.id + '', this, 'Y');" ' + - 'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear('#' + inst.id + '');"' + - '>'; - for (; year <= endYear; year++) { - html += '<option value="' + year + '"' + - (year == drawYear ? ' selected="selected"' : '') + - '>' + year + '</option>'; - } - html += '</select>'; + if ( !inst.yearshtml ) { + inst.yearshtml = ''; + if (secondary || !changeYear) + html += '<span class="ui-datepicker-year">' + drawYear + '</span>'; + else { + // determine range of years to display + var years = this._get(inst, 'yearRange').split(':'); + var thisYear = new Date().getFullYear(); + var determineYear = function(value) { + var year = (value.match(/c[+-].*/) ? drawYear + parseInt(value.substring(1), 10) : + (value.match(/[+-].*/) ? thisYear + parseInt(value, 10) : + parseInt(value, 10))); + return (isNaN(year) ? thisYear : year); + }; + var year = determineYear(years[0]); + 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');" ' + + '>'; + for (; year <= endYear; year++) { + inst.yearshtml += '<option value="' + year + '"' + + (year == drawYear ? ' selected="selected"' : '') + + '>' + year + '</option>'; + } + inst.yearshtml += '</select>'; + + html += inst.yearshtml; + inst.yearshtml = null; + } } html += this._get(inst, 'yearSuffix'); if (showMonthAfterYear) @@ -9140,9 +9903,9 @@ $.extend(Datepicker.prototype, { _restrictMinMax: function(inst, date) { var minDate = this._getMinMaxDate(inst, 'min'); var maxDate = this._getMinMaxDate(inst, 'max'); - date = (minDate && date < minDate ? minDate : date); - date = (maxDate && date > maxDate ? maxDate : date); - return date; + var newDate = (minDate && date < minDate ? minDate : date); + newDate = (maxDate && newDate > maxDate ? maxDate : newDate); + return newDate; },
/* Notify change of month/year. */ @@ -9166,7 +9929,7 @@ $.extend(Datepicker.prototype, {
/* Find the number of days in a given month. */ _getDaysInMonth: function(year, month) { - return 32 - new Date(year, month, 32).getDate(); + return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate(); },
/* Find the day of the week of the first of a month. */ @@ -9216,6 +9979,33 @@ $.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" ); + }) + .bind('mouseover', function(event) { + var elem = $( event.target ).closest( selector ); + if ($.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0]) || + !elem.length ) { + return; + } + 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'); + }); +} + /* jQuery extend now ignores nulls! */ function extendRemove(target, props) { $.extend(target, props); @@ -9236,7 +10026,12 @@ function isArray(a) { 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). @@ -9262,7 +10057,7 @@ $.fn.datepicker = function(options){ $.datepicker = new Datepicker(); // singleton instance $.datepicker.initialized = false; $.datepicker.uuid = new Date().getTime(); -$.datepicker.version = "1.8"; +$.datepicker.version = "1.8.16";
// Workaround for #4055 // Add another global to avoid noConflict issues with inline event handlers @@ -9270,11 +10065,11 @@ window['DP_jQuery_' + dpuuid] = $;
})(jQuery); /* - * jQuery UI Progressbar 1.8 + * jQuery UI Progressbar 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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 * @@ -9282,25 +10077,30 @@ window['DP_jQuery_' + dpuuid] = $; * jquery.ui.core.js * jquery.ui.widget.js */ -(function( $ ) { +(function( $, undefined ) {
$.widget( "ui.progressbar", { options: { - value: 0 + value: 0, + max: 100 }, + + min: 0, + _create: function() { this.element .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" ) .attr({ role: "progressbar", - "aria-valuemin": this._valueMin(), - "aria-valuemax": this._valueMax(), + "aria-valuemin": this.min, + "aria-valuemax": this.options.max, "aria-valuenow": this._value() });
this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" ) .appendTo( this.element );
+ this.oldValue = this._value(); this._refreshValue(); },
@@ -9327,12 +10127,12 @@ $.widget( "ui.progressbar", { },
_setOption: function( key, value ) { - switch ( key ) { - case "value": - this.options.value = value; - this._refreshValue(); - this._trigger( "change" ); - break; + if ( key === "value" ) { + this.options.value = value; + this._refreshValue(); + if ( this._value() === this.options.max ) { + this._trigger( "complete" ); + } }
$.Widget.prototype._setOption.apply( this, arguments ); @@ -9344,48 +10144,45 @@ $.widget( "ui.progressbar", { if ( typeof val !== "number" ) { val = 0; } - if ( val < this._valueMin() ) { - val = this._valueMin(); - } - if ( val > this._valueMax() ) { - val = this._valueMax(); - } - - return val; - }, - - _valueMin: function() { - return 0; + return Math.min( this.options.max, Math.max( this.min, val ) ); },
- _valueMax: function() { - return 100; + _percentage: function() { + return 100 * this._value() / this.options.max; },
_refreshValue: function() { var value = this.value(); + var percentage = this._percentage(); + + if ( this.oldValue !== value ) { + this.oldValue = value; + this._trigger( "change" ); + } + this.valueDiv - [ value === this._valueMax() ? "addClass" : "removeClass"]( "ui-corner-right" ) - .width( value + "%" ); + .toggle( value > this.min ) + .toggleClass( "ui-corner-right", value === this.options.max ) + .width( percentage.toFixed(0) + "%" ); this.element.attr( "aria-valuenow", value ); } });
$.extend( $.ui.progressbar, { - version: "1.8" + version: "1.8.16" });
})( jQuery ); /* - * jQuery UI Effects 1.8 + * jQuery UI Effects 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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/ */ -;jQuery.effects || (function($) { +;jQuery.effects || (function($, undefined) {
$.effects = {};
@@ -9397,7 +10194,7 @@ $.effects = {};
// override the animation for color styles $.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', - 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], + 'borderRightColor', 'borderTopColor', 'borderColor', 'color', 'outlineColor'], function(i, attr) { $.fx.step[attr] = function(fx) { if (!fx.colorInit) { @@ -9609,13 +10406,12 @@ $.effects.animateClass = function(value, duration, easing, callback) { easing = null; }
- return this.each(function() { - + return this.queue(function() { var that = $(this), originalStyleAttr = that.attr('style') || ' ', originalStyle = filterStyles(getElementStyles.call(this)), newStyle, - className = that.attr('className'); + className = that.attr('class');
$.each(classAnimationActions, function(i, action) { if (value[action]) { @@ -9623,20 +10419,26 @@ $.effects.animateClass = function(value, duration, easing, callback) { } }); newStyle = filterStyles(getElementStyles.call(this)); - that.attr('className', className); - - that.animate(styleDifference(originalStyle, newStyle), duration, easing, 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); + 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); + } + if (callback) { callback.apply(this, arguments); } + $.dequeue( this ); } - if (callback) { callback.apply(this, arguments); } }); }); }; @@ -9679,7 +10481,7 @@ $.fn.extend({ /******************************************************************************/
$.extend($.effects, { - version: "1.8", + version: "1.8.16",
// Saves a set of properties in a data storage save: function(element, set) { @@ -9740,9 +10542,16 @@ $.extend($.effects, { border: 'none', margin: 0, padding: 0 - }); + }), + active = document.activeElement;
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
// transfer positioning properties to the wrapper @@ -9760,15 +10569,25 @@ $.extend($.effects, { props[pos] = 'auto'; } }); - element.css({position: 'relative', top: 0, left: 0 }); + element.css({position: 'relative', top: 0, left: 0, right: 'auto', bottom: 'auto' }); }
return wrapper.css(props).show(); },
removeWrapper: function(element) { - if (element.parent().is('.ui-effects-wrapper')) - return element.parent().replaceWith(element); + var parent, + active = document.activeElement; + + if (element.parent().is('.ui-effects-wrapper')) { + parent = 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; },
@@ -9796,44 +10615,72 @@ function _normalizeArguments(effect, options, speed, callback) { speed = null; options = {}; } - if ($.isFunction(speed)) { - callback = speed; - speed = null; - } - if (typeof options == 'number' || $.fx.speeds[options]) { + if (typeof options == 'number' || $.fx.speeds[options]) { callback = speed; speed = options; options = {}; } + if ($.isFunction(speed)) { + callback = speed; + speed = null; + }
options = options || {};
speed = speed || options.duration; speed = $.fx.off ? 0 : typeof speed == 'number' - ? speed : $.fx.speeds[speed] || $.fx.speeds._default; + ? speed : speed in $.fx.speeds ? $.fx.speeds[speed] : $.fx.speeds._default;
callback = callback || options.complete;
return [effect, options, speed, callback]; }
+function standardSpeed( speed ) { + // valid standard speeds + if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) { + return true; + } + + // invalid strings - treat as "normal" speed + if ( typeof speed === "string" && !$.effects[ speed ] ) { + return true; + } + + return false; +} + $.fn.extend({ effect: function(effect, options, speed, callback) { var args = _normalizeArguments.apply(this, arguments), - // TODO: make effects takes actual parameters instead of a hash + // 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]; - return effectMethod && !$.fx.off ? effectMethod.call(this, args2) : this; + if ( $.fx.off || !effectMethod ) { + // delegate to the original method (e.g., .show()) if possible + if ( mode ) { + return this[ mode ]( args2.duration, args2.callback ); + } else { + return this.each(function() { + if ( args2.callback ) { + args2.callback.call( this ); + } + }); + } + } + + return effectMethod.call(this, args2); },
_show: $.fn.show, show: function(speed) { - if (!speed || typeof speed == 'number' || $.fx.speeds[speed]) { + if ( standardSpeed( speed ) ) { return this._show.apply(this, arguments); } else { var args = _normalizeArguments.apply(this, arguments); @@ -9844,7 +10691,7 @@ $.fn.extend({
_hide: $.fn.hide, hide: function(speed) { - if (!speed || typeof speed == 'number' || $.fx.speeds[speed]) { + if ( standardSpeed( speed ) ) { return this._hide.apply(this, arguments); } else { var args = _normalizeArguments.apply(this, arguments); @@ -9853,11 +10700,10 @@ $.fn.extend({ } },
- // jQuery core overloads toggle and create _toggle + // jQuery core overloads toggle and creates _toggle __toggle: $.fn.toggle, toggle: function(speed) { - if (!speed || typeof speed == 'number' || $.fx.speeds[speed] || - typeof speed == 'boolean' || $.isFunction(speed)) { + if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) { return this.__toggle.apply(this, arguments); } else { var args = _normalizeArguments.apply(this, arguments); @@ -10091,25 +10937,25 @@ $.extend($.easing,
})(jQuery); /* - * jQuery UI Effects Blind 1.8 + * jQuery UI Effects Blind 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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($) { +(function( $, undefined ) {
$.effects.blind = function(o) {
return this.queue(function() {
// Create element - var el = $(this), props = ['position','top','left']; + var el = $(this), props = ['position','top','bottom','left','right'];
// Set options var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode @@ -10140,25 +10986,25 @@ $.effects.blind = function(o) {
})(jQuery); /* - * jQuery UI Effects Bounce 1.8 + * jQuery UI Effects Bounce 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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($) { +(function( $, undefined ) {
$.effects.bounce = function(o) {
return this.queue(function() {
// Create element - var el = $(this), props = ['position','top','left']; + var el = $(this), props = ['position','top','bottom','left','right'];
// Set options var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode @@ -10218,25 +11064,25 @@ $.effects.bounce = function(o) {
})(jQuery); /* - * jQuery UI Effects Clip 1.8 + * jQuery UI Effects Clip 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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($) { +(function( $, undefined ) {
$.effects.clip = function(o) {
return this.queue(function() {
// Create element - var el = $(this), props = ['position','top','left','height','width']; + var el = $(this), props = ['position','top','bottom','left','right','height','width'];
// Set options var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode @@ -10272,25 +11118,25 @@ $.effects.clip = function(o) {
})(jQuery); /* - * jQuery UI Effects Drop 1.8 + * jQuery UI Effects Drop 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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($) { +(function( $, undefined ) {
$.effects.drop = function(o) {
return this.queue(function() {
// Create element - var el = $(this), props = ['position','top','left','opacity']; + var el = $(this), props = ['position','top','bottom','left','right','opacity'];
// Set options var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode @@ -10322,18 +11168,18 @@ $.effects.drop = function(o) {
})(jQuery); /* - * jQuery UI Effects Explode 1.8 + * jQuery UI Effects Explode 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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($) { +(function( $, undefined ) {
$.effects.explode = function(o) {
@@ -10401,25 +11247,57 @@ $.effects.explode = function(o) {
})(jQuery); /* - * jQuery UI Effects Fold 1.8 + * 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 (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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($) { +(function( $, undefined ) {
$.effects.fold = function(o) {
return this.queue(function() {
// Create element - var el = $(this), props = ['position','top','left']; + var el = $(this), props = ['position','top','bottom','left','right'];
// Set options var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode @@ -10457,18 +11335,18 @@ $.effects.fold = function(o) {
})(jQuery); /* - * jQuery UI Effects Highlight 1.8 + * jQuery UI Effects Highlight 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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($) { +(function( $, undefined ) {
$.effects.highlight = function(o) { return this.queue(function() { @@ -10507,18 +11385,18 @@ $.effects.highlight = function(o) {
})(jQuery); /* - * jQuery UI Effects Pulsate 1.8 + * jQuery UI Effects Pulsate 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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($) { +(function( $, undefined ) {
$.effects.pulsate = function(o) { return this.queue(function() { @@ -10558,18 +11436,18 @@ $.effects.pulsate = function(o) {
})(jQuery); /* - * jQuery UI Effects Scale 1.8 + * jQuery UI Effects Scale 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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($) { +(function( $, undefined ) {
$.effects.puff = function(o) { return this.queue(function() { @@ -10643,8 +11521,8 @@ $.effects.size = function(o) { return this.queue(function() {
// Create element - var el = $(this), props = ['position','top','left','width','height','overflow','opacity']; - var props1 = ['position','top','left','overflow','opacity']; // Always restore + 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']; @@ -10736,25 +11614,25 @@ $.effects.size = function(o) {
})(jQuery); /* - * jQuery UI Effects Shake 1.8 + * jQuery UI Effects Shake 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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($) { +(function( $, undefined ) {
$.effects.shake = function(o) {
return this.queue(function() {
// Create element - var el = $(this), props = ['position','top','left']; + var el = $(this), props = ['position','top','bottom','left','right'];
// Set options var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode @@ -10793,25 +11671,25 @@ $.effects.shake = function(o) {
})(jQuery); /* - * jQuery UI Effects Slide 1.8 + * jQuery UI Effects Slide 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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($) { +(function( $, undefined ) {
$.effects.slide = function(o) {
return this.queue(function() {
// Create element - var el = $(this), props = ['position','top','left']; + var el = $(this), props = ['position','top','bottom','left','right'];
// Set options var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode @@ -10823,7 +11701,7 @@ $.effects.slide = function(o) { 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' ? -distance : distance); // Shift + if (mode == 'show') el.css(ref, motion == 'pos' ? (isNaN(distance) ? "-" + distance : -distance) : distance); // Shift
// Animation var animation = {}; @@ -10843,18 +11721,18 @@ $.effects.slide = function(o) {
})(jQuery); /* - * jQuery UI Effects Transfer 1.8 + * jQuery UI Effects Transfer 1.8.16 * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. + * 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($) { +(function( $, undefined ) {
$.effects.transfer = function(o) { return this.queue(function() { diff --git a/libraries/common.inc.php b/libraries/common.inc.php index 8c34bdb..1a1dd23 100644 --- a/libraries/common.inc.php +++ b/libraries/common.inc.php @@ -555,7 +555,7 @@ $_REQUEST['js_frame'] = PMA_ifSetOr($_REQUEST['js_frame'], ''); */ $GLOBALS['js_include'] = array(); $GLOBALS['js_include'][] = 'jquery/jquery-1.6.2.js'; -$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js'; +$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.6.custom.js'; $GLOBALS['js_include'][] = 'update-location.js';
/** diff --git a/libraries/header_meta_style.inc.php b/libraries/header_meta_style.inc.php index 076035b..133afd4 100644 --- a/libraries/header_meta_style.inc.php +++ b/libraries/header_meta_style.inc.php @@ -47,5 +47,5 @@ if ($GLOBALS['text_dir'] == 'ltr') { ?></title> <link rel="stylesheet" type="text/css" href="<?php echo defined('PMA_PATH_TO_BASEDIR') ? PMA_PATH_TO_BASEDIR : ''; ?>phpmyadmin.css.php<?php echo PMA_generate_common_url(array('server' => $GLOBA "),10) || 0) ); s initialised as well as being kept in step with any changes that might have happened on the page). @I�� xdF��* 0?�� ��)��* ��)��* �H�� `�)��* I�� �_���* u�)��* P���* �T���* �Y���* ��*��* xdF��* 0?�� >�� k�)��* �! �! �H�� @I�� H.&��* @�� ��)��* ��)��* �H�� `�)��* I�� I�� �H�� 8�J��* �p� @I�� u�)��* ��*��* @�� �>�� k�)��* G H I J K M N O P �H�� @I�� H����* �A�� ��)��* ��)��* �H�� 0_���* u�)��* pF��* ����* P���* �T���* �Y���* ��*��* H����* �A�� �?�� k�)��* 8����* �A�� @�� k�)��* (����* �A�� P@�� k�)��* ����* �A�� �@�� k�)��* �^���* u�)��* �Y���* ;�� �h���* e�)��* �T���* A�� yh���* e�)��* P���* PA�� Zh���* e�)��* ����* pF��* ����* P���* �tF��* �T���* �Y���* ��*��* 8�J��* ݥ��* @I�� p����* C�� �A�� k�)��* 5 6 7 8 : <