/[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 163 by dpavlin, Sat Nov 26 18:18:10 2005 UTC revision 170 by dpavlin, Sun Nov 27 00:50:27 2005 UTC
# Line 8  var template_filename = null; Line 8  var template_filename = null;
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;
# Line 20  function update_status(text) { Line 15  function update_status(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    
# Line 57  function edit_template() { Line 83  function edit_template() {
83          Element.addClassName('a_template', 'tab_selected');          Element.addClassName('a_template', 'tab_selected');
84          $('div_template').style.visibility = "visible";          $('div_template').style.visibility = "visible";
85          Logger.debug("switched to template editor");          Logger.debug("switched to template editor");
86          $('template_content').focus();          var c = $('template_content');
87            if (c) c.focus();
88          return false;          return false;
89  }  }
90    
# Line 67  function edit_css() { Line 94  function edit_css() {
94          Element.addClassName('a_css', 'tab_selected');          Element.addClassName('a_css', 'tab_selected');
95          $('div_css').style.visibility = "visible";          $('div_css').style.visibility = "visible";
96          Logger.debug("switched to CSS editor");          Logger.debug("switched to CSS editor");
97          $('css_content').focus();          var c = $('css_content');
98            if (c) c.focus();
99          return false;          return false;
100  }  }
101    
102  function switch_template(template_name) {  function switch_template(new_template_filename) {
103    
104            Logger.info('switch_template to '+new_template_filename);
105            show_working();
106    
         Logger.info('switch_template to '+template_name);  
         new Effect.Opacity('div_template', { from: 1.0, to: 0.7, duration: 0.3 });  
107          Logger.debug('load template editor');          Logger.debug('load template editor');
108          load_template(template_name);          template_filename = new_template_filename;
109            load_template(new_template_filename);
110    
111          Logger.debug('refresh record');          Logger.debug('refresh record');
112          load_rec(rec);          load_rec(rec);
113    
114          Logger.debug('refresh template list');          hide_working();
115          iwfRequest( url+'/template_list/?template='+template_filename, 'div_template_list' );  
116            return false;
117  }  }
118    
119  var loading = {  var loading = {
120          template: 0,          template: 0,
121          css: 0,          css: 0,
122  }          record: 0
123    };
124    
125  function load_template( template ) {  function load_template( template_filename ) {
126    
127          if (loading.template) {          if (loading.template) {
128                  Logger.info('loading of template '+name+' skipped, load in progress');                  Logger.info('loading of template '+template_filename+' skipped, load in progress');
129                  return;                  return;
130          }          }
131    
132          new Ajax.Updater( 'div_template',  url+'template', {          var args = '?template_filename='+template_filename;
133    
134            new Ajax.Updater( 'div_template',  url+'template'+args, {
135                  asynchronous: 1,                  asynchronous: 1,
136                  onLoading: function(request) {                  onLoading: function(request) {
137                          loading.template = 1;                          loading.template = 1;
138                          Logger.info('load_template.onLoading: '+template);                          show_working();
139                            Logger.info('load_template.onLoading: '+template_filename);
140                  },                  },
141                  onLoaded: function(request) {                  onLoaded: function(request) {
142                          loading.template = 0;                          loading.template = 0;
143                          Position.clone('div_template', 'div_css');                          Position.clone('div_template', 'div_css');
144                          Logger.info('load_template.onLoaded: '+template);                          hide_working();
145                            Logger.info('load_template.onLoaded: '+template_filename);
146                  }                  }
147          } ) ;          } ) ;
148  }  }
149    
150  function load_css(css_file) {  function load_css(css_filename) {
151    
152          if (loading.css) {          if (loading.css) {
153                  Logger.info('loading of css '+name+' skipped, load in progress');                  Logger.info('loading of css '+css_filename+' skipped, load in progress');
154                  return;                  return;
155          }          }
156    
# Line 122  function load_css(css_file) { Line 158  function load_css(css_file) {
158                  asynchronous: 1,                  asynchronous: 1,
159                  onLoading: function(request) {                  onLoading: function(request) {
160                          loading.css = 1;                          loading.css = 1;
161                          Logger.info('load_css.onLoading: '+css_file);                          show_working();
162                            Logger.info('load_css.onLoading: '+css_filename);
163                  },                  },
164                  onLoaded: function(request) {                  onLoaded: function(request) {
165                          loading.css = 0;                          loading.css = 0;
166                          Logger.info('load_css.onLoaded: '+css_file);                          hide_working();
167                            Logger.info('load_css.onLoaded: '+css_filename);
168                  }                  }
169          } ) ;          } ) ;
170  };  };
171    
172    function reload_css() {
173            Logger.error('reload_css is not yet implemented!');
174            return false;
175    }
176    
177    var working_count = 0;
178    
179    function show_working() {
180            working_count++;
181            if (working_count > 1) Element.show('working');
182            Logger.debug('show_working, count = '+working_count);
183    }
184    
185    function hide_working() {
186            working_count--;
187            if (working_count < 1) Element.hide('working');
188            Logger.debug('hide_working, count = '+working_count);
189    }
190    
191  function init_page() {  function init_page() {
192    
193  //      Element.hide('div_css');          show_working();
 //      Element.show('div_template');  
194    
195  //      Position.clone('div_template', 'div_css');          edit_template();
196    
197          // load css editor          // load css editor
198          load_css();          load_css();
# Line 144  function init_page() { Line 200  function init_page() {
200          // load template editor and record          // load template editor and record
201          switch_template(template_filename);          switch_template(template_filename);
202    
203            hide_working();
204    
205  }  }
206    

Legend:
Removed from v.163  
changed lines
  Added in v.170

  ViewVC Help
Powered by ViewVC 1.1.26