changeset 5071:2881dd265f21 stable

templates: only bind pager event handlers once - avoid "leaks" and repeated page loads Summary page ended up hammering the server and when pages were loaded one time extra for each paging click. Just moving javascript code from the data template (where it would be re-run on each paging) and to the main page template.
author Mads Kiilerich <madski@unity3d.com>
date Tue, 28 Apr 2015 16:45:43 +0200
parents 58e4670c7902
children 26cbd84f0493 d9747a04c74a
files kallithea/templates/changelog/changelog_summary_data.html kallithea/templates/followers/followers.html kallithea/templates/followers/followers_data.html kallithea/templates/forks/forks.html kallithea/templates/forks/forks_data.html kallithea/templates/journal/journal.html kallithea/templates/journal/journal_data.html kallithea/templates/summary/summary.html
diffstat 8 files changed, 59 insertions(+), 56 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/templates/changelog/changelog_summary_data.html	Sun Apr 26 22:13:02 2015 +0200
+++ b/kallithea/templates/changelog/changelog_summary_data.html	Tue Apr 28 16:45:43 2015 +0200
@@ -72,16 +72,6 @@
 
 </table>
 
-<script type="text/javascript">
-  $(document).ready(function(){
-    var $shortlog_data = $('#shortlog_data');
-    $shortlog_data.on('click','.pager_link',function(e){
-      asynchtml(e.target.href, $shortlog_data, function(){tooltip_activate();});
-      e.preventDefault();
-    });
-  });
-</script>
-
 <div class="pagination-wh pagination-left">
 ${c.repo_changesets.pager('$link_previous ~2~ $link_next')}
 </div>
--- a/kallithea/templates/followers/followers.html	Sun Apr 26 22:13:02 2015 +0200
+++ b/kallithea/templates/followers/followers.html	Tue Apr 28 16:45:43 2015 +0200
@@ -12,6 +12,7 @@
 <%block name="header_menu">
     ${self.menu('repositories')}
 </%block>
+
 <%def name="main()">
 ${self.repo_context_bar('followers')}
 <div class="box">
@@ -26,4 +27,17 @@
         </div>
     </div>
 </div>
+<script type="text/javascript">
+  $(document).ready(function(){
+    var $followers = $('#followers');
+    $followers.on('click','.pager_link',function(e){
+        asynchtml(e.target.href, $followers, function(){
+            show_more_event();
+            tooltip_activate();
+            show_changeset_tooltip();
+        });
+        e.preventDefault();
+    });
+  });
+</script>
 </%def>
--- a/kallithea/templates/followers/followers_data.html	Sun Apr 26 22:13:02 2015 +0200
+++ b/kallithea/templates/followers/followers_data.html	Tue Apr 28 16:45:43 2015 +0200
@@ -16,18 +16,5 @@
 % endfor
 
 <div class="pagination-wh pagination-left">
-<script type="text/javascript">
-$(document).ready(function(){
-    var $followers = $('#followers');
-    $followers.on('click','.pager_link',function(e){
-        asynchtml(e.target.href, $followers, function(){
-            show_more_event();
-            tooltip_activate();
-            show_changeset_tooltip();
-        });
-        e.preventDefault();
-    });
-});
-</script>
 ${c.followers_pager.pager('$link_previous ~2~ $link_next')}
 </div>
--- a/kallithea/templates/forks/forks.html	Sun Apr 26 22:13:02 2015 +0200
+++ b/kallithea/templates/forks/forks.html	Tue Apr 28 16:45:43 2015 +0200
@@ -27,4 +27,17 @@
         </div>
     </div>
 </div>
+<script type="text/javascript">
+  $(document).ready(function(){
+      var $forks = $('#forks');
+      $forks.on('click','.pager_link',function(e){
+          asynchtml(e.target.href, $forks, function(){
+              show_more_event();
+              tooltip_activate();
+              show_changeset_tooltip();
+          });
+          e.preventDefault();
+      });
+  });
+</script>
 </%def>
--- a/kallithea/templates/forks/forks_data.html	Sun Apr 26 22:13:02 2015 +0200
+++ b/kallithea/templates/forks/forks_data.html	Tue Apr 28 16:45:43 2015 +0200
@@ -24,19 +24,6 @@
         </div>
     % endfor
   <div class="pagination-wh pagination-left">
-  <script type="text/javascript">
-  $(document).ready(function(){
-      var $forks = $('#forks');
-      $forks.on('click','.pager_link',function(e){
-          asynchtml(e.target.href, $forks, function(){
-              show_more_event();
-              tooltip_activate();
-              show_changeset_tooltip();
-          });
-          e.preventDefault();
-      });
-  });
-  </script>
   ${c.forks_pager.pager('$link_previous ~2~ $link_next')}
   </div>
 % else:
--- a/kallithea/templates/journal/journal.html	Sun Apr 26 22:13:02 2015 +0200
+++ b/kallithea/templates/journal/journal.html	Tue Apr 28 16:45:43 2015 +0200
@@ -70,7 +70,7 @@
         </div>
     </div>
 
-    <script type="text/javascript">
+<script type="text/javascript">
 
     $('#j_filter').click(function(){
         var $jfilter = $('#j_filter');
@@ -334,5 +334,24 @@
         }
     }
 
-    </script>
+</script>
+
+<script type="text/javascript">
+    $(document).ready(function(){
+        var $journal = $('#journal');
+        $journal.on('click','.pager_link',function(e){
+            asynchtml(e.target.href, $journal, function(){
+                show_more_event();
+                tooltip_activate();
+                show_changeset_tooltip();
+            });
+            e.preventDefault();
+        });
+        $('#journal').on('click','.show_more',function(e){
+            var el = e.target;
+            $('#'+el.id.substring(1)).show();
+            $(el.parentNode).hide();
+        });
+    });
+</script>
 </%def>
--- a/kallithea/templates/journal/journal_data.html	Sun Apr 26 22:13:02 2015 +0200
+++ b/kallithea/templates/journal/journal_data.html	Tue Apr 28 16:45:43 2015 +0200
@@ -38,24 +38,6 @@
   <div class="pagination-wh pagination-left" style="padding: 0px 0px 0px 10px;">
   ${c.journal_pager.pager('$link_previous ~2~ $link_next')}
   </div>
-    <script type="text/javascript">
-    $(document).ready(function(){
-        var $journal = $('#journal');
-        $journal.on('click','.pager_link',function(e){
-            asynchtml(e.target.href, $journal, function(){
-                show_more_event();
-                tooltip_activate();
-                show_changeset_tooltip();
-            });
-            e.preventDefault();
-        });
-        $('#journal').on('click','.show_more',function(e){
-            var el = e.target;
-            $('#'+el.id.substring(1)).show();
-            $(el.parentNode).hide();
-        });
-    });
-    </script>
 %else:
   <div style="padding:5px 0px 10px 10px;">
       ${_('No entries yet')}
--- a/kallithea/templates/summary/summary.html	Sun Apr 26 22:13:02 2015 +0200
+++ b/kallithea/templates/summary/summary.html	Tue Apr 28 16:45:43 2015 +0200
@@ -397,4 +397,15 @@
 </script>
 %endif
 
+## Shortlog paging
+<script type="text/javascript">
+  $(document).ready(function(){
+    var $shortlog_data = $('#shortlog_data');
+    $shortlog_data.on('click','.pager_link',function(e){
+      asynchtml(e.target.href, $shortlog_data, function(){tooltip_activate();});
+      e.preventDefault();
+    });
+  });
+</script>
+
 </%def>