src/hg/js/hgTracks.js 1.63

1.63 2010/04/08 20:35:57 kent
Starting to work on makeItems type tracks.
Index: src/hg/js/hgTracks.js
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/js/hgTracks.js,v
retrieving revision 1.62
retrieving revision 1.63
diff -b -B -U 4 -r1.62 -r1.63
--- src/hg/js/hgTracks.js	3 Apr 2010 01:50:04 -0000	1.62
+++ src/hg/js/hgTracks.js	8 Apr 2010 20:35:57 -0000	1.63
@@ -250,8 +250,9 @@
         // Handle the fact that (as of 1.3.1), jQuery.browser reports "safari" when the browser is in fact Chrome.
         browser = "chrome";
     }
     loadImgAreaSelect(true);
+    setUpMakeItemsDrag('jkTestMakeItems');
 
     if($('#hgTrackUiDialog'))
         $('#hgTrackUiDialog').hide();
 
@@ -319,8 +320,27 @@
             clickClipHeight: clickClipHeight}));
     }
 }
 
+function makeItemsEnd(img, selection)
+{
+alert("dragged out x1=" + selection.x1 + " x2=" + selection.x2);
+return true;
+}
+
+function setUpMakeItemsDrag(trackName)
+{
+// Set up so that they can drag out to define a new item on a makeItems track. 
+var img = $("#img_data_" + trackName);
+if(img != undefined && img.length != 0) {
+    var trackImgTbl = $('#imgTbl');
+    var imgHeight = trackImgTbl.height();
+    jQuery(img.imgAreaSelect( { selectionColor: 'green', outerColor: '',
+	minHeight: imgHeight, maxHeight: imgHeight, onSelectEnd: makeItemsEnd,
+	autoHide: true, movable: false}));
+    }
+}
+
 function toggleTrackGroupVisibility(button, prefix)
 {
 // toggle visibility of a track group; prefix is the prefix of all the id's of tr's in the
 // relevant group. This code also modifies the corresponding hidden fields and the gif of the +/- img tag.