debug-bar.dev.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. var wpDebugBar;
  2. (function($) {
  3. var api;
  4. wpDebugBar = api = {
  5. // The element that we will pad to prevent the debug bar
  6. // from overlapping the bottom of the page.
  7. body: undefined,
  8. init: function() {
  9. // If we're not in the admin, pad the body.
  10. api.body = $(document.body);
  11. api.toggle.init();
  12. api.tabs();
  13. api.actions.init();
  14. },
  15. toggle: {
  16. init: function() {
  17. $('#wp-admin-bar-debug-bar').click( function(e) {
  18. e.preventDefault();
  19. api.toggle.visibility();
  20. });
  21. },
  22. visibility: function( show ) {
  23. show = typeof show == 'undefined' ? ! api.body.hasClass( 'debug-bar-visible' ) : show;
  24. // Show/hide the debug bar.
  25. api.body.toggleClass( 'debug-bar-visible', show );
  26. // Press/unpress the button.
  27. $(this).toggleClass( 'active', show );
  28. }
  29. },
  30. tabs: function() {
  31. var debugMenuLinks = $('.debug-menu-link'),
  32. debugMenuTargets = $('.debug-menu-target');
  33. debugMenuLinks.click( function(e) {
  34. var t = $(this);
  35. e.preventDefault();
  36. if ( t.hasClass('current') )
  37. return;
  38. // Deselect other tabs and hide other panels.
  39. debugMenuTargets.hide().trigger('debug-bar-hide');
  40. debugMenuLinks.removeClass('current');
  41. // Select the current tab and show the current panel.
  42. t.addClass('current');
  43. // The hashed component of the href is the id that we want to display.
  44. $('#' + this.href.substr( this.href.indexOf( '#' ) + 1 ) ).show().trigger('debug-bar-show');
  45. });
  46. },
  47. actions: {
  48. init: function() {
  49. var actions = $('#debug-bar-actions');
  50. $('.maximize', actions).click( api.actions.maximize );
  51. $('.restore', actions).click( api.actions.restore );
  52. $('.close', actions).click( api.actions.close );
  53. },
  54. maximize: function() {
  55. api.body.removeClass('debug-bar-partial');
  56. api.body.addClass('debug-bar-maximized');
  57. },
  58. restore: function() {
  59. api.body.removeClass('debug-bar-maximized');
  60. api.body.addClass('debug-bar-partial');
  61. },
  62. close: function() {
  63. api.toggle.visibility( false );
  64. console.log( 'boo');
  65. }
  66. }
  67. };
  68. wpDebugBar.Panel = function() {
  69. };
  70. $(document).ready( wpDebugBar.init );
  71. })(jQuery);