Merge lp:~benji/launchpad/bug-779538 into lp:launchpad

Proposed by Benji York
Status: Superseded
Proposed branch: lp:~benji/launchpad/bug-779538
Merge into: lp:launchpad
Diff against target: 69 lines (+26/-18)
2 files modified
lib/canonical/launchpad/icing/style-3-0.css (+3/-13)
lib/lp/app/templates/base-layout-macros.pt (+23/-5)
To merge this branch: bzr merge lp:~benji/launchpad/bug-779538
Reviewer Review Type Date Requested Status
Launchpad code reviewers Pending
Review via email: mp+60552@code.launchpad.net

This proposal has been superseded by a proposal from 2011-05-11.

Description of the change

Bug 779538 describes a regression caused by my recent change to add a
"Hide X" link to notification boxes so the user can dismiss them when
they're no longer needed (especially useful on AJAX-heavy pages).
Unfortunately that behavior extended to links within the notification
box.

When a user would click on a link in a notification box the box would
disappear. This is primarily a problem when control- or shift-clicking
on a link to open it in another browser tab or window.

This branch rectifies that problem by limiting the click-to-close
behavior to the message box itself, excluding any <a> sub-elements.

The make lint report is clean.

To post a comment you must log in.
lp:~benji/launchpad/bug-779538 updated
13019. By Benji York

settled on final approach

Unmerged revisions

13019. By Benji York

settled on final approach

13018. By Benji York

even better

13017. By Benji York

make the comment a little clearer

13016. By Benji York

a much nicer way to handle this

13015. By Benji York

works, but it's ugly

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/icing/style-3-0.css'
2--- lib/canonical/launchpad/icing/style-3-0.css 2011-05-04 14:33:48 +0000
3+++ lib/canonical/launchpad/icing/style-3-0.css 2011-05-11 15:36:43 +0000
4@@ -1017,23 +1017,13 @@
5 .warning.message::before {
6 content: url(/@@/warning-large);
7 }
8-.error.message::after, .warning.message::after,
9-.informational.message::after {
10- /* Add an affordance that suggests the ability to hide the message. */
11- /* The NBSP (\00A0) is needed because of the margin trick below. */
12- content: 'Hide\00A0\2715';
13+.error.message .hider, .warning.message .hider,
14+.informational.message .hider {
15+ color: #333;
16 float: right;
17 display: block;
18 margin-left: 999em; /* Assure the message is always "bumped" down. */
19 }
20-.error.message:hover::after, .warning.message:hover::after,
21-.informational.message:hover::after {
22- text-decoration: underline;
23- }
24-.error.message:hover, .warning.message:hover,
25-.informational.message:hover {
26- cursor: pointer;
27-}
28 .informational {
29 /* Informational messages are blue-to-grey, alerts have an info icon. */
30
31
32=== modified file 'lib/lp/app/templates/base-layout-macros.pt'
33--- lib/lp/app/templates/base-layout-macros.pt 2011-05-03 17:53:50 +0000
34+++ lib/lp/app/templates/base-layout-macros.pt 2011-05-11 15:36:43 +0000
35@@ -125,11 +125,29 @@
36 // anywhere outside of it.
37 Y.on('click', handleClickOnPage, window);
38
39- // Hook up an event hanlder that will close any message boxes when they
40- // are clicked.
41- Y.delegate('click', function(e) {
42- this.setStyle('display', 'none');
43- }, 'body', '.message');
44+ // Add a "Hide" link to a message box.
45+ var add_hide_to_message = function(message) {
46+ if (Y.Lang.isValue(message.one('.hider'))) {
47+ // We've already done this one.
48+ return;
49+ }
50+ var hider = message.appendChild(Y.Node.create('<a/>')
51+ .set('href', '#')
52+ .set('text', 'Hide\u00A0\u2715')
53+ .addClass('hider'));
54+
55+ Y.on('click', function(e) {
56+ message.setStyle('display', 'none');
57+ }, hider);
58+ }
59+
60+ // Periodically check to see if there are any new message boxes on the
61+ // page that need a hide link.
62+ setInterval(function() {
63+ Y.all('.warning.message').each(add_hide_to_message);
64+ Y.all('.informational.message').each(add_hide_to_message);
65+ Y.all('.error.message').each(add_hide_to_message);
66+ }, 500);
67
68 Y.on('lp:context:web_link:changed', function(e) {
69 window.location = e.new_value;