##// END OF EJS Templates
events handling: minimize the amount of events attached per page
ergo -
r383:68fbf148 default
parent child Browse files
Show More
@@ -49,7 +49,7 b' class OPS(object):'
49 49 def wrap_to_table(str_):
50 50 return '''<table class="code-difftable">
51 51 <tr class="line no-comment">
52 <td class="add-comment-line"><span class="add-comment-content"></span></td>
52 <td class="add-comment-line tooltip" title="Click to comment"><span class="add-comment-content"></span></td>
53 53 <td class="lineno new"></td>
54 54 <td class="code no-comment"><pre>%s</pre></td>
55 55 </tr>
@@ -626,7 +626,7 b' class DiffProcessor(object):'
626 626 """
627 627
628 628 if condition:
629 return '''<a href="%(url)s">%(label)s</a>''' % {
629 return '''<a href="%(url)s" class="tooltip" title="Click to select line">%(label)s</a>''' % {
630 630 'url': url,
631 631 'label': label
632 632 }
@@ -249,21 +249,17 b' function offsetScroll(element, offset){'
249 249 });
250 250 }
251 251 });
252 // Add tooltips
253 $('tr.line .lineno a').attr("title","Click to select line").addClass('tooltip');
254 $('tr.line .add-comment-line a').attr("title","Click to comment").addClass('tooltip');
252 $('.compare_view_files').on(
253 'mouseenter mouseleave', 'tr.line .lineno a',function(event) {
254 if (event.type === "mouseenter") {
255 $(this).parents('tr.line').addClass('hover');
256 } else {
257 $(this).parents('tr.line').removeClass('hover');
258 }
259 });
255 260
256 // Set colors and styles
257 $('tr.line .lineno a').hover(
258 function(){
259 $(this).parents('tr.line').addClass('hover');
260 }, function(){
261 $(this).parents('tr.line').removeClass('hover');
262 }
263 );
264
265 $('tr.line .lineno a').click(
266 function(){
261 $('.compare_view_files').on(
262 'click', 'tr.line .lineno a',function(event) {
267 263 if ($(this).text() != ""){
268 264 $('tr.line').removeClass('selected');
269 265 $(this).parents("tr.line").addClass('selected');
@@ -271,7 +267,7 b' function offsetScroll(element, offset){'
271 267 // Replace URL without jumping to it if browser supports.
272 268 // Default otherwise
273 269 if (history.pushState) {
274 var new_location = location.href
270 var new_location = location.href;
275 271 if (location.hash){
276 272 new_location = new_location.replace(location.hash, "");
277 273 }
@@ -283,23 +279,14 b' function offsetScroll(element, offset){'
283 279 return false;
284 280 }
285 281 }
286 }
287 );
282 });
288 283
289 $('tr.line .add-comment-line a').hover(
290 function(){
291 $(this).parents('tr.line').addClass('commenting');
292 }, function(){
293 $(this).parents('tr.line').removeClass('commenting');
294 }
295 );
296
297 $('tr.line .add-comment-line a').on('click', function(e){
298 var tr = $(e.currentTarget).parents('tr.line')[0];
299 injectInlineForm(tr);
300 return false;
301 });
302
284 $('.compare_view_files').on(
285 'click', 'tr.line .add-comment-line a',function(event) {
286 var tr = $(event.currentTarget).parents('tr.line')[0];
287 injectInlineForm(tr);
288 return false;
289 });
303 290
304 291 $('.collapse_file').on('click', function(e) {
305 292 e.stopPropagation();
General Comments 0
You need to be logged in to leave comments. Login now