44320348c6e42155a50cd034f0c1cad7d2211969 larrym Tue Aug 2 16:02:58 2011 -0700 use a class to populate mouse events for area tags to slim down html diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js index 89a176e..6960335 100644 --- src/hg/js/hgTracks.js +++ src/hg/js/hgTracks.js @@ -957,30 +957,37 @@ function initImgTblButtons() { // Make side buttons visible (must also be called when updating rows in the imgTbl). var btns = $("p.btn"); if(btns.length > 0) { imgTblZipButtons($('#imgTbl')); $(btns).mouseenter( imgTblButtonMouseOver ); $(btns).mouseleave( imgTblButtonMouseOut ); $(btns).show(); } var handle = $("td.dragHandle"); if(handle.length > 0) { $(handle).mouseenter( imgTblDragHandleMouseOver ); $(handle).mouseleave( imgTblDragHandleMouseOut ); } + + // setup mouse callbacks for the area tags + $(".area").each( function(t) { + this.onmouseover = mapItemMouseOver; + this.onmouseout = mapItemMouseOut; + this.onclick = mapClk; + }); } function imgTblDragHandleMouseOver() { // Highlights a single row when mouse over a dragHandle column (sideLabel and buttons) if(jQuery.tableDnD == undefined) { //var handle = $("td.dragHandle"); //$(handle) // .unbind('mouseenter')//, jQuery.tableDnD.mousemove); // .unbind('mouseleave');//, jQuery.tableDnD.mouseup); return; } if (jQuery.tableDnD.dragObject == null) { $( this ).parents("tr.trDraggable").addClass("trDrag"); } @@ -1297,33 +1304,33 @@ engine.ready(function(){ var engine = this; var newToken = document.getElementById("hgt.token").value; if(newToken) { var oldToken = engine.get("token"); if(oldToken && oldToken == newToken) { // user has hit the back button. jQuery('body').css('cursor', 'wait'); window.location = "../cgi-bin/hgTracks?hgsid=" + getHgsid(); } } engine.set("token", newToken); }); }); -function mapClk(obj) +function mapClk() { - return postToSaveSettings(obj); + return postToSaveSettings(this); } function postToSaveSettings(obj) { if(blockUseMap==true) { return false; } if(obj == undefined || obj.href == undefined) // called directly with obj and from callback without obj obj = this; if( obj.href.match('#') || obj.target.length > 0) { //alert("Matched # ["+obj.href+"] or has target:"+obj.target); return true; } var thisForm=$(obj).parents('form'); if(thisForm == undefined || $(thisForm).length == 0) @@ -1533,37 +1540,37 @@ // Create a dummy mapItem on the fly (for objects that don't have corresponding entry in the map). if(typeof(hgTracks.trackDb) != "undefined" && hgTracks.trackDb != null) { var title; var rec = hgTracks.trackDb[id]; if(rec) { title = rec.shortLabel; } else { title = id; } return {id: id, title: "configure " + title}; } else { return null; } } -function mapItemMouseOver(obj) +function mapItemMouseOver() { // Record data for current map area item - currentMapItem = makeMapItem(obj.id); + currentMapItem = makeMapItem(this.id); if(currentMapItem != null) { - currentMapItem.href = obj.href; - currentMapItem.title = obj.title; + currentMapItem.href = this.href; + currentMapItem.title = this.title; } } function mapItemMouseOut(obj) { currentMapItem = null; } function findMapItem(e) { // Find mapItem for given event; returns item object or null if none found. if(currentMapItem) { return currentMapItem; }