diff options
| author | Rob Hudson | 2009-08-28 12:07:26 -0700 | 
|---|---|---|
| committer | Rob Hudson | 2009-08-28 12:09:09 -0700 | 
| commit | 96966b8e86ca8a4a12359312d5ab7351d3788dfd (patch) | |
| tree | 4702d8f0d0ba3c0b5522034a5fe033609745f985 | |
| parent | 425d3245a43766ccc337094ca922598c9b55b8de (diff) | |
| download | django-debug-toolbar-96966b8e86ca8a4a12359312d5ab7351d3788dfd.tar.bz2 | |
Made ESC work on various toolbar states.
When toolbar is minimized, ESC key isn't bound.  Otherwise ESC will fall
through until one of the following happens: If a sub panel is opened, hide it ;
if a panel is open, close it ; if the toolbar is open, minimize it.
| -rw-r--r-- | debug_toolbar/media/debug_toolbar/toolbar.js | 50 | 
1 files changed, 34 insertions, 16 deletions
| diff --git a/debug_toolbar/media/debug_toolbar/toolbar.js b/debug_toolbar/media/debug_toolbar/toolbar.js index 7b6d534..ccd0185 100644 --- a/debug_toolbar/media/debug_toolbar/toolbar.js +++ b/debug_toolbar/media/debug_toolbar/toolbar.js @@ -16,8 +16,7 @@ jQuery(function($j) {  				    $j(document).trigger('close.djDebug');  					$j(this).parent().removeClass("active");  				} else { -					//$j('.panelContent').hide(); -					$j(document).trigger('close.djDebug'); +					$j('.panelContent').hide(); // Hide any that are already open  					current.show();  					$j.djDebug.open();  					$j('#djDebugToolbar li').removeClass("active"); @@ -63,11 +62,7 @@ jQuery(function($j) {  			}  		},  		open: function() { -			$j(document).bind('keydown.djDebug', function(e) { -				if (e.keyCode == 27) { -					$j.djDebug.close(); -				} -			}); +			// TODO: Decide if we should remove this  		},  		toggle_content: function(elem) {  			if (elem.is(':visible')) { @@ -81,9 +76,13 @@ jQuery(function($j) {  			return false;  		},  		hide_toolbar: function(setCookie) { -		    $j(document).trigger('close.djDebug'); -			$j('#djDebugToolbar').hide("fast"); +			// close any sub panels +			$j('#djDebugWindow').hide(); +			// close all panels +			$j('.panelContent').hide();  			$j('#djDebugToolbar li').removeClass("active"); +			// finally close toolbar +			$j('#djDebugToolbar').hide("fast");  			$j('#djDebugToolbarHandle').show();  			if (setCookie) {  				$j.cookie(COOKIE_NAME, 'hide', { @@ -93,6 +92,12 @@ jQuery(function($j) {  			}  		},  		show_toolbar: function() { +			// Set up keybindings +			$j(document).bind('keydown.djDebug', function(e) { +				if (e.keyCode == 27) { +					$j.djDebug.close(); +				} +			});  			$j('#djDebugToolbarHandle').hide();  			$j('#djDebugToolbar').show("fast");  			$j.cookie(COOKIE_NAME, null, { @@ -101,15 +106,28 @@ jQuery(function($j) {  			});  		},  		toggle_arrow: function(elem) { -            var uarr = String.fromCharCode(0x25b6); -            var darr = String.fromCharCode(0x25bc); -            elem.html(elem.html() == uarr ? darr : uarr); -        } +			var uarr = String.fromCharCode(0x25b6); +			var darr = String.fromCharCode(0x25bc); +			elem.html(elem.html() == uarr ? darr : uarr); +		}  	});  	$j(document).bind('close.djDebug', function() { -		$j(document).unbind('keydown.djDebug'); -		$j('.panelContent').hide() -		$j('#djDebugToolbar li').removeClass("active"); +		// If a sub-panel is open, close that +		if ($j('#djDebugWindow').is(':visible')) { +			$j('#djDebugWindow').hide(); +			return; +		} +		// If a panel is open, close that +		if ($j('.panelContent').is(':visible')) { +			$j('.panelContent').hide(); +			return; +		} +		// Otherwise, just minimize the toolbar +		if ($j('#djDebugToolbar').is(':visible')) { +			$j.djDebug.hide_toolbar(true); +			$j(document).unbind('keydown.djDebug'); +			return; +		}  	});  });  jQuery(function() { | 
