src/hg/js/hgTracks.js 1.56
1.56 2010/02/26 07:34:01 larrym
POST => GET to fix problem on chrom with settings dialog; cleanup getDb code; handle IMAGEv2_DRAG_REORDER == false
Index: src/hg/js/hgTracks.js
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/js/hgTracks.js,v
retrieving revision 1.55
retrieving revision 1.56
diff -b -B -U 4 -r1.55 -r1.56
--- src/hg/js/hgTracks.js 17 Feb 2010 21:40:26 -0000 1.55
+++ src/hg/js/hgTracks.js 26 Feb 2010 07:34:01 -0000 1.56
@@ -113,9 +113,9 @@
function getDb()
{
var db = document.getElementsByName("db");
if(db == undefined || db.length == 0)
- return "";
+ return undef;
return db[0].value;
}
function checkPosition(img, selection)
@@ -884,8 +884,9 @@
$(document).unbind('mousemove',panner);
$(document).unbind('mouseup',panMouseUp);
mouseIsDown = false;
+ // Talk to tim about this.
if(beyondImage) {
// FIXME:
// 1) When dragging beyondImage, side label is seen. Only solution may be 2 images!
// NOTE: tried clip:rect() but this only works with position:absolute!
@@ -1034,10 +1035,10 @@
});
$(document).ready(function()
{
- if(jQuery.fn.autocomplete && $('input#suggest')) {
var db = getDb();
+ if(jQuery.fn.autocomplete && $('input#suggest') && db) {
$('input#suggest').autocomplete({
delay: 500,
minchars: 1,
ajax_get: ajaxGet(function () {return db;}, new Object),
@@ -1146,8 +1147,21 @@
var obj = imgAreaSelect.data('imgAreaSelect');
obj.setOptions({autoHide : autoHideSetting});
}
+function makeMapItem(id)
+{
+ // XXXX get title from json
+ var title;
+ var rec = trackDbJson[id];
+ if(rec) {
+ title = rec.shortLabel;
+ } else {
+ title = id;
+ }
+ return {id: id, title: "configure " + title};
+}
+
function findMapItem(e)
{
// Find mapItem for given event; returns item object or null if none found.
var x,y;
@@ -1174,24 +1188,27 @@
x = e.pageX - e.target.offsetLeft;
y = e.pageY - e.target.offsetTop;
}
if(e.target.tagName.toUpperCase() == "P") {
+ // This occurs in the left buttons when IMAGEv2_DRAG_REORDER is true.
var a = /p_btn_(.*)/.exec(e.target.id);
if(a && a[1]) {
- // XXXX get title from json
var id = a[1];
- var title;
- var rec = trackDbJson[id];
- if(rec) {
- title = rec.shortLabel;
+ return makeMapItem(id);
} else {
- title = id;
+ return null;
}
- return {id: id, title: "configure " + title};
+ } else if(e.target.tagName.toUpperCase() == "IMG") {
+ // This occurs in the left buttons when IMAGEv2_DRAG_REORDER is false.
+ var a = /img_btn_(.*)/.exec(e.target.id);
+ if(a && a[1]) {
+ var id = a[1];
+ return makeMapItem(id);
} else {
return null;
}
}
+
var retval = -1;
// console.log(e.target.tagName + "; " + e.target.id);
for(var i=0;i<mapItems.length;i++)
{
@@ -1325,9 +1342,9 @@
} else if (cmd == 'hgTrackUi') {
// data: ?
jQuery('body').css('cursor', 'wait');
$.ajax({
- type: "POST",
+ type: "GET",
url: "../cgi-bin/hgTrackUi?ajax=1&g=" + selectedMenuItem.id + "&hgsid=" + getHgsid(),
dataType: "html",
trueSuccess: handleTrackUi,
success: catchErrorOrDispatch,
@@ -1382,8 +1399,9 @@
setCartVar(id, cmd);
$('#tr_' + id).remove();
loadImgAreaSelect(false);
} else if (browser == "safari") {
+ // XXXX How about "Chrome"?
// Safari has the following bug: if we update the local map dynamically, the browser ignores the changes (even
// though if you look in the DOM the changes are there); so we have to do a full form submission when the
// user changes visibility settings.
jQuery('body').css('cursor', 'wait');
@@ -1472,9 +1490,9 @@
if(isGene || isHgc) {
var title = selectedMenuItem.title || "feature";
o["Zoom to " + title] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "selectWholeGene"); return true; }};
o["Get DNA for " + title] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "getDna"); return true; }};
- o["Open Link in New Window"] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "openLink"); return true; }};
+ o["Open details page in new window"] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "openLink"); return true; }};
} else {
o[selectedMenuItem.title] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "hgTrackUi"); return true; }};
}
menu.push(o);
@@ -1694,10 +1713,10 @@
// onClick handler for the "jump" button.
// Handles situation where user types a gene name into the gene box and immediately hits the jump button,
// expecting the browser to jump to that gene.
var gene = $('#suggest').val();
- if(gene && gene.length > 0 && getOriginalPosition() == getPosition()) {
var db = getDb();
+ if(gene && db && gene.length > 0 && (getOriginalPosition() == getPosition() || getPosition().length == 0)) {
pos = lookupGene(db, gene);
if(pos) {
setPosition(pos, null);
} else {