8 |
|
|
9 |
var css_rnd = 0; |
var css_rnd = 0; |
10 |
|
|
|
function iwfRequest( url, div ) { |
|
|
Logger.info('iwfRequest('+url+','+div+')'); |
|
|
return; |
|
|
} |
|
|
|
|
11 |
function update_status(text) { |
function update_status(text) { |
12 |
var el = $('div_record_nr'); |
var el = $('div_record_nr'); |
13 |
if (el) el.innerHTML = text; |
if (el) el.innerHTML = text; |
15 |
|
|
16 |
function load_rec(nr) { |
function load_rec(nr) { |
17 |
Logger.debug('load_rec '+nr); |
Logger.debug('load_rec '+nr); |
18 |
|
|
19 |
|
if (loading.record) { |
20 |
|
Logger.info('loading of record '+nr+' skipped, load in progress'); |
21 |
|
return; |
22 |
|
} |
23 |
|
|
24 |
|
show_working(); |
25 |
|
$('record_nr').disabled = 'true'; |
26 |
|
|
27 |
if (nr == 1) { |
if (nr == 1) { |
28 |
Element.hide('a_left_arr'); |
Element.addClassName('a_left_arr', 'nav_disable'); |
29 |
} else { |
} else { |
30 |
Element.show('a_left_arr'); |
Element.removeClassName('a_left_arr', 'nav_disable'); |
31 |
} |
} |
32 |
update_status(nr+'...'); |
|
33 |
iwfRequest( url+'/xml/?template='+template_filename+'&rec='+nr, 'div_record' ); |
var args = '?mfn='+nr+'&template_filename='+template_filename; |
34 |
new Effect.Opacity('div_record', { from: 1.0, to: 0.7, duration: 0.3 }); |
|
35 |
|
new Ajax.Updater( 'div_record', url+'record'+args, { |
36 |
|
asynchronous: 1, |
37 |
|
onLoading: function(request) { |
38 |
|
loading.record = 1; |
39 |
|
Logger.info('load_rec.onLoading: '+nr); |
40 |
|
}, |
41 |
|
onLoaded: function(request) { |
42 |
|
loading.record = 0; |
43 |
|
hide_working(); |
44 |
|
$('record_nr').value = nr; |
45 |
|
$('record_nr').disabled = ''; |
46 |
|
rec = nr; |
47 |
|
Logger.info('load_rec.onLoaded: '+nr); |
48 |
|
} |
49 |
|
} ) ; |
50 |
|
|
51 |
} |
} |
52 |
|
|
53 |
function inc_rec() { |
function inc_rec() { |
54 |
|
show_working(); |
55 |
rec++; |
rec++; |
56 |
load_rec(rec); |
load_rec(rec); |
57 |
|
hide_working(); |
58 |
return false; |
return false; |
59 |
} |
} |
60 |
|
|
61 |
function dec_rec() { |
function dec_rec() { |
62 |
if (rec > 1) { |
if (rec > 1) { |
63 |
|
show_working(); |
64 |
rec--; |
rec--; |
65 |
load_rec(rec); |
load_rec(rec); |
66 |
|
hide_working(); |
67 |
} |
} |
68 |
return false; |
return false; |
69 |
} |
} |
70 |
|
|
71 |
function reload_rec() { |
function reload_rec() { |
72 |
|
show_working(); |
73 |
load_rec(rec); |
load_rec(rec); |
74 |
|
hide_working(); |
75 |
return false; |
return false; |
76 |
} |
} |
77 |
|
|
78 |
|
var current_edit = ''; |
79 |
|
|
80 |
function edit_template() { |
function edit_template() { |
81 |
Effect.Fade('div_css'); |
$('div_css').style.visibility = "hidden"; |
82 |
Effect.Appear('div_template'); |
$('div_css').style.zIndex = 1; |
83 |
|
Element.removeClassName('a_css', 'tab_selected'); |
84 |
|
Element.addClassName('a_template', 'tab_selected'); |
85 |
|
$('div_template').style.visibility = "visible"; |
86 |
|
$('div_template').style.zIndex = 2; |
87 |
|
Logger.debug("switched to template editor"); |
88 |
|
var c = $('template_content'); |
89 |
|
if (c) c.focus(); |
90 |
|
Logger.debug('zIndex template:'+$('div_template').style.zIndex+' css:'+$('div_css').style.zIndex); |
91 |
return false; |
return false; |
92 |
} |
} |
93 |
|
|
94 |
function edit_css() { |
function edit_css() { |
95 |
Effect.Fade('div_template', 30, 1); |
$('div_template').style.visibility = "hidden"; |
96 |
Effect.Appear('div_css', 30, 1); |
$('div_template').style.zIndex = 1; |
97 |
|
Element.removeClassName('a_template', 'tab_selected'); |
98 |
|
Element.addClassName('a_css', 'tab_selected'); |
99 |
|
$('div_css').style.visibility = "visible"; |
100 |
|
$('div_css').style.zIndex = 2; |
101 |
|
Logger.debug("switched to CSS editor"); |
102 |
|
var c = $('css_content'); |
103 |
|
if (c) c.focus(); |
104 |
|
Logger.debug('zIndex template:'+$('div_template').style.zIndex+' css:'+$('div_css').style.zIndex); |
105 |
return false; |
return false; |
106 |
} |
} |
107 |
|
|
108 |
function switch_template(template_name) { |
function switch_template(new_template_filename) { |
109 |
|
|
110 |
|
Logger.info('switch_template to '+new_template_filename); |
111 |
|
show_working(); |
112 |
|
|
|
Logger.info('switch_template to '+template_name); |
|
|
new Effect.Opacity('div_template', { from: 1.0, to: 0.7, duration: 0.3 }); |
|
113 |
Logger.debug('load template editor'); |
Logger.debug('load template editor'); |
114 |
load_template(template_name); |
template_filename = new_template_filename; |
115 |
|
load_template(new_template_filename); |
116 |
|
|
117 |
Logger.debug('refresh record'); |
Logger.debug('refresh record'); |
118 |
load_rec(rec); |
load_rec(rec); |
119 |
|
|
120 |
Logger.debug('refresh template list'); |
hide_working(); |
121 |
iwfRequest( url+'/template_list/?template='+template_filename, 'div_template_list' ); |
|
122 |
|
return false; |
123 |
} |
} |
124 |
|
|
125 |
var loading = { |
var loading = { |
126 |
template: 0, |
template: 0, |
127 |
css: 0, |
css: 0, |
128 |
} |
record: 0 |
129 |
|
}; |
130 |
|
|
131 |
function load_template( template ) { |
function load_template( template_filename ) { |
132 |
|
|
133 |
if (loading.template) { |
if (loading.template) { |
134 |
Logger.info('loading of template '+name+' skipped, load in progress'); |
Logger.info('loading of template '+template_filename+' skipped, load in progress'); |
135 |
return; |
return; |
136 |
} |
} |
137 |
|
|
138 |
new Ajax.Updater( 'div_template', url+'template', { |
var args = '?template_filename='+template_filename; |
139 |
|
|
140 |
|
new Ajax.Updater( 'div_template', url+'template'+args, { |
141 |
asynchronous: 1, |
asynchronous: 1, |
142 |
onLoading: function(request) { |
onLoading: function(request) { |
143 |
loading.template = 1; |
loading.template = 1; |
144 |
|
show_working(); |
145 |
|
Logger.info('load_template.onLoading: '+template_filename); |
146 |
}, |
}, |
147 |
onLoaded: function(request) { |
onLoaded: function(request) { |
148 |
loading.template = 0; |
loading.template = 0; |
149 |
|
Position.clone('div_template', 'div_css'); |
150 |
|
hide_working(); |
151 |
|
Logger.info('load_template.onLoaded: '+template_filename); |
152 |
} |
} |
153 |
} ) ; |
} ) ; |
154 |
} |
} |
155 |
|
|
156 |
function load_css(css_file) { |
function load_css(css_filename) { |
157 |
|
|
158 |
if (loading.css) { |
if (loading.css) { |
159 |
Logger.info('loading of css '+name+' skipped, load in progress'); |
Logger.info('loading of css '+css_filename+' skipped, load in progress'); |
160 |
return; |
return; |
161 |
} |
} |
162 |
|
|
164 |
asynchronous: 1, |
asynchronous: 1, |
165 |
onLoading: function(request) { |
onLoading: function(request) { |
166 |
loading.css = 1; |
loading.css = 1; |
167 |
|
show_working(); |
168 |
|
Logger.info('load_css.onLoading: '+css_filename); |
169 |
}, |
}, |
170 |
onLoaded: function(request) { |
onLoaded: function(request) { |
171 |
loading.css = 0; |
loading.css = 0; |
172 |
|
hide_working(); |
173 |
|
Logger.info('load_css.onLoaded: '+css_filename); |
174 |
} |
} |
175 |
} ) ; |
} ) ; |
176 |
}; |
}; |
177 |
|
|
178 |
|
function reload_css() { |
179 |
|
Logger.error('reload_css is not yet implemented!'); |
180 |
|
return false; |
181 |
|
} |
182 |
|
|
183 |
|
var working_count = 0; |
184 |
|
|
185 |
|
function show_working() { |
186 |
|
working_count++; |
187 |
|
if (working_count > 1) Element.show('working'); |
188 |
|
Logger.debug('show_working, count = '+working_count); |
189 |
|
} |
190 |
|
|
191 |
|
function hide_working() { |
192 |
|
working_count--; |
193 |
|
if (working_count < 1) Element.hide('working'); |
194 |
|
Logger.debug('hide_working, count = '+working_count); |
195 |
|
} |
196 |
|
|
197 |
function init_page() { |
function init_page() { |
198 |
|
|
199 |
// Element.hide('div_css'); |
show_working(); |
|
// Element.show('div_template'); |
|
200 |
|
|
201 |
Position.clone('div_template', 'div_css'); |
edit_template(); |
202 |
|
|
203 |
// load css editor |
// load css editor |
204 |
load_css(); |
load_css(); |
206 |
// load template editor and record |
// load template editor and record |
207 |
switch_template(template_filename); |
switch_template(template_filename); |
208 |
|
|
209 |
|
hide_working(); |
210 |
|
|
211 |
} |
} |
212 |
|
|