From bdfc6d532c68c092a83461a8b76840719294313f Mon Sep 17 00:00:00 2001 From: Trey Hunner Date: Tue, 19 Apr 2011 11:04:08 -0700 Subject: [PATCH 01/59] Autocomplete: Fix list traversal bug. Fixes #7269 - autocomplete: holding down arrow keys in Firefox does not traverse list Use keypress event for listening for arrow keys because Firefox and Opera do not repeat keydown events for these keys. --- ui/jquery.ui.autocomplete.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 1685c06523..09bf4b268c 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -53,6 +53,7 @@ $.widget( "ui.autocomplete", { }) .bind( "keydown.autocomplete", function( event ) { if ( self.options.disabled || self.element.attr( "readonly" ) ) { + suppressKeyPress = true; return; } @@ -60,17 +61,21 @@ $.widget( "ui.autocomplete", { var keyCode = $.ui.keyCode; switch( event.keyCode ) { case keyCode.PAGE_UP: + suppressKeyPress = true; self._move( "previousPage", event ); break; case keyCode.PAGE_DOWN: + suppressKeyPress = true; self._move( "nextPage", event ); break; case keyCode.UP: + suppressKeyPress = true; self._move( "previous", event ); // prevent moving cursor to beginning of text field in some browsers event.preventDefault(); break; case keyCode.DOWN: + suppressKeyPress = true; self._move( "next", event ); // prevent moving cursor to end of text field in some browsers event.preventDefault(); @@ -112,7 +117,28 @@ $.widget( "ui.autocomplete", { if ( suppressKeyPress ) { suppressKeyPress = false; event.preventDefault(); + return; } + + var keyCode = $.ui.keyCode; + switch( event.keyCode ) { + case keyCode.PAGE_UP: + self._move( "previousPage", event ); + break; + case keyCode.PAGE_DOWN: + self._move( "nextPage", event ); + break; + case keyCode.UP: + self._move( "previous", event ); + // prevent moving cursor to beginning of text field in some browsers + event.preventDefault(); + break; + case keyCode.DOWN: + self._move( "next", event ); + // prevent moving cursor to end of text field in some browsers + event.preventDefault(); + break; + } }) .bind( "focus.autocomplete", function() { if ( self.options.disabled ) { From 61904162cf4f81330c23a5ea84fc49c62a3ce4ac Mon Sep 17 00:00:00 2001 From: gnarf Date: Tue, 3 May 2011 07:22:34 -0500 Subject: [PATCH 02/59] effects.pulsate: set default mode to 'effect' --- ui/jquery.effects.pulsate.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ui/jquery.effects.pulsate.js b/ui/jquery.effects.pulsate.js index bcba487971..bec33a4bb5 100644 --- a/ui/jquery.effects.pulsate.js +++ b/ui/jquery.effects.pulsate.js @@ -15,8 +15,8 @@ $.effects.effect.pulsate = function( o ) { return this.queue( function( next ) { var elem = $( this ), - mode = $.effects.setMode( elem, o.mode || "show" ), - show = mode === "show" || !elem.is( ":visible" ), + mode = $.effects.setMode( elem, o.mode || "effect" ), + show = mode === "show" || elem.is( ":hidden" ), showhide = ( show || mode === "hide" ), // showing or hiding leaves of the "last" animation @@ -32,7 +32,8 @@ $.effects.effect.pulsate = function( o ) { animateTo = 1; } - for ( i = 0; i < anims - 1; i++ ) { + // anims - 1 opacity "toggles" + for ( i = 1; i < anims; i++ ) { elem.animate({ opacity: animateTo }, duration, o.easing ); From 34d9e038bd03dcc8667b1ac12b687eec2209270f Mon Sep 17 00:00:00 2001 From: gnarf Date: Tue, 3 May 2011 08:39:02 -0500 Subject: [PATCH 03/59] effect.bounce: fixing default distance to be 1/3 the size of the bouncing box - thx @scott_gonzalez for catching this --- ui/jquery.effects.bounce.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/jquery.effects.bounce.js b/ui/jquery.effects.bounce.js index 1ffd5ed5ad..550f433b9b 100644 --- a/ui/jquery.effects.bounce.js +++ b/ui/jquery.effects.bounce.js @@ -23,7 +23,7 @@ $.effects.effect.bounce = function(o) { hide = mode === "hide", show = mode === "show", direction = o.direction || "up", - distance = o.distance || 20, + distance = o.distance, times = o.times || 5, // number of internal animations From e8bece27abbca237148754b8803f73c9b0b9a31a Mon Sep 17 00:00:00 2001 From: gnarf Date: Tue, 3 May 2011 08:45:21 -0500 Subject: [PATCH 04/59] effect.bounce: ignoring the margins for the height calc --- ui/jquery.effects.bounce.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/jquery.effects.bounce.js b/ui/jquery.effects.bounce.js index 550f433b9b..f1093839f5 100644 --- a/ui/jquery.effects.bounce.js +++ b/ui/jquery.effects.bounce.js @@ -53,7 +53,7 @@ $.effects.effect.bounce = function(o) { // default distance for the BIGGEST bounce is the outer Distance / 3 if ( !distance ) { - distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]({ margin:true }) / 3; + distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3; } if ( show ) { From d5f6a71cfa1966b9d838b7589bb92ba29274d1aa Mon Sep 17 00:00:00 2001 From: gnarf Date: Tue, 3 May 2011 08:51:53 -0500 Subject: [PATCH 05/59] effects.bounce: Fixing hide bounce distance calculation --- ui/jquery.effects.bounce.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/jquery.effects.bounce.js b/ui/jquery.effects.bounce.js index f1093839f5..bb386a4f4d 100644 --- a/ui/jquery.effects.bounce.js +++ b/ui/jquery.effects.bounce.js @@ -69,7 +69,7 @@ $.effects.effect.bounce = function(o) { // start at the smallest distance if we are hiding if ( hide ) { - distance = distance / ( ( times - 1 ) * 2 ); + distance = distance / Math.pow( 2, times - 1 ); } downAnim = {}; From 126d46c0509ff9b8b5f194b897201458925ace93 Mon Sep 17 00:00:00 2001 From: gnarf Date: Tue, 3 May 2011 10:48:00 -0500 Subject: [PATCH 06/59] effects.pulsate: tweaking 'times' - if showing / hiding the animation has an extra 'half' time as opposed to removing a 'half' time --- ui/jquery.effects.pulsate.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/jquery.effects.pulsate.js b/ui/jquery.effects.pulsate.js index bec33a4bb5..3325c251f2 100644 --- a/ui/jquery.effects.pulsate.js +++ b/ui/jquery.effects.pulsate.js @@ -19,8 +19,8 @@ $.effects.effect.pulsate = function( o ) { show = mode === "show" || elem.is( ":hidden" ), showhide = ( show || mode === "hide" ), - // showing or hiding leaves of the "last" animation - anims = ( ( o.times || 5 ) * 2 ) - ( showhide ? 1 : 0 ), + // showing or hiding adds an extra "half" animation + anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ), duration = o.duration / anims, animateTo = 0, queue = elem.queue(), From 8201c1392863eb9e13204854ad393c023fdeba94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Wed, 4 May 2011 08:20:41 +0200 Subject: [PATCH 07/59] Popup: Update popup test --- tests/visual/menu/popup.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/visual/menu/popup.html b/tests/visual/menu/popup.html index 271002a201..52a5bdd983 100644 --- a/tests/visual/menu/popup.html +++ b/tests/visual/menu/popup.html @@ -76,7 +76,7 @@ width: 200px; height: 150px; border: 1px solid gray; border-radius: 5px; box-shadow: 3px 3px 5px -1px rgba(0, 0, 0, 0.5); background: lightgray; background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#ddd)); - font-size: 120%; text-align: center; line-height: 150px; + font-size: 120%; text-align: center; line-height: 150px; outline: none; } From 66b96cbbe41ce873ad7bfcaf7394272eaf748672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Wed, 4 May 2011 08:21:57 +0200 Subject: [PATCH 08/59] Tooltip: Also close on click. Essential for tooltips on menu buttons. --- ui/jquery.ui.tooltip.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 20638cba54..a8a44f1c0e 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -96,7 +96,8 @@ $.widget("ui.tooltip", { this._bind( target, { mouseleave: "close", - blur: "close" + blur: "close", + click: "close" }); }, From f519bc0ebb3426cfaa0c918429781586abd87872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Wed, 4 May 2011 08:31:14 +0200 Subject: [PATCH 09/59] Menubar review --- tests/visual/menu/menubar.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/tests/visual/menu/menubar.js b/tests/visual/menu/menubar.js index cc3258d4a1..a8265e69bf 100644 --- a/tests/visual/menu/menubar.js +++ b/tests/visual/menu/menubar.js @@ -1,11 +1,11 @@ /* * jQuery UI menubar - * - * backported from Michael Lang's fork: http://www.nexul.com/prototypes/toolbar/demo.html + * + * TODO move to jquery.ui.menubar.js */ (function($) { -// TODO take non-menubar buttons into account +// TODO code formatting $.widget("ui.menubar", { options: { buttons: false, @@ -23,12 +23,14 @@ $.widget("ui.menubar", { this.element.addClass('ui-menubar ui-widget-header ui-helper-clearfix').attr("role", "menubar"); this._focusable(items); this._hoverable(items); + // TODO elm is used just once, so the each probably isn't nedded anymore items.next("ul").each(function(i, elm) { $(elm).menu({ select: function(event, ui) { ui.item.parents("ul.ui-menu:last").hide(); self._trigger( "select", event, ui ); self._close(); + // TODO what is this targetting? there's probably a better way to access it $(event.target).prev().focus(); } }).hide() @@ -60,6 +62,8 @@ $.widget("ui.menubar", { return; } event.preventDefault(); + // TODO can we simplify or extractthis check? especially the last two expressions + // there's a similar active[0] == menu[0] check in _open if (event.type == "click" && menu.is(":visible") && self.active && self.active[0] == menu[0]) { self._close(); return; @@ -90,19 +94,22 @@ $.widget("ui.menubar", { .attr("role", "menuitem") .attr("aria-haspopup", "true") .wrapInner(""); - + + // TODO review if these options are a good choice, maybe they can be merged if (o.menuIcon) { input.addClass("ui-state-default").append(""); input.removeClass("ui-button-text-only").addClass("ui-button-text-icon-secondary"); } if (!o.buttons) { + // TODO ui-menubar-link is added above, not needed here? input.addClass('ui-menubar-link').removeClass('ui-state-default'); }; }); self._bind({ keydown: function(event) { + // TODO merge the two ifs if (event.keyCode == $.ui.keyCode.ESCAPE) { if (self.active && self.active.menu("left", event) !== true) { var active = self.active; @@ -117,6 +124,7 @@ $.widget("ui.menubar", { self._close( event ); }, 100); }, + // TODO change order, focusin first focusin :function( event ) { clearTimeout(self.closeTimer); } @@ -150,8 +158,7 @@ $.widget("ui.menubar", { .removeAttr("aria-hidden", "true") .removeAttr("aria-expanded", "false") .removeAttr("tabindex") - .unbind("keydown", "blur") - ; + .unbind("keydown", "blur"); }, _close: function() { @@ -182,12 +189,13 @@ $.widget("ui.menubar", { }) .removeAttr("aria-hidden").attr("aria-expanded", "true") .menu("focus", event, menu.children("li").first()) + // TODO need a comment here why both events are triggered .focus() - .focusin() - ; + .focusin(); this.open = true; }, + // TODO refactor this and the next three methods _prev: function( event, button ) { button.attr("tabIndex", -1); var prev = button.parent().prevAll("li").children( ".ui-button" ).eq( 0 ); @@ -209,7 +217,8 @@ $.widget("ui.menubar", { firstItem.removeAttr("tabIndex")[0].focus(); } }, - + + // TODO rename to parent _left: function(event) { var prev = this.active.parent().prevAll("li:eq(0)").children( ".ui-menu" ).eq( 0 ); if (prev.length) { @@ -220,6 +229,7 @@ $.widget("ui.menubar", { } }, + // TODO rename to child (or something like that) _right: function(event) { var next = this.active.parent().nextAll("li:eq(0)").children( ".ui-menu" ).eq( 0 ); if (next.length) { From bba4cb2be68ae6ca71be987bf13f8c7834242221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Wed, 4 May 2011 11:06:32 +0200 Subject: [PATCH 10/59] Popup: Partial fix for closing popup when trigger is clicked again. --- tests/visual/menu/popup.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/visual/menu/popup.js b/tests/visual/menu/popup.js index f57cba699f..947888eec5 100644 --- a/tests/visual/menu/popup.js +++ b/tests/visual/menu/popup.js @@ -39,6 +39,10 @@ $.widget( "ui.popup", { this._bind(this.options.trigger, { click: function( event ) { event.preventDefault(); + if (this.open) { + // let it propagate to close + return; + } var that = this; setTimeout(function() { that._open( event ); @@ -47,10 +51,14 @@ $.widget( "ui.popup", { }); this._bind(this.element, { - blur: "_close" + // TODO also triggered when open and clicking the trigger again + // figure out how to close in that case, while still closing on regular blur + //blur: "_close" }); this._bind({ + // TODO only triggerd on element if it can receive focus + // bind to document instead? keyup: function( event ) { if (event.keyCode == $.ui.keyCode.ESCAPE && this.element.is( ":visible" )) { this._close( event ); From b96126b398777b5ed2ecf795c234f99c544ee61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Wed, 4 May 2011 11:14:32 +0200 Subject: [PATCH 11/59] Popup: Rename _close to close and use it when selecting something within a popup. --- demos/tooltip/video-player.html | 8 ++++++-- tests/visual/menu/popup.html | 2 +- tests/visual/menu/popup.js | 10 +++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/demos/tooltip/video-player.html b/demos/tooltip/video-player.html index c890c76b4d..2e24197608 100644 --- a/demos/tooltip/video-player.html +++ b/demos/tooltip/video-player.html @@ -24,8 +24,12 @@ }); $(".set").buttonset(); - // TODO hide the tooltip when clicking the button - $("ul").menu().popup({ + $("ul").menu({ + select: function() { + // would also execute some other action here + $(this).popup("close"); + } + }).popup({ trigger: $(".menu") }); diff --git a/tests/visual/menu/popup.html b/tests/visual/menu/popup.html index 52a5bdd983..2a712b00ab 100644 --- a/tests/visual/menu/popup.html +++ b/tests/visual/menu/popup.html @@ -25,7 +25,7 @@ var selected = { select: function( event, ui ) { $( "
" ).text( "Selected: " + ui.item.text() ).appendTo( "#log" ); - $(this).hide(); + $(this).popup("close"); } }; diff --git a/tests/visual/menu/popup.js b/tests/visual/menu/popup.js index 947888eec5..503bb93b7e 100644 --- a/tests/visual/menu/popup.js +++ b/tests/visual/menu/popup.js @@ -34,7 +34,7 @@ $.widget( "ui.popup", { this.element .addClass("ui-popup") - this._close(); + this.close(); this._bind(this.options.trigger, { click: function( event ) { @@ -53,7 +53,7 @@ $.widget( "ui.popup", { this._bind(this.element, { // TODO also triggered when open and clicking the trigger again // figure out how to close in that case, while still closing on regular blur - //blur: "_close" + //blur: "close" }); this._bind({ @@ -61,7 +61,7 @@ $.widget( "ui.popup", { // bind to document instead? keyup: function( event ) { if (event.keyCode == $.ui.keyCode.ESCAPE && this.element.is( ":visible" )) { - this._close( event ); + this.close( event ); this.options.trigger.focus(); } } @@ -70,7 +70,7 @@ $.widget( "ui.popup", { this._bind(document, { click: function( event ) { if (this.open && !$(event.target).closest(".ui-popup").length) { - this._close( event ); + this.close( event ); } } }) @@ -114,7 +114,7 @@ $.widget( "ui.popup", { this._trigger( "open", event ); }, - _close: function( event ) { + close: function( event ) { this.element .hide() .attr( "aria-hidden", true ) From 018590064f43c4003fe7be767f5c1d666e38b22a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Wed, 4 May 2011 11:20:04 +0200 Subject: [PATCH 12/59] Popup: Prevent SPACE key event on trigger from scrolling the page --- tests/visual/menu/popup.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/visual/menu/popup.js b/tests/visual/menu/popup.js index 503bb93b7e..a299048772 100644 --- a/tests/visual/menu/popup.js +++ b/tests/visual/menu/popup.js @@ -37,6 +37,12 @@ $.widget( "ui.popup", { this.close(); this._bind(this.options.trigger, { + keydown: function( event ) { + // prevent space-to-open to scroll the page + if (event.keyCode == $.ui.keyCode.SPACE) { + event.preventDefault() + } + }, click: function( event ) { event.preventDefault(); if (this.open) { From c7459df0622e8d1a4e5fcb56eac496eae60e5083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Wed, 4 May 2011 11:21:30 +0200 Subject: [PATCH 13/59] Popup: Also expose open method --- tests/visual/menu/popup.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/visual/menu/popup.js b/tests/visual/menu/popup.js index a299048772..dc81b694c6 100644 --- a/tests/visual/menu/popup.js +++ b/tests/visual/menu/popup.js @@ -51,7 +51,7 @@ $.widget( "ui.popup", { } var that = this; setTimeout(function() { - that._open( event ); + that.open( event ); }, 1); } }); @@ -101,7 +101,7 @@ $.widget( "ui.popup", { } }, - _open: function( event ) { + open: function( event ) { var position = $.extend( {}, { of: this.options.trigger }, this.options.position ); From fd1b4f84feb92b5e0684b3fb66ccc0a57caafaab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Wed, 4 May 2011 11:50:07 +0200 Subject: [PATCH 14/59] Menubar: Code formatting. A bit of cleanup: Replace self with that; replace an unnecessary each. --- tests/visual/menu/menubar.js | 288 +++++++++++++++++++---------------- 1 file changed, 153 insertions(+), 135 deletions(-) diff --git a/tests/visual/menu/menubar.js b/tests/visual/menu/menubar.js index a8265e69bf..b9abacb9bb 100644 --- a/tests/visual/menu/menubar.js +++ b/tests/visual/menu/menubar.js @@ -3,242 +3,260 @@ * * TODO move to jquery.ui.menubar.js */ -(function($) { +(function( $ ) { -// TODO code formatting -$.widget("ui.menubar", { +// TODO when mixing clicking menus and keyboard navigation, focus handling is broken +// there has to be just one item that has tabindex +$.widget( "ui.menubar", { options: { buttons: false, menuIcon: false }, _create: function() { - var self = this; - var items = this.items = this.element.children("li") - .addClass("ui-menubar-item") - .attr("role", "presentation") - .children("button, a"); - items.slice(1).attr("tabIndex", -1); - var o = this.options; - - this.element.addClass('ui-menubar ui-widget-header ui-helper-clearfix').attr("role", "menubar"); - this._focusable(items); - this._hoverable(items); - // TODO elm is used just once, so the each probably isn't nedded anymore - items.next("ul").each(function(i, elm) { - $(elm).menu({ - select: function(event, ui) { - ui.item.parents("ul.ui-menu:last").hide(); - self._trigger( "select", event, ui ); - self._close(); + var that = this; + var items = this.items = this.element.children( "li" ) + .addClass( "ui-menubar-item" ) + .attr( "role", "presentation" ) + .children( "button, a" ); + // let only the first item receive focus + items.slice(1).attr( "tabIndex", -1 ); + + this.element + .addClass( "ui-menubar ui-widget-header ui-helper-clearfix" ) + .attr( "role", "menubar" ); + this._focusable( items ); + this._hoverable( items ); + items.next( "ul" ) + .menu({ + select: function( event, ui ) { + ui.item.parents( "ul.ui-menu:last" ).hide(); + that._trigger( "select", event, ui ); + that._close(); // TODO what is this targetting? there's probably a better way to access it $(event.target).prev().focus(); } - }).hide() - .attr("aria-hidden", "true") - .attr("aria-expanded", "false") - .keydown(function(event) { - var menu = $(this); - if (menu.is(":hidden")) + }) + .hide() + .attr( "aria-hidden", "true" ) + .attr( "aria-expanded", "false" ) + .bind( "keydown.menubar", function( event ) { + var menu = $( this ); + if ( menu.is( ":hidden" ) ) return; - switch (event.keyCode) { + switch ( event.keyCode ) { case $.ui.keyCode.LEFT: - self._left(event); + that._left( event ); event.preventDefault(); break; case $.ui.keyCode.RIGHT: - self._right(event); + that._right( event ); event.preventDefault(); break; }; - }) - }); + }); items.each(function() { var input = $(this), - menu = input.next("ul"); + // TODO menu var is only used on two places, doesn't quite justify the .each + menu = input.next( "ul" ); - input.bind("click focus mouseenter", function(event) { + input.bind( "click.menubar focus.menubar mouseenter.menubar", function( event ) { // ignore triggered focus event - if (event.type == "focus" && !event.originalEvent) { + if ( event.type == "focus" && !event.originalEvent ) { return; } event.preventDefault(); // TODO can we simplify or extractthis check? especially the last two expressions // there's a similar active[0] == menu[0] check in _open - if (event.type == "click" && menu.is(":visible") && self.active && self.active[0] == menu[0]) { - self._close(); + if ( event.type == "click" && menu.is( ":visible" ) && that.active && that.active[0] == menu[0] ) { + that._close(); return; } - if ((self.open && event.type == "mouseenter") || event.type == "click") { - self._open(event, menu); - } + if ( ( that.open && event.type == "mouseenter" ) || event.type == "click" ) { + that._open( event, menu ); + } }) .bind( "keydown", function( event ) { switch ( event.keyCode ) { case $.ui.keyCode.SPACE: case $.ui.keyCode.UP: case $.ui.keyCode.DOWN: - self._open( event, $( this ).next() ); + that._open( event, $( this ).next() ); event.preventDefault(); break; case $.ui.keyCode.LEFT: - self._prev( event, $( this ) ); + that._prev( event, $( this ) ); event.preventDefault(); break; case $.ui.keyCode.RIGHT: - self._next( event, $( this ) ); + that._next( event, $( this ) ); event.preventDefault(); break; } }) - .addClass("ui-button ui-widget ui-button-text-only ui-menubar-link") - .attr("role", "menuitem") - .attr("aria-haspopup", "true") - .wrapInner(""); + .addClass( "ui-button ui-widget ui-button-text-only ui-menubar-link" ) + .attr( "role", "menuitem" ) + .attr( "aria-haspopup", "true" ) + .wrapInner( "" ); // TODO review if these options are a good choice, maybe they can be merged - if (o.menuIcon) { - input.addClass("ui-state-default").append(""); - input.removeClass("ui-button-text-only").addClass("ui-button-text-icon-secondary"); + if ( that.options.menuIcon ) { + input.addClass( "ui-state-default" ).append( "" ); + input.removeClass( "ui-button-text-only" ).addClass( "ui-button-text-icon-secondary" ); } - if (!o.buttons) { + if ( !that.options.buttons ) { // TODO ui-menubar-link is added above, not needed here? - input.addClass('ui-menubar-link').removeClass('ui-state-default'); + input.addClass( "ui-menubar-link" ).removeClass( "ui-state-default" ); }; }); - self._bind({ - keydown: function(event) { - // TODO merge the two ifs - if (event.keyCode == $.ui.keyCode.ESCAPE) { - if (self.active && self.active.menu("left", event) !== true) { - var active = self.active; - self.active.blur(); - self._close( event ); - active.prev().focus(); - } + that._bind( { + keydown: function( event ) { + if ( event.keyCode == $.ui.keyCode.ESCAPE && that.active && that.active.menu( "left", event ) !== true ) { + var active = that.active; + that.active.blur(); + that._close( event ); + active.prev().focus(); } }, - focusout : function( event ) { - self.closeTimer = setTimeout(function() { - self._close( event ); - }, 100); + focusin: function( event ) { + clearTimeout( that.closeTimer ); }, - // TODO change order, focusin first - focusin :function( event ) { - clearTimeout(self.closeTimer); + focusout: function( event ) { + that.closeTimer = setTimeout( function() { + that._close( event ); + }, 100); } }); }, _destroy : function() { - var items = this.element.children("li") - .removeClass("ui-menubar-item") - .removeAttr("role", "presentation") - .children("button, a"); + var items = this.element.children( "li" ) + .removeClass( "ui-menubar-item" ) + .removeAttr( "role", "presentation" ) + .children( "button, a" ); - this.element.removeClass('ui-menubar ui-widget-header ui-helper-clearfix').removeAttr("role", "menubar").unbind(".menubar");; - items.unbind("focusin focusout click focus mouseenter keydown"); + this.element + .removeClass( "ui-menubar ui-widget-header ui-helper-clearfix" ) + .removeAttr( "role", "menubar" ) + .unbind( ".menubar" ); items - .removeClass("ui-button ui-widget ui-button-text-only ui-menubar-link ui-state-default") - .removeAttr("role", "menuitem") - .removeAttr("aria-haspopup", "true") - .children("span.ui-button-text").each(function(i, e) { - var item = $(this); - item.parent().html(item.html()); + .unbind( ".menubar" ) + .removeClass( "ui-button ui-widget ui-button-text-only ui-menubar-link ui-state-default" ) + .removeAttr( "role", "menuitem" ) + .removeAttr( "aria-haspopup", "true" ) + // TODO unwrap? + .children( "span.ui-button-text" ).each(function( i, e ) { + var item = $( this ); + item.parent().html( item.html() ); }) .end() - .children(".ui-icon").remove(); + .children( ".ui-icon" ).remove(); - $(document).unbind(".menubar"); - - this.element.find(":ui-menu").menu("destroy") - .show() - .removeAttr("aria-hidden", "true") - .removeAttr("aria-expanded", "false") - .removeAttr("tabindex") - .unbind("keydown", "blur"); + this.element.find( ":ui-menu" ) + .menu( "destroy" ) + .show() + .removeAttr( "aria-hidden", "true" ) + .removeAttr( "aria-expanded", "false" ) + .removeAttr( "tabindex" ) + .unbind( ".menubar" ); }, _close: function() { - if (!this.active || !this.active.length) + if ( !this.active || !this.active.length ) return; - this.active.menu("closeAll").hide().attr("aria-hidden", "true").attr("aria-expanded", "false"); - this.active.prev().removeClass("ui-state-active").removeAttr("tabIndex"); + this.active + .menu( "closeAll" ) + .hide() + .attr( "aria-hidden", "true" ) + .attr( "aria-expanded", "false" ); + this.active + .prev() + .removeClass( "ui-state-active" ) + .removeAttr( "tabIndex" ); this.active = null; this.open = false; }, - _open: function(event, menu) { + _open: function( event, menu ) { // on a single-button menubar, ignore reopening the same menu - if (this.active && this.active[0] == menu[0]) { + if ( this.active && this.active[0] == menu[0] ) { return; } - // almost the same as _close above, but don't remove tabIndex - if (this.active) { - this.active.menu("closeAll").hide().attr("aria-hidden", "true").attr("aria-expanded", "false"); - this.active.prev().removeClass("ui-state-active"); + // TODO refactor, almost the same as _close above, but don't remove tabIndex + if ( this.active ) { + this.active + .menu( "closeAll" ) + .hide() + .attr( "aria-hidden", "true" ) + .attr( "aria-expanded", "false" ); + this.active + .prev() + .removeClass( "ui-state-active" ); } // set tabIndex -1 to have the button skipped on shift-tab when menu is open (it gets focus) - var button = menu.prev().addClass("ui-state-active").attr("tabIndex", -1); - this.active = menu.show().position({ - my: "left top", - at: "left bottom", - of: button - }) - .removeAttr("aria-hidden").attr("aria-expanded", "true") - .menu("focus", event, menu.children("li").first()) - // TODO need a comment here why both events are triggered - .focus() - .focusin(); + var button = menu.prev().addClass( "ui-state-active" ).attr( "tabIndex", -1 ); + this.active = menu + .show() + .position( { + my: "left top", + at: "left bottom", + of: button + }) + .removeAttr( "aria-hidden" ) + .attr( "aria-expanded", "true" ) + .menu("focus", event, menu.children( "li" ).first() ) + // TODO need a comment here why both events are triggered + .focus() + .focusin(); this.open = true; }, // TODO refactor this and the next three methods _prev: function( event, button ) { - button.attr("tabIndex", -1); - var prev = button.parent().prevAll("li").children( ".ui-button" ).eq( 0 ); - if (prev.length) { - prev.removeAttr("tabIndex")[0].focus(); + button.attr( "tabIndex", -1 ); + var prev = button.parent().prevAll( "li" ).children( ".ui-button" ).eq( 0 ); + if ( prev.length ) { + prev.removeAttr( "tabIndex" )[0].focus(); } else { - var lastItem = this.element.children("li:last").children(".ui-button:last"); - lastItem.removeAttr("tabIndex")[0].focus(); + var lastItem = this.element.children( "li:last" ).children( ".ui-button:last" ); + lastItem.removeAttr( "tabIndex" )[0].focus(); } }, _next: function( event, button ) { - button.attr("tabIndex", -1); - var next = button.parent().nextAll("li").children( ".ui-button" ).eq( 0 ); - if (next.length) { - next.removeAttr("tabIndex")[0].focus(); + button.attr( "tabIndex", -1 ); + var next = button.parent().nextAll( "li" ).children( ".ui-button" ).eq( 0 ); + if ( next.length ) { + next.removeAttr( "tabIndex")[0].focus(); } else { - var firstItem = this.element.children("li:first").children(".ui-button:first"); - firstItem.removeAttr("tabIndex")[0].focus(); + var firstItem = this.element.children( "li:first" ).children( ".ui-button:first" ); + firstItem.removeAttr( "tabIndex" )[0].focus(); } }, // TODO rename to parent - _left: function(event) { - var prev = this.active.parent().prevAll("li:eq(0)").children( ".ui-menu" ).eq( 0 ); - if (prev.length) { - this._open(event, prev); + _left: function( event ) { + var prev = this.active.parent().prevAll( "li:eq(0)" ).children( ".ui-menu" ).eq( 0 ); + if ( prev.length ) { + this._open( event, prev ); } else { - var lastItem = this.element.children("li:last").children(".ui-menu:first"); - this._open(event, lastItem); + var lastItem = this.element.children( "li:last" ).children( ".ui-menu:first" ); + this._open( event, lastItem ); } }, // TODO rename to child (or something like that) - _right: function(event) { - var next = this.active.parent().nextAll("li:eq(0)").children( ".ui-menu" ).eq( 0 ); - if (next.length) { - this._open(event, next); + _right: function( event ) { + var next = this.active.parent().nextAll( "li:eq(0)" ).children( ".ui-menu" ).eq( 0 ); + if ( next.length ) { + this._open( event, next ); } else { - var firstItem = this.element.children("li:first").children(".ui-menu:first"); - this._open(event, firstItem); + var firstItem = this.element.children( "li:first" ).children( ".ui-menu:first" ); + this._open( event, firstItem ); } } }); -}(jQuery)); +}( jQuery )); From fc97ccd398b60525fd9e4c0e9aa1f51048984394 Mon Sep 17 00:00:00 2001 From: Kato Kazuyoshi Date: Thu, 5 May 2011 04:07:43 +0900 Subject: [PATCH 15/59] Datepicker: Remove old "ui-datepicker-multi-N" before add new one. Fixed #6704 - Display overflow when multiple datepickers have different numberOfMonths. --- tests/unit/datepicker/datepicker_core.js | 8 ++++++++ ui/jquery.ui.datepicker.js | 3 +-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/unit/datepicker/datepicker_core.js b/tests/unit/datepicker/datepicker_core.js index 78f78ce388..badb837ed8 100644 --- a/tests/unit/datepicker/datepicker_core.js +++ b/tests/unit/datepicker/datepicker_core.js @@ -116,8 +116,16 @@ test('baseStructure', function() { ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-last'), 'Structure multi [2] - second month division'); child = dp.children(':eq(2)'); ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2] - row break'); + ok(dp.is('.ui-datepicker-multi-2'), 'Structure multi [2] - multi-2'); inp.datepicker('hide').datepicker('destroy'); + // Multi-month 3 + inp = init('#inp', {numberOfMonths: 3}); + inp.focus(); + ok(dp.is('.ui-datepicker-multi-3'), 'Structure multi [3] - multi-3'); + ok(! dp.is('.ui-datepicker-multi-2'), 'Structure multi [3] - Trac #6704'); + inp.datepicker('hide').datepicker('destroy'); + // Multi-month [2, 2] inp = init('#inp', {numberOfMonths: [2, 2]}); inp.focus(); diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index 3437d0bda5..aa9caec8ce 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -685,10 +685,9 @@ $.extend(Datepicker.prototype, { var numMonths = this._getNumberOfMonths(inst); var cols = numMonths[1]; var width = 17; + inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width(''); if (cols > 1) inst.dpDiv.addClass('ui-datepicker-multi-' + cols).css('width', (width * cols) + 'em'); - else - inst.dpDiv.removeClass('ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4').width(''); inst.dpDiv[(numMonths[0] != 1 || numMonths[1] != 1 ? 'add' : 'remove') + 'Class']('ui-datepicker-multi'); inst.dpDiv[(this._get(inst, 'isRTL') ? 'add' : 'remove') + From a891e81e06c7ce491ae9058aea2fa7fbd51eddb6 Mon Sep 17 00:00:00 2001 From: Kato Kazuyoshi Date: Thu, 5 May 2011 05:06:27 +0900 Subject: [PATCH 16/59] Datepicker: Greedy matching in month name. Fixed #7062 - $.datepicker.parseDate does not work for some locale date strings. --- tests/unit/datepicker/datepicker.html | 1 + tests/unit/datepicker/datepicker_options.js | 4 ++++ ui/jquery.ui.datepicker.js | 24 +++++++++++++++------ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/tests/unit/datepicker/datepicker.html b/tests/unit/datepicker/datepicker.html index 76082e7801..fa346c6c91 100644 --- a/tests/unit/datepicker/datepicker.html +++ b/tests/unit/datepicker/datepicker.html @@ -12,6 +12,7 @@ + diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index 4f1e9a1646..a10d1ea454 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -827,6 +827,10 @@ test('parseDate', function() { equalsDate($.datepicker.parseDate('\'jour\' d \'de\' MM (\'\'DD\'\'), yy', 'jour 9 de Avril (\'Lundi\'), 2001', settings), new Date(2001, 4 - 1, 9), 'Parse date \'jour\' d \'de\' MM (\'\'DD\'\'), yy with settings'); + + var zh = $.datepicker.regional['zh-CN']; + equalsDate($.datepicker.parseDate('yy M d', '2011 十一 22', zh), + new Date(2011, 11 - 1, 22), 'Parse date yy M d with zh-CN'); }); test('parseDateErrors', function() { diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index 3437d0bda5..d49fb7781a 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -996,14 +996,24 @@ $.extend(Datepicker.prototype, { }; // Extract a name from the string value and convert to an index var getName = function(match, shortNames, longNames) { - var names = (lookAhead(match) ? longNames : shortNames); - for (var i = 0; i < names.length; i++) { - if (value.substr(iValue, names[i].length).toLowerCase() == names[i].toLowerCase()) { - iValue += names[i].length; - return i + 1; + var names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) { + return [ [k, v] ]; + }).sort(function (a, b) { + return -(a[1].length - b[1].length); + }); + var index = -1; + $.each(names, function (i, pair) { + var name = pair[1]; + if (value.substr(iValue, name.length).toLowerCase() == name.toLowerCase()) { + index = pair[0]; + iValue += name.length; + return false; } - } - throw 'Unknown name at position ' + iValue; + }); + if (index != -1) + return index + 1; + else + throw 'Unknown name at position ' + iValue; }; // Confirm that a literal character matches the string value var checkLiteral = function() { From f505de68fd7a0f8be70b0ccf97bb9b75b610d8e6 Mon Sep 17 00:00:00 2001 From: Kato Kazuyoshi Date: Thu, 5 May 2011 05:29:13 +0900 Subject: [PATCH 17/59] Datepicker: Remove BOM. Fixed #6734 - Datepicker i18n: Problem with JavascriptPacker. --- ui/i18n/jquery.ui.datepicker-af.js | 2 +- ui/i18n/jquery.ui.datepicker-ar.js | 2 +- ui/i18n/jquery.ui.datepicker-az.js | 2 +- ui/i18n/jquery.ui.datepicker-bg.js | 2 +- ui/i18n/jquery.ui.datepicker-bs.js | 2 +- ui/i18n/jquery.ui.datepicker-cs.js | 2 +- ui/i18n/jquery.ui.datepicker-da.js | 2 +- ui/i18n/jquery.ui.datepicker-de.js | 2 +- ui/i18n/jquery.ui.datepicker-el.js | 2 +- ui/i18n/jquery.ui.datepicker-en-GB.js | 2 +- ui/i18n/jquery.ui.datepicker-eo.js | 2 +- ui/i18n/jquery.ui.datepicker-et.js | 2 +- ui/i18n/jquery.ui.datepicker-eu.js | 2 +- ui/i18n/jquery.ui.datepicker-fa.js | 2 +- ui/i18n/jquery.ui.datepicker-fo.js | 2 +- ui/i18n/jquery.ui.datepicker-fr-CH.js | 2 +- ui/i18n/jquery.ui.datepicker-fr.js | 2 +- ui/i18n/jquery.ui.datepicker-he.js | 2 +- ui/i18n/jquery.ui.datepicker-hr.js | 2 +- ui/i18n/jquery.ui.datepicker-ja.js | 2 +- ui/i18n/jquery.ui.datepicker-ml.js | 2 +- ui/i18n/jquery.ui.datepicker-nl.js | 2 +- ui/i18n/jquery.ui.datepicker-ro.js | 2 +- ui/i18n/jquery.ui.datepicker-sq.js | 2 +- ui/i18n/jquery.ui.datepicker-sr-SR.js | 2 +- ui/i18n/jquery.ui.datepicker-sr.js | 2 +- ui/i18n/jquery.ui.datepicker-sv.js | 2 +- ui/i18n/jquery.ui.datepicker-ta.js | 2 +- ui/i18n/jquery.ui.datepicker-th.js | 2 +- ui/i18n/jquery.ui.datepicker-vi.js | 2 +- ui/i18n/jquery.ui.datepicker-zh-TW.js | 2 +- 31 files changed, 31 insertions(+), 31 deletions(-) diff --git a/ui/i18n/jquery.ui.datepicker-af.js b/ui/i18n/jquery.ui.datepicker-af.js index 43fbf6cd8e..0922ef7a1c 100644 --- a/ui/i18n/jquery.ui.datepicker-af.js +++ b/ui/i18n/jquery.ui.datepicker-af.js @@ -1,4 +1,4 @@ -/* Afrikaans initialisation for the jQuery UI date picker plugin. */ +/* Afrikaans initialisation for the jQuery UI date picker plugin. */ /* Written by Renier Pretorius. */ jQuery(function($){ $.datepicker.regional['af'] = { diff --git a/ui/i18n/jquery.ui.datepicker-ar.js b/ui/i18n/jquery.ui.datepicker-ar.js index db57735584..f24b3ff5a1 100644 --- a/ui/i18n/jquery.ui.datepicker-ar.js +++ b/ui/i18n/jquery.ui.datepicker-ar.js @@ -1,4 +1,4 @@ -/* Arabic Translation for jQuery UI date picker plugin. */ +/* Arabic Translation for jQuery UI date picker plugin. */ /* 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($){ diff --git a/ui/i18n/jquery.ui.datepicker-az.js b/ui/i18n/jquery.ui.datepicker-az.js index 0f60a7e1d0..1101c8b91b 100644 --- a/ui/i18n/jquery.ui.datepicker-az.js +++ b/ui/i18n/jquery.ui.datepicker-az.js @@ -1,4 +1,4 @@ -/* Azerbaijani (UTF-8) initialisation for the jQuery UI date picker plugin. */ +/* Azerbaijani (UTF-8) initialisation for the jQuery UI date picker plugin. */ /* Written by Jamil Najafov (necefov33@gmail.com). */ jQuery(function($) { $.datepicker.regional['az'] = { diff --git a/ui/i18n/jquery.ui.datepicker-bg.js b/ui/i18n/jquery.ui.datepicker-bg.js index ae850ef807..4e0ee2f509 100644 --- a/ui/i18n/jquery.ui.datepicker-bg.js +++ b/ui/i18n/jquery.ui.datepicker-bg.js @@ -1,4 +1,4 @@ -/* Bulgarian initialisation for the jQuery UI date picker plugin. */ +/* Bulgarian initialisation for the jQuery UI date picker plugin. */ /* Written by Stoyan Kyosev (http://svest.org). */ jQuery(function($){ $.datepicker.regional['bg'] = { diff --git a/ui/i18n/jquery.ui.datepicker-bs.js b/ui/i18n/jquery.ui.datepicker-bs.js index 7be269ab2e..d645737554 100644 --- a/ui/i18n/jquery.ui.datepicker-bs.js +++ b/ui/i18n/jquery.ui.datepicker-bs.js @@ -1,4 +1,4 @@ -/* Bosnian i18n for the jQuery UI date picker plugin. */ +/* Bosnian i18n for the jQuery UI date picker plugin. */ /* Written by Kenan Konjo. */ jQuery(function($){ $.datepicker.regional['bs'] = { diff --git a/ui/i18n/jquery.ui.datepicker-cs.js b/ui/i18n/jquery.ui.datepicker-cs.js index 115b8c0e1a..bf56baf01e 100644 --- a/ui/i18n/jquery.ui.datepicker-cs.js +++ b/ui/i18n/jquery.ui.datepicker-cs.js @@ -1,4 +1,4 @@ -/* Czech initialisation for the jQuery UI date picker plugin. */ +/* Czech initialisation for the jQuery UI date picker plugin. */ /* Written by Tomas Muller (tomas@tomas-muller.net). */ jQuery(function($){ $.datepicker.regional['cs'] = { diff --git a/ui/i18n/jquery.ui.datepicker-da.js b/ui/i18n/jquery.ui.datepicker-da.js index 6d2ddee59e..fb2d3356d7 100644 --- a/ui/i18n/jquery.ui.datepicker-da.js +++ b/ui/i18n/jquery.ui.datepicker-da.js @@ -1,4 +1,4 @@ -/* Danish initialisation for the jQuery UI date picker plugin. */ +/* Danish initialisation for the jQuery UI date picker plugin. */ /* Written by Jan Christensen ( deletestuff@gmail.com). */ jQuery(function($){ $.datepicker.regional['da'] = { diff --git a/ui/i18n/jquery.ui.datepicker-de.js b/ui/i18n/jquery.ui.datepicker-de.js index 56203ed7ae..52d6c82ce9 100644 --- a/ui/i18n/jquery.ui.datepicker-de.js +++ b/ui/i18n/jquery.ui.datepicker-de.js @@ -1,4 +1,4 @@ -/* German initialisation for the jQuery UI date picker plugin. */ +/* German initialisation for the jQuery UI date picker plugin. */ /* Written by Milian Wolff (mail@milianw.de). */ jQuery(function($){ $.datepicker.regional['de'] = { diff --git a/ui/i18n/jquery.ui.datepicker-el.js b/ui/i18n/jquery.ui.datepicker-el.js index 9542769d9a..6d775f995f 100644 --- a/ui/i18n/jquery.ui.datepicker-el.js +++ b/ui/i18n/jquery.ui.datepicker-el.js @@ -1,4 +1,4 @@ -/* Greek (el) initialisation for the jQuery UI date picker plugin. */ +/* Greek (el) initialisation for the jQuery UI date picker plugin. */ /* Written by Alex Cicovic (http://www.alexcicovic.com) */ jQuery(function($){ $.datepicker.regional['el'] = { diff --git a/ui/i18n/jquery.ui.datepicker-en-GB.js b/ui/i18n/jquery.ui.datepicker-en-GB.js index aac7b6195c..16a096e758 100644 --- a/ui/i18n/jquery.ui.datepicker-en-GB.js +++ b/ui/i18n/jquery.ui.datepicker-en-GB.js @@ -1,4 +1,4 @@ -/* English/UK initialisation for the jQuery UI date picker plugin. */ +/* English/UK initialisation for the jQuery UI date picker plugin. */ /* Written by Stuart. */ jQuery(function($){ $.datepicker.regional['en-GB'] = { diff --git a/ui/i18n/jquery.ui.datepicker-eo.js b/ui/i18n/jquery.ui.datepicker-eo.js index 7201a2c9f9..39e44fc57c 100644 --- a/ui/i18n/jquery.ui.datepicker-eo.js +++ b/ui/i18n/jquery.ui.datepicker-eo.js @@ -1,4 +1,4 @@ -/* Esperanto initialisation for the jQuery UI date picker plugin. */ +/* Esperanto initialisation for the jQuery UI date picker plugin. */ /* Written by Olivier M. (olivierweb@ifrance.com). */ jQuery(function($){ $.datepicker.regional['eo'] = { diff --git a/ui/i18n/jquery.ui.datepicker-et.js b/ui/i18n/jquery.ui.datepicker-et.js index f97311f31a..92f81f6378 100644 --- a/ui/i18n/jquery.ui.datepicker-et.js +++ b/ui/i18n/jquery.ui.datepicker-et.js @@ -1,4 +1,4 @@ -/* Estonian initialisation for the jQuery UI date picker plugin. */ +/* Estonian initialisation for the jQuery UI date picker plugin. */ /* Written by Mart Sõmermaa (mrts.pydev at gmail com). */ jQuery(function($){ $.datepicker.regional['et'] = { diff --git a/ui/i18n/jquery.ui.datepicker-eu.js b/ui/i18n/jquery.ui.datepicker-eu.js index 5eaace8801..4c40eebec6 100644 --- a/ui/i18n/jquery.ui.datepicker-eu.js +++ b/ui/i18n/jquery.ui.datepicker-eu.js @@ -1,4 +1,4 @@ -/* Euskarako oinarria 'UI date picker' jquery-ko extentsioarentzat */ +/* Euskarako oinarria 'UI date picker' jquery-ko extentsioarentzat */ /* Karrikas-ek itzulia (karrikas@karrikas.com) */ jQuery(function($){ $.datepicker.regional['eu'] = { diff --git a/ui/i18n/jquery.ui.datepicker-fa.js b/ui/i18n/jquery.ui.datepicker-fa.js index c3252a5489..1d7fbd23c7 100644 --- a/ui/i18n/jquery.ui.datepicker-fa.js +++ b/ui/i18n/jquery.ui.datepicker-fa.js @@ -1,4 +1,4 @@ -/* Persian (Farsi) Translation for the jQuery UI date picker plugin. */ +/* Persian (Farsi) Translation for the jQuery UI date picker plugin. */ /* Javad Mowlanezhad -- jmowla@gmail.com */ /* Jalali calendar should supported soon! (Its implemented but I have to test it) */ jQuery(function($) { diff --git a/ui/i18n/jquery.ui.datepicker-fo.js b/ui/i18n/jquery.ui.datepicker-fo.js index 2548df8361..9c848a04be 100644 --- a/ui/i18n/jquery.ui.datepicker-fo.js +++ b/ui/i18n/jquery.ui.datepicker-fo.js @@ -1,4 +1,4 @@ -/* Faroese initialisation for the jQuery UI date picker plugin */ +/* Faroese initialisation for the jQuery UI date picker plugin */ /* Written by Sverri Mohr Olsen, sverrimo@gmail.com */ jQuery(function($){ $.datepicker.regional['fo'] = { diff --git a/ui/i18n/jquery.ui.datepicker-fr-CH.js b/ui/i18n/jquery.ui.datepicker-fr-CH.js index 04f9b033ee..fec03a042f 100644 --- a/ui/i18n/jquery.ui.datepicker-fr-CH.js +++ b/ui/i18n/jquery.ui.datepicker-fr-CH.js @@ -1,4 +1,4 @@ -/* Swiss-French initialisation for the jQuery UI date picker plugin. */ +/* Swiss-French initialisation for the jQuery UI date picker plugin. */ /* Written Martin Voelkle (martin.voelkle@e-tc.ch). */ jQuery(function($){ $.datepicker.regional['fr-CH'] = { diff --git a/ui/i18n/jquery.ui.datepicker-fr.js b/ui/i18n/jquery.ui.datepicker-fr.js index 74ea1c231a..7e793639f5 100644 --- a/ui/i18n/jquery.ui.datepicker-fr.js +++ b/ui/i18n/jquery.ui.datepicker-fr.js @@ -1,4 +1,4 @@ -/* French initialisation for the jQuery UI date picker plugin. */ +/* French initialisation for the jQuery UI date picker plugin. */ /* Written by Keith Wood (kbwood{at}iinet.com.au), Stéphane Nahmani (sholby@sholby.net), Stéphane Raimbault */ diff --git a/ui/i18n/jquery.ui.datepicker-he.js b/ui/i18n/jquery.ui.datepicker-he.js index 429a11c2cb..58ea8c6d8d 100644 --- a/ui/i18n/jquery.ui.datepicker-he.js +++ b/ui/i18n/jquery.ui.datepicker-he.js @@ -1,4 +1,4 @@ -/* Hebrew initialisation for the UI Datepicker extension. */ +/* Hebrew initialisation for the UI Datepicker extension. */ /* Written by Amir Hardon (ahardon at gmail dot com). */ jQuery(function($){ $.datepicker.regional['he'] = { diff --git a/ui/i18n/jquery.ui.datepicker-hr.js b/ui/i18n/jquery.ui.datepicker-hr.js index 61b7fccb13..6bc5aade12 100644 --- a/ui/i18n/jquery.ui.datepicker-hr.js +++ b/ui/i18n/jquery.ui.datepicker-hr.js @@ -1,4 +1,4 @@ -/* Croatian i18n for the jQuery UI date picker plugin. */ +/* Croatian i18n for the jQuery UI date picker plugin. */ /* Written by Vjekoslav Nesek. */ jQuery(function($){ $.datepicker.regional['hr'] = { diff --git a/ui/i18n/jquery.ui.datepicker-ja.js b/ui/i18n/jquery.ui.datepicker-ja.js index ab9243bbd6..afd2983157 100644 --- a/ui/i18n/jquery.ui.datepicker-ja.js +++ b/ui/i18n/jquery.ui.datepicker-ja.js @@ -1,4 +1,4 @@ -/* Japanese initialisation for the jQuery UI date picker plugin. */ +/* Japanese initialisation for the jQuery UI date picker plugin. */ /* Written by Kentaro SATO (kentaro@ranvis.com). */ jQuery(function($){ $.datepicker.regional['ja'] = { diff --git a/ui/i18n/jquery.ui.datepicker-ml.js b/ui/i18n/jquery.ui.datepicker-ml.js index 753dba411d..1e3432c0a8 100644 --- a/ui/i18n/jquery.ui.datepicker-ml.js +++ b/ui/i18n/jquery.ui.datepicker-ml.js @@ -1,4 +1,4 @@ -/* Malayalam (UTF-8) initialisation for the jQuery UI date picker plugin. */ +/* Malayalam (UTF-8) initialisation for the jQuery UI date picker plugin. */ /* Written by Saji Nediyanchath (saji89@gmail.com). */ jQuery(function($){ $.datepicker.regional['ml'] = { diff --git a/ui/i18n/jquery.ui.datepicker-nl.js b/ui/i18n/jquery.ui.datepicker-nl.js index 40be2cfa41..09634088b6 100644 --- a/ui/i18n/jquery.ui.datepicker-nl.js +++ b/ui/i18n/jquery.ui.datepicker-nl.js @@ -1,4 +1,4 @@ -/* Dutch (UTF-8) initialisation for the jQuery UI date picker plugin. */ +/* Dutch (UTF-8) initialisation for the jQuery UI date picker plugin. */ /* Written by Mathias Bynens */ jQuery(function($){ $.datepicker.regional.nl = { diff --git a/ui/i18n/jquery.ui.datepicker-ro.js b/ui/i18n/jquery.ui.datepicker-ro.js index 9016b67122..a988270d75 100644 --- a/ui/i18n/jquery.ui.datepicker-ro.js +++ b/ui/i18n/jquery.ui.datepicker-ro.js @@ -1,4 +1,4 @@ -/* Romanian initialisation for the jQuery UI date picker plugin. +/* Romanian initialisation for the jQuery UI date picker plugin. * * Written by Edmond L. (ll_edmond@walla.com) * and Ionut G. Stan (ionut.g.stan@gmail.com) diff --git a/ui/i18n/jquery.ui.datepicker-sq.js b/ui/i18n/jquery.ui.datepicker-sq.js index 52f8eee0cb..d6086a7896 100644 --- a/ui/i18n/jquery.ui.datepicker-sq.js +++ b/ui/i18n/jquery.ui.datepicker-sq.js @@ -1,4 +1,4 @@ -/* Albanian initialisation for the jQuery UI date picker plugin. */ +/* Albanian initialisation for the jQuery UI date picker plugin. */ /* Written by Flakron Bytyqi (flakron@gmail.com). */ jQuery(function($){ $.datepicker.regional['sq'] = { diff --git a/ui/i18n/jquery.ui.datepicker-sr-SR.js b/ui/i18n/jquery.ui.datepicker-sr-SR.js index 57ee8f24a4..6d5d042110 100644 --- a/ui/i18n/jquery.ui.datepicker-sr-SR.js +++ b/ui/i18n/jquery.ui.datepicker-sr-SR.js @@ -1,4 +1,4 @@ -/* Serbian i18n for the jQuery UI date picker plugin. */ +/* Serbian i18n for the jQuery UI date picker plugin. */ /* Written by Dejan Dimić. */ jQuery(function($){ $.datepicker.regional['sr-SR'] = { diff --git a/ui/i18n/jquery.ui.datepicker-sr.js b/ui/i18n/jquery.ui.datepicker-sr.js index 543dd0febe..d4e1d9af09 100644 --- a/ui/i18n/jquery.ui.datepicker-sr.js +++ b/ui/i18n/jquery.ui.datepicker-sr.js @@ -1,4 +1,4 @@ -/* Serbian i18n for the jQuery UI date picker plugin. */ +/* Serbian i18n for the jQuery UI date picker plugin. */ /* Written by Dejan Dimić. */ jQuery(function($){ $.datepicker.regional['sr'] = { diff --git a/ui/i18n/jquery.ui.datepicker-sv.js b/ui/i18n/jquery.ui.datepicker-sv.js index 05aab3308d..173689b2a9 100644 --- a/ui/i18n/jquery.ui.datepicker-sv.js +++ b/ui/i18n/jquery.ui.datepicker-sv.js @@ -1,4 +1,4 @@ -/* Swedish initialisation for the jQuery UI date picker plugin. */ +/* Swedish initialisation for the jQuery UI date picker plugin. */ /* Written by Anders Ekdahl ( anders@nomadiz.se). */ jQuery(function($){ $.datepicker.regional['sv'] = { diff --git a/ui/i18n/jquery.ui.datepicker-ta.js b/ui/i18n/jquery.ui.datepicker-ta.js index 91116d3877..40431ed8ec 100644 --- a/ui/i18n/jquery.ui.datepicker-ta.js +++ b/ui/i18n/jquery.ui.datepicker-ta.js @@ -1,4 +1,4 @@ -/* Tamil (UTF-8) initialisation for the jQuery UI date picker plugin. */ +/* Tamil (UTF-8) initialisation for the jQuery UI date picker plugin. */ /* Written by S A Sureshkumar (saskumar@live.com). */ jQuery(function($){ $.datepicker.regional['ta'] = { diff --git a/ui/i18n/jquery.ui.datepicker-th.js b/ui/i18n/jquery.ui.datepicker-th.js index f2122fc9f5..d57541f640 100644 --- a/ui/i18n/jquery.ui.datepicker-th.js +++ b/ui/i18n/jquery.ui.datepicker-th.js @@ -1,4 +1,4 @@ -/* Thai initialisation for the jQuery UI date picker plugin. */ +/* Thai initialisation for the jQuery UI date picker plugin. */ /* Written by pipo (pipo@sixhead.com). */ jQuery(function($){ $.datepicker.regional['th'] = { diff --git a/ui/i18n/jquery.ui.datepicker-vi.js b/ui/i18n/jquery.ui.datepicker-vi.js index 3ecf361973..b49e7eb130 100644 --- a/ui/i18n/jquery.ui.datepicker-vi.js +++ b/ui/i18n/jquery.ui.datepicker-vi.js @@ -1,4 +1,4 @@ -/* Vietnamese initialisation for the jQuery UI date picker plugin. */ +/* Vietnamese initialisation for the jQuery UI date picker plugin. */ /* Translated by Le Thanh Huy (lthanhhuy@cit.ctu.edu.vn). */ jQuery(function($){ $.datepicker.regional['vi'] = { diff --git a/ui/i18n/jquery.ui.datepicker-zh-TW.js b/ui/i18n/jquery.ui.datepicker-zh-TW.js index 3c58ea92d4..19702a65c9 100644 --- a/ui/i18n/jquery.ui.datepicker-zh-TW.js +++ b/ui/i18n/jquery.ui.datepicker-zh-TW.js @@ -1,4 +1,4 @@ -/* Chinese initialisation for the jQuery UI date picker plugin. */ +/* Chinese initialisation for the jQuery UI date picker plugin. */ /* Written by Ressol (ressol@gmail.com). */ jQuery(function($){ $.datepicker.regional['zh-TW'] = { From c73e40adbec6d3240e92b125e55eae38532ed359 Mon Sep 17 00:00:00 2001 From: gnarf Date: Wed, 4 May 2011 21:04:28 -0500 Subject: [PATCH 18/59] effects.tests: Adding 'size' effect to the visual effect tests --- tests/visual/effects.all.html | 6 ++++++ tests/visual/effects.all.js | 1 + 2 files changed, 7 insertions(+) diff --git a/tests/visual/effects.all.html b/tests/visual/effects.all.html index 1fc35f7009..5c2c418ae0 100644 --- a/tests/visual/effects.all.html +++ b/tests/visual/effects.all.html @@ -145,6 +145,12 @@
+
  • +
    +

    Size

    +
    +
  • +
  • Slide down

    diff --git a/tests/visual/effects.all.js b/tests/visual/effects.all.js index 3ac8968b3d..1c9c71efdb 100644 --- a/tests/visual/effects.all.js +++ b/tests/visual/effects.all.js @@ -61,6 +61,7 @@ $(function() { effect("#puff", "puff", { times: 2 }); effect("#scale", "scale", {}); + effect("#size", "size", { from: { width: 300, height: 300 }}); $("#shake").bind("click", function() { $(this).addClass("current").effect("shake", {}, 100, function() { $(this).removeClass("current"); }); }); From d4bdd19429b82acebf37772669b796cc84e1674a Mon Sep 17 00:00:00 2001 From: gnarf Date: Wed, 4 May 2011 23:40:16 -0500 Subject: [PATCH 19/59] effects.test: adding a test for size using toggle --- tests/visual/effects.all.html | 8 +++++++- tests/visual/effects.all.js | 21 +++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/tests/visual/effects.all.html b/tests/visual/effects.all.html index 5c2c418ae0..fed35de8ad 100644 --- a/tests/visual/effects.all.html +++ b/tests/visual/effects.all.html @@ -147,7 +147,13 @@
  • -

    Size

    +

    Size Default Show/Hide

    +
    +
  • + +
  • +
    +

    Size Toggle

  • diff --git a/tests/visual/effects.all.js b/tests/visual/effects.all.js index 1c9c71efdb..17e2c6448f 100644 --- a/tests/visual/effects.all.js +++ b/tests/visual/effects.all.js @@ -28,10 +28,10 @@ $(function() { var el = $(this); el.addClass("current").hide(duration, function() { setTimeout(function() { - el.show(duration, function() { el.removeClass("current") }); + el.show(duration, function() { el.removeClass("current"); }); }, wait); - }) - }) + }); + }); effect("#blindLeft", "blind", { direction: "left" }); effect("#blindUp", "blind", { direction: "up" }); @@ -61,7 +61,16 @@ $(function() { effect("#puff", "puff", { times: 2 }); effect("#scale", "scale", {}); - effect("#size", "size", { from: { width: 300, height: 300 }}); + effect("#size", "size", {}); + $("#sizeToggle").bind("click", function() { + var opts = { to: { width: 300, height: 300 }}; + $(this).addClass('current') + .toggle("size", opts, duration) + .delay(wait) + .toggle("size", opts, duration, function() { + $(this).removeClass("current"); + }); + }); $("#shake").bind("click", function() { $(this).addClass("current").effect("shake", {}, 100, function() { $(this).removeClass("current"); }); }); @@ -83,13 +92,13 @@ $(function() { $("#removeClass").click(function() { $(this).addClass("current").removeClass(function() { window.console && console.log(arguments); - return "current" + return "current"; }, duration); }); $("#toggleClass").click(function() { $(this).toggleClass(function() { window.console && console.log(arguments); - return "current" + return "current"; }, duration); }); }); From 993d37af1d04d586b8b977daf0da3588d63714d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Thu, 5 May 2011 14:20:56 +0200 Subject: [PATCH 20/59] Popup: Rename open flag to isOpen to avoid name conflict with open method. --- tests/visual/menu/popup.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/visual/menu/popup.js b/tests/visual/menu/popup.js index dc81b694c6..08088c994b 100644 --- a/tests/visual/menu/popup.js +++ b/tests/visual/menu/popup.js @@ -45,7 +45,7 @@ $.widget( "ui.popup", { }, click: function( event ) { event.preventDefault(); - if (this.open) { + if (this.isOpen) { // let it propagate to close return; } @@ -75,7 +75,7 @@ $.widget( "ui.popup", { this._bind(document, { click: function( event ) { - if (this.open && !$(event.target).closest(".ui-popup").length) { + if (this.isOpen && !$(event.target).closest(".ui-popup").length) { this.close( event ); } } @@ -116,7 +116,7 @@ $.widget( "ui.popup", { // take trigger out of tab order to allow shift-tab to skip trigger this.options.trigger.attr("tabindex", -1); - this.open = true; + this.isOpen = true; this._trigger( "open", event ); }, @@ -128,7 +128,7 @@ $.widget( "ui.popup", { this.options.trigger.attr("tabindex", 0); - this.open = false; + this.isOpen = false; this._trigger( "close", event ); } From a7f1659cdc99222a733ed2edbd7d00dc57c30227 Mon Sep 17 00:00:00 2001 From: Eike Send Date: Thu, 5 May 2011 14:45:06 +0200 Subject: [PATCH 21/59] Button: stop disabled button from firing click events. fixes #5945. Behavior was inconsisten between BUTTON and A elements. --- ui/jquery.ui.button.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index 5777d47539..031ac20912 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -103,6 +103,11 @@ $.widget( "ui.button", { }) .bind( "blur.button", function() { $( this ).removeClass( focusClass ); + }) + .bind( "click.button", function( event ) { + if ( options.disabled ) { + event.stopImmediatePropagation(); + } }); if ( toggleButton ) { From 88d8209fddf083c9a2eeb3ad47abf1bd5746aadb Mon Sep 17 00:00:00 2001 From: kborchers Date: Fri, 6 May 2011 10:40:43 -0500 Subject: [PATCH 22/59] Datepicker: Moved the setting of _datepickerShowing to after postProcess to prevent being able to tab away leaving the datepicker open. Fixed #6775 - DatePicker remains open when tabbing out --- ui/jquery.ui.datepicker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index 92c005d19a..12323672ab 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -648,7 +648,6 @@ $.extend(Datepicker.prototype, { var showAnim = $.datepicker._get(inst, 'showAnim'); var duration = $.datepicker._get(inst, 'duration'); var postProcess = function() { - $.datepicker._datepickerShowing = true; var cover = inst.dpDiv.find('iframe.ui-datepicker-cover'); // IE6- only if( !! cover.length ){ var borders = $.datepicker._getBorders(inst.dpDiv); @@ -657,6 +656,7 @@ $.extend(Datepicker.prototype, { } }; inst.dpDiv.zIndex($(input).zIndex()+1); + $.datepicker._datepickerShowing = true; // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) From d522dad71862c1633bae8281453936dea38c597f Mon Sep 17 00:00:00 2001 From: eddiemonge Date: Thu, 5 May 2011 15:51:48 -0700 Subject: [PATCH 23/59] Tabs: Removed executable file permissions. Fixes #7329 - Tabs doesn't need to have execute permissions. --- ui/jquery.ui.tabs.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 ui/jquery.ui.tabs.js diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js old mode 100755 new mode 100644 From 28017052a497c4fc62f6bb518e0f39e71ee034c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Fri, 6 May 2011 19:21:13 +0200 Subject: [PATCH 24/59] Popup: Fix the reopens-issue when clicking the trigger while popup is visible, while still handling an actualy blur properly. --- tests/visual/menu/popup.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/visual/menu/popup.js b/tests/visual/menu/popup.js index 08088c994b..a8238adb0d 100644 --- a/tests/visual/menu/popup.js +++ b/tests/visual/menu/popup.js @@ -39,6 +39,7 @@ $.widget( "ui.popup", { this._bind(this.options.trigger, { keydown: function( event ) { // prevent space-to-open to scroll the page + // TODO do this only for a:ui-button? if (event.keyCode == $.ui.keyCode.SPACE) { event.preventDefault() } @@ -50,6 +51,7 @@ $.widget( "ui.popup", { return; } var that = this; + clearTimeout( this.closeTimer ); setTimeout(function() { that.open( event ); }, 1); @@ -57,9 +59,14 @@ $.widget( "ui.popup", { }); this._bind(this.element, { - // TODO also triggered when open and clicking the trigger again - // figure out how to close in that case, while still closing on regular blur - //blur: "close" + blur: function( event ) { + var that = this; + // use a timer to allow click to clear it and letting that + // handle the closing instead of opening again + that.closeTimer = setTimeout( function() { + that.close( event ); + }, 100); + } }); this._bind({ From fbe982b9fbd7ac50fc08a8e539c7a7d9be5089b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Fri, 6 May 2011 19:28:18 +0200 Subject: [PATCH 25/59] Popup: If popup is a menu, focus the first menu item, as menubar does. --- tests/visual/menu/popup.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/visual/menu/popup.js b/tests/visual/menu/popup.js index a8238adb0d..a5e42a884a 100644 --- a/tests/visual/menu/popup.js +++ b/tests/visual/menu/popup.js @@ -120,6 +120,10 @@ $.widget( "ui.popup", { .position( position ) .focus(); + if (this.element.is(":ui-menu")) { + this.element.menu("focus", event, this.element.children( "li" ).first() ); + } + // take trigger out of tab order to allow shift-tab to skip trigger this.options.trigger.attr("tabindex", -1); From 2cf85da23fde6f067bf197f60b458d1afe78a6b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Fri, 6 May 2011 19:43:47 +0200 Subject: [PATCH 26/59] Popup/Tooltip: Fix tab order and add notifications (on select) in video-player demo. --- demos/tooltip/video-player.html | 63 +++++++++++++++++++++------------ tests/visual/menu/popup.js | 2 ++ 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/demos/tooltip/video-player.html b/demos/tooltip/video-player.html index 2e24197608..473c6a6a3c 100644 --- a/demos/tooltip/video-player.html +++ b/demos/tooltip/video-player.html @@ -14,25 +14,40 @@ + + + - - + diff --git a/tests/visual/menu/popup.html b/tests/visual/menu/popup.html index 2a712b00ab..de27208b48 100644 --- a/tests/visual/menu/popup.html +++ b/tests/visual/menu/popup.html @@ -10,7 +10,7 @@ - + diff --git a/tests/visual/menu/menubar.js b/ui/jquery.ui.menubar.js similarity index 95% rename from tests/visual/menu/menubar.js rename to ui/jquery.ui.menubar.js index b9abacb9bb..2879d079c0 100644 --- a/tests/visual/menu/menubar.js +++ b/ui/jquery.ui.menubar.js @@ -1,7 +1,17 @@ /* - * jQuery UI menubar - * - * TODO move to jquery.ui.menubar.js + * jQuery UI Menubar @VERSION + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Menubar + * + * Depends: + * jquery.ui.core.js + * jquery.ui.widget.js + * jquery.ui.position.js + * jquery.ui.menu.js */ (function( $ ) { diff --git a/tests/visual/menu/popup.js b/ui/jquery.ui.popup.js similarity index 93% rename from tests/visual/menu/popup.js rename to ui/jquery.ui.popup.js index 87a480741e..784e5c655b 100644 --- a/tests/visual/menu/popup.js +++ b/ui/jquery.ui.popup.js @@ -1,5 +1,16 @@ /* - * jQuery UI popup utility + * jQuery UI Popup @VERSION + * + * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Popup + * + * Depends: + * jquery.ui.core.js + * jquery.ui.widget.js + * jquery.ui.position.js */ (function($) { From 24c0d9195a3ae84bf6fe4698926fafafa55b2bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Sat, 7 May 2011 16:23:31 +0200 Subject: [PATCH 33/59] Popup: Fix keyboard handling to prevent scrolling on keydown --- ui/jquery.ui.popup.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/jquery.ui.popup.js b/ui/jquery.ui.popup.js index 784e5c655b..10361a35ca 100644 --- a/ui/jquery.ui.popup.js +++ b/ui/jquery.ui.popup.js @@ -60,6 +60,8 @@ $.widget( "ui.popup", { // translate keydown to click // opens popup and let's tooltip hide itself if ( event.keyCode == $.ui.keyCode.DOWN ) { + // prevent scrolling + event.preventDefault(); this.options.trigger.trigger( "click", event ); } }, From f7cf9228e5843ecf6e3bc23f33ceaca946c6023b Mon Sep 17 00:00:00 2001 From: itsadok Date: Sun, 8 May 2011 02:37:33 -0700 Subject: [PATCH 34/59] fix: delete runaway backslash --- demos/resizable/constrain-area.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/resizable/constrain-area.html b/demos/resizable/constrain-area.html index a7003352c0..33539f9400 100644 --- a/demos/resizable/constrain-area.html +++ b/demos/resizable/constrain-area.html @@ -10,7 +10,7 @@ - + +
    +
    Log: -
    +
    +
    + +
    + +

    TODO

    + +
    + diff --git a/demos/menubar/index.html b/demos/menubar/index.html new file mode 100644 index 0000000000..3eebda2d06 --- /dev/null +++ b/demos/menubar/index.html @@ -0,0 +1,16 @@ + + + + + jQuery UI Menubar Demos + + + +
    +

    Examples

    + +
    + + diff --git a/demos/popup/default.html b/demos/popup/default.html new file mode 100644 index 0000000000..71b3c8dd2b --- /dev/null +++ b/demos/popup/default.html @@ -0,0 +1,83 @@ + + + + jQuery UI Popup - Default demo + + + + + + + + + + + + + + +
    + Log In +
    +
    +
    + + +
    +
    + + +
    +
    + +
    +
    +
    +
    + +
    + +

    A link to a login form that opens as a popup. [Not quite functional, focus handling needs to get better]

    + +
    + + + + diff --git a/demos/popup/index.html b/demos/popup/index.html new file mode 100644 index 0000000000..e69365c986 --- /dev/null +++ b/demos/popup/index.html @@ -0,0 +1,18 @@ + + + + + jQuery UI Popup Demos + + + + + + diff --git a/demos/popup/popup-menu-table.html b/demos/popup/popup-menu-table.html new file mode 100644 index 0000000000..a06a384343 --- /dev/null +++ b/demos/popup/popup-menu-table.html @@ -0,0 +1,108 @@ + + + + jQuery UI Popup - Menu as Popup in table demo + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameRelease YearAverage Rating
    Red Hot Chili Peppers: Funky Monks19933.6 + +
    Rod Stewart: Storyteller 1984-199119913.1
    Stevie Ray Vaughan and Double Trouble: Live at the El Mocambo 198319913.9
    Spike and Mike's Sick & Twisted Festival of Animation19972.6
    + +
    +
    + + +
    + +

    Poup menu in a table. Works okay standalone, not so much in the scrolling demo view. For that to work better, position() would have to take the closest scrolled parent into account for collision detection.

    + +
    + + + + diff --git a/demos/popup/popup-menu.html b/demos/popup/popup-menu.html new file mode 100644 index 0000000000..7152d85bcd --- /dev/null +++ b/demos/popup/popup-menu.html @@ -0,0 +1,98 @@ + + + + jQuery UI Popup - Popup Menu + + + + + + + + + + + + + + +
    + + + + + +
    +
    + + + +
    +
    + +
    +
    + + +
    + +

    Make the popup a menu (or the menu a popup) and you get context menus.

    + +
    + + + + diff --git a/tests/visual/menu/contextmenu.html b/tests/visual/menu/contextmenu.html deleted file mode 100644 index 63d9877a0d..0000000000 --- a/tests/visual/menu/contextmenu.html +++ /dev/null @@ -1,191 +0,0 @@ - - - - Menu Visual Test: Default - - - - - - - - - - - - - - - - - - - - -
    - Log: -
    -
    - - - - - - diff --git a/tests/visual/menu/popup.html b/tests/visual/menu/popup.html deleted file mode 100644 index de27208b48..0000000000 --- a/tests/visual/menu/popup.html +++ /dev/null @@ -1,176 +0,0 @@ - - - - Visual Test for Popup Utility - - - - - - - - - - - - - - - -
    - Project members -
    - some form controls in here -
    -
    - - - - - -
    -
    - - -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NameRelease YearAverage Rating
    Red Hot Chili Peppers: Funky Monks19933.6 - -
    Rod Stewart: Storyteller 1984-199119913.1
    Stevie Ray Vaughan and Double Trouble: Live at the El Mocambo 198319913.9
    Spike and Mike's Sick & Twisted Festival of Animation19972.6
    - -
    - Log: -
    -
    - - - From 0e2bc5efe217681c006ae7a16be21520e6563da6 Mon Sep 17 00:00:00 2001 From: Carson McDonald Date: Mon, 9 May 2011 11:00:12 -0400 Subject: [PATCH 36/59] Resizable: Skip autohide hover action when resizable is disabled. Fix #6948 - Resizable autoHide Doesn't Work With Resizable's disable --- ui/jquery.ui.resizable.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js index 1e1706a9df..e0579ef849 100644 --- a/ui/jquery.ui.resizable.js +++ b/ui/jquery.ui.resizable.js @@ -176,10 +176,12 @@ $.widget("ui.resizable", $.ui.mouse, { $(this.element) .addClass("ui-resizable-autohide") .hover(function() { + if (o.disabled) return; $(this).removeClass("ui-resizable-autohide"); self._handles.show(); }, function(){ + if (o.disabled) return; if (!self.resizing) { $(this).addClass("ui-resizable-autohide"); self._handles.hide(); From 0546cd57bbd0ccee25e96e1fb8be5f208b08dfd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 9 May 2011 11:31:01 -0400 Subject: [PATCH 37/59] Tabs: Added tests for idPrefix, tabTemplate, panelTemplate. Fixes #7139 - Tabs: Deprecate templating (idPrefix, tabTemplate, panelTemplate options). --- tests/unit/tabs/tabs_deprecated.js | 45 ++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js index 90c43037c0..8d63409a80 100644 --- a/tests/unit/tabs/tabs_deprecated.js +++ b/tests/unit/tabs/tabs_deprecated.js @@ -20,7 +20,7 @@ test( "panel ids", function() { element.tabs( "option", "active", 2 ); }); -module("tabs (deprecated): options"); +module( "tabs (deprecated): options" ); test('ajaxOptions', function() { ok(false, "missing test - untested code is broken code."); @@ -30,16 +30,45 @@ test('cache', function() { ok(false, "missing test - untested code is broken code."); }); -test('idPrefix', function() { - ok(false, "missing test - untested code is broken code."); +test( "idPrefix", function() { + expect( 1 ); + + $( "#tabs2" ) + .one( "tabsbeforeload", function( event, ui ) { + ok( /^testing-\d+$/.test( ui.panel.attr( "id" ) ), "generated id" ); + event.preventDefault(); + }) + .tabs({ + idPrefix: "testing-", + active: 2 + }); }); -test('tabTemplate', function() { - ok(false, "missing test - untested code is broken code."); -}); +test( "tabTemplate + panelTemplate", function() { + // defaults are tested in the add method test + expect( 11 ); -test('panelTemplate', function() { - ok(false, "missing test - untested code is broken code."); + var element = $( "#tabs2" ).tabs({ + tabTemplate: "
  • #{label}
  • ", + panelTemplate: "
    " + }); + element.one( "tabsadd", function( event, ui ) { + var anchor = $( ui.tab ); + equal( ui.index, 5, "ui.index" ); + equal( anchor.text(), "New", "ui.tab" ); + equal( anchor.attr( "href" ), "http://example.com/#new", "tab href" ); + ok( anchor.parent().hasClass( "customTab" ), "tab custom class" ); + equal( ui.panel.id, "new", "ui.panel" ); + ok( $( ui.panel ).hasClass( "customPanel" ), "panel custom class" ); + }); + element.tabs( "add", "#new", "New" ); + var tab = element.find( ".ui-tabs-nav li" ).last(), + anchor = tab.find( "a" ); + equals( tab.text(), "New", "label" ); + ok( tab.hasClass( "customTab" ), "tab custom class" ); + equals( anchor.attr( "href" ), "http://example.com/#new", "href" ); + equals( anchor.attr( "aria-controls" ), "new", "aria-controls" ); + ok( element.find( "#new" ).hasClass( "customPanel" ), "panel custom class" ); }); test('cookie', function() { From 9c50bdfde0260fc8412eec1c5020ed6b61558ebd Mon Sep 17 00:00:00 2001 From: kborchers Date: Mon, 9 May 2011 11:43:45 -0500 Subject: [PATCH 38/59] Mouse: Changed mouseHandled check to a local var rather than using originalEvent. Fixed #4333 - Nested draggables problem in IE --- ui/jquery.ui.mouse.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ui/jquery.ui.mouse.js b/ui/jquery.ui.mouse.js index bfe4a75782..0bd38db853 100644 --- a/ui/jquery.ui.mouse.js +++ b/ui/jquery.ui.mouse.js @@ -12,6 +12,11 @@ */ (function( $, undefined ) { +var mouseHandled = false; +$(document).mousedown(function(e) { + mouseHandled = false; +}); + $.widget("ui.mouse", { options: { cancel: ':input,option', @@ -44,9 +49,7 @@ $.widget("ui.mouse", { _mouseDown: function(event) { // don't let more than one widget handle mouseStart - // TODO: figure out why we have to use originalEvent - event.originalEvent = event.originalEvent || {}; - if (event.originalEvent.mouseHandled) { return; } + if(mouseHandled) {return}; // we may have missed mouseup (out of window) (this._mouseStarted && this._mouseUp(event)); @@ -92,7 +95,8 @@ $.widget("ui.mouse", { .bind('mouseup.'+this.widgetName, this._mouseUpDelegate); event.preventDefault(); - event.originalEvent.mouseHandled = true; + + mouseHandled = true; return true; }, From 5ae44f8a3bdd858aa95c79b5938566ca0a67f373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 9 May 2011 12:52:00 -0400 Subject: [PATCH 39/59] Tabs: Refactored spinner implementation. Fixes #7134 - Tabs: Deprecate spinner option. --- tests/unit/tabs/tabs_deprecated.js | 35 +++++++------------------ ui/jquery.ui.tabs.js | 42 +++++++++++++----------------- 2 files changed, 28 insertions(+), 49 deletions(-) diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js index 8d63409a80..0094bc4f79 100644 --- a/tests/unit/tabs/tabs_deprecated.js +++ b/tests/unit/tabs/tabs_deprecated.js @@ -106,34 +106,19 @@ test('cookie', function() { }); +asyncTest( "spinner", function() { + expect( 2 ); -test('spinner', function() { - expect(4); - stop(); + var element = $( "#tabs2" ).tabs(); - el = $('#tabs2'); - - el.tabs({ - selected: 2, - load: function() { - // spinner: default spinner - setTimeout(function() { - equals($('li:eq(2) > a > span', el).length, 1, "should restore tab markup after spinner is removed"); - equals($('li:eq(2) > a > span', el).html(), '3', "should restore tab label after spinner is removed"); - el.tabs('destroy'); - el.tabs({ - selected: 2, - spinner: '', - load: function() { - // spinner: image - equals($('li:eq(2) > a > span', el).length, 1, "should restore tab markup after spinner is removed"); - equals($('li:eq(2) > a > span', el).html(), '3', "should restore tab label after spinner is removed"); - start(); - } - }); - }, 1); - } + element.one( "tabsbeforeload", function( event, ui ) { + equals( element.find( ".ui-tabs-nav li:eq(2) em" ).length, 1, "beforeload" ); }); + element.one( "tabsload", function( event, ui ) { + equals( element.find( ".ui-tabs-nav li:eq(2) em" ).length, 0, "load" ); + start(); + }); + element.tabs( "option", "active", 2 ); }); test( "selected", function() { diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 58c181670b..f0661b3add 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -743,34 +743,28 @@ if ( $.uiBackCompat !== false ) { }( jQuery, jQuery.ui.tabs.prototype ) ); // spinner - (function( $, prototype ) { - $.extend( prototype.options, { + $.widget( "ui.tabs", $.ui.tabs, { + options: { spinner: "Loading…" - }); - - var _create = prototype._create; - prototype._create = function() { - _create.call( this ); - var self = this; - - this.element.bind( "tabsbeforeload", function( event, ui ) { - if ( self.options.spinner ) { - var span = $( "span", ui.tab ); - if ( span.length ) { - span.data( "label.tabs", span.html() ).html( self.options.spinner ); + }, + _create: function() { + this._super( "_create" ); + this._bind({ + tabsbeforeload: function( event, ui ) { + if ( !this.options.spinner ) { + return; } + + var span = ui.tab.find( "span" ), + html = span.html(); + span.html( this.options.spinner ); + ui.jqXHR.complete(function() { + span.html( html ); + }); } - ui.jqXHR.complete( function() { - if ( self.options.spinner ) { - var span = $( "span", ui.tab ); - if ( span.length ) { - span.html( span.data( "label.tabs" ) ).removeData( "label.tabs" ); - } - } - }); }); - }; - }( jQuery, jQuery.ui.tabs.prototype ) ); + } + }); // enable/disable events (function( $, prototype ) { From 9549686cb35b877740aca388286d71ad04311a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 9 May 2011 14:45:57 -0400 Subject: [PATCH 40/59] Tabs: Added test for ajaxOptions. Partial fix for #7131 - Tabs: Add beforeload event; deprecate ajaxOptions and cache options. Thanks gnarf for the unit test idea. --- tests/unit/tabs/tabs_deprecated.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js index 0094bc4f79..e5f7b7568c 100644 --- a/tests/unit/tabs/tabs_deprecated.js +++ b/tests/unit/tabs/tabs_deprecated.js @@ -22,8 +22,23 @@ test( "panel ids", function() { module( "tabs (deprecated): options" ); -test('ajaxOptions', function() { - ok(false, "missing test - untested code is broken code."); +asyncTest( "ajaxOptions", function() { + expect( 1 ); + + var element = $( "#tabs2" ).tabs({ + ajaxOptions: { + converters: { + "text html": function() { + return "test"; + } + } + } + }); + element.one( "tabsload", function( event, ui ) { + equals( ui.panel.html(), "test" ); + start(); + }); + element.tabs( "option", "active", 2 ); }); test('cache', function() { @@ -419,4 +434,8 @@ test( "url", function() { element.tabs( "option", "active", 3 ); }); +test( "abort", function() { + ok( false, "missing test - untested code is broken code." ); +}); + }( jQuery ) ); From 7157af2550b1b26fb71a7fac17ea67f36f117f7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 9 May 2011 15:04:01 -0400 Subject: [PATCH 41/59] Tabs: Added tests for cache option. Fixes #7131 - Tabs: Add beforeload event; deprecate ajaxOptions and cache options. --- tests/unit/tabs/tabs_deprecated.js | 30 ++++++++++++++++++++++++++++-- ui/jquery.ui.tabs.js | 2 +- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js index e5f7b7568c..49e89b7a0a 100644 --- a/tests/unit/tabs/tabs_deprecated.js +++ b/tests/unit/tabs/tabs_deprecated.js @@ -41,8 +41,34 @@ asyncTest( "ajaxOptions", function() { element.tabs( "option", "active", 2 ); }); -test('cache', function() { - ok(false, "missing test - untested code is broken code."); +asyncTest( "cache", function() { + expect( 5 ); + + var element = $( "#tabs2" ).tabs({ + cache: true + }); + element.one( "tabsshow", function( event, ui ) { + tabs_state( element, 0, 0, 1, 0, 0 ); + }); + element.one( "tabsload", function( event, ui ) { + ok( true, "tabsload" ); + + setTimeout(function() { + element.tabs( "option", "active", 0 ); + tabs_state( element, 1, 0, 0, 0, 0 ); + + element.one( "tabsshow", function( event, ui ) { + tabs_state( element, 0, 0, 1, 0, 0 ); + }); + element.one( "tabsload", function( event, ui ) { + ok( false, "should be cached" ); + }); + element.tabs( "option", "active", 2 ); + start(); + }, 1 ); + }); + element.tabs( "option", "active", 2 ); + tabs_state( element, 0, 0, 1, 0, 0 ); }); test( "idPrefix", function() { diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index f0661b3add..8da11367eb 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -705,7 +705,7 @@ if ( $.uiBackCompat !== false ) { } }); - ui.jqXHR.success( function() { + ui.jqXHR.success(function() { if ( self.options.cache ) { $.data( ui.tab[ 0 ], "cache.tabs", true ); } From 58a41e73e4b6e59c7e9f7773d6ef7807f3eee701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Mon, 9 May 2011 21:42:44 +0200 Subject: [PATCH 42/59] Readme update: Some instructions for cherry-picking from pull requests --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 5c7d79a133..9a0d7c5c5a 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,20 @@ If you want to use jQuery UI, go to [jqueryui.com](http://jqueryui.com) to get s If you are interested in helping developing jQuery UI, you are in the right place. To discuss development with team members and the community, visit the [Developing jQuery UI Forum](http://forum.jquery.com/developing-jquery-ui). + +For commiters +--- +When looking at pull requests, first check for [proper commit messages](http://wiki.jqueryui.com/w/page/12137724/Bug-Fixing-Guide). + +Unless everything is fine and you can merge directly via GitHub's interface, fetch the remote first: + + git remote add [username] [his-fork.git] -f + +If you want just one commit and edit the commit message: + + git cherry-pick -e [sha-of-commit] + +If it should go to the stable brach, cherry-pick it to stable: + + git checkout 1-8-stable + git cherry-pick -x [sha-of-commit] From 0adeb9b0e1b2883eb008917333effe12ad20a64d Mon Sep 17 00:00:00 2001 From: David Petersen Date: Mon, 9 May 2011 15:42:24 -0400 Subject: [PATCH 43/59] Tabs: Add tabsload event tests. --- tests/unit/tabs/tabs_events.js | 62 ++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/tests/unit/tabs/tabs_events.js b/tests/unit/tabs/tabs_events.js index 28925a2b9d..d64005f8b2 100644 --- a/tests/unit/tabs/tabs_events.js +++ b/tests/unit/tabs/tabs_events.js @@ -191,8 +191,66 @@ test( "beforeLoad", function() { equals( panel.html(), "

    testing

    ", "panel html after" ); }); -test( "load", function() { - ok( false, "missing test - untested code is broken code." ); +asyncTest( "load", function() { + expect( 21 ); + + var tab, panelId, panel, + element = $( "#tabs2" ); + + // init + element.one( "tabsload", function( event, ui ) { + tab = element.find( ".ui-tabs-nav a" ).eq( 2 ); + panelId = tab.attr( "aria-controls" ); + panel = $( "#" + panelId ); + + ok( !( "originalEvent" in event ), "originalEvent" ); + equals( ui.tab.size(), 1, "tab size" ); + strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" ); + equals( ui.panel.size(), 1, "panel size" ); + strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" ); + equals( ui.panel.find( "p" ).length, 1, "panel html" ); + tabs_state( element, 0, 0, 1, 0, 0 ); + tabsload1(); + }); + element.tabs({ active: 2 }); + + function tabsload1() { + // .option() + element.one( "tabsload", function( event, ui ) { + tab = element.find( ".ui-tabs-nav a" ).eq( 3 ); + panelId = tab.attr( "aria-controls" ); + panel = $( "#" + panelId ); + + ok( !( "originalEvent" in event ), "originalEvent" ); + equals( ui.tab.size(), 1, "tab size" ); + strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" ); + equals( ui.panel.size(), 1, "panel size" ); + strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" ); + equals( ui.panel.find( "p" ).length, 1, "panel html" ); + tabs_state( element, 0, 0, 0, 1, 0 ); + tabsload2(); + }); + element.tabs( "option", "active", 3 ); + } + + function tabsload2() { + // click, change panel content + element.one( "tabsload", function( event, ui ) { + tab = element.find( ".ui-tabs-nav a" ).eq( 4 ); + panelId = tab.attr( "aria-controls" ); + panel = $( "#" + panelId ); + + equals( event.originalEvent.type, "click", "originalEvent" ); + equals( ui.tab.size(), 1, "tab size" ); + strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" ); + equals( ui.panel.size(), 1, "panel size" ); + strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" ); + equals( ui.panel.find( "p" ).length, 1, "panel html" ); + tabs_state( element, 0, 0, 0, 0, 1 ); + start(); + }); + element.find( ".ui-tabs-nav a" ).eq( 4 ).click(); + } }); }( jQuery ) ); From 9ea6db634f392b5432e03f893cd48a9c2e15cbb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 9 May 2011 16:04:33 -0400 Subject: [PATCH 44/59] Tabs: Only trigger tabsload on success. --- tests/unit/tabs/tabs_deprecated.js | 7 +++++-- ui/jquery.ui.tabs.js | 5 ++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js index 49e89b7a0a..a9f1f032fa 100644 --- a/tests/unit/tabs/tabs_deprecated.js +++ b/tests/unit/tabs/tabs_deprecated.js @@ -156,8 +156,11 @@ asyncTest( "spinner", function() { equals( element.find( ".ui-tabs-nav li:eq(2) em" ).length, 1, "beforeload" ); }); element.one( "tabsload", function( event, ui ) { - equals( element.find( ".ui-tabs-nav li:eq(2) em" ).length, 0, "load" ); - start(); + // wait until after the load finishes before checking for the spinner to be removed + setTimeout(function() { + equals( element.find( ".ui-tabs-nav li:eq(2) em" ).length, 0, "load" ); + start(); + }, 1 ); }); element.tabs( "option", "active", 2 ); }); diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 8da11367eb..e7d4e3513e 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -621,6 +621,7 @@ $.widget( "ui.tabs", { this.xhr .success(function( response ) { panel.html( response ); + self._trigger( "load", event, eventData ); }) .complete(function( jqXHR, status ) { if ( status === "abort" ) { @@ -631,13 +632,11 @@ $.widget( "ui.tabs", { // "tabs" queue must not contain more than two elements, // which are the callbacks for the latest clicked tab... self.element.queue( "tabs", self.element.queue( "tabs" ).splice( -2, 2 ) ); - - delete this.xhr; } self.lis.eq( index ).removeClass( "ui-tabs-loading" ); - self._trigger( "load", event, eventData ); + delete self.xhr; }); } From f53d11785339543de7878add5ff25476246fa0b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 9 May 2011 16:54:51 -0400 Subject: [PATCH 45/59] Tabs: Added test for abort method. Fixes #7133 - Tabs: Deprecate abort method. --- tests/unit/tabs/tabs_deprecated.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js index a9f1f032fa..1448250078 100644 --- a/tests/unit/tabs/tabs_deprecated.js +++ b/tests/unit/tabs/tabs_deprecated.js @@ -463,8 +463,18 @@ test( "url", function() { element.tabs( "option", "active", 3 ); }); -test( "abort", function() { - ok( false, "missing test - untested code is broken code." ); +asyncTest( "abort", function() { + expect( 1 ); + + var element = $( "#tabs2" ).tabs(); + element.one( "tabsbeforeload", function( event, ui ) { + ui.jqXHR.error(function( jqXHR, status ) { + equals( status, "abort", "aborted" ); + start(); + }); + }); + element.tabs( "option", "active", 2 ); + element.tabs( "abort" ); }); }( jQuery ) ); From ea01e7fc50bb9480ee92dd3989dbdeb89cb71562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 9 May 2011 17:01:11 -0400 Subject: [PATCH 46/59] Tabs: Added tests for event option. --- tests/unit/tabs/tabs_options.js | 51 +++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/tests/unit/tabs/tabs_options.js b/tests/unit/tabs/tabs_options.js index 691186276e..7e2d9baf5c 100644 --- a/tests/unit/tabs/tabs_options.js +++ b/tests/unit/tabs/tabs_options.js @@ -149,8 +149,55 @@ test('disabled', function() { same(el.tabs('option', 'disabled'), false, "should not disable any tab"); // ... }); -test('event', function() { - ok(false, "missing test - untested code is broken code."); +test( "{ event: null }", function() { + expect( 5 ); + + var element = $( "#tabs1" ).tabs({ + event: null + }); + tabs_state( element, 1, 0, 0 ); + + element.tabs( "option", "active", 1 ); + equal( element.tabs( "option", "active" ), 1 ); + tabs_state( element, 0, 1, 0 ); + + // ensure default click handler isn't bound + element.find( ".ui-tabs-nav a" ).eq( 2 ).click(); + equal( element.tabs( "option", "active" ), 1 ); + tabs_state( element, 0, 1, 0 ); +}); + +test( "{ event: custom }", function() { + expect( 11 ); + + var element = $( "#tabs1" ).tabs({ + event: "custom1 custom2" + }); + tabs_state( element, 1, 0, 0 ); + + element.find( ".ui-tabs-nav a" ).eq( 1 ).trigger( "custom1" ); + equal( element.tabs( "option", "active" ), 1 ); + tabs_state( element, 0, 1, 0 ); + + // ensure default click handler isn't bound + element.find( ".ui-tabs-nav a" ).eq( 2 ).trigger( "click" ); + equal( element.tabs( "option", "active" ), 1 ); + tabs_state( element, 0, 1, 0 ); + + element.find( ".ui-tabs-nav a" ).eq( 2 ).trigger( "custom2" ); + equal( element.tabs( "option", "active" ), 2 ); + tabs_state( element, 0, 0, 1 ); + + element.tabs( "option", "event", "custom3" ); + + // ensure old event handlers are unbound + element.find( ".ui-tabs-nav a" ).eq( 1 ).trigger( "custom1" ); + equal( element.tabs( "option", "active" ), 2 ); + tabs_state( element, 0, 0, 1 ); + + element.find( ".ui-tabs-nav a" ).eq( 1 ).trigger( "custom3" ); + equal( element.tabs( "option", "active" ), 1 ); + tabs_state( element, 0, 1, 0 ); }); test('fx', function() { From 6a9b789bc7f3ef99036974c1c06695aef091a994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 9 May 2011 17:10:36 -0400 Subject: [PATCH 47/59] Tabs: Updated tests for disabled option. --- tests/unit/tabs/tabs_options.js | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/tests/unit/tabs/tabs_options.js b/tests/unit/tabs/tabs_options.js index 7e2d9baf5c..97fd87bf67 100644 --- a/tests/unit/tabs/tabs_options.js +++ b/tests/unit/tabs/tabs_options.js @@ -133,20 +133,28 @@ test( "{ collapsible: true }", function() { tabs_state( element, 0, 0, 0 ); }); -test('disabled', function() { - expect(4); +test( "disabled", function() { + expect( 10 ); - el = $('#tabs1').tabs(); - same(el.tabs('option', 'disabled'), false, "should not disable any tab by default"); + // fully enabled by default + var element = $( "#tabs1" ).tabs(); + tabs_disabled( element, false ); - el.tabs('option', 'disabled', [ 1 ]); - same(el.tabs('option', 'disabled'), [ 1 ], "should set property"); // everything else is being tested in methods module... + // disable single tab + element.tabs( "option", "disabled", [ 1 ] ); + tabs_disabled( element, [ 1 ] ); - el.tabs('option', 'disabled', [ 0, 1 ]); - same(el.tabs('option', 'disabled'), [ 0, 1 ], "should disable given tabs, even selected one"); // ... + // disabled active tab + element.tabs( "option", "disabled", [ 0, 1 ] ); + tabs_disabled( element, [ 0, 1 ] ); - el.tabs('option', 'disabled', [ ]); - same(el.tabs('option', 'disabled'), false, "should not disable any tab"); // ... + // disable all tabs + element.tabs( "option", "disabled", [ 0, 1, 2 ] ); + tabs_disabled( element, true ); + + // enable all tabs + element.tabs( "option", "disabled", [] ); + tabs_disabled( element, false ); }); test( "{ event: null }", function() { @@ -200,8 +208,6 @@ test( "{ event: custom }", function() { tabs_state( element, 0, 1, 0 ); }); -test('fx', function() { - ok(false, "missing test - untested code is broken code."); -}); +// TODO: add animation tests })(jQuery); From 73ed73890c0e91430a6dc2a01a971f9a4586a6e0 Mon Sep 17 00:00:00 2001 From: kborchers Date: Mon, 9 May 2011 16:22:11 -0500 Subject: [PATCH 48/59] Autocomplete: Added check to determine if menu has just been created to override mouseover event and reset that variable from autocomplete on close. Fixed #7024 - Autocomplete menu options are activated even if mouse is not moved --- ui/jquery.ui.autocomplete.js | 1 + ui/jquery.ui.menu.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 526eb38697..e388a63bd6 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -338,6 +338,7 @@ $.widget( "ui.autocomplete", { this.menu.element.hide(); this.menu.blur(); this._trigger( "close", event ); + this.menu.isNewMenu = true; } }, diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index 0841018af1..3cc25062c2 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -18,6 +18,7 @@ var idIncrement = 0; $.widget("ui.menu", { defaultElement: "
      ", delay: 150, + isNewMenu: true, options: { position: { my: "left top", @@ -54,7 +55,8 @@ $.widget("ui.menu", { self.select( event ); }) .bind( "mouseover.menu", function( event ) { - if ( self.options.disabled ) { + if ( self.options.disabled || self.isNewMenu ) { + self.isNewMenu = false; return; } var target = $( event.target ).closest( ".ui-menu-item" ); From 0f7075e2811489a5aeba13a763be602ef1aeea72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 9 May 2011 17:38:34 -0400 Subject: [PATCH 49/59] Tabs: Added tests for beforeload event on init. --- tests/unit/tabs/tabs_events.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/tests/unit/tabs/tabs_events.js b/tests/unit/tabs/tabs_events.js index d64005f8b2..2fabaafca4 100644 --- a/tests/unit/tabs/tabs_events.js +++ b/tests/unit/tabs/tabs_events.js @@ -138,15 +138,32 @@ test( "activate", function() { }); test( "beforeLoad", function() { - expect( 21 ); + expect( 32 ); var tab, panelId, panel, - element = $( "#tabs2" ).tabs(); + element = $( "#tabs2" ); - // TODO: init -// element.one( "tabsbeforeload", function( event, ui ) { -// }); -// element.tabs({ active: 2 }); + // init + element.one( "tabsbeforeload", function( event, ui ) { + tab = element.find( ".ui-tabs-nav a" ).eq( 2 ); + panelId = tab.attr( "aria-controls" ); + panel = $( "#" + panelId ); + + ok( !( "originalEvent" in event ), "originalEvent" ); + ok( "abort" in ui.jqXHR, "jqXHR" ); + ok( ui.ajaxSettings.url, "data/test.html", "ajaxSettings.url" ); + equals( ui.tab.size(), 1, "tab size" ); + strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" ); + equals( ui.panel.size(), 1, "panel size" ); + strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" ); + equals( ui.panel.html(), "", "panel html" ); + event.preventDefault(); + tabs_state( element, 0, 0, 1, 0, 0 ); + }); + element.tabs({ active: 2 }); + tabs_state( element, 0, 0, 1, 0, 0 ); + equals( panel.html(), "", "panel html after" ); + element.tabs( "destroy" ); // .option() element.one( "tabsbeforeload", function( event, ui ) { @@ -165,6 +182,7 @@ test( "beforeLoad", function() { event.preventDefault(); tabs_state( element, 1, 0, 0, 0, 0 ); }); + element.tabs(); element.tabs( "option", "active", 2 ); tabs_state( element, 0, 0, 1, 0, 0 ); equals( panel.html(), "", "panel html after" ); From bd6672d2571f69d5e2ed819e13514580648aaa13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Mon, 9 May 2011 17:41:43 -0400 Subject: [PATCH 50/59] Tabs: Updated tests for destroy method. --- tests/unit/tabs/tabs_methods.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/tests/unit/tabs/tabs_methods.js b/tests/unit/tabs/tabs_methods.js index a6e60a4b30..221b0d39de 100644 --- a/tests/unit/tabs/tabs_methods.js +++ b/tests/unit/tabs/tabs_methods.js @@ -2,19 +2,10 @@ module( "tabs: methods" ); -test('destroy', function() { - expect(6); - - el = $('#tabs1').tabs({ collapsible: true }); - $('li:eq(2)', el).simulate('mouseover').find('a').focus(); - el.tabs('destroy'); - - ok( el.is(':not(.ui-tabs, .ui-widget, .ui-widget-content, .ui-corner-all, .ui-tabs-collapsible)'), 'remove classes from container'); - ok( $('ul', el).is(':not(.ui-tabs-nav, .ui-helper-reset, .ui-helper-clearfix, .ui-widget-header, .ui-corner-all)'), 'remove classes from list' ); - ok( $('div:eq(1)', el).is(':not(.ui-tabs-panel, .ui-widget-content, .ui-corner-bottom)'), 'remove classes to panel' ); - ok( $('li:eq(0)', el).is(':not(.ui-tabs-active, .ui-state-active, .ui-corner-top)'), 'remove classes from active li'); - ok( $('li:eq(1)', el).is(':not(.ui-state-default, .ui-corner-top)'), 'remove classes from inactive li'); - ok( $('li:eq(2)', el).is(':not(.ui-state-hover, .ui-state-focus)'), 'remove classes from mouseovered or focused li'); +test( "destroy", function() { + domEqual( "#tabs1", function() { + $( "#tabs1" ).tabs().tabs( "destroy" ); + }); }); test( "enable", function() { From a205c2c8b8498f82f87a723f49c1fe746e47c667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Tue, 10 May 2011 08:47:00 -0400 Subject: [PATCH 51/59] Tabs: Moved tests out of tickets file. --- tests/unit/tabs/tabs.html | 1 - tests/unit/tabs/tabs_core.js | 28 +++++++++++++++++++++ tests/unit/tabs/tabs_deprecated.html | 1 - tests/unit/tabs/tabs_options.js | 2 +- tests/unit/tabs/tabs_tickets.js | 37 ---------------------------- 5 files changed, 29 insertions(+), 40 deletions(-) delete mode 100644 tests/unit/tabs/tabs_tickets.js diff --git a/tests/unit/tabs/tabs.html b/tests/unit/tabs/tabs.html index 565a0b427c..34ec28bc4b 100644 --- a/tests/unit/tabs/tabs.html +++ b/tests/unit/tabs/tabs.html @@ -24,7 +24,6 @@ - -