mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 00:32:52 +08:00
FIX: shift+click on links
Default browser's behavior when shift+clicking was messed up. This adds the shift key modifier to the list of click modifiers in both `click_track` and `discourse`. Also updated & refactored a bit the `click_track_spec`.
This commit is contained in:
@ -152,25 +152,30 @@ describe("Discourse.ClickTrack", function() {
|
||||
spyOn(window, 'open');
|
||||
});
|
||||
|
||||
it("opens in a new tab when pressing alt", function() {
|
||||
clickEvent.metaKey = true;
|
||||
var expectItOpensInANewTab = function() {
|
||||
expect(track(clickEvent)).toBe(false);
|
||||
expect(Discourse.ajax).toHaveBeenCalled();
|
||||
expect(window.open).toHaveBeenCalledWith('http://www.google.com', '_blank');
|
||||
};
|
||||
|
||||
it("opens in a new tab when pressing shift", function() {
|
||||
clickEvent.shiftKey = true;
|
||||
expectItOpensInANewTab();
|
||||
});
|
||||
|
||||
it("opens in a new tab when pressing meta", function() {
|
||||
clickEvent.metaKey = true;
|
||||
expectItOpensInANewTab();
|
||||
});
|
||||
|
||||
it("opens in a new tab when pressing ctrl", function() {
|
||||
clickEvent.ctrlKey = true;
|
||||
expect(track(clickEvent)).toBe(false);
|
||||
expect(Discourse.ajax).toHaveBeenCalled();
|
||||
expect(window.open).toHaveBeenCalledWith('http://www.google.com', '_blank');
|
||||
expectItOpensInANewTab();
|
||||
});
|
||||
|
||||
it("opens in a new tab when middle clicking", function() {
|
||||
clickEvent.which = 2;
|
||||
expect(track(clickEvent)).toBe(false);
|
||||
expect(Discourse.ajax).toHaveBeenCalled();
|
||||
expect(window.open).toHaveBeenCalledWith('http://www.google.com', '_blank');
|
||||
expectItOpensInANewTab();
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user