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

Contents of /Webpacus/root/editor/editor.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 164 - (show annotations)
Sat Nov 26 20:21:49 2005 UTC (18 years, 5 months ago) by dpavlin
File MIME type: application/javascript
File size: 3171 byte(s)
 r11164@llin:  dpavlin | 2005-11-26 19:53:45 +0100
 more design

1 /*
2 Webpacus template editor
3 */
4
5 var rec = null;
6 var url = null;
7 var template_filename = null;
8
9 var css_rnd = 0;
10
11 function iwfRequest( url, div ) {
12 Logger.info('iwfRequest('+url+','+div+')');
13 return;
14 }
15
16 function update_status(text) {
17 var el = $('div_record_nr');
18 if (el) el.innerHTML = text;
19 }
20
21 function load_rec(nr) {
22 Logger.debug('load_rec '+nr);
23 if (nr == 1) {
24 Element.hide('a_left_arr');
25 } else {
26 Element.show('a_left_arr');
27 }
28 update_status(nr+'...');
29 iwfRequest( url+'/xml/?template='+template_filename+'&rec='+nr, 'div_record' );
30 new Effect.Opacity('div_record', { from: 1.0, to: 0.7, duration: 0.3 });
31 }
32
33 function inc_rec() {
34 rec++;
35 load_rec(rec);
36 return false;
37 }
38
39 function dec_rec() {
40 if (rec > 1) {
41 rec--;
42 load_rec(rec);
43 }
44 return false;
45 }
46
47 function reload_rec() {
48 load_rec(rec);
49 return false;
50 }
51
52 var current_edit = '';
53
54 function edit_template() {
55 $('div_css').style.visibility = "hidden";
56 Element.removeClassName('a_css', 'tab_selected');
57 Element.addClassName('a_template', 'tab_selected');
58 $('div_template').style.visibility = "visible";
59 Logger.debug("switched to template editor");
60 var c = $('template_content');
61 if (c) c.focus();
62 return false;
63 }
64
65 function edit_css() {
66 $('div_template').style.visibility = "hidden";
67 Element.removeClassName('a_template', 'tab_selected');
68 Element.addClassName('a_css', 'tab_selected');
69 $('div_css').style.visibility = "visible";
70 Logger.debug("switched to CSS editor");
71 var c = $('css_content');
72 if (c) c.focus();
73 return false;
74 }
75
76 function switch_template(template_name) {
77
78 Logger.info('switch_template to '+template_name);
79 new Effect.Opacity('div_template', { from: 1.0, to: 0.7, duration: 0.3 });
80 Logger.debug('load template editor');
81 load_template(template_name);
82
83 Logger.debug('refresh record');
84 load_rec(rec);
85
86 Logger.debug('refresh template list');
87 iwfRequest( url+'/template_list/?template='+template_filename, 'div_template_list' );
88 }
89
90 var loading = {
91 template: 0,
92 css: 0,
93 }
94
95 function load_template( template ) {
96
97 if (loading.template) {
98 Logger.info('loading of template '+name+' skipped, load in progress');
99 return;
100 }
101
102 new Ajax.Updater( 'div_template', url+'template', {
103 asynchronous: 1,
104 onLoading: function(request) {
105 loading.template = 1;
106 Logger.info('load_template.onLoading: '+template);
107 },
108 onLoaded: function(request) {
109 loading.template = 0;
110 Position.clone('div_template', 'div_css');
111 Logger.info('load_template.onLoaded: '+template);
112 }
113 } ) ;
114 }
115
116 function load_css(css_file) {
117
118 if (loading.css) {
119 Logger.info('loading of css '+name+' skipped, load in progress');
120 return;
121 }
122
123 new Ajax.Updater( 'div_css', url+'css', {
124 asynchronous: 1,
125 onLoading: function(request) {
126 loading.css = 1;
127 Logger.info('load_css.onLoading: '+css_file);
128 },
129 onLoaded: function(request) {
130 loading.css = 0;
131 Logger.info('load_css.onLoaded: '+css_file);
132 }
133 } ) ;
134 };
135
136 function init_page() {
137
138 // Element.hide('div_css');
139 // Element.show('div_template');
140
141 // Position.clone('div_template', 'div_css');
142
143 edit_template();
144
145 // load css editor
146 load_css();
147
148 // load template editor and record
149 switch_template(template_filename);
150
151 }
152

  ViewVC Help
Powered by ViewVC 1.1.26