CXM_jquery.anubis
4.7 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
/*
* Created by PyramIDE.
* User: Jeremy
* Date: 21/08/2012
* Time: 16:52
*
*/
read 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,
jqlink,
jqflink,
jqscript.
/* 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, str) then
if target is
{
same then
if act_type is
{
jqform then "$('#"+str+"').submit();",
jqlink then "document.location='/?a="+str+"';",
jqflink then "document.location='"+str+"';",
jqscript then str
},
same(label) then
if act_type is
{
jqform then "$('#"+str+"').submit();",
jqlink then "document.location='/?a="+str+"';",
jqflink then "document.location='"+str+"';",
jqscript then str
},
other(window_name, window_options) then
if act_type is
{
jqform then "$('#"+str+"').submit();", //il s'agit d'une soumision d'un formulaire => cela se fait uniquement dans la même fenêtre !
jqlink then "window.open('"+str+"', '"+window_name+"', '"+jquery_button_get_onclick_action_window_options(window_options, "")+"');",
jqflink then "document.location='"+str+"';",
jqscript then str
}
}.
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 ]
.