Skip to content

Commit

Permalink
Merge branch master into jbrowse_img
Browse files Browse the repository at this point in the history
Conflicts:
	index.html
	js/Browser.js
  • Loading branch information
rbuels committed Mar 5, 2012
2 parents 67f4bed + 944232e commit 76fe51e
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 54 deletions.
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
location: queryParams.loc,
tracks: queryParams.tracks,
bookmark: bookmarkCallback,
show_nav: queryParams.nav,
show_tracklist: queryParams.tracklist,
show_overview: queryParams.overview
});
b.deferredFunctions.push(function() { loadTouch(); });

Expand Down
165 changes: 111 additions & 54 deletions js/Browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
* <li><code>location</code> - (optional) string describing the initial location</li>
* <li><code>defaultTracks</code> - (optional) comma-delimited string containing initial list of tracks to view if there are no cookies and no "tracks" parameter</li>
* <li><code>defaultLocation</code> - (optional) string describing the initial location if there are no cookies and no "location" parameter</li>
* <li><code>show_nav</code> - (optional) string describing the on/off state of navigation box</li>
* <li><code>show_tracklist</code> - (optional) string describing the on/off state of track bar</li>
* <li><code>show_overview</code> - (optional) string describing the on/off state of overview</li>
* </ul>
*/


