define("mvc/workflow/workflow-globals",{}),define(["utils/utils","mvc/workflow/workflow-globals","mvc/workflow/workflow-manager","mvc/workflow/workflow-canvas","mvc/workflow/workflow-node","mvc/workflow/workflow-icons","mvc/workflow/workflow-forms","mvc/ui/ui-misc","utils/async-save-text","libs/toastr","ui/editable-text"],function(a,b,c,d,e,f,g,h,i){function j(a){var b=$("#galaxy_tools").contents();if(0===b.length&&(b=$(document),$(this).removeClass("search_active"),b.find(".toolTitle").removeClass("search_match"),b.find(".toolSectionBody").hide(),b.find(".toolTitle").show(),b.find(".toolPanelLabel").show(),b.find(".toolSectionWrapper").each(function(){"recently_used_wrapper"!==$(this).attr("id")?$(this).show():$(this).hasClass("user_pref_visible")&&$(this).show()}),b.find("#search-no-results").hide(),b.find("#search-spinner").hide(),a)){var c=b.find("#tool-search-query");c.val("search tools")}}return add_node_icon=function(a,b){var c=f[b];if(c){var d=$(' ').addClass(c);a.before(d)}},Backbone.View.extend({initialize:function(c){function e(){var a=$('

');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=$("