]> git.sur5r.net Git - bacula/bacula/blob - gui/bacula-web/js/overlib_cssstyle.js
Update
[bacula/bacula] / gui / bacula-web / js / overlib_cssstyle.js
1 //\/////
2 //\  overLIB CSS Style Plugin
3 //\  This file requires overLIB 4.00 or later.
4 //\
5 //\  overLIB 4.00 - You may not remove or change this notice.
6 //\  Copyright Erik Bosrup 1998-2004. All rights reserved.
7 //\  Contributors are listed on the homepage.
8 //\  See http://www.bosrup.com/web/overlib/ for details.
9 //   $Revision$                      $Date$
10 //\/////
11
12
13
14 ////////
15 // PRE-INIT
16 // Ignore these lines, configuration is below.
17 ////////
18 if (typeof olInfo == 'undefined' || olInfo.simpleversion < 400) alert('overLIB 4.00 or later is required for the CSS Style Plugin.');
19 registerCommands('cssstyle,padunit,heightunit,widthunit,textsizeunit,textdecoration,textstyle,textweight,captionsizeunit,captiondecoration,captionstyle,captionweight,closesizeunit,closedecoration,closestyle,closeweight');
20
21
22 ////////
23 // DEFAULT CONFIGURATION
24 // Settings you want everywhere are set here. All of this can also be
25 // changed on your html page or through an overLIB call.
26 ////////
27 if (typeof ol_padunit=='undefined') var ol_padunit="px";
28 if (typeof ol_heightunit=='undefined') var ol_heightunit="px";
29 if (typeof ol_widthunit=='undefined') var ol_widthunit="px";
30 if (typeof ol_textsizeunit=='undefined') var ol_textsizeunit="px";
31 if (typeof ol_textdecoration=='undefined') var ol_textdecoration="none";
32 if (typeof ol_textstyle=='undefined') var ol_textstyle="normal";
33 if (typeof ol_textweight=='undefined') var ol_textweight="normal";
34 if (typeof ol_captionsizeunit=='undefined') var ol_captionsizeunit="px";
35 if (typeof ol_captiondecoration=='undefined') var ol_captiondecoration="none";
36 if (typeof ol_captionstyle=='undefined') var ol_captionstyle="normal";
37 if (typeof ol_captionweight=='undefined') var ol_captionweight="bold";
38 if (typeof ol_closesizeunit=='undefined') var ol_closesizeunit="px";
39 if (typeof ol_closedecoration=='undefined') var ol_closedecoration="none";
40 if (typeof ol_closestyle=='undefined') var ol_closestyle="normal";
41 if (typeof ol_closeweight=='undefined') var ol_closeweight="normal";
42
43 ////////
44 // END OF CONFIGURATION
45 // Don't change anything below this line, all configuration is above.
46 ////////
47
48
49
50 ////////
51 // INIT
52 ////////
53 // Runtime variables init. Don't change for config!
54 var o3_padunit="px";
55 var o3_heightunit="px";
56 var o3_widthunit="px";
57 var o3_textsizeunit="px";
58 var o3_textdecoration="";
59 var o3_textstyle="";
60 var o3_textweight="";
61 var o3_captionsizeunit="px";
62 var o3_captiondecoration="";
63 var o3_captionstyle="";
64 var o3_captionweight="";
65 var o3_closesizeunit="px";
66 var o3_closedecoration="";
67 var o3_closestyle="";
68 var o3_closeweight="";
69
70
71 ////////
72 // PLUGIN FUNCTIONS
73 ////////
74
75 // Function which sets runtime variables to their default values
76 function setCSSStyleVariables() {
77         o3_padunit=ol_padunit;
78         o3_heightunit=ol_heightunit;
79         o3_widthunit=ol_widthunit;
80         o3_textsizeunit=ol_textsizeunit;
81         o3_textdecoration=ol_textdecoration;
82         o3_textstyle=ol_textstyle;
83         o3_textweight=ol_textweight;
84         o3_captionsizeunit=ol_captionsizeunit;
85         o3_captiondecoration=ol_captiondecoration;
86         o3_captionstyle=ol_captionstyle;
87         o3_captionweight=ol_captionweight;
88         o3_closesizeunit=ol_closesizeunit;
89         o3_closedecoration=ol_closedecoration;
90         o3_closestyle=ol_closestyle;
91         o3_closeweight=ol_closeweight;
92 }
93
94 // Parses CSS Style commands.
95 function parseCSSStyleExtras(pf, i, ar) {
96         var k = i;
97         
98         if (k < ar.length) {
99                 if (ar[k]==CSSSTYLE) { eval(pf+'css='+ar[k]); return k; }
100                 if (ar[k]==PADUNIT) { eval(pf+'padunit="'+ar[++k]+'"'); return k; }
101                 if (ar[k]==HEIGHTUNIT) { eval(pf+'heightunit="'+ar[++k]+'"'); return k; }
102                 if (ar[k]==WIDTHUNIT) { eval(pf+'widthunit="'+ar[++k]+'"'); return k; }
103                 if (ar[k]==TEXTSIZEUNIT) { eval(pf+'textsizeunit="'+ar[++k]+'"'); return k; }
104                 if (ar[k]==TEXTDECORATION) { eval(pf+'textdecoration="'+ar[++k]+'"'); return k; }
105                 if (ar[k]==TEXTSTYLE) { eval(pf+'textstyle="'+ar[++k]+'"'); return k; }
106                 if (ar[k]==TEXTWEIGHT) { eval(pf+'textweight="'+ar[++k]+'"'); return k; }
107                 if (ar[k]==CAPTIONSIZEUNIT) { eval(pf+'captionsizeunit="'+ar[++k]+'"'); return k; }
108                 if (ar[k]==CAPTIONDECORATION) { eval(pf+'captiondecoration="'+ar[++k]+'"'); return k; }
109                 if (ar[k]==CAPTIONSTYLE) { eval(pf+'captionstyle="'+ar[++k]+'"'); return k; }
110                 if (ar[k]==CAPTIONWEIGHT) { eval(pf+'captionweight="'+ar[++k]+'"'); return k; }
111                 if (ar[k]==CLOSESIZEUNIT) { eval(pf+'closesizeunit="'+ar[++k]+'"'); return k; }
112                 if (ar[k]==CLOSEDECORATION) { eval(pf+'closedecoration="'+ar[++k]+'"'); return k; }
113                 if (ar[k]==CLOSESTYLE) { eval(pf+'closestyle="'+ar[++k]+'"'); return k; }
114                 if (ar[k]==CLOSEWEIGHT) { eval(pf+'closeweight="'+ar[++k]+'"'); return k; }
115         }
116         
117         return -1;
118 }
119
120 ////////
121 // LAYER GENERATION FUNCTIONS
122 ////////
123
124 // Makes simple table without caption
125 function ol_content_simple_cssstyle(text) {
126         txt = '<table width="'+o3_width+ '" border="0" cellpadding="'+o3_border+'" cellspacing="0" style="background-color: '+o3_bgcolor+'; height: '+o3_height+o3_heightunit+';"><tr><td><table width="100%" border="0" cellpadding="' + o3_cellpad + '" cellspacing="0" style="color: '+o3_fgcolor+'; background-color: '+o3_fgcolor+'; height: '+o3_height+o3_heightunit+';"><tr><td valign="TOP"><font style="font-family: '+o3_textfont+'; color: '+o3_textcolor+'; font-size: '+o3_textsize+o3_textsizeunit+'; text-decoration: '+o3_textdecoration+'; font-weight: '+o3_textweight+'; font-style:'+o3_textstyle+'">'+text+'</font></td></tr></table></td></tr></table>';
127         set_background("");
128         
129         return txt;
130 }
131
132 // Makes table with caption and optional close link
133 function ol_content_caption_cssstyle(text, title, close) {
134         var nameId;
135         closing = "";
136         closeevent = "onMouseOver";
137         
138         if (o3_closeclick == 1) closeevent= (o3_closetitle ? "title='" + o3_closetitle +"'" : "") + " onClick";
139
140         if (o3_capicon!="") {
141                 nameId=' hspace=\"5\"'+' align=\"middle\" alt=\"\"';
142                 if (typeof o3_dragimg != 'undefined' && o3_dragimg) nameId = ' hspace=\"5\"'+' name=\"'+o3_dragimg+'\" id=\"'+o3_dragimg+'\" align=\"middle\" alt=\"Drag Enabled\" title=\"Drag Enabled\"';
143                 o3_capicon = '<img src=\"'+o3_capicon+'\"'+nameId+' />';
144         }
145         
146         if (close != "") {
147                 closing = '<td align="RIGHT"><a href="javascript:return '+fnRef+'cClick();" '+closeevent+'="return '+fnRef+'cClick();" style="color: '+o3_closecolor+'; font-family: '+o3_closefont+'; font-size: '+o3_closesize+o3_closesizeunit+'; text-decoration: '+o3_closedecoration+'; font-weight: '+o3_closeweight+'; font-style:'+o3_closestyle+';">'+close+'</a></td>';
148         }
149         
150         txt = '<table width="'+o3_width+ '" border="0" cellpadding="'+o3_border+'" cellspacing="0" style="background-color: '+o3_bgcolor+'; background-image: url('+o3_bgbackground+'); height: '+o3_height+o3_heightunit+';"><tr><td><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><font style="font-family: '+o3_captionfont+'; color: '+o3_capcolor+'; font-size: '+o3_captionsize+o3_captionsizeunit+'; font-weight: '+o3_captionweight+'; font-style: '+o3_captionstyle+'; text-decoration: '+o3_captiondecoration+';">'+o3_capicon+title+'</font></td>'+closing+'</tr></table><table width="100%" border="0" cellpadding="' + o3_cellpad + '" cellspacing="0" style="color: '+o3_fgcolor+'; background-color: '+o3_fgcolor+'; height: '+o3_height+o3_heightunit+';"><tr><td valign="TOP"><font style="font-family: '+o3_textfont+'; color: '+o3_textcolor+'; font-size: '+o3_textsize+o3_textsizeunit+'; text-decoration: '+o3_textdecoration+'; font-weight: '+o3_textweight+'; font-style:'+o3_textstyle+'">'+text+'</font></td></tr></table></td></tr></table>';
151         set_background("");
152
153         return txt;
154 }
155
156 // Sets the background picture, padding and lots more. :)
157 function ol_content_background_cssstyle(text, picture, hasfullhtml) {
158         if (hasfullhtml) {
159                 txt = text;
160         } else {
161                 var pU, hU, wU;
162                 pU = (o3_padunit == '%' ? '%' : '');
163                 hU = (o3_heightunit == '%' ? '%' : '');
164                 wU = (o3_widthunit == '%' ? '%' : '');
165                 txt = '<table width="'+o3_width+wu+'" border="0" cellpadding="0" cellspacing="0" height="'+o3_height+hu+'"><tr><td colspan="3" height="'+o3_padyt+pu+'"></td></tr><tr><td width="'+o3_padxl+pu+'"></td><td valign="TOP" width="'+(o3_width-o3_padxl-o3_padxr)+pu+'"><font style="font-family: '+o3_textfont+'; color: '+o3_textcolor+'; font-size: '+o3_textsize+o3_textsizeunit+';">'+text+'</font></td><td width="'+o3_padxr+pu+'"></td></tr><tr><td colspan="3" height="'+o3_padyb+pu+'"></td></tr></table>';
166         }
167
168         set_background(picture);
169
170         return txt;
171 }
172
173 ////////
174 // PLUGIN REGISTRATIONS
175 ////////
176 registerRunTimeFunction(setCSSStyleVariables);
177 registerCmdLineFunction(parseCSSStyleExtras);
178 registerHook("ol_content_simple", ol_content_simple_cssstyle, FALTERNATE, CSSSTYLE);
179 registerHook("ol_content_caption", ol_content_caption_cssstyle, FALTERNATE, CSSSTYLE);
180 registerHook("ol_content_background", ol_content_background_cssstyle, FALTERNATE, CSSSTYLE);