Skip to content

Commit 0f4a65c

Browse files
committed
Merge branch 'master' into release
2 parents bfd7671 + be469ae commit 0f4a65c

File tree

5 files changed

+55
-15
lines changed

5 files changed

+55
-15
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"AnythingSlider": "1.8.17",
1717
"chosen": "0.9.11",
1818
"jquery-form": "3.46.0",
19-
"fullcalendar": "http://arshaw.com/fullcalendar/downloads/fullcalendar-2.0.0.zip",
19+
"fullcalendar": "https://github.com/arshaw/fullcalendar/releases/download/v2.0.0/fullcalendar-2.0.0.zip",
2020
"jquery-placeholder": "2.0.7",
2121
"prefixfree": "",
2222
"select2": "3.4.3",

changes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
- #377 Local inject doesn't work for IE10 and 11
66
- #378 pat-switch detecting click on container of link prevent default on anchor
7-
- #379 Local inject doesn't work for IE10 and 11
7+
- #379 pat-checklist selectAll/deselectAll only works inside .pat-checklist element
88

99

1010
## 2.0.1 - Sept. 2, 2014

src/pat/inject.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ define([
558558
if ($scrollable.length) {
559559
// if scrollable parent and visible -> trigger it
560560
// we only look at the closest scrollable parent, no nesting
561-
checkVisibility = function inject_checkVisibility_scrollable() {
561+
checkVisibility = utils.debounce(function inject_checkVisibility_scrollable() {
562562
if ($el.data("patterns.autoload"))
563563
return false;
564564
var reltop = $el.offset().top - $scrollable.offset().top - 1000,
@@ -571,28 +571,28 @@ define([
571571
return trigger();
572572
}
573573
return false;
574-
};
574+
}, 100);
575575
if (checkVisibility())
576576
return true;
577577

578578
// wait to become visible - again only immediate scrollable parent
579-
$($scrollable[0]).on("scroll", utils.debounce(checkVisibility, 100));
580-
$(window).on("resize.pat-autoload", utils.debounce(checkVisibility, 100));
579+
$($scrollable[0]).on("scroll", checkVisibility);
580+
$(window).on("resize.pat-autoload", checkVisibility);
581581
} else {
582582
// Use case 2: scrolling the entire page
583-
checkVisibility = function inject_checkVisibility_not_scrollable() {
583+
checkVisibility = utils.debounce(function inject_checkVisibility_not_scrollable() {
584584
if ($el.data("patterns.autoload"))
585585
return false;
586586
if (!utils.elementInViewport($el[0]))
587587
return false;
588588

589589
$(window).off(".pat-autoload", checkVisibility);
590590
return trigger();
591-
};
591+
}, 100);
592592
if (checkVisibility())
593593
return true;
594594
$(window).on("resize.pat-autoload scroll.pat-autoload",
595-
utils.debounce(checkVisibility, 100));
595+
checkVisibility);
596596
}
597597
return false;
598598
},

src/pat/tooltip.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,15 @@ define([
213213
var $trigger = event.data,
214214
$container = tooltip.getContainer($trigger),
215215
namespace = $container.attr("id");
216-
$container.css("visibility", "hidden");
217-
$container.parents().add(window).off("." + namespace);
218-
tooltip.removeHideEvents($trigger);
219-
tooltip.setupShowEvents($trigger);
220-
$trigger.removeClass("active").addClass("inactive");
221-
$trigger.trigger("pat-update", {pattern: "tooltip", hidden: true});
216+
// when another tooltip trigger is clicked, only close the previous tooltip if it does not contain the trigger
217+
if (event.type !== "pat-tooltip-click" || $container.has(event.target).length <= 0) {
218+
$container.css("visibility", "hidden");
219+
$container.parents().add(window).off("." + namespace);
220+
tooltip.removeHideEvents($trigger);
221+
tooltip.setupShowEvents($trigger);
222+
$trigger.removeClass("active").addClass("inactive");
223+
$trigger.trigger("pat-update", {pattern: "tooltip", hidden: true});
224+
}
222225
},
223226

224227
onDestroy: function(event) {

tests/specs/pat/tooltip.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,43 @@ define(["pat-tooltip", "pat-inject"], function(pattern, inject) {
252252
});
253253
});
254254
});
255+
256+
describe("A tooltip that opens on click and contains another tooltip trigger", function () {
257+
beforeEach(function() {
258+
utils.createTooltip({
259+
data: "trigger: click; source: content",
260+
href: "#tooltip-content"
261+
});
262+
$("<div />", {
263+
"id": "tooltip-content"
264+
}).appendTo($("div#lab"));
265+
$("<a/>", {
266+
"id": "nested-tooltip",
267+
"href": "#nested-tooltip-content",
268+
"title": "nested tooltip title attribute",
269+
"data-pat-tooltip": "trigger: click; source: content",
270+
"class": "pat-tooltip"
271+
}).appendTo($("div#tooltip-content"));
272+
});
273+
afterEach(function() {
274+
utils.removeTooltip();
275+
});
276+
it("will not close if the contained trigger is clicked", function () {
277+
runs(function () {
278+
spyOn(pattern, "show").andCallThrough();
279+
var $el = $("a#tooltip");
280+
pattern.init($el);
281+
pattern.init($("a#nested-tooltip"));
282+
$el.trigger(utils.click);
283+
expect(pattern.show).toHaveBeenCalled();
284+
});
285+
waits(100); // hide events get registered 50 ms after show
286+
runs(function () {
287+
$(".tooltip-container a#nested-tooltip").trigger(utils.click);
288+
expect($(".tooltip-container a#nested-tooltip").css("visibility")).toBe("visible");
289+
});
290+
});
291+
});
255292
});
256293
});
257294
// jshint indent: 4, browser: true, jquery: true, quotmark: double

0 commit comments

Comments
 (0)