Sfoglia il codice sorgente

Don't render if the timeline tab not shown

Sotaro KARASAWA 9 anni fa
parent
commit
e4f47eda08
2 ha cambiato i file con 18 aggiunte e 10 eliminazioni
  1. 1 1
      lib/views/page_list.html
  2. 17 9
      resource/js/crowi.js

+ 1 - 1
lib/views/page_list.html

@@ -186,7 +186,7 @@
     </div>
 
     {# timeline view #}
-    <div class="tab-pane" id="view-timeline">
+    <div class="tab-pane" id="view-timeline" data-shown=0>
       {% for page in pages %}
       <div class="timeline-body" id="id-{{ page.id }}">
         <h3 class="revision-path"><a href="{{ page.path }}">{{ page.path }}</a></h3>

+ 17 - 9
resource/js/crowi.js

@@ -353,16 +353,24 @@ $(function() {
   });
 
   // for list page
-  $('#view-timeline .timeline-body').each(function()
-  {
-    var id = $(this).attr('id');
-    var contentId = '#' + id + ' > script';
-    var revisionBody = '#' + id + ' .revision-body';
-    var revisionPath = '#' + id + ' .revision-path';
+  $('a[data-toggle="tab"][href="#view-timeline"]').on('show.bs.tab', function() {
+    var isShown = $('#view-timeline').data('shown');
+    if (isShown == 0) {
+      $('#view-timeline .timeline-body').each(function()
+      {
+        var id = $(this).attr('id');
+        var contentId = '#' + id + ' > script';
+        var revisionBody = '#' + id + ' .revision-body';
+        var revisionPath = '#' + id + ' .revision-path';
+
+        var markdown = Crowi.unescape($(contentId).html());
+        var parsedHTML = crowiRenderer.render(markdown);
+        $(revisionBody).html(parsedHTML);
+      });
 
-    var markdown = Crowi.unescape($(contentId).html());
-    var parsedHTML = crowiRenderer.render(markdown);
-    $(revisionBody).html(parsedHTML);
+      $('#view-timeline').data('shown', 1);
+      console.log('data-shown set as 1');
+    }
   });
 
   // login