Merge lp:~deryck/launchpad/icon-positioning-js-400057 into lp:launchpad

Proposed by Deryck Hodge
Status: Merged
Merged at revision: not available
Proposed branch: lp:~deryck/launchpad/icon-positioning-js-400057
Merge into: lp:launchpad
Diff against target: None lines
To merge this branch: bzr merge lp:~deryck/launchpad/icon-positioning-js-400057
Reviewer Review Type Date Requested Status
Guilherme Salgado (community) Approve
Review via email: mp+9256@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Deryck Hodge (deryck) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

= Summary =

After the addition of r8886 in devel, the add/remove icons are set via
sprite classes and positioned differently than when the JavaScript for
handling inline subscribing was originally written. So when subscribing
inline the icons are positioned incorrectly currently. This problem is
captured in bug 400057.

== Proposed fix ==

The correct fix is to get have the js that generates HTML use sprite
classes instead of inserting images.

== Pre-implementation notes ==

I didn't have any specific pre-imp discussions but plenty of discussion
happened on bug 383555 and bug 401658.

== Implementation details ==

This fix is pretty simple, just matching the current UI classes in js.
There are some outstanding questions about alignment from mpt in bug 401658.

== Tests ==

A Windmill test has been updated, and can be run with:

./bin/lp-windmill -e
test=lib/lp/bugs/windmill/tests/test_bugs/test_bug_inline_subscriber.py
firefox http://bugs.launchpad.dev:8085

== Demo and Q/A ==

Subscribe and unsubscribe yourself a couple times and note that the
remove icon should appear to the right of the "Unsubscribe" link and
should be flush with the link. The add icon should always be to the
left of the link.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/canonical/launchpad/javascript/bugs/subscriber.js
  lib/canonical/launchpad/javascript/bugs/bugtask-index.js
  lib/lp/bugs/windmill/tests/test_bugs/test_bug_inline_subscriber.py

== JSLint notices ==
jslint: Lint found in
'/home/deryck/canonical/lp-branches/icon-positioning-js-400057/lib/canonical/launchpad/javascript/bugs/bugtask-index.js':
Line 1263 character 58: Missing semicolon.
        status_content.on('click', function(e) { e.halt() });

Line 1264 character 62: Missing semicolon.
        importance_content.on('click', function(e) { e.halt() });

jslint: No problem found in
'/home/deryck/canonical/lp-branches/icon-positioning-js-400057/lib/canonical/launchpad/javascript/bugs/subscriber.js'.

jslint: 2 files to lint.

(Note: These lint notices are fixed in another, not yet landed, branch.)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpp+FkACgkQ4glRK0DaE8j69ACgt9PkUAVbefqAgoZMthVAwuTg
B9IAoK2TEaVe6IAfg1L76ulTBQF0gGA+
=MhGd
-----END PGP SIGNATURE-----

Revision history for this message
Guilherme Salgado (salgado) wrote :

