From 6204e1a3c4197d4c612e786337ee371295364ee2 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Thu, 8 Apr 2010 23:21:47 +0200 Subject: The accidental merge of tooltip into master was reverted in master, that revert got merged back into tooltip; now reverting that revert to get the tooltip stuff back, should then make it easy to merge into master once tooltip is done --- tests/visual/compound/tabs_tooltips.html | 37 +++++ tests/visual/compound/widgets_in_dialog.html | 9 +- tests/visual/index.html | 2 + tests/visual/tooltip/ajaxcontent.php | 2 + tests/visual/tooltip/callout.html | 213 +++++++++++++++++++++++++++ tests/visual/tooltip/tooltip.html | 149 +++++++++++++++++++ 6 files changed, 409 insertions(+), 3 deletions(-) create mode 100644 tests/visual/compound/tabs_tooltips.html create mode 100644 tests/visual/tooltip/ajaxcontent.php create mode 100644 tests/visual/tooltip/callout.html create mode 100644 tests/visual/tooltip/tooltip.html (limited to 'tests') diff --git a/tests/visual/compound/tabs_tooltips.html b/tests/visual/compound/tabs_tooltips.html new file mode 100644 index 000000000..00046fe0d --- /dev/null +++ b/tests/visual/compound/tabs_tooltips.html @@ -0,0 +1,37 @@ + + + + + Compound Visual Test : Tabs in Tabs + + + + + + + + + + + + +
+ +
+ label +
+ +
+ + + diff --git a/tests/visual/compound/widgets_in_dialog.html b/tests/visual/compound/widgets_in_dialog.html index 7551efd8d..e2eb366b4 100644 --- a/tests/visual/compound/widgets_in_dialog.html +++ b/tests/visual/compound/widgets_in_dialog.html @@ -20,8 +20,11 @@ + @@ -76,11 +79,11 @@
- +
-
+
@@ -43,6 +44,7 @@
  • Progressbar
  • Slider
  • Tabs
  • +
  • Tooltip
  • diff --git a/tests/visual/tooltip/ajaxcontent.php b/tests/visual/tooltip/ajaxcontent.php new file mode 100644 index 000000000..a689a734d --- /dev/null +++ b/tests/visual/tooltip/ajaxcontent.php @@ -0,0 +1,2 @@ + +Hello world! \ No newline at end of file diff --git a/tests/visual/tooltip/callout.html b/tests/visual/tooltip/callout.html new file mode 100644 index 000000000..3ef694987 --- /dev/null +++ b/tests/visual/tooltip/callout.html @@ -0,0 +1,213 @@ + + + + Tooltip Visual Test: Default + + + + + + + + + + + + + +
    + + +
    + collision detection should kick in around here +
    + +
    + I'm a link to a footnote. +
    + +
    + right aligned with custom position +
    + +
    + gets its content via ajax +
    + +
    + span +
    + div + nested span +
    +
    + +
    +
    + + +
    +
    + + +
    +
    + +
    This is the footnote, including other elements
    + + + +
    + + + + diff --git a/tests/visual/tooltip/tooltip.html b/tests/visual/tooltip/tooltip.html new file mode 100644 index 000000000..3f1ae3878 --- /dev/null +++ b/tests/visual/tooltip/tooltip.html @@ -0,0 +1,149 @@ + + + + Tooltip Visual Test: Default + + + + + + + + + + + + + +
    + + +
    + collision detection should kick in around here +
    + +
    + I'm a link to a footnote. +
    + +
    + right aligned with custom position +
    + +
    + gets its content via ajax +
    + +
    + span +
    + div + nested span +
    +
    + +
    + Text in bold. +
    + +
    +
    + + +
    +
    + + +
    +
    + + + + + +
    This is the footnote, including other elements
    + + + +
    + + + + -- cgit v1.2.3 From 50fe1d04fc60d57507aa949f585b06a2bcf3aec1 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Tue, 13 Apr 2010 15:43:44 +0200 Subject: Position unit tests: Add module for testswarm to run all tests --- tests/unit/position/position_core.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js index 57e02da0a..3976e43ab 100644 --- a/tests/unit/position/position_core.js +++ b/tests/unit/position/position_core.js @@ -2,6 +2,8 @@ * position_core.js */ (function($) { + +module("position"); test('my, at, of', function() { $('#elx').position({ -- cgit v1.2.3 From acfc66e1ab4c90897139507124de7365fee4afb9 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Wed, 14 Apr 2010 09:15:15 +0200 Subject: Revert "Position unit tests: Add module for testswarm to run all tests" This reverts commit 50fe1d04fc60d57507aa949f585b06a2bcf3aec1. Should have been commited to master, not tooltip branch. --- tests/unit/position/position_core.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js index 3976e43ab..57e02da0a 100644 --- a/tests/unit/position/position_core.js +++ b/tests/unit/position/position_core.js @@ -2,8 +2,6 @@ * position_core.js */ (function($) { - -module("position"); test('my, at, of', function() { $('#elx').position({ -- cgit v1.2.3 From 84e0ce168f109fbd5482c6c1ba09bbbb55592888 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Thu, 15 Apr 2010 09:45:35 +0200 Subject: Tooltip: Unit tests for tooltip and a fix to pass through event objects to triggered events --- tests/unit/index.html | 22 +------------- tests/unit/tooltip/tooltip.html | 43 +++++++++++++++++++++++++++ tests/unit/tooltip/tooltip_core.js | 11 +++++++ tests/unit/tooltip/tooltip_defaults.js | 16 ++++++++++ tests/unit/tooltip/tooltip_events.js | 54 ++++++++++++++++++++++++++++++++++ tests/unit/tooltip/tooltip_methods.js | 23 +++++++++++++++ tests/unit/tooltip/tooltip_options.js | 39 ++++++++++++++++++++++++ tests/unit/tooltip/tooltip_tickets.js | 10 +++++++ ui/jquery.ui.tooltip.js | 18 ++++++------ 9 files changed, 206 insertions(+), 30 deletions(-) create mode 100644 tests/unit/tooltip/tooltip.html create mode 100644 tests/unit/tooltip/tooltip_core.js create mode 100644 tests/unit/tooltip/tooltip_defaults.js create mode 100644 tests/unit/tooltip/tooltip_events.js create mode 100644 tests/unit/tooltip/tooltip_methods.js create mode 100644 tests/unit/tooltip/tooltip_options.js create mode 100644 tests/unit/tooltip/tooltip_tickets.js (limited to 'tests') diff --git a/tests/unit/index.html b/tests/unit/index.html index 4882098d7..ad8c96433 100644 --- a/tests/unit/index.html +++ b/tests/unit/index.html @@ -19,27 +19,6 @@ } - - - - - - - - - - - - - - - - - - - - - @@ -69,6 +48,7 @@
  • Progressbar
  • Slider
  • Tabs
  • +
  • Tooltip
  • Utilities

    diff --git a/tests/unit/tooltip/tooltip.html b/tests/unit/tooltip/tooltip.html new file mode 100644 index 000000000..37bfeafce --- /dev/null +++ b/tests/unit/tooltip/tooltip.html @@ -0,0 +1,43 @@ + + + + + jQuery UI Tooltip Test Suite + + + + + + + + + + + + + + + + + + + + + + + +

    jQuery UI Tooltip Test Suite

    +

    +

    +
      +
    + +
    +
    + anchor + +
    +
    + + + diff --git a/tests/unit/tooltip/tooltip_core.js b/tests/unit/tooltip/tooltip_core.js new file mode 100644 index 000000000..247927df4 --- /dev/null +++ b/tests/unit/tooltip/tooltip_core.js @@ -0,0 +1,11 @@ +/* + * tooltip_core.js + */ + + +(function($) { + +module("tooltip: core"); + + +})(jQuery); diff --git a/tests/unit/tooltip/tooltip_defaults.js b/tests/unit/tooltip/tooltip_defaults.js new file mode 100644 index 000000000..bcdcd4307 --- /dev/null +++ b/tests/unit/tooltip/tooltip_defaults.js @@ -0,0 +1,16 @@ +/* + * tooltip_defaults.js + */ + +var tooltip_defaults = { + disabled: false, + content: $.ui.tooltip.prototype.options.content, + tooltipClass: "ui-widget-content", + position: { + my: "left center", + at: "right center", + offset: "15 0" + } +}; + +commonWidgetTests('tooltip', { defaults: tooltip_defaults }); diff --git a/tests/unit/tooltip/tooltip_events.js b/tests/unit/tooltip/tooltip_events.js new file mode 100644 index 000000000..51c56b62e --- /dev/null +++ b/tests/unit/tooltip/tooltip_events.js @@ -0,0 +1,54 @@ +/* + * tooltip_events.js + */ +(function($) { + +module("tooltip: events"); + +test("programmatic triggers", function() { + expect(2); + var e = $("#tooltipped1").tooltip({ + open: function(event, ui) { + same( event.type, "tooltipopen" ); + }, + close: function(event, ui) { + same( event.type, "tooltipclose" ); + } + }); + e.tooltip("open").tooltip("close"); + e.tooltip("destroy"); +}); + +test("mouse events", function() { + expect(4); + var e = $("#tooltipped1").tooltip({ + open: function(event, ui) { + same( event.type, "tooltipopen" ); + same( event.originalEvent.type, "mouseenter" ); + }, + close: function(event, ui) { + same( event.type, "tooltipclose" ); + same( event.originalEvent.type, "mouseleave" ); + } + }); + e.trigger("mouseover").trigger("mouseout"); + e.tooltip("destroy"); +}); + +test("focus events", function() { + expect(4); + var e = $("#tooltipped1").tooltip({ + open: function(event, ui) { + same( event.type, "tooltipopen" ); + same( event.originalEvent.type, "focus" ); + }, + close: function(event, ui) { + same( event.type, "tooltipclose" ); + same( event.originalEvent.type, "blur" ); + } + }); + e.trigger("focus").trigger("blur"); + e.tooltip("destroy"); +}); + +})(jQuery); diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js new file mode 100644 index 000000000..867923dd0 --- /dev/null +++ b/tests/unit/tooltip/tooltip_methods.js @@ -0,0 +1,23 @@ +/* + * tooltip_methods.js + */ +(function($) { + + +module("tooltip: methods"); + +test("destroy", function() { + var beforeHtml = $("#tooltipped1").parent().html(); + var afterHtml = $("#tooltipped1").tooltip().tooltip("destroy").parent().html(); + equal( afterHtml, beforeHtml ); +}); + +test("open", function() { + var e = $("#tooltipped1").tooltip(); + ok( $(".ui-tooltip").is(":hidden") ); + e.tooltip("open"); + ok( $(".ui-tooltip").is(":visible") ); + $(":ui-tooltip").tooltip("destroy"); +}); + +})(jQuery); diff --git a/tests/unit/tooltip/tooltip_options.js b/tests/unit/tooltip/tooltip_options.js new file mode 100644 index 000000000..e0262a947 --- /dev/null +++ b/tests/unit/tooltip/tooltip_options.js @@ -0,0 +1,39 @@ +/* + * tooltip_options.js + */ +(function($) { + +module("tooltip: options"); + +function contentTest(name, expected, impl) { + test(name, function() { + $("#tooltipped1").tooltip({ + content: impl + }).tooltip("open"); + same( $(".ui-tooltip").text(), expected ); + $(":ui-tooltip").tooltip("destroy"); + }); +} + +contentTest("content: default", "anchortitle"); +contentTest("content: return string", "customstring", function() { + return "customstring"; +}); +contentTest("content: callback string", "customstring2", function(response) { + response("customstring2"); +}); + +test("tooltipClass, default", function() { + $("#tooltipped1").tooltip().tooltip("open"); + same( $(".ui-tooltip").attr("class"), "ui-tooltip ui-widget ui-corner-all ui-widget-content"); + $(":ui-tooltip").tooltip("destroy"); +}); +test("tooltipClass, custom", function() { + $("#tooltipped1").tooltip({ + tooltipClass: "pretty fancy" + }).tooltip("open"); + same( $(".ui-tooltip").attr("class"), "ui-tooltip ui-widget ui-corner-all pretty fancy"); + $(":ui-tooltip").tooltip("destroy"); +}); + +})(jQuery); diff --git a/tests/unit/tooltip/tooltip_tickets.js b/tests/unit/tooltip/tooltip_tickets.js new file mode 100644 index 000000000..5d6d0ef86 --- /dev/null +++ b/tests/unit/tooltip/tooltip_tickets.js @@ -0,0 +1,10 @@ +/* + * tooltip_tickets.js + */ +(function($) { + +module("tooltip: tickets"); + + + +})(jQuery); diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 166bff407..13c809f45 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -49,10 +49,10 @@ $.widget("ui.tooltip", { this.opacity = this.tooltip.css("opacity"); this.element .bind("focus.tooltip mouseenter.tooltip", function(event) { - self.open(); + self.open( event ); }) .bind("blur.tooltip mouseleave.tooltip", function(event) { - self.close(); + self.close( event ); }); }, @@ -73,7 +73,7 @@ $.widget("ui.tooltip", { return this.tooltip; }, - open: function() { + open: function(event) { var target = this.element; // already visible? possible when both focus and mouseover events occur if (this.current && this.current[0] == target[0]) @@ -84,14 +84,14 @@ $.widget("ui.tooltip", { var content = this.options.content.call(target[0], function(response) { // ignore async responses that come in after the tooltip is already hidden if (self.current == target) - self._show(target, response); + self._show(event, target, response); }); if (content) { - self._show(target, content); + self._show(event, target, content); } }, - _show: function(target, content) { + _show: function(event, target, content) { if (!content) return; @@ -116,10 +116,10 @@ $.widget("ui.tooltip", { else this.tooltip.is(':visible') ? this.tooltip.fadeTo("normal", this.opacity) : this.tooltip.fadeIn(); - this._trigger( "open" ); + this._trigger( "open", event ); }, - close: function() { + close: function(event) { if (!this.current) return; @@ -137,7 +137,7 @@ $.widget("ui.tooltip", { else this.tooltip.stop().fadeOut(); - this._trigger( "close" ); + this._trigger( "close", event ); } }); -- cgit v1.2.3 From 9f56913dcc247b6aad4cea752d744ebf7775f794 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Sat, 15 May 2010 16:37:52 +0200 Subject: Tooltip: Enhanced visual test to include a few more buttons and a high element to get a scrollbar --- tests/visual/tooltip/tooltip.html | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/visual/tooltip/tooltip.html b/tests/visual/tooltip/tooltip.html index 3f1ae3878..022093bc7 100644 --- a/tests/visual/tooltip/tooltip.html +++ b/tests/visual/tooltip/tooltip.html @@ -55,18 +55,25 @@ tooltipClass: "ui-state-highlight" }); - $("#button1").button().tooltip(); + var positionOnTop = { + position: { + my: "center bottom", + at: "center top", + offset: "0 -5" + } + }; + $("#button1").button().tooltip(positionOnTop); $("#button2").button({ icons: { primary: "ui-icon-wrench" } - }).tooltip(); - $("#button3").button({ + }).tooltip(positionOnTop); + $("#button3, #button4").button({ icons: { primary: "ui-icon-wrench" }, text: false - }).tooltip(); + }).tooltip(positionOnTop); } enable(); @@ -136,7 +143,8 @@ - + +
    This is the footnote, including other elements
    @@ -144,6 +152,7 @@
    +
    -- cgit v1.2.3 From 96977edecc134d9212a304a1236e823237e8e274 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Fri, 30 Jul 2010 14:30:43 +0200 Subject: Use pushStack in tooltip's widget method. See #5732 --- tests/unit/tooltip/tooltip_methods.js | 7 +++++++ ui/jquery.ui.tooltip.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js index 867923dd0..ace1a1288 100644 --- a/tests/unit/tooltip/tooltip_methods.js +++ b/tests/unit/tooltip/tooltip_methods.js @@ -20,4 +20,11 @@ test("open", function() { $(":ui-tooltip").tooltip("destroy"); }); +test("widget", function() { + var tooltip = $("#tooltipped1").tooltip(); + same(tooltip.tooltip("widget")[0], $(".ui-tooltip")[0]); + same(tooltip.tooltip("widget").end()[0], tooltip[0]); +}); + + })(jQuery); diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index caa36b205..32d5afeee 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -70,7 +70,7 @@ $.widget("ui.tooltip", { }, widget: function() { - return this.tooltip; + return this.element.pushStack(this.tooltip.get()); }, open: function(event) { -- cgit v1.2.3 From 732a485676a1dcbefc16fdb9d26774b622410138 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Thu, 21 Oct 2010 21:03:48 +0200 Subject: Tooltip: Adding another ajax example to visual testcase. Fixing async response handling (taking IE cached response quirk into account) and simplifying fade animations a ton. --- tests/visual/tooltip/tooltip.html | 21 +++++++++++++++++++++ ui/jquery.ui.tooltip.js | 21 ++++++++------------- 2 files changed, 29 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/visual/tooltip/tooltip.html b/tests/visual/tooltip/tooltip.html index 022093bc7..7b931b155 100644 --- a/tests/visual/tooltip/tooltip.html +++ b/tests/visual/tooltip/tooltip.html @@ -44,6 +44,24 @@ return "Loading..."; } }); + // asynchronous content with caching + var content; + $("#ajax2").tooltip({ + content: function(response) { + if (content) { + return content; + } + $.ajax({ + url: "ajaxcontent.php", + cache: false, + success: function(result) { + content = result; + response(result); + } + }); + return "Loading..."; + } + }); // custom position $("#right2").tooltip({ @@ -117,6 +135,9 @@
    gets its content via ajax
    +
    + gets its content via ajax, caches the response +
    span diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 32d5afeee..8341131ca 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -82,9 +82,12 @@ $.widget("ui.tooltip", { this.current = target; this.currentTitle = target.attr("title"); var content = this.options.content.call(target[0], function(response) { - // ignore async responses that come in after the tooltip is already hidden - if (self.current == target) - self._show(event, target, response); + // IE may instantly serve a cached response, need to give it a chance to finish with _show before that + setTimeout(function() { + // ignore async responses that come in after the tooltip is already hidden + if (self.current == target) + self._show(event, target, response); + }, 13); }); if (content) { self._show(event, target, content); @@ -111,10 +114,7 @@ $.widget("ui.tooltip", { this.tooltip.attr("aria-hidden", "false"); target.attr("aria-describedby", this.tooltip.attr("id")); - if (this.tooltip.is(":animated")) - this.tooltip.stop().show().fadeTo("normal", this.opacity); - else - this.tooltip.is(':visible') ? this.tooltip.fadeTo("normal", this.opacity) : this.tooltip.fadeIn(); + this.tooltip.stop(false, true).fadeIn(); this._trigger( "open", event ); }, @@ -132,12 +132,7 @@ $.widget("ui.tooltip", { current.removeAttr("aria-describedby"); this.tooltip.attr("aria-hidden", "true"); - if (this.tooltip.is(':animated')) - this.tooltip.stop().fadeTo("normal", 0, function() { - $(this).hide().css("opacity", ""); - }); - else - this.tooltip.stop().fadeOut(); + this.tooltip.stop(false, true).fadeOut(); this._trigger( "close", event ); } -- cgit v1.2.3 From 61b4b3e445b0065774f22151d02aab2e8e4be245 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Tue, 26 Oct 2010 14:26:53 +0200 Subject: Tooltip: Unit tests cleanup --- tests/unit/tooltip/tooltip.html | 1 + tests/unit/tooltip/tooltip_options.js | 44 +++++++++++++++++++++++------------ 2 files changed, 30 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/unit/tooltip/tooltip.html b/tests/unit/tooltip/tooltip.html index 37bfeafce..a5d76fb8f 100644 --- a/tests/unit/tooltip/tooltip.html +++ b/tests/unit/tooltip/tooltip.html @@ -9,6 +9,7 @@ + diff --git a/tests/unit/tooltip/tooltip_options.js b/tests/unit/tooltip/tooltip_options.js index e0262a947..f7abddb8b 100644 --- a/tests/unit/tooltip/tooltip_options.js +++ b/tests/unit/tooltip/tooltip_options.js @@ -3,24 +3,38 @@ */ (function($) { -module("tooltip: options"); - -function contentTest(name, expected, impl) { - test(name, function() { - $("#tooltipped1").tooltip({ - content: impl - }).tooltip("open"); - same( $(".ui-tooltip").text(), expected ); +module("tooltip: options", { + teardown: function() { $(":ui-tooltip").tooltip("destroy"); - }); -} + } +}); + +test("content: default", function() { + $("#tooltipped1").tooltip().tooltip("open"); + same( $(".ui-tooltip").text(), "anchortitle" ); +}); -contentTest("content: default", "anchortitle"); -contentTest("content: return string", "customstring", function() { - return "customstring"; +test("content: return string", function() { + $("#tooltipped1").tooltip({ + content: function() { + return "customstring"; + } + }).tooltip("open"); + same( $(".ui-tooltip").text(), "customstring" ); }); -contentTest("content: callback string", "customstring2", function(response) { - response("customstring2"); + +test("content: callback string", function() { + stop(); + $("#tooltipped1").tooltip({ + content: function(response) { + response("customstring2"); + setTimeout(function() { + same( $(".ui-tooltip").text(), "customstring2" ); + start(); + }, 100) + } + }).tooltip("open"); + }); test("tooltipClass, default", function() { -- cgit v1.2.3 From 8b4245ac7e8c746af97059ed3ef1c886bccdb903 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Tue, 26 Oct 2010 14:32:03 +0200 Subject: Tooltip: Removing tooltipClass option; use .tooltip("widget").addClass("whatever") instead --- tests/unit/tooltip/tooltip_defaults.js | 1 - tests/unit/tooltip/tooltip_options.js | 13 ------------- ui/jquery.ui.tooltip.js | 4 +--- 3 files changed, 1 insertion(+), 17 deletions(-) (limited to 'tests') diff --git a/tests/unit/tooltip/tooltip_defaults.js b/tests/unit/tooltip/tooltip_defaults.js index bcdcd4307..c9960d334 100644 --- a/tests/unit/tooltip/tooltip_defaults.js +++ b/tests/unit/tooltip/tooltip_defaults.js @@ -5,7 +5,6 @@ var tooltip_defaults = { disabled: false, content: $.ui.tooltip.prototype.options.content, - tooltipClass: "ui-widget-content", position: { my: "left center", at: "right center", diff --git a/tests/unit/tooltip/tooltip_options.js b/tests/unit/tooltip/tooltip_options.js index f7abddb8b..41873ab5b 100644 --- a/tests/unit/tooltip/tooltip_options.js +++ b/tests/unit/tooltip/tooltip_options.js @@ -37,17 +37,4 @@ test("content: callback string", function() { }); -test("tooltipClass, default", function() { - $("#tooltipped1").tooltip().tooltip("open"); - same( $(".ui-tooltip").attr("class"), "ui-tooltip ui-widget ui-corner-all ui-widget-content"); - $(":ui-tooltip").tooltip("destroy"); -}); -test("tooltipClass, custom", function() { - $("#tooltipped1").tooltip({ - tooltipClass: "pretty fancy" - }).tooltip("open"); - same( $(".ui-tooltip").attr("class"), "ui-tooltip ui-widget ui-corner-all pretty fancy"); - $(":ui-tooltip").tooltip("destroy"); -}); - })(jQuery); diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 8341131ca..08d2e616a 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -23,7 +23,6 @@ var increments = 0; $.widget("ui.tooltip", { options: { - tooltipClass: "ui-widget-content", content: function() { return $(this).attr("title"); }, @@ -39,8 +38,7 @@ $.widget("ui.tooltip", { .attr("id", "ui-tooltip-" + increments++) .attr("role", "tooltip") .attr("aria-hidden", "true") - .addClass("ui-tooltip ui-widget ui-corner-all") - .addClass(this.options.tooltipClass) + .addClass("ui-tooltip ui-widget ui-corner-all ui-widget-content") .appendTo(document.body) .hide(); this.tooltipContent = $("
    ") -- cgit v1.2.3 From bdd815e8dcdeace8be6dd8005ef443bc5ea20548 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Tue, 26 Oct 2010 15:36:43 +0200 Subject: Tooltip: Demo and tests update --- tests/unit/tooltip/tooltip_options.js | 9 +++++++++ tests/visual/tooltip/tooltip.html | 15 ++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'tests') diff --git a/tests/unit/tooltip/tooltip_options.js b/tests/unit/tooltip/tooltip_options.js index 41873ab5b..99d582489 100644 --- a/tests/unit/tooltip/tooltip_options.js +++ b/tests/unit/tooltip/tooltip_options.js @@ -23,6 +23,15 @@ test("content: return string", function() { same( $(".ui-tooltip").text(), "customstring" ); }); +test("content: return jQuery", function() { + $("#tooltipped1").tooltip({ + content: function() { + return $("
    ").html("customstring"); + } + }).tooltip("open"); + same( $(".ui-tooltip").text(), "customstring" ); +}); + test("content: callback string", function() { stop(); $("#tooltipped1").tooltip({ diff --git a/tests/visual/tooltip/tooltip.html b/tests/visual/tooltip/tooltip.html index 7b931b155..1e2832e34 100644 --- a/tests/visual/tooltip/tooltip.html +++ b/tests/visual/tooltip/tooltip.html @@ -24,12 +24,10 @@ $("#context1 a, form input, #childish").tooltip(); // custom class, replaces ui-widget-content - $("#context2 [title]").tooltip({ - tooltipClass: "ui-widget-header" - }); - $("#right1").tooltip({ - tooltipClass: "ui-state-error" - }); + $("#context2 [title]").tooltip().each(function() { + $(this).tooltip("widget").addClass("ui-widget-header"); + }) + $("#right1").tooltip().tooltip("widget").addClass("ui-state-error"); // synchronous content $("#see-footnote").tooltip({ @@ -69,9 +67,8 @@ my: "center top", at: "center bottom", offset: "0 10" - }, - tooltipClass: "ui-state-highlight" - }); + } + }).tooltip("widget").addClass("ui-state-highlight"); var positionOnTop = { position: { -- cgit v1.2.3 From 48a5977d3325869abd7b7ba835eb8ac331fd6eb5 Mon Sep 17 00:00:00 2001 From: jzaefferer Date: Tue, 26 Oct 2010 17:07:22 +0200 Subject: Tooltip: Implementing event delegation support. --- demos/tooltip/ajax/content1.html | 1 + demos/tooltip/ajax/content2.html | 1 + demos/tooltip/custom-animation.html | 2 +- demos/tooltip/default.html | 2 +- demos/tooltip/delegation-mixbag.html | 73 ++++++++++++++++++++++++++++++++++ demos/tooltip/index.html | 1 + demos/tooltip/tracking.html | 2 +- tests/unit/tooltip/tooltip_defaults.js | 1 + tests/unit/tooltip/tooltip_events.js | 4 +- tests/unit/tooltip/tooltip_options.js | 5 +++ tests/visual/tooltip/tooltip.html | 45 +++++++++++---------- ui/jquery.ui.tooltip.js | 7 ++-- 12 files changed, 116 insertions(+), 28 deletions(-) create mode 100644 demos/tooltip/ajax/content1.html create mode 100644 demos/tooltip/ajax/content2.html create mode 100644 demos/tooltip/delegation-mixbag.html (limited to 'tests') diff --git a/demos/tooltip/ajax/content1.html b/demos/tooltip/ajax/content1.html new file mode 100644 index 000000000..a1401b26d --- /dev/null +++ b/demos/tooltip/ajax/content1.html @@ -0,0 +1 @@ +

    This content was loaded via ajax.

    \ No newline at end of file diff --git a/demos/tooltip/ajax/content2.html b/demos/tooltip/ajax/content2.html new file mode 100644 index 000000000..f4132d731 --- /dev/null +++ b/demos/tooltip/ajax/content2.html @@ -0,0 +1 @@ +

    This other content was loaded via ajax.

    \ No newline at end of file diff --git a/demos/tooltip/custom-animation.html b/demos/tooltip/custom-animation.html index 585360d7c..1353e3b91 100644 --- a/demos/tooltip/custom-animation.html +++ b/demos/tooltip/custom-animation.html @@ -11,7 +11,7 @@ + + + +
    + + + + + +
    +
    This is the footnote, including other elements
    +
    This is the other footnote, including other elements
    +
    +
    + + + +
    + +

    Show how to combine different event delegated tooltips into a single instance, by customizing the items and content options.

    + +
    + + + + + diff --git a/demos/tooltip/index.html b/demos/tooltip/index.html index e55575d4c..6bc9c1e5c 100644 --- a/demos/tooltip/index.html +++ b/demos/tooltip/index.html @@ -13,6 +13,7 @@
  • Forms with tooltips
  • Track the mouse
  • Custom animation
  • +
  • Delegation Mixbag
  • diff --git a/demos/tooltip/tracking.html b/demos/tooltip/tracking.html index 9af4d0d09..286f01209 100644 --- a/demos/tooltip/tracking.html +++ b/demos/tooltip/tracking.html @@ -11,7 +11,7 @@