');window.show_modal("Save As a New Workflow",a,{OK:function(){var a=$("#workflow_rename").val().length>0?$("#workflow_rename").val():"SavedAs_"+k.workflow.name,b=$("#wf_annotation").val().length>0?$("#wf_annotation").val():"";$.ajax({url:k.urls.workflow_save_as,type:"POST",data:{workflow_name:a,workflow_annotation:b,workflow_data:function(){return JSON.stringify(k.workflow.to_simple())}}}).done(function(a){window.onbeforeunload=void 0,window.location=Galaxy.root+"workflow/editor?id="+a,hide_modal()}).fail(function(){hide_modal(),alert("Saving this workflow failed. Please contact this site's administrator.")})},Cancel:hide_modal})}function f(){k.workflow.layout(),k.workflow.fit_canvas_to_nodes(),k.scroll_to_nodes(),k.canvas_manager.draw_overview()}function g(){$.jStorage.set("overview-off",!1),$("#overview-border").css("right","0px"),$("#close-viewport").css("background-position","0px 0px")}function h(){$.jStorage.set("overview-off",!0),$("#overview-border").css("right","20000px"),$("#close-viewport").css("background-position","12px 0px")}var k=b.app=this;this.options=c,this.urls=c&&c.urls||{};var l=function(){if(k.workflow.check_changes_in_active_form(),workflow&&k.workflow.has_changes){var a=function(){window.onbeforeunload=void 0,window.document.location=k.urls.workflow_index};window.show_modal("Close workflow editor","There are unsaved changes to your workflow which will be lost.",{Cancel:hide_modal,"Save Changes":function(){m(null,a)}},{"Don't Save":a})}else window.document.location=k.urls.workflow_index},m=function(b,c){return show_message("Saving workflow","progress"),k.workflow.check_changes_in_active_form(),k.workflow.has_changes?(k.workflow.rectify_workflow_outputs(),void a.request({url:Galaxy.root+"api/workflows/"+k.options.id,type:"PUT",data:{workflow:k.workflow.to_simple()},success:function(a){var b=$("").text(a.message);if(a.errors){b.addClass("warningmark");var d=$("
")}),b?window.show_modal("Issues loading this workflow","Please review the following issues, possibly resulting from tool upgrades or changes.
"+b+"
",{Continue:hide_modal}):hide_modal(),k.showWorkflowParameters()},beforeSubmit:function(){show_message("Loading workflow","progress")}}),window.make_popupmenu&&make_popupmenu($("#workflow-options-button"),{Save:m,"Save As":e,Run:function(){window.location=Galaxy.root+"workflow/run?id="+k.options.id},"Edit Attributes":function(){k.workflow.clear_active_node()},"Auto Re-layout":f,Close:l});var n=$.jStorage.get("overview-size");void 0!==n&&$("#overview-border").css({width:n,height:n}),$.jStorage.get("overview-off")?h():g(),$("#overview-border").bind("dragend",function(a,b){var c=$(this).offsetParent(),d=c.offset(),e=Math.max(c.width()-(b.offsetX-d.left),c.height()-(b.offsetY-d.top));$.jStorage.set("overview-size",e+"px")}),$("#close-viewport").click(function(){"0px"===$("#overview-border").css("right")?h():g()}),window.onbeforeunload=function(){return workflow&&k.workflow.has_changes?"There are unsaved changes to your workflow which will be lost.":void 0},this.options.workflows.length>0&&$("#left").find(".toolMenu").append(this._buildToolPanelWorkflows()),$("div.toolSectionBody").hide(),$("div.toolSectionTitle > span").wrap("");var o=null;$("div.toolSectionTitle").each(function(){var a=$(this).next("div.toolSectionBody");$(this).click(function(){a.is(":hidden")?(o&&o.slideUp("fast"),o=a,a.slideDown("fast")):(a.slideUp("fast"),o=null)})}),i("workflow-name","workflow-name",k.urls.rename_async,"new_name"),$("#workflow-tag").click(function(){return $(".tag-area").click(),!1}),i("workflow-annotation","workflow-annotation",k.urls.annotate_async,"new_annotation",25,!0,4)},_buildToolPanelWorkflows:function(){var a=this,b=$('
');return _.each(this.options.workflows,function(c){if(c.id!==a.options.id){var d=new h.ButtonIcon({icon:"fa fa-copy",cls:"ui-button-icon-plain",tooltip:"Copy and insert individual steps",onclick:function(){c.step_count<2?a.copy_into_workflow(c.id,c.name):Galaxy.modal.show({title:"Warning",body:"This will copy "+c.step_count+" new steps into your workflow.",buttons:{Cancel:function(){Galaxy.modal.hide()},Copy:function(){Galaxy.modal.hide(),a.copy_into_workflow(c.id,c.name)}}})}}),e=$("").attr("href","#").html(c.name).on("click",function(){a.add_node_for_subworkflow(c.latest_id,c.name)});b.find(".toolSectionBg").append($("").addClass("toolTitle").append(e).append(d.$el))}}),b},copy_into_workflow:function(a){var b=this;this._workflowLoadAjax(a,{success:function(a){b.workflow.from_simple(a,!1);var c="";$.each(a.upgrade_messages,function(a,d){c+="
"}),c?window.show_modal("Subworkflow embedded with changes","Problems were encountered loading this workflow (possibly a result of tool upgrades). Please review the following parameters and then save.
"}),d.html(f),e.show()):(d.html(f),e.hide())},showAttributes:function(){$(".right-content").hide(),$("#edit-attributes").show()},showForm:function(a,b){var c="right-content",d=c+"-"+b.id,e=$("#"+c);if(a&&0==e.find("#"+d).length){var h=$('');if(a.node=b,a.workflow=this.workflow,a.datatypes=this.datatypes,a.icon=f[b.type],a.cls="ui-portlet-narrow",b){var i="tool"==b.type?"Tool":"Default";h.append(new g[i](a).form.$el),e.append(h)}else Galaxy.emit.debug("workflow-view::initialize()","Node not found in workflow.")}$("."+c).hide(),e.find("#"+d).show(),e.show(),e.scrollTop()},isSubType:function(a,b){return a=this.ext_to_type[a],b=this.ext_to_type[b],this.type_to_type[a]&&b in this.type_to_type[a]},prebuildNode:function(a,b,c){var d=this,f=$(""),g=$("