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