8531e866353c70c318c9d6bf79a916f773d9c799 larrym Mon Dec 19 16:46:38 2011 -0800 more inPlaceUpdating (live only in larrym's tree) diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index 0546cef..407a89d 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -7,30 +7,31 @@ /* Data passed in from CGI via the hgTracks object: * * string cgiVersion // CGI_VERSION * string chromName // current chromosome * int winStart // genomic start coordinate (0-based, half-open) * int winEnd // genomic end coordinate * int newWinWidth // new width (in bps) if user clicks on the top ruler * boolean revCmplDisp // true if we are in reverse display * int insideX // width of side-bar (in pixels) * int rulerClickHeight // height of ruler (in pixels) - zero if ruler is hidden * boolean inPlaceUpdate // true if in-place-update is turned on * int imgBox* // various drag-scroll values * boolean measureTiming // true if measureTiming is on * Object trackDb // hash of trackDb entries for tracks which are visible on current page + * string err // error message (present only when hgTracks has hit a fatal berror). */ function initVars() { // There are various entry points, so we call initVars in several places to make sure all is well if (!genomePos.original) { // remember initial position and size so we can restore it if user cancels genomePos.original = genomePos.getOriginalPos(); genomePos.originalSize = $('#size').text(); dragSelect.originalCursor = jQuery('body').css('cursor'); imageV2.imgTbl = $('#imgTbl'); // imageV2.enabled == true unless: advancedJavascript==false, or trackSearch, or config pg imageV2.enabled = (imageV2.imgTbl != undefined && imageV2.imgTbl.length > 0); jQuery.each(jQuery.browser, function(i, val) { if(val) { @@ -345,41 +346,68 @@ blockUseMap: false, blockMapClicks: function () { posting.blockUseMap=true; }, allowMapClicks: function () { posting.blockUseMap=false; }, mapClicksAllowed: function () { return (posting.blockUseMap == false); }, blockTheMapOnMouseMove: function (ev) { if (!posting.blockUseMap && mouse.hasMoved(ev)) { posting.blockUseMap=true; } }, mapClk: function () { - // Use in-place update if the map item just modifies the current position (this is nice because it - // preserves the users current relative position). - var str = "/cgi-bin/hgTracks\\?position=([^:]+):(.+)&hgsid=(\\d+)$"; + var done = false; + if(false && imageV2.inPlaceUpdate) { + // XXXX experimental and only turned on in larrym's tree. + // Use in-place update if the map item just modifies the current position (this is nice because it's faster + // and it preserves the users current relative position in the track image). + // + // First test handles next/prev item. + var str = "/cgi-bin/hgTracks\\?position=([^:]+):(.+)&hgsid=(\\d+)&(hgt\.(next|prev)Item=[^&]+)"; var reg = new RegExp(str); var a = reg.exec(this.href); - if(a && a[1] && a[1] == hgTracks.chromName && imageV2.inPlaceUpdate) { + if(a && a[1] && a[1] == hgTracks.chromName) { + imageV2.navigateInPlace("position=" + encodeURIComponent(a[1] + ":" + a[2]) + "&" + a[4], null, true); + done = true; + } else { + // handle next/prev exon + str = "/cgi-bin/hgTracks\\?position=([^:]+):(.+)&hgsid=(\\d+)$"; + reg = new RegExp(str); + a = reg.exec(this.href); + if(a && a[1]) { imageV2.navigateInPlace("position=" + encodeURIComponent(a[1] + ":" + a[2]), null, true); - return false; + done = true; } else { - return posting.saveSettings(this); + // handle toggle visibility. Request may include a track set, so we cannot use requestImgUpdate. + str = "/cgi-bin/hgTracks\\?(position=[^:]+:.+&hgsid=\\d+&([^=]+)=([^&]+))$"; + reg = new RegExp(str); + a = reg.exec(this.href); + if(a && a[1]) { + imageV2.navigateInPlace(a[1], null, true); + // imageV2.requestImgUpdate(a[1], a[1] + "=" + a[2], "", a[2]); + done = true; + } + } } + } + if(done) + return false; + else + return posting.saveSettings(this); }, saveSettings: function (obj) { if(posting.blockUseMap==true) { return false; } if(obj == undefined || obj.href == undefined) // called directly with obj obj = this; // and from callback without obj if ($(obj).hasClass('noLink')) // TITLE_BUT_NO_LINK return false; if (obj.href.match('#') || obj.target.length > 0) { //alert("Matched # ["+obj.href+"] or has target:"+obj.target);