Files

35 lines
707 B
JavaScript
Raw Permalink Normal View History

2015-02-14 17:14:22 -05:00
/**
* Module that takes care of header buttons
*/
var Header = {
init: function(options) {
this.options = $.extend(
this.options,
options
);
},
options: {}, // Nothing for now
canTravel: function() {
return $('div#header div.headerButton').length > 1;
},
2023-06-09 12:38:16 -04:00
addLocation: function(text, id, module, before) {
const toAdd = $('<div>').attr('id', "location_" + id)
2015-02-14 17:14:22 -05:00
.addClass('headerButton')
.text(text).click(function() {
if(Header.canTravel()) {
Engine.travelTo(module);
}
2023-06-09 12:38:16 -04:00
});
if (before && $(`#location_${before}`).length > 0) {
return toAdd.insertBefore(`#location_${before}`);
}
return toAdd.appendTo($('div#header'));
2015-02-14 17:14:22 -05:00
}
2023-06-09 12:38:16 -04:00
};