CXM_jquery_dialog.anubis
3.58 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
/*
* Created by PyramIDE.
* User: フランスのトトロ & julien
* Date: 09/11/2014
* Time: 15:51
* © Calexium
*/
read system/convert.anubis
read calexium_lib/web/CXM_making_a_web_site.anubis
read calexium_lib/web/CXM_jquery.anubis
public type JQuery_dialog_id:
dialog_id(String id).
public type JQuery_dialog:
p_content(HTML_Partial_Content content),
off_form(HTML_Off_Form o_form),
ajax(WEB_Action_Name url).
public define JQuery_dialog ajax(String url) = ajax(action_name(url)).
public type JQuery_dialog_size:
auto,
percent(Float w, Float h)
.
public define JQuery_dialog_size
percent
(
Float all
)=
percent(all, all).
public define HTML_Partial_Content
jq_dialog_create
(
JQuery_dialog_id dial_id,
JQuery_dialog content,
Bool autoOpen,
JQuery_dialog_size size,
String extra_param
)=
with dlg_id = id(dial_id),
js_str =
"
$( \"#"+dlg_id+"\" ).dialog({
autoOpen: "+to_String(autoOpen)+",
modal: true,
"+
if size is
{
auto then "height: 'auto', width: 'auto',",
percent(w, h) then "width: $(window).width() * "+w+", height: $(window).height() * "+h+","
}
+extra_param+"
Cancel: function() {
$( this ).dialog( 'close' );
}
});
",
js = js_inline(jquery_ready(js_str)),
if content is
{
p_content(pc) then
if pc is partial_content(tags, html) then
partial_content( [js . tags ], html), //html code of the dialog
off_form(html) then
partial_content( [js], html), //html code of the dialog
ajax(_url) then
with url = format_web_action_name(_url),
//println("jq_dialog_create : \njs_str ->"+js_str+"\nurl ->"+url);
partial_content( [js], div_empty([id(dlg_id), attr("ajax_url",url)]))
}.
public define HTML_Partial_Content
jq_dialog_create
(
JQuery_dialog_id dial_id,
JQuery_dialog content,
String extra_param
)=
jq_dialog_create(dial_id, content, false, auto, extra_param).
public define HTML_Partial_Content
jq_dialog_create
(
JQuery_dialog_id dial_id,
JQuery_dialog content
)=
jq_dialog_create(dial_id, content, false, auto, "").
public define HTML_Partial_Content
jq_dialog_create
(
JQuery_dialog_id dial_id,
JQuery_dialog content,
Bool autoOpen
)=
jq_dialog_create(dial_id, content, autoOpen, auto, "").
define String
_jq_dialog_open
(
Maybe(String) mb_html,
JQuery_dialog_id dialog_id,
String params
)=
with js_function = "CalexiumToolBox.jquery_dialog_click('"+id(dialog_id)+"', "+(if length(params)=0 then "''" else params) +");",
if mb_html is
{
failure then js_function,
success(html) then "<a onclick=\""+js_function+"\">"+html+"</a>"
}.
public define String
jq_dialog_open
(
String html,
JQuery_dialog_id dialog_id,
String params
)=
_jq_dialog_open(success(html), dialog_id, params).
public define HTML_Partial_Content
jq_dialog_open
(
String html,
JQuery_dialog_id dialog_id,
String params
)=
partial_content([],
literal(_jq_dialog_open(success(html), dialog_id, params))).
public define String
jq_dialog_open
(
JQuery_dialog_id dialog_id,
String params
)=
_jq_dialog_open(failure, dialog_id, params).
public define String
jq_dialog_open
(
JQuery_dialog_id dialog_id
)=
_jq_dialog_open(failure, dialog_id, "").
public define List(HTML_Head_Tag)
jq_dialog_init
=
[
js_inline(jquery_ready("
"))
].