1 | <%inherit file="/webapps/galaxy/base_panels.mako"/> |
---|
2 | |
---|
3 | <%def name="init()"> |
---|
4 | <% |
---|
5 | self.has_left_panel=False |
---|
6 | self.has_right_panel=False |
---|
7 | self.active_view="user" |
---|
8 | self.overlay_visible=False |
---|
9 | %> |
---|
10 | </%def> |
---|
11 | |
---|
12 | <%def name="late_javascripts()"> |
---|
13 | <script type='text/javascript' src="${h.url_for('/static/scripts/galaxy.panels.js')}"> </script> |
---|
14 | <script type="text/javascript"> |
---|
15 | ensure_dd_helper(); |
---|
16 | ##make_left_panel( $("#left"), $("#center"), $("#left-border" ) ); |
---|
17 | ##make_right_panel( $("#right"), $("#center"), $("#right-border" ) ); |
---|
18 | ensure_popup_helper(); |
---|
19 | ## handle_minwidth_hint = rp.handle_minwidth_hint; |
---|
20 | </script> |
---|
21 | </%def> |
---|
22 | |
---|
23 | <%def name="javascripts()"> |
---|
24 | ${parent.javascripts()} |
---|
25 | ${h.js( "jquery", "jquery.event.drag", "jquery.event.drop", "jquery.event.hover", "jquery.form", "jquery.jstore-all", "json2", |
---|
26 | "galaxy.base", "jquery.wymeditor", "jquery.autocomplete", "autocomplete_tagging")} |
---|
27 | <script type="text/javascript"> |
---|
28 | |
---|
29 | // Useful Galaxy stuff. |
---|
30 | var Galaxy = |
---|
31 | { |
---|
32 | // Item types. |
---|
33 | ITEM_HISTORY : "item_history", |
---|
34 | ITEM_DATASET : "item_dataset", |
---|
35 | ITEM_WORKFLOW : "item_workflow", |
---|
36 | ITEM_PAGE : "item_page", |
---|
37 | ITEM_VISUALIZATION : "item_visualization", |
---|
38 | |
---|
39 | // Link dialogs. |
---|
40 | DIALOG_HISTORY_LINK : "link_history", |
---|
41 | DIALOG_DATASET_LINK : "link_dataset", |
---|
42 | DIALOG_WORKFLOW_LINK : "link_workflow", |
---|
43 | DIALOG_PAGE_LINK : "link_page", |
---|
44 | DIALOG_VISUALIZATION_LINK : "link_visualization", |
---|
45 | |
---|
46 | // Embed dialogs. |
---|
47 | DIALOG_EMBED_HISTORY : "embed_history", |
---|
48 | DIALOG_EMBED_DATASET : "embed_dataset", |
---|
49 | DIALOG_EMBED_WORKFLOW : "embed_workflow", |
---|
50 | DIALOG_EMBED_PAGE : "embed_page", |
---|
51 | DIALOG_EMBED_VISUALIZATION : "embed_visualization", |
---|
52 | |
---|
53 | // Annotation dialogs. |
---|
54 | DIALOG_HISTORY_ANNOTATE : "history_annotate", |
---|
55 | }; |
---|
56 | |
---|
57 | // Initialize Galaxy elements. |
---|
58 | function init_galaxy_elts(wym) |
---|
59 | { |
---|
60 | // Set up events to make annotation easy. |
---|
61 | $('.annotation', wym._doc.body).each( function() |
---|
62 | { |
---|
63 | $(this).click( function() { |
---|
64 | // Works in Safari, not in Firefox. |
---|
65 | var range = wym._doc.createRange(); |
---|
66 | range.selectNodeContents( this ); |
---|
67 | var selection = window.getSelection(); |
---|
68 | selection.removeAllRanges(); |
---|
69 | selection.addRange(range); |
---|
70 | var t = ""; |
---|
71 | }); |
---|
72 | }); |
---|
73 | |
---|
74 | }; |
---|
75 | |
---|
76 | // Based on the dialog type, return a dictionary of information about an item |
---|
77 | function get_item_info( dialog_type ) |
---|
78 | { |
---|
79 | var |
---|
80 | item_singular, |
---|
81 | item_plural, |
---|
82 | item_controller; |
---|
83 | switch( dialog_type ) { |
---|
84 | case( Galaxy.ITEM_HISTORY ): |
---|
85 | item_singular = "History"; |
---|
86 | item_plural = "Histories"; |
---|
87 | item_controller = "history"; |
---|
88 | item_class = "History"; |
---|
89 | break; |
---|
90 | case( Galaxy.ITEM_DATASET ): |
---|
91 | item_singular = "Dataset"; |
---|
92 | item_plural = "Datasets"; |
---|
93 | item_controller = "dataset"; |
---|
94 | item_class = "HistoryDatasetAssociation"; |
---|
95 | break; |
---|
96 | case( Galaxy.ITEM_WORKFLOW ): |
---|
97 | item_singular = "Workflow"; |
---|
98 | item_plural = "Workflows"; |
---|
99 | item_controller = "workflow"; |
---|
100 | item_class = "StoredWorkflow"; |
---|
101 | break; |
---|
102 | case( Galaxy.ITEM_PAGE ): |
---|
103 | item_singular = "Page"; |
---|
104 | item_plural = "Pages"; |
---|
105 | item_controller = "page"; |
---|
106 | item_class = "Page"; |
---|
107 | break; |
---|
108 | case( Galaxy.ITEM_VISUALIZATION ): |
---|
109 | item_singular = "Visualization"; |
---|
110 | item_plural = "Visualizations"; |
---|
111 | item_controller = "visualization"; |
---|
112 | item_class = "Visualization"; |
---|
113 | break; |
---|
114 | } |
---|
115 | |
---|
116 | // Build ajax URL that lists items for selection. |
---|
117 | var item_list_action = "list_" + item_plural.toLowerCase() + "_for_selection"; |
---|
118 | var url_template = "${h.url_for( action='LIST_ACTION' )}"; |
---|
119 | var ajax_url = url_template.replace( "LIST_ACTION", item_list_action ); |
---|
120 | |
---|
121 | // Set up and return dict. |
---|
122 | return { |
---|
123 | singular : item_singular, |
---|
124 | plural : item_plural, |
---|
125 | controller : item_controller, |
---|
126 | iclass : item_class, |
---|
127 | list_ajax_url : ajax_url |
---|
128 | }; |
---|
129 | }; |
---|
130 | |
---|
131 | // Make an item importable. |
---|
132 | function make_item_importable( item_controller, item_id, item_type ) |
---|
133 | { |
---|
134 | url_template = "${h.url_for( controller='ITEM_CONTROLLER', action='set_accessible_async' )}"; |
---|
135 | ajax_url = url_template.replace( "ITEM_CONTROLLER", item_controller ); |
---|
136 | $.ajax({ |
---|
137 | type: "POST", |
---|
138 | url: ajax_url, |
---|
139 | data: { id: item_id, accessible: 'True' }, |
---|
140 | error: function() { alert("Making " + item_type + " accessible failed"); } |
---|
141 | }); |
---|
142 | }; |
---|
143 | |
---|
144 | ## Completely replace WYM's dialog handling |
---|
145 | WYMeditor.editor.prototype.dialog = function( dialogType, dialogFeatures, bodyHtml ) { |
---|
146 | |
---|
147 | var wym = this; |
---|
148 | var sStamp = wym.uniqueStamp(); |
---|
149 | var selected = wym.selected(); |
---|
150 | |
---|
151 | // Swap out URL attribute for id/name attribute in link creation to enable anchor creation in page. |
---|
152 | function set_link_id() |
---|
153 | { |
---|
154 | // When "set link id" link clicked, update UI. |
---|
155 | $('#set_link_id').click( function() |
---|
156 | { |
---|
157 | // Set label. |
---|
158 | $("#link_attribute_label").text("ID/Name"); |
---|
159 | |
---|
160 | // Set input elt class, value. |
---|
161 | var attribute_input = $(".wym_href"); |
---|
162 | attribute_input.addClass("wym_id").removeClass("wym_href"); |
---|
163 | if (selected) |
---|
164 | attribute_input.val( $(selected).attr('id') ); |
---|
165 | |
---|
166 | // Remove link. |
---|
167 | $(this).remove(); |
---|
168 | }); |
---|
169 | } |
---|
170 | |
---|
171 | // LINK DIALOG |
---|
172 | if ( dialogType == WYMeditor.DIALOG_LINK ) { |
---|
173 | if(selected) { |
---|
174 | jQuery(wym._options.hrefSelector).val(jQuery(selected).attr(WYMeditor.HREF)); |
---|
175 | jQuery(wym._options.srcSelector).val(jQuery(selected).attr(WYMeditor.SRC)); |
---|
176 | jQuery(wym._options.titleSelector).val(jQuery(selected).attr(WYMeditor.TITLE)); |
---|
177 | jQuery(wym._options.altSelector).val(jQuery(selected).attr(WYMeditor.ALT)); |
---|
178 | } |
---|
179 | // Get current URL, title. |
---|
180 | var curURL, curTitle; |
---|
181 | if (selected) |
---|
182 | { |
---|
183 | curURL = $(selected).attr("href"); |
---|
184 | if (curURL == undefined) |
---|
185 | curURL = ""; |
---|
186 | curTitle = $(selected).attr("title"); |
---|
187 | if (curTitle == undefined) |
---|
188 | curTitle = ""; |
---|
189 | } |
---|
190 | show_modal( |
---|
191 | "Create Link", |
---|
192 | "<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='" + curURL + "' size='40' /></div>" |
---|
193 | + "<div><label>Title</label><br><input type='text' class='wym_title' value='" + curTitle + "' size='40' /></div><div>", |
---|
194 | { |
---|
195 | "Make link": function() { |
---|
196 | var sUrl = jQuery(wym._options.hrefSelector).val(); |
---|
197 | sUrl = ( sUrl ? sUrl : "" ); |
---|
198 | var sName = $(".wym_id").val(); |
---|
199 | sName = ( sName ? sName : "" ); |
---|
200 | if ( (sUrl.length > 0) || (sName.length > 0) ) { |
---|
201 | // Create link. |
---|
202 | wym._exec(WYMeditor.CREATE_LINK, sStamp); |
---|
203 | |
---|
204 | var link = jQuery("a[href=" + sStamp + "]", wym._doc.body); |
---|
205 | link.attr(WYMeditor.HREF, sUrl); |
---|
206 | link.attr(WYMeditor.TITLE, jQuery(wym._options.titleSelector).val()); |
---|
207 | if (sName.length > 0) |
---|
208 | link.attr("id", sName); |
---|
209 | } |
---|
210 | hide_modal(); |
---|
211 | }, |
---|
212 | "Cancel": function() { |
---|
213 | hide_modal(); |
---|
214 | } |
---|
215 | }, |
---|
216 | {}, |
---|
217 | set_link_id |
---|
218 | ); |
---|
219 | return; |
---|
220 | } |
---|
221 | |
---|
222 | // IMAGE DIALOG |
---|
223 | if ( dialogType == WYMeditor.DIALOG_IMAGE ) { |
---|
224 | if(wym._selected_image) { |
---|
225 | jQuery(wym._options.dialogImageSelector + " " + wym._options.srcSelector) |
---|
226 | .val(jQuery(wym._selected_image).attr(WYMeditor.SRC)); |
---|
227 | jQuery(wym._options.dialogImageSelector + " " + wym._options.titleSelector) |
---|
228 | .val(jQuery(wym._selected_image).attr(WYMeditor.TITLE)); |
---|
229 | jQuery(wym._options.dialogImageSelector + " " + wym._options.altSelector) |
---|
230 | .val(jQuery(wym._selected_image).attr(WYMeditor.ALT)); |
---|
231 | } |
---|
232 | show_modal( |
---|
233 | "Image", |
---|
234 | "<div class='row'>" |
---|
235 | + "<label>URL</label><br>" |
---|
236 | + "<input type='text' class='wym_src' value='' size='40' />" |
---|
237 | + "</div>" |
---|
238 | + "<div class='row'>" |
---|
239 | + "<label>Alt text</label><br>" |
---|
240 | + "<input type='text' class='wym_alt' value='' size='40' />" |
---|
241 | + "</div>" |
---|
242 | + "<div class='row'>" |
---|
243 | + "<label>Title</label><br>" |
---|
244 | + "<input type='text' class='wym_title' value='' size='40' />" |
---|
245 | + "</div>", |
---|
246 | { |
---|
247 | "Insert": function() { |
---|
248 | var sUrl = jQuery(wym._options.srcSelector).val(); |
---|
249 | if(sUrl.length > 0) { |
---|
250 | wym._exec(WYMeditor.INSERT_IMAGE, sStamp); |
---|
251 | jQuery("img[src$=" + sStamp + "]", wym._doc.body) |
---|
252 | .attr(WYMeditor.SRC, sUrl) |
---|
253 | .attr(WYMeditor.TITLE, jQuery(wym._options.titleSelector).val()) |
---|
254 | .attr(WYMeditor.ALT, jQuery(wym._options.altSelector).val()); |
---|
255 | } |
---|
256 | hide_modal(); |
---|
257 | }, |
---|
258 | "Cancel": function() { |
---|
259 | hide_modal(); |
---|
260 | } |
---|
261 | } |
---|
262 | ); |
---|
263 | return; |
---|
264 | } |
---|
265 | |
---|
266 | // TABLE DIALOG |
---|
267 | if ( dialogType == WYMeditor.DIALOG_TABLE ) { |
---|
268 | show_modal( |
---|
269 | "Table", |
---|
270 | "<div class='row'>" |
---|
271 | + "<label>Caption</label><br>" |
---|
272 | + "<input type='text' class='wym_caption' value='' size='40' />" |
---|
273 | + "</div>" |
---|
274 | + "<div class='row'>" |
---|
275 | + "<label>Summary</label><br>" |
---|
276 | + "<input type='text' class='wym_summary' value='' size='40' />" |
---|
277 | + "</div>" |
---|
278 | + "<div class='row'>" |
---|
279 | + "<label>Number Of Rows<br></label>" |
---|
280 | + "<input type='text' class='wym_rows' value='3' size='3' />" |
---|
281 | + "</div>" |
---|
282 | + "<div class='row'>" |
---|
283 | + "<label>Number Of Cols<br></label>" |
---|
284 | + "<input type='text' class='wym_cols' value='2' size='3' />" |
---|
285 | + "</div>", |
---|
286 | { |
---|
287 | "Insert": function() { |
---|
288 | var iRows = jQuery(wym._options.rowsSelector).val(); |
---|
289 | var iCols = jQuery(wym._options.colsSelector).val(); |
---|
290 | |
---|
291 | if(iRows > 0 && iCols > 0) { |
---|
292 | |
---|
293 | var table = wym._doc.createElement(WYMeditor.TABLE); |
---|
294 | var newRow = null; |
---|
295 | var newCol = null; |
---|
296 | |
---|
297 | var sCaption = jQuery(wym._options.captionSelector).val(); |
---|
298 | |
---|
299 | //we create the caption |
---|
300 | var newCaption = table.createCaption(); |
---|
301 | newCaption.innerHTML = sCaption; |
---|
302 | |
---|
303 | //we create the rows and cells |
---|
304 | for(x=0; x<iRows; x++) { |
---|
305 | newRow = table.insertRow(x); |
---|
306 | for(y=0; y<iCols; y++) {newRow.insertCell(y);} |
---|
307 | } |
---|
308 | |
---|
309 | //set the summary attr |
---|
310 | jQuery(table).attr('summary', |
---|
311 | jQuery(wym._options.summarySelector).val()); |
---|
312 | |
---|
313 | //append the table after the selected container |
---|
314 | var node = jQuery(wym.findUp(wym.container(), |
---|
315 | WYMeditor.MAIN_CONTAINERS)).get(0); |
---|
316 | if(!node || !node.parentNode) jQuery(wym._doc.body).append(table); |
---|
317 | else jQuery(node).after(table); |
---|
318 | } |
---|
319 | hide_modal(); |
---|
320 | }, |
---|
321 | "Cancel": function() { |
---|
322 | hide_modal(); |
---|
323 | } |
---|
324 | } |
---|
325 | ); |
---|
326 | } |
---|
327 | |
---|
328 | // INSERT "GALAXY ITEM" LINK DIALOG |
---|
329 | if ( dialogType == Galaxy.DIALOG_HISTORY_LINK || dialogType == Galaxy.DIALOG_DATASET_LINK || |
---|
330 | dialogType == Galaxy.DIALOG_WORKFLOW_LINK || dialogType == Galaxy.DIALOG_PAGE_LINK || |
---|
331 | dialogType == Galaxy.DIALOG_VISUALIZATION_LINK ) { |
---|
332 | // Based on item type, set useful vars. |
---|
333 | var item_info; |
---|
334 | switch(dialogType) |
---|
335 | { |
---|
336 | case(Galaxy.DIALOG_HISTORY_LINK): |
---|
337 | item_info = get_item_info(Galaxy.ITEM_HISTORY); |
---|
338 | break; |
---|
339 | case(Galaxy.DIALOG_DATASET_LINK): |
---|
340 | item_info = get_item_info(Galaxy.ITEM_DATASET); |
---|
341 | break; |
---|
342 | case(Galaxy.DIALOG_WORKFLOW_LINK): |
---|
343 | item_info = get_item_info(Galaxy.ITEM_WORKFLOW); |
---|
344 | break; |
---|
345 | case(Galaxy.DIALOG_PAGE_LINK): |
---|
346 | item_info = get_item_info(Galaxy.ITEM_PAGE); |
---|
347 | break; |
---|
348 | case(Galaxy.DIALOG_VISUALIZATION_LINK): |
---|
349 | item_info = get_item_info(Galaxy.ITEM_VISUALIZATION); |
---|
350 | break; |
---|
351 | } |
---|
352 | |
---|
353 | $.ajax( |
---|
354 | { |
---|
355 | url: item_info.list_ajax_url, |
---|
356 | data: {}, |
---|
357 | error: function() { alert( "Failed to list " + item_info.plural.toLowerCase() + " for selection"); }, |
---|
358 | success: function(table_html) |
---|
359 | { |
---|
360 | show_modal( |
---|
361 | "Insert Link to " + item_info.singular, |
---|
362 | table_html + |
---|
363 | "<div><input id='make-importable' type='checkbox' checked/>" + |
---|
364 | "Make the selected " + item_info.plural.toLowerCase() + " accessible so that they can viewed by everyone.</div>" |
---|
365 | , |
---|
366 | { |
---|
367 | "Insert": function() |
---|
368 | { |
---|
369 | // Make selected items accessible (importable) ? |
---|
370 | var make_importable = false; |
---|
371 | if ( $('#make-importable:checked').val() !== null ) |
---|
372 | make_importable = true; |
---|
373 | |
---|
374 | // Insert links to history for each checked item. |
---|
375 | var item_ids = new Array(); |
---|
376 | $('input[name=id]:checked').each(function() { |
---|
377 | var item_id = $(this).val(); |
---|
378 | |
---|
379 | // Make item importable? |
---|
380 | if (make_importable) |
---|
381 | make_item_importable(item_info.controller, item_id, item_info.singular); |
---|
382 | |
---|
383 | // Insert link(s) to item(s). This is done by getting item info and then manipulating wym. |
---|
384 | url_template = "${h.url_for( controller='ITEM_CONTROLLER', action='get_name_and_link_async' )}?id=" + item_id; |
---|
385 | ajax_url = url_template.replace( "ITEM_CONTROLLER", item_info.controller); |
---|
386 | $.getJSON( ajax_url, function( returned_item_info ) { |
---|
387 | // Get link text. |
---|
388 | wym._exec(WYMeditor.CREATE_LINK, sStamp); |
---|
389 | var link_text = $("a[href=" + sStamp + "]", wym._doc.body).text(); |
---|
390 | |
---|
391 | // Insert link: need to do different actions depending on link text. |
---|
392 | if ( |
---|
393 | link_text == "" // Firefox. |
---|
394 | || |
---|
395 | link_text == sStamp // Safari |
---|
396 | ) |
---|
397 | { |
---|
398 | // User selected no text; create link from scratch and use default text. |
---|
399 | wym.insert("<a href='" + returned_item_info.link + "'>" + item_info.singular + " '" + returned_item_info.name + "'</a>"); |
---|
400 | } |
---|
401 | else |
---|
402 | { |
---|
403 | // Link created from selected text; add href and title. |
---|
404 | $("a[href=" + sStamp + "]", wym._doc.body).attr(WYMeditor.HREF, returned_item_info.link).attr(WYMeditor.TITLE, item_info.singular + item_id); |
---|
405 | } |
---|
406 | }); |
---|
407 | }); |
---|
408 | |
---|
409 | hide_modal(); |
---|
410 | }, |
---|
411 | "Cancel": function() |
---|
412 | { |
---|
413 | hide_modal(); |
---|
414 | } |
---|
415 | } |
---|
416 | ); |
---|
417 | } |
---|
418 | }); |
---|
419 | } |
---|
420 | // EMBED GALAXY OBJECT DIALOGS |
---|
421 | 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 ) { |
---|
422 | // Based on item type, set useful vars. |
---|
423 | var item_info; |
---|
424 | switch(dialogType) |
---|
425 | { |
---|
426 | case(Galaxy.DIALOG_EMBED_HISTORY): |
---|
427 | item_info = get_item_info(Galaxy.ITEM_HISTORY); |
---|
428 | break; |
---|
429 | case(Galaxy.DIALOG_EMBED_DATASET): |
---|
430 | item_info = get_item_info(Galaxy.ITEM_DATASET); |
---|
431 | break; |
---|
432 | case(Galaxy.DIALOG_EMBED_WORKFLOW): |
---|
433 | item_info = get_item_info(Galaxy.ITEM_WORKFLOW); |
---|
434 | break; |
---|
435 | case(Galaxy.DIALOG_EMBED_PAGE): |
---|
436 | item_info = get_item_info(Galaxy.ITEM_PAGE); |
---|
437 | break; |
---|
438 | case(Galaxy.DIALOG_EMBED_VISUALIZATION): |
---|
439 | item_info = get_item_info(Galaxy.ITEM_VISUALIZATION); |
---|
440 | break; |
---|
441 | } |
---|
442 | |
---|
443 | $.ajax( |
---|
444 | { |
---|
445 | url: item_info.list_ajax_url, |
---|
446 | data: {}, |
---|
447 | error: function() { alert( "Failed to list " + item_info.plural.toLowerCase() + " for selection"); }, |
---|
448 | success: function(list_html) |
---|
449 | { |
---|
450 | // Can make histories, workflows importable; cannot make datasets importable. |
---|
451 | if (dialogType == Galaxy.DIALOG_EMBED_HISTORY || dialogType == Galaxy.DIALOG_EMBED_WORKFLOW |
---|
452 | || dialogType == Galaxy.DIALOG_EMBED_VISUALIZATION) |
---|
453 | list_html = list_html + "<div><input id='make-importable' type='checkbox' checked/>" + |
---|
454 | "Make the selected " + item_info.plural.toLowerCase() + " accessible so that they can viewed by everyone.</div>"; |
---|
455 | show_modal( |
---|
456 | "Embed " + item_info.plural, |
---|
457 | list_html, |
---|
458 | { |
---|
459 | "Embed": function() |
---|
460 | { |
---|
461 | // Make selected items accessible (importable) ? |
---|
462 | var make_importable = false; |
---|
463 | if ( $('#make-importable:checked').val() != null ) |
---|
464 | make_importable = true; |
---|
465 | |
---|
466 | $('input[name=id]:checked').each(function() { |
---|
467 | // Get item ID and name. |
---|
468 | var item_id = $(this).val(); |
---|
469 | // Use ':first' because there are many labels in table; the first one is the item name. |
---|
470 | var item_name = $("label[for='" + item_id + "']:first").text(); |
---|
471 | |
---|
472 | if (make_importable) |
---|
473 | make_item_importable(item_info.controller, item_id, item_info.singular); |
---|
474 | |
---|
475 | // Embedded item HTML; item class is embedded in div container classes; this is necessary because the editor strips |
---|
476 | // all non-standard attributes when it returns its content (e.g. it will not return an element attribute of the form |
---|
477 | // item_class='History'). |
---|
478 | var item_elt_id = item_info.iclass + "-" + item_id; |
---|
479 | var item_embed_html = |
---|
480 | "<p><div id='" + item_elt_id + "' class='embedded-item " + item_info.singular.toLowerCase() + |
---|
481 | " placeholder'> \ |
---|
482 | <p class='title'>Embedded Galaxy " + item_info.singular + " '" + item_name + "'</p> \ |
---|
483 | <p class='content'> \ |
---|
484 | [Do not edit this block; Galaxy will fill it in with the annotated " + |
---|
485 | item_info.singular.toLowerCase() + " when it is displayed.] \ |
---|
486 | </p> \ |
---|
487 | </div></p>"; |
---|
488 | |
---|
489 | // Insert embedded item into document. |
---|
490 | wym.insert(" "); // Needed to prevent insertion from occurring in child element in webkit browsers. |
---|
491 | wym.insert(item_embed_html); |
---|
492 | |
---|
493 | // TODO: can we fix this? |
---|
494 | // Due to oddities of wym.insert() [likely due to inserting a <div> and/or a complete paragraph], an |
---|
495 | // empty paragraph (or two!) may be included either before an embedded item. Remove these paragraphs. |
---|
496 | $("#" + item_elt_id, wym._doc.body).each( function() { |
---|
497 | // Remove previous empty paragraphs. |
---|
498 | var removing = true; |
---|
499 | while (removing) |
---|
500 | { |
---|
501 | var prev_elt = $(this).prev(); |
---|
502 | if ( prev_elt.length != 0 && jQuery.trim(prev_elt.text()) == "" ) |
---|
503 | prev_elt.remove(); |
---|
504 | else |
---|
505 | removing = false; |
---|
506 | } |
---|
507 | }); |
---|
508 | |
---|
509 | }); |
---|
510 | hide_modal(); |
---|
511 | }, |
---|
512 | "Cancel": function() |
---|
513 | { |
---|
514 | hide_modal(); |
---|
515 | } |
---|
516 | } |
---|
517 | ); |
---|
518 | } |
---|
519 | }); |
---|
520 | } |
---|
521 | |
---|
522 | // ANNOTATE HISTORY DIALOG |
---|
523 | if ( dialogType == Galaxy.DIALOG_ANNOTATE_HISTORY ) { |
---|
524 | $.ajax( |
---|
525 | { |
---|
526 | url: "${h.url_for( action='list_histories_for_selection' )}", |
---|
527 | data: {}, |
---|
528 | error: function() { alert( "Grid refresh failed" ) }, |
---|
529 | success: function(table_html) |
---|
530 | { |
---|
531 | show_modal( |
---|
532 | "Insert Link to History", |
---|
533 | table_html, |
---|
534 | { |
---|
535 | "Annotate": function() |
---|
536 | { |
---|
537 | // Insert links to history for each checked item. |
---|
538 | var item_ids = new Array(); |
---|
539 | $('input[name=id]:checked').each(function() { |
---|
540 | var item_id = $(this).val(); |
---|
541 | |
---|
542 | // Get annotation table for history. |
---|
543 | $.ajax( |
---|
544 | { |
---|
545 | url: "${h.url_for( action='get_history_annotation_table' )}", |
---|
546 | data: { id : item_id }, |
---|
547 | error: function() { alert( "Grid refresh failed" ) }, |
---|
548 | success: function(result) |
---|
549 | { |
---|
550 | // Insert into document. |
---|
551 | wym.insert(result); |
---|
552 | |
---|
553 | init_galaxy_elts(wym); |
---|
554 | |
---|
555 | } |
---|
556 | }); |
---|
557 | }); |
---|
558 | |
---|
559 | hide_modal(); |
---|
560 | }, |
---|
561 | "Cancel": function() |
---|
562 | { |
---|
563 | hide_modal(); |
---|
564 | } |
---|
565 | } |
---|
566 | ); |
---|
567 | } |
---|
568 | }); |
---|
569 | } |
---|
570 | }; |
---|
571 | </script> |
---|
572 | |
---|
573 | <script type='text/javascript'> |
---|
574 | $(function(){ |
---|
575 | ## Generic error handling |
---|
576 | $(document).ajaxError( function ( e, x ) { |
---|
577 | // console.log( e, x ); |
---|
578 | var message = x.responseText || x.statusText || "Could not connect to server"; |
---|
579 | show_modal( "Server error", message, { "Ignore error" : hide_modal } ); |
---|
580 | return false; |
---|
581 | }); |
---|
582 | ## Create editor |
---|
583 | $("[name=page_content]").wymeditor( { |
---|
584 | skin: 'galaxy', |
---|
585 | basePath: "${h.url_for('/static/wymeditor')}/", |
---|
586 | iframeBasePath: "${h.url_for('/static/wymeditor/iframe/galaxy')}/", |
---|
587 | boxHtml: "<table class='wym_box' width='100%' height='100%'>" |
---|
588 | + "<tr><td><div class='wym_area_top'>" |
---|
589 | + WYMeditor.TOOLS |
---|
590 | + "</div></td></tr>" |
---|
591 | + "<tr height='100%'><td>" |
---|
592 | + "<div class='wym_area_main' style='height: 100%;'>" |
---|
593 | // + WYMeditor.HTML |
---|
594 | + WYMeditor.IFRAME |
---|
595 | + WYMeditor.STATUS |
---|
596 | + "</div>" |
---|
597 | + "</div>" |
---|
598 | + "</td></tr></table>", |
---|
599 | toolsItems: [ |
---|
600 | {'name': 'Bold', 'title': 'Strong', 'css': 'wym_tools_strong'}, |
---|
601 | {'name': 'Italic', 'title': 'Emphasis', 'css': 'wym_tools_emphasis'}, |
---|
602 | {'name': 'Superscript', 'title': 'Superscript', 'css': 'wym_tools_superscript'}, |
---|
603 | {'name': 'Subscript', 'title': 'Subscript', 'css': 'wym_tools_subscript'}, |
---|
604 | {'name': 'InsertOrderedList', 'title': 'Ordered_List', 'css': 'wym_tools_ordered_list'}, |
---|
605 | {'name': 'InsertUnorderedList', 'title': 'Unordered_List', 'css': 'wym_tools_unordered_list'}, |
---|
606 | {'name': 'Indent', 'title': 'Indent', 'css': 'wym_tools_indent'}, |
---|
607 | {'name': 'Outdent', 'title': 'Outdent', 'css': 'wym_tools_outdent'}, |
---|
608 | {'name': 'Undo', 'title': 'Undo', 'css': 'wym_tools_undo'}, |
---|
609 | {'name': 'Redo', 'title': 'Redo', 'css': 'wym_tools_redo'}, |
---|
610 | {'name': 'CreateLink', 'title': 'Link', 'css': 'wym_tools_link'}, |
---|
611 | {'name': 'Unlink', 'title': 'Unlink', 'css': 'wym_tools_unlink'}, |
---|
612 | {'name': 'InsertImage', 'title': 'Image', 'css': 'wym_tools_image'}, |
---|
613 | {'name': 'InsertTable', 'title': 'Table', 'css': 'wym_tools_table'}, |
---|
614 | ] |
---|
615 | }); |
---|
616 | ## Get the editor object |
---|
617 | var editor = $.wymeditors(0); |
---|
618 | var save = function ( callback ) { |
---|
619 | show_modal( "Saving page", "progress" ); |
---|
620 | |
---|
621 | /* |
---|
622 | Not used right now. |
---|
623 | // Gather annotations. |
---|
624 | var annotations = new Array(); |
---|
625 | |
---|
626 | $('.annotation', editor._doc.body).each( function() { |
---|
627 | var item_class = $(this).attr( 'item_class' ); |
---|
628 | var item_id = $(this).attr( 'item_id' ); |
---|
629 | var text = $(this).text(); |
---|
630 | annotation = { |
---|
631 | "item_class" : item_class, |
---|
632 | "item_id" : item_id, |
---|
633 | "text" : text |
---|
634 | }; |
---|
635 | annotations[ annotations.length ] = annotation; |
---|
636 | }); |
---|
637 | |
---|
638 | */ |
---|
639 | |
---|
640 | // Do save. |
---|
641 | $.ajax( { |
---|
642 | url: "${h.url_for( action='save' )}", |
---|
643 | type: "POST", |
---|
644 | data: { |
---|
645 | id: "${trans.security.encode_id(page.id)}", |
---|
646 | content: editor.xhtml(), |
---|
647 | annotations: JSON.stringify(new Object()), |
---|
648 | ## annotations: JSON.stringify(annotations), |
---|
649 | "_": "true" |
---|
650 | }, |
---|
651 | success: function() { |
---|
652 | callback(); |
---|
653 | } |
---|
654 | }); |
---|
655 | } |
---|
656 | ## Save button |
---|
657 | $("#save-button").click( function() { |
---|
658 | save( function() { hide_modal(); } ) |
---|
659 | }); |
---|
660 | ## Close button |
---|
661 | $("#close-button").click(function() { |
---|
662 | <% next_url = h.url_for( controller='page', action='list' ) %> |
---|
663 | // var new_content = editor.xhtml(); |
---|
664 | // var changed = ( initial_content != new_content ); |
---|
665 | var changed = false; |
---|
666 | if ( changed ) { |
---|
667 | var do_close = function() { |
---|
668 | window.onbeforeunload = undefined; |
---|
669 | window.document.location = "${next_url}" |
---|
670 | }; |
---|
671 | show_modal( "Close editor", |
---|
672 | "There are unsaved changes to your page which will be lost.", |
---|
673 | { |
---|
674 | "Cancel" : hide_modal, |
---|
675 | "Save Changes" : function() { |
---|
676 | save( do_close ); |
---|
677 | } |
---|
678 | }, { |
---|
679 | "Don't Save": do_close |
---|
680 | } ); |
---|
681 | } else { |
---|
682 | window.document.location = "${next_url}"; |
---|
683 | } |
---|
684 | }); |
---|
685 | |
---|
686 | // Initialize galaxy elements. |
---|
687 | //init_galaxy_elts(editor); |
---|
688 | |
---|
689 | // |
---|
690 | // Containers, Galaxy style |
---|
691 | // |
---|
692 | var containers_menu = $("<div class='galaxy-page-editor-button'><a id='insert-galaxy-link' class='action-button popup' href='#'>${_('Paragraph type')}</a></div>"); |
---|
693 | $(".wym_area_top").append( containers_menu ); |
---|
694 | |
---|
695 | // Add menu options. |
---|
696 | var items = {} |
---|
697 | $.each( editor._options.containersItems, function( k, v ) { |
---|
698 | var tagname = v.name; |
---|
699 | items[ v.title.replace( '_', ' ' ) ] = function() { editor.container( tagname ) } |
---|
700 | }); |
---|
701 | make_popupmenu( containers_menu, items); |
---|
702 | |
---|
703 | // |
---|
704 | // Create 'Insert Link to Galaxy Object' menu. |
---|
705 | // |
---|
706 | |
---|
707 | // Add menu button. |
---|
708 | var insert_link_menu_button = $("<div><a id='insert-galaxy-link' class='action-button popup' href='#'>${_('Insert Link to Galaxy Object')}</a></div>").addClass('galaxy-page-editor-button'); |
---|
709 | $(".wym_area_top").append(insert_link_menu_button); |
---|
710 | |
---|
711 | // Add menu options. |
---|
712 | make_popupmenu( insert_link_menu_button, { |
---|
713 | "Insert History Link": function() { |
---|
714 | editor.dialog(Galaxy.DIALOG_HISTORY_LINK); |
---|
715 | }, |
---|
716 | "Insert Dataset Link": function() { |
---|
717 | editor.dialog(Galaxy.DIALOG_DATASET_LINK); |
---|
718 | }, |
---|
719 | "Insert Workflow Link": function() { |
---|
720 | editor.dialog(Galaxy.DIALOG_WORKFLOW_LINK); |
---|
721 | }, |
---|
722 | "Insert Page Link": function() { |
---|
723 | editor.dialog(Galaxy.DIALOG_PAGE_LINK); |
---|
724 | }, |
---|
725 | "Insert Visualization Link": function() { |
---|
726 | editor.dialog(Galaxy.DIALOG_VISUALIZATION_LINK); |
---|
727 | }, |
---|
728 | }); |
---|
729 | |
---|
730 | // |
---|
731 | // Create 'Embed Galaxy Object' menu. |
---|
732 | // |
---|
733 | |
---|
734 | // Add menu button. |
---|
735 | var embed_object_button = $("<div><a id='embed-galaxy-object' class='action-button popup' href='#'>${_('Embed Galaxy Object')}</a></div>").addClass('galaxy-page-editor-button'); |
---|
736 | $(".wym_area_top").append(embed_object_button); |
---|
737 | |
---|
738 | // Add menu options. |
---|
739 | make_popupmenu( embed_object_button, { |
---|
740 | "Embed History": function() { |
---|
741 | editor.dialog(Galaxy.DIALOG_EMBED_HISTORY); |
---|
742 | }, |
---|
743 | "Embed Dataset": function() { |
---|
744 | editor.dialog(Galaxy.DIALOG_EMBED_DATASET); |
---|
745 | }, |
---|
746 | "Embed Workflow": function() { |
---|
747 | editor.dialog(Galaxy.DIALOG_EMBED_WORKFLOW); |
---|
748 | }, |
---|
749 | "Embed Visualization": function() { |
---|
750 | editor.dialog(Galaxy.DIALOG_EMBED_VISUALIZATION); |
---|
751 | }, |
---|
752 | ##"Embed Page": function() { |
---|
753 | ## editor.dialog(Galaxy.DIALOG_EMBED_PAGE); |
---|
754 | ##} |
---|
755 | }); |
---|
756 | }); |
---|
757 | </script> |
---|
758 | </%def> |
---|
759 | |
---|
760 | <%def name="stylesheets()"> |
---|
761 | ${parent.stylesheets()} |
---|
762 | ${h.css( "base", "autocomplete_tagging", "embed_item" )} |
---|
763 | <style type='text/css'> |
---|
764 | .galaxy-page-editor-button |
---|
765 | { |
---|
766 | position: relative; |
---|
767 | float: left; |
---|
768 | padding: 0.2em; |
---|
769 | } |
---|
770 | </style> |
---|
771 | </%def> |
---|
772 | |
---|
773 | <%def name="center_panel()"> |
---|
774 | |
---|
775 | <div class="unified-panel-header" unselectable="on"> |
---|
776 | <div class="unified-panel-header-inner" style="float: right"> |
---|
777 | <a id="save-button" class="panel-header-button">Save</a> |
---|
778 | <a id="close-button" class="panel-header-button">Close</a> |
---|
779 | </div> |
---|
780 | <div class="unified-panel-header-inner"> |
---|
781 | Page Editor <span style="font-weight: normal">| Title : ${page.title}</span> |
---|
782 | </div> |
---|
783 | </div> |
---|
784 | |
---|
785 | <div class="unified-panel-body"> |
---|
786 | <textarea name="page_content">${page.latest_revision.content.decode('utf-8')}</textarea> |
---|
787 | </div> |
---|
788 | |
---|
789 | </%def> |
---|