Skip to content

Instantly share code, notes, and snippets.

@adis-io
Created August 20, 2012 12:54
Show Gist options
  • Save adis-io/3403824 to your computer and use it in GitHub Desktop.
Save adis-io/3403824 to your computer and use it in GitHub Desktop.
Debug Bar
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment