Files
galaxy/static/scripts/galaxy.pages.js
T

3 lines
11 KiB
JavaScript

"use strict";function init_galaxy_elts(e){$(".annotation",e._doc.body).each(function(){$(this).click(function(){var t=e._doc.createRange();t.selectNodeContents(this);var a=window.getSelection();a.removeAllRanges(),a.addRange(t)})})}function get_item_info(e){var t,a,i;switch(e){case CONTROLS.ITEM_HISTORY:t="History",a="Histories",i="history",item_class="History";break;case CONTROLS.ITEM_DATASET:t="Dataset",a="Datasets",i="dataset",item_class="HistoryDatasetAssociation";break;case CONTROLS.ITEM_WORKFLOW:t="Workflow",a="Workflows",i="workflow",item_class="StoredWorkflow";break;case CONTROLS.ITEM_PAGE:t="Page",a="Pages",i="page",item_class="Page";break;case CONTROLS.ITEM_VISUALIZATION:t="Visualization",a="Visualizations",i="visualization",item_class="Visualization"}var o="list_"+a.toLowerCase()+"_for_selection",l=list_objects_url.replace("LIST_ACTION",o);return{singular:t,plural:a,controller:i,iclass:item_class,list_ajax_url:l}}function make_item_importable(e,t,a){var i=set_accessible_url.replace("ITEM_CONTROLLER",e);$.ajax({type:"POST",url:i,data:{id:t,accessible:"True"},error:function(){alert("Making "+a+" accessible failed")}})}var CONTROLS={ITEM_HISTORY:"item_history",ITEM_DATASET:"item_dataset",ITEM_WORKFLOW:"item_workflow",ITEM_PAGE:"item_page",ITEM_VISUALIZATION:"item_visualization",DIALOG_HISTORY_LINK:"link_history",DIALOG_DATASET_LINK:"link_dataset",DIALOG_WORKFLOW_LINK:"link_workflow",DIALOG_PAGE_LINK:"link_page",DIALOG_VISUALIZATION_LINK:"link_visualization",DIALOG_EMBED_HISTORY:"embed_history",DIALOG_EMBED_DATASET:"embed_dataset",DIALOG_EMBED_WORKFLOW:"embed_workflow",DIALOG_EMBED_PAGE:"embed_page",DIALOG_EMBED_VISUALIZATION:"embed_visualization"};WYMeditor.editor.prototype.dialog=function(e,t,a){var i=this,o=i.uniqueStamp(),l=i.selected();if(e==WYMeditor.DIALOG_LINK){l&&($(i._options.hrefSelector).val($(l).attr(WYMeditor.HREF)),$(i._options.srcSelector).val($(l).attr(WYMeditor.SRC)),$(i._options.titleSelector).val($(l).attr(WYMeditor.TITLE)),$(i._options.altSelector).val($(l).attr(WYMeditor.ALT)));var s,r;l&&(void 0==(s=$(l).attr("href"))&&(s=""),void 0==(r=$(l).attr("title"))&&(r="")),show_modal("Create Link","<div><div><label id='link_attribute_label'>URL <span style='float: right; font-size: 90%'><a href='#' id='set_link_id'>Create in-page anchor</a></span></label><br><input type='text' class='wym_href' value='"+s+"' size='40' /></div><div><label>Title</label><br><input type='text' class='wym_title' value='"+r+"' size='40' /></div><div>",{"Make link":function(){var e=$(i._options.hrefSelector).val()||"",t=$(".wym_id").val()||"",a=$(i._options.titleSelector).val()||"";if(e||t){i._exec(WYMeditor.CREATE_LINK,o);var l=$("a[href="+o+"]",i._doc.body);l.attr(WYMeditor.HREF,e).attr(WYMeditor.TITLE,a).attr("id",t),0===l.text().indexOf("wym-")&&l.text(a)}hide_modal()},Cancel:function(){hide_modal()}},{},function(){$("#set_link_id").click(function(){$("#link_attribute_label").text("ID/Name");var e=$(".wym_href");e.addClass("wym_id").removeClass("wym_href"),l&&e.val($(l).attr("id")),$(this).remove()})})}if(e==WYMeditor.DIALOG_IMAGE)return i._selected_image&&($(i._options.dialogImageSelector+" "+i._options.srcSelector).val($(i._selected_image).attr(WYMeditor.SRC)),$(i._options.dialogImageSelector+" "+i._options.titleSelector).val($(i._selected_image).attr(WYMeditor.TITLE)),$(i._options.dialogImageSelector+" "+i._options.altSelector).val($(i._selected_image).attr(WYMeditor.ALT))),void show_modal("Image","<div class='row'><label>URL</label><br><input type='text' class='wym_src' value='' size='40' /></div><div class='row'><label>Alt text</label><br><input type='text' class='wym_alt' value='' size='40' /></div><div class='row'><label>Title</label><br><input type='text' class='wym_title' value='' size='40' /></div>",{Insert:function(){var e=$(i._options.srcSelector).val();e.length>0&&(i._exec(WYMeditor.INSERT_IMAGE,o),$("img[src$="+o+"]",i._doc.body).attr(WYMeditor.SRC,e).attr(WYMeditor.TITLE,$(i._options.titleSelector).val()).attr(WYMeditor.ALT,$(i._options.altSelector).val())),hide_modal()},Cancel:function(){hide_modal()}});if(e==WYMeditor.DIALOG_TABLE&&show_modal("Table","<div class='row'><label>Caption</label><br><input type='text' class='wym_caption' value='' size='40' /></div><div class='row'><label>Summary</label><br><input type='text' class='wym_summary' value='' size='40' /></div><div class='row'><label>Number Of Rows<br></label><input type='text' class='wym_rows' value='3' size='3' /></div><div class='row'><label>Number Of Cols<br></label><input type='text' class='wym_cols' value='2' size='3' /></div>",{Insert:function(){var e=$(i._options.rowsSelector).val(),t=$(i._options.colsSelector).val();if(e>0&&t>0){var a=i._doc.createElement(WYMeditor.TABLE),o=null,l=$(i._options.captionSelector).val();a.createCaption().innerHTML=l;for(var s=0;s<e;s++){o=a.insertRow(s);for(var r=0;r<t;r++)o.insertCell(r)}$(a).attr("summary",$(i._options.summarySelector).val());var n=$(i.findUp(i.container(),WYMeditor.MAIN_CONTAINERS)).get(0);n&&n.parentNode?$(n).after(a):$(i._doc.body).append(a)}hide_modal()},Cancel:function(){hide_modal()}}),e==CONTROLS.DIALOG_HISTORY_LINK||e==CONTROLS.DIALOG_DATASET_LINK||e==CONTROLS.DIALOG_WORKFLOW_LINK||e==CONTROLS.DIALOG_PAGE_LINK||e==CONTROLS.DIALOG_VISUALIZATION_LINK){switch(e){case CONTROLS.DIALOG_HISTORY_LINK:n=get_item_info(CONTROLS.ITEM_HISTORY);break;case CONTROLS.DIALOG_DATASET_LINK:n=get_item_info(CONTROLS.ITEM_DATASET);break;case CONTROLS.DIALOG_WORKFLOW_LINK:n=get_item_info(CONTROLS.ITEM_WORKFLOW);break;case CONTROLS.DIALOG_PAGE_LINK:n=get_item_info(CONTROLS.ITEM_PAGE);break;case CONTROLS.DIALOG_VISUALIZATION_LINK:n=get_item_info(CONTROLS.ITEM_VISUALIZATION)}require(["mvc/grid/grid-view"],function(e){var t=new e({url_base:n.list_ajax_url,dict_format:!0,embedded:!0});Galaxy.modal.show({title:"Insert Link to "+n.singular,body:$("<div/>").append(t.$el).append($("<div/>").append('<input id="make-importable" type="checkbox" checked/>').append("Make the selected "+n.plural.toLowerCase()+" accessible so that they can viewed by everyone.")),closing_events:!0,buttons:{Insert:function(){var e=!1;null!=$("#make-importable:checked").val()&&(e=!0);new Array;t.$("input[name=id]:checked").each(function(){var t=$(this).val();e&&make_item_importable(n.controller,t,n.singular);var a=(get_name_and_link_url+t).replace("ITEM_CONTROLLER",n.controller);$.getJSON(a,function(e){i._exec(WYMeditor.CREATE_LINK,o);var a=$("a[href="+o+"]",i._doc.body).text();""==a||a==o?i.insert("<a href='"+e.link+"'>"+n.singular+" '"+e.name+"'</a>"):$("a[href="+o+"]",i._doc.body).attr(WYMeditor.HREF,e.link).attr(WYMeditor.TITLE,n.singular+t)})}),Galaxy.modal.hide()},Close:function(){Galaxy.modal.hide()}}})})}if(e==CONTROLS.DIALOG_EMBED_HISTORY||e==CONTROLS.DIALOG_EMBED_DATASET||e==CONTROLS.DIALOG_EMBED_WORKFLOW||e==CONTROLS.DIALOG_EMBED_PAGE||e==CONTROLS.DIALOG_EMBED_VISUALIZATION){var n;switch(e){case CONTROLS.DIALOG_EMBED_HISTORY:n=get_item_info(CONTROLS.ITEM_HISTORY);break;case CONTROLS.DIALOG_EMBED_DATASET:n=get_item_info(CONTROLS.ITEM_DATASET);break;case CONTROLS.DIALOG_EMBED_WORKFLOW:n=get_item_info(CONTROLS.ITEM_WORKFLOW);break;case CONTROLS.DIALOG_EMBED_PAGE:n=get_item_info(CONTROLS.ITEM_PAGE);break;case CONTROLS.DIALOG_EMBED_VISUALIZATION:n=get_item_info(CONTROLS.ITEM_VISUALIZATION)}require(["mvc/grid/grid-view"],function(e){var t=new e({url_base:n.list_ajax_url,dict_format:!0,embedded:!0});Galaxy.modal.show({title:"Insert Link to "+n.singular,body:$("<div/>").append(t.$el).append($("<div/>").append('<input id="make-importable" type="checkbox" checked/>').append("Make the selected "+n.plural.toLowerCase()+" accessible so that they can viewed by everyone.")),closing_events:!0,buttons:{Embed:function(){var e=!1;null!=$("#make-importable:checked").val()&&(e=!0),t.$("input[name=id]:checked").each(function(){var t=$(this).val(),a=$("label[for='"+t+"']:first").text();e&&make_item_importable(n.controller,t,n.singular);var o=["<div id='",n.iclass+"-"+t,"' class='embedded-item ",n.singular.toLowerCase()," placeholder'>","<p class='title'>","Embedded Galaxy ",n.singular," '",a,"'","</p>","<p class='content'>","[Do not edit this block; Galaxy will fill it in with the annotated ",n.singular.toLowerCase()," when it is displayed.]","</p>","</div>"].join("");i.insert(o)}),Galaxy.modal.hide()},Close:function(){Galaxy.modal.hide()}}})})}},$(function(){$(document).ajaxError(function(e,t){var a=t.responseText||t.statusText||"Could not connect to server";return show_modal("Server error",a,{"Ignore error":hide_modal}),!1}),$("[name=page_content]").wymeditor({skin:"galaxy",basePath:editor_base_path,iframeBasePath:iframe_base_path,boxHtml:"<table class='wym_box' width='100%' height='100%'><tr><td><div class='wym_area_top'>"+WYMeditor.TOOLS+"</div></td></tr><tr height='100%'><td><div class='wym_area_main' style='height: 100%;'>"+WYMeditor.IFRAME+WYMeditor.STATUS+"</div></div></td></tr></table>",toolsItems:[{name:"Bold",title:"Strong",css:"wym_tools_strong"},{name:"Italic",title:"Emphasis",css:"wym_tools_emphasis"},{name:"Superscript",title:"Superscript",css:"wym_tools_superscript"},{name:"Subscript",title:"Subscript",css:"wym_tools_subscript"},{name:"InsertOrderedList",title:"Ordered_List",css:"wym_tools_ordered_list"},{name:"InsertUnorderedList",title:"Unordered_List",css:"wym_tools_unordered_list"},{name:"Indent",title:"Indent",css:"wym_tools_indent"},{name:"Outdent",title:"Outdent",css:"wym_tools_outdent"},{name:"Undo",title:"Undo",css:"wym_tools_undo"},{name:"Redo",title:"Redo",css:"wym_tools_redo"},{name:"CreateLink",title:"Link",css:"wym_tools_link"},{name:"Unlink",title:"Unlink",css:"wym_tools_unlink"},{name:"InsertImage",title:"Image",css:"wym_tools_image"},{name:"InsertTable",title:"Table",css:"wym_tools_table"}]});var e=$.wymeditors(0),t=function(t){show_modal("Saving page","progress"),$.ajax({url:save_url,type:"POST",data:{id:page_id,content:e.xhtml(),annotations:JSON.stringify(new Object),_:"true"},success:function(){t()}})};$("#save-button").click(function(){t(function(){hide_modal()})}),$("#close-button").click(function(){window.document.location=page_list_url});var a=$("<div class='galaxy-page-editor-button'><a id='insert-galaxy-link' class='action-button popup' href='#'>Paragraph type</a></div>");$(".wym_area_top").append(a);var i={};$.each(e._options.containersItems,function(t,a){var o=a.name;i[a.title.replace("_"," ")]=function(){e.container(o)}}),make_popupmenu(a,i);var o=$("<div><a id='insert-galaxy-link' class='action-button popup' href='#'>Insert Link to Galaxy Object</a></div>").addClass("galaxy-page-editor-button");$(".wym_area_top").append(o),make_popupmenu(o,{"Insert History Link":function(){e.dialog(CONTROLS.DIALOG_HISTORY_LINK)},"Insert Dataset Link":function(){e.dialog(CONTROLS.DIALOG_DATASET_LINK)},"Insert Workflow Link":function(){e.dialog(CONTROLS.DIALOG_WORKFLOW_LINK)},"Insert Page Link":function(){e.dialog(CONTROLS.DIALOG_PAGE_LINK)},"Insert Visualization Link":function(){e.dialog(CONTROLS.DIALOG_VISUALIZATION_LINK)}});var l=$("<div><a id='embed-galaxy-object' class='action-button popup' href='#'>Embed Galaxy Object</a></div>").addClass("galaxy-page-editor-button");$(".wym_area_top").append(l),make_popupmenu(l,{"Embed History":function(){e.dialog(CONTROLS.DIALOG_EMBED_HISTORY)},"Embed Dataset":function(){e.dialog(CONTROLS.DIALOG_EMBED_DATASET)},"Embed Workflow":function(){e.dialog(CONTROLS.DIALOG_EMBED_WORKFLOW)},"Embed Visualization":function(){e.dialog(CONTROLS.DIALOG_EMBED_VISUALIZATION)}})});
//# sourceMappingURL=../maps/galaxy.pages.js.map