aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/i18n/jquery.ui.datepicker-nl.js2
-rw-r--r--ui/i18n/jquery.ui.datepicker-sk.js2
-rw-r--r--ui/jquery.effects.core.js49
-rw-r--r--ui/jquery.ui.accordion.js11
-rw-r--r--ui/jquery.ui.autocomplete.js11
-rw-r--r--ui/jquery.ui.core.js46
-rw-r--r--ui/jquery.ui.menu.js100
-rwxr-xr-xui/jquery.ui.tabs.js239
-rw-r--r--ui/jquery.ui.widget.js5
9 files changed, 271 insertions, 194 deletions
diff --git a/ui/i18n/jquery.ui.datepicker-nl.js b/ui/i18n/jquery.ui.datepicker-nl.js
index 663d6bb26..40be2cfa4 100644
--- a/ui/i18n/jquery.ui.datepicker-nl.js
+++ b/ui/i18n/jquery.ui.datepicker-nl.js
@@ -14,7 +14,7 @@ jQuery(function($){
dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
weekHeader: 'Wk',
- dateFormat: 'dd/mm/yy',
+ dateFormat: 'dd-mm-yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
diff --git a/ui/i18n/jquery.ui.datepicker-sk.js b/ui/i18n/jquery.ui.datepicker-sk.js
index a9179c179..83ae8e811 100644
--- a/ui/i18n/jquery.ui.datepicker-sk.js
+++ b/ui/i18n/jquery.ui.datepicker-sk.js
@@ -10,7 +10,7 @@ jQuery(function($){
'Júl','August','September','Október','November','December'],
monthNamesShort: ['Jan','Feb','Mar','Apr','Máj','Jún',
'Júl','Aug','Sep','Okt','Nov','Dec'],
- dayNames: ['Nedel\'a','Pondelok','Utorok','Streda','Štvrtok','Piatok','Sobota'],
+ dayNames: ['Nedeľa','Pondelok','Utorok','Streda','Štvrtok','Piatok','Sobota'],
dayNamesShort: ['Ned','Pon','Uto','Str','Štv','Pia','Sob'],
dayNamesMin: ['Ne','Po','Ut','St','Št','Pia','So'],
weekHeader: 'Ty',
diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js
index 573cb2554..581fb0861 100644
--- a/ui/jquery.effects.core.js
+++ b/ui/jquery.effects.core.js
@@ -234,12 +234,12 @@ $.effects.animateClass = function( value, duration, easing, callback ) {
easing = null;
}
- return this.queue( 'fx', 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 ] ) {
@@ -247,32 +247,31 @@ $.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 ] );
+ 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 );
}
- });
- // 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 );
+ if ( callback ) {
+ callback.apply( this, arguments );
+ }
+ $.dequeue( this );
}
});
-
- // $.animate adds a function to the end of the queue
- // but we want it at the front
- var queue = $.queue( this ),
- anim = queue.splice( queue.length - 1, 1 )[ 0 ];
- queue.splice( 1, 0, anim );
- $.dequeue( this );
});
};
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js
index 455c66a28..0cc1f9e2a 100644
--- a/ui/jquery.ui.accordion.js
+++ b/ui/jquery.ui.accordion.js
@@ -25,7 +25,11 @@ $.widget( "ui.accordion", {
icons: {
activeHeader: "ui-icon-triangle-1-s",
header: "ui-icon-triangle-1-e"
- }
+ },
+
+ // callbacks
+ activate: null,
+ beforeActivate: null
},
_create: function() {
@@ -649,6 +653,11 @@ if ( $.uiBackCompat !== false ) {
// change events
(function( $, prototype ) {
+ $.extend( prototype.options, {
+ change: null,
+ changestart: null
+ });
+
var _trigger = prototype._trigger;
prototype._trigger = function( type, event, data ) {
var ret = _trigger.apply( this, arguments );
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index 1685c0652..526eb3869 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -30,7 +30,16 @@ $.widget( "ui.autocomplete", {
at: "left bottom",
collision: "none"
},
- source: null
+ source: null,
+
+ // callbacks
+ change: null,
+ close: null,
+ focus: null,
+ open: null,
+ response: null,
+ search: null,
+ select: null
},
pending: 0,
diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js
index 51f6b71d7..8bcc4c441 100644
--- a/ui/jquery.ui.core.js
+++ b/ui/jquery.ui.core.js
@@ -174,6 +174,27 @@ $.each( [ "Width", "Height" ], function( i, name ) {
});
// 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" ||
@@ -187,30 +208,13 @@ $.extend( $.expr[ ":" ], {
},
focusable: function( element ) {
- var nodeName = element.nodeName.toLowerCase(),
- tabIndex = $.attr( element, "tabindex" );
- 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 || !isNaN( tabIndex )
- : !isNaN( tabIndex ))
- // the element and all of its ancestors must be visible
- && visible( element );
+ return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
},
tabbable: function( element ) {
- var tabIndex = $.attr( element, "tabindex" );
- return ( isNaN( tabIndex ) || tabIndex >= 0 ) && $( element ).is( ":focusable" );
+ var tabIndex = $.attr( element, "tabindex" ),
+ isTabIndexNaN = isNaN( tabIndex );
+ return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
}
});
diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js
index af1101f73..0f585d976 100644
--- a/ui/jquery.ui.menu.js
+++ b/ui/jquery.ui.menu.js
@@ -28,11 +28,14 @@ $.widget("ui.menu", {
var self = this;
this.activeMenu = this.element;
this.menuId = this.element.attr( "id" ) || "ui-menu-" + idIncrement++;
+ if (this.element.find(".ui-icon").length) {
+ this.element.addClass("ui-menu-icons");
+ }
this.element
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
.attr({
id: this.menuId,
- role: "listbox"
+ role: "menu"
})
.bind( "click.menu", function( event ) {
var item = $( event.target ).closest( ".ui-menu-item:has(a)" );
@@ -108,9 +111,16 @@ $.widget("ui.menu", {
event.preventDefault();
break;
case $.ui.keyCode.ENTER:
- self.select( event );
+ if (self.active.children("a[aria-haspopup='true']").length) {
+ if (self.right( event )) {
+ event.stopImmediatePropagation();
+ }
+ }
+ else {
+ self.select( event );
+ event.stopImmediatePropagation();
+ }
event.preventDefault();
- event.stopImmediatePropagation();
break;
case $.ui.keyCode.ESCAPE:
if ( self.left( event ) ) {
@@ -132,13 +142,13 @@ $.widget("ui.menu", {
function escape(value) {
return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
}
- var match = self.widget().children(".ui-menu-item").filter(function() {
+ var match = self.activeMenu.children(".ui-menu-item").filter(function() {
return new RegExp("^" + escape(character), "i").test($(this).children("a").text());
});
var match = skip && match.index(self.active.next()) != -1 ? self.active.nextAll(".ui-menu-item") : match;
if (!match.length) {
character = String.fromCharCode(event.keyCode);
- match = self.widget().children(".ui-menu-item").filter(function() {
+ match = self.activeMenu.children(".ui-menu-item").filter(function() {
return new RegExp("^" + escape(character), "i").test($(this).children("a").text());
});
}
@@ -160,41 +170,62 @@ $.widget("ui.menu", {
},
_destroy: function() {
+ //destroy (sub)menus
this.element
+ .removeAttr( "aria-activedescendant" )
+ .find("ul")
+ .andSelf()
.removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
- .removeAttr( "tabIndex" )
.removeAttr( "role" )
- .removeAttr( "aria-activedescendant" );
+ .removeAttr("id")
+ .removeAttr( "aria-labelledby" )
+ .removeAttr( "aria-expanded" )
+ .removeAttr( "aria-hidden" )
+ .show();
- this.element.children( ".ui-menu-item" )
+ //destroy menu items
+ this.element.find( ".ui-menu-item" )
+ .unbind( ".menu" )
.removeClass( "ui-menu-item" )
.removeAttr( "role" )
.children( "a" )
.removeClass( "ui-corner-all ui-state-hover" )
.removeAttr( "tabIndex" )
- .unbind( ".menu" );
+ .removeAttr( "role" )
+ .removeAttr( "aria-haspopup" )
+ .removeAttr( "id" )
+ .children(".ui-icon").remove();
},
refresh: function() {
+ var self = this;
// initialize nested menus
- // TODO add role=listbox to these, too? or just the top level menu?
var submenus = this.element.find("ul:not(.ui-menu)")
.addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
+ .attr("role", "menu")
.hide()
-
- submenus
- .prev("a")
- .prepend('<span class="ui-icon ui-icon-carat-1-e"></span>');
-
+ .attr("aria-hidden", "true")
+ .attr("aria-expanded", "false")
+ ;
// don't refresh list items that are already adapted
var items = submenus.add(this.element).children( "li:not(.ui-menu-item):has(a)" )
.addClass( "ui-menu-item" )
- .attr( "role", "menuitem" );
+ .attr( "role", "presentation" );
items.children( "a" )
.addClass( "ui-corner-all" )
- .attr( "tabIndex", -1 );
+ .attr( "tabIndex", -1 )
+ .attr( "role", "menuitem" )
+ .attr("id", function(i) {return self.element.attr("id") + "-" + i});
+
+ submenus.each(function() {
+ var menu = $(this);
+ var item = menu.prev("a")
+ item.attr("aria-haspopup", "true")
+ .prepend('<span class="ui-menu-icon ui-icon ui-icon-carat-1-e"></span>');
+ menu.attr("aria-labelledby", item.attr("id"));
+ });
},
focus: function( event, item ) {
@@ -219,13 +250,11 @@ $.widget("ui.menu", {
this.active = item.first()
.children( "a" )
.addClass( "ui-state-focus" )
- .attr( "id", function(index, id) {
- return (self.itemId = id || self.menuId + "-activedescendant");
- })
.end();
- // need to remove the attribute before adding it for the screenreader to pick up the change
- // see http://groups.google.com/group/jquery-a11y/msg/929e0c1e8c5efc8f
- this.element.removeAttr("aria-activedescendant").attr("aria-activedescendant", self.itemId)
+ self.element.attr("aria-activedescendant", self.active.children("a").attr("id"))
+
+ // highlight active parent menu item, if any
+ this.active.parent().closest(".ui-menu-item").children("a:first").addClass("ui-state-active");
self.timer = setTimeout(function() {
self._close();
@@ -247,10 +276,6 @@ $.widget("ui.menu", {
clearTimeout(this.timer);
this.active.children( "a" ).removeClass( "ui-state-focus" );
- // remove only generated id
- $( "#" + this.menuId + "-activedescendant" ).removeAttr( "id" );
- this.element.removeAttr( "aria-activedescenant" );
- this._trigger( "blur", event );
this.active = null;
},
@@ -264,23 +289,20 @@ $.widget("ui.menu", {
},
_open: function(submenu) {
- this.element.find(".ui-menu").not(submenu.parents()).hide();
-
+ clearTimeout(this.timer);
+ this.element.find(".ui-menu").not(submenu.parents()).hide().attr("aria-hidden", "true");
var position = $.extend({}, {
of: this.active
}, $.type(this.options.position) == "function"
? this.options.position(this.active)
: this.options.position
);
-
- submenu.show().position(position);
-
- this.active.find(">a:first").addClass("ui-state-active");
+ submenu.show().removeAttr("aria-hidden").attr("aria-expanded", "true").position(position);
},
closeAll: function() {
this.element
- .find("ul").hide().end()
+ .find("ul").hide().attr("aria-hidden", "true").attr("aria-expanded", "false").end()
.find("a.ui-state-active").removeClass("ui-state-active");
this.blur();
this.activeMenu = this.element;
@@ -288,25 +310,27 @@ $.widget("ui.menu", {
_close: function() {
this.active.parent()
- .find("ul").hide().end()
+ .find("ul").hide().attr("aria-hidden", "true").attr("aria-expanded", "false").end()
.find("a.ui-state-active").removeClass("ui-state-active");
},
left: function(event) {
- var newItem = this.active && this.active.parents("li").first();
+ var newItem = this.active && this.active.parents("li:not(.ui-menubar-item)").first();
if (newItem && newItem.length) {
- this.active.parent().hide();
+ this.active.parent().attr("aria-hidden", "true").attr("aria-expanded", "false").hide();
this.focus(event, newItem);
return true;
}
},
right: function(event) {
+ var self= this;
var newItem = this.active && this.active.children("ul").children("li").first();
if (newItem && newItem.length) {
this._open(newItem.parent());
var current = this.active;
- this.focus(event, newItem);
+ //timeout so Firefox will not hide activedescendant change in expanding submenu from AT
+ setTimeout(function(){self.focus(event, newItem)}, 20);
return true;
}
},
diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js
index 699c1a5ee..7946cc667 100755
--- a/ui/jquery.ui.tabs.js
+++ b/ui/jquery.ui.tabs.js
@@ -26,13 +26,15 @@ function getNextListId() {
$.widget( "ui.tabs", {
options: {
- activate: null,
active: null,
- beforeActivate: null,
- beforeLoad: null,
collapsible: false,
event: "click",
fx: null, // e.g. { height: 'toggle', opacity: 'toggle', duration: 200 }
+
+ // callbacks
+ activate: null,
+ beforeActivate: null,
+ beforeLoad: null,
load: null
},
@@ -79,7 +81,7 @@ $.widget( "ui.tabs", {
options.active = active;
// don't allow collapsible: false and active: false
- if ( !options.collapsible && options.active === false ) {
+ if ( !options.collapsible && options.active === false && this.anchors.length ) {
options.active = 0;
}
@@ -128,13 +130,26 @@ $.widget( "ui.tabs", {
return;
}
+ if ( key === "disabled" ) {
+ // don't use the widget factory's disabled handling
+ this._setupDisabled( value );
+ return;
+ }
+
+ this._super( "_setOption", key, value);
+
// setting collapsible: false while collapsed; open first panel
if ( key === "collapsible" && !value && this.options.active === false ) {
this._activate( 0 );
}
- this.options[ key ] = value;
- this.refresh();
+ if ( key === "event" ) {
+ this._setupEvents( value );
+ }
+
+ if ( key === "fx" ) {
+ this._setupFx( value );
+ }
},
_tabId: function( a ) {
@@ -155,39 +170,45 @@ $.widget( "ui.tabs", {
},
refresh: function() {
- var self = this;
+ var self = this,
+ options = this.options,
+ lis = this.list.children( ":has(a[href])" );
- this._processTabs();
+ // get disabled tabs from class attribute from HTML
+ // this will get converted to a boolean if needed in _refresh()
+ options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
+ return lis.index( tab );
+ });
+ this._processTabs();
this._refresh();
+ this.panels.not( this._getPanelForTab( this.active ) ).hide();
- // Remove panels that we created that are missing their tab
- this.element.find(".ui-tabs-panel:data(destroy.tabs)").each( function( index, panel ) {
- var anchor = self.anchors.filter( "[aria-controls='" + panel.id + "']");
- if ( !anchor.length ) {
- $( panel ).remove();
- }
- });
+ // was collapsed or no tabs
+ if ( options.active === false || !this.anchors.length ) {
+ options.active = false;
+ this.active = $();
+ // was active, but active tab is gone
+ } else if ( this.active.length && !$.contains( this.list[ 0 ], this.active[ 0 ] ) ) {
+ // activate previous tab
+ var next = options.active - 1;
+ this._activate( next >= 0 ? next : 0 );
+ // was active, active tab still exists
+ } else {
+ // make sure active index is correct
+ options.active = this.anchors.index( this.active );
+ }
},
_refresh: function() {
- var that = this,
- options = that.options;
+ var options = this.options;
this.element.toggleClass( "ui-tabs-collapsible", options.collapsible );
- this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" );
+ this.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" );
- if ( !options.disabled.length ) {
- options.disabled = false;
- }
-
- // disable tabs
- for ( var i = 0, li; ( li = this.lis[ i ] ); i++ ) {
- $( li ).toggleClass( "ui-state-disabled", $.inArray( i, options.disabled ) !== -1 );
- }
-
+ this._setupDisabled( options.disabled );
this._setupEvents( options.event );
// remove all handlers, may run on existing tabs
@@ -258,6 +279,23 @@ $.widget( "ui.tabs", {
.data( "destroy.tabs", true );
},
+ _setupDisabled: function( disabled ) {
+ if ( $.isArray( disabled ) ) {
+ if ( !disabled.length ) {
+ disabled = false;
+ } else if ( disabled.length === this.anchors.length ) {
+ disabled = true;
+ }
+ }
+
+ // disable tabs
+ for ( var i = 0, li; ( li = this.lis[ i ] ); i++ ) {
+ $( li ).toggleClass( "ui-state-disabled", ( disabled === true || $.inArray( i, disabled ) !== -1 ) );
+ }
+
+ this.options.disabled = disabled;
+ },
+
_setupFx: function( fx ) {
// set up animations
if ( fx ) {
@@ -500,53 +538,48 @@ $.widget( "ui.tabs", {
},
enable: function( index ) {
- if ( index === undefined ) {
- for ( var i = 0, len = this.lis.length; i < len; i++ ) {
- this.enable( i );
- }
- return this;
- }
- index = this._getIndex( index );
- var o = this.options;
- if ( !o.disabled || ($.isArray( o.disabled ) && $.inArray( index, o.disabled ) == -1 ) ) {
+ var disabled = this.options.disabled;
+ if ( disabled === false ) {
return;
}
- this.lis.eq( index ).removeClass( "ui-state-disabled" );
- o.disabled = this.lis.map( function( i ) {
- return $(this).is( ".ui-state-disabled" ) ? i : null;
- }).get();
-
- if ( !o.disabled.length ) {
- o.disabled = false;
+ if ( index === undefined ) {
+ disabled = false;
+ } else {
+ index = this._getIndex( index );
+ if ( $.isArray( disabled ) ) {
+ disabled = $.map( disabled, function( num ) {
+ return num !== index ? num : null;
+ });
+ } else {
+ disabled = $.map( this.lis, function( li, num ) {
+ return num !== index ? num : null;
+ });
+ }
}
-
- return this;
+ this._setupDisabled( disabled );
},
disable: function( index ) {
+ var disabled = this.options.disabled;
+ if ( disabled === true ) {
+ return;
+ }
+
if ( index === undefined ) {
- for ( var i = 0, len = this.lis.length; i < len; i++ ) {
- this.disable( i );
+ disabled = true;
+ } else {
+ index = this._getIndex( index );
+ if ( $.inArray( index, disabled ) !== -1 ) {
+ return;
}
- return this;
- }
- index = this._getIndex( index );
- var o = this.options;
- if ( !o.disabled || ($.isArray( o.disabled ) && $.inArray( index, o.disabled ) == -1 ) ) {
- this.lis.eq( index ).addClass( "ui-state-disabled" );
-
- o.disabled = this.lis.map( function( i ) {
- return $(this).is( ".ui-state-disabled" ) ? i : null;
- }).get();
-
- if ( o.disabled.length === this.anchors.length ) {
- o.disabled = true;
+ if ( $.isArray( disabled ) ) {
+ disabled = $.merge( [ index ], disabled ).sort();
+ } else {
+ disabled = [ index ];
}
-
}
-
- return this;
+ this._setupDisabled( disabled );
},
load: function( index, event ) {
@@ -626,6 +659,14 @@ $.extend( $.ui.tabs, {
// DEPRECATED
if ( $.uiBackCompat !== false ) {
+
+ // url method
+ (function( $, prototype ) {
+ prototype.url = function( index, url ) {
+ this.anchors.eq( index ).attr( "href", url );
+ };
+ }( jQuery, jQuery.ui.tabs.prototype ) );
+
// ajaxOptions and cache options
(function( $, prototype ) {
$.extend( prototype.options, {
@@ -636,7 +677,7 @@ if ( $.uiBackCompat !== false ) {
var _create = prototype._create,
_setOption = prototype._setOption,
_destroy = prototype._destroy,
- oldurl = prototype._url;
+ oldurl = prototype.url || $.noop;
$.extend( prototype, {
_create: function() {
@@ -785,43 +826,38 @@ if ( $.uiBackCompat !== false ) {
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 options = this.options,
+ li = $( options.tabTemplate
+ .replace( /#\{href\}/g, url )
+ .replace( /#\{label\}/g, label ) ),
+ id = !url.indexOf( "#" ) ?
+ url.replace( "#", "" ) :
+ this._tabId( li.find( "a" )[ 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 );
+ li.find( "a" ).attr( "aria-controls", id );
// try to find an existing element before creating a new one
- var $panel = self.element.find( "#" + id );
- if ( !$panel.length ) {
- $panel = self._createPanel( id );
+ var panel = this.element.find( "#" + id );
+ if ( !panel.length ) {
+ panel = this._createPanel( id );
}
- $panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ).hide();
+ panel.addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" ).hide();
if ( index >= this.lis.length ) {
- $li.appendTo( this.list );
- $panel.appendTo( this.list[ 0 ].parentNode );
+ li.appendTo( this.list );
+ panel.appendTo( this.list[ 0 ].parentNode );
} else {
- $li.insertBefore( this.lis[ index ] );
- $panel.insertBefore( this.panels[ index ] );
+ li.insertBefore( this.lis[ index ] );
+ panel.insertBefore( this.panels[ index ] );
}
-
- o.disabled = $.map( o.disabled, function( n, i ) {
+ options.disabled = $.map( options.disabled, function( n ) {
return n >= index ? ++n : n;
});
this.refresh();
-
- if ( this.anchors.length == 1 ) {
- o.active = o.selected = 0;
- $li.addClass( "ui-tabs-active ui-state-active" );
- $panel.show();
- this.element.queue( "tabs", function() {
- self._trigger( "activate", null, self._ui( self.anchors[ 0 ], self.panels[ 0 ] ) );
- });
-
- this.load( 0 );
+ if ( this.lis.length === 1 && options.active === false ) {
+ this.option( "active", 0 );
}
this._trigger( "add", null, this._ui( this.anchors[ index ], this.panels[ index ] ) );
@@ -830,27 +866,27 @@ if ( $.uiBackCompat !== false ) {
prototype.remove = function( index ) {
index = this._getIndex( index );
- var o = this.options,
- $li = this.lis.eq( index ).remove(),
- $panel = this.panels.eq( index ).remove();
+ var options = this.options,
+ tab = 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-active" ) && this.anchors.length > 1) {
+ if ( tab.hasClass( "ui-tabs-active" ) && this.anchors.length > 1) {
this._activate( index + ( index + 1 < this.anchors.length ? 1 : -1 ) );
}
- o.disabled = $.map(
- $.grep( o.disabled, function(n, i) {
- return n != index;
+ options.disabled = $.map(
+ $.grep( options.disabled, function( n ) {
+ return n !== index;
}),
- function( n, i ) {
+ function( n ) {
return n >= index ? --n : n;
});
this.refresh();
- this._trigger( "remove", null, this._ui( $li.find( "a" )[ 0 ], $panel[ 0 ] ) );
+ this._trigger( "remove", null, this._ui( tab.find( "a" )[ 0 ], panel[ 0 ] ) );
return this;
};
}( jQuery, jQuery.ui.tabs.prototype ) );
@@ -862,13 +898,6 @@ if ( $.uiBackCompat !== false ) {
};
}( jQuery, jQuery.ui.tabs.prototype ) );
- // url method
- (function( $, prototype ) {
- prototype.url = function( index, url ) {
- this.anchors.eq( index ).attr( "href", url );
- };
- }( jQuery, jQuery.ui.tabs.prototype ) );
-
// panel ids (idPrefix option + title attribute)
(function( $, prototype ) {
$.extend( prototype.options, {
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index a5c59ad3c..65a9f1ce4 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -155,7 +155,10 @@ $.Widget.prototype = {
widgetEventPrefix: "",
defaultElement: "<div>",
options: {
- disabled: false
+ disabled: false,
+
+ // callbacks
+ create: null
},
_createWidget: function( options, element ) {
element = $( element || this.defaultElement || this )[ 0 ];