src/hg/js/hgTracks.js 1.28
1.28 2009/06/26 23:35:15 tdreszer
Some adjustments to make sure dragZoom still works with imageV2
Index: src/hg/js/hgTracks.js
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/js/hgTracks.js,v
retrieving revision 1.27
retrieving revision 1.28
diff -b -B -U 4 -r1.27 -r1.28
--- src/hg/js/hgTracks.js 26 Jun 2009 20:53:18 -0000 1.27
+++ src/hg/js/hgTracks.js 26 Jun 2009 23:35:15 -0000 1.28
@@ -4,11 +4,12 @@
var debug = false;
var originalPosition;
var originalSize;
var clickClipHeight;
-var start;
+var startDragZoom = null;
var mapHtml;
var newWinWidth;
+var imageV2 = false;
function commify (str) {
if(typeof(str) == "number")
str = str + "";
@@ -36,9 +37,11 @@
function selectStart(img, selection)
{
initVars();
var now = new Date();
- start = now.getTime();
+ startDragZoom = now.getTime();
+ // vvvvvvv Should be obsolete since maps items are ignored when startDragZoom is set
+ if(imageV2 == false) {
jQuery.each(jQuery.browser, function(i, val) {
if(i=="msie" && val) {
// Very hacky way to solve following probem specif to IE:
// If the user ends selection with the mouse in a map box item, the map item
@@ -47,8 +50,10 @@
mapHtml = $('#map').html();
$('#map').empty();
}
});
+ }
+ // ^^^^^^^^ Should be obsolete since maps items are ignored when startDragZoom is set
}
function setPosition(position, size)
{
@@ -145,13 +150,13 @@
if((selection.event.pageX >= (imgOfs.left - slop)) && (selection.event.pageX < (imgOfs.left + imgWidth + slop))
&& (selection.event.pageY >= (imgOfs.top - slop)) && (selection.event.pageY < (imgOfs.top + imgHeight + slop))) {
// ignore single clicks that aren't in the top of the image (this happens b/c the clickClipHeight test in selectStart
// doesn't occur when the user single clicks).
- doIt = start != null || selection.y1 <= clickClipHeight;
+ doIt = startDragZoom != null || selection.y1 <= clickClipHeight;
}
if(doIt) {
- // start is null if mouse has never been moved
- if(updatePosition(img, selection, (selection.x2 == selection.x1) || start == null || (now.getTime() - start) < 100)) {
+ // startDragZoom is null if mouse has never been moved
+ if(updatePosition(img, selection, (selection.x2 == selection.x1) || startDragZoom == null || (now.getTime() - startDragZoom) < 100)) {
document.TrackHeaderForm.submit();
}
} else {
setPosition(originalPosition, originalSize);
@@ -159,9 +164,9 @@
if(mapHtml) {
$('#map').append(mapHtml);
}
}
- mapHtml = start = null;
+ setTimeout('mapHtml = startDragZoom = null;',50); // Necessary incase the selectEnd was over a map item. select takes precedence.
return true;
}
$(window).load(function () {
@@ -169,12 +174,20 @@
var rulerEle = document.getElementById("hgt.rulerClickHeight");
var dragSelectionEle = document.getElementById("hgt.dragSelection");
// disable if ruler is not visible.
if((dragSelectionEle != null) && (dragSelectionEle.value == '1') && (rulerEle != null)) {
- var img = $('#trackMap');
- var imgHeight = jQuery(img).height();
- var imgWidth = jQuery(img).width();
- var imgOfs = jQuery(img).offset();
+ var imgHeight = 0;
+ var imgWidth = 0;
+ var img = $('#img_data_ruler');
+ if(img==undefined || img.length == 0) { // Revert to old imageV1
+ img = $('#trackMap');
+ imgHeight = jQuery(img).height();
+ imgWidth = jQuery(img).width();
+ } else {
+ imageV2 = true;
+ imgHeight = $('#imgTbl').height();
+ imgWidth = $('#td_data_ruler').width();
+ }
clickClipHeight = parseInt(rulerEle.value);
newWinWidth = parseInt(document.getElementById("hgt.newWinWidth").value);
img.imgAreaSelect({ selectionColor: 'blue', outerColor: '',
@@ -228,15 +241,18 @@
$(document).ready(function()
{
// Convert map AREA gets to post the form, ensuring that cart variables are kept up to date
$('a,area').not("[href*='#']").filter("[target='']").click(function(i) {
+ if(startDragZoom != null)
+ return false;
var thisForm=$(this).parents('form');
if(thisForm != undefined && thisForm.length == 1)
return postTheForm($(thisForm).attr('name'),this.href);
return true;
});
- if($('table#imgTbl').length == 1) {
+ if($('#imgTbl').length == 1) {
+ imageV2 = true;
// Make imgTbl allow draw reorder of imgTrack rows
if($(".tableWithDragAndDrop").length > 0) {
$(".tableWithDragAndDrop").tableDnD({
onDragClass: "trDrag",
@@ -247,9 +263,9 @@
// Turn on drag scrolling.
//$(".panDivScroller").panImages($(".panDivScroller").width(),0,0);
// Temporary warning while new imageV2 code is being worked through
- if($('map#map').children().length > 0) {
+ if($('#map').children().length > 0) {
alert('Using imageV2, but old map is not empty!');
}
}
});