Build client/formatting.

This commit is contained in:
Dannon Baker
2017-10-24 14:07:06 -04:00
parent a3c00c122c
commit 4dc97ceb59
5 changed files with 18 additions and 12 deletions
+14 -8
View File
@@ -136,15 +136,15 @@ Select any tour to get started (and remember, you can click 'End Tour' at any ti
var tourtags = {};
_.each(this.model.models, function(tour) {
if(tour.attributes.tags === null) {
if(tourtags[""] === undefined) {
tourtags[""] = {"name": "Untagged", "tours": []};
if (tour.attributes.tags === null) {
if (tourtags[""] === undefined) {
tourtags[""] = { name: "Untagged", tours: [] };
}
tourtags[""]["tours"].push(tour);
} else {
_.each(tour.attributes.tags, function (tag) {
_.each(tour.attributes.tags, function(tag) {
if (tourtags[tag] === undefined) {
tourtags[tag] = {"name": tag, "tours": []};
tourtags[tag] = { name: tag, tours: [] };
}
tourtags[tag]["tours"].push(tour);
});
@@ -153,7 +153,13 @@ Select any tour to get started (and remember, you can click 'End Tour' at any ti
var tourtagorder = Object.keys(tourtags).sort();
this.$el
.html(tpl({ tours: this.model.models, tourtags: tourtags, tourtagorder: tourtagorder}))
.html(
tpl({
tours: this.model.models,
tourtags: tourtags,
tourtagorder: tourtagorder
})
)
.on("click", ".tourItem", function(e) {
e.preventDefault();
giveTour($(this).data("tour.id"));
@@ -166,10 +172,10 @@ Select any tour to get started (and remember, you can click 'End Tour' at any ti
elem.toggleClass("btn-primary");
elem.toggleClass("btn-secondary");
if(elem.hasClass("btn-secondary")) {
if (elem.hasClass("btn-secondary")) {
display = "none";
}
$("div[tag='"+tag+"']").css({display: display});
$("div[tag='" + tag + "']").css({ display: display });
});
}
});
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 @@
"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";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},a=Backbone.Model.extend({urlRoot:e+"api/tours"}),r=Backbone.Collection.extend({url:e+"api/tours",model:a}),s=function(t){var a=e+"api/tours/"+t;$.getJSON(a,function(t){var e=n(t);sessionStorage.setItem("activeGalaxyTour",JSON.stringify(t));var a=new Tour(_.extend({steps:e.steps},o));a.init(),a.goTo(0),a.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\n<div class="col-12 btn-group" role="group" aria-label="Tag selector">\n <% _.each(tourtagorder, function(tag) { %>\n <button class="btn btn-primary tag-selector-button" tag-selector-button="<%- tag %>">\n <%- tag %>\n </button>\n <% }); %>\n</div>\n\n<% _.each(tourtagorder, function(tourtagkey) { %>\n<div tag="<%- tourtagkey %>" style="display: block;">\n <% var tourtag = tourtags[tourtagkey]; %>\n <h4>\n <%- tourtag.name %>\n </h4>\n <ul class="list-group">\n <% _.each(tourtag.tours, function(tour) { %>\n <li class="list-group-item">\n <a href="/tours/<%- tour.id %>" class="tourItem" data-tour.id=<%- tour.id %>>\n <%- tour.name || tour.id %>\n </a>\n - <%- tour.attributes.description || "No description given." %>\n <% _.each(tour.attributes.tags, function(tag) { %>\n <span class="label label-primary">\n <%- tag %>\n </span>\n <% }); %>\n </li>\n <% }); %>\n </ul>\n</div>\n<% }); %>'),e={};_.each(this.model.models,function(t){null===t.attributes.tags?(void 0===e[""]&&(e[""]={name:"Untagged",tours:[]}),e[""].tours.push(t)):_.each(t.attributes.tags,function(o){void 0===e[o]&&(e[o]={name:o,tours:[]}),e[o].tours.push(t)})});var o=Object.keys(e).sort();this.$el.html(t({tours:this.model.models,tourtags:e,tourtagorder:o})).on("click",".tourItem",function(t){t.preventDefault(),s($(this).data("tour.id"))}).on("click",".tag-selector-button",function(t){var e=$(t.target),o="block",n=e.attr("tag-selector-button");e.toggleClass("btn-primary"),e.toggleClass("btn-secondary"),e.hasClass("btn-secondary")&&(o="none"),$("div[tag='"+n+"']").css({display:o})})}}),hooked_tour_from_data:n,tour_opts:o,giveTour:s}});
//# sourceMappingURL=../../maps/mvc/tours.js.map