Merge lp:~twom/loggerhead/animation-binding into lp:loggerhead

Proposed by Tom Wardill
Status: Merged
Approved by: Tom Wardill
Approved revision: 507
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: lp:~twom/loggerhead/animation-binding
Merge into: lp:loggerhead
Diff against target: 52 lines (+5/-5)
2 files modified
loggerhead/static/javascript/custom.js (+4/-4)
loggerhead/static/javascript/diff.js (+1/-1)
To merge this branch: bzr merge lp:~twom/loggerhead/animation-binding
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+390489@code.launchpad.net

Commit message

Fix animation binding and item iteration

Description of the change

The move to jQuery needs some adjustment in how animation callbacks work.
The callback is handed the DOM object, not the javascript object, so `this` refers to the wrong object. Use `.bind(this)` to ensure we have the correct object.
Also fix the arguments for iteration.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'loggerhead/static/javascript/custom.js'
2--- loggerhead/static/javascript/custom.js 2020-06-04 19:43:36 +0000
3+++ loggerhead/static/javascript/custom.js 2020-09-09 16:46:30 +0000
4@@ -106,7 +106,7 @@
5 if (this._loading) return;
6 if (callback) callback();
7 this.is_open = true;
8- });
9+ }.bind(this));
10 }
11
12 Collapsable.prototype._load_finished = function(data, callback)
13@@ -174,7 +174,7 @@
14
15 Collapsable.prototype.open = function(callback)
16 {
17- this.expand_icon.src = expanded_icon_path;
18+ this.expand_icon[0].src = expanded_icon_path;
19
20 this._ensure_container();
21
22@@ -223,7 +223,7 @@
23
24 var anim = $(this.container).animate(
25 { marginBottom: [0, close_height - open_height]},
26- 0.2, "swing", this.closeComplete);
27+ 0.2, "swing", this.closeComplete.bind(this));
28 };
29
30 Collapsable.prototype.closeComplete = function () {
31@@ -232,7 +232,7 @@
32 $(this.close_node).css({'display': 'block'});
33 }
34 $(this.container).css({'marginBottom': 0});
35- this.expand_icon.set('src', collapsed_icon_path);
36+ this.expand_icon[0].src = collapsed_icon_path;
37 this.is_open = false;
38 };
39
40
41=== modified file 'loggerhead/static/javascript/diff.js'
42--- loggerhead/static/javascript/diff.js 2020-06-04 19:43:36 +0000
43+++ loggerhead/static/javascript/diff.js 2020-09-09 16:46:30 +0000
44@@ -109,7 +109,7 @@
45 var diffs = $('.diff');
46 if (diffs == null) return;
47 diffs.each(
48- function(item, i)
49+ function(i, item)
50 {
51 var collapsable = item.collapsable;
52 if(action == 'close')

Subscribers

People subscribed via source and target branches