Individual mvc/* module conversions.

This commit is contained in:
Dannon Baker
2017-10-19 12:13:15 -04:00
parent 9489252839
commit e602114987
23 changed files with 844 additions and 950 deletions
+77 -82
View File
@@ -1,90 +1,85 @@
define(["mvc/base-mvc", "utils/localization", "ui/editable-text"], function(
baseMVC,
_l
) {
// =============================================================================
/** A view on any model that has a 'annotation' attribute
import baseMVC from "mvc/base-mvc";
import _l from "utils/localization";
import "ui/editable-text";
// =============================================================================
/** A view on any model that has a 'annotation' attribute
*/
var AnnotationEditor = Backbone.View
.extend(baseMVC.LoggableMixin)
.extend(baseMVC.HiddenUntilActivatedViewMixin)
.extend({
tagName: "div",
className: "annotation-display",
var AnnotationEditor = Backbone.View
.extend(baseMVC.LoggableMixin)
.extend(baseMVC.HiddenUntilActivatedViewMixin)
.extend({
tagName: "div",
className: "annotation-display",
/** Set up listeners, parse options */
initialize: function(options) {
options = options || {};
this.tooltipConfig = options.tooltipConfig || {
placement: "bottom"
};
//console.debug( this, options );
// only listen to the model only for changes to annotations
this.listenTo(this.model, "change:annotation", function() {
this.render();
});
this.hiddenUntilActivated(options.$activator, options);
},
/** Set up listeners, parse options */
initialize: function(options) {
options = options || {};
this.tooltipConfig = options.tooltipConfig || {
placement: "bottom"
};
//console.debug( this, options );
// only listen to the model only for changes to annotations
this.listenTo(this.model, "change:annotation", function() {
this.render();
});
this.hiddenUntilActivated(options.$activator, options);
},
/** Build the DOM elements, call select to on the created input, and set up behaviors */
render: function() {
var view = this;
this.$el.html(this._template());
/** Build the DOM elements, call select to on the created input, and set up behaviors */
render: function() {
var view = this;
this.$el.html(this._template());
//TODO: handle empties better
this.$annotation().make_text_editable({
use_textarea: true,
on_finish: function(newAnnotation) {
view.$annotation().text(newAnnotation);
view.model
.save(
{ annotation: newAnnotation },
{ silent: true }
)
.fail(function() {
view
.$annotation()
.text(view.model.previous("annotation"));
});
}
});
return this;
},
//TODO: handle empties better
this.$annotation().make_text_editable({
use_textarea: true,
on_finish: function(newAnnotation) {
view.$annotation().text(newAnnotation);
view.model
.save({ annotation: newAnnotation }, { silent: true })
.fail(function() {
view
.$annotation()
.text(view.model.previous("annotation"));
});
}
});
return this;
},
/** @returns {String} the html text used to build the view's DOM */
_template: function() {
var annotation = this.model.get("annotation");
return [
//TODO: make prompt optional
'<label class="prompt">',
_l("Annotation"),
"</label>",
// set up initial tags by adding as CSV to input vals (necc. to init select2)
'<div class="annotation">',
_.escape(annotation),
"</div>"
].join("");
},
/** @returns {String} the html text used to build the view's DOM */
_template: function() {
var annotation = this.model.get("annotation");
return [
//TODO: make prompt optional
'<label class="prompt">',
_l("Annotation"),
"</label>",
// set up initial tags by adding as CSV to input vals (necc. to init select2)
'<div class="annotation">',
_.escape(annotation),
"</div>"
].join("");
},
/** @returns {jQuery} the main element for this view */
$annotation: function() {
return this.$el.find(".annotation");
},
/** @returns {jQuery} the main element for this view */
$annotation: function() {
return this.$el.find(".annotation");
},
/** shut down event listeners and remove this view's DOM */
remove: function() {
this.$annotation.off();
this.stopListening(this.model);
Backbone.View.prototype.remove.call(this);
},
/** shut down event listeners and remove this view's DOM */
remove: function() {
this.$annotation.off();
this.stopListening(this.model);
Backbone.View.prototype.remove.call(this);
},
/** string rep */
toString: function() {
return ["AnnotationEditor(", this.model + "", ")"].join("");
}
});
// =============================================================================
return {
AnnotationEditor: AnnotationEditor
};
});
/** string rep */
toString: function() {
return ["AnnotationEditor(", this.model + "", ")"].join("");
}
});
// =============================================================================
export default {
AnnotationEditor: AnnotationEditor
};
File diff suppressed because it is too large Load Diff
+179 -182
View File
@@ -1,205 +1,202 @@
define(["mvc/base-mvc", "utils/localization"], function(baseMVC, _l) {
// =============================================================================
/** A view on any model that has a 'tags' attribute (a list of tag strings)
import baseMVC from "mvc/base-mvc";
import _l from "utils/localization";
// =============================================================================
/** A view on any model that has a 'tags' attribute (a list of tag strings)
* Incorporates the select2 jQuery plugin for tags display/editing:
* http://ivaynberg.github.io/select2/
*/
var TagsEditor = Backbone.View
.extend(baseMVC.LoggableMixin)
.extend(baseMVC.HiddenUntilActivatedViewMixin)
.extend({
tagName: "div",
className: "tags-display",
select_width: "100%",
events: {},
var TagsEditor = Backbone.View
.extend(baseMVC.LoggableMixin)
.extend(baseMVC.HiddenUntilActivatedViewMixin)
.extend({
tagName: "div",
className: "tags-display",
select_width: "100%",
events: {},
/** Set up listeners, parse options */
initialize: function(options) {
//console.debug( this, options );
// only listen to the model only for changes to tags - re-render
this.show_editor = false;
if (options.usePrompt === false) {
this.label = "";
} else {
this.label =
'<label class="prompt">' + _l("Tags") + "</label>";
/** Set up listeners, parse options */
initialize: function(options) {
//console.debug( this, options );
// only listen to the model only for changes to tags - re-render
this.show_editor = false;
if (options.usePrompt === false) {
this.label = "";
} else {
this.label = '<label class="prompt">' + _l("Tags") + "</label>";
}
this.workflow_mode = options.workflow_mode || false;
if (this.workflow_mode) {
this.events.click = "showEditor";
this.events.keydown = "keydownHandler";
}
this.hiddenUntilActivated(options.$activator, options);
},
/** Build the DOM elements, call select to on the created input, and set up behaviors */
render: function() {
var self = this;
if (this.workflow_mode) {
this.$el.html(this._workflowTemplate());
} else {
this.$el.html(this._defaultTemplate());
}
this.$input().select2({
placeholder: "Add tags",
width: this.workflow_mode ? this.width : this.select_width,
tags: function() {
// initialize possible tags in the dropdown based on all the tags the user has used so far
return self._getTagsUsed();
}
this.workflow_mode = options.workflow_mode || false;
if (this.workflow_mode) {
this.events.click = "showEditor";
this.events.keydown = "keydownHandler";
}
this.hiddenUntilActivated(options.$activator, options);
},
});
/** Build the DOM elements, call select to on the created input, and set up behaviors */
render: function() {
var self = this;
if (this.workflow_mode) {
this.$el.html(this._workflowTemplate());
} else {
this.$el.html(this._defaultTemplate());
}
this.$input().select2({
placeholder: "Add tags",
width: this.workflow_mode ? this.width : this.select_width,
tags: function() {
// initialize possible tags in the dropdown based on all the tags the user has used so far
return self._getTagsUsed();
}
});
this._setUpBehaviors();
return this;
},
this._setUpBehaviors();
return this;
},
_hashToName: function(tag) {
if (tag.startsWith("#")) {
return "name:" + tag.slice(1);
}
return tag;
},
_hashToName: function(tag) {
if (tag.startsWith("#")) {
return "name:" + tag.slice(1);
}
return tag;
},
_nameToHash: function(tag) {
if (tag.startsWith("name:")) {
tag = "#" + tag.slice(5);
}
return tag;
},
_nameToHash: function(tag) {
if (tag.startsWith("name:")) {
tag = "#" + tag.slice(5);
}
return tag;
},
/** @returns {String} the html text used to build the view's DOM */
_defaultTemplate: function() {
return [this.label, this._renderEditor()].join("");
},
/** @returns {String} the html text used to build the view's DOM */
_defaultTemplate: function() {
return [this.label, this._renderEditor()].join("");
},
_workflowTemplate: function() {
// Shows labels by default, event handler controls whether we show tags or editor
return [
this.show_editor ? this._renderEditor() : this._renderTags()
].join(" ");
},
_workflowTemplate: function() {
// Shows labels by default, event handler controls whether we show tags or editor
return [
this.show_editor ? this._renderEditor() : this._renderTags()
].join(" ");
},
keydownHandler: function(e) {
switch (e.which) {
// esc
case 27:
// hide the tag editor when pressing escape
this.hideEditor();
break;
}
},
keydownHandler: function(e) {
switch (e.which) {
// esc
case 27:
// hide the tag editor when pressing escape
this.hideEditor();
break;
}
},
showEditor: function() {
this.show_editor = true;
this.render();
},
showEditor: function() {
this.show_editor = true;
this.render();
},
hideEditor: function() {
this.show_editor = false;
this.render();
},
hideEditor: function() {
this.show_editor = false;
this.render();
},
_renderEditor: function() {
// set up initial tags by adding as CSV to input vals (necc. to init select2)
return (
'<input class="tags-input" value="' + this.tagsToCSV() + '"/>'
);
},
_renderEditor: function() {
// set up initial tags by adding as CSV to input vals (necc. to init select2)
return (
'<input class="tags-input" value="' +
this.tagsToCSV() +
'"/>'
_renderTags: function() {
var tags = this.model.get("tags");
var addButton = "static/images/fugue/tag--plus.png";
var renderedArray = [];
_.each(tags, function(tag) {
tag = tag.indexOf("name:") == 0 ? tag.slice(5) : tag;
var renderString =
'<span class="label label-info">' + tag + "</span>";
renderedArray.push(renderString);
});
if (renderedArray.length === 0) {
// If there are no tags to render we just show the add-tag-button
renderedArray.push(
"<img src=" +
addButton +
' class="add-tag-button" title="Add tags"/>'
);
},
}
return renderedArray.join(" ");
},
_renderTags: function() {
var tags = this.model.get("tags");
var addButton = "static/images/fugue/tag--plus.png";
var renderedArray = [];
_.each(tags, function(tag) {
tag = tag.indexOf("name:") == 0 ? tag.slice(5) : tag;
var renderString =
'<span class="label label-info">' + tag + "</span>";
renderedArray.push(renderString);
});
if (renderedArray.length === 0) {
// If there are no tags to render we just show the add-tag-button
renderedArray.push(
"<img src=" +
addButton +
' class="add-tag-button" title="Add tags"/>'
);
/** @returns {String} the sorted, comma-separated tags from the model */
tagsToCSV: function() {
var self = this;
var tagsArray = this.model.get("tags");
if (!_.isArray(tagsArray) || _.isEmpty(tagsArray)) {
return "";
}
return tagsArray
.map(function(tag) {
return _.escape(self._nameToHash(tag));
})
.sort()
.join(",");
},
/** @returns {jQuery} the input for this view */
$input: function() {
return this.$el.find("input.tags-input");
},
/** @returns {String[]} all tags used by the current user */
_getTagsUsed: function() {
//TODO: global
var self = this;
return _.map(Galaxy.user.get("tags_used"), self._nameToHash);
},
/** set up any event listeners on the view's DOM (mostly handled by select2) */
_setUpBehaviors: function() {
var self = this;
this.$input().on("change", function(event) {
// Modify any 'hashtag' 'nametags'
event.val = _.map(event.val, self._hashToName);
// save the model's tags in either remove or added event
self.model.save({ tags: event.val });
// if it's new, add the tag to the users tags
if (event.added) {
//??: solve weird behavior in FF on test.galaxyproject.org where
// event.added.text is string object: 'String{ 0="o", 1="n", 2="e" }'
self._addNewTagToTagsUsed(event.added.text + "");
}
return renderedArray.join(" ");
},
});
},
/** @returns {String} the sorted, comma-separated tags from the model */
tagsToCSV: function() {
var self = this;
var tagsArray = this.model.get("tags");
if (!_.isArray(tagsArray) || _.isEmpty(tagsArray)) {
return "";
}
return tagsArray
.map(function(tag) {
return _.escape(self._nameToHash(tag));
})
.sort()
.join(",");
},
/** @returns {jQuery} the input for this view */
$input: function() {
return this.$el.find("input.tags-input");
},
/** @returns {String[]} all tags used by the current user */
_getTagsUsed: function() {
//TODO: global
var self = this;
return _.map(Galaxy.user.get("tags_used"), self._nameToHash);
},
/** set up any event listeners on the view's DOM (mostly handled by select2) */
_setUpBehaviors: function() {
var self = this;
this.$input().on("change", function(event) {
// Modify any 'hashtag' 'nametags'
event.val = _.map(event.val, self._hashToName);
// save the model's tags in either remove or added event
self.model.save({ tags: event.val });
// if it's new, add the tag to the users tags
if (event.added) {
//??: solve weird behavior in FF on test.galaxyproject.org where
// event.added.text is string object: 'String{ 0="o", 1="n", 2="e" }'
self._addNewTagToTagsUsed(event.added.text + "");
}
});
},
/** add a new tag (if not already there) to the list of all tags used by the user
/** add a new tag (if not already there) to the list of all tags used by the user
* @param {String} newTag the tag to add to the list of used
*/
_addNewTagToTagsUsed: function(newTag) {
//TODO: global
var tagsUsed = Galaxy.user.get("tags_used");
if (!_.contains(tagsUsed, newTag)) {
tagsUsed.push(newTag);
tagsUsed.sort();
Galaxy.user.set("tags_used", tagsUsed);
}
},
/** shut down event listeners and remove this view's DOM */
remove: function() {
this.$input.off();
this.stopListening(this.model);
Backbone.View.prototype.remove.call(this);
},
/** string rep */
toString: function() {
return ["TagsEditor(", this.model + "", ")"].join("");
_addNewTagToTagsUsed: function(newTag) {
//TODO: global
var tagsUsed = Galaxy.user.get("tags_used");
if (!_.contains(tagsUsed, newTag)) {
tagsUsed.push(newTag);
tagsUsed.sort();
Galaxy.user.set("tags_used", tagsUsed);
}
});
},
return {
TagsEditor: TagsEditor
};
});
/** shut down event listeners and remove this view's DOM */
remove: function() {
this.$input.off();
this.stopListening(this.model);
Backbone.View.prototype.remove.call(this);
},
/** string rep */
toString: function() {
return ["TagsEditor(", this.model + "", ")"].join("");
}
});
export default {
TagsEditor: TagsEditor
};
+103 -104
View File
@@ -3,10 +3,10 @@
* rendering a tour menu.
*/
define(["libs/bootstrap-tour"], function(BootstrapTour) {
var gxy_root = typeof Galaxy === "undefined" ? "/" : Galaxy.root;
import BootstrapTour from "libs/bootstrap-tour";
var gxy_root = typeof Galaxy === "undefined" ? "/" : Galaxy.root;
var tourpage_template = `<h2>Galaxy Tours</h2>
var tourpage_template = `<h2>Galaxy Tours</h2>
<p>This page presents a list of interactive tours available on this Galaxy server.
Select any tour to get started (and remember, you can click 'End Tour' at any time).</p>
<ul>
@@ -20,110 +20,109 @@ Select any tour to get started (and remember, you can click 'End Tour' at any ti
<% }); %>
</ul>`;
var tour_opts = {
storage: window.sessionStorage,
onEnd: function() {
sessionStorage.removeItem("activeGalaxyTour");
},
delay: 150, // Attempts to make it look natural
orphan: true
};
var tour_opts = {
storage: window.sessionStorage,
onEnd: function() {
sessionStorage.removeItem("activeGalaxyTour");
},
delay: 150, // Attempts to make it look natural
orphan: true
};
var hooked_tour_from_data = function(data) {
_.each(data.steps, function(step) {
if (step.preclick) {
step.onShow = function() {
_.each(step.preclick, function(preclick) {
// TODO: click delay between clicks
$(preclick).click();
});
};
}
if (step.postclick) {
step.onHide = function() {
_.each(step.postclick, function(postclick) {
// TODO: click delay between clicks
$(postclick).click();
});
};
}
if (step.textinsert) {
// Have to manually trigger a change here, for some
// elements which have additional logic, like the
// upload input box
step.onShown = function() {
$(step.element)
.val(step.textinsert)
.trigger("change");
};
}
});
return data;
};
var TourItem = Backbone.Model.extend({
urlRoot: gxy_root + "api/tours"
});
var Tours = Backbone.Collection.extend({
url: gxy_root + "api/tours",
model: TourItem
});
var giveTour = function(tour_id) {
var url = gxy_root + "api/tours/" + tour_id;
$.getJSON(url, function(data) {
// Set hooks for additional click and data entry actions.
var tourdata = hooked_tour_from_data(data);
sessionStorage.setItem("activeGalaxyTour", JSON.stringify(data));
// Store tour steps in sessionStorage to easily persist w/o hackery.
var tour = new Tour(
_.extend(
{
steps: tourdata.steps
},
tour_opts
)
);
// Always clean restart, since this is a new, explicit giveTour execution.
tour.init();
tour.goTo(0);
tour.restart();
});
};
var ToursView = Backbone.View.extend({
title: "Tours",
// initialize
initialize: function() {
var self = this;
this.setElement("<div/>");
this.model = new Tours();
this.model.fetch({
success: function() {
self.render();
},
error: function() {
// Do something.
console.error("Failed to fetch tours.");
}
});
},
render: function() {
var tpl = _.template(tourpage_template);
this.$el
.html(tpl({ tours: this.model.models }))
.on("click", ".tourItem", function(e) {
e.preventDefault();
giveTour($(this).data("tour.id"));
var hooked_tour_from_data = function(data) {
_.each(data.steps, function(step) {
if (step.preclick) {
step.onShow = function() {
_.each(step.preclick, function(preclick) {
// TODO: click delay between clicks
$(preclick).click();
});
};
}
if (step.postclick) {
step.onHide = function() {
_.each(step.postclick, function(postclick) {
// TODO: click delay between clicks
$(postclick).click();
});
};
}
if (step.textinsert) {
// Have to manually trigger a change here, for some
// elements which have additional logic, like the
// upload input box
step.onShown = function() {
$(step.element)
.val(step.textinsert)
.trigger("change");
};
}
});
return data;
};
return {
ToursView: ToursView,
hooked_tour_from_data: hooked_tour_from_data,
tour_opts: tour_opts,
giveTour: giveTour
};
var TourItem = Backbone.Model.extend({
urlRoot: gxy_root + "api/tours"
});
var Tours = Backbone.Collection.extend({
url: gxy_root + "api/tours",
model: TourItem
});
var giveTour = function(tour_id) {
var url = gxy_root + "api/tours/" + tour_id;
$.getJSON(url, function(data) {
// Set hooks for additional click and data entry actions.
var tourdata = hooked_tour_from_data(data);
sessionStorage.setItem("activeGalaxyTour", JSON.stringify(data));
// Store tour steps in sessionStorage to easily persist w/o hackery.
var tour = new Tour(
_.extend(
{
steps: tourdata.steps
},
tour_opts
)
);
// Always clean restart, since this is a new, explicit giveTour execution.
tour.init();
tour.goTo(0);
tour.restart();
});
};
var ToursView = Backbone.View.extend({
title: "Tours",
// initialize
initialize: function() {
var self = this;
this.setElement("<div/>");
this.model = new Tours();
this.model.fetch({
success: function() {
self.render();
},
error: function() {
// Do something.
console.error("Failed to fetch tours.");
}
});
},
render: function() {
var tpl = _.template(tourpage_template);
this.$el
.html(tpl({ tours: this.model.models }))
.on("click", ".tourItem", function(e) {
e.preventDefault();
giveTour($(this).data("tour.id"));
});
}
});
export default {
ToursView: ToursView,
hooked_tour_from_data: hooked_tour_from_data,
tour_opts: tour_opts,
giveTour: giveTour
};
-67
View File
@@ -1,67 +0,0 @@
/**
Webhooks
**/
define([], function() {
var WebhookModel = Backbone.Model.extend({
defaults: {
activate: false
}
});
var Webhooks = Backbone.Collection.extend({
model: WebhookModel
});
var WebhookView = Backbone.View.extend({
el: "#webhook-view",
initialize: function(options) {
var me = this;
var toolId = options.toolId || "";
var toolVersion = options.toolVersion || "";
this.$el.attr("tool_id", toolId);
this.$el.attr("tool_version", toolVersion);
this.model = new WebhookModel();
this.model.urlRoot = options.urlRoot;
this.model.fetch({
success: function() {
me.render();
}
});
},
render: function() {
var webhook = this.model.toJSON();
this.$el.html('<div id="' + webhook.name + '"></div>');
if (webhook.styles)
$("<style/>", { type: "text/css" })
.text(webhook.styles)
.appendTo("head");
if (webhook.script)
$("<script/>", { type: "text/javascript" })
.text(webhook.script)
.appendTo("head");
return this;
}
});
var add = function(options) {
var webhooks = new Webhooks();
webhooks.url = Galaxy.root + options.url;
webhooks.fetch({
async: options.async ? options.async : true,
success: options.callback
});
};
return {
Webhooks: Webhooks,
WebhookView: WebhookView,
add: add
};
});
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":3,"sources":["mvc/webhooks.js"],"names":["define","WebhookModel","Backbone","Model","extend","defaults","Webhooks","Collection","model","WebhookView","View","el","options","me","this","initialize","toolId","toolVersion","$el","attr","urlRoot","fetch","success","render","webhook","toJSON","add","name","styles","$","type","script","text","appendTo","webhooks","async","url","Galaxy","root","callback"],"mappings":"aAGAA,UAAW,WACP,IAAIC,EAAeC,SAASC,MAAMC,QAD/BC,UACCJ,UAAAA,KAAJK,EAAAJ,SAAAK,WAAAH,QAOII,MAAOP,IADXQ,EAAAP,SAAAQ,KAAAN,QAKIO,GAAI,gBAAJA,WAAI,SAD+BC,GAI/B,IAAIC,EAAKC,KADbC,EAAYH,EAAAI,QAASJ,GACbC,EAAJD,EAAAK,aAAA,GAEAH,KAAIG,IAAAA,KAAAA,UAAcL,GAGlBE,KAAKI,IAAIC,KAAK,eAAgBF,GAA9BH,KAAKI,MAAL,IAAcjB,EAGda,KAAKN,MAAMY,QAAUR,EAAQQ,QAD7BN,KAAKN,MAALa,OACAC,QAAWF,WACNZ,EAAMa,aAKdE,OAlBkC,WAqB/B,IAAIC,EAAUV,KAAKN,MAAMiB,SAgB7BC,OAhBIZ,KAAIU,IAAAA,KAAU,YAAWC,EAAzBE,KAAA,YAGIH,EAAQI,QADZC,EAAKX,YAASY,KAAA,aACVN,KAAQI,EACNA,QAGFJ,SAAJ,QAAIA,EAAQO,QAKZF,EAAA,aAAAC,KAAA,oBACHE,KAAAR,EAAAO,QAlCLE,SAAA,QAqCUnB,QAUH,OA1DXR,SAAAA,EA4DQG,YAAaA,EACbiB,IATAQ,SAAetB,GACXuB,IAAAA,EAAOvB,IAAQuB,EADJD,EAAfE,IAAAC,OAAAC,KAAA1B,EAAAwB,IAJJF,EAAAb,OAKQc,OAAOvB,EAAQuB,OAAQvB,EAAQuB,MAKhCb,QAAAV,EAAA2B","file":"../../scripts/mvc/webhooks.js","sourcesContent":["/**\n Webhooks\n**/\ndefine([], function() {\n var WebhookModel = Backbone.Model.extend({\n defaults: {\n activate: false\n }\n });\n\n var Webhooks = Backbone.Collection.extend({\n model: WebhookModel\n });\n\n var WebhookView = Backbone.View.extend({\n el: \"#webhook-view\",\n\n initialize: function(options) {\n var me = this;\n var toolId = options.toolId || \"\";\n var toolVersion = options.toolVersion || \"\";\n\n this.$el.attr(\"tool_id\", toolId);\n this.$el.attr(\"tool_version\", toolVersion);\n\n this.model = new WebhookModel();\n this.model.urlRoot = options.urlRoot;\n this.model.fetch({\n success: function() {\n me.render();\n }\n });\n },\n\n render: function() {\n var webhook = this.model.toJSON();\n\n this.$el.html('<div id=\"' + webhook.name + '\"></div>');\n if (webhook.styles)\n $(\"<style/>\", { type: \"text/css\" })\n .text(webhook.styles)\n .appendTo(\"head\");\n if (webhook.script)\n $(\"<script/>\", { type: \"text/javascript\" })\n .text(webhook.script)\n .appendTo(\"head\");\n\n return this;\n }\n });\n\n var add = function(options) {\n var webhooks = new Webhooks();\n\n webhooks.url = Galaxy.root + options.url;\n webhooks.fetch({\n async: options.async ? options.async : true,\n success: options.callback\n });\n };\n\n return {\n Webhooks: Webhooks,\n WebhookView: WebhookView,\n add: add\n };\n});\n"]}
{"version":3,"sources":["mvc/webhooks.js"],"names":[],"mappings":"AAAA","file":"../../scripts/mvc/webhooks.js","sourcesContent":["\"use strict\";"]}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,2 +1,2 @@
webpackJsonp([4],{116:function(e,t,i){"use strict";(function(e,t){function a(e){return e&&e.__esModule?e:{default:e}}var n=i(0),r=a(n),o=i(42),l=i(4),u=a(l),d=i(43),c=a(d),p=r.default;window.app=function(i,a){window.Galaxy=new o.GalaxyApp(i,a),Galaxy.debug("login app");var n=encodeURI(i.redirect);if(!i.show_welcome_with_login){var l=r.default.param({use_panels:"True",redirect:n});return void(window.location.href=Galaxy.root+"user/login?"+l)}var d=e.View.extend({initialize:function(t){this.page=t,this.model=new e.Model({title:(0,u.default)("Login required")}),this.setElement(this._template())},render:function(){this.page.$("#galaxy_main").prop("src",i.welcome_url)},_template:function(){return'<iframe src="'+i.root+"user/login?"+p.param({redirect:n})+'" frameborder="0" style="width: 100%; height: 100%;"/>'}});p(function(){Galaxy.page=new c.default.View(t.extend(i,{Right:d}))})}}).call(t,i(1),i(2))}},[116]);
webpackJsonp([4],{116:function(e,t,i){"use strict";(function(e,t){function a(e){return e&&e.__esModule?e:{default:e}}var n=i(0),r=a(n),o=i(42),l=i(4),u=a(l),d=i(43),c=a(d),p=r.default;window.app=function(i,a){window.Galaxy=new o.GalaxyApp(i,a),Galaxy.debug("login app");var n=encodeURI(i.redirect);if(!i.show_welcome_with_login){var l=r.default.param({use_panels:"True",redirect:n});return void(window.location.href=Galaxy.root+"user/login?"+l)}var d=e.View.extend({initialize:function(t){this.page=t,this.model=new e.Model({title:(0,u.default)("Login required")}),this.setElement(this._template())},render:function(){this.page.$("#galaxy_main").prop("src",i.welcome_url)},_template:function(){return'<iframe src="'+i.root+"user/login?"+p.param({redirect:n})+'" frameborder="0" style="width: 100%; height: 100%;"/>'}});p(function(){Galaxy.page=new c.default.View(t.extend(i,{Right:d}))})}}).call(t,i(2),i(1))}},[116]);
//# sourceMappingURL=login.bundled.js.map
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,2 +1,2 @@
"use strict";define(["mvc/base-mvc","utils/localization","ui/editable-text"],function(t,n){return{AnnotationEditor:Backbone.View.extend(t.LoggableMixin).extend(t.HiddenUntilActivatedViewMixin).extend({tagName:"div",className:"annotation-display",initialize:function(t){t=t||{},this.tooltipConfig=t.tooltipConfig||{placement:"bottom"},this.listenTo(this.model,"change:annotation",function(){this.render()}),this.hiddenUntilActivated(t.$activator,t)},render:function(){var t=this;return this.$el.html(this._template()),this.$annotation().make_text_editable({use_textarea:!0,on_finish:function(n){t.$annotation().text(n),t.model.save({annotation:n},{silent:!0}).fail(function(){t.$annotation().text(t.model.previous("annotation"))})}}),this},_template:function(){var t=this.model.get("annotation");return['<label class="prompt">',n("Annotation"),"</label>",'<div class="annotation">',_.escape(t),"</div>"].join("")},$annotation:function(){return this.$el.find(".annotation")},remove:function(){this.$annotation.off(),this.stopListening(this.model),Backbone.View.prototype.remove.call(this)},toString:function(){return["AnnotationEditor(",this.model+"",")"].join("")}})}});
"use strict";function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(exports,"__esModule",{value:!0});var _baseMvc=require("mvc/base-mvc"),_baseMvc2=_interopRequireDefault(_baseMvc),_localization=require("utils/localization"),_localization2=_interopRequireDefault(_localization);require("ui/editable-text");var AnnotationEditor=Backbone.View.extend(_baseMvc2.default.LoggableMixin).extend(_baseMvc2.default.HiddenUntilActivatedViewMixin).extend({tagName:"div",className:"annotation-display",initialize:function(t){t=t||{},this.tooltipConfig=t.tooltipConfig||{placement:"bottom"},this.listenTo(this.model,"change:annotation",function(){this.render()}),this.hiddenUntilActivated(t.$activator,t)},render:function(){var t=this;return this.$el.html(this._template()),this.$annotation().make_text_editable({use_textarea:!0,on_finish:function(n){t.$annotation().text(n),t.model.save({annotation:n},{silent:!0}).fail(function(){t.$annotation().text(t.model.previous("annotation"))})}}),this},_template:function(){var t=this.model.get("annotation");return['<label class="prompt">',(0,_localization2.default)("Annotation"),"</label>",'<div class="annotation">',_.escape(t),"</div>"].join("")},$annotation:function(){return this.$el.find(".annotation")},remove:function(){this.$annotation.off(),this.stopListening(this.model),Backbone.View.prototype.remove.call(this)},toString:function(){return["AnnotationEditor(",this.model+"",")"].join("")}});exports.default={AnnotationEditor:AnnotationEditor};
//# sourceMappingURL=../../maps/mvc/annotation.js.map
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,2 +1,2 @@
"use strict";define(["mvc/base-mvc","utils/localization"],function(t,e){return{TagsEditor:Backbone.View.extend(t.LoggableMixin).extend(t.HiddenUntilActivatedViewMixin).extend({tagName:"div",className:"tags-display",select_width:"100%",events:{},initialize:function(t){this.show_editor=!1,!1===t.usePrompt?this.label="":this.label='<label class="prompt">'+e("Tags")+"</label>",this.workflow_mode=t.workflow_mode||!1,this.workflow_mode&&(this.events.click="showEditor",this.events.keydown="keydownHandler"),this.hiddenUntilActivated(t.$activator,t)},render:function(){var t=this;return this.workflow_mode?this.$el.html(this._workflowTemplate()):this.$el.html(this._defaultTemplate()),this.$input().select2({placeholder:"Add tags",width:this.workflow_mode?this.width:this.select_width,tags:function(){return t._getTagsUsed()}}),this._setUpBehaviors(),this},_hashToName:function(t){return t.startsWith("#")?"name:"+t.slice(1):t},_nameToHash:function(t){return t.startsWith("name:")&&(t="#"+t.slice(5)),t},_defaultTemplate:function(){return[this.label,this._renderEditor()].join("")},_workflowTemplate:function(){return[this.show_editor?this._renderEditor():this._renderTags()].join(" ")},keydownHandler:function(t){switch(t.which){case 27:this.hideEditor()}},showEditor:function(){this.show_editor=!0,this.render()},hideEditor:function(){this.show_editor=!1,this.render()},_renderEditor:function(){return'<input class="tags-input" value="'+this.tagsToCSV()+'"/>'},_renderTags:function(){var t=this.model.get("tags"),e=[];return _.each(t,function(t){var i='<span class="label label-info">'+(t=0==t.indexOf("name:")?t.slice(5):t)+"</span>";e.push(i)}),0===e.length&&e.push('<img src=static/images/fugue/tag--plus.png class="add-tag-button" title="Add tags"/>'),e.join(" ")},tagsToCSV:function(){var t=this,e=this.model.get("tags");return!_.isArray(e)||_.isEmpty(e)?"":e.map(function(e){return _.escape(t._nameToHash(e))}).sort().join(",")},$input:function(){return this.$el.find("input.tags-input")},_getTagsUsed:function(){var t=this;return _.map(Galaxy.user.get("tags_used"),t._nameToHash)},_setUpBehaviors:function(){var t=this;this.$input().on("change",function(e){e.val=_.map(e.val,t._hashToName),t.model.save({tags:e.val}),e.added&&t._addNewTagToTagsUsed(e.added.text+"")})},_addNewTagToTagsUsed:function(t){var e=Galaxy.user.get("tags_used");_.contains(e,t)||(e.push(t),e.sort(),Galaxy.user.set("tags_used",e))},remove:function(){this.$input.off(),this.stopListening(this.model),Backbone.View.prototype.remove.call(this)},toString:function(){return["TagsEditor(",this.model+"",")"].join("")}})}});
"use strict";function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(exports,"__esModule",{value:!0});var _baseMvc=require("mvc/base-mvc"),_baseMvc2=_interopRequireDefault(_baseMvc),_localization=require("utils/localization"),_localization2=_interopRequireDefault(_localization),TagsEditor=Backbone.View.extend(_baseMvc2.default.LoggableMixin).extend(_baseMvc2.default.HiddenUntilActivatedViewMixin).extend({tagName:"div",className:"tags-display",select_width:"100%",events:{},initialize:function(t){this.show_editor=!1,!1===t.usePrompt?this.label="":this.label='<label class="prompt">'+(0,_localization2.default)("Tags")+"</label>",this.workflow_mode=t.workflow_mode||!1,this.workflow_mode&&(this.events.click="showEditor",this.events.keydown="keydownHandler"),this.hiddenUntilActivated(t.$activator,t)},render:function(){var t=this;return this.workflow_mode?this.$el.html(this._workflowTemplate()):this.$el.html(this._defaultTemplate()),this.$input().select2({placeholder:"Add tags",width:this.workflow_mode?this.width:this.select_width,tags:function(){return t._getTagsUsed()}}),this._setUpBehaviors(),this},_hashToName:function(t){return t.startsWith("#")?"name:"+t.slice(1):t},_nameToHash:function(t){return t.startsWith("name:")&&(t="#"+t.slice(5)),t},_defaultTemplate:function(){return[this.label,this._renderEditor()].join("")},_workflowTemplate:function(){return[this.show_editor?this._renderEditor():this._renderTags()].join(" ")},keydownHandler:function(t){switch(t.which){case 27:this.hideEditor()}},showEditor:function(){this.show_editor=!0,this.render()},hideEditor:function(){this.show_editor=!1,this.render()},_renderEditor:function(){return'<input class="tags-input" value="'+this.tagsToCSV()+'"/>'},_renderTags:function(){var t=this.model.get("tags"),e=[];return _.each(t,function(t){var i='<span class="label label-info">'+(t=0==t.indexOf("name:")?t.slice(5):t)+"</span>";e.push(i)}),0===e.length&&e.push('<img src=static/images/fugue/tag--plus.png class="add-tag-button" title="Add tags"/>'),e.join(" ")},tagsToCSV:function(){var t=this,e=this.model.get("tags");return!_.isArray(e)||_.isEmpty(e)?"":e.map(function(e){return _.escape(t._nameToHash(e))}).sort().join(",")},$input:function(){return this.$el.find("input.tags-input")},_getTagsUsed:function(){var t=this;return _.map(Galaxy.user.get("tags_used"),t._nameToHash)},_setUpBehaviors:function(){var t=this;this.$input().on("change",function(e){e.val=_.map(e.val,t._hashToName),t.model.save({tags:e.val}),e.added&&t._addNewTagToTagsUsed(e.added.text+"")})},_addNewTagToTagsUsed:function(t){var e=Galaxy.user.get("tags_used");_.contains(e,t)||(e.push(t),e.sort(),Galaxy.user.set("tags_used",e))},remove:function(){this.$input.off(),this.stopListening(this.model),Backbone.View.prototype.remove.call(this)},toString:function(){return["TagsEditor(",this.model+"",")"].join("")}});exports.default={TagsEditor:TagsEditor};
//# sourceMappingURL=../../maps/mvc/tag.js.map
+1 -1
View File
@@ -1,2 +1,2 @@
"use strict";define(["libs/bootstrap-tour"],function(t){var e="undefined"==typeof Galaxy?"/":Galaxy.root,o={storage:window.sessionStorage,onEnd:function(){sessionStorage.removeItem("activeGalaxyTour")},delay:150,orphan:!0},n=function(t){return _.each(t.steps,function(t){t.preclick&&(t.onShow=function(){_.each(t.preclick,function(t){$(t).click()})}),t.postclick&&(t.onHide=function(){_.each(t.postclick,function(t){$(t).click()})}),t.textinsert&&(t.onShown=function(){$(t.element).val(t.textinsert).trigger("change")})}),t},i=Backbone.Model.extend({urlRoot:e+"api/tours"}),r=Backbone.Collection.extend({url:e+"api/tours",model:i}),a=function(t){var i=e+"api/tours/"+t;$.getJSON(i,function(t){var e=n(t);sessionStorage.setItem("activeGalaxyTour",JSON.stringify(t));var i=new Tour(_.extend({steps:e.steps},o));i.init(),i.goTo(0),i.restart()})};return{ToursView:Backbone.View.extend({title:"Tours",initialize:function(){var t=this;this.setElement("<div/>"),this.model=new r,this.model.fetch({success:function(){t.render()},error:function(){console.error("Failed to fetch tours.")}})},render:function(){var t=_.template('<h2>Galaxy Tours</h2>\n<p>This page presents a list of interactive tours available on this Galaxy server.\nSelect any tour to get started (and remember, you can click \'End Tour\' at any time).</p>\n<ul>\n<% _.each(tours, function(tour) { %>\n <li>\n <a href="/tours/<%- tour.id %>" class="tourItem" data-tour.id=<%- tour.id %>>\n <%- tour.attributes.name || tour.id %>\n </a>\n - <%- tour.attributes.description || "No description given." %>\n </li>\n<% }); %>\n</ul>');this.$el.html(t({tours:this.model.models})).on("click",".tourItem",function(t){t.preventDefault(),a($(this).data("tour.id"))})}}),hooked_tour_from_data:n,tour_opts:o,giveTour:a}});
"use strict";function _interopRequireDefault(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(exports,"__esModule",{value:!0});var _bootstrapTour=require("libs/bootstrap-tour"),_bootstrapTour2=_interopRequireDefault(_bootstrapTour),gxy_root="undefined"==typeof Galaxy?"/":Galaxy.root,tourpage_template='<h2>Galaxy Tours</h2>\n<p>This page presents a list of interactive tours available on this Galaxy server.\nSelect any tour to get started (and remember, you can click \'End Tour\' at any time).</p>\n<ul>\n<% _.each(tours, function(tour) { %>\n <li>\n <a href="/tours/<%- tour.id %>" class="tourItem" data-tour.id=<%- tour.id %>>\n <%- tour.attributes.name || tour.id %>\n </a>\n - <%- tour.attributes.description || "No description given." %>\n </li>\n<% }); %>\n</ul>',tour_opts={storage:window.sessionStorage,onEnd:function(){sessionStorage.removeItem("activeGalaxyTour")},delay:150,orphan:!0},hooked_tour_from_data=function(t){return _.each(t.steps,function(t){t.preclick&&(t.onShow=function(){_.each(t.preclick,function(t){$(t).click()})}),t.postclick&&(t.onHide=function(){_.each(t.postclick,function(t){$(t).click()})}),t.textinsert&&(t.onShown=function(){$(t.element).val(t.textinsert).trigger("change")})}),t},TourItem=Backbone.Model.extend({urlRoot:gxy_root+"api/tours"}),Tours=Backbone.Collection.extend({url:gxy_root+"api/tours",model:TourItem}),giveTour=function(t){var o=gxy_root+"api/tours/"+t;$.getJSON(o,function(t){var o=hooked_tour_from_data(t);sessionStorage.setItem("activeGalaxyTour",JSON.stringify(t));var e=new Tour(_.extend({steps:o.steps},tour_opts));e.init(),e.goTo(0),e.restart()})},ToursView=Backbone.View.extend({title:"Tours",initialize:function(){var t=this;this.setElement("<div/>"),this.model=new Tours,this.model.fetch({success:function(){t.render()},error:function(){console.error("Failed to fetch tours.")}})},render:function(){var t=_.template(tourpage_template);this.$el.html(t({tours:this.model.models})).on("click",".tourItem",function(t){t.preventDefault(),giveTour($(this).data("tour.id"))})}});exports.default={ToursView:ToursView,hooked_tour_from_data:hooked_tour_from_data,tour_opts:tour_opts,giveTour:giveTour};
//# sourceMappingURL=../../maps/mvc/tours.js.map
+1 -1
View File
@@ -1,2 +1,2 @@
"use strict";define([],function(){var e=Backbone.Model.extend({defaults:{activate:!1}}),t=Backbone.Collection.extend({model:e}),o=Backbone.View.extend({el:"#webhook-view",initialize:function(t){var o=this,i=t.toolId||"",s=t.toolVersion||"";this.$el.attr("tool_id",i),this.$el.attr("tool_version",s),this.model=new e,this.model.urlRoot=t.urlRoot,this.model.fetch({success:function(){o.render()}})},render:function(){var e=this.model.toJSON();return this.$el.html('<div id="'+e.name+'"></div>'),e.styles&&$("<style/>",{type:"text/css"}).text(e.styles).appendTo("head"),e.script&&$("<script/>",{type:"text/javascript"}).text(e.script).appendTo("head"),this}});return{Webhooks:t,WebhookView:o,add:function(e){var o=new t;o.url=Galaxy.root+e.url,o.fetch({async:!e.async||e.async,success:e.callback})}}});
"use strict";
//# sourceMappingURL=../../maps/mvc/webhooks.js.map