Skip to content

Commit

Permalink
beginnings of File menu and open-file dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuels committed Nov 16, 2012
1 parent 7bc7fcc commit f7cc0c9
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 21 deletions.
21 changes: 21 additions & 0 deletions main.css
Expand Up @@ -7,6 +7,27 @@ html, body {
font-family: Univers,Trebuchet MS,Helvetica,Arial,sans-serif;
}

.fileDialog label {
font-weight: bold;
padding: 0 0.5em;
}
.fileDialog table {
padding: 1em;
margin: 2em 1em;
}
.fileDialog table h2 {
text-align: center;
margin: 0;
}
.fileDialog table hr {
margin: 3em 0;
}
.fileDialog div.aux {
text-align: center;
margin-bottom: 1em;
}


fieldset {
padding-left: 1em;
margin: 0.7em 0.5em;
Expand Down
47 changes: 26 additions & 21 deletions src/JBrowse/Browser.js
Expand Up @@ -22,7 +22,8 @@ define( [
'JBrowse/GenomeView',
'JBrowse/TouchScreenSupport',
'JBrowse/ConfigManager',
'JBrowse/View/InfoDialog'
'JBrowse/View/InfoDialog',
'JBrowse/View/FileDialog'
],
function(
lang,
Expand All @@ -46,7 +47,8 @@ define( [
GenomeView,
Touch,
ConfigManager,
InfoDialog
InfoDialog,
FileDialog
) {

var dojof = Util.dojof;
Expand Down Expand Up @@ -327,24 +329,24 @@ Browser.prototype.initView = function() {

if( this.config.show_nav ) {

// this.addGlobalMenuItem( 'file',
// new dijitMenuItem(
// {
// label: 'Open',
// onClick: function() { alert('open sesame!'); }
// })
// );
// var fileMenu = this.makeGlobalMenu('file');
// if( fileMenu ) {
// var fileButton = new dijitDropDownButton(
// { className: 'file',
// innerHTML: 'File',
// //title: '',
// dropDown: fileMenu
// });
// dojo.addClass( fileButton.domNode, 'menu' );
// menuBar.appendChild( fileButton.domNode );
// }
this.addGlobalMenuItem( 'file',
new dijitMenuItem(
{
label: 'Open',
onClick: dojo.hitch( this, 'openFileDialog' )
})
);
var fileMenu = this.makeGlobalMenu('file');
if( fileMenu ) {
var fileButton = new dijitDropDownButton(
{ className: 'file',
innerHTML: 'File',
//title: '',
dropDown: fileMenu
});
dojo.addClass( fileButton.domNode, 'menu' );
menuBar.appendChild( fileButton.domNode );
}

var configMenu = this.makeGlobalMenu('options');
if( configMenu ) {
Expand Down Expand Up @@ -441,6 +443,10 @@ Browser.prototype.initView = function() {
}));
};

Browser.prototype.openFileDialog = function() {
new FileDialog({ browser: this }).open();
};


Browser.prototype.makeGlobalMenu = function( menuName ) {
var items = ( this._globalMenuItems || {} )[menuName] || [];
Expand Down Expand Up @@ -1660,7 +1666,6 @@ Browser.prototype.createNavBox = function( parent ) {
}, dojo.create('button',{},navbox));



this.loadRefSeqs().then( dojo.hitch( this, function() {
if( this.refSeqOrder.length && this.refSeqOrder.length < 30 || this.config.refSeqDropdown ) {
this.refSeqSelectBox = new dijitSelectBox({
Expand Down
113 changes: 113 additions & 0 deletions src/JBrowse/View/FileDialog.js
@@ -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();
});
}
});
});

0 comments on commit f7cc0c9

Please sign in to comment.