Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * TEventTriggeredCallback class file.
4
 *
5
 * @author Wei Zhuo <weizhuo[at]gamil[dot]com>
6
 * @link http://www.pradosoft.com/
7
 * @copyright Copyright &copy; 2005-2008 PradoSoft
8
 * @license http://www.pradosoft.com/license/
9
 * @version $Id: TEventTriggeredCallback.php 2541 2008-10-21 15:05:13Z qiang.xue $
10
 * @package System.Web.UI.ActiveControls
11
 */
12
 
13
Prado::using('System.Web.UI.ActiveControls.TTriggeredCallback');
14
 
15
/**
16
 * TEventTriggeredCallback Class
17
 *
18
 * Triggers a new callback request when a particular {@link setEventName EventName}
19
 * on a control with ID given by {@link setControlID ControlID} is raised.
20
 *
21
 * The default action of the event on the client-side can be prevented when
22
 * {@link setPreventDefaultAction PreventDefaultAction} is set to true.
23
 *
24
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
25
 * @version $Id: TEventTriggeredCallback.php 2541 2008-10-21 15:05:13Z qiang.xue $
26
 * @package System.Web.UI.ActiveControls
27
 * @since 3.1
28
 */
29
class TEventTriggeredCallback extends TTriggeredCallback
30
{
31
	/**
32
	 * @return string The client-side event name the trigger listens to.
33
	 */
34
	public function getEventName()
35
	{
36
		return $this->getViewState('EventName', '');
37
	}
38
 
39
	/**
40
	 * Sets the client-side event name that fires the callback request.
41
	 * @param string The client-side event name the trigger listens to.
42
	 */
43
	public function setEventName($value)
44
	{
45
		$this->setViewState('EventName', $value, '');
46
	}
47
 
48
	/**
49
	 * @param boolean true to prevent/stop default event action.
50
	 */
51
	public function setPreventDefaultAction($value)
52
	{
53
		$this->setViewState('StopEvent', TPropertyValue::ensureBoolean($value), false);
54
	}
55
 
56
	/**
57
	 * @return boolean true to prevent/stop default event action.
58
	 */
59
	public function getPreventDefaultAction()
60
	{
61
		return $this->getViewState('StopEvent', false);
62
	}
63
 
64
	/**
65
	 * @return array list of timer options for client-side.
66
	 */
67
	protected function getTriggerOptions()
68
	{
69
		$options = parent::getTriggerOptions();
70
		$name = preg_replace('/^on/', '', $this->getEventName());
71
		$options['EventName'] = strtolower($name);
72
		$options['StopEvent'] = $this->getPreventDefaultAction();
73
		return $options;
74
	}
75
 
76
	/**
77
	 * Registers the javascript code for initializing the active control.
78
	 * @param THtmlWriter the renderer.
79
	 */
80
	public function render($writer)
81
	{
82
		parent::render($writer);
83
		$this->getActiveControl()->registerCallbackClientScript(
84
			$this->getClientClassName(), $this->getTriggerOptions());
85
	}
86
 
87
	/**
88
	 * @return string corresponding javascript class name for TEventTriggeredCallback.
89
	 */
90
	protected function getClientClassName()
91
	{
92
		return 'Prado.WebUI.TEventTriggeredCallback';
93
	}
94
}
95