Merge lp:~thumper/launchpad/js-play into lp:launchpad

Proposed by Tim Penhey
Status: Merged
Approved by: Tim Penhey
Approved revision: not available
Merged at revision: 10226
Proposed branch: lp:~thumper/launchpad/js-play
Merge into: lp:launchpad
Diff against target: 95 lines (+44/-9)
2 files modified
lib/canonical/launchpad/javascript/code/codereview.js (+43/-8)
lib/lp/code/templates/branchmergeproposal-index.pt (+1/-1)
To merge this branch: bzr merge lp:~thumper/launchpad/js-play
Reviewer Review Type Date Requested Status
Michael Nelson (community) ui Approve
Paul Hummer (community) code ui* Approve
Review via email: mp+17193@code.launchpad.net

Commit message

provide smooth scrolling down to the diff

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

I think this is all untestable javascript.

Revision history for this message
Paul Hummer (rockstar) wrote :

Thanks for moving the brace to be the right way.

review: Approve (code ui*)
Revision history for this message
Paul Hummer (rockstar) wrote :

Please change:

    if (!link) return;

...to...

    if (Y.lang.isValue(link)) return;

Revision history for this message
Michael Nelson (michael.nelson) wrote :

Thanks for the demo Tim! It's great seeing this page just getting better and better.

review: Approve (ui)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/javascript/code/codereview.js'
2--- lib/canonical/launchpad/javascript/code/codereview.js 2009-12-17 04:17:12 +0000
3+++ lib/canonical/launchpad/javascript/code/codereview.js 2010-01-18 09:02:22 +0000
4@@ -14,13 +14,19 @@
5 var reviewer_picker; // The "Request a review" overlay
6 var lp_client;
7
8+var window_scroll_anim = new Y.Anim({
9+ node: 'window',
10+ duration: 1,
11+ easing: Y.Easing.easeOut
12+ });
13+
14 /*
15 * Connect all the links to their given actions.
16 */
17 Y.codereview.connect_links = function() {
18
19 var link = Y.one('#request-review');
20- if (link !== null) {
21+ if (Y.Lang.isValue(link)) {
22 link.addClass('js-action');
23 /* XXX: salgado 2009-11-11 bug=497603
24 * This will cause the picker to be recreated every time the
25@@ -34,19 +40,48 @@
26 link.on('click', show_request_review_form);
27 }
28 link = Y.one('.menu-link-set_commit_message');
29- if (link !== null) {
30+ if (Y.Lang.isValue(link)) {
31 link.addClass('js-action');
32 link.on('click', edit_commit_message);
33 }
34- var widget = Y.lp.widgets['edit-commit-message'];
35- widget.editor.on('save', function() {
36- commit_message_listener(this.get('value'), true);
37- });
38- widget.editor.on('cancel', function() {
39- commit_message_listener(this.get('value'), false);
40+ if (Y.Lang.isValue(Y.lp.widgets)) {
41+ var widget = Y.lp.widgets['edit-commit-message'];
42+ if (Y.Lang.isValue(widget)) {
43+ widget.editor.on('save', function() {
44+ commit_message_listener(this.get('value'), true);
45+ });
46+ widget.editor.on('cancel', function() {
47+ commit_message_listener(this.get('value'), false);
48+ });
49+ }
50+ }
51+ link_scroller('#proposal-summary a.diff-link', '#review-diff');
52+ link_scroller('.menu-link-add_comment', '#add-comment', function() {
53+ Y.one('#add-comment-form textarea').focus();
54 });
55 };
56
57+
58+function link_scroller(link_selector, node_selector, on_end) {
59+ var link = Y.one(link_selector);
60+ if (!Y.Lang.isValue(link)) return;
61+
62+ link.addClass('js-action');
63+ link.on('click', function(e) {
64+ e.halt();
65+ // Stop any running scrolling.
66+ window_scroll_anim.stop();
67+ // Detach any on end handlers.
68+ window_scroll_anim.detach('anim:end');
69+ var node = Y.one(node_selector);
70+ window_scroll_anim.set('to', {scroll: [0, node.getY() - 5] });
71+ if (on_end) {
72+ window_scroll_anim.on('end', on_end);
73+ }
74+ window_scroll_anim.run();
75+ });
76+}
77+
78 /*
79 * Hide the commit message editor if the value is empty.
80 *
81
82=== modified file 'lib/lp/code/templates/branchmergeproposal-index.pt'
83--- lib/lp/code/templates/branchmergeproposal-index.pt 2010-01-13 21:49:43 +0000
84+++ lib/lp/code/templates/branchmergeproposal-index.pt 2010-01-18 09:02:22 +0000
85@@ -213,9 +213,9 @@
86 return;
87 }
88
89- Y.code.codereview.connect_links();
90 Y.code.branchmergeproposal.connect_status(conf);
91 }
92+ Y.code.codereview.connect_links();
93 (new Y.codereview.NumberToggle()).render();
94 }, window);
95 });