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
=== modified file 'lib/lp/registry/javascript/distroseries/differences.js'
--- lib/lp/registry/javascript/distroseries/differences.js 2011-07-29 15:53:15 +0000
+++ lib/lp/registry/javascript/distroseries/differences.js 2011-07-29 15:53:15 +0000
@@ -89,7 +89,10 @@
89 *89 *
90 */90 */
91var linkify = function(node) {91var linkify = function(node) {
92 var link = Y.Node.create('<a class="js-action sprite edit" />');92 /* Set the href so that the visual display is consistent with
93 other links (cursor most notably). */
94 var link = Y.Node.create(
95 '<a href="#" class="js-action sprite edit" />');
93 link.set("innerHTML", node.get("innerHTML"));96 link.set("innerHTML", node.get("innerHTML"));
94 node.empty().append(link);97 node.empty().append(link);
95 return link;98 return link;
@@ -194,8 +197,10 @@
194 overlay.after("visibleChange", initialize_picker);197 overlay.after("visibleChange", initialize_picker);
195198
196 /* Linkify the origin and show the overlay when it's clicked. */199 /* Linkify the origin and show the overlay when it's clicked. */
197 var link = linkify(origin);200 linkify(origin).on("click", function(e) {
198 link.on("click", function() { overlay.show(); });201 e.halt();
202 overlay.show();
203 });
199};204};
200205
201206
@@ -257,7 +262,10 @@
257 });262 });
258263
259 /* Linkify the origin and show the picker when it's clicked. */264 /* Linkify the origin and show the picker when it's clicked. */
260 linkify(origin).on("click", function(e) { picker.show(); });265 linkify(origin).on("click", function(e) {
266 e.halt();
267 picker.show();
268 });
261269
262 return picker;270 return picker;
263};271};
264272
=== modified file 'lib/lp/registry/javascript/distroseries/tests/test_differences.js'
--- lib/lp/registry/javascript/distroseries/tests/test_differences.js 2011-07-29 15:53:15 +0000
+++ lib/lp/registry/javascript/distroseries/tests/test_differences.js 2011-07-29 15:53:15 +0000
@@ -85,6 +85,9 @@
85 Assert.areSame(link, target.one("a"));85 Assert.areSame(link, target.one("a"));
86 Assert.areSame("Foobar", link.get("text"));86 Assert.areSame("Foobar", link.get("text"));
87 Assert.isTrue(link.hasClass("js-action"));87 Assert.isTrue(link.hasClass("js-action"));
88 var href = link.get("href");
89 Assert.isString(href);
90 Assert.isTrue(href.length > 0);
88 }91 }
8992
90 };93 };
@@ -95,6 +98,11 @@
95 name: "TestLastChangedPicker",98 name: "TestLastChangedPicker",
9699
97 setUp: function() {100 setUp: function() {
101 window.LP = {
102 links: {
103 me: "~foobar"
104 }
105 };
98 var body = Y.one(document.body);106 var body = Y.one(document.body);
99 this.form = Y.Node.create("<form />").appendTo(body);107 this.form = Y.Node.create("<form />").appendTo(body);
100 this.origin = Y.Node.create("<div>Origin</div>").appendTo(body);108 this.origin = Y.Node.create("<div>Origin</div>").appendTo(body);
@@ -106,6 +114,7 @@
106 this.picker.get("boundingBox").remove(true);114 this.picker.get("boundingBox").remove(true);
107 this.origin.remove(true);115 this.origin.remove(true);
108 this.form.remove(true);116 this.form.remove(true);
117 delete window.LP;
109 },118 },
110119
111 test_linkify_click_activates_picker: function() {120 test_linkify_click_activates_picker: function() {