|
15 | 15 | alert(errorText); |
16 | 16 | }); |
17 | 17 |
|
18 | | - CodeComments.$tableRows = $( CodeComments.tableSelectors ).not( '.comments' ); |
19 | | - |
20 | 18 | window.Comment = Backbone.Model.extend({ |
21 | 19 | }); |
22 | 20 |
|
|
114 | 112 | if (!this.viewPerLine[line]) { |
115 | 113 | this.viewPerLine[line] = new CommentsForALineView( { line: line } ); |
116 | 114 |
|
117 | | - var $tr = $( CodeComments.$tableRows[ line-1 ] ); |
118 | | - |
| 115 | + var $tr = $( Rows.getTrByLineNumber( line ) ); |
119 | 116 | $tr.after(this.viewPerLine[line].render().el).addClass('with-comments'); |
120 | 117 | } |
121 | 118 | this.viewPerLine[line].addOne(comment); |
|
132 | 129 | tagName: 'tr', |
133 | 130 | className: 'comments', |
134 | 131 | template: _.template(CodeComments.templates.comments_for_a_line), |
135 | | - templateData: {}, |
136 | 132 | initialize: function(attrs) { |
137 | 133 | this.line = attrs.line; |
138 | | - this.templateData.colspan = ( 'changeset' === CodeComments.page ) ? 2 : 1; |
139 | 134 | }, |
140 | 135 | events: { |
141 | 136 | 'click button': 'showAddCommentDialog' |
142 | 137 | }, |
143 | 138 | render: function() { |
144 | | - $( this.el ).html( this.template( this.templateData ) ); |
| 139 | + $( this.el ).html( this.template( { colspan: Rows.getNumberOfTHsPerRow() } ) ); |
145 | 140 | this.$('button').button(); |
146 | 141 | return this; |
147 | 142 | }, |
|
228 | 223 |
|
229 | 224 | window.LineCommentBubblesView = Backbone.View.extend({ |
230 | 225 | 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 | | - |
236 | 226 | var callbackMouseover = function( event ) { |
237 | 227 | var $th = ( $( 'th', this ).length) ? $( 'th', this ) : $( this ), |
238 | 228 | $item = $th.last(), |
|
256 | 246 | $th.children().css( 'display', '' ); |
257 | 247 | }; |
258 | 248 |
|
259 | | - CodeComments.$tableRows.hover( callbackMouseover, callbackMouseout ); |
| 249 | + Rows.hover( callbackMouseover, callbackMouseout ); |
260 | 250 | } |
261 | 251 | }); |
262 | 252 |
|
|
294 | 284 | window.LineCommentsBlock = new LineCommentsView(); |
295 | 285 | window.AddCommentDialog = new AddCommentDialogView(); |
296 | 286 | window.LineCommentBubbles = new LineCommentBubblesView({el: $('#preview, .diff .entries')}); |
| 287 | + window.Rows = new RowsView( { tableSelector: 'table.code tbody, table.trac-diff tbody' } ); |
297 | 288 |
|
298 | 289 | $(CodeComments.selectorToInsertBefore).before(TopCommentsBlock.render().el); |
299 | 290 | LineCommentsBlock.render(); |
300 | 291 | AddCommentDialog.render(); |
301 | 292 | LineCommentBubbles.render(); |
| 293 | + Rows.render(); |
302 | 294 | }); }( jQuery.noConflict( true ) ) ); |
0 commit comments