From 37807f00cb1f60ca439050244e885eb31545f464 Mon Sep 17 00:00:00 2001 From: Robert Buels Date: Wed, 5 Sep 2012 22:40:14 +0900 Subject: [PATCH] make feature tracks initialize their config at construction time --- src/JBrowse/View/Track/HTMLFeatures.js | 88 ++++++++++++-------------- 1 file changed, 42 insertions(+), 46 deletions(-) diff --git a/src/JBrowse/View/Track/HTMLFeatures.js b/src/JBrowse/View/Track/HTMLFeatures.js index 6ad86efb22..41ed601ce0 100644 --- a/src/JBrowse/View/Track/HTMLFeatures.js +++ b/src/JBrowse/View/Track/HTMLFeatures.js @@ -72,52 +72,8 @@ var HTMLFeatures = declare( BlockBased, // to eachother dojo.connect( this.featureStore, 'loadSuccess', this, 'loadSuccess' ); dojo.connect( this.featureStore, 'loadFail', this, 'loadFail' ); - }, - - /** - * Request that the track load its data. The track will call its own - * loadSuccess() function when it is loaded. - */ - load: function() { - this.featureStore.load(); - }, - - /** - * Make a default feature detail page for the given feature. - * @returns {HTMLElement} feature detail page HTML - */ - defaultFeatureDetail: function( /** JBrowse.Track */ track, /** Object */ f, /** HTMLElement */ div ) { - var fmt = dojo.hitch( this, '_fmtFeatureDetailField' ); - var container = dojo.create('div', { className: 'feature-detail feature-detail-'+track.name, innerHTML: '' } ); - container.innerHTML += fmt( 'Name', f.get('name') ); - container.innerHTML += fmt( 'Type', f.get('type') ); - container.innerHTML += fmt( 'Description', f.get('note') ); - container.innerHTML += fmt( 'Position', this.refSeq.name+':'+f.get('start')+'..'+f.get('end') ); - container.innerHTML += fmt( 'Strand', {'1':'+', '-1': '-', 0: undefined }[f.get('strand')] || f.get('strand') ); - - var additionalTags = array.filter( f.tags(), function(t) { return ! {name:1,start:1,end:1,strand:1,note:1,subfeatures:1,type:1}[t.toLowerCase()]; }); - dojo.forEach( additionalTags.sort(), function(t) { - container.innerHTML += fmt( t, f.get(t) ); - }); - - return container; - }, - _fmtFeatureDetailField: function( title, val, class_ ) { - var valType = typeof val; - if( !( valType in {string:1,number:1} ) ) - return ''; //val = 'none'; - class_ = class_ || title.replace(/\s+/g,'_').toLowerCase(); - return '

'+title+'

'+val+'
'; - }, - - // _autoLinkText: function( text ) { - // return text - // // GO terms like GO:12345 - // .replace(/\b(GO:\d{5,})\b/g, '$1'); - // }, - - loadSuccess: function(trackInfo, url) { + // initialize a bunch of config stuff var defaultConfig = { description: true, style: { @@ -169,9 +125,49 @@ var HTMLFeatures = declare( BlockBased, this.labelScale = this.featureStore.density * this.config.style.labelScale; this.subfeatureScale = this.featureStore.density * this.config.style.subfeatureScale; this.descriptionScale = this.featureStore.density * this.config.style.descriptionScale;; + }, + + /** + * Request that the track load its data. The track will call its own + * loadSuccess() function when it is loaded. + */ + load: function() { + this.featureStore.load(); + }, + + /** + * Make a default feature detail page for the given feature. + * @returns {HTMLElement} feature detail page HTML + */ + defaultFeatureDetail: function( /** JBrowse.Track */ track, /** Object */ f, /** HTMLElement */ div ) { + var fmt = dojo.hitch( this, '_fmtFeatureDetailField' ); + var container = dojo.create('div', { className: 'feature-detail feature-detail-'+track.name, innerHTML: '' } ); + container.innerHTML += fmt( 'Name', f.get('name') ); + container.innerHTML += fmt( 'Type', f.get('type') ); + container.innerHTML += fmt( 'Description', f.get('note') ); + container.innerHTML += fmt( 'Position', this.refSeq.name+':'+f.get('start')+'..'+f.get('end') ); + container.innerHTML += fmt( 'Strand', {'1':'+', '-1': '-', 0: undefined }[f.get('strand')] || f.get('strand') ); - this.setLoaded(); + var additionalTags = array.filter( f.tags(), function(t) { return ! {name:1,start:1,end:1,strand:1,note:1,subfeatures:1,type:1}[t.toLowerCase()]; }); + dojo.forEach( additionalTags.sort(), function(t) { + container.innerHTML += fmt( t, f.get(t) ); + }); + + return container; }, + _fmtFeatureDetailField: function( title, val, class_ ) { + var valType = typeof val; + if( !( valType in {string:1,number:1} ) ) + return ''; //val = 'none'; + class_ = class_ || title.replace(/\s+/g,'_').toLowerCase(); + return '

'+title+'

'+val+'
'; + }, + + // _autoLinkText: function( text ) { + // return text + // // GO terms like GO:12345 + // .replace(/\b(GO:\d{5,})\b/g, '$1'); + // }, /** * Make life easier for event handlers by handing them some things