/[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 168 by dpavlin, Sat Nov 26 23:26:45 2005 UTC revision 193 by dpavlin, Tue Nov 29 14:31:26 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) {          if (loading.record) {
34                  Logger.info('loading of record '+nr+' skipped, load in progress');                  Logger.info('loading of record '+nr+' skipped, load in progress');
35                  return;                  return false;
36          }          }
37    
38            show_working();
39            $('record_nr').disabled = 'true';
40    
41          if (nr == 1) {          if (nr == 1) {
42                  Element.addClassName('a_left_arr', 'nav_disable');                  Element.addClassName('a_left_arr', 'nav_disable');
43          } else {          } else {
44                  Element.removeClassName('a_left_arr', 'nav_disable');                  Element.removeClassName('a_left_arr', 'nav_disable');
45          }          }
46    
47          var args = '?mfn='+nr+'&template_filename='+template_filename;          var args = '?mfn='+nr+'&template_filename='+tmp_template_filename;
48    
49          new Ajax.Updater( 'div_record',  url+'record'+args, {          new Ajax.Updater( 'div_record',  url+'record'+args, {
50                  asynchronous: 1,                  asynchronous: 1,
51                  onLoading: function(request) {                  onLoading: function(request) {
52                          loading.record = 1;                          loading.record = 1;
                         update_status(nr+'...');  
53                          Logger.info('load_rec.onLoading: '+nr);                          Logger.info('load_rec.onLoading: '+nr);
54                  },                  },
55                  onLoaded: function(request) {                  onLoaded: function(request) {
56                          loading.record = 0;                          loading.record = 0;
57                          update_status('# '+nr);                          hide_working();
58                            $('record_nr').value = nr;
59                            $('record_nr').disabled = '';
60                            rec = nr;
61                          Logger.info('load_rec.onLoaded: '+nr);                          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 = '';  var current_edit = '';
94    
95  function edit_template() {  function edit_template() {
96          $('div_css').style.visibility = "hidden";          Element.hide('row_css');
97    
98          Element.removeClassName('a_css', 'tab_selected');          Element.removeClassName('a_css', 'tab_selected');
99          Element.addClassName('a_template', 'tab_selected');          Element.addClassName('a_template', 'tab_selected');
100          $('div_template').style.visibility = "visible";  
101            Element.show('row_template');
102    
103          Logger.debug("switched to template editor");          Logger.debug("switched to template editor");
104          var c = $('template_content');          var c = $('template_content');
105          if (c) c.focus();          if (c) c.focus();
106            Logger.debug('zIndex template:'+$('row_template').style.zIndex+' css:'+$('row_css').style.zIndex);
107          return false;          return false;
108  }  }
109    
110  function edit_css() {  function edit_css() {
111          $('div_template').style.visibility = "hidden";  
112            Element.hide('row_template');
113    
114          Element.removeClassName('a_template', 'tab_selected');          Element.removeClassName('a_template', 'tab_selected');
115          Element.addClassName('a_css', 'tab_selected');          Element.addClassName('a_css', 'tab_selected');
116          $('div_css').style.visibility = "visible";  
117            Element.show('row_css');
118    
119          Logger.debug("switched to CSS editor");          Logger.debug("switched to CSS editor");
120          var c = $('css_content');          var c = $('css_content');
121          if (c) c.focus();          if (c) c.focus();
122            Logger.debug('zIndex template:'+$('row_template').style.zIndex+' css:'+$('row_css').style.zIndex);
123          return false;          return false;
124  }  }
125    
126  function switch_template(new_template_filename) {  function switch_template(new_template_filename) {
127    
128          Logger.info('switch_template to '+new_template_filename);          Logger.info('switch_template to '+new_template_filename);
129            show_working();
130    
131          Logger.debug('load template editor');          Logger.debug('load template editor');
132          template_filename = new_template_filename;          template_filename = new_template_filename;
# Line 104  function switch_template(new_template_fi Line 135  function switch_template(new_template_fi
135          Logger.debug('refresh record');          Logger.debug('refresh record');
136          load_rec(rec);          load_rec(rec);
137    
138            edKill('template_content');
139    
140            hide_working();
141    
142          return false;          return false;
143  }  }
144    
145  var loading = {  var loading = {
146          template: 0,          template: 0,
147          css: 0,          css: 0,
148          record: 0,          record: 0
149  }  };
150    
151  function load_template( template_filename ) {  function load_template( template_filename ) {
152    
# Line 120  function load_template( template_filenam Line 155  function load_template( template_filenam
155                  return;                  return;
156          }          }
157    
158            show_working();
159    
160          var args = '?template_filename='+template_filename;          var args = '?template_filename='+template_filename;
161    
162          new Ajax.Updater( 'div_template',  url+'template'+args, {          new Ajax.Updater( 'row_template',  url+'template'+args, {
163                  asynchronous: 1,                  asynchronous: 1,
164                  onLoading: function(request) {                  onLoading: function(request) {
165                          loading.template = 1;                          loading.template = 1;
# Line 130  function load_template( template_filenam Line 167  function load_template( template_filenam
167                  },                  },
168                  onLoaded: function(request) {                  onLoaded: function(request) {
169                          loading.template = 0;                          loading.template = 0;
170                          Position.clone('div_template', 'div_css');                          hide_working();
171                          Logger.info('load_template.onLoaded: '+template_filename);                          Logger.info('load_template.onLoaded: '+template_filename);
172                  }                  }
173          } ) ;          } ) ;
# Line 143  function load_css(css_filename) { Line 180  function load_css(css_filename) {
180                  return;                  return;
181          }          }
182    
183          new Ajax.Updater( 'div_css',  url+'css', {          Logger.info('load_css '+css_filename);
184    
185            show_working();
186    
187            new Ajax.Updater( 'row_css',  url+'css', {
188                  asynchronous: 1,                  asynchronous: 1,
189                  onLoading: function(request) {                  onLoading: function(request) {
190                          loading.css = 1;                          loading.css = 1;
# Line 151  function load_css(css_filename) { Line 192  function load_css(css_filename) {
192                  },                  },
193                  onLoaded: function(request) {                  onLoaded: function(request) {
194                          loading.css = 0;                          loading.css = 0;
195                            hide_working();
196                          Logger.info('load_css.onLoaded: '+css_filename);                          Logger.info('load_css.onLoaded: '+css_filename);
197                            reload_css( css_filename );
198                  }                  }
199          } ) ;          } ) ;
200  };  };
201    
202  function init_page() {  function reload_css( css_filename ) {
203    
204  //      Element.hide('div_css');          if (! css_filename) css_filename = 'user.css';
205  //      Element.show('div_template');  
206            css_rnd++;
207            var css_url = url + 'css/' + css_filename + '?' + css_rnd;
208            Logger.info('reload_css from '+css_url);
209            $('user_css_link').href = css_url;
210    
211            return false;
212    }
213    
214  //      Position.clone('div_template', 'div_css');  var working_count = 0;
215    
216    function show_working() {
217            working_count++;
218            if (working_count > 1) Element.show('working');
219            Logger.debug('show_working, count = '+working_count);
220    }
221    
222    function hide_working() {
223            working_count--;
224            if (working_count < 1) Element.hide('working');
225            Logger.debug('hide_working, count = '+working_count);
226    }
227    
228    function init_page() {
229    
230            show_working();
231    
232          edit_template();          edit_template();
233    
# Line 171  function init_page() { Line 237  function init_page() {
237          // load template editor and record          // load template editor and record
238          switch_template(template_filename);          switch_template(template_filename);
239    
240            hide_working();
241    
242  }  }
243    

Legend:
Removed from v.168  
changed lines
  Added in v.193

  ViewVC Help
Powered by ViewVC 1.1.26