spficklin 14 năm trước cách đây
mục cha
commit
0158a40b09
1 tập tin đã thay đổi với 15 bổ sung28 xóa
  1. 15 28
      theme_tripal/js/tripal_cv.js

+ 15 - 28
theme_tripal/js/tripal_cv.js

@@ -1,29 +1,7 @@
 
 if (Drupal.jsEnabled) {
-   var baseurl;
-   var isClean;
   
    $(document).ready(function() {
-       // 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
-       baseurl = location.href.substring(0,location.href.lastIndexOf('/?q=/node'));
-       isClean = 1;
-       if(!baseurl) {
-          baseurl = location.href.substring(0,location.href.lastIndexOf('/node'));
-          isClean = 0;
-       }
-       if (!baseurl) {
-          // This base_url is obtained when Clean URL function is off
-          baseurl = location.href.substring(0,location.href.lastIndexOf('/?q=node'));
-          isClean = 1;
-       }
-       if (!baseurl) {
-          // The last possibility is we've assigned an alias path, get base_url till the last /
-          baseurl = location.href.substring(0,location.href.indexOf('/',10));
-          isClean = 0;
-       }
-
      // any img object of class .tripal_cv_chart will have it's src attribute
      // populated when the document is ready by the following code.  The id
      // for the object must have a unique identifier that the calling tripal
@@ -54,7 +32,7 @@ if (Drupal.jsEnabled) {
          var api = new jGCharts.Api();
          var tree_id = $(this).attr("id");
          var link = baseurl + "/";
-         if(isClean){
+         if(!isClean){
             link += "?q=";
          }
          link += 'tripal_cv_tree/' + tree_id; 
@@ -80,10 +58,10 @@ if (Drupal.jsEnabled) {
          var api = new jGCharts.Api();
          var chart_id = $(this).attr("id");
          var link = baseurl + "/";
-         if(isClean){
+         if(!isClean){
             link += "?q=";
          }
-         link += '/tripal_cv_chart/' + chart_id;
+         link += 'tripal_cv_chart/' + chart_id;
          tripal_startAjax();
          $.ajax({
             url: link,
@@ -124,7 +102,12 @@ if (Drupal.jsEnabled) {
    // When a term in CV term tree browser is clicked this
    // function loads the term info into a box on the page.
    function tripal_cv_cvterm_info(cvterm_id,vars){
-       var link = baseurl + '/tripal_cv_cvterm_info/' + cvterm_id + '?cv=' + vars.cv + '&tree_id=' + vars.tree_id;
+      var link = baseurl + "/";
+      if(!isClean){
+         link += "?q=";
+      }
+      link += 'tripal_cv_cvterm_info/' + cvterm_id + '?cv=' + vars.cv + '&tree_id=' + vars.tree_id;
+
       // Get the cv_id from DOM
       $.ajax({
          url: link,
@@ -144,8 +127,12 @@ if (Drupal.jsEnabled) {
    //------------------------------------------------------------
    // This function initializes a CV term tree
    function init_tree(id,vars){
-      var link = baseurl + '/tripal_cv_update_tree';
-      var theme_link = baseurl + "/sites/all/themes/theme_tripal/js/jsTree/source/themes/";
+      var link = baseurl + "/";
+      if(!isClean){
+         link += "?q=";
+      }
+      link += 'tripal_cv_update_tree';
+      var theme_link = baseurl + '/' + themedir + "/js/jsTree/source/themes/";
       $("#" + id).tree ({
         data    : {
           type    : "json", // ENUM [json, xml_flat, xml_nested, predefined]