1 |
dpavlin |
134 |
/* |
2 |
|
|
Webpacus template editor |
3 |
|
|
*/ |
4 |
|
|
|
5 |
|
|
var rec = null; |
6 |
|
|
var url = null; |
7 |
|
|
var template_filename = null; |
8 |
|
|
|
9 |
|
|
var css_rnd = 0; |
10 |
|
|
|
11 |
|
|
function iwfRequest( url, div ) { |
12 |
|
|
Logger.info('iwfRequest('+url+','+div+')'); |
13 |
|
|
return; |
14 |
|
|
} |
15 |
|
|
|
16 |
|
|
function update_status(text) { |
17 |
|
|
var el = $('div_record_nr'); |
18 |
|
|
if (el) el.innerHTML = text; |
19 |
|
|
} |
20 |
|
|
|
21 |
|
|
function load_rec(nr) { |
22 |
|
|
Logger.debug('load_rec '+nr); |
23 |
|
|
if (nr == 1) { |
24 |
|
|
Element.hide('a_left_arr'); |
25 |
|
|
} else { |
26 |
|
|
Element.show('a_left_arr'); |
27 |
|
|
} |
28 |
|
|
update_status(nr+'...'); |
29 |
|
|
iwfRequest( url+'/xml/?template='+template_filename+'&rec='+nr, 'div_record' ); |
30 |
dpavlin |
137 |
new Effect.Opacity('div_record', { from: 1.0, to: 0.7, duration: 0.3 }); |
31 |
dpavlin |
134 |
} |
32 |
|
|
|
33 |
|
|
function inc_rec() { |
34 |
|
|
rec++; |
35 |
|
|
load_rec(rec); |
36 |
|
|
return false; |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
function dec_rec() { |
40 |
|
|
if (rec > 1) { |
41 |
|
|
rec--; |
42 |
|
|
load_rec(rec); |
43 |
|
|
} |
44 |
|
|
return false; |
45 |
|
|
} |
46 |
|
|
|
47 |
|
|
function reload_rec() { |
48 |
|
|
load_rec(rec); |
49 |
|
|
return false; |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
function edit_template() { |
53 |
|
|
Effect.Fade('div_css'); |
54 |
|
|
Effect.Appear('div_template'); |
55 |
|
|
return false; |
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
function edit_css() { |
59 |
|
|
Effect.Fade('div_template', 30, 1); |
60 |
|
|
Effect.Appear('div_css', 30, 1); |
61 |
|
|
return false; |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
function switch_template(template_name) { |
65 |
|
|
|
66 |
|
|
Logger.info('switch_template to '+template_name); |
67 |
dpavlin |
137 |
new Effect.Opacity('div_template', { from: 1.0, to: 0.7, duration: 0.3 }); |
68 |
dpavlin |
134 |
Logger.debug('load template editor'); |
69 |
|
|
load_template(template_name); |
70 |
|
|
|
71 |
|
|
Logger.debug('refresh record'); |
72 |
|
|
load_rec(rec); |
73 |
|
|
|
74 |
|
|
Logger.debug('refresh template list'); |
75 |
|
|
iwfRequest( url+'/template_list/?template='+template_filename, 'div_template_list' ); |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
var loading = { |
79 |
|
|
template: 0, |
80 |
|
|
css: 0, |
81 |
|
|
} |
82 |
|
|
|
83 |
|
|
function load_template( template ) { |
84 |
|
|
|
85 |
|
|
if (loading.template) { |
86 |
|
|
Logger.info('loading of template '+name+' skipped, load in progress'); |
87 |
|
|
return; |
88 |
|
|
} |
89 |
|
|
|
90 |
|
|
new Ajax.Updater( 'div_template', url+'template', { |
91 |
|
|
asynchronous: 1, |
92 |
|
|
onLoading: function(request) { |
93 |
|
|
loading.template = 1; |
94 |
|
|
}, |
95 |
|
|
onLoaded: function(request) { |
96 |
|
|
loading.template = 0; |
97 |
|
|
} |
98 |
|
|
} ) ; |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
function load_css(css_file) { |
102 |
|
|
|
103 |
|
|
if (loading.css) { |
104 |
|
|
Logger.info('loading of css '+name+' skipped, load in progress'); |
105 |
|
|
return; |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
new Ajax.Updater( 'div_css', url+'css', { |
109 |
|
|
asynchronous: 1, |
110 |
|
|
onLoading: function(request) { |
111 |
|
|
loading.css = 1; |
112 |
|
|
}, |
113 |
|
|
onLoaded: function(request) { |
114 |
|
|
loading.css = 0; |
115 |
|
|
} |
116 |
|
|
} ) ; |
117 |
|
|
}; |
118 |
|
|
|
119 |
|
|
function init_page() { |
120 |
|
|
|
121 |
|
|
// Element.hide('div_css'); |
122 |
|
|
// Element.show('div_template'); |
123 |
|
|
|
124 |
|
|
Position.clone('div_template', 'div_css'); |
125 |
|
|
|
126 |
|
|
// load css editor |
127 |
|
|
load_css(); |
128 |
|
|
|
129 |
|
|
// load template editor and record |
130 |
|
|
switch_template(template_filename); |
131 |
|
|
|
132 |
|
|
} |
133 |
|
|
|