Skip to content

Commit 45699d6

Browse files
committed
Put the Rows instance of RowsView into use
1 parent ae67243 commit 45699d6

2 files changed

Lines changed: 5 additions & 14 deletions

File tree

code_comments/htdocs/code-comments.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
alert(errorText);
1616
});
1717

18-
CodeComments.$tableRows = $( CodeComments.tableSelectors ).not( '.comments' );
19-
2018
window.Comment = Backbone.Model.extend({
2119
});
2220

@@ -114,8 +112,7 @@
114112
if (!this.viewPerLine[line]) {
115113
this.viewPerLine[line] = new CommentsForALineView( { line: line } );
116114

117-
var $tr = $( CodeComments.$tableRows[ line-1 ] );
118-
115+
var $tr = $( Rows.getTrByLineNumber( line ) );
119116
$tr.after(this.viewPerLine[line].render().el).addClass('with-comments');
120117
}
121118
this.viewPerLine[line].addOne(comment);
@@ -132,16 +129,14 @@
132129
tagName: 'tr',
133130
className: 'comments',
134131
template: _.template(CodeComments.templates.comments_for_a_line),
135-
templateData: {},
136132
initialize: function(attrs) {
137133
this.line = attrs.line;
138-
this.templateData.colspan = ( 'changeset' === CodeComments.page ) ? 2 : 1;
139134
},
140135
events: {
141136
'click button': 'showAddCommentDialog'
142137
},
143138
render: function() {
144-
$( this.el ).html( this.template( this.templateData ) );
139+
$( this.el ).html( this.template( { colspan: Rows.getNumberOfTHsPerRow() } ) );
145140
this.$('button').button();
146141
return this;
147142
},
@@ -228,11 +223,6 @@
228223

229224
window.LineCommentBubblesView = Backbone.View.extend({
230225
render: function() {
231-
// wrap TH contents in spans so we can hide/show them
232-
$( 'th', CodeComments.$tableRows ).each( function( i, elem ) {
233-
elem.innerHTML = '<span>' + elem.innerHTML + '</span>';
234-
});
235-
236226
var callbackMouseover = function( event ) {
237227
var $th = ( $( 'th', this ).length) ? $( 'th', this ) : $( this ),
238228
$item = $th.last(),
@@ -256,7 +246,7 @@
256246
$th.children().css( 'display', '' );
257247
};
258248

259-
CodeComments.$tableRows.hover( callbackMouseover, callbackMouseout );
249+
Rows.hover( callbackMouseover, callbackMouseout );
260250
}
261251
});
262252

@@ -294,9 +284,11 @@
294284
window.LineCommentsBlock = new LineCommentsView();
295285
window.AddCommentDialog = new AddCommentDialogView();
296286
window.LineCommentBubbles = new LineCommentBubblesView({el: $('#preview, .diff .entries')});
287+
window.Rows = new RowsView( { tableSelector: 'table.code tbody, table.trac-diff tbody' } );
297288

298289
$(CodeComments.selectorToInsertBefore).before(TopCommentsBlock.render().el);
299290
LineCommentsBlock.render();
300291
AddCommentDialog.render();
301292
LineCommentBubbles.render();
293+
Rows.render();
302294
}); }( jQuery.noConflict( true ) ) );

code_comments/web.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ def post_process_request(self, req, template, data, content_type):
7474
'active_comment_id': req.args.get('codecomment'),
7575
'username': req.authname,
7676
'is_admin': 'TRAC_ADMIN' in req.perm,
77-
'tableSelectors': 'table.code tbody tr, table.trac-diff tbody tr',
7877
}
7978

8079
original_return_value = template, data, content_type

0 commit comments

Comments
 (0)