Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
beginnings of File menu and open-file dialog
- Loading branch information
Showing
3 changed files
with
160 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
define( [ 'dojo/_base/declare', | ||
'dojo/aspect', | ||
'dojo/on', | ||
'dijit/Dialog', | ||
'dijit/form/ValidationTextBox', | ||
'dijit/form/Select', | ||
'dijit/form/Button', | ||
'dijit/form/RadioButton' | ||
], | ||
function( declare, aspect, on, Dialog, TextBox, Select, Button ) { | ||
|
||
return declare(null,{ | ||
constructor: function( args ) { | ||
this.browser = args.browser; | ||
this.config = dojo.clone( args.config || {} ); | ||
}, | ||
|
||
_remoteControls: function() { | ||
var inputCounter = 0; | ||
var id = 'remoteInput'+(inputCounter++); | ||
|
||
var tr = dojo.create( 'tr', {} ); | ||
dojo.create( 'label', { for: id, innerHTML: 'URL' }, dojo.create('td',{},tr) ); | ||
|
||
var textBox = new TextBox({ | ||
id: id, | ||
regExpGen: function() { return '^(https?|file):\/\/.+'; } | ||
}); | ||
textBox.placeAt( dojo.create('td',{},tr) ); | ||
|
||
var typeSelect = new Select({ | ||
options: [ | ||
{ label: '<span class="ghosted">file type</span>', value: null }, | ||
{ label: "GFF3", value: "gff3" }, | ||
{ label: "BigWig", value: "bigwig" }, | ||
{ label: "BAM", value: "bam" }, | ||
{ label: "BAI", value: "bai" } | ||
] | ||
}); | ||
typeSelect.placeAt( dojo.create('td',{},tr) ); | ||
|
||
return tr; | ||
}, | ||
|
||
_localControls: function() { | ||
var inputCounter = 0; | ||
var id = 'localInput'+(inputCounter++); | ||
|
||
var tr = dojo.create( 'tr', {} ); | ||
|
||
var fileBox = dojo.create('input', { type: 'file', | ||
id: id, | ||
onChange: function() { | ||
alert('change!'); | ||
} | ||
}, dojo.create('td',{colspan: 2},tr)); | ||
|
||
var typeSelect = new Select({ | ||
options: [ | ||
{ label: '<span class="ghosted">file type</span>', value: null }, | ||
{ label: "GFF3", value: "gff3" }, | ||
{ label: "BigWig", value: "bigwig" }, | ||
{ label: "BAM", value: "bam" }, | ||
{ label: "BAI", value: "bai" } | ||
] | ||
}); | ||
typeSelect.placeAt( dojo.create( 'td', {}, tr ) ); | ||
|
||
return tr; | ||
}, | ||
|
||
_actionBar: function() { | ||
var actionBar = dojo.create( | ||
'div', { | ||
className: 'dijitDialogPaneActionBar', | ||
innerHTML: '<div class="aux">' | ||
+ '<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"/>' | ||
+ '<label for="tracksOnly">Add to tracks</label>' | ||
+ '</div>' | ||
}); | ||
new Button({ iconClass: 'dijitIconDelete', onClick: dojo.hitch( this.dialog, 'hide' ), label: 'Cancel' }) | ||
.placeAt( actionBar ); | ||
new Button({ iconClass: 'dijitIconFolderOpen', onClick: dojo.hitch( this.dialog, 'hide' ), label: 'Open' }) | ||
.placeAt( actionBar ); | ||
|
||
return actionBar; | ||
}, | ||
|
||
open: function() { | ||
var dialog = this.dialog = new Dialog( | ||
{ title: "Open", className: 'fileDialog' } | ||
); | ||
var table = dojo.create('table'); | ||
dojo.forEach( | ||
[dojo.create('tr',{ innerHTML: '<td colspan="3"><h2>Local Files</h2></td>'})] | ||
.concat( this._localControls() ) | ||
.concat( dojo.create('tr',{innerHTML: '<td colspan="3"><hr></td>'}) ) | ||
.concat( dojo.create('tr',{innerHTML: '<td colspan="3"><h2>Remote Files</h2></td>'}) ) | ||
.concat( this._remoteControls() ), | ||
dojo.hitch( table, 'appendChild' ) | ||
); | ||
|
||
dialog.set( 'content', [ table, this._actionBar() ] ); | ||
dialog.show(); | ||
|
||
aspect.after( dialog, 'hide', function() { | ||
dialog.destroyRecursive(); | ||
}); | ||
} | ||
}); | ||
}); |