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
=== modified file 'loggerhead/static/javascript/custom.js'
--- loggerhead/static/javascript/custom.js 2020-06-04 19:43:36 +0000
+++ loggerhead/static/javascript/custom.js 2020-09-09 16:46:30 +0000
@@ -106,7 +106,7 @@
106 if (this._loading) return;106 if (this._loading) return;
107 if (callback) callback();107 if (callback) callback();
108 this.is_open = true;108 this.is_open = true;
109 });109 }.bind(this));
110}110}
111111
112Collapsable.prototype._load_finished = function(data, callback)112Collapsable.prototype._load_finished = function(data, callback)
@@ -174,7 +174,7 @@
174174
175Collapsable.prototype.open = function(callback)175Collapsable.prototype.open = function(callback)
176{176{
177 this.expand_icon.src = expanded_icon_path;177 this.expand_icon[0].src = expanded_icon_path;
178178
179 this._ensure_container();179 this._ensure_container();
180180
@@ -223,7 +223,7 @@
223223
224 var anim = $(this.container).animate(224 var anim = $(this.container).animate(
225 { marginBottom: [0, close_height - open_height]},225 { marginBottom: [0, close_height - open_height]},
226 0.2, "swing", this.closeComplete);226 0.2, "swing", this.closeComplete.bind(this));
227};227};
228228
229Collapsable.prototype.closeComplete = function () {229Collapsable.prototype.closeComplete = function () {
@@ -232,7 +232,7 @@
232 $(this.close_node).css({'display': 'block'});232 $(this.close_node).css({'display': 'block'});
233 }233 }
234 $(this.container).css({'marginBottom': 0});234 $(this.container).css({'marginBottom': 0});
235 this.expand_icon.set('src', collapsed_icon_path);235 this.expand_icon[0].src = collapsed_icon_path;
236 this.is_open = false;236 this.is_open = false;
237};237};
238238
239239
=== modified file 'loggerhead/static/javascript/diff.js'
--- loggerhead/static/javascript/diff.js 2020-06-04 19:43:36 +0000
+++ loggerhead/static/javascript/diff.js 2020-09-09 16:46:30 +0000
@@ -109,7 +109,7 @@
109 var diffs = $('.diff');109 var diffs = $('.diff');
110 if (diffs == null) return;110 if (diffs == null) return;
111 diffs.each(111 diffs.each(
112 function(item, i)112 function(i, item)
113 {113 {
114 var collapsable = item.collapsable;114 var collapsable = item.collapsable;
115 if(action == 'close')115 if(action == 'close')

Subscribers

People subscribed via source and target branches