2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/b129ae3fc035/ changeset: b129ae3fc035 user: jgoecks date: 2012-05-28 18:05:20 summary: Move icons from trackster.css to base.css for general usage. affected #: 5 files diff -r 03cb8ee86726813073913be149516ab10e601e55 -r b129ae3fc0359f08b9f47ae33230249a4ce0975e static/june_2007_style/base_sprites.less.tmpl --- a/static/june_2007_style/base_sprites.less.tmpl +++ b/static/june_2007_style/base_sprites.less.tmpl @@ -102,14 +102,28 @@ -sprite-group: fugue; -sprite-image: silk/chart_curve.png; } - +.icon-button.disk--arrow { + -sprite-group: fugue; + -sprite-image: fugue/disk--arrow-bw.png; +} +.icon-button.disk--arrow:hover { + -sprite-group: fugue; + -sprite-image: fugue/disk--arrow.png; +} +.icon-button.cross-circle { + -sprite-group: fugue; + -sprite-image: fugue/cross-circle-bw.png; +} +.icon-button.cross-circle:hover { + -sprite-group: fugue; + -sprite-image: fugue/cross-circle.png; +} .text-and-autocomplete-select { -sprite-group: fugue; -sprite-image: fugue/control-270.png; -sprite-horiz-position: right; } - div.historyItem-error .state-icon { -sprite-group: history-states; -sprite-image: data_error.png; diff -r 03cb8ee86726813073913be149516ab10e601e55 -r b129ae3fc0359f08b9f47ae33230249a4ce0975e static/june_2007_style/blue/base.css --- a/static/june_2007_style/blue/base.css +++ b/static/june_2007_style/blue/base.css @@ -754,7 +754,11 @@ .icon-button.plus-button:hover{background:url(fugue.png) no-repeat 0px -364px;} .icon-button.gear{background:url(fugue.png) no-repeat 0px -390px;} .icon-button.chart_curve{background:url(fugue.png) no-repeat 0px -416px;} -.text-and-autocomplete-select{background:url(fugue.png) no-repeat right -442px;} +.icon-button.disk--arrow{background:url(fugue.png) no-repeat 0px -442px;} +.icon-button.disk--arrow:hover{background:url(fugue.png) no-repeat 0px -468px;} +.icon-button.cross-circle{background:url(fugue.png) no-repeat 0px -494px;} +.icon-button.cross-circle:hover{background:url(fugue.png) no-repeat 0px -520px;} +.text-and-autocomplete-select{background:url(fugue.png) no-repeat right -546px;} div.historyItem-error .state-icon{background:url(history-states.png) no-repeat 0px 0px;} div.historyItem-empty .state-icon{background:url(history-states.png) no-repeat 0px -25px;} div.historyItem-queued .state-icon{background:url(history-states.png) no-repeat 0px -50px;} diff -r 03cb8ee86726813073913be149516ab10e601e55 -r b129ae3fc0359f08b9f47ae33230249a4ce0975e static/june_2007_style/blue/fugue.png Binary file static/june_2007_style/blue/fugue.png has changed diff -r 03cb8ee86726813073913be149516ab10e601e55 -r b129ae3fc0359f08b9f47ae33230249a4ce0975e static/june_2007_style/blue/trackster.css --- a/static/june_2007_style/blue/trackster.css +++ b/static/june_2007_style/blue/trackster.css @@ -84,16 +84,12 @@ .icon-button.toggle:hover{background:transparent url(../images/fugue/toggle.png) no-repeat;} .icon-button.toggle-expand{background:transparent url(../images/fugue/toggle-expand-bw.png) no-repeat;margin-right:0px;} .icon-button.toggle-expand:hover{background:transparent url(../images/fugue/toggle-expand.png) no-repeat;} -.icon-button.cross-circle{background:transparent url(../images/fugue/cross-circle-bw.png) no-repeat;margin-right:0px;} -.icon-button.cross-circle:hover{background:transparent url(../images/fugue/cross-circle.png) no-repeat;} .icon-button.block--plus{background:transparent url(../images/fugue/block--plus-bw.png) no-repeat;} .icon-button.block--plus:hover{background:transparent url(../images/fugue/block--plus.png) no-repeat;} .icon-button.bookmarks{background:transparent url(../images/fugue/bookmarks-bw.png) no-repeat;} .icon-button.bookmarks:hover{background:transparent url(../images/fugue/bookmarks.png) no-repeat;} .icon-button.toolbox{background:transparent url(../images/fugue/toolbox-bw.png) no-repeat;} .icon-button.toolbox:hover{background:transparent url(../images/fugue/toolbox.png) no-repeat;} -.icon-button.disk--arrow{background:transparent url(../images/fugue/disk--arrow-bw.png) no-repeat;} -.icon-button.disk--arrow:hover{background:transparent url(../images/fugue/disk--arrow.png) no-repeat;} .child-track-icon{background:url('../images/fugue/arrow-000-small-bw.png') no-repeat;width:30px;cursor:move;} .track-resize{background:white url('../images/visualization/draggable_vertical.png') no-repeat top center;position:absolute;right:3px;bottom:-4px;width:14px;height:7px;border:solid #999 1px;z-index:100;} .bookmark{background:white;border:solid #999 1px;border-right:none;margin:0.5em;margin-right:0;padding:0.5em;} diff -r 03cb8ee86726813073913be149516ab10e601e55 -r b129ae3fc0359f08b9f47ae33230249a4ce0975e static/june_2007_style/trackster.css.tmpl --- a/static/june_2007_style/trackster.css.tmpl +++ b/static/june_2007_style/trackster.css.tmpl @@ -405,12 +405,6 @@ .icon-button.toggle-expand:hover { background: transparent url(../images/fugue/toggle-expand.png) no-repeat; } -.icon-button.cross-circle { - background: transparent url(../images/fugue/cross-circle-bw.png) no-repeat;margin-right:0px; -} -.icon-button.cross-circle:hover { - background: transparent url(../images/fugue/cross-circle.png) no-repeat; -} .icon-button.block--plus { background: transparent url(../images/fugue/block--plus-bw.png) no-repeat; } @@ -429,12 +423,6 @@ .icon-button.toolbox:hover { background: transparent url(../images/fugue/toolbox.png) no-repeat; } -.icon-button.disk--arrow { - background: transparent url(../images/fugue/disk--arrow-bw.png) no-repeat; -} -.icon-button.disk--arrow:hover { - background: transparent url(../images/fugue/disk--arrow.png) no-repeat; -} .child-track-icon { background:url('../images/fugue/arrow-000-small-bw.png') no-repeat; width: 30px; https://bitbucket.org/galaxy/galaxy-central/changeset/9765176c63f7/ changeset: 9765176c63f7 user: jgoecks date: 2012-05-28 18:10:04 summary: Visualization: (a) rename circos viz 'circster' and (b) foundational work for circster and backbone-visualization integration. Also pack scripts. affected #: 11 files diff -r b129ae3fc0359f08b9f47ae33230249a4ce0975e -r 9765176c63f7ada3ee30a649ab3ef13396d9c84b lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -277,7 +277,7 @@ class UsesVisualizationMixin( SharableItemSecurityMixin ): """ Mixin for controllers that use Visualization objects. """ - viz_types = [ "trackster", "circos" ] + viz_types = [ "trackster", "circster" ] len_files = None @@ -360,7 +360,7 @@ end = config['viewport']['end'] overview = config['viewport']['overview'] vis_rev.config[ "viewport" ] = { 'chrom': chrom, 'start': start, 'end': end, 'overview': overview } - elif type == 'circos': + elif type == 'circster': # TODO. pass diff -r b129ae3fc0359f08b9f47ae33230249a4ce0975e -r 9765176c63f7ada3ee30a649ab3ef13396d9c84b lib/galaxy/web/controllers/tracks.py --- a/lib/galaxy/web/controllers/tracks.py +++ b/lib/galaxy/web/controllers/tracks.py @@ -758,7 +758,7 @@ @web.expose @web.require_login( "use Galaxy visualizations", use_panels=True ) - def circos( self, trans, hda_ldda, dataset_id ): + def circster( self, trans, hda_ldda, dataset_id ): # Get dataset. dataset = self._get_dataset( trans, hda_ldda, dataset_id ) @@ -777,7 +777,7 @@ summary = indexer.get_summary( chrom_info[ 'chrom' ], 0, chrom_info[ 'len' ], level=4 ) dataset_summary.append( summary ) - return trans.fill_template_mako( "visualization/circos.mako", dataset=dataset, dataset_summary=dataset_summary, genome=genome ) + return trans.fill_template_mako( "visualization/circster.mako", dataset=dataset, dataset_summary=dataset_summary, genome=genome ) # ----------------- # Helper methods. diff -r b129ae3fc0359f08b9f47ae33230249a4ce0975e -r 9765176c63f7ada3ee30a649ab3ef13396d9c84b static/scripts/mvc/tools.js --- a/static/scripts/mvc/tools.js +++ b/static/scripts/mvc/tools.js @@ -181,6 +181,7 @@ * applies search results as they become available. */ var ToolPanel = Backbone.Collection.extend({ + // TODO: need to generate this using url_for url: "/tools", tools: new ToolCollection(), diff -r b129ae3fc0359f08b9f47ae33230249a4ce0975e -r 9765176c63f7ada3ee30a649ab3ef13396d9c84b static/scripts/mvc/ui.js --- a/static/scripts/mvc/ui.js +++ b/static/scripts/mvc/ui.js @@ -1,5 +1,24 @@ /** - * Utility models and views for Galaxy objects. + * -- Functions for creating large UI elements. -- + */ + +/** + * Returns an IconButtonMenuView for the provided configuration. + * Configuration is a list of dictionaries where each dictionary + * defines an icon button. Each dictionary must have the following + * elements: icon_class, title, and on_click. + */ +var create_icon_buttons_menu = function(config) { + // Create and initialize menu. + var buttons = new IconButtonCollection( + _.map(config, function(button_config) { return new IconButton(button_config); }) + ); + + return new IconButtonMenuView( {collection: buttons} ); +}; + +/** + * -- Utility models and views for Galaxy objects. -- */ /** diff -r b129ae3fc0359f08b9f47ae33230249a4ce0975e -r 9765176c63f7ada3ee30a649ab3ef13396d9c84b static/scripts/mvc/visualization.js --- a/static/scripts/mvc/visualization.js +++ b/static/scripts/mvc/visualization.js @@ -26,9 +26,77 @@ }); /** + * A genome browser bookmark. + */ +var BrowserBookmark = Backbone.Model.extend({ + defaults: { + chrom: null, + start: 0, + end: 0, + note: "" + } +}); + +/** + * Bookmarks collection. + */ +var BrowserBookmarks = Backbone.Collection.extend({ + model: BrowserBookmark +}); + +/** + * A visualization. + */ +var Visualization = Backbone.RelationalModel.extend({ + defaults: { + id: "", + title: "", + type: "", + dbkey: "", + datasets: [] + } +}); + +/** + * A Trackster visualization. + */ +var TracksterVisualization = Visualization.extend({ + defaults: { + bookmarks: [], + viewport: {} + } +}); + +/** + * A Circster visualization. + */ +var CircsterVisualization = Visualization.extend({ +}); + +/** + * A dataset. In Galaxy, datasets are associated with a history, so + * this object is also known as a HistoryDatasetAssociation. + */ +var Dataset = Backbone.Model.extend({ + defaults: { + id: "", + type: "", + name: "", + hda_ldda: "" + } +}); + +/** * A histogram dataset. */ var HistogramDataset = Backbone.Model.extend({ + /* + defaults: { + data: [], + dataset: null, + max: 0 + }, + */ initialize: function(data) { // Set max across dataset. @@ -42,9 +110,16 @@ }); /** - * Layout for a histogram dataset in a circos visualization. + * Configuration data for a Trackster track. */ -var CircosHistogramDatasetLayout = Backbone.Model.extend({ +var TrackConfig = Backbone.Model.extend({ + +}); + +/** + * Layout for a histogram dataset in a circster visualization. + */ +var CircsterHistogramDatasetLayout = Backbone.Model.extend({ // TODO: should accept genome and dataset and use these to generate layout data. /** @@ -104,8 +179,8 @@ * -- Views -- */ -var CircosView = Backbone.View.extend({ - className: 'circos', +var CircsterView = Backbone.View.extend({ + className: 'circster', initialize: function(options) { this.width = options.width; @@ -124,7 +199,7 @@ dataset_arc_height = this.dataset_arc_height, // Layout chromosome arcs. - arcs_layout = new CircosHistogramDatasetLayout({ + arcs_layout = new CircsterHistogramDatasetLayout({ genome: this.genome, total_gap: this.total_gap }), @@ -205,3 +280,58 @@ this.view.go_to(new_loc); } }); + +/** + * -- Helper functions. + */ + +/** + * Use a popup grid to add more datasets. + */ +var add_datasets = function(dataset_url, add_track_async_url, success_fn) { + $.ajax({ + url: dataset_url, + data: { "f-dbkey": view.dbkey }, + error: function() { alert( "Grid failed" ); }, + success: function(table_html) { + show_modal( + "Select datasets for new tracks", + table_html, { + "Cancel": function() { + hide_modal(); + }, + "Add": function() { + var requests = []; + $('input[name=id]:checked,input[name=ldda_ids]:checked').each(function() { + var data, + id = $(this).val(); + if ($(this).attr("name") === "id") { + data = { hda_id: id }; + } else { + data = { ldda_id: id}; + } + requests[requests.length] = $.ajax({ + url: add_track_async_url, + data: data, + dataType: "json", + }); + }); + // To preserve order, wait until there are definitions for all tracks and then add + // them sequentially. + $.when.apply($, requests).then(function() { + // jQuery always returns an Array for arguments, so need to look at first element + // to determine whether multiple requests were made and consequently how to + // map arguments to track definitions. + var track_defs = (arguments[0] instanceof Array ? + $.map(arguments, function(arg) { return arg[0]; }) : + [ arguments[0] ] + ); + success_fn(track_defs); + }); + hide_modal(); + } + } + ); + } + }); +}; diff -r b129ae3fc0359f08b9f47ae33230249a4ce0975e -r 9765176c63f7ada3ee30a649ab3ef13396d9c84b static/scripts/packed/mvc/ui.js --- a/static/scripts/packed/mvc/ui.js +++ b/static/scripts/packed/mvc/ui.js @@ -1,1 +1,1 @@ -var GalaxyPaths=Backbone.Model.extend({defaults:{root_path:"",image_path:""}});var IconButton=Backbone.Model.extend({defaults:{title:"",icon_class:"",on_click:null}});var IconButtonCollection=Backbone.Collection.extend({model:IconButton});var IconButtonMenuView=Backbone.View.extend({tagName:"div",render:function(){var a=this;this.collection.each(function(b){$("<a/>").attr("href","javascript:void(0)").attr("title",b.attributes.title).addClass("icon-button menu-button").addClass(b.attributes.icon_class).appendTo(a.$el).click(b.attributes.on_click)});return this}});var Grid=Backbone.Collection.extend({});var GridView=Backbone.View.extend({}); \ No newline at end of file +var create_icon_buttons_menu=function(a){var b=new IconButtonCollection(_.map(a,function(c){return new IconButton(c)}));return new IconButtonMenuView({collection:b})};var GalaxyPaths=Backbone.Model.extend({defaults:{root_path:"",image_path:""}});var IconButton=Backbone.Model.extend({defaults:{title:"",icon_class:"",on_click:null}});var IconButtonCollection=Backbone.Collection.extend({model:IconButton});var IconButtonMenuView=Backbone.View.extend({tagName:"div",render:function(){var a=this;this.collection.each(function(b){$("<a/>").attr("href","javascript:void(0)").attr("title",b.attributes.title).addClass("icon-button menu-button").addClass(b.attributes.icon_class).appendTo(a.$el).click(b.attributes.on_click)});return this}});var Grid=Backbone.Collection.extend({});var GridView=Backbone.View.extend({}); \ No newline at end of file diff -r b129ae3fc0359f08b9f47ae33230249a4ce0975e -r 9765176c63f7ada3ee30a649ab3ef13396d9c84b static/scripts/packed/mvc/visualization.js --- a/static/scripts/packed/mvc/visualization.js +++ b/static/scripts/packed/mvc/visualization.js @@ -1,1 +1,1 @@ -var Genome=Backbone.Model.extend({defaults:{name:null,key:null,chroms_info:null},get_chroms_info:function(){return this.attributes.chroms_info.chrom_info}});var HistogramDataset=Backbone.Model.extend({initialize:function(a){this.attributes.data=a;this.attributes.max=_.max(a,function(b){if(!b||typeof b==="string"){return 0}return b[1]})[1]}});var CircosHistogramDatasetLayout=Backbone.Model.extend({chroms_layout:function(){var b=this.attributes.genome.get_chroms_info(),d=d3.layout.pie().value(function(f){return f.len}).sort(null),e=d(b),a=this.attributes.total_gap/b.length,c=_.map(e,function(h,g){var f=h.endAngle-a;h.endAngle=(f>h.startAngle?f:h.startAngle);return h});return c},chrom_data_layout:function(j,b,g,f,h){if(!b||typeof b==="string"){return null}var d=b[0],i=b[3],c=d3.scale.linear().domain([0,h]).range([g,f]),e=d3.layout.pie().value(function(k){return i}).startAngle(j.startAngle).endAngle(j.endAngle),a=e(d);_.each(d,function(k,l){a[l].outerRadius=c(k[1])});return a}});var CircosView=Backbone.View.extend({className:"circos",initialize:function(a){this.width=a.width;this.height=a.height;this.total_gap=a.total_gap;this.genome=a.genome;this.dataset=a.dataset;this.radius_start=a.radius_start;this.dataset_arc_height=a.dataset_arc_height},render:function(){var d=this.radius_start,e=this.dataset_arc_height,j=new CircosHistogramDatasetLayout({genome:this.genome,total_gap:this.total_gap}),i=j.chroms_layout(),g=_.zip(i,this.dataset.attributes.data),h=this.dataset.attributes.max,b=_.map(g,function(m){var n=m[0],l=m[1];return j.chrom_data_layout(n,l,d,d+e,h)});var c=d3.select(this.$el[0]).append("svg").attr("width",this.width).attr("height",this.height).append("g").attr("transform","translate("+this.width/2+","+this.height/2+")");var k=c.append("g").attr("id","inner-arc"),f=d3.svg.arc().innerRadius(d).outerRadius(d+e),a=k.selectAll("#inner-arc>path").data(i).enter().append("path").attr("d",f).style("stroke","#ccc").style("fill","#ccc").append("title").text(function(l){return l.data.chrom});_.each(b,function(l){if(!l){return}var o=c.append("g"),n=d3.svg.arc().innerRadius(d),m=o.selectAll("path").data(l).enter().append("path").attr("d",n).style("stroke","red").style("fill","red")})}});var TrackBrowserRouter=Backbone.Router.extend({initialize:function(b){this.view=b.view;this.route(/([\w]+)$/,"change_location");this.route(/([\w]+\:[\d,]+-[\d,]+)$/,"change_location");var a=this;a.view.on("navigate",function(c){a.navigate(c)})},change_location:function(a){this.view.go_to(a)}}); \ No newline at end of file +var Genome=Backbone.Model.extend({defaults:{name:null,key:null,chroms_info:null},get_chroms_info:function(){return this.attributes.chroms_info.chrom_info}});var BrowserBookmark=Backbone.Model.extend({defaults:{chrom:null,start:0,end:0,note:""}});var BrowserBookmarks=Backbone.Collection.extend({model:BrowserBookmark});var Visualization=Backbone.RelationalModel.extend({defaults:{id:"",title:"",type:"",dbkey:"",datasets:[]}});var TracksterVisualization=Visualization.extend({defaults:{bookmarks:[],viewport:{}}});var CircsterVisualization=Visualization.extend({});var Dataset=Backbone.Model.extend({defaults:{id:"",type:"",name:"",hda_ldda:""}});var HistogramDataset=Backbone.Model.extend({initialize:function(a){this.attributes.data=a;this.attributes.max=_.max(a,function(b){if(!b||typeof b==="string"){return 0}return b[1]})[1]}});var TrackConfig=Backbone.Model.extend({});var CircsterHistogramDatasetLayout=Backbone.Model.extend({chroms_layout:function(){var b=this.attributes.genome.get_chroms_info(),d=d3.layout.pie().value(function(f){return f.len}).sort(null),e=d(b),a=this.attributes.total_gap/b.length,c=_.map(e,function(h,g){var f=h.endAngle-a;h.endAngle=(f>h.startAngle?f:h.startAngle);return h});return c},chrom_data_layout:function(j,b,g,f,h){if(!b||typeof b==="string"){return null}var d=b[0],i=b[3],c=d3.scale.linear().domain([0,h]).range([g,f]),e=d3.layout.pie().value(function(k){return i}).startAngle(j.startAngle).endAngle(j.endAngle),a=e(d);_.each(d,function(k,l){a[l].outerRadius=c(k[1])});return a}});var CircsterView=Backbone.View.extend({className:"circster",initialize:function(a){this.width=a.width;this.height=a.height;this.total_gap=a.total_gap;this.genome=a.genome;this.dataset=a.dataset;this.radius_start=a.radius_start;this.dataset_arc_height=a.dataset_arc_height},render:function(){var d=this.radius_start,e=this.dataset_arc_height,j=new CircsterHistogramDatasetLayout({genome:this.genome,total_gap:this.total_gap}),i=j.chroms_layout(),g=_.zip(i,this.dataset.attributes.data),h=this.dataset.attributes.max,b=_.map(g,function(m){var n=m[0],l=m[1];return j.chrom_data_layout(n,l,d,d+e,h)});var c=d3.select(this.$el[0]).append("svg").attr("width",this.width).attr("height",this.height).append("g").attr("transform","translate("+this.width/2+","+this.height/2+")");var k=c.append("g").attr("id","inner-arc"),f=d3.svg.arc().innerRadius(d).outerRadius(d+e),a=k.selectAll("#inner-arc>path").data(i).enter().append("path").attr("d",f).style("stroke","#ccc").style("fill","#ccc").append("title").text(function(l){return l.data.chrom});_.each(b,function(l){if(!l){return}var o=c.append("g"),n=d3.svg.arc().innerRadius(d),m=o.selectAll("path").data(l).enter().append("path").attr("d",n).style("stroke","red").style("fill","red")})}});var TrackBrowserRouter=Backbone.Router.extend({initialize:function(b){this.view=b.view;this.route(/([\w]+)$/,"change_location");this.route(/([\w]+\:[\d,]+-[\d,]+)$/,"change_location");var a=this;a.view.on("navigate",function(c){a.navigate(c)})},change_location:function(a){this.view.go_to(a)}});var add_datasets=function(a,c,b){$.ajax({url:a,data:{"f-dbkey":view.dbkey},error:function(){alert("Grid failed")},success:function(d){show_modal("Select datasets for new tracks",d,{Cancel:function(){hide_modal()},Add:function(){var e=[];$("input[name=id]:checked,input[name=ldda_ids]:checked").each(function(){var f,g=$(this).val();if($(this).attr("name")==="id"){f={hda_id:g}}else{f={ldda_id:g}}e[e.length]=$.ajax({url:c,data:f,dataType:"json",})});$.when.apply($,e).then(function(){var f=(arguments[0] instanceof Array?$.map(arguments,function(g){return g[0]}):[arguments[0]]);b(f)});hide_modal()}})}})}; \ No newline at end of file diff -r b129ae3fc0359f08b9f47ae33230249a4ce0975e -r 9765176c63f7ada3ee30a649ab3ef13396d9c84b templates/base_panels.mako --- a/templates/base_panels.mako +++ b/templates/base_panels.mako @@ -61,7 +61,7 @@ <%def name="late_javascripts()"> ## Scripts can be loaded later since they progressively add features to ## the panels, but do not change layout - ${h.js( 'jquery.event.drag', 'jquery.event.hover', 'jquery.form', 'jquery.rating', 'galaxy.base', 'galaxy.panels' )} + ${h.js( 'jquery.event.drag', 'jquery.event.hover', 'jquery.form', 'jquery.rating', 'galaxy.base', 'galaxy.panels', 'jquery.tipsy' )} <script type="text/javascript"> ensure_dd_helper(); diff -r b129ae3fc0359f08b9f47ae33230249a4ce0975e -r 9765176c63f7ada3ee30a649ab3ef13396d9c84b templates/tracks/browser.mako --- a/templates/tracks/browser.mako +++ b/templates/tracks/browser.mako @@ -42,13 +42,16 @@ <script type='text/javascript' src="${h.url_for('/static/scripts/excanvas.js')}"></script><![endif]--> -${h.js( "galaxy.base", "galaxy.panels", "json2", "jquery", "jstorage", "jquery.event.drag", "jquery.event.hover","jquery.mousewheel", "jquery.autocomplete", "trackster", "trackster_ui", "jquery.ui.sortable.slider", "farbtastic", "jquery.tipsy", "mvc/visualization" )} +${h.js( "galaxy.base", "galaxy.panels", "json2", "jquery", "jstorage", "jquery.event.drag", "jquery.event.hover","jquery.mousewheel", "jquery.autocomplete", "trackster", "trackster_ui", "jquery.ui.sortable.slider", "farbtastic", "mvc/visualization" )} <script type="text/javascript"> // // Place URLs here so that url_for can be used to generate them. // - var default_data_url = "${h.url_for( action='data' )}", + var + add_track_async_url = "${h.url_for( action='add_track_async' )}", + add_datasets_url = "${h.url_for( action='list_current_history_datasets' )}", + default_data_url = "${h.url_for( action='data' )}", raw_data_url = "${h.url_for( action='raw_data' )}", run_tool_url = "${h.url_for( action='run_tool' )}", rerun_tool_url = "${h.url_for( action='rerun_tool' )}", @@ -66,60 +69,7 @@ browser_router = new TrackBrowserRouter(options); Backbone.history.start(); }; - - /** - * Use a popup grid to add more tracks. - */ - var add_tracks = function() { - $.ajax({ - url: "${h.url_for( action='list_current_history_datasets' )}", - data: { "f-dbkey": view.dbkey }, - error: function() { alert( "Grid failed" ); }, - success: function(table_html) { - show_modal( - "Select datasets for new tracks", - table_html, { - "Cancel": function() { - hide_modal(); - }, - "Insert": function() { - var requests = []; - $('input[name=id]:checked,input[name=ldda_ids]:checked').each(function() { - var data, - id = $(this).val(); - if ($(this).attr("name") === "id") { - data = { hda_id: id }; - } else { - data = { ldda_id: id}; - } - requests[requests.length] = $.ajax({ - url: "${h.url_for( action='add_track_async' )}", - data: data, - dataType: "json", - }); - }); - // To preserve order, wait until there are definitions for all tracks and then add - // them sequentially. - $.when.apply($, requests).then(function() { - // jQuery always returns an Array for arguments, so need to look at first element - // to determine whether multiple requests were made and consequently how to - // map arguments to track definitions. - var track_defs = (arguments[0] instanceof Array ? - $.map(arguments, function(arg) { return arg[0]; }) : - [ arguments[0] ] - ); - for (var i= 0; i < track_defs.length; i++) { - view.add_drawable( object_from_template(track_defs[i], view) ); - } - }); - hide_modal(); - } - } - ); - } - }); - }; - + /** * Use a popup grid to bookmarks from a dataset. */ @@ -168,23 +118,22 @@ var browser_router; $(function() { // Create and initialize menu. - var - - buttons = new IconButtonCollection([ - new IconButton({icon_class: 'plus-button', title: 'Add tracks', on_click: function() { add_tracks(); } }), - new IconButton({icon_class: 'block--plus', title: 'Add group', on_click: function() { + var menu = create_icon_buttons_menu([ + { icon_class: 'plus-button', title: 'Add tracks', on_click: function() { + add_datasets(add_datasets_url, add_track_async_url, function(tracks) { + _.each(tracks, function(track) { + view.add_drawable( object_from_template(track, view) ); + }); + }); + } }, + { icon_class: 'block--plus', title: 'Add group', on_click: function() { view.add_drawable( new DrawableGroup(view, view, { name: "New Group" }) ); - } }), - /* - new IconButton({icon_class: 'toolbox', title: 'Use tools', on_click: function() { - console.log("toolbox!") - } }), - */ - new IconButton({icon_class: 'bookmarks', title: 'Bookmarks', on_click: function() { + } }, + { icon_class: 'bookmarks', title: 'Bookmarks', on_click: function() { // HACK -- use style to determine if panel is hidden and hide/show accordingly. parent.force_right_panel(($("div#right").css("right") == "0px" ? "hide" : "show")); - } }), - new IconButton({icon_class: 'disk--arrow', title: 'Save', on_click: function() { + } }, + { icon_class: 'disk--arrow', title: 'Save', on_click: function() { // Show saving dialog box show_modal("Saving...", "progress"); @@ -229,15 +178,11 @@ { "Close" : hide_modal } ); } }); - } }), - new IconButton({icon_class: 'cross-circle', title: 'Close', on_click: function() { + } }, + { icon_class: 'cross-circle', title: 'Close', on_click: function() { window.location = "${h.url_for( controller='visualization', action='list' )}"; - } }) - ]), - - menu = new IconButtonMenuView({ - collection: buttons - }); + } } + ]); menu.render(); menu.$el.attr("style", "float: right"); diff -r b129ae3fc0359f08b9f47ae33230249a4ce0975e -r 9765176c63f7ada3ee30a649ab3ef13396d9c84b templates/visualization/circos.mako --- a/templates/visualization/circos.mako +++ /dev/null @@ -1,39 +0,0 @@ -<%inherit file="/base.mako"/> - -<%def name="stylesheets()"> - ${parent.stylesheets()} -</%def> - -<%def name="javascripts()"> - ${parent.javascripts()} - - ${h.js( "libs/d3", "mvc/visualization" )} - - <script type="text/javascript"> - $(function() { - // -- Viz set up. -- - - var genome = new Genome(JSON.parse('${ h.to_json_string( genome ) }')), - dataset = new HistogramDataset(JSON.parse('${ h.to_json_string( dataset_summary ) }')), - circos = new CircosView({ - width: 600, - height: 600, - // Gap is difficult to set because it very dependent on chromosome size and organization. - total_gap: 2 * Math.PI * 0.5, - genome: genome, - dataset: dataset, - radius_start: 100, - dataset_arc_height: 50 - }); - - // -- Render viz. -- - - circos.render(); - $('body').append(circos.$el); - }); - </script> -</%def> - -<%def name="body()"> - <h1>Circos plot for '${dataset.name}'</h1> -</%def> diff -r b129ae3fc0359f08b9f47ae33230249a4ce0975e -r 9765176c63f7ada3ee30a649ab3ef13396d9c84b templates/visualization/circster.mako --- /dev/null +++ b/templates/visualization/circster.mako @@ -0,0 +1,97 @@ +<%inherit file="/webapps/galaxy/base_panels.mako"/> + +<%def name="init()"> +<% + self.has_left_panel=False + self.has_right_panel=False + self.active_view="visualization" + self.message_box_visible=False +%> +</%def> + +<%def name="stylesheets()"> + ${parent.stylesheets()} +</%def> + +<%def name="javascripts()"> + ${parent.javascripts()} + + ${h.js( "libs/d3", "mvc/visualization" )} + + <script type="text/javascript"> + $(function() { + // -- Visualization menu and set up. + var menu = create_icon_buttons_menu([ + { icon_class: 'plus-button', title: 'Add tracks', on_click: function() { add_tracks(); } }, + { icon_class: 'disk--arrow', title: 'Save', on_click: function() { + // Show saving dialog box + show_modal("Saving...", "progress"); + + $.ajax({ + url: "${h.url_for( action='save' )}", + type: "POST", + data: { + 'id': view.vis_id, + 'title': view.name, + 'dbkey': view.dbkey, + 'type': 'trackster', + 'config': JSON.stringify(payload) + }, + dataType: "json", + success: function(vis_info) { + hide_modal(); + view.vis_id = vis_info.vis_id; + view.has_changes = false; + + // Needed to set URL when first saving a visualization. + window.history.pushState({}, "", vis_info.url + window.location.hash); + }, + error: function() { + show_modal( "Could Not Save", "Could not save visualization. Please try again later.", + { "Close" : hide_modal } ); + } + }); + } }, + { icon_class: 'cross-circle', title: 'Close', on_click: function() { + window.location = "${h.url_for( controller='visualization', action='list' )}"; + } } + ]); + + menu.render(); + menu.$el.attr("style", "float: right"); + $("#center .unified-panel-header-inner").append(menu.$el); + // Manual tipsy config because default gravity is S and cannot be changed. + $(".menu-button").tipsy( {gravity: 'n'} ); + + // -- Viz set up. -- + + var genome = new Genome(JSON.parse('${ h.to_json_string( genome ) }')), + dataset = new HistogramDataset(JSON.parse('${ h.to_json_string( dataset_summary ) }')), + circster = new CircsterView({ + width: 600, + height: 600, + // Gap is difficult to set because it very dependent on chromosome size and organization. + total_gap: 2 * Math.PI * 0.5, + genome: genome, + dataset: dataset, + radius_start: 100, + dataset_arc_height: 50 + }); + + // -- Render viz. -- + + circster.render(); + $('#vis').append(circster.$el); + }); + </script> +</%def> + +<%def name="center_panel()"> + <div class="unified-panel-header" unselectable="on"> + <div class="unified-panel-header-inner"> + <div style="float:left;" id="title"></div> + </div> + <div style="clear: both"></div> + </div> + <div id="vis" class="unified-panel-body"></div> +</%def> Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.