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

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

  ViewVC Help
Powered by ViewVC 1.1.26