From: Leo Koppelkamm Date: Thu, 14 Apr 2011 13:09:02 +0000 (+0000) Subject: Updating jQuery UI to 1.8.11 (was 1.8.2). Also loosening button css, since j.ui.butto... X-Git-Tag: 1.31.0-rc.0~30852 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/?a=commitdiff_plain;h=3897fa0691edccc3a03f3ca46fc4b31b70284abc;p=lhc%2Fweb%2Fwiklou.git Updating jQuery UI to 1.8.11 (was 1.8.2). Also loosening button css, since j.ui.button works for non ') - .text(name) - .click(function() { fn.apply(self.element[0], arguments); }) - .appendTo(uiDialogButtonPane); + .attr( props, true ) + .unbind('click') + .click(function() { + props.click.apply(self.element[0], arguments); + }) + .appendTo(uiButtonSet); if ($.fn.button) { button.button(); } @@ -450,40 +489,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 @@ -494,31 +527,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 @@ -530,7 +572,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": @@ -546,44 +588,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); - } - resize = true; - break; - case "maxWidth": - if (isResizable) { - uiDialog.resizable('option', 'maxWidth', value); - } - resize = true; - break; - case "minHeight": - if (isResizable) { - uiDialog.resizable('option', 'minHeight', value); + var isDraggable = uiDialog.is( ":data(draggable)" ); + if ( isDraggable && !value ) { + uiDialog.draggable( "destroy" ); } - 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'); } @@ -602,15 +621,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() { @@ -618,16 +631,21 @@ $.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({ + 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 nonContentHeight = this.uiDialog.css({ @@ -635,16 +653,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()); @@ -653,7 +681,7 @@ $.widget("ui.dialog", { }); $.extend($.ui.dialog, { - version: "1.8.2", + version: "1.8.11", uuid: 0, maxZ: 0, @@ -689,7 +717,10 @@ $.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); @@ -724,7 +755,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'); diff --git a/resources/jquery.ui/jquery.ui.draggable.js b/resources/jquery.ui/jquery.ui.draggable.js index b4c1070dfa..5f36761607 100644 --- a/resources/jquery.ui/jquery.ui.draggable.js +++ b/resources/jquery.ui/jquery.ui.draggable.js @@ -1,9 +1,9 @@ /* - * jQuery UI Draggable 1.8.2 + * jQuery UI Draggable 1.8.11 * - * 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 * @@ -12,7 +12,7 @@ * jquery.ui.mouse.js * jquery.ui.widget.js */ -(function($) { +(function( $, undefined ) { $.widget("ui.draggable", $.ui.mouse, { widgetEventPrefix: "drag", @@ -192,8 +192,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))) { @@ -317,7 +317,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) }; }, @@ -333,10 +335,10 @@ $.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) { @@ -345,10 +347,10 @@ $.widget("ui.draggable", $.ui.mouse, { 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 + co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0), + co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0), + 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 - this.margins.right, + 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 - this.margins.bottom ]; } else if(o.containment.constructor == Array) { this.containment = o.containment; @@ -459,7 +461,7 @@ $.widget("ui.draggable", $.ui.mouse, { }); $.extend($.ui.draggable, { - version: "1.8.2" + version: "1.8.11" }); $.ui.plugin.add("draggable", "connectToSortable", { @@ -475,7 +477,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); } }); diff --git a/resources/jquery.ui/jquery.ui.droppable.js b/resources/jquery.ui/jquery.ui.droppable.js index b6a15fdf1b..7d6b897589 100644 --- a/resources/jquery.ui/jquery.ui.droppable.js +++ b/resources/jquery.ui/jquery.ui.droppable.js @@ -1,9 +1,9 @@ /* - * jQuery UI Droppable 1.8.2 + * jQuery UI Droppable 1.8.11 * - * 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 * @@ -13,7 +13,7 @@ * jquery.ui.mouse.js * jquery.ui.draggable.js */ -(function($) { +(function( $, undefined ) { $.widget("ui.droppable", { widgetEventPrefix: "drop", @@ -147,7 +147,7 @@ $.widget("ui.droppable", { }); $.extend($.ui.droppable, { - version: "1.8.2" + version: "1.8.11" }); $.ui.intersect = function(draggable, droppable, toleranceMode) { @@ -161,8 +161,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 @@ -212,11 +212,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 - } }, diff --git a/resources/jquery.ui/jquery.ui.mouse.js b/resources/jquery.ui/jquery.ui.mouse.js index 871edd8318..b8db85ceb0 100644 --- a/resources/jquery.ui/jquery.ui.mouse.js +++ b/resources/jquery.ui/jquery.ui.mouse.js @@ -1,16 +1,16 @@ /*! - * jQuery UI Mouse 1.8.2 + * jQuery UI Mouse 1.8.11 * - * 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 ) { $.widget("ui.mouse", { options: { @@ -26,8 +26,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; } @@ -75,6 +75,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); @@ -86,18 +91,14 @@ $.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.preventDefault(); event.originalEvent.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); } @@ -122,7 +123,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); } diff --git a/resources/jquery.ui/jquery.ui.position.js b/resources/jquery.ui/jquery.ui.position.js index 50dd57f0e3..b66e59ef8d 100644 --- a/resources/jquery.ui/jquery.ui.position.js +++ b/resources/jquery.ui/jquery.ui.position.js @@ -1,20 +1,19 @@ /* - * jQuery UI Position 1.8.2 + * jQuery UI Position 1.8.11 * - * 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; @@ -27,21 +26,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; @@ -58,13 +59,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; }); @@ -82,13 +83,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; } @@ -99,23 +100,35 @@ $.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 = parseInt( position.left ); - position.top = parseInt( position.top ); + 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] ] ) { @@ -124,6 +137,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 @@ -142,41 +158,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" ? @@ -186,8 +205,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; diff --git a/resources/jquery.ui/jquery.ui.progressbar.js b/resources/jquery.ui/jquery.ui.progressbar.js index 4bc092d194..c432132a5f 100644 --- a/resources/jquery.ui/jquery.ui.progressbar.js +++ b/resources/jquery.ui/jquery.ui.progressbar.js @@ -1,9 +1,9 @@ /* - * jQuery UI Progressbar 1.8.2 + * jQuery UI Progressbar 1.8.11 * - * 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 * @@ -11,25 +11,30 @@ * 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 = $( "
" ) .appendTo( this.element ); + this.oldValue = this._value(); this._refreshValue(); }, @@ -56,12 +61,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 ); @@ -73,35 +78,31 @@ $.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; + return Math.min( this.options.max, Math.max( this.min, val ) ); }, - _valueMin: function() { - return 0; - }, - - _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 + "%" ); + .toggleClass( "ui-corner-right", value === this.options.max ) + .width( percentage.toFixed(0) + "%" ); this.element.attr( "aria-valuenow", value ); } }); $.extend( $.ui.progressbar, { - version: "1.8.2" + version: "1.8.11" }); })( jQuery ); diff --git a/resources/jquery.ui/jquery.ui.resizable.js b/resources/jquery.ui/jquery.ui.resizable.js index 0a782bb515..1d1c906e8b 100644 --- a/resources/jquery.ui/jquery.ui.resizable.js +++ b/resources/jquery.ui/jquery.ui.resizable.js @@ -1,9 +1,9 @@ /* - * jQuery UI Resizable 1.8.2 + * jQuery UI Resizable 1.8.11 * - * 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 * @@ -12,7 +12,7 @@ * jquery.ui.mouse.js * jquery.ui.widget.js */ -(function($) { +(function( $, undefined ) { $.widget("ui.resizable", $.ui.mouse, { widgetEventPrefix: "resize", @@ -322,10 +322,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; @@ -519,7 +519,7 @@ $.widget("ui.resizable", $.ui.mouse, { }); $.extend($.ui.resizable, { - version: "1.8.2" + version: "1.8.11" }); /* @@ -528,28 +528,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 = { @@ -557,18 +558,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' }); } @@ -578,22 +580,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"); } }); diff --git a/resources/jquery.ui/jquery.ui.selectable.js b/resources/jquery.ui/jquery.ui.selectable.js index bc707d36ff..e3b91328f5 100644 --- a/resources/jquery.ui/jquery.ui.selectable.js +++ b/resources/jquery.ui/jquery.ui.selectable.js @@ -1,10 +1,9 @@ - /* - * jQuery UI Selectable 1.8.2 + * jQuery UI Selectable 1.8.11 * - * 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 * @@ -13,7 +12,7 @@ * jquery.ui.mouse.js * jquery.ui.widget.js */ -(function($) { +(function( $, undefined ) { $.widget("ui.selectable", $.ui.mouse, { options: { @@ -90,8 +89,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, @@ -263,7 +260,7 @@ $.widget("ui.selectable", $.ui.mouse, { }); $.extend($.ui.selectable, { - version: "1.8.2" + version: "1.8.11" }); })(jQuery); diff --git a/resources/jquery.ui/jquery.ui.slider.js b/resources/jquery.ui/jquery.ui.slider.js index 81d854b583..f02a922f03 100644 --- a/resources/jquery.ui/jquery.ui.slider.js +++ b/resources/jquery.ui/jquery.ui.slider.js @@ -1,9 +1,9 @@ /* - * jQuery UI Slider 1.8.2 + * jQuery UI Slider 1.8.11 * - * 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 * @@ -12,8 +12,7 @@ * 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) @@ -310,8 +309,9 @@ $.widget( "ui.slider", $.ui.mouse, { ( 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; }, @@ -585,14 +585,14 @@ $.widget( "ui.slider", $.ui.mouse, { // returns the step-aligned value that val is closest to, between (inclusive) min and max _trimAlignValue: function( val ) { - if ( val < this._valueMin() ) { + if ( val <= this._valueMin() ) { return this._valueMin(); } - if ( val > this._valueMax() ) { + if ( val >= this._valueMax() ) { return this._valueMax(); } var step = ( this.options.step > 0 ) ? this.options.step : 1, - valModStep = val % step, + valModStep = (val - this._valueMin()) % step; alignValue = val - valModStep; if ( Math.abs(valModStep) * 2 >= step ) { @@ -676,7 +676,7 @@ $.widget( "ui.slider", $.ui.mouse, { }); $.extend( $.ui.slider, { - version: "1.8.2" + version: "1.8.11" }); }(jQuery)); diff --git a/resources/jquery.ui/jquery.ui.sortable.js b/resources/jquery.ui/jquery.ui.sortable.js index fe9898e066..1a06dcae0f 100644 --- a/resources/jquery.ui/jquery.ui.sortable.js +++ b/resources/jquery.ui/jquery.ui.sortable.js @@ -1,9 +1,9 @@ /* - * jQuery UI Sortable 1.8.2 + * jQuery UI Sortable 1.8.11 * - * 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 * @@ -12,7 +12,7 @@ * jquery.ui.mouse.js * jquery.ui.widget.js */ -(function($) { +(function( $, undefined ) { $.widget("ui.sortable", $.ui.mouse, { widgetEventPrefix: "sort", @@ -49,8 +49,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 ? (/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(); @@ -360,7 +360,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"); @@ -378,21 +378,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(); - - $.extend(this, { - helper: null, - dragging: false, - reverting: false, - _noFinalSort: null - }); + 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(); - if(this.domPosition.prev) { - $(this.domPosition.prev).after(this.currentItem); - } else { - $(this.domPosition.parent).prepend(this.currentItem); + $.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); + } } return this; @@ -409,6 +411,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('&'); }, @@ -1061,7 +1067,7 @@ $.widget("ui.sortable", $.ui.mouse, { }); $.extend($.ui.sortable, { - version: "1.8.2" + version: "1.8.11" }); })(jQuery); diff --git a/resources/jquery.ui/jquery.ui.tabs.js b/resources/jquery.ui/jquery.ui.tabs.js index 1f94d52a25..3be7ff494a 100644 --- a/resources/jquery.ui/jquery.ui.tabs.js +++ b/resources/jquery.ui/jquery.ui.tabs.js @@ -1,9 +1,9 @@ /* - * jQuery UI Tabs 1.8.2 + * jQuery UI Tabs 1.8.11 * - * 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 * @@ -11,7 +11,7 @@ * jquery.ui.core.js * jquery.ui.widget.js */ -(function($) { +(function( $, undefined ) { var tabId = 0, listId = 0; @@ -24,7 +24,7 @@ function getNextListId() { return ++listId; } -$.widget("ui.tabs", { +$.widget( "ui.tabs", { options: { add: null, ajaxOptions: null, @@ -34,619 +34,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: '
', + panelTemplate: "
", remove: null, select: null, show: null, - spinner: 'Loading…', - tabTemplate: '
  • #{label}
  • ' + spinner: "Loading…", + tabTemplate: "
  • #{label}
  • " }, + _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, '') || + _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-' + getNextListId()); - 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 = $([]); + _tabify: function( init ) { + var self = this, + o = this.options, + fragmentId = /^#.+/; // Safari 2 reports '#' for an empty hash - var self = this, o = this.options; - - 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
  • - 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(); - - if ($.inArray(o.selected, o.disabled) != -1) { - o.disabled.splice($.inArray(o.selected, o.disabled), 1); + 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 ); } // 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); - } - $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); + var $panel = self.element.find( "#" + id ); + if ( !$panel.length ) { + $panel = $( o.panelTemplate ) + .attr( "id", id ) + .data( "destroy.tabs", true ); } - else { - $li.insertBefore(this.lis[index]); - $panel.insertBefore(this.panels[index]); + $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 ] ); } - 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; } @@ -656,19 +687,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.2' +$.extend( $.ui.tabs, { + version: "1.8.11" }); /* @@ -678,46 +708,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; } @@ -726,4 +755,4 @@ $.extend($.ui.tabs.prototype, { } }); -})(jQuery); +})( jQuery ); diff --git a/resources/jquery.ui/jquery.ui.widget.js b/resources/jquery.ui/jquery.ui.widget.js index 6425d086a5..b6b1beea97 100644 --- a/resources/jquery.ui/jquery.ui.widget.js +++ b/resources/jquery.ui/jquery.ui.widget.js @@ -1,28 +1,38 @@ /*! - * jQuery UI Widget 1.8.2 + * jQuery UI Widget 1.8.11 * - * 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; - -$.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" ); - }); - } +(function( $, undefined ) { + +// jQuery 1.4+ +if ( $.cleanData ) { + var _cleanData = $.cleanData; + $.cleanData = function( elems ) { + for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { + $( elem ).triggerHandler( "remove" ); } - 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() { + $( this ).triggerHandler( "remove" ); + }); + } + } + return _remove.call( $(this), selector, keepData ); + }); + }; +} $.widget = function( name, base, prototype ) { var namespace = name.split( "." )[ 0 ], @@ -57,7 +67,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, @@ -80,7 +90,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; } @@ -90,6 +100,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; @@ -99,10 +118,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 ) ); } @@ -129,10 +145,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; @@ -141,8 +158,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() {}, @@ -163,12 +184,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" ) { @@ -179,11 +199,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; diff --git a/resources/jquery.ui/themes/vector/jquery.ui.button.css b/resources/jquery.ui/themes/vector/jquery.ui.button.css index 5507c42b0f..97cfcdaff6 100644 --- a/resources/jquery.ui/themes/vector/jquery.ui.button.css +++ b/resources/jquery.ui/themes/vector/jquery.ui.button.css @@ -29,7 +29,7 @@ input.ui-button { padding: .4em 1em; } /* workarounds */ button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */ -body button.ui-button { +body .ui-button { -moz-border-radius: 4px; -webkit-border-radius: 4px; padding: 0.2em 0.6em 0.15em !important; @@ -43,18 +43,18 @@ body button.ui-button { width: auto; overflow: visible; } -body button.ui-button:hover { +body .ui-button:hover { border-color: #6e7273; /* @embed */ background: #e1e1e1 url(images/button-over.png) repeat-x scroll 50% 100% !important; } -body button.ui-button:active, -body button.ui-button:focus { +body .ui-button:active, +body .ui-button:focus { border-color: #707271; /* @embed */ background: #bfbfbf url(images/button-down.png) repeat-x scroll 50% 100% !important; } -body button.ui-button.disabled { +body .ui-button.disabled { color: #7f7f7f; border-color: #cccccc; /* @embed */ @@ -67,24 +67,24 @@ body button.ui-button::-moz-focus-inner { /* Green buttons */ -body button.ui-button.ui-button-green { +body .ui-button.ui-button-green { color: white; border-color: #97af7e !important; /* @embed */ background: #85c940 url(images/button-off-green.png) repeat-x scroll 50% 100% !important; } -body button.ui-button.ui-button-green:hover { +body .ui-button.ui-button-green:hover { border-color: #778e61; /* @embed */ background: #77ad40 url(images/button-over-green.png) repeat-x scroll 50% 100% !important; } -body button.ui-button.ui-button-green:active, -body button.ui-button.ui-button-green:focus { +body .ui-button.ui-button-green:active, +body .ui-button.ui-button-green:focus { border-color: #61b000; /* @embed */ background: #54a800 url(images/button-down-green.png) repeat-x scroll 50% 100% !important; } -body button.ui-button.ui-button-green.disabled { +body .ui-button.ui-button-green.disabled { color: #7f7f7f; border-color: #b8d29f; /* @embed */ @@ -93,24 +93,24 @@ body button.ui-button.ui-button-green.disabled { /* Blue buttons */ -body button.ui-button.ui-button-blue { +body .ui-button.ui-button-blue { color: white; border-color: #407ec9 !important; /* @embed */ background: #407ec9 url(images/button-off-blue.png) repeat-x scroll 50% 100% !important; } -body button.ui-button.ui-button-blue:hover { +body .ui-button.ui-button-blue:hover { border-color: #245289; /* @embed */ background: #4071ad url(images/button-over-blue.png) repeat-x scroll 50% 100% !important; } -body button.ui-button.ui-button-blue:active, -body button.ui-button.ui-button-blue:focus { +body .ui-button.ui-button-blue:active, +body .ui-button.ui-button-blue:focus { border-color: #003980; /* @embed */ background: #004daa url(images/button-down-blue.png) repeat-x scroll 50% 100% !important; } -body button.ui-button.ui-button-blue.disabled { +body .ui-button.ui-button-blue.disabled { border-color: #9eafc6; /* @embed */ background: #c3c8cf url(images/button-disabled-blue.png) repeat-x scroll 50% 100% !important; @@ -118,24 +118,24 @@ body button.ui-button.ui-button-blue.disabled { /* Red buttons */ -body button.ui-button.ui-button-red { +body .ui-button.ui-button-red { color: white; border-color: #af977e !important; /* @embed */ background: #c9404c url(images/button-off-red.png) repeat-x scroll 50% 100% !important; } -body button.ui-button.ui-button-red:hover { +body .ui-button.ui-button-red:hover { border-color: #8e7761; /* @embed */ background: #ad404a url(images/button-over-red.png) repeat-x scroll 50% 100% !important; } -body button.ui-button.ui-button-red:active, -body button.ui-button.ui-button-red:focus { +body .ui-button.ui-button-red:active, +body .ui-button.ui-button-red:focus { border-color: #b06100; /* @embed */ background: #aa000f url(images/button-down-red.png) repeat-x scroll 50% 100% !important; } -body button.ui-button.ui-button-red.disabled { +body .ui-button.ui-button-red.disabled { color: #7f7f7f; border-color: #c3acae; /* @embed */