2 typeof define === "function" ? function (m) { define("kismet-ui-tabpane-js", m); } :
3 typeof exports === "object" ? function (m) { module.exports = m(); } :
4 function(m){ this.kismet_ui_tabpane = m(); }
11 var local_uri_prefix = "";
12 if (typeof(KISMET_URI_PREFIX) !== 'undefined')
13 local_uri_prefix = KISMET_URI_PREFIX;
15 // Flag we're still loading
16 exports.load_complete = 0;
24 href: local_uri_prefix + 'css/kismet.ui.tabpane.css'
31 * By default adds to the 'south' container, which previously was the only tab holder available.
33 * Options is a dictionary which must include:
35 * id: id for created div
36 * tabTitle: Title show in tab bar
37 * createCallback: function called after the div is created, passed the new div
39 * priority: order priority in list (optional)
41 exports.AddTab = function(options, group="south") {
42 if (!('id' in options) ||
43 !('tabTitle' in options) ||
44 !('createCallback' in options)) {
48 if (!('priority' in options)) {
52 if (!('expandable' in options)) {
53 options.expandable = false;
56 if (!('expandCallback' in options)) {
57 options.expandCallback = null;
60 options.expanded = false;
62 if (group in tabholders) {
63 for (var x = 0; x < tabholders[group].TabItems.length; x++) {
64 if (tabholders[group].TabItems[x].id == options["id"]) {
65 tabholders[group].TabItems.splice(x, 1);
70 tabholders[group].TabItems.push(options);
78 exports.RemoveTab = function(id, group="south") {
80 for (var x = 0; x < tabholders[group].TabItems.length; x++) {
81 if (tabholders[group].TabItems[x].id == id) {
82 tabholders[group].TabItems.splice(x, 1);
87 alert(`UI attempted to remove tab ${id} from invalid group ${group}`);
91 function createListCallback(c) {
97 function createExpanderCallback(c, group) {
99 MoveToExpanded(c, group);
103 function populateList(div, group) {
104 if (group in tabholders) {
105 tabholders[group].TabDiv = div;
107 tabholders[group] = {
113 tabholders[group].TabItems.sort(function(a, b) {
114 if (a.priority < b.priority)
116 if (a.priority > b.priority)
125 id: `tabpane_ul_${group}`
130 for (var i in tabholders[group].TabItems) {
131 var c = tabholders[group].TabItems[i];
133 var title = c.tabTitle;;
136 title += ' <i class="fa fa-expand pseudolink"></i>';
149 $('i', ul).tooltipster({content: 'Expand tab to own window'});
152 $('i', ul).on('click', createExpanderCallback(c, group));
164 c.createCallback(td);
169 activate: function(e, ui) {
170 var id = $('a', ui.newTab).attr('href');
171 kismet.putStorage(`kismet.base.${group}.last_tab`, id);
175 var lasttab = kismet.getStorage(`kismet.base.${group}.last_tab`, '');
176 $('a[href="' + lasttab + '"]', div).click();
179 function MoveToExpanded(tab, group) {
180 var div = $('div#' + tab.id, tabholders[group].TabDiv);
182 var placeholder = $('<div>', {
183 id: 'original_' + tab.id,
185 .html("Content moved to window");
199 tab.jspanel = $.jsPanel({
201 headerTitle: tab.tabTitle,
205 content: panelcontainer,
206 onclosed: function() {
207 placeholder.replaceWith(original);
208 tabholders[group].TabDiv.tabs("refresh");
212 div.replaceWith(placeholder);
214 // Take out the fixed height and width imposed by tab width
215 original.removeProp('height');
216 original.removeProp('width');
217 original.css('height', '');
218 original.css('width', '');
220 $('#target', panelcontainer).replaceWith(original);
224 var w = $(window).width() * 0.75;
225 var h = $(window).height() * 0.5;
228 if ($(window).width() < 450 || $(window).height() < 450) {
229 w = $(window).width() - 5;
230 h = $(window).height() - 5;
245 // Call the tab expansion callback
246 if (('expandCallback' in tab) && tab['expandCallback'] != null) {
247 tab['expandCallback'](jspanel);
252 // Populate the sidebar content in the supplied div
253 exports.MakeTabPane = function(div, group) {
254 populateList(div, group);
257 // We're done loading
258 exports.load_complete = 1;