Merge lp:~allenap/launchpad/localpackagediffs-mouse-pointer-bug-815788 into lp:launchpad

Proposed by Gavin Panella
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 13565
Proposed branch: lp:~allenap/launchpad/localpackagediffs-mouse-pointer-bug-815788
Merge into: lp:launchpad
Prerequisite: lp:~allenap/launchpad/localpackagediffs-filter-by-person-or-team-bug-798873-ui
Diff against target: 74 lines (+21/-4)
2 files modified
lib/lp/registry/javascript/distroseries/differences.js (+12/-4)
lib/lp/registry/javascript/distroseries/tests/test_differences.js (+9/-0)
To merge this branch: bzr merge lp:~allenap/launchpad/localpackagediffs-mouse-pointer-bug-815788
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+69820@code.launchpad.net

Commit message

[r=allenap][bug=815788] On DistroSeries:+localpackagediffs ensure that links dynamically added from JavaScript have a similar visual appearance and behaviour to others on Launchpad.

Description of the change

This branch does three small things in the
lp.registry.distroseries.differences JavaScript module:

- Changes linkify() to set href:

+ /* Set the href so that the visual display is consistent with
+ other links (cursor most notably). */

- Now that the links produced by linkify() have hrefs, the events
  produced by click have to be halted once we've done our thing.

- The test suite was failing because it was looking for the LP
  global. I've added this to the test case set up and tear down.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/javascript/distroseries/differences.js'
2--- lib/lp/registry/javascript/distroseries/differences.js 2011-07-29 15:53:15 +0000
3+++ lib/lp/registry/javascript/distroseries/differences.js 2011-07-29 15:53:15 +0000
4@@ -89,7 +89,10 @@
5 *
6 */
7 var linkify = function(node) {
8- var link = Y.Node.create('<a class="js-action sprite edit" />');
9+ /* Set the href so that the visual display is consistent with
10+ other links (cursor most notably). */
11+ var link = Y.Node.create(
12+ '<a href="#" class="js-action sprite edit" />');
13 link.set("innerHTML", node.get("innerHTML"));
14 node.empty().append(link);
15 return link;
16@@ -194,8 +197,10 @@
17 overlay.after("visibleChange", initialize_picker);
18
19 /* Linkify the origin and show the overlay when it's clicked. */
20- var link = linkify(origin);
21- link.on("click", function() { overlay.show(); });
22+ linkify(origin).on("click", function(e) {
23+ e.halt();
24+ overlay.show();
25+ });
26 };
27
28
29@@ -257,7 +262,10 @@
30 });
31
32 /* Linkify the origin and show the picker when it's clicked. */
33- linkify(origin).on("click", function(e) { picker.show(); });
34+ linkify(origin).on("click", function(e) {
35+ e.halt();
36+ picker.show();
37+ });
38
39 return picker;
40 };
41
42=== modified file 'lib/lp/registry/javascript/distroseries/tests/test_differences.js'
43--- lib/lp/registry/javascript/distroseries/tests/test_differences.js 2011-07-29 15:53:15 +0000
44+++ lib/lp/registry/javascript/distroseries/tests/test_differences.js 2011-07-29 15:53:15 +0000
45@@ -85,6 +85,9 @@
46 Assert.areSame(link, target.one("a"));
47 Assert.areSame("Foobar", link.get("text"));
48 Assert.isTrue(link.hasClass("js-action"));
49+ var href = link.get("href");
50+ Assert.isString(href);
51+ Assert.isTrue(href.length > 0);
52 }
53
54 };
55@@ -95,6 +98,11 @@
56 name: "TestLastChangedPicker",
57
58 setUp: function() {
59+ window.LP = {
60+ links: {
61+ me: "~foobar"
62+ }
63+ };
64 var body = Y.one(document.body);
65 this.form = Y.Node.create("<form />").appendTo(body);
66 this.origin = Y.Node.create("<div>Origin</div>").appendTo(body);
67@@ -106,6 +114,7 @@
68 this.picker.get("boundingBox").remove(true);
69 this.origin.remove(true);
70 this.form.remove(true);
71+ delete window.LP;
72 },
73
74 test_linkify_click_activates_picker: function() {