2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/changeset/5a61f5123386/ changeset: 5a61f5123386 user: james_taylor date: 2012-09-17 22:24:13 summary: trackster: moving more stuff out of mako into javascript affected #: 2 files diff -r 6c0bb542d2e0cbda209e473db9d77a7076614f0d -r 5a61f51233861c6f7f4be41c5fd2de94d468ea61 static/scripts/viz/trackster_ui.js --- a/static/scripts/viz/trackster_ui.js +++ b/static/scripts/viz/trackster_ui.js @@ -12,6 +12,90 @@ this.baseURL = baseURL; }, + + /** + * Create button menu + */ + createButtonMenu: 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( trackster_ui.object_from_template(track, view, view) ); + }); + }); + } }, + { icon_class: 'block--plus', title: 'Add group', on_click: function() { + view.add_drawable( new tracks.DrawableGroup(view, view, { name: "New Group" }) ); + } }, + { 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")); + } }, + { + icon_class: 'globe', + title: 'Circster', + on_click: function() { + // Add viz id dynamically so that newly saved visualizations work as well. + window.location = "${h.url_for( controller='visualization', action='circster' )}?id=" + view.vis_id; + } + }, + { icon_class: 'disk--arrow', title: 'Save', on_click: function() { + // Show saving dialog box + show_modal("Saving...", "progress"); + + // Save bookmarks. + var bookmarks = []; + $(".bookmark").each(function() { + bookmarks.push({ + position: $(this).children(".position").text(), + annotation: $(this).children(".annotation").text() + }); + }); + + // FIXME: give unique IDs to Drawables and save overview as ID. + var overview_track_name = (view.overview_drawable ? view.overview_drawable.name : null), + viz_config = { + 'id': view.vis_id, + 'title': view.name, + 'dbkey': view.dbkey, + 'type': 'trackster', + 'datasets': view.to_dict(), + 'viewport': { 'chrom': view.chrom, 'start': view.low , 'end': view.high, 'overview': overview_track_name }, + 'bookmarks': bookmarks + }; + + $.ajax({ + url: galaxy_paths.get("visualization_url"), + type: "POST", + dataType: "json", + data: { + vis_json: JSON.stringify(viz_config) + } + }).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' )}"; + } } + ], + { + tooltip_config: { placement: 'bottom' } + }); + this.buttonMenu = menu; + return menu; + }, + /** * Use a popup to select a dataset of create bookmarks from */ diff -r 6c0bb542d2e0cbda209e473db9d77a7076614f0d -r 5a61f51233861c6f7f4be41c5fd2de94d468ea61 templates/tracks/browser.mako --- a/templates/tracks/browser.mako +++ b/templates/tracks/browser.mako @@ -61,85 +61,12 @@ var browser_router; $(function() { - // Create and initialize menu. - 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( trackster_ui.object_from_template(track, view, view) ); - }); - }); - } }, - { icon_class: 'block--plus', title: 'Add group', on_click: function() { - view.add_drawable( new tracks.DrawableGroup(view, view, { name: "New Group" }) ); - } }, - { 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")); - } }, - { - icon_class: 'globe', - title: 'Circster', - on_click: function() { - // Add viz id dynamically so that newly saved visualizations work as well. - window.location = "${h.url_for( controller='visualization', action='circster' )}?id=" + view.vis_id; - } - }, - { icon_class: 'disk--arrow', title: 'Save', on_click: function() { - // Show saving dialog box - show_modal("Saving...", "progress"); - - // Save bookmarks. - var bookmarks = []; - $(".bookmark").each(function() { - bookmarks.push({ - position: $(this).children(".position").text(), - annotation: $(this).children(".annotation").text() - }); - }); - // FIXME: give unique IDs to Drawables and save overview as ID. - var overview_track_name = (view.overview_drawable ? view.overview_drawable.name : null), - viz_config = { - 'id': view.vis_id, - 'title': view.name, - 'dbkey': view.dbkey, - 'type': 'trackster', - 'datasets': view.to_dict(), - 'viewport': { 'chrom': view.chrom, 'start': view.low , 'end': view.high, 'overview': overview_track_name }, - 'bookmarks': bookmarks - }; + ui.createButtonMenu(); - $.ajax({ - url: galaxy_paths.get("visualization_url"), - type: "POST", - dataType: "json", - data: { - vis_json: JSON.stringify(viz_config) - } - }).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' )}"; - } } - ], - { - tooltip_config: { placement: 'bottom' } - }); - - menu.$el.attr("style", "float: right"); - $("#center .unified-panel-header-inner").append(menu.$el); + // Attach the button menu to the panel header and float it left + ui.buttonMenu.$el.attr("style", "float: right"); + $("#center .unified-panel-header-inner").append(ui.buttonMenu.$el); // Hide bookmarks by default right now. parent.force_right_panel("hide"); @@ -159,7 +86,7 @@ JSON.parse('${ h.to_json_string( config['bookmarks'] ) }'), true ); - init_editor(); + ui.init_editor(); set_up_router({view: view}); %else: var continue_fn = function() { @@ -169,7 +96,7 @@ dbkey: $("#new-dbkey").val() } ); view.editor = true; - init_editor(); + ui.init_editor(); set_up_router({view: view}); hide_modal(); }; https://bitbucket.org/galaxy/galaxy-central/changeset/65ecf4e0ed28/ changeset: 65ecf4e0ed28 user: james_taylor date: 2012-09-17 22:24:27 summary: pack affected #: 1 file diff -r 5a61f51233861c6f7f4be41c5fd2de94d468ea61 -r 65ecf4e0ed28eaa2f3e64495ab800aa7c9779a54 static/scripts/packed/viz/trackster_ui.js --- a/static/scripts/packed/viz/trackster_ui.js +++ b/static/scripts/packed/viz/trackster_ui.js @@ -1,1 +1,1 @@ -define(["base","libs/underscore","viz/trackster/slotting","viz/trackster/painters","viz/trackster/tracks"],function(f,c,g,d,b){var a=b.object_from_template;var e=f.Base.extend({initialize:function(h){this.baseURL=h},add_bookmarks:function(){var h=this.baseURL;show_modal("Select dataset for new bookmarks","progress");$.ajax({url:this.baseURL+"/visualization/list_histories",data:{"f-dbkey":view.dbkey},error:function(){alert("Grid failed")},success:function(j){show_modal("Select dataset for new bookmarks",j,{Cancel:function(){hide_modal()},Insert:function(){$("input[name=id]:checked,input[name=ldda_ids]:checked").first().each(function(){var k,l=$(this).val();if($(this).attr("name")==="id"){k={hda_id:l}}else{k={ldda_id:l}}$.ajax({url:this.baseURL+"/visualization/bookmarks_from_dataset",data:k,dataType:"json",}).then(function(m){for(i=0;i<m.data.length;i++){var n=m.data[i];add_bookmark(n[0],n[1])}})});hide_modal()}})}})},add_bookmark:function(m,k,h){var o=$("#bookmarks-container"),q=$("<div/>").addClass("bookmark").appendTo(o);var r=$("<div/>").addClass("position").appendTo(q),n=$("<a href=''/>").text(m).appendTo(r).click(function(){view.go_to(m);return false}),l=$("<div/>").text(k).appendTo(q);if(h){var p=$("<div/>").addClass("delete-icon-container").prependTo(q).click(function(){q.slideUp("fast");q.remove();view.has_changes=true;return false}),j=$("<a href=''/>").addClass("icon-button delete").appendTo(p);l.make_text_editable({num_rows:3,use_textarea:true,help_text:"Edit bookmark note"}).addClass("annotation")}view.has_changes=true;return q},create_visualization:function(l,h,k,m,j){view=new b.View(l);view.editor=true;$.when(view.load_chroms_deferred).then(function(){if(h){var v=h.chrom,n=h.start,s=h.end,p=h.overview;if(v&&(n!==undefined)&&s){view.change_chrom(v,n,s)}}if(k){var q,o,r;for(var t=0;t<k.length;t++){view.add_drawable(a(k[t],view,view))}}view.update_intro_div();var w;for(var t=0;t<view.drawables.length;t++){if(view.drawables[t].name===p){view.set_overview(view.drawables[t]);break}}if(m){var u;for(var t=0;t<m.length;t++){u=m[t];add_bookmark(u.position,u.annotation,j)}}view.has_changes=false});return view},init_keyboard_nav:function(h){$(document).keydown(function(j){if($(j.srcElement).is(":input")){return}switch(j.which){case 37:h.move_fraction(0.25);break;case 38:var k=Math.round(h.viewport_container.height()/15);h.viewport_container.scrollTop(h.viewport_container.scrollTop()-20);break;case 39:h.move_fraction(-0.25);break;case 40:var k=Math.round(h.viewport_container.height()/15);h.viewport_container.scrollTop(h.viewport_container.scrollTop()+20);break}})}});return{object_from_template:a,TracksterUI:e}}); \ No newline at end of file +define(["base","libs/underscore","viz/trackster/slotting","viz/trackster/painters","viz/trackster/tracks"],function(f,c,g,d,b){var a=b.object_from_template;var e=f.Base.extend({initialize:function(h){this.baseURL=h},createButtonMenu:function(){var h=create_icon_buttons_menu([{icon_class:"plus-button",title:"Add tracks",on_click:function(){add_datasets(add_datasets_url,add_track_async_url,function(j){c.each(j,function(k){view.add_drawable(trackster_ui.object_from_template(k,view,view))})})}},{icon_class:"block--plus",title:"Add group",on_click:function(){view.add_drawable(new b.DrawableGroup(view,view,{name:"New Group"}))}},{icon_class:"bookmarks",title:"Bookmarks",on_click:function(){parent.force_right_panel(($("div#right").css("right")=="0px"?"hide":"show"))}},{icon_class:"globe",title:"Circster",on_click:function(){window.location="${h.url_for( controller='visualization', action='circster' )}?id="+view.vis_id}},{icon_class:"disk--arrow",title:"Save",on_click:function(){show_modal("Saving...","progress");var j=[];$(".bookmark").each(function(){j.push({position:$(this).children(".position").text(),annotation:$(this).children(".annotation").text()})});var k=(view.overview_drawable?view.overview_drawable.name:null),l={id:view.vis_id,title:view.name,dbkey:view.dbkey,type:"trackster",datasets:view.to_dict(),viewport:{chrom:view.chrom,start:view.low,end:view.high,overview:k},bookmarks:j};$.ajax({url:galaxy_paths.get("visualization_url"),type:"POST",dataType:"json",data:{vis_json:JSON.stringify(l)}}).success(function(m){hide_modal();view.vis_id=m.vis_id;view.has_changes=false;window.history.pushState({},"",m.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' )}"}}],{tooltip_config:{placement:"bottom"}});this.buttonMenu=h;return h},add_bookmarks:function(){var h=this.baseURL;show_modal("Select dataset for new bookmarks","progress");$.ajax({url:this.baseURL+"/visualization/list_histories",data:{"f-dbkey":view.dbkey},error:function(){alert("Grid failed")},success:function(j){show_modal("Select dataset for new bookmarks",j,{Cancel:function(){hide_modal()},Insert:function(){$("input[name=id]:checked,input[name=ldda_ids]:checked").first().each(function(){var k,l=$(this).val();if($(this).attr("name")==="id"){k={hda_id:l}}else{k={ldda_id:l}}$.ajax({url:this.baseURL+"/visualization/bookmarks_from_dataset",data:k,dataType:"json",}).then(function(m){for(i=0;i<m.data.length;i++){var n=m.data[i];add_bookmark(n[0],n[1])}})});hide_modal()}})}})},add_bookmark:function(m,k,h){var o=$("#bookmarks-container"),q=$("<div/>").addClass("bookmark").appendTo(o);var r=$("<div/>").addClass("position").appendTo(q),n=$("<a href=''/>").text(m).appendTo(r).click(function(){view.go_to(m);return false}),l=$("<div/>").text(k).appendTo(q);if(h){var p=$("<div/>").addClass("delete-icon-container").prependTo(q).click(function(){q.slideUp("fast");q.remove();view.has_changes=true;return false}),j=$("<a href=''/>").addClass("icon-button delete").appendTo(p);l.make_text_editable({num_rows:3,use_textarea:true,help_text:"Edit bookmark note"}).addClass("annotation")}view.has_changes=true;return q},create_visualization:function(l,h,k,m,j){view=new b.View(l);view.editor=true;$.when(view.load_chroms_deferred).then(function(){if(h){var v=h.chrom,n=h.start,s=h.end,p=h.overview;if(v&&(n!==undefined)&&s){view.change_chrom(v,n,s)}}if(k){var q,o,r;for(var t=0;t<k.length;t++){view.add_drawable(a(k[t],view,view))}}view.update_intro_div();var w;for(var t=0;t<view.drawables.length;t++){if(view.drawables[t].name===p){view.set_overview(view.drawables[t]);break}}if(m){var u;for(var t=0;t<m.length;t++){u=m[t];add_bookmark(u.position,u.annotation,j)}}view.has_changes=false});return view},init_keyboard_nav:function(h){$(document).keydown(function(j){if($(j.srcElement).is(":input")){return}switch(j.which){case 37:h.move_fraction(0.25);break;case 38:var k=Math.round(h.viewport_container.height()/15);h.viewport_container.scrollTop(h.viewport_container.scrollTop()-20);break;case 39:h.move_fraction(-0.25);break;case 40:var k=Math.round(h.viewport_container.height()/15);h.viewport_container.scrollTop(h.viewport_container.scrollTop()+20);break}})}});return{object_from_template:a,TracksterUI:e}}); \ No newline at end of file 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.