public
Created

Debug Bar

  • Download Gist
debug-bar.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
var wpDebugBar;
(function(b) {
var a;
var vis = 'dbar_visibility';
var curtab = 'dbar_curtab';
var dbstate = 'dbar_state'
wpDebugBar = a = {
last: function() {
var index;
var state;
var c;
c = (b.cookie(vis) === '1') ? true : false;
a.body.toggleClass("debug-bar-visible", c);
 
index = parseInt(b.cookie(curtab)) || 0;
console.log(index);
b(".debug-menu-link").removeClass("current");
b(".debug-menu-link").eq(index).addClass('current');
b(".debug-menu-target").hide().trigger("debug-bar-hide");
b(".debug-menu-target").eq(index).show().trigger("debug-bar-show");
 
state = (b.cookie(dbstate) ==='1');
a.body.toggleClass("debug-bar-maximized", state);
a.body.toggleClass("debug-bar-partial", !state);
},
body: undefined,
init: function() {
a.body = b(document.body);
a.toggle.init();
a.tabs();
a.actions.init();
a.last();
},
toggle: {
init: function() {
b("#wp-admin-bar-debug-bar").click(function(c) {
c.preventDefault();
a.toggle.visibility()
});
},
visibility: function(c) {
c = typeof c == "undefined" ? !a.body.hasClass("debug-bar-visible") : c;
b.cookie(vis, (c==true) ? 1 : 0);
a.body.toggleClass("debug-bar-visible", c);
b(this).toggleClass("active", c)
}
},
tabs: function() {
var d = b(".debug-menu-link"),
c = b(".debug-menu-target");
d.click(function(g) {
var f = b(this);
g.preventDefault();
if (f.hasClass("current")) {
return
}
c.hide().trigger("debug-bar-hide");
d.removeClass("current");
f.addClass("current");
b.cookie(curtab, f.parent().index());
b("#" + this.href.substr(this.href.indexOf("#") + 1)).show().trigger("debug-bar-show")
})
},
actions: {
init: function() {
var c = b("#debug-bar-actions");
b(".maximize", c).click(a.actions.maximize);
b(".restore", c).click(a.actions.restore);
b(".close", c).click(a.actions.close)
},
maximize: function() {
a.body.removeClass("debug-bar-partial");
a.body.addClass("debug-bar-maximized");
b.cookie(dbstate, 1);
},
restore: function() {
a.body.removeClass("debug-bar-maximized");
a.body.addClass("debug-bar-partial");
b.cookie(dbstate, 0);
},
close: function() {
a.toggle.visibility(false);
b.cookie(vis, 0);
}
}
};
wpDebugBar.Panel = function() {};
b(document).ready(wpDebugBar.init);
 
})(jQuery);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.