CXM_jquery_tabs.anubis
3.17 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
/*
* Created by PyramIDE.
* User: Jeremy
* Date: 04/09/2012
* Time: 16:19
*
*
*/
read calexium_lib/web/CXM_making_a_web_site.anubis
read calexium_lib/web/CXM_jquery.anubis
read calexium_lib/web/CXM_common.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(
tabs_heads,
sequence([
ul(tabs_titles),
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>",
[
div([id(tabs_container_id+"-tab-"+count)], content)
.
tabs_contents
],
tabs_heads + tags ,
count+1
)
}
.
public define HTML_Partial_Content
jquery_tabs
(
String tabs_container_id,
List(JQuery_tab) tabs,
List(Web_arg) lwa
)
=
with index_str = if web_arg_value(lwa, "jq_tabs_" + tabs_container_id) is
{
not_found then "0",
found(ps) then ps
},
if _jquery_tabs(tabs_container_id, tabs, "", [], [], 0) is partial_content(tags, html) then
partial_content(
[
js_inline(jquery_ready("
$('#"+tabs_container_id+"').tabs({
active: " + index_str + ",
activate: function( event, ui ) {
ui.newPanel.find('input[name=jq_tabs_" + tabs_container_id + "]').each(function () {
$(this).attr('value', ui.newTab.index());
});
if (typeof CalexiumToolBox !== 'undefined' && typeof CalexiumToolBox.jq_tab_activate !== 'undefined') {
CalexiumToolBox.jq_tab_activate(event, ui);
}
},
create: function( event, ui ) {
$('#"+tabs_container_id+"').find('form').prepend('<input type=\"hidden\" name=\"jq_tabs_" + tabs_container_id + "\" value=\"'+ui.tab.index()+'\">');
}
});
"))
.
tags
],
div([id(tabs_container_id)], html)
).
public define HTML_Partial_Content
jquery_tabs
(
String tabs_container_id,
List(JQuery_tab) tabs
)
=
jquery_tabs(tabs_container_id, tabs, []).