CXM_jquery.anubis
6.44 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*
* Created by PyramIDE.
* User: Jeremy
* Date: 21/08/2012
* Time: 16:52
*
*/
transmit calexium_lib/web/CXM_making_a_web_site.anubis
read tools/printable_tree.anubis
read tools/basis.anubis
/* jQuery Actioner type */
public type JQuery_Actioner_type:
jqform ( String form),
jqlink ( WEB_Action_Name name),
jqflink ( String link),
jqscript( String script)
.
public define JQuery_Actioner_type jqlink(String name) = jqlink(action_name(name)).
/* jQuery Actioner */
public type JQuery_Actioner:
jQuery_actioner(Actioner_Target target, JQuery_Actioner_type type). //, String url_or_form_id_or_script
/* jQuery Selector - http://api.jquery.com/category/selectors/ */
public type JQuerySelector:
element(HTML_Id id),
element_class(String name),
childs(HTML_Id id).
define String
jquery_button_get_onclick_action_window_options
(
List(Other_Window_Option) options,
String formated_options
)
=
//if there is already formated_options add a comma + space between the options
with comma = if formated_options="" then "" else ", ",
if options is
{
[ ] then formated_options,
[ c . t ] then
if c is
{
resizable then jquery_button_get_onclick_action_window_options(
t, formated_options+ comma + "resizable=yes"),
scrollbars then jquery_button_get_onclick_action_window_options(
t, formated_options+ comma + "scrollbars=yes"),
width(w) then jquery_button_get_onclick_action_window_options(
t, formated_options+ comma + "width="+w),
height(h) then jquery_button_get_onclick_action_window_options(
t, formated_options+ comma + "height="+h)
}
}
.
public define String
jquery_button_get_onclick_action
(
JQuery_Actioner actioner
)
=
if actioner is jQuery_actioner(target, act_type) then
if target is
{
same then
if act_type is
{
jqform(form) then "$('#"+form+"').submit();",
jqlink(control_action) then
if control_action is
{
no_action then "",
controller_action(ctrl, action) then "document.location='/?aws_controller="+ctrl+"&aws_action="+action+"';",
action_name(action) then "document.location='/?aws_action="+action+"';",
url(url) then "document.location='"+url+"';",
}
jqflink(link) then "document.location='"+link+"';",
jqscript(script) then script
},
same(label) then
if act_type is
{
jqform(form) then "$('#"+form+"').submit();",
jqlink(control_action) then
if control_action is
{
no_action then "",
controller_action(ctrl, action) then "document.location='/?aws_controller="+ctrl+"&aws_action="+action+"';",
action_name(action) then "document.location='/?aws_action="+action+"';",
url(url) then "document.location='"+url+"';",
}
jqflink(link) then "document.location='"+link+"';",
jqscript(script) then script
},
other(window_name, window_options) then
if act_type is
{
jqform(form) then "$('#"+form+"').submit();",//il s'agit d'une soumision d'un formulaire => cela se fait uniquement dans la même fenêtre !
jqlink(control_action) then
if control_action is
{
no_action then "",
controller_action(ctrl, action) then
"window.open('aws_controller="+ctrl+"&aws_action="+action+"', '"+window_name+"', '"+jquery_button_get_onclick_action_window_options(window_options, "")+"');",
//"document.location='/?aws_controller="+ctrl+"&aws_action="+action+"';",
action_name(action) then
"window.open('"+action+"', '"+window_name+"', '"+jquery_button_get_onclick_action_window_options(window_options, "")+"');",
url(url) then "document.location='"+url+"';",
}
jqflink(link) then "document.location='"+link+"';",
jqscript(script) then script
}
}.
public define String
format_jquery_selector
(
JQuerySelector selector
) =
if selector is
{
element(html_id) then
if html_id is html_Id(id) then "'#" + id + "'",
element_class(name) then
"'." + name + "'",
childs(html_id) then
if html_id is html_Id(id) then "'#" + id + " > *'"
}.
/* */
public define Script
jquery_ready
(
String code //javascript code to execute when the document is ready
)=
script("text/javascript","$(document).ready(function(){"+code+"});").
public define String
jquery_ready
(
String code //javascript code to execute when the document is ready
)=
"$(document).ready(function(){"+code+"});".
/* jQuery default js files */
define List(HTML_Head_Tag)
jquery_defaults
=
[
js(js_file("/js/jquery/jquery-1.11.3.min.js")),
js(js_file("/js/jquery/jquery-ui-1.11.4/jquery-ui.min.js")),
].
/* Initialize jQuery in compatiblity mode with jQueryUI */
public define List(HTML_Head_Tag)
jquery_init
(
String web_dir,
String theme_name
)
=
if file_exists(web_dir+"/public/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.min.css") then
[ css(css_file("/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.min.css")),
css(css_file("/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.structure.min.css")),
css(css_file("/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.theme.min.css")) . jquery_defaults ]
else
println("Jquery Theme not found "+web_dir+"/public/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.min.css");
//TODO change to real default jquery ui css
[ css(css_file("/js/jquery/jquery-ui-1.11.4/theme/"+theme_name+"/jquery-ui.min.css")) . jquery_defaults ]
.