spficklin 13 年之前
父節點
當前提交
9cbe315972
共有 1 個文件被更改,包括 12 次插入43 次删除
  1. 12 43
      tripal_analysis_kegg/theme/js/tripal_analysis_kegg.js

+ 12 - 43
tripal_analysis_kegg/theme/js/tripal_analysis_kegg.js

@@ -2,41 +2,22 @@
 
 if (Drupal.jsEnabled) {
    $(document).ready(function() {
-      $(".tripal_kegg_brite_tree").attr("id", function(){
-			init_kegg_tree($(this).attr("id"));    
-      });
 
        // Select default KEGG analysis when available
        var selectbox = $('#edit-tripal-analysis-kegg-select');
        if(selectbox){ 
           selectbox[0].selectedIndex = 1;
-          tripal_analysis_kegg_org_report(selectbox.val());
+          selectbox.change();
        }
 
    });
 
    //------------------------------------------------------------
-   function tripal_analysis_kegg_org_report(item){
+   function tripal_analysis_kegg_org_report(item,baseurl,themedir){
       if(!item){
          $("#tripal_analysis_kegg_org_report").html('');
          return false;
       }
-      // Get the base url. Drupal can not pass it through the form so we need 
-	  // to get it ourself. Use different patterns to match the url in case
-      // the Clean URL function is turned on
-      var baseurl = location.href.substring(0,location.href.lastIndexOf('/?q=/node'));
-      if(!baseurl) {
-  	     var baseurl = location.href.substring(0,location.href.lastIndexOf('/node'));
-      }
-      if (!baseurl) {
-         // This base_url is obtained when Clean URL function is off
-         var baseurl = location.href.substring(0,location.href.lastIndexOf('/?q=node'));
-      }
-      if (!baseurl) {
-         // The last possibility is we've assigned an alias path, get base_url till the last /
-         var baseurl = location.href.substring(0,location.href.indexOf('/',10));
-      }
-     
       // Form the link for the following ajax call  
       var link = baseurl + '/tripal_analysis_kegg_org_report/' + item;
       tripal_startAjax();
@@ -47,7 +28,7 @@ if (Drupal.jsEnabled) {
            success: function(data){
              $("#tripal_analysis_kegg_org_report").html(data[0]);
              $(".tripal_kegg_brite_tree").attr("id", function(){
-			       init_kegg_tree($(this).attr("id"));    
+                init_kegg_tree($(this).attr("id"),baseurl,themedir);    
              });
              tripal_stopAjax();
            }
@@ -57,7 +38,7 @@ if (Drupal.jsEnabled) {
    
    //------------------------------------------------------------
    // Update the BRITE hierarchy based on the user selection
-   function tripal_update_brite(link,type_id){
+   function tripal_update_brite(link,type_id,baseurl,themedir){
       tripal_startAjax();
       $.ajax({
          url: link.href,
@@ -67,7 +48,9 @@ if (Drupal.jsEnabled) {
             $("#tripal_kegg_brite_hierarchy").html(data.update);
             $("#tripal_kegg_brite_header").html(data.brite_term);
             tripal_stopAjax();
-            init_kegg_tree(data.id);
+            if(baseurl && themedir){
+               init_kegg_tree(data.id,baseurl,themedir);
+            }
          }
       });
       return false;
@@ -75,24 +58,10 @@ if (Drupal.jsEnabled) {
 
    //------------------------------------------------------------
    // This function initializes a KEGG term tree
-   function init_kegg_tree(id){
-	   // Get the base url. Drupal can not pass it through the form so we need 
-	   // to get it ourself. Use different patterns to match the url in case
-       // the Clean URL function is turned on
-       var baseurl = location.href.substring(0,location.href.lastIndexOf('/?q=/node'));
-       if(!baseurl) {
-    	   var baseurl = location.href.substring(0,location.href.lastIndexOf('/node'));
-       }
-       if (!baseurl) {
-          // This base_url is obtained when Clena URL function is off
-          var baseurl = location.href.substring(0,location.href.lastIndexOf('/?q=node'));
-       }
-       if (!baseurl) {
-          // The last possibility is we've assigned an alias path, get base_url till the last /
-          var baseurl = location.href.substring(0,location.href.lastIndexOf('/'));
-       }
-	   // Form the link for the following ajax call
-       var link = baseurl + "/sites/all/themes/theme_tripal/js/jsTree/source/themes/";
+   function init_kegg_tree(id,baseurl,themedir){
+
+      // Form the link for the following ajax call
+      var theme_path = baseurl + '/' + themedir + "/js/jsTree/source/themes/";
 	   
       $("#" + id).tree ({
 	    data    : {
@@ -110,7 +79,7 @@ if (Drupal.jsEnabled) {
            animation   : 0,        // INT - duration of open/close animations in miliseconds
            hover_mode  : true,     // SHOULD get_* functions chage focus or change hovered item
            scroll_spd  : 4,
-           theme_path  : link,    // Path to themes
+           theme_path  : theme_path,    // Path to themes
            theme_name  : "classic",// Name of theme
         },