/[webpac2]/Webpacus/root/editor/editor.js
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /Webpacus/root/editor/editor.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 168 - (show annotations)
Sat Nov 26 23:26:45 2005 UTC (18 years, 5 months ago) by dpavlin
File MIME type: application/javascript
File size: 3566 byte(s)
 r11172@llin:  dpavlin | 2005-11-26 23:09:52 +0100
 use switch_template not load_template (which is editor internal)

1 /*
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
24 if (loading.record) {
25 Logger.info('loading of record '+nr+' skipped, load in progress');
26 return;
27 }
28
29 if (nr == 1) {
30 Element.addClassName('a_left_arr', 'nav_disable');
31 } else {
32 Element.removeClassName('a_left_arr', 'nav_disable');
33 }
34
35 var args = '?mfn='+nr+'&template_filename='+template_filename;
36
37 new Ajax.Updater( 'div_record', url+'record'+args, {
38 asynchronous: 1,
39 onLoading: function(request) {
40 loading.record = 1;
41 update_status(nr+'...');
42 Logger.info('load_rec.onLoading: '+nr);
43 },
44 onLoaded: function(request) {
45 loading.record = 0;
46 update_status('# '+nr);
47 Logger.info('load_rec.onLoaded: '+nr);
48 }
49 } ) ;
50
51 }
52
53 function inc_rec() {
54 rec++;
55 load_rec(rec);
56 return false;
57 }
58
59 function dec_rec() {
60 if (rec > 1) {
61 rec--;
62 load_rec(rec);
63 }
64 return false;
65 }
66
67 function reload_rec() {
68 load_rec(rec);
69 return false;
70 }
71
72 var current_edit = '';
73
74 function edit_template() {
75 $('div_css').style.visibility = "hidden";
76 Element.removeClassName('a_css', 'tab_selected');
77 Element.addClassName('a_template', 'tab_selected');
78 $('div_template').style.visibility = "visible";
79 Logger.debug("switched to template editor");
80 var c = $('template_content');
81 if (c) c.focus();
82 return false;
83 }
84
85 function edit_css() {
86 $('div_template').style.visibility = "hidden";
87 Element.removeClassName('a_template', 'tab_selected');
88 Element.addClassName('a_css', 'tab_selected');
89 $('div_css').style.visibility = "visible";
90 Logger.debug("switched to CSS editor");
91 var c = $('css_content');
92 if (c) c.focus();
93 return false;
94 }
95
96 function switch_template(new_template_filename) {
97
98 Logger.info('switch_template to '+new_template_filename);
99
100 Logger.debug('load template editor');
101 template_filename = new_template_filename;
102 load_template(new_template_filename);
103
104 Logger.debug('refresh record');
105 load_rec(rec);
106
107 return false;
108 }
109
110 var loading = {
111 template: 0,
112 css: 0,
113 record: 0,
114 }
115
116 function load_template( template_filename ) {
117
118 if (loading.template) {
119 Logger.info('loading of template '+template_filename+' skipped, load in progress');
120 return;
121 }
122
123 var args = '?template_filename='+template_filename;
124
125 new Ajax.Updater( 'div_template', url+'template'+args, {
126 asynchronous: 1,
127 onLoading: function(request) {
128 loading.template = 1;
129 Logger.info('load_template.onLoading: '+template_filename);
130 },
131 onLoaded: function(request) {
132 loading.template = 0;
133 Position.clone('div_template', 'div_css');
134 Logger.info('load_template.onLoaded: '+template_filename);
135 }
136 } ) ;
137 }
138
139 function load_css(css_filename) {
140
141 if (loading.css) {
142 Logger.info('loading of css '+css_filename+' skipped, load in progress');
143 return;
144 }
145
146 new Ajax.Updater( 'div_css', url+'css', {
147 asynchronous: 1,
148 onLoading: function(request) {
149 loading.css = 1;
150 Logger.info('load_css.onLoading: '+css_filename);
151 },
152 onLoaded: function(request) {
153 loading.css = 0;
154 Logger.info('load_css.onLoaded: '+css_filename);
155 }
156 } ) ;
157 };
158
159 function init_page() {
160
161 // Element.hide('div_css');
162 // Element.show('div_template');
163
164 // Position.clone('div_template', 'div_css');
165
166 edit_template();
167
168 // load css editor
169 load_css();
170
171 // load template editor and record
172 switch_template(template_filename);
173
174 }
175

  ViewVC Help
Powered by ViewVC 1.1.26