CXM_jquery_button.anubis
5.66 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
* Created by PyramIDE.
* User: Jeremy
* Date: 07/09/2012
* Time: 15:10
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
read calexium_lib/web/CXM_making_a_web_site.anubis
read calexium_lib/web/CXM_jquery_icons.anubis
read tools/basis.anubis
read system/string.anubis
public type JQuery_button:
jQuery_button(
String button_id, String button_name, String button_label, JQuery_icon primary, JQuery_icon secondary // primary icon is for left icon, secondary icon is for right icon and button_id must set with an unique ID in order to have icons working
)
.
define HTML_Partial_Content
_jquery_buttons
(
List(JQuery_button) buttons,
List(HTML_Head_Tag) html_tags,
List(HTML_Off_Form) html_buttons
)
=
if buttons is
{
[ ] then
partial_content(
reverse(html_tags),
sequence(reverse(html_buttons))
),
[ h . t ] then
if h is jQuery_button(id, name, label, primary, secondary) then
if id = "" then // if the ID is not set => we can't use icons in the buttonset.
_jquery_buttons(
t,
html_tags,
[
literal("<input type=\"submit\" name=\""+name+"\" value=\""+label+"\">")
.
html_buttons
]
)
else
if jquery_icon_to_string(primary) = "" then
if jquery_icon_to_string(secondary) = "" then
_jquery_buttons(
t,
[
js_inline(script("", "$(document).ready(function(){$('#"+id+"').button();});"))
.
html_tags
],
[
literal("<input type=\"submit\" id=\""+id+"\" name=\""+name+"\" value=\""+label+"\">")
.
html_buttons
]
)
else
_jquery_buttons(
t,
[
js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{secondary:'"+jquery_icon_to_string(secondary)+"'}});});"))
.
html_tags
],
[
literal("<button id=\""+id+"\">"+label+"</button>")
.
html_buttons
]
)
else
if jquery_icon_to_string(secondary) = "" then
_jquery_buttons(
t,
[
js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"'}});});"))
.
html_tags
],
[
literal("<button id=\""+id+"\">"+label+"</button>")
.
html_buttons
]
)
else
_jquery_buttons(
t,
[
js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"',secondary:'"+jquery_icon_to_string(secondary)+"'}});});"))
.
html_tags
],
[
literal("<button id=\""+id+"\">"+label+"</button>")
.
html_buttons
]
)
}
.
public define HTML_Partial_Content
jquery_buttons
(
String buttons_container_id,
List(JQuery_button) buttons
)
=
if _jquery_buttons(buttons, [], []) is partial_content(tags, html) then
partial_content(
[ js_inline(script("", "$(document).ready(function(){$('#"+buttons_container_id+"').buttonset();});")) ] + tags,
sequence([
literal("<div id=\""+buttons_container_id+"\">"),
html,
literal("</div>")
])
)
.
public define HTML_Partial_Content
jquery_button
(
JQuery_button button
)
=
if button is jQuery_button(id, name, label, primary, secondary) then
if jquery_icon_to_string(primary) = "" then
if jquery_icon_to_string(secondary) = "" then
partial_content(
[
js_inline(script("", "$(document).ready(function(){$('#"+id+"').button();});"))
],
literal("<input type=\"submit\" id=\""+id+"\" name=\""+name+"\" value=\""+label+"\">")
)
else
partial_content(
[
js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{secondary:'"+jquery_icon_to_string(secondary)+"'}});});"))
],
literal("<button id=\""+id+"\">"+label+"</button>")
)
else
if jquery_icon_to_string(secondary) = "" then
partial_content(
[
js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"'}});});"))
],
literal("<button id=\""+id+"\">"+label+"</button>")
)
else
partial_content(
[
js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"',secondary:'"+jquery_icon_to_string(secondary)+"'}});});"))
],
literal("<button id=\""+id+"\">"+label+"</button>")
)
.