From 6b5f0bdbfb621ab3e4ec0f23c000b780d030d47f Mon Sep 17 00:00:00 2001
From: xue <>
Date: Mon, 4 Dec 2006 03:15:22 +0000
Subject: merge from 3.0 branch till 1559.
---
framework/Web/UI/WebControls/TJavascriptLogger.php | 32 ++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
(limited to 'framework/Web/UI/WebControls')
diff --git a/framework/Web/UI/WebControls/TJavascriptLogger.php b/framework/Web/UI/WebControls/TJavascriptLogger.php
index a873d8d8..4f206ef4 100644
--- a/framework/Web/UI/WebControls/TJavascriptLogger.php
+++ b/framework/Web/UI/WebControls/TJavascriptLogger.php
@@ -32,6 +32,12 @@
*/
class TJavascriptLogger extends TWebControl
{
+ private static $_keyCodes = array(
+ '0'=>48, '1'=>49, '2'=>50, '3'=>51, '4'=>52, '5'=>53, '6'=>54, '7'=>55, '8'=>56, '9'=>57,
+ 'a'=>65, 'b'=>66, 'c'=>67, 'd'=>68, 'e'=>69, 'f'=>70, 'g'=>71, 'h'=>72,
+ 'i'=>73, 'j'=>74, 'k'=>75, 'l'=>76, 'm'=>77, 'n'=>78, 'o'=>79, 'p'=>80,
+ 'q'=>81, 'r'=>82, 's'=>83, 't'=>84, 'u'=>85, 'v'=>86, 'w'=>87, 'x'=>88, 'y'=>89, 'z'=>90);
+
/**
* @return string tag name of the panel
*/
@@ -40,13 +46,34 @@ class TJavascriptLogger extends TWebControl
return 'div';
}
+ /**
+ * @param string keyboard key for toggling the console, default is J.
+ */
+ public function setToggleKey($value)
+ {
+ $this->setViewState('ToggleKey', $value, 'j');
+ }
+
+ /**
+ * @return string keyboard key for toggling the console.
+ */
+ public function getToggleKey()
+ {
+ return $this->getViewState('ToggleKey', 'j');
+ }
+
/**
* Registers the required logger javascript.
* @param TEventParameter event parameter
*/
public function onPreRender($param)
{
- $this->getPage()->getClientScript()->registerPradoScript('logger');
+ $key = strtolower($this->getToggleKey());
+ $code = isset(self::$_keyCodes[$key]) ? self::$_keyCodes[$key] : 74;
+ $js = "var logConsole; Event.OnLoad(function() { logConsole = new LogConsole($code)}); ";
+ $cs = $this->getPage()->getClientScript();
+ $cs->registerBeginScript($this->getClientID(),$js);
+ $cs->registerPradoScript('logger');
}
/**
@@ -56,9 +83,10 @@ class TJavascriptLogger extends TWebControl
*/
public function renderContents($writer)
{
+ $code = strtoupper($this->getToggleKey());
$info = '(more info).';
$link = 'toggle the javascript log console.';
- $usage = 'Press ALT-D (Or CTRL-D on OS X) to';
+ $usage = 'Press ALT-'.$code.' (Or CTRL-'.$code.' on OS X) to';
$writer->write("{$usage} {$link} {$info}");
}
}
--
cgit v1.2.3