",
{
"Insert": function() {
var iRows = $(wym._options.rowsSelector).val();
var iCols = $(wym._options.colsSelector).val();
if(iRows > 0 && iCols > 0) {
var table = wym._doc.createElement(WYMeditor.TABLE);
var newRow = null;
var newCol = null;
var sCaption = $(wym._options.captionSelector).val();
//we create the caption
var newCaption = table.createCaption();
newCaption.innerHTML = sCaption;
//we create the rows and cells
for(x=0; x" +
"Make the selected " + item_info.plural.toLowerCase() + " accessible so that they can viewed by everyone.
"
,
{
"Insert": function()
{
// Make selected items accessible (importable) ?
var make_importable = false;
if ( $('#make-importable:checked').val() !== null )
make_importable = true;
// Insert links to history for each checked item.
var item_ids = new Array();
$('input[name=id]:checked').each(function() {
var item_id = $(this).val();
// Make item importable?
if (make_importable)
make_item_importable(item_info.controller, item_id, item_info.singular);
// Insert link(s) to item(s). This is done by getting item info and then manipulating wym.
url_template = get_name_and_link_url + item_id;
ajax_url = url_template.replace( "ITEM_CONTROLLER", item_info.controller);
$.getJSON( ajax_url, function( returned_item_info ) {
// Get link text.
wym._exec(WYMeditor.CREATE_LINK, sStamp);
var link_text = $("a[href=" + sStamp + "]", wym._doc.body).text();
// Insert link: need to do different actions depending on link text.
if (
link_text == "" // Firefox.
||
link_text == sStamp // Safari
)
{
// User selected no text; create link from scratch and use default text.
wym.insert("" + item_info.singular + " '" + returned_item_info.name + "'");
}
else
{
// Link created from selected text; add href and title.
$("a[href=" + sStamp + "]", wym._doc.body).attr(WYMeditor.HREF, returned_item_info.link).attr(WYMeditor.TITLE, item_info.singular + item_id);
}
});
});
hide_modal();
},
"Cancel": function()
{
hide_modal();
}
}
);
}
});
}
// EMBED GALAXY OBJECT DIALOGS
if ( dialogType == Galaxy.DIALOG_EMBED_HISTORY || dialogType == Galaxy.DIALOG_EMBED_DATASET || dialogType == Galaxy.DIALOG_EMBED_WORKFLOW || dialogType == Galaxy.DIALOG_EMBED_PAGE || dialogType == Galaxy.DIALOG_EMBED_VISUALIZATION ) {
// Based on item type, set useful vars.
var item_info;
switch(dialogType)
{
case(Galaxy.DIALOG_EMBED_HISTORY):
item_info = get_item_info(Galaxy.ITEM_HISTORY);
break;
case(Galaxy.DIALOG_EMBED_DATASET):
item_info = get_item_info(Galaxy.ITEM_DATASET);
break;
case(Galaxy.DIALOG_EMBED_WORKFLOW):
item_info = get_item_info(Galaxy.ITEM_WORKFLOW);
break;
case(Galaxy.DIALOG_EMBED_PAGE):
item_info = get_item_info(Galaxy.ITEM_PAGE);
break;
case(Galaxy.DIALOG_EMBED_VISUALIZATION):
item_info = get_item_info(Galaxy.ITEM_VISUALIZATION);
break;
}
$.ajax(
{
url: item_info.list_ajax_url,
data: {},
error: function() { alert( "Failed to list " + item_info.plural.toLowerCase() + " for selection"); },
success: function(list_html)
{
// Can make histories, workflows importable; cannot make datasets importable.
if (dialogType == Galaxy.DIALOG_EMBED_HISTORY || dialogType == Galaxy.DIALOG_EMBED_WORKFLOW
|| dialogType == Galaxy.DIALOG_EMBED_VISUALIZATION)
list_html = list_html + "
" +
"Make the selected " + item_info.plural.toLowerCase() + " accessible so that they can viewed by everyone.
";
show_modal(
"Embed " + item_info.plural,
list_html,
{
"Embed": function()
{
// Make selected items accessible (importable) ?
var make_importable = false;
if ( $('#make-importable:checked').val() != null )
make_importable = true;
$('input[name=id]:checked').each(function() {
// Get item ID and name.
var item_id = $(this).val();
// Use ':first' because there are many labels in table; the first one is the item name.
var item_name = $("label[for='" + item_id + "']:first").text();
if (make_importable)
make_item_importable(item_info.controller, item_id, item_info.singular);
// Embedded item HTML; item class is embedded in div container classes; this is necessary because the editor strips
// all non-standard attributes when it returns its content (e.g. it will not return an element attribute of the form
// item_class='History').
var item_elt_id = item_info.iclass + "-" + item_id;
var item_embed_html = [
"
",
"[Do not edit this block; Galaxy will fill it in with the annotated ",
item_info.singular.toLowerCase(), " when it is displayed.]",
"
",
"
" ].join( '' );
// Insert embedded item into document.
//wym.insert(" "); // Needed to prevent insertion from occurring in child element in webkit browsers.
wym.insert(item_embed_html);
// TODO: can we fix this?
// Due to oddities of wym.insert() [likely due to inserting a
and/or a complete paragraph], an
// empty paragraph (or two!) may be included either before an embedded item. Remove these paragraphs.
//$("#" + item_elt_id, wym._doc.body).each( function() {
// // Remove previous empty paragraphs.
// var removing = true;
// while (removing)
// {
// var prev_elt = $(this).prev();
// if ( prev_elt.length != 0 && jQuery.trim(prev_elt.text()) == "" )
// prev_elt.remove();
// else
// removing = false;
// }
//});
});
hide_modal();
},
"Cancel": function()
{
hide_modal();
}
}
);
}
});
}
// ANNOTATE HISTORY DIALOG
if ( dialogType == Galaxy.DIALOG_ANNOTATE_HISTORY ) {
$.ajax(
{
url: list_histories_for_selection_url,
data: {},
error: function() { alert( "Grid refresh failed" ) },
success: function(table_html)
{
show_modal(
"Insert Link to History",
table_html,
{
"Annotate": function()
{
// Insert links to history for each checked item.
var item_ids = new Array();
$('input[name=id]:checked').each(function() {
var item_id = $(this).val();
// Get annotation table for history.
$.ajax(
{
url: get_history_annotation_table_url,
data: { id : item_id },
error: function() { alert( "Grid refresh failed" ) },
success: function(result)
{
// Insert into document.
wym.insert(result);
init_galaxy_elts(wym);
}
});
});
hide_modal();
},
"Cancel": function()
{
hide_modal();
}
}
);
}
});
}
};
$(function(){
// Generic error handling
$(document).ajaxError( function ( e, x ) {
// console.log( e, x );
var message = x.responseText || x.statusText || "Could not connect to server";
show_modal( "Server error", message, { "Ignore error" : hide_modal } );
return false;
});
// Create editor
$("[name=page_content]").wymeditor( {
skin: 'galaxy',
basePath: editor_base_path,
iframeBasePath: iframe_base_path,
boxHtml: "