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/tool/tool-form-workflow","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 NODE_ICONS={tool:"fa-wrench",data_input:"fa-file-o",data_collection_input:"fa-folder-o",subworkflow:"fa-sitemap fa-rotate-270",pause:"fa-pause"},add_node_icon=function(a,b){var c=NODE_ICONS[b];if(c){var d=$(' ').addClass(c);a.before(d)}},EditorFormView=Backbone.View.extend({initialize:function(b){this.options=a.merge(b,{});var c=$("
"),d=b.workflowView,e=b.node;if(b.html&&c.html(b.html),this.setElement(c),e&&"no-node"!=e.id){c.find("table:first").after(this._genericStepAttributesTemplate(e));var f=e.type;add_node_icon(c.find(".portlet-title-text"),f);var g=c.find(".portlet-title-text");g.data("last-value",g.text()),g.make_text_editable({on_finish:function(a){var b=g.data("last-value");if(a!=b){var f=d.workflow;f.attemptUpdateNodeLabel(e,a)?(c.find("input[name='label']").val(a),g.data("last-value",a),c.find("form").submit(),""==a&&g.text(e.name)):(i.warning("Step label "+a+" already exists, cannot update label."),g.text(b))}}}),c.find("form").length>0&&c.find("form").ajaxForm({type:"POST",dataType:"json",success:function(a){d.workflow.active_form_has_changes=!1,e.update_field_data(a),d.showWorkflowParameters()},beforeSubmit:function(a){a.push({name:"content_id",value:e.content_id}),a.push({name:"tool_state",value:e.tool_state}),a.push({name:"_",value:"true"})}}).each(function(){var a=this;$(this).find('select[refresh_on_change="true"]').change(function(){$(a).submit()}),$(this).find('input[refresh_on_change="true"]').change(function(){$(a).submit()}),$(this).find("input, textarea, select").each(function(){$(this).bind("focus click",function(){d.workflow.active_form_has_changes=!0})})})}},_genericStepAttributesTemplate:function(a){return'

Edit Step Attributes
'+this._annotationTemplate(a)+"

"},_annotationTemplate:function(a){return'
Add an annotation or notes to this step; annotations are available when a workflow is viewed.
'}}),Backbone.View.extend({initialize:function(a){function c(){i.workflow.layout(),i.workflow.fit_canvas_to_nodes(),i.scroll_to_nodes(),i.canvas_manager.draw_overview()}function e(){i.workflow.clear_active_node(),$(".right-content").hide(),$("#edit-attributes").show()}function f(){$.jStorage.set("overview-off",!1),$("#overview-border").css("right","0px"),$("#close-viewport").css("background-position","0px 0px")}function g(){$.jStorage.set("overview-off",!0),$("#overview-border").css("right","20000px"),$("#close-viewport").css("background-position","12px 0px")}var i=b.app=this;this.options=a,this.urls=a&&a.urls||{},this.active_ajax_call=!1;var k=function(){i.workflow.check_changes_in_active_form(),workflow&&i.workflow.has_changes?(do_close=function(){window.onbeforeunload=void 0,window.document.location=i.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(){l(null,do_close)}},{"Don't Save":do_close})):window.document.location=i.urls.workflow_index},l=function(a,b){if(show_message("Saving workflow","progress"),i.workflow.check_changes_in_active_form(),!i.workflow.has_changes)return hide_modal(),void(b&&b());i.workflow.rectify_workflow_outputs();var c=function(a){$.ajax({url:i.urls.save_workflow,type:"POST",data:{id:i.options.id,workflow_data:function(){return JSON.stringify(i.workflow.to_simple())},_:"true"},dataType:"json",success:function(b){var c=$("
").text(b.message);if(b.errors){c.addClass("warningmark");var d=$("