فهرست منبع

updated node template to not use DrupalBehaviors so that the visible block doesn't change on AJAX loading

Stephen Ficklin 11 سال پیش
والد
کامیت
0255f204e8
2فایلهای تغییر یافته به همراه49 افزوده شده و 49 حذف شده
  1. 29 29
      tripal_core/theme/node--chado-generic.tpl.php
  2. 20 20
      tripal_pub/includes/importers/tripal_pub.AGL.inc

+ 29 - 29
tripal_core/theme/node--chado-generic.tpl.php

@@ -7,35 +7,35 @@ else {
   $node_type = $node->type; ?>
   
   <script type="text/javascript">
-    (function ($) {
-      Drupal.behaviors.<?php print $node_type?>Behavior = {
-        attach: function (context, settings){ 
-          // hide all but the first data block 
-          $(".tripal-data-block").hide().filter(":first-child").show();
-     
-          // when a title in the table of contents is clicked, then 
-          // show the corresponding item in the details box 
-          $(".tripal_toc_list_item_link").click(function(){
-            var id = $(this).attr('id') + "-tripal-data-block";
-            $(".tripal-data-block").hide().filter("#"+ id).fadeIn('fast');
-            return false;
-          }); 
-    
-          // if a ?block= is specified in the URL then we want to show the
-          // requested block
-          var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
-          if(block == null){
-            block = window.location.href.match(/[\?|\&]block=(.+)/)
-          }
-          if(block != null){
-            $(".tripal-data-block").hide().filter("#" + block[1] + "-tripal-data-block").show();
-          }
-          // remove the 'active' class from the links section, as it doesn't
-          // make sense for this layout
-          $("a.active").removeClass('active');
-        }
-      };
-    })(jQuery);
+    // we do not use Drupal Behaviors because we do not want this
+    // code to be executed on AJAX callbacks. This code only needs to 
+    // be executed once the page is ready.
+    jQuery(document).ready(function($){
+
+      // hide all but the first data block 
+      $(".tripal-data-block").hide().filter(":first-child").show();
+  
+      // when a title in the table of contents is clicked, then 
+      // show the corresponding item in the details box 
+      $(".tripal_toc_list_item_link").click(function(){
+        var id = $(this).attr('id') + "-tripal-data-block";
+        $(".tripal-data-block").hide().filter("#"+ id).fadeIn('fast');
+        return false;
+      }); 
+  
+      // if a ?block= is specified in the URL then we want to show the
+      // requested block
+      var block = window.location.href.match(/[\?|\&]block=(.+?)\&/)
+      if(block == null){
+        block = window.location.href.match(/[\?|\&]block=(.+)/)
+      }
+      if(block != null){
+        $(".tripal-data-block").hide().filter("#" + block[1] + "-tripal-data-block").show();
+      }
+      // remove the 'active' class from the links section, as it doesn't
+      // make sense for this layout
+      $("a.active").removeClass('active');
+    });
   </script>
   
   <div id="tripal_<?php print $node_type?>_contents" class="tripal-contents">

+ 20 - 20
tripal_pub/includes/importers/tripal_pub.AGL.inc

@@ -567,26 +567,26 @@ function tripal_pub_AGL_parse_pubxml($pub_xml) {
             '04' => 'Apr', '05' => 'May', '06' => 'Jun',
             '07' => 'Jul', '08' => 'Aug', '09' => 'Sep',
             '10' => 'Oct', '11' => 'Nov', '12' => 'Dec'
-            );
-            $date0 = substr($value, 0, 6);  // date entered on file
-            $date1 = substr($value, 7, 4);  // year of publication
-            $date2 = substr($value, 11, 4); // month of publication
-            $place = substr($value, 15, 3);
-            $lang  = substr($value, 35, 3);
-            if (preg_match('/\d\d\d\d/', $date1)) {
-              $pub['Year'] = $date1;
-              $pub['Publication Date'] = $date1;
-            }
-            if (preg_match('/\d\d/', $date2)) {
-              $pub['Publication Date'] = $date1 . " " . $month[substr($date2, 0, 2)] . " " . substr($date2, 3, 2);
-            }
-            if (!preg_match('/\s+/', $place)) {
-              $pub['Published Location'] = $place;
-            }
-            if (!preg_match('/\s+/', $lang)) {
-              $pub['Language Abbr'] = $lang;
-            }
-            break;
+          );
+          $date0 = substr($value, 0, 6);  // date entered on file
+          $date1 = substr($value, 7, 4);  // year of publication
+          $date2 = substr($value, 11, 4); // month of publication
+          $place = substr($value, 15, 3);
+          $lang  = substr($value, 35, 3);
+          if (preg_match('/\d\d\d\d/', $date1)) {
+            $pub['Year'] = $date1;
+            $pub['Publication Date'] = $date1;
+          }
+          if (preg_match('/\d\d/', $date2)) {
+            $pub['Publication Date'] = $date1 . " " . $month[substr($date2, 0, 2)] . " " . substr($date2, 3, 2);
+          }
+          if (!preg_match('/\s+/', $place)) {
+            $pub['Published Location'] = $place;
+          }
+          if (!preg_match('/\s+/', $lang)) {
+            $pub['Language Abbr'] = $lang;
+          }
+          break;
         default:  // unhandled tag
           break;
       }