Looks good to me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/javascript/bugs/bugtask-index.js'
2--- lib/canonical/launchpad/javascript/bugs/bugtask-index.js 2009-07-17 18:46:25 +0000
3+++ lib/canonical/launchpad/javascript/bugs/bugtask-index.js 2009-07-24 17:21:52 +0000
4@@ -714,21 +714,23 @@
5 terms.subscribed_by = 'by ' + full_name;
6 }
7
8- if (subscription.is_team()) {
9- terms.img_url = '/@@/team';
10- } else {
11- terms.img_url = '/@@/person';
12- }
13-
14- var html = Y.Node.create(
15- '<div><a><img alt="" width="14" height="14" />' +
16- '&nbsp;</a></div>');
17+ var html = Y.Node.create('<div><a></a></div>');
18 html.addClass('subscriber-' + terms.name);
19- html.query('img').set('src', terms.img_url);
20+
21 html.query('a')
22 .set('href', '/~' + terms.name)
23 .set('name', terms.full_name)
24- .set('title', 'Subscribed ' + terms.subscribed_by)
25+ .set('title', 'Subscribed ' + terms.subscribed_by);
26+
27+ var span;
28+ if (subscription.is_team()) {
29+ span = '<span class="sprite team"></span>';
30+ } else {
31+ span = '<span class="sprite person"></span>';
32+ }
33+
34+ html.query('a')
35+ .appendChild(Y.Node.create(span))
36 .appendChild(document.createTextNode(terms.display_name));
37
38 // Add remove icon if the current user can unsubscribe the subscriber.
39@@ -1079,8 +1081,8 @@
40 subscription.set('has_dupes', true);
41 }
42 }
43- subscription_link.setStyle('background',
44- 'url(/@@/add) left center no-repeat');
45+ subscription_link.removeClass('sprite-after remove');
46+ subscription_link.addClass('sprite add');
47 });
48 anim.run();
49 },
50@@ -1125,8 +1127,6 @@
51 var config = {
52 on: {
53 success: function(client) {
54- subscription_link.setStyle('background',
55- 'url(/@@/remove) left center no-repeat');
56 subscription.disable_spinner('Unsubscribe');
57
58 if (subscription.has_duplicate_subscriptions()) {
59
60=== modified file 'lib/canonical/launchpad/javascript/bugs/subscriber.js'
61--- lib/canonical/launchpad/javascript/bugs/subscriber.js 2009-07-08 20:42:19 +0000
62+++ lib/canonical/launchpad/javascript/bugs/subscriber.js 2009-07-24 17:21:52 +0000
63@@ -163,17 +163,18 @@
64 */
65 'disable_spinner': function(text) {
66 if (Y.Lang.isValue(text)) {
67- this.get('link').set('innerHTML', text);
68+ var link = this.get('link');
69+ link.set('innerHTML', text);
70 if (text == 'Subscribe') {
71- this.get('link').setStyle('background',
72- 'url(/@@/add) left center no-repeat');
73+ link.removeClass('sprite-after remove');
74+ link.addClass('sprite add');
75 } else {
76- this.get('link').setStyle('background',
77- 'url(/@@/remove) left center no-repeat');
78+ link.removeClass('sprite add');
79+ link.addClass('sprite-after remove');
80 }
81 }
82 this.get('spinner').setStyle('display', 'none');
83- this.get('link').setStyle('display', 'block');
84+ this.get('link').setStyle('display', 'inline');
85 }
86 });
87
88
89=== modified file 'lib/lp/bugs/windmill/tests/test_bugs/test_bug_inline_subscriber.py'
90--- lib/lp/bugs/windmill/tests/test_bugs/test_bug_inline_subscriber.py 2009-07-17 00:26:05 +0000
91+++ lib/lp/bugs/windmill/tests/test_bugs/test_bug_inline_subscriber.py 2009-07-24 17:50:13 +0000
92@@ -45,7 +45,7 @@
93 client.asserts.assertNode(classname=SAMPLE_PERSON_CLASS)
94 client.asserts.assertProperty(
95 xpath=SUBSCRIPTION_LINK,
96- validator=u'style.backgroundImage|url(/@@/remove)')
97+ validator=u'className|remove')
98
99 # Make sure the unsubscribe link also works, that
100 # the person's named is removed from the subscriber's list,
101@@ -56,7 +56,7 @@
102 xpath=SUBSCRIPTION_LINK, validator=u'Subscribe')
103 client.asserts.assertProperty(
104 xpath=SUBSCRIPTION_LINK,
105- validator=u'style.backgroundImage|url(/@@/add)')
106+ validator=u'className|add')
107 client.asserts.assertNotNode(classname=SAMPLE_PERSON_CLASS)
108
109 # Subscribe again in order to check that the minus icon
110@@ -71,7 +71,7 @@
111 xpath=SUBSCRIPTION_LINK, validator=u'Subscribe')
112 client.asserts.assertProperty(
113 xpath=SUBSCRIPTION_LINK,
114- validator=u'style.backgroundImage|url(/@@/add)')
115+ validator=u'className|add')
116 client.asserts.assertNotNode(classname=SAMPLE_PERSON_CLASS)
117
118 # Test inline subscribing of others by subscribing Ubuntu Team.