/[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

Diff of /Webpacus/root/editor/editor.js

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.134  
changed lines
  Added in v.191

  ViewVC Help
Powered by ViewVC 1.1.26