blob: 52bf2b890137a3917d253fa72a3164683aed9aef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
var Prado = { Version: '3.0a' };
Prado.Button = Class.create();
/**
* Usage: Event.observe("panelID", "keypress", Prado.fireButton.bindEvent($("panelID"), "targetButtonID"));
*/
Object.extend(Prado.Button,
{
buttonFired : false,
fireButton : function(e, target)
{
var eventFired = !this.buttonFired && Event.keyCode(e) == Event.KEY_RETURN;
var isTextArea = Event.element(e).targName.toLowerCase() == "textarea";
if (eventFired && !isTextArea)
{
var defaultButton = $(target);
if (defaultButton)
{
Prado.Button.buttonFired = true;
Event.fireEvent(defaultButton,"click");
Event.stop(e);
return false;
}
}
return true;
}
});
Prado.TextBox = Class.create();
/**
* Usage: Event.observe("textboxID", "keypress", Prado.fireButton.bindEvent($("textboxID")));
*/
Object.extend(Prado.TextBox,
{
handleReturnKey = function(e)
{
if(Event.keyCode(e) == Event.KEY_RETURN)
{
var target = Event.element(e);
if(target)
{
Event.fireEvent(target, "change");
Event.stop(e);
return false;
}
}
return true;
}
});
|