aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/i18n/jquery.ui.datepicker-ar.js13
-rw-r--r--ui/i18n/jquery.ui.datepicker-fr.js22
-rw-r--r--ui/i18n/jquery.ui.datepicker-no.js4
-rw-r--r--ui/i18n/jquery.ui.datepicker-rm.js21
-rw-r--r--ui/i18n/jquery.ui.datepicker-th.js2
-rw-r--r--ui/jquery.effects.blind.js2
-rw-r--r--ui/jquery.effects.bounce.js2
-rw-r--r--ui/jquery.effects.clip.js2
-rw-r--r--ui/jquery.effects.core.js14
-rw-r--r--ui/jquery.effects.drop.js2
-rw-r--r--ui/jquery.effects.fold.js2
-rw-r--r--ui/jquery.effects.scale.js4
-rw-r--r--ui/jquery.effects.shake.js2
-rw-r--r--ui/jquery.effects.slide.js4
-rw-r--r--ui/jquery.ui.accordion.js129
-rw-r--r--ui/jquery.ui.autocomplete.js54
-rw-r--r--ui/jquery.ui.button.js18
-rw-r--r--ui/jquery.ui.core.js7
-rw-r--r--ui/jquery.ui.datepicker.js95
-rw-r--r--ui/jquery.ui.dialog.js582
-rw-r--r--ui/jquery.ui.draggable.js14
-rw-r--r--ui/jquery.ui.mouse.js10
-rw-r--r--ui/jquery.ui.position.js7
-rw-r--r--ui/jquery.ui.progressbar.js27
-rw-r--r--ui/jquery.ui.slider.js10
-rw-r--r--ui/jquery.ui.sortable.js23
-rwxr-xr-x[-rw-r--r--]ui/jquery.ui.tabs.js92
-rw-r--r--ui/jquery.ui.widget.js26
28 files changed, 639 insertions, 551 deletions
diff --git a/ui/i18n/jquery.ui.datepicker-ar.js b/ui/i18n/jquery.ui.datepicker-ar.js
index c799b48d8..9e37911c2 100644
--- a/ui/i18n/jquery.ui.datepicker-ar.js
+++ b/ui/i18n/jquery.ui.datepicker-ar.js
@@ -1,6 +1,5 @@
/* Arabic Translation for jQuery UI date picker plugin. */
-/* Khaled Al Horani -- koko.dw@gmail.com */
-/* خالد الحوراني -- koko.dw@gmail.com */
+/* Khaled Alhourani -- me@khaledalhourani.com */
/* NOTE: monthNames are the original months names and they are the Arabic names, not the new months name فبراير - يناير and there isn't any Arabic roots for these months */
jQuery(function($){
$.datepicker.regional['ar'] = {
@@ -10,13 +9,13 @@ jQuery(function($){
currentText: 'اليوم',
monthNames: ['كانون الثاني', 'شباط', 'آذار', 'نيسان', 'آذار', 'حزيران',
'تموز', 'آب', 'أيلول', 'تشرين الأول', 'تشرين الثاني', 'كانون الأول'],
- monthNamesShort: ['1','2','3','4','5','6','7','8','9','10','11','12'],
- dayNames: ['السبت', 'الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة'],
- dayNamesShort: ['سبت', 'أحد', 'اثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة'],
- dayNamesMin: ['سبت', 'أحد', 'اثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة'],
+ monthNamesShort: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'],
+ dayNames: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
+ dayNamesShort: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
+ dayNamesMin: ['الأحد', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'],
weekHeader: 'أسبوع',
dateFormat: 'dd/mm/yy',
- firstDay: 0,
+ firstDay: 6,
isRTL: true,
showMonthAfterYear: false,
yearSuffix: ''};
diff --git a/ui/i18n/jquery.ui.datepicker-fr.js b/ui/i18n/jquery.ui.datepicker-fr.js
index 134bda65d..74ea1c231 100644
--- a/ui/i18n/jquery.ui.datepicker-fr.js
+++ b/ui/i18n/jquery.ui.datepicker-fr.js
@@ -1,23 +1,25 @@
/* French initialisation for the jQuery UI date picker plugin. */
-/* Written by Keith Wood (kbwood{at}iinet.com.au) and Stéphane Nahmani (sholby@sholby.net). */
+/* Written by Keith Wood (kbwood{at}iinet.com.au),
+ Stéphane Nahmani (sholby@sholby.net),
+ Stéphane Raimbault <stephane.raimbault@gmail.com> */
jQuery(function($){
$.datepicker.regional['fr'] = {
closeText: 'Fermer',
- prevText: '&#x3c;Préc',
- nextText: 'Suiv&#x3e;',
- currentText: 'Courant',
+ prevText: 'Précédent',
+ nextText: 'Suivant',
+ currentText: 'Aujourd\'hui',
monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin',
'Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
- monthNamesShort: ['Jan','Fév','Mar','Avr','Mai','Jun',
- 'Jul','Aoû','Sep','Oct','Nov','Déc'],
+ monthNamesShort: ['Janv.','Févr.','Mars','Avril','Mai','Juin',
+ 'Juil.','Août','Sept.','Oct.','Nov.','Déc.'],
dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
- dayNamesShort: ['Dim','Lun','Mar','Mer','Jeu','Ven','Sam'],
- dayNamesMin: ['Di','Lu','Ma','Me','Je','Ve','Sa'],
- weekHeader: 'Sm',
+ dayNamesShort: ['Dim.','Lun.','Mar.','Mer.','Jeu.','Ven.','Sam.'],
+ dayNamesMin: ['D','L','M','M','J','V','S'],
+ weekHeader: 'Sem.',
dateFormat: 'dd/mm/yy',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
$.datepicker.setDefaults($.datepicker.regional['fr']);
-}); \ No newline at end of file
+});
diff --git a/ui/i18n/jquery.ui.datepicker-no.js b/ui/i18n/jquery.ui.datepicker-no.js
index 12b2356bf..6b3a498be 100644
--- a/ui/i18n/jquery.ui.datepicker-no.js
+++ b/ui/i18n/jquery.ui.datepicker-no.js
@@ -14,8 +14,8 @@ jQuery(function($){
dayNames: ['Søndag','Mandag','Tirsdag','Onsdag','Torsdag','Fredag','Lørdag'],
dayNamesMin: ['Sø','Ma','Ti','On','To','Fr','Lø'],
weekHeader: 'Uke',
- dateFormat: 'yy-mm-dd',
- firstDay: 0,
+ dateFormat: 'dd.mm.yy',
+ firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: ''};
diff --git a/ui/i18n/jquery.ui.datepicker-rm.js b/ui/i18n/jquery.ui.datepicker-rm.js
new file mode 100644
index 000000000..cf03cd4c1
--- /dev/null
+++ b/ui/i18n/jquery.ui.datepicker-rm.js
@@ -0,0 +1,21 @@
+/* Romansh initialisation for the jQuery UI date picker plugin. */
+/* Written by Yvonne Gienal (yvonne.gienal@educa.ch). */
+jQuery(function($){
+ $.datepicker.regional['rm'] = {
+ closeText: 'Serrar',
+ prevText: '&#x3c;Suandant',
+ nextText: 'Precedent&#x3e;',
+ currentText: 'Actual',
+ monthNames: ['Schaner','Favrer','Mars','Avrigl','Matg','Zercladur', 'Fanadur','Avust','Settember','October','November','December'],
+ monthNamesShort: ['Scha','Fev','Mar','Avr','Matg','Zer', 'Fan','Avu','Sett','Oct','Nov','Dec'],
+ dayNames: ['Dumengia','Glindesdi','Mardi','Mesemna','Gievgia','Venderdi','Sonda'],
+ dayNamesShort: ['Dum','Gli','Mar','Mes','Gie','Ven','Som'],
+ dayNamesMin: ['Du','Gl','Ma','Me','Gi','Ve','So'],
+ weekHeader: 'emna',
+ dateFormat: 'dd/mm/yy',
+ firstDay: 1,
+ isRTL: false,
+ showMonthAfterYear: false,
+ yearSuffix: ''};
+ $.datepicker.setDefaults($.datepicker.regional['rm']);
+});
diff --git a/ui/i18n/jquery.ui.datepicker-th.js b/ui/i18n/jquery.ui.datepicker-th.js
index 978500ab1..c090c6b81 100644
--- a/ui/i18n/jquery.ui.datepicker-th.js
+++ b/ui/i18n/jquery.ui.datepicker-th.js
@@ -7,7 +7,7 @@ jQuery(function($){
nextText: 'ถัดไป&nbsp;&raquo;',
currentText: 'วันนี้',
monthNames: ['มกราคม','กุมภาพันธ์','มีนาคม','เมษายน','พฤษภาคม','มิถุนายน',
- 'กรกฏาคม','สิงหาคม','กันยายน','ตุลาคม','พฤศจิกายน','ธันวาคม'],
+ 'กรกฎาคม','สิงหาคม','กันยายน','ตุลาคม','พฤศจิกายน','ธันวาคม'],
monthNamesShort: ['ม.ค.','ก.พ.','มี.ค.','เม.ย.','พ.ค.','มิ.ย.',
'ก.ค.','ส.ค.','ก.ย.','ต.ค.','พ.ย.','ธ.ค.'],
dayNames: ['อาทิตย์','จันทร์','อังคาร','พุธ','พฤหัสบดี','ศุกร์','เสาร์'],
diff --git a/ui/jquery.effects.blind.js b/ui/jquery.effects.blind.js
index 9dc7067a9..44f398a55 100644
--- a/ui/jquery.effects.blind.js
+++ b/ui/jquery.effects.blind.js
@@ -17,7 +17,7 @@ $.effects.blind = function(o) {
return this.queue(function() {
// Create element
- var el = $(this), props = ['position','top','left'];
+ var el = $(this), props = ['position','top','bottom','left','right'];
// Set options
var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
diff --git a/ui/jquery.effects.bounce.js b/ui/jquery.effects.bounce.js
index b307d4f53..ec4a77ec4 100644
--- a/ui/jquery.effects.bounce.js
+++ b/ui/jquery.effects.bounce.js
@@ -17,7 +17,7 @@ $.effects.bounce = function(o) {
return this.queue(function() {
// Create element
- var el = $(this), props = ['position','top','left'];
+ var el = $(this), props = ['position','top','bottom','left','right'];
// Set options
var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
diff --git a/ui/jquery.effects.clip.js b/ui/jquery.effects.clip.js
index c859205b4..9fa8df94a 100644
--- a/ui/jquery.effects.clip.js
+++ b/ui/jquery.effects.clip.js
@@ -17,7 +17,7 @@ $.effects.clip = function(o) {
return this.queue(function() {
// Create element
- var el = $(this), props = ['position','top','left','height','width'];
+ var el = $(this), props = ['position','top','bottom','left','right','height','width'];
// Set options
var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
diff --git a/ui/jquery.effects.core.js b/ui/jquery.effects.core.js
index 49ab4e220..bb88dcf19 100644
--- a/ui/jquery.effects.core.js
+++ b/ui/jquery.effects.core.js
@@ -231,8 +231,7 @@ $.effects.animateClass = function(value, duration, easing, callback) {
easing = null;
}
- return this.each(function() {
-
+ return this.queue('fx', function() {
var that = $(this),
originalStyleAttr = that.attr('style') || ' ',
originalStyle = filterStyles(getElementStyles.call(this)),
@@ -260,6 +259,13 @@ $.effects.animateClass = function(value, duration, easing, callback) {
}
if (callback) { callback.apply(this, arguments); }
});
+
+ // $.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);
});
};
@@ -382,7 +388,7 @@ $.extend($.effects, {
props[pos] = 'auto';
}
});
- element.css({position: 'relative', top: 0, left: 0 });
+ element.css({position: 'relative', top: 0, left: 0, right: 'auto', bottom: 'auto' });
}
return wrapper.css(props).show();
@@ -432,7 +438,7 @@ function _normalizeArguments(effect, options, speed, callback) {
speed = speed || options.duration;
speed = $.fx.off ? 0 : typeof speed == 'number'
- ? speed : $.fx.speeds[speed] || $.fx.speeds._default;
+ ? speed : speed in $.fx.speeds ? $.fx.speeds[speed] : $.fx.speeds._default;
callback = callback || options.complete;
diff --git a/ui/jquery.effects.drop.js b/ui/jquery.effects.drop.js
index 11f501fc4..941508b2e 100644
--- a/ui/jquery.effects.drop.js
+++ b/ui/jquery.effects.drop.js
@@ -17,7 +17,7 @@ $.effects.drop = function(o) {
return this.queue(function() {
// Create element
- var el = $(this), props = ['position','top','left','opacity'];
+ var el = $(this), props = ['position','top','bottom','left','right','opacity'];
// Set options
var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
diff --git a/ui/jquery.effects.fold.js b/ui/jquery.effects.fold.js
index c9b7b698d..f19ae1bf2 100644
--- a/ui/jquery.effects.fold.js
+++ b/ui/jquery.effects.fold.js
@@ -17,7 +17,7 @@ $.effects.fold = function(o) {
return this.queue(function() {
// Create element
- var el = $(this), props = ['position','top','left'];
+ var el = $(this), props = ['position','top','bottom','left','right'];
// Set options
var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js
index edbffb7c9..d980882db 100644
--- a/ui/jquery.effects.scale.js
+++ b/ui/jquery.effects.scale.js
@@ -84,8 +84,8 @@ $.effects.size = function(o) {
return this.queue(function() {
// Create element
- var el = $(this), props = ['position','top','left','width','height','overflow','opacity'];
- var props1 = ['position','top','left','overflow','opacity']; // Always restore
+ var el = $(this), props = ['position','top','bottom','left','right','width','height','overflow','opacity'];
+ var props1 = ['position','top','bottom','left','right','overflow','opacity']; // Always restore
var props2 = ['width','height','overflow']; // Copy for children
var cProps = ['fontSize'];
var vProps = ['borderTopWidth', 'borderBottomWidth', 'paddingTop', 'paddingBottom'];
diff --git a/ui/jquery.effects.shake.js b/ui/jquery.effects.shake.js
index 763789159..b94e5a5ab 100644
--- a/ui/jquery.effects.shake.js
+++ b/ui/jquery.effects.shake.js
@@ -17,7 +17,7 @@ $.effects.shake = function(o) {
return this.queue(function() {
// Create element
- var el = $(this), props = ['position','top','left'];
+ var el = $(this), props = ['position','top','bottom','left','right'];
// Set options
var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
diff --git a/ui/jquery.effects.slide.js b/ui/jquery.effects.slide.js
index 5ada8a09a..59f6dc578 100644
--- a/ui/jquery.effects.slide.js
+++ b/ui/jquery.effects.slide.js
@@ -17,7 +17,7 @@ $.effects.slide = function(o) {
return this.queue(function() {
// Create element
- var el = $(this), props = ['position','top','left'];
+ var el = $(this), props = ['position','top','bottom','left','right'];
// Set options
var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
@@ -29,7 +29,7 @@ $.effects.slide = function(o) {
var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) : el.outerWidth({margin:true}));
- if (mode == 'show') el.css(ref, motion == 'pos' ? -distance : distance); // Shift
+ if (mode == 'show') el.css(ref, motion == 'pos' ? (isNaN(distance) ? "-" + distance : -distance) : distance); // Shift
// Animation
var animation = {};
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js
index 96a69d4f3..955030ccc 100644
--- a/ui/jquery.ui.accordion.js
+++ b/ui/jquery.ui.accordion.js
@@ -17,19 +17,14 @@ $.widget( "ui.accordion", {
options: {
active: 0,
animated: "slide",
- autoHeight: true,
- clearStyle: false,
collapsible: false,
event: "click",
- fillSpace: false,
header: "> li > :first-child,> :not(li):even",
+ // TODO: set to "auto" in 2.0 (#5868, #5872)
+ heightStyle: null, // "auto"
icons: {
header: "ui-icon-triangle-1-e",
headerSelected: "ui-icon-triangle-1-s"
- },
- navigation: false,
- navigationFilter: function() {
- return this.href.toLowerCase() === location.href.toLowerCase();
}
},
@@ -75,20 +70,7 @@ $.widget( "ui.accordion", {
self.headers.next()
.addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" );
-
- if ( options.navigation ) {
- var current = self.element.find( "a" ).filter( options.navigationFilter ).eq( 0 );
- if ( current.length ) {
- var header = current.closest( ".ui-accordion-header" );
- if ( header.length ) {
- // anchor within header
- self.active = header;
- } else {
- // anchor within content
- self.active = current.closest( ".ui-accordion-content" ).prev();
- }
- }
- }
+ self.headers.find( ":first-child" ).addClass( "ui-accordion-heading" );
self.active = self._findActive( self.active || options.active )
.addClass( "ui-state-default ui-state-active" )
@@ -177,11 +159,12 @@ $.widget( "ui.accordion", {
this.headers.find( "a" ).removeAttr( "tabIndex" );
this._destroyIcons();
+ this.headers.find( "a:first-child" ).removeClass( "ui-accordion-heading" );
var contents = this.headers.next()
.css( "display", "" )
.removeAttr( "role" )
.removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled" );
- if ( options.autoHeight || options.fillHeight ) {
+ if ( options.heightStyle !== "content" ) {
contents.css( "height", "" );
}
@@ -190,7 +173,7 @@ $.widget( "ui.accordion", {
_setOption: function( key, value ) {
$.Widget.prototype._setOption.apply( this, arguments );
-
+
if ( key == "active" ) {
this.activate( value );
}
@@ -204,8 +187,7 @@ $.widget( "ui.accordion", {
// so we need to add the disabled class to the headers and panels
if ( key == "disabled" ) {
this.headers.add(this.headers.next())
- [ value ? "addClass" : "removeClass" ](
- "ui-accordion-disabled ui-state-disabled" );
+ .toggleClass( "ui-accordion-disabled ui-state-disabled", !!value );
}
},
@@ -248,12 +230,21 @@ $.widget( "ui.accordion", {
var options = this.options,
maxHeight;
- if ( options.fillSpace ) {
+ if ( options.heightStyle === "fill" ) {
if ( $.browser.msie ) {
var defOverflow = this.element.parent().css( "overflow" );
this.element.parent().css( "overflow", "hidden");
}
maxHeight = this.element.parent().height();
+ this.element.siblings( ":visible" ).each(function() {
+ var elem = $( this ),
+ position = elem.css( "position" );
+
+ if ( position === "absolute" || position === "fixed" ) {
+ return;
+ }
+ maxHeight -= elem.outerHeight( true );
+ });
if ($.browser.msie) {
this.element.parent().css( "overflow", defOverflow );
}
@@ -268,7 +259,7 @@ $.widget( "ui.accordion", {
$( this ).innerHeight() + $( this ).height() ) );
})
.css( "overflow", "auto" );
- } else if ( options.autoHeight ) {
+ } else if ( options.heightStyle === "auto" ) {
maxHeight = 0;
this.headers.next()
.each(function() {
@@ -414,7 +405,7 @@ $.widget( "ui.accordion", {
toHide: toHide,
complete: complete,
down: down,
- autoHeight: options.autoHeight || options.fillSpace
+ autoHeight: options.heightStyle !== "content"
};
} else {
animOptions = {
@@ -422,7 +413,7 @@ $.widget( "ui.accordion", {
toHide: toHide,
complete: complete,
down: down,
- autoHeight: options.autoHeight || options.fillSpace
+ autoHeight: options.heightStyle !== "content"
};
}
@@ -491,7 +482,7 @@ $.widget( "ui.accordion", {
return;
}
- if ( this.options.clearStyle ) {
+ if ( this.options.heightStyle === "content" ) {
this.toShow.add( this.toHide ).css({
height: "",
overflow: ""
@@ -596,4 +587,82 @@ $.extend( $.ui.accordion, {
}
});
+
+
+// DEPRECATED
+
+// navigation options
+(function( $, prototype ) {
+ $.extend( prototype.options, {
+ navigation: false,
+ navigationFilter: function() {
+ return this.href.toLowerCase() === location.href.toLowerCase();
+ }
+ });
+
+ var _create = prototype._create;
+ prototype._create = function() {
+ if ( this.options.navigation ) {
+ var self = this,
+ headers = this.element.find( this.options.header ),
+ content = headers.next();
+ current = headers.add( content )
+ .find( "a" )
+ .filter( this.options.navigationFilter )
+ [ 0 ];
+ if ( current ) {
+ headers.add( content ).each( function( index ) {
+ if ( $.contains( this, current ) ) {
+ self.options.active = Math.floor( index / 2 );
+ return false;
+ }
+ });
+ }
+ }
+ _create.call( this );
+ };
+}( jQuery, jQuery.ui.accordion.prototype ) );
+
+(function( $, prototype ) {
+ $.extend( prototype.options, {
+ autoHeight: true, // use heightStyle: "auto"
+ clearStyle: false, // use heightStyle: "content"
+ fillSpace: false // use heightStyle: "fill"
+ });
+
+ var _create = prototype._create,
+ _setOption = prototype._setOption;
+
+ $.extend( prototype, {
+ _create: function() {
+ this.options.heightStyle = this.options.heightStyle ||
+ this._mergeHeightStyle();
+ _create.call( this );
+ },
+
+ _setOption: function( key, value ) {
+ if ( key === "autoHeight" || key === "clearStyle" || key === "fillSpace" ) {
+ this.options.heightStyle = this._mergeHeightStyle();
+ }
+ _setOption.apply( this, arguments );
+ },
+
+ _mergeHeightStyle: function() {
+ var options = this.options;
+
+ if ( options.fillSpace ) {
+ return "fill";
+ }
+
+ if ( options.clearStyle ) {
+ return "content";
+ }
+
+ if ( options.autoHeight ) {
+ return "auto";
+ }
+ }
+ });
+}( jQuery, jQuery.ui.accordion.prototype ) );
+
})( jQuery );
diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js
index 427ad1a5a..73d50ee6e 100644
--- a/ui/jquery.ui.autocomplete.js
+++ b/ui/jquery.ui.autocomplete.js
@@ -26,6 +26,9 @@ $.widget( "ui.autocomplete", {
},
source: null
},
+
+ pending: 0,
+
_create: function() {
var self = this,
doc = this.element[ 0 ].ownerDocument,
@@ -142,7 +145,7 @@ $.widget( "ui.autocomplete", {
$( document ).one( 'mousedown', function( event ) {
if ( event.target !== self.element[ 0 ] &&
event.target !== menuElement &&
- !$.ui.contains( menuElement, event.target ) ) {
+ !$.contains( menuElement, event.target ) ) {
self.close();
}
});
@@ -177,13 +180,16 @@ $.widget( "ui.autocomplete", {
// term synchronously and asynchronously :-(
setTimeout(function() {
self.previous = previous;
+ self.selectedItem = item;
}, 1);
}
if ( false !== self._trigger( "select", event, { item: item } ) ) {
- self.term = item.value;
self.element.val( item.value );
}
+ // reset the term after the select event
+ // this allows custom select handling to work properly
+ self.term = self.element.val();
self.close( event );
self.selectedItem = item;
@@ -198,8 +204,6 @@ $.widget( "ui.autocomplete", {
}
})
.zIndex( this.element.zIndex() + 1 )
- // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
- .css({ top: 0, left: 0 })
.hide()
.data( "menu" );
if ( $.fn.bgiframe ) {
@@ -226,6 +230,9 @@ $.widget( "ui.autocomplete", {
if ( key === "appendTo" ) {
this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] )
}
+ if ( key === "disabled" && value && this.xhr ) {
+ this.xhr.abort();
+ }
},
_initSource: function() {
@@ -240,14 +247,25 @@ $.widget( "ui.autocomplete", {
} else if ( typeof this.options.source === "string" ) {
url = this.options.source;
this.source = function( request, response ) {
- if (self.xhr) {
+ if ( self.xhr ) {
self.xhr.abort();
}
- self.xhr = $.getJSON( url, request, function( data, status, xhr ) {
- if ( xhr === self.xhr ) {
- response( data );
+ self.xhr = $.ajax({
+ url: url,
+ data: request,
+ dataType: "json",
+ success: function( data, status, xhr ) {
+ if ( xhr === self.xhr ) {
+ response( data );
+ }
+ self.xhr = null;
+ },
+ error: function( xhr ) {
+ if ( xhr === self.xhr ) {
+ response( [] );
+ }
+ self.xhr = null;
}
- self.xhr = null;
});
};
} else {
@@ -274,28 +292,32 @@ $.widget( "ui.autocomplete", {
},
_search: function( value ) {
+ this.pending++;
this.element.addClass( "ui-autocomplete-loading" );
this.source( { term: value }, this.response );
},
_response: function( content ) {
- if ( content && content.length ) {
+ if ( !this.options.disabled && content && content.length ) {
content = this._normalize( content );
this._suggest( content );
this._trigger( "open" );
} else {
this.close();
}
- this.element.removeClass( "ui-autocomplete-loading" );
+ this.pending--;
+ if ( !this.pending ) {
+ this.element.removeClass( "ui-autocomplete-loading" );
+ }
},
close: function( event ) {
clearTimeout( this.closing );
if ( this.menu.element.is(":visible") ) {
- this._trigger( "close", event );
this.menu.element.hide();
this.menu.deactivate();
+ this._trigger( "close", event );
}
},
@@ -332,11 +354,13 @@ $.widget( "ui.autocomplete", {
// TODO refresh should check if the active item is still in the dom, removing the need for a manual deactivate
this.menu.deactivate();
this.menu.refresh();
- this.menu.element.show().position( $.extend({
- of: this.element
- }, this.options.position ));
+ // size and position menu
+ ul.show();
this._resizeMenu();
+ ul.position( $.extend({
+ of: this.element
+ }, this.options.position ));
},
_resizeMenu: function() {
diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js
index 912e45273..78134e308 100644
--- a/ui/jquery.ui.button.js
+++ b/ui/jquery.ui.button.js
@@ -315,6 +315,10 @@ $.widget( "ui.button", {
});
$.widget( "ui.buttonset", {
+ options: {
+ items: ":button, :submit, :reset, :checkbox, :radio, a, :data(button)"
+ },
+
_create: function() {
this.element.addClass( "ui-buttonset" );
},
@@ -332,7 +336,7 @@ $.widget( "ui.buttonset", {
},
refresh: function() {
- this.buttons = this.element.find( ":button, :submit, :reset, :checkbox, :radio, a, :data(button)" )
+ this.buttons = this.element.find( this.options.items )
.filter( ":ui-button" )
.button( "refresh" )
.end()
@@ -343,13 +347,11 @@ $.widget( "ui.buttonset", {
return $( this ).button( "widget" )[ 0 ];
})
.removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
- .filter( ":visible" )
- .filter( ":first" )
- .addClass( "ui-corner-left" )
- .end()
- .filter( ":last" )
- .addClass( "ui-corner-right" )
- .end()
+ .filter( ":first" )
+ .addClass( "ui-corner-left" )
+ .end()
+ .filter( ":last" )
+ .addClass( "ui-corner-right" )
.end()
.end();
},
diff --git a/ui/jquery.ui.core.js b/ui/jquery.ui.core.js
index bda679554..d41654b29 100644
--- a/ui/jquery.ui.core.js
+++ b/ui/jquery.ui.core.js
@@ -263,12 +263,7 @@ $.extend( $.ui, {
}
},
- // will be deprecated when we switch to jQuery 1.4 - use jQuery.contains()
- contains: function( a, b ) {
- return document.compareDocumentPosition ?
- a.compareDocumentPosition( b ) & 16 :
- a !== b && a.contains( b );
- },
+ contains: $.contains,
// only used by resizable
hasScroll: function( el, a ) {
diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js
index 678129e49..abcb37067 100644
--- a/ui/jquery.ui.datepicker.js
+++ b/ui/jquery.ui.datepicker.js
@@ -107,7 +107,7 @@ function Datepicker() {
autoSize: false // True to size the input for the date format, false to leave as is
};
$.extend(this._defaults, this.regional['']);
- this.dpDiv = $('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible"></div>');
+ this.dpDiv = $('<div id="' + this._mainDivId + '" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>');
}
$.extend(Datepicker.prototype, {
@@ -272,6 +272,7 @@ $.extend(Datepicker.prototype, {
this._setDate(inst, this._getDefaultDate(inst), true);
this._updateDatepicker(inst);
this._updateAlternate(inst);
+ inst.dpDiv.show();
},
/* Pop-up the date picker in a "dialog" box.
@@ -499,8 +500,8 @@ $.extend(Datepicker.prototype, {
case 9: $.datepicker._hideDatepicker();
handled = false;
break; // hide on tab out
- case 13: var sel = $('td.' + $.datepicker._dayOverClass, inst.dpDiv).
- add($('td.' + $.datepicker._currentClass, inst.dpDiv));
+ case 13: var sel = $('td.' + $.datepicker._dayOverClass + ':not(.' +
+ $.datepicker._currentClass + ')', inst.dpDiv);
if (sel[0])
$.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
else
@@ -564,7 +565,7 @@ $.extend(Datepicker.prototype, {
if ($.datepicker._get(inst, 'constrainInput')) {
var chars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat'));
var chr = String.fromCharCode(event.charCode == undefined ? event.keyCode : event.charCode);
- return event.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
+ return event.ctrlKey || event.metaKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1);
}
},
@@ -624,6 +625,8 @@ $.extend(Datepicker.prototype, {
}
var offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
$.datepicker._pos = null;
+ //to avoid flashes on Firefox
+ inst.dpDiv.empty();
// determine sizing offscreen
inst.dpDiv.css({position: 'absolute', display: 'block', top: '-1000px'});
$.datepicker._updateDatepicker(inst);
@@ -638,10 +641,12 @@ $.extend(Datepicker.prototype, {
var duration = $.datepicker._get(inst, 'duration');
var postProcess = function() {
$.datepicker._datepickerShowing = true;
- var borders = $.datepicker._getBorders(inst.dpDiv);
- inst.dpDiv.find('iframe.ui-datepicker-cover'). // IE6- only
- css({left: -borders[0], top: -borders[1],
+ var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
+ if( !! cover.length ){
+ var borders = $.datepicker._getBorders(inst.dpDiv);
+ cover.css({left: -borders[0], top: -borders[1],
width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()});
+ }
};
inst.dpDiv.zIndex($(input).zIndex()+1);
if ($.effects && $.effects[showAnim])
@@ -660,12 +665,12 @@ $.extend(Datepicker.prototype, {
_updateDatepicker: function(inst) {
var self = this;
var borders = $.datepicker._getBorders(inst.dpDiv);
- inst.dpDiv.empty().append(this._generateHTML(inst))
- .find('iframe.ui-datepicker-cover') // IE6- only
- .css({left: -borders[0], top: -borders[1],
- width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()})
- .end()
- .find('button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a')
+ inst.dpDiv.empty().append(this._generateHTML(inst));
+ var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only
+ if( !!cover.length ){ //avoid call to outerXXXX() when not in IE6
+ cover.css({left: -borders[0], top: -borders[1], width: inst.dpDiv.outerWidth(), height: inst.dpDiv.outerHeight()})
+ }
+ inst.dpDiv.find('button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a')
.bind('mouseout', function(){
$(this).removeClass('ui-state-hover');
if(this.className.indexOf('ui-datepicker-prev') != -1) $(this).removeClass('ui-datepicker-prev-hover');
@@ -697,6 +702,17 @@ $.extend(Datepicker.prototype, {
if (inst == $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
inst.input.is(':visible') && !inst.input.is(':disabled'))
inst.input.focus();
+ // deffered render of the years select (to avoid flashes on Firefox)
+ if( inst.yearshtml ){
+ var origyearshtml = inst.yearshtml;
+ setTimeout(function(){
+ //assure that inst.yearshtml didn't change.
+ if( origyearshtml === inst.yearshtml ){
+ inst.dpDiv.find('select.ui-datepicker-year:first').replaceWith(inst.yearshtml);
+ }
+ origyearshtml = inst.yearshtml = null;
+ }, 0);
+ }
},
/* Retrieve the size of left and top borders for an element.
@@ -968,9 +984,9 @@ $.extend(Datepicker.prototype, {
};
// Extract a number from the string value
var getNumber = function(match) {
- lookAhead(match);
+ var isDoubled = lookAhead(match);
var size = (match == '@' ? 14 : (match == '!' ? 20 :
- (match == 'y' ? 4 : (match == 'o' ? 3 : 2))));
+ (match == 'y' && isDoubled ? 4 : (match == 'o' ? 3 : 2))));
var digits = new RegExp('^\\d{1,' + size + '}');
var num = value.substring(iValue).match(digits);
if (!num)
@@ -1300,16 +1316,16 @@ $.extend(Datepicker.prototype, {
}
return new Date(year, month, day);
};
- date = (date == null ? defaultDate : (typeof date == 'string' ? offsetString(date) :
- (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : date)));
- date = (date && date.toString() == 'Invalid Date' ? defaultDate : date);
- if (date) {
- date.setHours(0);
- date.setMinutes(0);
- date.setSeconds(0);
- date.setMilliseconds(0);
+ var newDate = (date == null || date === '' ? defaultDate : (typeof date == 'string' ? offsetString(date) :
+ (typeof date == 'number' ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
+ newDate = (newDate && newDate.toString() == 'Invalid Date' ? defaultDate : newDate);
+ if (newDate) {
+ newDate.setHours(0);
+ newDate.setMinutes(0);
+ newDate.setSeconds(0);
+ newDate.setMilliseconds(0);
}
- return this._daylightSavingAdjust(date);
+ return this._daylightSavingAdjust(newDate);
},
/* Handle switch to/from daylight saving.
@@ -1326,13 +1342,13 @@ $.extend(Datepicker.prototype, {
/* Set the date(s) directly. */
_setDate: function(inst, date, noChange) {
- var clear = !(date);
+ var clear = !date;
var origMonth = inst.selectedMonth;
var origYear = inst.selectedYear;
- date = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
- inst.selectedDay = inst.currentDay = date.getDate();
- inst.drawMonth = inst.selectedMonth = inst.currentMonth = date.getMonth();
- inst.drawYear = inst.selectedYear = inst.currentYear = date.getFullYear();
+ var newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
+ inst.selectedDay = inst.currentDay = newDate.getDate();
+ inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
+ inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
if ((origMonth != inst.selectedMonth || origYear != inst.selectedYear) && !noChange)
this._notifyChange(inst);
this._adjustInstDate(inst);
@@ -1548,6 +1564,7 @@ $.extend(Datepicker.prototype, {
if (!showMonthAfterYear)
html += monthHtml + (secondary || !(changeMonth && changeYear) ? '&#xa0;' : '');
// year selection
+ inst.yearshtml = '';
if (secondary || !changeYear)
html += '<span class="ui-datepicker-year">' + drawYear + '</span>';
else {
@@ -1564,16 +1581,24 @@ $.extend(Datepicker.prototype, {
var endYear = Math.max(year, determineYear(years[1] || ''));
year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
- html += '<select class="ui-datepicker-year" ' +
+ inst.yearshtml += '<select class="ui-datepicker-year" ' +
'onchange="DP_jQuery_' + dpuuid + '.datepicker._selectMonthYear(\'#' + inst.id + '\', this, \'Y\');" ' +
'onclick="DP_jQuery_' + dpuuid + '.datepicker._clickMonthYear(\'#' + inst.id + '\');"' +
'>';
for (; year <= endYear; year++) {
- html += '<option value="' + year + '"' +
+ inst.yearshtml += '<option value="' + year + '"' +
(year == drawYear ? ' selected="selected"' : '') +
'>' + year + '</option>';
}
- html += '</select>';
+ inst.yearshtml += '</select>';
+ //when showing there is no need for later update
+ if( ! $.browser.mozilla ){
+ html += inst.yearshtml;
+ inst.yearshtml = null;
+ } else {
+ // will be replaced later with inst.yearshtml
+ html += '<select class="ui-datepicker-year"><option value="' + drawYear + '" selected="selected">' + drawYear + '</option></select>';
+ }
}
html += this._get(inst, 'yearSuffix');
if (showMonthAfterYear)
@@ -1601,9 +1626,9 @@ $.extend(Datepicker.prototype, {
_restrictMinMax: function(inst, date) {
var minDate = this._getMinMaxDate(inst, 'min');
var maxDate = this._getMinMaxDate(inst, 'max');
- date = (minDate && date < minDate ? minDate : date);
- date = (maxDate && date > maxDate ? maxDate : date);
- return date;
+ var newDate = (minDate && date < minDate ? minDate : date);
+ newDate = (maxDate && newDate > maxDate ? maxDate : newDate);
+ return newDate;
},
/* Notify change of month/year. */
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js
index 3d38df4c0..501772eb5 100644
--- a/ui/jquery.ui.dialog.js
+++ b/ui/jquery.ui.dialog.js
@@ -18,11 +18,7 @@
*/
(function( $, undefined ) {
-var uiDialogClasses =
- 'ui-dialog ' +
- 'ui-widget ' +
- 'ui-widget-content ' +
- 'ui-corner-all ',
+var uiDialogClasses = "ui-dialog ui-widget ui-widget-content ui-corner-all ",
sizeRelatedOptions = {
buttons: true,
height: true,
@@ -44,39 +40,39 @@ $.widget("ui.dialog", {
autoOpen: true,
buttons: {},
closeOnEscape: true,
- closeText: 'close',
- dialogClass: '',
+ closeText: "close",
+ dialogClass: "",
draggable: true,
hide: null,
- height: 'auto',
+ height: "auto",
maxHeight: false,
maxWidth: false,
minHeight: 150,
minWidth: 150,
modal: false,
position: {
- my: 'center',
- at: 'center',
+ my: "center",
+ at: "center",
of: window,
- collision: 'fit',
+ collision: "fit",
// ensure that the titlebar is never outside the document
- using: function(pos) {
- var topOffset = $(this).css(pos).offset().top;
- if (topOffset < 0) {
- $(this).css('top', pos.top - topOffset);
+ using: function( pos ) {
+ var topOffset = $( this ).css( pos ).offset().top;
+ if ( topOffset < 0 ) {
+ $( this ).css( "top", pos.top - topOffset );
}
}
},
resizable: true,
show: null,
stack: true,
- title: '',
+ title: "",
width: 300,
zIndex: 1000
},
_create: function() {
- this.originalTitle = this.element.attr('title');
+ this.originalTitle = this.element.attr( "title" );
// #5742 - .attr() might return a DOMElement
if ( typeof this.originalTitle !== "string" ) {
this.originalTitle = "";
@@ -86,111 +82,93 @@ $.widget("ui.dialog", {
var self = this,
options = self.options,
- title = options.title || '&#160;',
- titleId = $.ui.dialog.getTitleId(self.element),
+ title = options.title || "&#160;",
+ titleId = $.ui.dialog.getTitleId( self.element ),
- uiDialog = (self.uiDialog = $('<div></div>'))
- .appendTo(document.body)
+ uiDialog = ( self.uiDialog = $( "<div>" ) )
+ .appendTo( document.body )
.hide()
- .addClass(uiDialogClasses + options.dialogClass)
+ .addClass( uiDialogClasses + options.dialogClass )
.css({
zIndex: options.zIndex
})
// setting tabIndex makes the div focusable
- // setting outline to 0 prevents a border on focus in Mozilla
- .attr('tabIndex', -1).css('outline', 0).keydown(function(event) {
- if (options.closeOnEscape && event.keyCode &&
- event.keyCode === $.ui.keyCode.ESCAPE) {
-
- self.close(event);
+ .attr( "tabIndex", -1)
+ // TODO: move to stylesheet
+ .css( "outline", 0 )
+ .keydown(function( event ) {
+ if ( options.closeOnEscape && event.keyCode &&
+ event.keyCode === $.ui.keyCode.ESCAPE ) {
+ self.close( event );
event.preventDefault();
}
})
.attr({
- role: 'dialog',
- 'aria-labelledby': titleId
+ role: "dialog",
+ "aria-labelledby": titleId
})
- .mousedown(function(event) {
- self.moveToTop(false, event);
+ .mousedown(function( event ) {
+ self.moveToTop( false, event );
}),
uiDialogContent = self.element
.show()
- .removeAttr('title')
- .addClass(
- 'ui-dialog-content ' +
- 'ui-widget-content')
- .appendTo(uiDialog),
-
- uiDialogTitlebar = (self.uiDialogTitlebar = $('<div></div>'))
- .addClass(
- 'ui-dialog-titlebar ' +
- 'ui-widget-header ' +
- 'ui-corner-all ' +
- 'ui-helper-clearfix'
- )
- .prependTo(uiDialog),
-
- uiDialogTitlebarClose = $('<a href="#"></a>')
- .addClass(
- 'ui-dialog-titlebar-close ' +
- 'ui-corner-all'
- )
- .attr('role', 'button')
+ .removeAttr( "title" )
+ .addClass( "ui-dialog-content ui-widget-content" )
+ .appendTo( uiDialog ),
+
+ uiDialogTitlebar = ( self.uiDialogTitlebar = $( "<div>" ) )
+ .addClass( "ui-dialog-titlebar ui-widget-header " +
+ "ui-corner-all ui-helper-clearfix" )
+ .prependTo( uiDialog ),
+
+ uiDialogTitlebarClose = $( "<a href='#'>" )
+ .addClass( "ui-dialog-titlebar-close ui-corner-all" )
+ .attr( "role", "button" )
.hover(
function() {
- uiDialogTitlebarClose.addClass('ui-state-hover');
+ uiDialogTitlebarClose.addClass( "ui-state-hover" );
},
function() {
- uiDialogTitlebarClose.removeClass('ui-state-hover');
+ uiDialogTitlebarClose.removeClass( "ui-state-hover" );
}
)
.focus(function() {
- uiDialogTitlebarClose.addClass('ui-state-focus');
+ uiDialogTitlebarClose.addClass( "ui-state-focus" );
})
.blur(function() {
- uiDialogTitlebarClose.removeClass('ui-state-focus');
+ uiDialogTitlebarClose.removeClass( "ui-state-focus" );
})
- .click(function(event) {
- self.close(event);
- return false;
+ .click(function( event ) {
+ event.preventDefault();
+ self.close( event );
})
- .appendTo(uiDialogTitlebar),
+ .appendTo( uiDialogTitlebar ),
- uiDialogTitlebarCloseText = (self.uiDialogTitlebarCloseText = $('<span></span>'))
- .addClass(
- 'ui-icon ' +
- 'ui-icon-closethick'
- )
- .text(options.closeText)
- .appendTo(uiDialogTitlebarClose),
-
- uiDialogTitle = $('<span></span>')
- .addClass('ui-dialog-title')
- .attr('id', titleId)
- .html(title)
- .prependTo(uiDialogTitlebar);
+ uiDialogTitlebarCloseText = ( self.uiDialogTitlebarCloseText = $( "<span>" ) )
+ .addClass( "ui-icon ui-icon-closethick" )
+ .text( options.closeText )
+ .appendTo( uiDialogTitlebarClose ),
- //handling of deprecated beforeclose (vs beforeClose) option
- //Ticket #4669 http://dev.jqueryui.com/ticket/4669
- //TODO: remove in 1.9pre
- if ($.isFunction(options.beforeclose) && !$.isFunction(options.beforeClose)) {
- options.beforeClose = options.beforeclose;
- }
+ uiDialogTitle = $( "<span>" )
+ .addClass( "ui-dialog-title" )
+ .attr( "id", titleId )
+ .html( title )
+ .prependTo( uiDialogTitlebar );
- uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();
+ uiDialogTitlebar.find( "*" ).add( uiDialogTitlebar ).disableSelection();
- if (options.draggable && $.fn.draggable) {
+ if ( options.draggable && $.fn.draggable ) {
self._makeDraggable();
}
- if (options.resizable && $.fn.resizable) {
+ if ( options.resizable && $.fn.resizable ) {
self._makeResizable();
}
- self._createButtons(options.buttons);
+ self._createButtons( options.buttons );
self._isOpen = false;
- if ($.fn.bgiframe) {
+ if ( $.fn.bgiframe ) {
uiDialog.bgiframe();
}
},
@@ -204,21 +182,21 @@ $.widget("ui.dialog", {
destroy: function() {
var self = this;
- if (self.overlay) {
+ if ( self.overlay ) {
self.overlay.destroy();
}
self.uiDialog.hide();
self.element
- .unbind('.dialog')
- .removeData('dialog')
- .removeClass('ui-dialog-content ui-widget-content')
- .hide().appendTo('body');
+ .removeClass( "ui-dialog-content ui-widget-content" )
+ .hide()
+ .appendTo( "body" );
self.uiDialog.remove();
- if (self.originalTitle) {
- self.element.attr('title', self.originalTitle);
+ if ( self.originalTitle ) {
+ self.element.attr( "title", self.originalTitle );
}
+ $.Widget.prototype.destroy.call( this );
return self;
},
@@ -226,38 +204,41 @@ $.widget("ui.dialog", {
return this.uiDialog;
},
- close: function(event) {
+ close: function( event ) {
var self = this,
- maxZ;
+ maxZ, thisZ;
- if (false === self._trigger('beforeClose', event)) {
+ if ( false === self._trigger( "beforeClose", event ) ) {
return;
}
- if (self.overlay) {
+ if ( self.overlay ) {
self.overlay.destroy();
}
- self.uiDialog.unbind('keypress.ui-dialog');
+ self.uiDialog.unbind( "keypress.ui-dialog" );
self._isOpen = false;
- if (self.options.hide) {
- self.uiDialog.hide(self.options.hide, function() {
- self._trigger('close', event);
+ if ( self.options.hide ) {
+ self.uiDialog.hide( self.options.hide, function() {
+ self._trigger( "close", event );
});
} else {
self.uiDialog.hide();
- self._trigger('close', event);
+ self._trigger( "close", event );
}
$.ui.dialog.overlay.resize();
// adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
- if (self.options.modal) {
+ if ( self.options.modal ) {
maxZ = 0;
- $('.ui-dialog').each(function() {
- if (this !== self.uiDialog[0]) {
- maxZ = Math.max(maxZ, $(this).css('z-index'));
+ $( ".ui-dialog" ).each(function() {
+ if ( this !== self.uiDialog[0] ) {
+ thisZ = $( this ).css( "z-index" );
+ if ( !isNaN( thisZ ) ) {
+ maxZ = Math.max( maxZ, thisZ );
+ }
}
});
$.ui.dialog.maxZ = maxZ;
@@ -272,64 +253,71 @@ $.widget("ui.dialog", {
// the force parameter allows us to move modal dialogs to their correct
// position on open
- moveToTop: function(force, event) {
+ moveToTop: function( force, event ) {
var self = this,
options = self.options,
saveScroll;
- if ((options.modal && !force) ||
- (!options.stack && !options.modal)) {
- return self._trigger('focus', event);
+ if ( ( options.modal && !force ) ||
+ ( !options.stack && !options.modal ) ) {
+ return self._trigger( "focus", event );
}
- if (options.zIndex > $.ui.dialog.maxZ) {
+ if ( options.zIndex > $.ui.dialog.maxZ ) {
$.ui.dialog.maxZ = options.zIndex;
}
- if (self.overlay) {
+ if ( self.overlay ) {
$.ui.dialog.maxZ += 1;
- self.overlay.$el.css('z-index', $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ);
+ $.ui.dialog.overlay.maxZ = $.ui.dialog.maxZ;
+ self.overlay.$el.css( "z-index", $.ui.dialog.overlay.maxZ );
}
- //Save and then restore scroll since Opera 9.5+ resets when parent z-Index is changed.
- // http://ui.jquery.com/bugs/ticket/3193
- saveScroll = { scrollTop: self.element.attr('scrollTop'), scrollLeft: self.element.attr('scrollLeft') };
+ // Save and then restore scroll
+ // Opera 9.5+ resets when parent z-index is changed.
+ // http://bugs.jqueryui.com/ticket/3193
+ saveScroll = {
+ scrollTop: self.element.attr( "scrollTop" ),
+ scrollLeft: self.element.attr( "scrollLeft" )
+ };
$.ui.dialog.maxZ += 1;
- self.uiDialog.css('z-index', $.ui.dialog.maxZ);
- self.element.attr(saveScroll);
- self._trigger('focus', event);
+ self.uiDialog.css( "z-index", $.ui.dialog.maxZ );
+ self.element.attr( saveScroll );
+ self._trigger( "focus", event );
return self;
},
open: function() {
- if (this._isOpen) { return; }
+ if ( this._isOpen ) {
+ return;
+ }
var self = this,
options = self.options,
uiDialog = self.uiDialog;
- self.overlay = options.modal ? new $.ui.dialog.overlay(self) : null;
+ self.overlay = options.modal ? new $.ui.dialog.overlay( self ) : null;
self._size();
- self._position(options.position);
- uiDialog.show(options.show);
- self.moveToTop(true);
+ self._position( options.position );
+ uiDialog.show( options.show );
+ self.moveToTop( true );
// prevent tabbing out of modal dialogs
- if (options.modal) {
- uiDialog.bind('keypress.ui-dialog', function(event) {
- if (event.keyCode !== $.ui.keyCode.TAB) {
+ if ( options.modal ) {
+ uiDialog.bind( "keypress.ui-dialog", function( event ) {
+ if ( event.keyCode !== $.ui.keyCode.TAB ) {
return;
}
- var tabbables = $(':tabbable', this),
- first = tabbables.filter(':first'),
- last = tabbables.filter(':last');
+ var tabbables = $( ":tabbable", this ),
+ first = tabbables.filter( ":first" ),
+ last = tabbables.filter( ":last" );
- if (event.target === last[0] && !event.shiftKey) {
- first.focus(1);
+ if ( event.target === last[0] && !event.shiftKey ) {
+ first.focus( 1 );
return false;
- } else if (event.target === first[0] && event.shiftKey) {
- last.focus(1);
+ } else if ( event.target === first[0] && event.shiftKey ) {
+ last.focus( 1 );
return false;
}
});
@@ -337,64 +325,60 @@ $.widget("ui.dialog", {
// set focus to the first tabbable element in the content area or the first button
// if there are no tabbable elements, set focus on the dialog itself
- $(self.element.find(':tabbable').get().concat(
- uiDialog.find('.ui-dialog-buttonpane :tabbable').get().concat(
- uiDialog.get()))).eq(0).focus();
+ $( self.element.find( ":tabbable" ).get().concat(
+ uiDialog.find( ".ui-dialog-buttonpane :tabbable" ).get().concat(
+ uiDialog.get() ) ) ).eq( 0 ).focus();
self._isOpen = true;
- self._trigger('open');
+ self._trigger( "open" );
return self;
},
- _createButtons: function(buttons) {
+ _createButtons: function( buttons ) {
var self = this,
hasButtons = false,
- uiDialogButtonPane = $('<div></div>')
- .addClass(
- 'ui-dialog-buttonpane ' +
- 'ui-widget-content ' +
- 'ui-helper-clearfix'
- ),
- uiButtonSet = $( "<div></div>" )
+ uiDialogButtonPane = $( "<div>" )
+ .addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" ),
+ uiButtonSet = $( "<div>" )
.addClass( "ui-dialog-buttonset" )
.appendTo( uiDialogButtonPane );
// if we already have a button pane, remove it
- self.uiDialog.find('.ui-dialog-buttonpane').remove();
+ self.uiDialog.find( ".ui-dialog-buttonpane" ).remove();
- if (typeof buttons === 'object' && buttons !== null) {
- $.each(buttons, function() {
+ if ( typeof buttons === "object" && buttons !== null ) {
+ $.each( buttons, function() {
return !(hasButtons = true);
});
}
- if (hasButtons) {
- $.each(buttons, function(name, props) {
+ if ( hasButtons ) {
+ $.each( buttons, function( name, props ) {
props = $.isFunction( props ) ?
{ click: props, text: name } :
props;
- var button = $('<button type="button"></button>')
+ var button = $( "<button type='button'>" )
.attr( props, true )
- .unbind('click')
+ .unbind( "click" )
.click(function() {
- props.click.apply(self.element[0], arguments);
+ props.click.apply( self.element[0], arguments );
})
- .appendTo(uiButtonSet);
- if ($.fn.button) {
+ .appendTo( uiButtonSet );
+ if ( $.fn.button ) {
button.button();
}
});
- uiDialogButtonPane.appendTo(self.uiDialog);
+ uiDialogButtonPane.appendTo( self.uiDialog );
}
},
_makeDraggable: function() {
var self = this,
options = self.options,
- doc = $(document),
+ doc = $( document ),
heightBeforeDrag;
- function filteredUi(ui) {
+ function filteredUi( ui ) {
return {
position: ui.position,
offset: ui.offset
@@ -402,40 +386,45 @@ $.widget("ui.dialog", {
}
self.uiDialog.draggable({
- cancel: '.ui-dialog-content, .ui-dialog-titlebar-close',
- handle: '.ui-dialog-titlebar',
- containment: 'document',
- start: function(event, ui) {
- heightBeforeDrag = options.height === "auto" ? "auto" : $(this).height();
- $(this).height($(this).height()).addClass("ui-dialog-dragging");
- self._trigger('dragStart', event, filteredUi(ui));
+ cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
+ handle: ".ui-dialog-titlebar",
+ containment: "document",
+ start: function( event, ui ) {
+ heightBeforeDrag = options.height === "auto" ? "auto" : $( this ).height();
+ $( this )
+ .height( $( this ).height() )
+ .addClass( "ui-dialog-dragging" );
+ self._trigger( "dragStart", event, filteredUi( ui ) );
},
- drag: function(event, ui) {
- self._trigger('drag', event, filteredUi(ui));
+ drag: function( event, ui ) {
+ self._trigger( "drag", event, filteredUi( ui ) );
},
- stop: function(event, ui) {
- options.position = [ui.position.left - doc.scrollLeft(),
- ui.position.top - doc.scrollTop()];
- $(this).removeClass("ui-dialog-dragging").height(heightBeforeDrag);
- self._trigger('dragStop', event, filteredUi(ui));
+ stop: function( event, ui ) {
+ options.position = [
+ ui.position.left - doc.scrollLeft(),
+ ui.position.top - doc.scrollTop()
+ ];
+ $( this )
+ .removeClass( "ui-dialog-dragging" )
+ .height( heightBeforeDrag );
+ self._trigger( "dragStop", event, filteredUi( ui ) );
$.ui.dialog.overlay.resize();
}
});
},
- _makeResizable: function(handles) {
+ _makeResizable: function( handles ) {
handles = (handles === undefined ? this.options.resizable : handles);
var self = this,
options = self.options,
// .ui-resizable has position: relative defined in the stylesheet
// but dialogs have to use absolute or fixed positioning
- position = self.uiDialog.css('position'),
- resizeHandles = (typeof handles === 'string' ?
+ position = self.uiDialog.css( "position" ),
+ resizeHandles = typeof handles === 'string' ?
handles :
- 'n,e,s,w,se,sw,ne,nw'
- );
+ "n,e,s,w,se,sw,ne,nw";
- function filteredUi(ui) {
+ function filteredUi( ui ) {
return {
originalPosition: ui.originalPosition,
originalSize: ui.originalSize,
@@ -445,88 +434,86 @@ $.widget("ui.dialog", {
}
self.uiDialog.resizable({
- cancel: '.ui-dialog-content',
- containment: 'document',
+ cancel: ".ui-dialog-content",
+ containment: "document",
alsoResize: self.element,
maxWidth: options.maxWidth,
maxHeight: options.maxHeight,
minWidth: options.minWidth,
minHeight: self._minHeight(),
handles: resizeHandles,
- start: function(event, ui) {
- $(this).addClass("ui-dialog-resizing");
- self._trigger('resizeStart', event, filteredUi(ui));
+ start: function( event, ui ) {
+ $( this ).addClass( "ui-dialog-resizing" );
+ self._trigger( "resizeStart", event, filteredUi( ui ) );
},
- resize: function(event, ui) {
- self._trigger('resize', event, filteredUi(ui));
+ resize: function( event, ui ) {
+ self._trigger( "resize", event, filteredUi( ui ) );
},
- stop: function(event, ui) {
- $(this).removeClass("ui-dialog-resizing");
- options.height = $(this).height();
- options.width = $(this).width();
- self._trigger('resizeStop', event, filteredUi(ui));
+ stop: function( event, ui ) {
+ $( this ).removeClass( "ui-dialog-resizing" );
+ options.height = $( this ).height();
+ options.width = $( this ).width();
+ self._trigger( "resizeStop", event, filteredUi( ui ) );
$.ui.dialog.overlay.resize();
}
})
- .css('position', position)
- .find('.ui-resizable-se').addClass('ui-icon ui-icon-grip-diagonal-se');
+ .css( "position", position )
+ .find( ".ui-resizable-se" )
+ .addClass( "ui-icon ui-icon-grip-diagonal-se" );
},
_minHeight: function() {
var options = this.options;
- if (options.height === 'auto') {
+ if ( options.height === "auto" ) {
return options.minHeight;
} else {
- return Math.min(options.minHeight, options.height);
+ return Math.min( options.minHeight, options.height );
}
},
- _position: function(position) {
+ _position: function( position ) {
var myAt = [],
- offset = [0, 0],
+ offset = [ 0, 0 ],
isVisible;
- if (position) {
+ if ( position ) {
// deep extending converts arrays to objects in jQuery <= 1.3.2 :-(
// if (typeof position == 'string' || $.isArray(position)) {
// myAt = $.isArray(position) ? position : position.split(' ');
- if (typeof position === 'string' || (typeof position === 'object' && '0' in position)) {
- myAt = position.split ? position.split(' ') : [position[0], position[1]];
- if (myAt.length === 1) {
- myAt[1] = myAt[0];
+ if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
+ myAt = position.split ? position.split( " " ) : [ position[ 0 ], position[ 1 ] ];
+ if ( myAt.length === 1 ) {
+ myAt[ 1 ] = myAt[ 0 ];
}
- $.each(['left', 'top'], function(i, offsetPosition) {
- if (+myAt[i] === myAt[i]) {
- offset[i] = myAt[i];
- myAt[i] = offsetPosition;
+ $.each( [ "left", "top" ], function( i, offsetPosition ) {
+ if ( +myAt[ i ] === myAt[ i ] ) {
+ offset[ i ] = myAt[ i ];
+ myAt[ i ] = offsetPosition;
}
});
position = {
- my: myAt.join(" "),
- at: myAt.join(" "),
- offset: offset.join(" ")
+ my: myAt.join( " " ),
+ at: myAt.join( " " ),
+ offset: offset.join( " " )
};
}
- position = $.extend({}, $.ui.dialog.prototype.options.position, position);
+ position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
} else {
position = $.ui.dialog.prototype.options.position;
}
// need to show the dialog to get the actual offset in the position plugin
- isVisible = this.uiDialog.is(':visible');
- if (!isVisible) {
+ isVisible = this.uiDialog.is( ":visible" );
+ if ( !isVisible ) {
this.uiDialog.show();
}
- this.uiDialog
- // workaround for jQuery bug #5781 http://dev.jquery.com/ticket/5781
- .css({ top: 0, left: 0 })
- .position(position);
- if (!isVisible) {
+ this.uiDialog.position( position );
+ if ( !isVisible ) {
this.uiDialog.hide();
}
},
@@ -555,38 +542,32 @@ $.widget("ui.dialog", {
}
},
- _setOption: function(key, value){
+ _setOption: function( key, value ) {
var self = this,
uiDialog = self.uiDialog;
- switch (key) {
- //handling of deprecated beforeclose (vs beforeClose) option
- //Ticket #4669 http://dev.jqueryui.com/ticket/4669
- //TODO: remove in 1.9pre
- case "beforeclose":
- key = "beforeClose";
- break;
+ switch ( key ) {
case "buttons":
- self._createButtons(value);
+ self._createButtons( value );
break;
case "closeText":
// ensure that we always pass a string
- self.uiDialogTitlebarCloseText.text("" + value);
+ self.uiDialogTitlebarCloseText.text( "" + value );
break;
case "dialogClass":
uiDialog
- .removeClass(self.options.dialogClass)
- .addClass(uiDialogClasses + value);
+ .removeClass( self.options.dialogClass )
+ .addClass( uiDialogClasses + value );
break;
case "disabled":
- if (value) {
- uiDialog.addClass('ui-dialog-disabled');
+ if ( value ) {
+ uiDialog.addClass( "ui-dialog-disabled" );
} else {
- uiDialog.removeClass('ui-dialog-disabled');
+ uiDialog.removeClass( "ui-dialog-disabled" );
}
break;
case "draggable":
- var isDraggable = uiDialog.is( ":data(draggable)" )
+ var isDraggable = uiDialog.is( ":data(draggable)" );
if ( isDraggable && !value ) {
uiDialog.draggable( "destroy" );
}
@@ -596,32 +577,33 @@ $.widget("ui.dialog", {
}
break;
case "position":
- self._position(value);
+ self._position( value );
break;
case "resizable":
// currently resizable, becoming non-resizable
- var isResizable = uiDialog.is( ":data(resizable)" )
- if (isResizable && !value) {
- uiDialog.resizable('destroy');
+ var isResizable = uiDialog.is( ":data(resizable)" );
+ if ( isResizable && !value ) {
+ uiDialog.resizable( "destroy" );
}
// currently resizable, changing handles
- if (isResizable && typeof value === 'string') {
- uiDialog.resizable('option', 'handles', value);
+ if ( isResizable && typeof value === "string" ) {
+ uiDialog.resizable( "option", "handles", value );
}
// currently non-resizable, becoming resizable
- if (!isResizable && value !== false) {
- self._makeResizable(value);
+ if ( !isResizable && value !== false ) {
+ self._makeResizable( value );
}
break;
case "title":
// convert whatever was passed in o a string, for html() to not throw up
- $(".ui-dialog-title", self.uiDialogTitlebar).html("" + (value || '&#160;'));
+ $( ".ui-dialog-title", self.uiDialogTitlebar )
+ .html( "" + ( value || "&#160;" ) );
break;
}
- $.Widget.prototype._setOption.apply(self, arguments);
+ $.Widget.prototype._setOption.apply( self, arguments );
},
_size: function() {
@@ -630,23 +612,24 @@ $.widget("ui.dialog", {
*/
var options = this.options,
nonContentHeight,
- minContentHeight;
+ minContentHeight,
+ isVisible = this.uiDialog.is( ":visible" );
// reset content sizing
this.element.show().css({
- width: 'auto',
+ width: "auto",
minHeight: 0,
height: 0
});
- if (options.minWidth > options.width) {
+ if ( options.minWidth > options.width ) {
options.width = options.minWidth;
}
// reset wrapper sizing
// determine the height of all the non-content elements
nonContentHeight = this.uiDialog.css({
- height: 'auto',
+ height: "auto",
width: options.width
})
.height();
@@ -662,15 +645,17 @@ $.widget("ui.dialog", {
} else {
this.uiDialog.show();
var autoHeight = this.element.css( "height", "auto" ).height();
- this.uiDialog.hide();
+ 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());
+ if (this.uiDialog.is( ":data(resizable)" ) ) {
+ this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
}
}
});
@@ -682,86 +667,93 @@ $.extend($.ui.dialog, {
maxZ: 0,
getTitleId: function($el) {
- var id = $el.attr('id');
- if (!id) {
+ var id = $el.attr( "id" );
+ if ( !id ) {
this.uuid += 1;
id = this.uuid;
}
- return 'ui-dialog-title-' + id;
+ return "ui-dialog-title-" + id;
},
- overlay: function(dialog) {
- this.$el = $.ui.dialog.overlay.create(dialog);
+ overlay: function( dialog ) {
+ this.$el = $.ui.dialog.overlay.create( dialog );
}
});
-$.extend($.ui.dialog.overlay, {
+$.extend( $.ui.dialog.overlay, {
instances: [],
// reuse old instances due to IE memory leak with alpha transparency (see #5185)
oldInstances: [],
maxZ: 0,
- events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
- function(event) { return event + '.dialog-overlay'; }).join(' '),
- create: function(dialog) {
- if (this.instances.length === 0) {
+ events: $.map(
+ "focus,mousedown,mouseup,keydown,keypress,click".split( "," ),
+ function( event ) {
+ return event + ".dialog-overlay";
+ }
+ ).join( " " ),
+ create: function( dialog ) {
+ if ( this.instances.length === 0 ) {
// prevent use of anchors and inputs
// we use a setTimeout in case the overlay is created from an
// event that we're going to be cancelling (see #2804)
setTimeout(function() {
// handle $(el).dialog().dialog('close') (see #4065)
- if ($.ui.dialog.overlay.instances.length) {
- $(document).bind($.ui.dialog.overlay.events, function(event) {
+ if ( $.ui.dialog.overlay.instances.length ) {
+ $( document ).bind( $.ui.dialog.overlay.events, function( event ) {
// stop events if the z-index of the target is < the z-index of the overlay
// we cannot return true when we don't want to cancel the event (#3523)
- if ($(event.target).zIndex() < $.ui.dialog.overlay.maxZ) {
+ if ( $( event.target ).zIndex() < $.ui.dialog.overlay.maxZ ) {
return false;
}
});
}
- }, 1);
+ }, 1 );
// allow closing by pressing the escape key
- $(document).bind('keydown.dialog-overlay', function(event) {
- if (dialog.options.closeOnEscape && event.keyCode &&
- event.keyCode === $.ui.keyCode.ESCAPE) {
+ $( document ).bind( "keydown.dialog-overlay", function( event ) {
+ if ( dialog.options.closeOnEscape && event.keyCode &&
+ event.keyCode === $.ui.keyCode.ESCAPE ) {
- dialog.close(event);
+ dialog.close( event );
event.preventDefault();
}
});
// handle window resize
- $(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);
+ $( window ).bind( "resize.dialog-overlay", $.ui.dialog.overlay.resize );
}
- var $el = (this.oldInstances.pop() || $('<div></div>').addClass('ui-widget-overlay'))
- .appendTo(document.body)
+ var $el = ( this.oldInstances.pop() || $( "<div>" ).addClass( "ui-widget-overlay" ) )
+ .appendTo( document.body )
.css({
width: this.width(),
height: this.height()
});
- if ($.fn.bgiframe) {
+ if ( $.fn.bgiframe ) {
$el.bgiframe();
}
- this.instances.push($el);
+ this.instances.push( $el );
return $el;
},
- destroy: function($el) {
- this.oldInstances.push(this.instances.splice($.inArray($el, this.instances), 1)[0]);
+ destroy: function( $el ) {
+ 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');
+ if ( this.instances.length === 0 ) {
+ $( [ document, window ] ).unbind( ".dialog-overlay" );
}
$el.remove();
-
+
// adjust the maxZ to allow other modal dialogs to continue to work (see #4309)
var maxZ = 0;
- $.each(this.instances, function() {
- maxZ = Math.max(maxZ, this.css('z-index'));
+ $.each( this.instances, function() {
+ maxZ = Math.max( maxZ, this.css( "z-index" ) );
});
this.maxZ = maxZ;
},
@@ -770,7 +762,7 @@ $.extend($.ui.dialog.overlay, {
var scrollHeight,
offsetHeight;
// handle IE 6
- if ($.browser.msie && $.browser.version < 7) {
+ if ( $.browser.msie && $.browser.version < 7 ) {
scrollHeight = Math.max(
document.documentElement.scrollHeight,
document.body.scrollHeight
@@ -780,14 +772,14 @@ $.extend($.ui.dialog.overlay, {
document.body.offsetHeight
);
- if (scrollHeight < offsetHeight) {
- return $(window).height() + 'px';
+ if ( scrollHeight < offsetHeight ) {
+ return $( window ).height() + "px";
} else {
- return scrollHeight + 'px';
+ return scrollHeight + "px";
}
// handle "good" browsers
} else {
- return $(document).height() + 'px';
+ return $( document ).height() + "px";
}
},
@@ -795,7 +787,7 @@ $.extend($.ui.dialog.overlay, {
var scrollWidth,
offsetWidth;
// handle IE 6
- if ($.browser.msie && $.browser.version < 7) {
+ if ( $.browser.msie && $.browser.version < 7 ) {
scrollWidth = Math.max(
document.documentElement.scrollWidth,
document.body.scrollWidth
@@ -805,14 +797,14 @@ $.extend($.ui.dialog.overlay, {
document.body.offsetWidth
);
- if (scrollWidth < offsetWidth) {
- return $(window).width() + 'px';
+ if ( scrollWidth < offsetWidth ) {
+ return $( window ).width() + "px";
} else {
- return scrollWidth + 'px';
+ return scrollWidth + "px";
}
// handle "good" browsers
} else {
- return $(document).width() + 'px';
+ return $( document ).width() + "px";
}
},
@@ -825,9 +817,9 @@ $.extend($.ui.dialog.overlay, {
* This is handled by shrinking the overlay before setting it
* to the full document size.
*/
- var $overlays = $([]);
- $.each($.ui.dialog.overlay.instances, function() {
- $overlays = $overlays.add(this);
+ var $overlays = $( [] );
+ $.each( $.ui.dialog.overlay.instances, function() {
+ $overlays = $overlays.add( this );
});
$overlays.css({
@@ -840,10 +832,10 @@ $.extend($.ui.dialog.overlay, {
}
});
-$.extend($.ui.dialog.overlay.prototype, {
+$.extend( $.ui.dialog.overlay.prototype, {
destroy: function() {
- $.ui.dialog.overlay.destroy(this.$el);
+ $.ui.dialog.overlay.destroy( this.$el );
}
});
-}(jQuery));
+}( jQuery ) );
diff --git a/ui/jquery.ui.draggable.js b/ui/jquery.ui.draggable.js
index 71698a85d..2d4947145 100644
--- a/ui/jquery.ui.draggable.js
+++ b/ui/jquery.ui.draggable.js
@@ -284,7 +284,7 @@ $.widget("ui.draggable", $.ui.mouse, {
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
- if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
+ if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
po.left += this.scrollParent.scrollLeft();
po.top += this.scrollParent.scrollTop();
}
@@ -333,10 +333,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) {
@@ -360,7 +360,7 @@ $.widget("ui.draggable", $.ui.mouse, {
if(!pos) pos = this.position;
var mod = d == "absolute" ? 1 : -1;
- var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
return {
top: (
@@ -381,7 +381,7 @@ $.widget("ui.draggable", $.ui.mouse, {
_generatePosition: function(event) {
- var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
var pageX = event.pageX;
var pageY = event.pageY;
diff --git a/ui/jquery.ui.mouse.js b/ui/jquery.ui.mouse.js
index d0c82f83f..bfe8640a2 100644
--- a/ui/jquery.ui.mouse.js
+++ b/ui/jquery.ui.mouse.js
@@ -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;
}
@@ -118,7 +118,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/ui/jquery.ui.position.js b/ui/jquery.ui.position.js
index deacedbcc..3992e1c63 100644
--- a/ui/jquery.ui.position.js
+++ b/ui/jquery.ui.position.js
@@ -37,8 +37,7 @@ $.fn.position = function( options ) {
targetWidth = target.width();
targetHeight = target.height();
basePosition = { top: 0, left: 0 };
- // TODO: use $.isWindow() in 1.9
- } else if ( targetElem.setTimeout ) {
+ } else if ( $.isWindow( targetElem ) ) {
targetWidth = target.width();
targetHeight = target.height();
basePosition = { top: target.scrollTop(), left: target.scrollLeft() };
@@ -122,8 +121,8 @@ $.fn.position = function( options ) {
}
// 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,
diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js
index 5347e026b..009049d27 100644
--- a/ui/jquery.ui.progressbar.js
+++ b/ui/jquery.ui.progressbar.js
@@ -15,11 +15,11 @@
$.widget( "ui.progressbar", {
options: {
- value: 0
+ value: 0,
+ max: 100
},
min: 0,
- max: 100,
_create: function() {
this.element
@@ -27,13 +27,14 @@ $.widget( "ui.progressbar", {
.attr({
role: "progressbar",
"aria-valuemin": this.min,
- "aria-valuemax": this.max,
+ "aria-valuemax": this.options.max,
"aria-valuenow": this._value()
});
this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
.appendTo( this.element );
+ this.oldValue = this._value();
this._refreshValue();
},
@@ -63,8 +64,7 @@ $.widget( "ui.progressbar", {
if ( key === "value" ) {
this.options.value = value;
this._refreshValue();
- this._trigger( "change" );
- if ( this._value() === this.max ) {
+ if ( this._value() === this.options.max ) {
this._trigger( "complete" );
}
}
@@ -78,14 +78,25 @@ $.widget( "ui.progressbar", {
if ( typeof val !== "number" ) {
val = 0;
}
- return Math.min( this.max, Math.max( this.min, val ) );
+ return Math.min( this.options.max, Math.max( this.min, val ) );
+ },
+
+ _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
- .toggleClass( "ui-corner-right", value === this.max )
- .width( value + "%" );
+ .toggleClass( "ui-corner-right", value === this.options.max )
+ .width( percentage.toFixed(0) + "%" );
this.element.attr( "aria-valuenow", value );
}
});
diff --git a/ui/jquery.ui.slider.js b/ui/jquery.ui.slider.js
index d90a7940f..d3b4744e3 100644
--- a/ui/jquery.ui.slider.js
+++ b/ui/jquery.ui.slider.js
@@ -309,7 +309,9 @@ $.widget( "ui.slider", $.ui.mouse, {
( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
};
- this._slide( event, index, normValue );
+ if ( !this.handles.hasClass( "ui-state-hover" ) ) {
+ this._slide( event, index, normValue );
+ }
this._animateOff = true;
return true;
},
@@ -583,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 ) {
diff --git a/ui/jquery.ui.sortable.js b/ui/jquery.ui.sortable.js
index 6cc2434e8..32757d41c 100644
--- a/ui/jquery.ui.sortable.js
+++ b/ui/jquery.ui.sortable.js
@@ -77,8 +77,7 @@ $.widget("ui.sortable", $.ui.mouse, {
if ( key === "disabled" ) {
this.options[ key ] = value;
- this.widget()
- [ value ? "addClass" : "removeClass"]( "ui-sortable-disabled" );
+ this.widget().toggleClass( "ui-sortable-disabled", !!value );
} else {
// Don't call widget base _setOption for disable as it adds ui-state-disabled class
$.Widget.prototype._setOption.apply(this, arguments);
@@ -294,8 +293,8 @@ $.widget("ui.sortable", $.ui.mouse, {
if(itemElement != this.currentItem[0] //cannot intersect with itself
&& this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
- && !$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
- && (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true)
+ && !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
+ && (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true)
//&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
) {
@@ -691,13 +690,13 @@ $.widget("ui.sortable", $.ui.mouse, {
for (var i = this.containers.length - 1; i >= 0; i--){
// never consider a container that's located within the item itself
- if($.ui.contains(this.currentItem[0], this.containers[i].element[0]))
+ if($.contains(this.currentItem[0], this.containers[i].element[0]))
continue;
if(this._intersectsWith(this.containers[i].containerCache)) {
// if we've already found a container and it's more "inner" than this, then continue
- if(innermostContainer && $.ui.contains(this.containers[i].element[0], innermostContainer.element[0]))
+ if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0]))
continue;
innermostContainer = this.containers[i];
@@ -725,7 +724,7 @@ $.widget("ui.sortable", $.ui.mouse, {
//When entering a new container, we will find the item with the least distance and append our item near it
var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
for (var j = this.items.length - 1; j >= 0; j--) {
- if(!$.ui.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
+ if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
var cur = this.items[j][this.containers[innermostIndex].floating ? 'left' : 'top'];
if(Math.abs(cur - base) < dist) {
dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
@@ -800,7 +799,7 @@ $.widget("ui.sortable", $.ui.mouse, {
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
- if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
+ if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
po.left += this.scrollParent.scrollLeft();
po.top += this.scrollParent.scrollTop();
}
@@ -874,7 +873,7 @@ $.widget("ui.sortable", $.ui.mouse, {
if(!pos) pos = this.position;
var mod = d == "absolute" ? 1 : -1;
- var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
return {
top: (
@@ -895,7 +894,7 @@ $.widget("ui.sortable", $.ui.mouse, {
_generatePosition: function(event) {
- var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
+ var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
// This is another very weird special case that only happens for relative elements:
// 1. If the css position is relative
@@ -992,10 +991,10 @@ $.widget("ui.sortable", $.ui.mouse, {
if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
if((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !noPropagation) delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
- if(!$.ui.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
+ if(!$.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
if(!noPropagation) delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
for (var i = this.containers.length - 1; i >= 0; i--){
- if($.ui.contains(this.containers[i].element[0], this.currentItem[0]) && !noPropagation) {
+ if($.contains(this.containers[i].element[0], this.currentItem[0]) && !noPropagation) {
delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
}
diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js
index ad99a99b7..82da51d5b 100644..100755
--- a/ui/jquery.ui.tabs.js
+++ b/ui/jquery.ui.tabs.js
@@ -126,7 +126,7 @@ $.widget( "ui.tabs", {
// inline tab
if ( fragmentId.test( href ) ) {
- self.panels = self.panels.add( self._sanitizeSelector( href ) );
+ self.panels = self.panels.add( self.element.find( self._sanitizeSelector( href ) ) );
// remote tab
// prevent loading the page itself if href is just "#"
} else if ( href && href !== "#" ) {
@@ -139,7 +139,7 @@ $.widget( "ui.tabs", {
var id = self._tabId( a );
a.href = "#" + id;
- var $panel = $( "#" + id );
+ var $panel = self.element.find( "#" + id );
if ( !$panel.length ) {
$panel = $( o.panelTemplate )
.attr( "id", id )
@@ -210,13 +210,13 @@ $.widget( "ui.tabs", {
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._sanitizeSelector( self.anchors[ o.selected ].hash ) ).removeClass( "ui-tabs-hide" );
+ 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._sanitizeSelector( self.anchors[ o.selected ].hash ) ) ) );
+ self._ui( self.anchors[ o.selected ], self.element.find( self._sanitizeSelector( self.anchors[ o.selected ].hash ) ) ) );
});
this.load( o.selected );
@@ -233,9 +233,7 @@ $.widget( "ui.tabs", {
o.selected = this.lis.index( this.lis.filter( ".ui-tabs-selected" ) );
}
- // update collapsible
- // TODO: use .toggleClass()
- this.element[ o.collapsible ? "addClass" : "removeClass" ]( "ui-tabs-collapsible" );
+ this.element.toggleClass( "ui-tabs-collapsible", o.collapsible );
// set or update cookie after init and add/remove respectively
if ( o.cookie ) {
@@ -244,9 +242,8 @@ $.widget( "ui.tabs", {
// disable tabs
for ( var i = 0, li; ( li = this.lis[ i ] ); i++ ) {
- $( li )[ $.inArray( i, o.disabled ) != -1 &&
- // TODO: use .toggleClass()
- !$( li ).hasClass( "ui-tabs-selected" ) ? "addClass" : "removeClass" ]( "ui-state-disabled" );
+ $( li ).toggleClass( "ui-state-disabled",
+ $.inArray( i, o.disabled ) != -1 && !$( li ).hasClass( "ui-tabs-selected" ) );
}
// reset cache if switching from cached to not cached
@@ -333,11 +330,12 @@ $.widget( "ui.tabs", {
};
// attach tab event handler, unbind to avoid duplicates from former tabifying...
- this.anchors.bind( o.event + ".tabs", function() {
+ this.anchors.bind( o.event + ".tabs", function( event ) {
+ event.preventDefault();
var el = this,
$li = $(el).closest( "li" ),
$hide = self.panels.filter( ":not(.ui-tabs-hide)" ),
- $show = $( self._sanitizeSelector( el.hash ) );
+ $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.
@@ -349,7 +347,7 @@ $.widget( "ui.tabs", {
self.panels.filter( ":animated" ).length ||
self._trigger( "select", null, self._ui( this, $show[ 0 ] ) ) === false ) {
this.blur();
- return false;
+ return;
}
o.selected = self.anchors.index( this );
@@ -370,7 +368,7 @@ $.widget( "ui.tabs", {
}).dequeue( "tabs" );
this.blur();
- return false;
+ return;
} else if ( !$hide.length ) {
if ( o.cookie ) {
self._cookie( o.selected, o.cookie );
@@ -384,7 +382,7 @@ $.widget( "ui.tabs", {
self.load( self.anchors.index( this ) );
this.blur();
- return false;
+ return;
}
}
@@ -411,15 +409,15 @@ $.widget( "ui.tabs", {
// 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').
+ // which can become a usability
if ( $.browser.msie ) {
this.blur();
}
});
// disable click in any case
- this.anchors.bind( "click.tabs", function(){
- return false;
+ this.anchors.bind( "click.tabs", function( event ){
+ event.preventDefault();
});
},
@@ -496,7 +494,7 @@ $.widget( "ui.tabs", {
$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 );
+ var $panel = self.element.find( "#" + id );
if ( !$panel.length ) {
$panel = $( o.panelTemplate )
.attr( "id", id )
@@ -630,7 +628,7 @@ $.widget( "ui.tabs", {
this.xhr = $.ajax( $.extend( {}, o.ajaxOptions, {
url: url,
success: function( r, s ) {
- $( self._sanitizeSelector( a.hash ) ).html( r );
+ self.element.find( self._sanitizeSelector( a.hash ) ).html( r );
// take care of tab labels
self._cleanup();
@@ -701,58 +699,4 @@ $.extend( $.ui.tabs, {
version: "@VERSION"
});
-/*
- * Tabs Extensions
- */
-
-/*
- * Rotate
- */
-$.extend( $.ui.tabs.prototype, {
- rotation: null,
- rotate: function( ms, continuing ) {
- var self = this,
- o = this.options;
-
- var rotate = self._rotate || ( self._rotate = function( e ) {
- clearTimeout( self.rotation );
- self.rotation = setTimeout(function() {
- var t = o.selected;
- self.select( ++t < self.anchors.length ? t : 0 );
- }, ms );
-
- if ( e ) {
- e.stopPropagation();
- }
- });
-
- var stop = self._unrotate || ( self._unrotate = !continuing
- ? function(e) {
- if (e.clientX) { // in case of a true click
- self.rotate(null);
- }
- }
- : function( e ) {
- t = o.selected;
- rotate();
- });
-
- // start rotation
- if ( ms ) {
- this.element.bind( "tabsshow", rotate );
- this.anchors.bind( o.event + ".tabs", stop );
- rotate();
- // stop rotation
- } else {
- clearTimeout( self.rotation );
- this.element.unbind( "tabsshow", rotate );
- this.anchors.unbind( o.event + ".tabs", stop );
- delete this._rotate;
- delete this._unrotate;
- }
-
- return this;
- }
-});
-
})( jQuery );
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index fadf81f2b..b5fb600d9 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -96,19 +96,15 @@ $.widget.bridge = function( name, object ) {
if ( isMethodCall ) {
this.each(function() {
- var instance = $.data( this, name ),
- methodValue = instance && $.isFunction( instance[options] ) ?
- instance[ options ].apply( instance, args ) :
- instance;
- // TODO: add this back in 1.9 and use $.error() (see #5972)
-// if ( !instance ) {
-// throw "cannot call methods on " + name + " prior to initialization; " +
-// "attempted to call method '" + options + "'";
-// }
-// if ( !$.isFunction( instance[options] ) ) {
-// throw "no such method '" + options + "' for " + name + " widget instance";
-// }
-// var methodValue = instance[ options ].apply( instance, args );
+ var instance = $.data( this, name );
+ if ( !instance ) {
+ return $.error( "cannot call methods on " + name + " prior to initialization; " +
+ "attempted to call method '" + options + "'" );
+ }
+ if ( !$.isFunction( instance[options] ) ) {
+ return $.error( "no such method '" + options + "' for " + name + " widget instance" );
+ }
+ var methodValue = instance[ options ].apply( instance, args );
if ( methodValue !== instance && methodValue !== undefined ) {
returnValue = methodValue;
return false;
@@ -216,9 +212,7 @@ $.Widget.prototype = {
if ( key === "disabled" ) {
this.widget()
- [ value ? "addClass" : "removeClass"](
- this.widgetBaseClass + "-disabled" + " " +
- "ui-state-disabled" )
+ .toggleClass( this.widgetBaseClass + "-disabled ui-state-disabled", !!value )
.attr( "aria-disabled", value );
}