Skip to content

Commit

Permalink
guess file types from file extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuels committed Nov 16, 2012
1 parent f7cc0c9 commit 336faeb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/JBrowse/Browser.js
Expand Up @@ -333,6 +333,7 @@ Browser.prototype.initView = function() {
new dijitMenuItem(
{
label: 'Open',
iconClass: 'dijitIconFolderOpen',
onClick: dojo.hitch( this, 'openFileDialog' )
})
);
Expand Down
38 changes: 28 additions & 10 deletions src/JBrowse/View/FileDialog.js
Expand Up @@ -7,7 +7,7 @@ define( [ 'dojo/_base/declare',
'dijit/form/Button',
'dijit/form/RadioButton'
],
function( declare, aspect, on, Dialog, TextBox, Select, Button ) {
function( declare, aspect, on, Dialog, TextBox, Select, Button, RadioButton ) {

return declare(null,{
constructor: function( args ) {
Expand All @@ -24,13 +24,23 @@ return declare(null,{

var textBox = new TextBox({
id: id,
regExpGen: function() { return '^(https?|file):\/\/.+'; }
regExpGen: function() { return '^(https?|file):\/\/.+'; },
onChange: function() {
typeSelect.set(
'value',
/\.bam$/i.test(this.get('value')) ? 'bam' :
/\.bai$/i.test(this.get('value')) ? 'bai' :
/\.gff3?$/i.test(this.get('value') ) ? 'gff3' :
/\.(bw|bigwig)$/i.test(this.get('value') ) ? 'bigwig' :
null
);
}
});
textBox.placeAt( dojo.create('td',{},tr) );

var typeSelect = new Select({
options: [
{ label: '<span class="ghosted">file type</span>', value: null },
{ label: '<span class="ghosted">file type?</span>', value: null },
{ label: "GFF3", value: "gff3" },
{ label: "BigWig", value: "bigwig" },
{ label: "BAM", value: "bam" },
Expand All @@ -49,15 +59,23 @@ return declare(null,{
var tr = dojo.create( 'tr', {} );

var fileBox = dojo.create('input', { type: 'file',
id: id,
onChange: function() {
alert('change!');
}
id: id
}, dojo.create('td',{colspan: 2},tr));
on( fileBox, 'change', function() {
console.log(this.value);
typeSelect.set(
'value',
/\.bam$/i.test(this.value) ? 'bam' :
/\.bai$/i.test(this.value) ? 'bai' :
/\.gff3?$/i.test(this.value ) ? 'gff3' :
/\.(bw|bigwig)$/i.test(this.value ) ? 'bigwig' :
null
);
});

var typeSelect = new Select({
options: [
{ label: '<span class="ghosted">file type</span>', value: null },
{ label: '<span class="ghosted">file type?</span>', value: null },
{ label: "GFF3", value: "gff3" },
{ label: "BigWig", value: "bigwig" },
{ label: "BAM", value: "bam" },
Expand All @@ -74,9 +92,9 @@ return declare(null,{
'div', {
className: 'dijitDialogPaneActionBar',
innerHTML: '<div class="aux">'
+ '<input type="radio" checked="checked" data-dojo-type="dijit/form/RadioButton" name="display" id="immediate" value="immediate"/>'
+ '<input type="radio" checked="checked" data-dojo-type="dijit.form.RadioButton" name="display" id="immediate" value="immediate"/>'
+ '<label for="immediate">Display immediately</label>'
+ ' <input type="radio" data-dojo-type="dijit/form/RadioButton" name="display" id="tracksOnly" value="tracksOnly"/>'
+ ' <input type="radio" data-dojo-type="dijit.form.RadioButton" name="display" id="tracksOnly" value="tracksOnly"/>'
+ '<label for="tracksOnly">Add to tracks</label>'
+ '</div>'
});
Expand Down

0 comments on commit 336faeb

Please sign in to comment.