ave-cms/lib/debug/debug.js

78 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-08-29 13:12:11 +03:00
var Debug = {
2018-04-19 19:11:58 +03:00
2019-08-29 13:12:11 +03:00
initialized: false,
2018-04-19 19:11:58 +03:00
2019-08-29 13:12:11 +03:00
init: function () {
2019-08-28 13:05:06 +03:00
2019-08-29 13:12:11 +03:00
if (this.initialized)
return;
2018-04-19 19:11:58 +03:00
2019-08-29 13:12:11 +03:00
this.initialized = true;
2018-04-19 19:11:58 +03:00
2019-08-29 13:12:11 +03:00
this.build();
this.events();
},
build: function () {
2019-08-29 14:10:36 +03:00
//
2019-08-29 13:12:11 +03:00
},
events: function () {
this.debugButton();
this.debugTabs();
},
debugButton: function () {
$('#debug_btn').on('click', function(event) {
event.preventDefault();
2019-08-29 14:10:36 +03:00
let $bar = $('#debug_bar');
2019-08-29 13:12:11 +03:00
2019-08-29 14:10:36 +03:00
if ($bar.css('display') === 'none') {
2019-08-29 13:12:11 +03:00
$(document.body).css('overflow', 'hidden');
$bar.show();
} else {
$(document.body).css('overflow', 'inherit');
$bar.hide();
}
2019-08-29 14:10:36 +03:00
Debug.debugStorage();
2019-08-29 13:12:11 +03:00
});
},
2019-08-28 13:05:06 +03:00
2019-08-29 13:12:11 +03:00
debugTabs: function () {
$('.debug_tabs > li').on('click', function(event) {
event.preventDefault();
$('.debug_tabs > li').removeClass('selected');
$('.debug_tab').hide();
$(this).addClass('selected');
$('#' + this.id + '-cont').show();
2019-08-29 14:10:36 +03:00
localStorage.setItem('__debug_bar', this.id);
2019-08-29 13:12:11 +03:00
});
},
2019-08-29 14:10:36 +03:00
debugStorage: function () {
let localValue = localStorage.getItem('__debug_bar');
if (localValue !== '') {
2019-08-29 13:12:11 +03:00
2019-08-29 14:10:36 +03:00
let tab = $('.debug_tabs > li#' + localValue);
2019-08-29 13:12:11 +03:00
if (tab.length > 0) {
tab.click();
}
2019-08-28 13:05:06 +03:00
}
}
2019-08-29 13:12:11 +03:00
};
2018-04-19 19:11:58 +03:00
2019-08-29 13:12:11 +03:00
$(document).ready(function() {
Debug.init();
});