3170: Add comments.
authorTom Clegg <tom@curoverse.com>
Mon, 21 Jul 2014 17:00:34 +0000 (13:00 -0400)
committerTom Clegg <tom@curoverse.com>
Mon, 21 Jul 2014 17:00:34 +0000 (13:00 -0400)
apps/workbench/app/assets/javascripts/tab_panes.js

index 9586e4c10bc48076f7cfdd756f0609bb71cd6a1a..ec4a519e96b644be72cc5213c2b42a4bb9bb1421 100644 (file)
@@ -1,3 +1,8 @@
+// Load tab panes on demand. See app/views/application/_content.html.erb
+
+// Fire when a tab is selected/clicked. Check whether the content in
+// the corresponding pane is loaded (or is being loaded). If not,
+// start an AJAX request to load the content.
 $(document).on('shown.bs.tab', '[data-toggle="tab"]', function(e) {
     var content_url = $(e.target).attr('data-pane-content-url');
     var $pane = $($(e.target).attr('href'));
@@ -10,6 +15,10 @@ $(document).on('shown.bs.tab', '[data-toggle="tab"]', function(e) {
         });
 });
 
+// Fire when the content in a tab pane becomes stale/dirty. If the
+// pane is visible now, reload it right away. Otherwise, just replace
+// the current content with a spinner for now: there's no need to load
+// the new content unless/until the user clicks the corresponding tab.
 $(document).on('arv:pane:reload', '.tab-pane', function() {
     // Unload a single pane. Reload it if it's active.
     $(this).removeClass('loaded');
@@ -23,7 +32,7 @@ $(document).on('arv:pane:reload', '.tab-pane', function() {
     }
 });
 
+// Mark all panes as stale/dirty. Refresh the active pane.
 $(document).on('arv-log-event arv:pane:reload:all', function() {
-    // Reload all panes (except ones that haven't even loaded yet).
     $('.tab-pane.loaded').trigger('arv:pane:reload');
 });