Skip to content

Commit

Permalink
Add css configuration variable that allows users to specify either
Browse files Browse the repository at this point in the history
strings or URLs containing CSS to add.
  • Loading branch information
rbuels committed Aug 30, 2012
1 parent 150cc10 commit 3a2c518
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
3 changes: 3 additions & 0 deletions release-notes.txt
@@ -1,5 +1,8 @@
{{$NEXT}}

* Add `css` configuration variable that allows users to specify
either strings or URLs containing CSS to add.

* Fixed feature-layout performance problem when zoomed very far in
on features that are much larger than the viewing window.

Expand Down
20 changes: 17 additions & 3 deletions src/JBrowse/Browser.js
Expand Up @@ -64,13 +64,18 @@ var Browser = function(params) {

this.startTime = Date.now();

this.container = dojo.byId(this.config.containerID);
this.container.onselectstart = function() { return false; };
this.container.genomeBrowser = this;

// init our touch device support
this.addDeferred( Touch.loadTouch );

// schedule the config load, the first step in the initialization
// process, to happen when the page is done loading
dojo.addOnLoad( dojo.hitch( this,'loadConfig' ) );

dojo.connect( this, 'onConfigLoaded', Util.debugHandler( this, 'loadUserCSS' ));
dojo.connect( this, 'onConfigLoaded', Util.debugHandler( this, 'loadRefSeqs' ));
dojo.connect( this, 'onConfigLoaded', Util.debugHandler( this, 'loadNames' ));
dojo.connect( this, 'onRefSeqsLoaded', Util.debugHandler( this, 'initView' ));
Expand Down Expand Up @@ -145,6 +150,18 @@ Browser.prototype.loadRefSeqs = function() {
*/
Browser.prototype.onRefSeqsLoaded = function() {};

Browser.prototype.loadUserCSS = function() {
if( this.config.css && ! dojo.isArray( this.config.css ) )
this.config.css = [ this.config.css ];
dojo.forEach( this.config.css || [], function(css) {
if( typeof css == 'string' ) {
dojo.create('style', { type: 'text/css', innerHTML: css }, this.container );
} else if( typeof css == 'object' ) {
dojo.create('link', { rel: 'stylesheet', href: css.url, type: 'text/css'}, document.head );
}
},this);
};

/**
* Load our name index.
*/
Expand All @@ -157,9 +174,6 @@ Browser.prototype.loadNames = function() {
Browser.prototype.initView = function() {
//set up top nav/overview pane and main GenomeView pane
dojo.addClass(document.body, "tundra");
this.container = dojo.byId(this.config.containerID);
this.container.onselectstart = function() { return false; };
this.container.genomeBrowser = this;
var topPane = dojo.create( 'div',{ style: {overflow: 'hidden'}}, this.container );

var overview = dojo.create( 'div', { className: 'overview', id: 'overview' }, topPane );
Expand Down

0 comments on commit 3a2c518

Please sign in to comment.