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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
Prado.WebUI = Class.create();
//base postback-able controls
Prado.WebUI.PostBackControl = Class.create();
Object.extend(Prado.WebUI.PostBackControl.prototype,
{
initialize : function(options)
{
this.element = $(options['ID']);
if(options['CausesValidation'] && Prado.Validation)
Prado.Validation.AddTarget(options['ID'], options['ValidationGroup']);
//TODO: what do the following options do?
//options['PostBackUrl']
//options['ClientSubmit']
if(this.onInit)
this.onInit(options);
}
});
//short cut to create postback components
Prado.WebUI.createPostBackComponent = function(definition)
{
var component = Class.create();
Object.extend(component.prototype, Prado.WebUI.PostBackControl.prototype);
if(definition) Object.extend(component.prototype, definition);
return component;
}
Prado.WebUI.TButton = Prado.WebUI.createPostBackComponent();
Prado.WebUI.ClickableComponent = Prado.WebUI.createPostBackComponent(
{
onInit : function(options)
{
Event.observe(this.element, "click", Prado.PostBack.bindEvent(this,options));
}
});
Prado.WebUI.TLinkButton = Prado.WebUI.ClickableComponent;
Prado.WebUI.TCheckBox = Prado.WebUI.ClickableComponent;
Prado.WebUI.TRadioButton = Prado.WebUI.ClickableComponent;
Prado.WebUI.TBulletedList = Prado.WebUI.ClickableComponent;
Prado.WebUI.TTextBox = Prado.WebUI.createPostBackComponent(
{
onInit : function(options)
{
if(options['TextMode'] != 'MultiLine')
Event.observe(this.element, "keypress", this.handleReturnKey.bind(this));
Event.observe(this.element, "change", Prado.PostBack.bindEvent(this,options));
},
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;
}
});
Prado.WebUI.TListControl = Prado.WebUI.createPostBackComponent(
{
onInit : function(options)
{
Event.observe(this.element.id, "change", Prado.PostBack.bindEvent(this,options));
}
});
Prado.WebUI.TListBox = Prado.WebUI.TListControl;
Prado.WebUI.TDropDownList = Prado.WebUI.TListControl;
//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).tagName.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;
}
});*/
|