var Browser = function(params) {
dojo.require("dojo.dnd.Source");
dojo.require("dojo.dnd.Moveable");
Expand All @@ -39,12 +43,19 @@ var Browser = function(params) {
brwsr.container = dojo.byId(params.containerID);
brwsr.container.genomeBrowser = brwsr;
var topPane = document.createElement("div");
brwsr.container.appendChild(topPane);

brwsr.container.appendChild(topPane);
var overview = document.createElement("div");
overview.className = "overview";
overview.id = "overview";

// controls blue shading in red box
topPane.appendChild(overview);

// overview=0 hides overview
if( params.show_overview == 0 ) {
overview.style.cssText="display: none";
};

//try to come up with a good estimate of how big the location box
//actually has to be
var maxBase = 100000000;
Expand Down Expand Up @@ -201,6 +212,8 @@ Browser.prototype.addRefseqs = function(refSeqs) {
/**
* @private
*/


Browser.prototype.onFineMove = function(startbp, endbp) {
var length = this.view.ref.end - this.view.ref.start;
var trapLeft = Math.round((((startbp - this.view.ref.start) / length)
Expand Down Expand Up @@ -233,11 +246,14 @@ Browser.prototype.onFineMove = function(startbp, endbp) {
/**
* @private
*/


Browser.prototype.createTrackList = function(parent, params) {
var leftPane = document.createElement("div");
leftPane.id = "trackPane";
leftPane.style.cssText="width: 10em";
parent.appendChild(leftPane);
//splitter on left side
var leftWidget = new dijit.layout.ContentPane({region: "left", splitter: true}, leftPane);
var trackListDiv = document.createElement("div");
trackListDiv.id = "tracksAvail";
Expand All @@ -253,7 +269,7 @@ Browser.prototype.createTrackList = function(parent, params) {
var brwsr = this;

var changeCallback = function() {
brwsr.view.showVisibleBlocks(true);
brwsr.view.showVisibleBlocks(true);
};

var trackListCreate = function(track, hint) {
Expand All @@ -273,7 +289,7 @@ Browser.prototype.createTrackList = function(parent, params) {
};
this.trackListWidget = new dojo.dnd.Source(trackListDiv,
{creator: trackListCreate,
accept: ["track"],
accept: ["track"], // accepts tracks into left div
withHandles: false});

var trackCreate = function(track, hint) {
Expand All @@ -293,12 +309,15 @@ Browser.prototype.createTrackList = function(parent, params) {
}
return {node: node, data: track, type: ["track"]};
};



this.viewDndWidget = new dojo.dnd.Source(this.view.zoomContainer,
{
creator: trackCreate,
accept: ["track"],
withHandles: true
});
{
creator: trackCreate,
accept: ["track"], //accepts tracks into the viewing field
withHandles: true
});
dojo.subscribe("/dnd/drop", function(source,nodes,iscopy){
brwsr.onVisibleTracksChanged();
//multi-select too confusing?
Expand All @@ -311,6 +330,8 @@ Browser.prototype.createTrackList = function(parent, params) {
/**
* @private
*/


Browser.prototype.onVisibleTracksChanged = function() {
this.view.updateTrackList();
var trackLabels = dojo.map(this.view.tracks,
Expand All @@ -333,6 +354,7 @@ Browser.prototype.onVisibleTracksChanged = function() {
* &lt;center base&gt;<br>
* &lt;feature name/ID&gt;
*/

Browser.prototype.navigateTo = function(loc) {
if (!this.isInitialized) {
var brwsr = this;
Expand Down Expand Up @@ -456,6 +478,7 @@ Browser.prototype.searchNames = function( loc ) {
});
};


/**
* load and display the given tracks
* @example
Expand All @@ -465,6 +488,7 @@ Browser.prototype.searchNames = function( loc ) {
* each of which should correspond to the "label" element of the track
* information dictionaries
*/

Browser.prototype.showTracks = function(trackNameList) {
if (!this.isInitialized) {
var brwsr = this;
Expand All @@ -483,6 +507,7 @@ Browser.prototype.showTracks = function(trackNameList) {
brwsr.viewDndWidget.insertNodes(false, [obj.data]);
removeFromList.push(id);
}

});
}
var movedNode;
Expand All @@ -498,6 +523,7 @@ Browser.prototype.showTracks = function(trackNameList) {
* @returns {String} locstring representation of the current location<br>
* (suitable for passing to navigateTo)
*/

Browser.prototype.visibleRegion = function() {
return Util.assembleLocString({
ref: this.view.ref.name,
Expand All @@ -510,15 +536,43 @@ Browser.prototype.visibleRegion = function() {
* @returns {String} containing comma-separated list of currently-viewed tracks<br>
* (suitable for passing to showTracks)
*/

Browser.prototype.visibleTracks = function() {
var trackLabels = dojo.map(this.view.tracks,
function(track) { return track.name; });
return trackLabels.join(",");
};

Browser.prototype.bkmrk = function (params, area) {
var brwsr = this;
if (!this.isInitialized) {
this.deferredFunctions.push(function() { brwsr.bkmrk(params, area); });
return;
}

if (params.bookmark) {
this.link = document.createElement("a");
if ((params.show_nav != 0) && (params.show_tracklist != 0) && (params.show_overview != 0)) {
this.link.appendChild(document.createTextNode("Link"));
} else {
this.link.appendChild(document.createTextNode("Fullview"));
};
this.link.href = window.location.href;
dojo.connect(this, "onCoarseMove", function() {
brwsr.link.href = params.bookmark(brwsr);
});
dojo.connect(this, "onVisibleTracksChanged", function() {
brwsr.link.href = params.bookmark(brwsr);
});
this.link.style.cssText = "float: right; clear";
area.appendChild(this.link);
}
};

/**
* @private
*/

Browser.prototype.onCoarseMove = function(startbp, endbp) {
var length = this.view.ref.end - this.view.ref.start;
var trapLeft = Math.round((((startbp - this.view.ref.start) / length)
Expand Down Expand Up @@ -549,56 +603,47 @@ Browser.prototype.onCoarseMove = function(startbp, endbp) {
document.title = locString;
};



/**
* @private
*/

Browser.prototype.createNavBox = function(parent, locLength, params) {
var brwsr = this;
var navbox = document.createElement("div");
var browserRoot = params.browserRoot ? params.browserRoot : "";
navbox.id = "navbox";
parent.appendChild(navbox);
navbox.style.cssText = "text-align: center; padding: 2px; z-index: 10;";

if (params.bookmark) {
this.link = document.createElement("a");
this.link.appendChild(document.createTextNode("Link"));
this.link.href = window.location.href;
dojo.connect(this, "onCoarseMove", function() {
brwsr.link.href = params.bookmark(brwsr);
});
dojo.connect(this, "onVisibleTracksChanged", function() {
brwsr.link.href = params.bookmark(brwsr);
});
this.link.style.cssText = "float: right; clear";
navbox.appendChild(this.link);
}
brwsr.bkmrk(params, navbox);

var moveLeft = document.createElement("input");
moveLeft.type = "image";
moveLeft.src = browserRoot + "img/slide-left.png";
moveLeft.id = "moveLeft";
moveLeft.className = "icon nav";
moveLeft.style.height = "40px";
dojo.connect(moveLeft, "click",
function(event) {
dojo.stopEvent(event);
brwsr.view.slide(0.9);
});
navbox.appendChild(moveLeft);

if( params.show_nav != 0 ) {
dojo.connect(moveLeft, "click",
function(event) {
dojo.stopEvent(event);
brwsr.view.slide(0.9);
})
};

var moveRight = document.createElement("input");
moveRight.type = "image";
moveRight.src = browserRoot + "img/slide-right.png";
moveRight.id="moveRight";
moveRight.className = "icon nav";
moveRight.style.height = "40px";
dojo.connect(moveRight, "click",
function(event) {
if( params.show_nav != 0 ) {
dojo.connect(moveRight, "click",
function(event) {
dojo.stopEvent(event);
brwsr.view.slide(-0.9);
});
navbox.appendChild(moveRight);
})};

navbox.appendChild(document.createTextNode("\u00a0\u00a0\u00a0\u00a0"));

Expand All @@ -608,61 +653,60 @@ Browser.prototype.createNavBox = function(parent, locLength, params) {
bigZoomOut.id = "bigZoomOut";
bigZoomOut.className = "icon nav";
bigZoomOut.style.height = "40px";
navbox.appendChild(bigZoomOut);
dojo.connect(bigZoomOut, "click",
if( params.show_nav != 0 ) {
dojo.connect(bigZoomOut, "click",
function(event) {
dojo.stopEvent(event);
brwsr.view.zoomOut(undefined, undefined, 2);
});
})};

var zoomOut = document.createElement("input");
zoomOut.type = "image";
zoomOut.src = browserRoot + "img/zoom-out-1.png";
zoomOut.id = "zoomOut";
zoomOut.className = "icon nav";
zoomOut.style.height = "40px";
dojo.connect(zoomOut, "click",
if( params.show_nav != 0 ) {
dojo.connect(zoomOut, "click",
function(event) {
dojo.stopEvent(event);
brwsr.view.zoomOut();
});
navbox.appendChild(zoomOut);
})};

var zoomIn = document.createElement("input");
zoomIn.type = "image";
zoomIn.src = browserRoot + "img/zoom-in-1.png";
zoomIn.id = "zoomIn";
zoomIn.className = "icon nav";
zoomIn.style.height = "40px";
dojo.connect(zoomIn, "click",
if( params.show_nav != 0 ) {
dojo.connect(zoomIn, "click",
function(event) {
dojo.stopEvent(event);
brwsr.view.zoomIn();
});
navbox.appendChild(zoomIn);
})};

var bigZoomIn = document.createElement("input");
bigZoomIn.type = "image";
bigZoomIn.src = browserRoot + "img/zoom-in-2.png";
bigZoomIn.id = "bigZoomIn";
bigZoomIn.className = "icon nav";
bigZoomIn.style.height = "40px";
dojo.connect(bigZoomIn, "click",
if( params.show_nav != 0 ) {
dojo.connect(bigZoomIn, "click",
function(event) {
dojo.stopEvent(event);
brwsr.view.zoomIn(undefined, undefined, 2);
});
navbox.appendChild(bigZoomIn);
})};

navbox.appendChild(document.createTextNode("\u00a0\u00a0\u00a0\u00a0"));
this.chromList = document.createElement("select");
this.chromList.id="chrom";
navbox.appendChild(this.chromList);
this.locationBox = document.createElement("input");
this.locationBox.size=locLength;
this.locationBox.type="text";
this.locationBox.id="location";
dojo.connect(this.locationBox, "keydown", function(event) {
if( params.show_nav != 0 ) {
dojo.connect(this.locationBox, "keydown", function(event) {
if (event.keyCode == dojo.keys.ENTER) {
brwsr.navigateTo(brwsr.locationBox.value);
//brwsr.locationBox.blur();
Expand All @@ -671,19 +715,32 @@ Browser.prototype.createNavBox = function(parent, locLength, params) {
} else {
brwsr.goButton.disabled = false;
}
});
navbox.appendChild(this.locationBox);
})};

this.goButton = document.createElement("button");
this.goButton.appendChild(document.createTextNode("Go"));
this.goButton.disabled = true;
dojo.connect(this.goButton, "click", function(event) {
if( params.show_nav != 0 ) {
dojo.connect(this.goButton, "click", function(event) {
brwsr.navigateTo(brwsr.locationBox.value);
//brwsr.locationBox.blur();
brwsr.goButton.disabled = true;
dojo.stopEvent(event);
});
navbox.appendChild(this.goButton);
})};

if( params.show_nav != 0 ) {
navbox.appendChild(moveLeft);
navbox.appendChild(moveRight);
navbox.appendChild(document.createTextNode("\u00a0\u00a0\u00a0\u00a0"));
navbox.appendChild(bigZoomOut);
navbox.appendChild(zoomOut);
navbox.appendChild(zoomIn);
navbox.appendChild(bigZoomIn);
navbox.appendChild(document.createTextNode("\u00a0\u00a0\u00a0\u00a0"));
navbox.appendChild(this.chromList);
navbox.appendChild(this.locationBox);
navbox.appendChild(this.goButton);
};

return navbox;
};
Expand Down

0 comments on commit 76fe51e

Please sign in to comment.