CXM_jquery_tabs.anubis
2.28 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
/*
* Created by PyramIDE.
* User: Jeremy
* Date: 04/09/2012
* Time: 16:19
*
* 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 tools/basis.anubis
public type JQuery_tab:
jQuery_tab(String title, HTML_Partial_Content content)
.
// Helper to be compatible with the first version of JQuery_tab which
// take HTML_Off_Form as second argument instead of HTML_Partial_Content.
public define JQuery_tab
jQuery_tab
(
String title,
HTML_Off_Form content
)=
jQuery_tab(title, partial_content([], content)).
define HTML_Partial_Content
_jquery_tabs
(
String tabs_container_id,
List(JQuery_tab) tabs,
String tabs_titles,
List(HTML_Off_Form) tabs_contents,
List(HTML_Head_Tag) tabs_heads,
Int count
)
=
if tabs is
{
[ ] then
partial_content(
reverse(tabs_heads),
sequence([
literal("<ul>"+tabs_titles+"</ul>"),
sequence(reverse(tabs_contents))
])
),
[ h . t ] then
if h is jQuery_tab(title, p_content) then
if p_content is partial_content(tags, content) then
_jquery_tabs(
tabs_container_id,
t,
tabs_titles + "<li><a href=\"#"+tabs_container_id+"-tab-"+count+"\">"+title+"</a></li>",
[
sequence([
literal("<div id=\""+tabs_container_id+"-tab-"+count+"\">"),
content,
literal("</div>")
])
.
tabs_contents
],
tags + tabs_heads,
count+1
)
}
.
public define HTML_Partial_Content
jquery_tabs
(
String tabs_container_id,
List(JQuery_tab) tabs
)
=
if _jquery_tabs(tabs_container_id, tabs, "", [], [], 0) is partial_content(tags, html) then
partial_content(
[
js_inline(jquery_ready("$('#"+tabs_container_id+"').tabs();"))
.
tags
],
sequence([
literal("<div id=\""+tabs_container_id+"\">"),
html,
literal("</div>")
])
)
.