##// 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 def wrap_to_table(str_):
49 def wrap_to_table(str_):
50 return '''<table class="code-difftable">
50 return '''<table class="code-difftable">
51 <tr class="line no-comment">
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 <td class="lineno new"></td>
53 <td class="lineno new"></td>
54 <td class="code no-comment"><pre>%s</pre></td>
54 <td class="code no-comment"><pre>%s</pre></td>
55 </tr>
55 </tr>
@@ -626,7 +626,7 b' class DiffProcessor(object):'
626 """
626 """
627
627
628 if condition:
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 'url': url,
630 'url': url,
631 'label': label
631 'label': label
632 }
632 }
@@ -249,21 +249,17 b' function offsetScroll(element, offset){'
249 });
249 });
250 }
250 }
251 });
251 });
252 // Add tooltips
252 $('.compare_view_files').on(
253 $('tr.line .lineno a').attr("title","Click to select line").addClass('tooltip');
253 'mouseenter mouseleave', 'tr.line .lineno a',function(event) {
254 $('tr.line .add-comment-line a').attr("title","Click to comment").addClass('tooltip');
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
261 $('.compare_view_files').on(
257 $('tr.line .lineno a').hover(
262 'click', 'tr.line .lineno a',function(event) {
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(){
267 if ($(this).text() != ""){
263 if ($(this).text() != ""){
268 $('tr.line').removeClass('selected');
264 $('tr.line').removeClass('selected');
269 $(this).parents("tr.line").addClass('selected');
265 $(this).parents("tr.line").addClass('selected');
@@ -271,7 +267,7 b' function offsetScroll(element, offset){'
271 // Replace URL without jumping to it if browser supports.
267 // Replace URL without jumping to it if browser supports.
272 // Default otherwise
268 // Default otherwise
273 if (history.pushState) {
269 if (history.pushState) {
274 var new_location = location.href
270 var new_location = location.href;
275 if (location.hash){
271 if (location.hash){
276 new_location = new_location.replace(location.hash, "");
272 new_location = new_location.replace(location.hash, "");
277 }
273 }
@@ -283,23 +279,14 b' function offsetScroll(element, offset){'
283 return false;
279 return false;
284 }
280 }
285 }
281 }
286 }
282 });
287 );
288
283
289 $('tr.line .add-comment-line a').hover(
284 $('.compare_view_files').on(
290 function(){
285 'click', 'tr.line .add-comment-line a',function(event) {
291 $(this).parents('tr.line').addClass('commenting');
286 var tr = $(event.currentTarget).parents('tr.line')[0];
292 }, function(){
287 injectInlineForm(tr);
293 $(this).parents('tr.line').removeClass('commenting');
288 return false;
294 }
289 });
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
303
290
304 $('.collapse_file').on('click', function(e) {
291 $('.collapse_file').on('click', function(e) {
305 e.stopPropagation();
292 e.stopPropagation();
General Comments 0
You need to be logged in to leave comments. Login now