CXM_jquery_eudock.anubis
7.11 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*
* Created by PyramIDE.
* User: Jeremy
* Date: 18/09/2012
* Time: 17:28
*
* 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.anubis
read calexium_lib/web/CXM_jquery_eudock_types.anubis
read tools/basis.anubis
read system/string.anubis
read system/convert.anubis
/********************************************************************************************************/
/********************************************************************************************************/
/********************************************************************************************************/
/********************************************************************************************************/
/**************************************** ATTENTION !!! *******************************************/
/************* Le mode 'object_alignment' n'est pas fonctionnel : NE PAS L'UTILISER ! ****************/
/************************ Un recodage en jQuery de la lib JS est à prévoir **************************/
/********************************************************************************************************/
/********************************************************************************************************/
/********************************************************************************************************/
/********************************************************************************************************/
/* jQuery euDock initialization */
public define List(HTML_Head_Tag)
jquery_eudock_init
(
String web_dir,
)
=
[
js(js_file("/js/jquery/euDock.2.0.js")),
//js(js_file("/js/jquery/euDock.Blank.js")), // not needed for now
//js(js_file("/js/jquery/euDock.DivMousePos.js")), // not needed for now
//js(js_file("/js/jquery/euDock.Ghost.js")), // not needed for now
js(js_file("/js/jquery/euDock.Image.js")),
//js(js_file("/js/jquery/euDock.Label.js")) // not needed for now
]
.
/* Recursive format of the bar */
define String
_jquery_eudock_format_bar
(
List(JQ_eudock_imagebar) bar_images,
String formatted
)
=
if bar_images is
{
[] then formatted,
[ h . t ] then
if h is
{
jq_eudock_bar_top(image) then
if t is
{
[] then _jquery_eudock_format_bar(t, formatted+"top :{euImage:{image:'"+image.image_url+"'}}"),
[ h . t] then _jquery_eudock_format_bar(t, formatted+"top :{euImage:{image:'"+image.image_url+"'}},")
},
jq_eudock_bar_vertical(image) then
if t is
{
[] then _jquery_eudock_format_bar(t, formatted+"vertical :{euImage:{image:'"+image.image_url+"'}}"),
[ h . t] then _jquery_eudock_format_bar(t, formatted+"vertical :{euImage:{image:'"+image.image_url+"'}},")
},
jq_eudock_bar_bottom(image) then
if t is
{
[] then _jquery_eudock_format_bar(t, formatted+"bottom :{euImage:{image:'"+image.image_url+"'}}"),
[ h . t] then _jquery_eudock_format_bar(t, formatted+"bottom :{euImage:{image:'"+image.image_url+"'}},")
},
jq_eudock_bar_left(image) then
if t is
{
[] then _jquery_eudock_format_bar(t, formatted+"left :{euImage:{image:'"+image.image_url+"'}}"),
[ h . t] then _jquery_eudock_format_bar(t, formatted+"left :{euImage:{image:'"+image.image_url+"'}},")
},
jq_eudock_bar_horizontal(image) then
if t is
{
[] then _jquery_eudock_format_bar(t, formatted+"horizontal :{euImage:{image:'"+image.image_url+"'}}"),
[ h . t] then _jquery_eudock_format_bar(t, formatted+"horizontal :{euImage:{image:'"+image.image_url+"'}},")
},
jq_eudock_bar_right(image) then
if t is
{
[] then _jquery_eudock_format_bar(t, formatted+"right :{euImage:{image:'"+image.image_url+"'}}"),
[ h . t] then _jquery_eudock_format_bar(t, formatted+"right :{euImage:{image:'"+image.image_url+"'}},")
}
}
}
.
/* Format the bar */
define String
jquery_eudock_format_bar
(
String dockname,
JQ_eudock_bar bar
)
=
dockname+".setBar({"+
_jquery_eudock_format_bar(bar.bar_images, "")+
"});"
.
/* Format 1 icon */
define String
_jquery_eudock_format_icon
(
String dockname,
JQ_euDock_Icon icon
)
=
if icon is jq_eudock_icon(icon_image, link) then
" "+dockname+".addIcon(new Array({euImage:{image:'"+icon_image.image_url+"'}}), {link:'"+link+"'});\n" // space added at the beginning to avoid any js syntax error
.
/* Format icons */
define String
_jquery_eudock_format_icons
(
String dockname,
List(JQ_euDock_Icon) icons,
String formatted
)
=
if icons is
{
[] then formatted,
[ h . t ] then
_jquery_eudock_format_icons(dockname, t, formatted+ _jquery_eudock_format_icon(dockname, h))
}
.
/* Format icons */
define String
jquery_eudock_format_icons
(
String dockname,
List(JQ_euDock_Icon) icons
)
=
_jquery_eudock_format_icons(dockname, icons, "")
.
/* Format alignment */
define String
jquery_eudock_format_alignment
(
String dockname,
JQ_euDock_alignment alignment
)
=
if alignment is
{
jq_eudock_screen_alignment(a, o) then
dockname+".setScreenAlign("+jq_eudock_align_to_string(a)+", "+o+");",
jq_eudock_object_alignment(o_id, o_al, o, p) then
dockname+".setObjectAlign('"+o_id+"', "+jq_eudock_object_align_to_string(o_al)+", "+o+", "+jq_eudock_position_to_string(p)+");",
jq_eudock_fixed_alignment(x, y, p) then
dockname+".setPointAlign("+x+", "+y+", "+jq_eudock_position_to_string(p)+");"
}
// "+dockname+".setScreenAlign("+jq_eudock_position_to_string(position)+",0);
.
/* Creation of an euDock */
public define HTML_Partial_Content
jquery_eudock
(
JQ_euDock dock
)
=
with dockname="dock_"+now, // dock name is suffixed with a timestamp to guarantee its uniqueness
if dock is jq_eudock(bar, icons, icon_offset, alignment) then
partial_content
(
[
js_inline(script("", "
euEnv.imageBasePath=\"\";
var "+dockname+"=new euDock();
"+jquery_eudock_format_alignment(dockname, alignment)+"
"+jquery_eudock_format_bar(dockname, bar)+"
"+dockname+".setIconsOffset("+icon_offset+");
"+jquery_eudock_format_icons(dockname, icons)+"
"))
],
literal("") // euDock does not need to return HTML content => it's javascript only !
)
.