/[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 171 by dpavlin, Sun Nov 27 00:50:32 2005 UTC revision 207 by dpavlin, Sat Dec 3 22:25:49 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 update_status(text) {  function _ts(text) {
14          var el = $('div_record_nr');          var el = $('div_template_status');
15            if (el) el.innerHTML = text;
16    }
17    
18    function _cs(text) {
19            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();          show_working();
# Line 30  function load_rec(nr) { Line 44  function load_rec(nr) {
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,
# Line 48  function load_rec(nr) { Line 62  function load_rec(nr) {
62                  }                  }
63          } ) ;          } ) ;
64    
65            return false;
66  }  }
67    
68  function inc_rec() {  function inc_rec() {
# Line 78  function reload_rec() { Line 93  function reload_rec() {
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          $('div_css').style.zIndex = 1;  
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          $('div_template').style.zIndex = 2;          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:'+$('div_template').style.zIndex+' css:'+$('div_css').style.zIndex);          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          $('div_template').style.zIndex = 1;          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          $('div_css').style.zIndex = 2;          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:'+$('div_template').style.zIndex+' css:'+$('div_css').style.zIndex);          Logger.debug('zIndex template:'+$('row_template').style.zIndex+' css:'+$('row_css').style.zIndex);
123          return false;          return false;
124  }  }
125    
# Line 117  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();          hide_working();
141    
142          return false;          return false;
# Line 135  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;
                         show_working();  
166                          Logger.info('load_template.onLoading: '+template_filename);                          Logger.info('load_template.onLoading: '+template_filename);
167                  },                  },
168                  onLoaded: function(request) {                  onLoaded: function(request) {
169                          loading.template = 0;                          loading.template = 0;
                         Position.clone('div_template', 'div_css');  
170                          hide_working();                          hide_working();
171                          Logger.info('load_template.onLoaded: '+template_filename);                          Logger.info('load_template.onLoaded: '+template_filename);
172                  }                  }
173          } ) ;          } ) ;
174  }  }
175    
176  function load_css(css_filename) {  function load_css( css_filename ) {
177    
178          if (loading.css) {          if (loading.css) {
179                  Logger.info('loading of css '+css_filename+' skipped, load in progress');                  Logger.info('loading of css '+css_filename+' skipped, load in progress');
180                  return;                  return;
181          }          }
182    
183          new Ajax.Updater( 'div_css',  url+'css', {          var css_url = url + 'css?css_filename='+css_filename;
184    
185            Logger.info('load_css '+css_url);
186    
187            show_working();
188    
189            new Ajax.Updater( 'row_css', css_url, {
190                  asynchronous: 1,                  asynchronous: 1,
191                  onLoading: function(request) {                  onLoading: function(request) {
192                          loading.css = 1;                          loading.css = 1;
                         show_working();  
193                          Logger.info('load_css.onLoading: '+css_filename);                          Logger.info('load_css.onLoading: '+css_filename);
194                  },                  },
195                  onLoaded: function(request) {                  onLoaded: function(request) {
196                          loading.css = 0;                          loading.css = 0;
197                          hide_working();                          hide_working();
198                          Logger.info('load_css.onLoaded: '+css_filename);                          Logger.info('load_css.onLoaded: '+css_filename);
199                            reload_css( css_filename );
200                  }                  }
201          } ) ;          } ) ;
202  };  };
203    
204  function reload_css() {  function reload_css( css_filename ) {
205          Logger.error('reload_css is not yet implemented!');  
206            if (! css_filename) css_filename = 'user.css';
207    
208            css_rnd++;
209            var css_url = '/css/' + css_filename + '?' + css_rnd;
210            Logger.info('reload_css from '+css_url);
211            $('user_css_link').href = css_url;
212    
213          return false;          return false;
214  }  }
215    
# Line 195  function hide_working() { Line 228  function hide_working() {
228  }  }
229    
230  function init_page() {  function init_page() {
   
231          show_working();          show_working();
232    
233          edit_template();          edit_template();
234    
         // load css editor  
         load_css();  
   
         // load template editor and record  
         switch_template(template_filename);  
   
235          hide_working();          hide_working();
   
236  }  }
237    

Legend:
Removed from v.171  
changed lines
  Added in v.207

  ViewVC Help
Powered by ViewVC 1.1.26