19e41db7a2c91f90967be5a7c550623b2d3d93b5
Merge parents 76db7c9 71376b3
tdreszer
  Wed Nov 2 15:39:59 2011 -0700
Merge-o-mania.
diff --cc src/hg/js/utils.js
index fff80b8,facc1fb..f23a03a
--- src/hg/js/utils.js
+++ src/hg/js/utils.js
@@@ -1028,147 -1049,74 +1028,148 @@@
                  ro.step(msecs,args);      // recursion
              else if (msecs == 0)
                  continuingFunc(args);     // completion
              // else (msec < 0) // abandon
          });
      ro.step(1,args);                      // kick-off
  }
  
  function showLoadingImage(id)
  {
  // Show a loading image above the given id; return's id of div added (so it can be removed when loading is finished).
  // This code was mostly directly copied from hgHeatmap.js, except I also added the "overlay.appendTo("body");"
      var loadingId = id + "LoadingOverlay";
      // make an opaque overlay to partially hide the image
      var overlay = $("<div></div>").attr("id", loadingId).css("position", "absolute");
+     var ele = $(document.getElementById(id));
      overlay.appendTo("body");
-     overlay.css("top", $('#'+ id).position().top);
-     var divLeft = $('#'+ id).position().left + 2;
+     overlay.css("top", ele.position().top);
+     var divLeft = ele.position().left + 2;
      overlay.css("left",divLeft);
-     var width = $('#'+ id).width() - 5;
-     var height = $('#'+ id).height();
+     var width = ele.width() - 5;
+     var height = ele.height();
      overlay.width(width);
      overlay.height(height);
      overlay.css("background", "white");
      overlay.css("opacity", 0.75);
      // now add the overlay image itself in the center of the overlay.
      var imgWidth = 220;   // hardwired based on width of loading.gif
      var imgLeft = (width / 2) - (imgWidth / 2);
      var imgTop = (height / 2 ) - 10;
      $("<img src='../images/loading.gif'/>").css("position", "relative").css('left', imgLeft).css('top', imgTop).appendTo(overlay);
      return loadingId;
  }
  
  function hideLoadingImage(id)
  {
-     $('#' + id).remove();
+     $(document.getElementById(id)).remove();
  }
  
  function codonColoringChanged(name)
  {
  // Updated disabled state of codonNumbering checkbox based on current value of track coloring select.
      var val = $("select[name='" + name + ".baseColorDrawOpt'] option:selected").text();
      $("input[name='" + name + ".codonNumbering']").attr('disabled', val == "OFF");
  }
  
  
 +function stripJsFiles(returnedHtml,showError)
 +{ // strips javascript files from html returned by ajax
 +    var cleanHtml = returnedHtml;
 +    var shlurpPattern=/\<script type=\'text\/javascript\' SRC\=\'.*\'\>\<\/script\>/gi;
 +    if (showError) {
 +        var jsFiles = cleanHtml.match(shlurpPattern);
 +        if (jsFiles && jsFiles.length > 0)
 +            alert("jsFiles:'"+jsFiles+"'\n---------------\n"+cleanHtml); // warn() interprets html, etc.
 +    }
 +    cleanHtml = cleanHtml.replace(shlurpPattern,"");
 +
 +    return cleanHtml;
 +}
 +
 +function stripCssFiles(returnedHtml,showError)
 +{ // strips csst files from html returned by ajax
 +    var cleanHtml = returnedHtml;
 +    var shlurpPattern=/\<LINK rel=\'STYLESHEET\' href\=\'.*\' TYPE=\'text\/css\' \/\>/gi;
 +    if (showError) {
 +        var cssFiles = cleanHtml.match(shlurpPattern);
 +        if (cssFiles && cssFiles.length > 0)
 +            alert("cssFiles:'"+cssFiles+"'\n---------------\n"+cleanHtml);
 +    }
 +    cleanHtml = cleanHtml.replace(shlurpPattern,"");
 +
 +    return cleanHtml;
 +}
 +
 +function stripJsEmbedded(returnedHtml,showError)
 +{ // strips embedded javascript from html returned by ajax
 +  // NOTE: any warnBox style errors will be put into the warnBox
 +    var cleanHtml = returnedHtml;
 +    // embedded javascript?
 +    while(cleanHtml.length > 0) {
 +        var ix = cleanHtml.search(/\<script type=\'text\/javascript\'\>/i);
 +        if (ix == -1)
 +            break;
 +        var ix2 = cleanHtml.search(/\<\/script\>/i);
 +        if (ix2 == -1)
 +            break;
 +        var jsEmbeded = cleanHtml.slice(ix,ix2+"</script>".length);
 +        if (jsEmbeded && jsEmbeded.length > 0) {
 +            // ignore warnBoxes
 +            if(-1 == jsEmbeded.indexOf("showWarnBox")) {
 +                if (showError)
 +                    alert("jsEmbedded:'"+jsEmbeded+"'\n---------------\n"+cleanHtml);
 +            } else {
 +                var ix3 = cleanHtml.indexOf('<P>',ix);
 +                var ix4 = cleanHtml.indexOf('</P>',ix);
 +                var warnMsg = cleanHtml.slice(ix3+3,ix4-1);
 +                cleanHtml = cleanHtml.slice(0,ix3) + cleanHtml.slice(ix4+4);
 +                warn(warnMsg);
 +            }
 +        }
 +        cleanHtml = cleanHtml.slice(0,ix) + cleanHtml.slice(ix2+"</script>".length);
 +    }
 +    return cleanHtml;
 +}
 +
 +function visTriggersHiddenSelect(obj)
 +{ // SuperTrack child changing vis should trigger superTrack reshaping.
 +  // This is done by setting hidden input "_sel"
 +    var trackName_Sel = $(obj).attr('name') + "_sel";
 +    var theForm = $(obj).closest("form");
 +    var visible = (obj.selectedIndex != 0);
 +    if (visible) {
 +        updateOrMakeNamedVariable(theForm,trackName_Sel,"1");
 +    } else
 +        disableNamedVariable(theForm,trackName_Sel);
 +    return true;
 +}
 +
  //////////// Drag and Drop ////////////
  function tableDragAndDropRegister(thisTable)
  {// Initialize a table with tableWithDragAndDrop
      if ($(thisTable).hasClass("tableWithDragAndDrop") == false)
          return;
  
      $(thisTable).tableDnD({
          onDragClass: "trDrag",
          dragHandle: "dragHandle",
          onDrop: function(table, row, dragStartIndex) {
 -                if(tableSetPositions) {
 -                    tableSetPositions(table);
 +                if (row.rowIndex != dragStartIndex) {
 +                    if(tableSetPositions) {
 +                        tableSetPositions(table);
 +                    }
                  }
              }
      });
      $(thisTable).find("td.dragHandle").hover(
          function(){ $(this).closest('tr').addClass('trDrag'); },
          function(){ $(this).closest('tr').removeClass('trDrag'); }
      );
  }
  
  //////////// Sorting ////////////
  // Sorting a table by columns relies upon the sortColumns structure
  
  // The sortColumns structure looks like:
  //{
  //    char *  tags[];     // a list of field names in sort order (e.g. 'cell', 'shortLabel')