2011-12-13 12:29:05 +01:00
//\/////
//\ overLIB CSS Style Plugin
//\ This file requires overLIB 4.10 or later.
//\
//\ overLIB 4.05 - You may not remove or change this notice.
//\ Copyright Erik Bosrup 1998-2004. All rights reserved.
//\ Contributors are listed on the homepage.
//\ See http://www.bosrup.com/web/overlib/ for details.
2011-12-25 10:07:20 +01:00
// $Revision$ $Date$
2011-12-13 12:29:05 +01:00
//\/////
//\mini
////////
// PRE-INIT
// Ignore these lines, configuration is below.
////////
if ( typeof olInfo == 'undefined' || typeof olInfo . meets == 'undefined' || ! olInfo . meets ( 4.10 ) ) alert ( 'overLIB 4.10 or later is required for the CSS Style Plugin.' ) ;
else {
registerCommands ( 'cssstyle,padunit,heightunit,widthunit,textsizeunit,textdecoration,textstyle,textweight,captionsizeunit,captiondecoration,captionstyle,captionweight,closesizeunit,closedecoration,closestyle,closeweight' ) ;
////////
// DEFAULT CONFIGURATION
// Settings you want everywhere are set here. All of this can also be
// changed on your html page or through an overLIB call.
////////
if ( typeof ol _padunit == 'undefined' ) var ol _padunit = "px" ;
if ( typeof ol _heightunit == 'undefined' ) var ol _heightunit = "px" ;
if ( typeof ol _widthunit == 'undefined' ) var ol _widthunit = "px" ;
if ( typeof ol _textsizeunit == 'undefined' ) var ol _textsizeunit = "px" ;
if ( typeof ol _textdecoration == 'undefined' ) var ol _textdecoration = "none" ;
if ( typeof ol _textstyle == 'undefined' ) var ol _textstyle = "normal" ;
if ( typeof ol _textweight == 'undefined' ) var ol _textweight = "normal" ;
if ( typeof ol _captionsizeunit == 'undefined' ) var ol _captionsizeunit = "px" ;
if ( typeof ol _captiondecoration == 'undefined' ) var ol _captiondecoration = "none" ;
if ( typeof ol _captionstyle == 'undefined' ) var ol _captionstyle = "normal" ;
if ( typeof ol _captionweight == 'undefined' ) var ol _captionweight = "bold" ;
if ( typeof ol _closesizeunit == 'undefined' ) var ol _closesizeunit = "px" ;
if ( typeof ol _closedecoration == 'undefined' ) var ol _closedecoration = "none" ;
if ( typeof ol _closestyle == 'undefined' ) var ol _closestyle = "normal" ;
if ( typeof ol _closeweight == 'undefined' ) var ol _closeweight = "normal" ;
////////
// END OF CONFIGURATION
// Don't change anything below this line, all configuration is above.
////////
////////
// INIT
////////
// Runtime variables init. Don't change for config!
var o3 _padunit = "px" ;
var o3 _heightunit = "px" ;
var o3 _widthunit = "px" ;
var o3 _textsizeunit = "px" ;
var o3 _textdecoration = "" ;
var o3 _textstyle = "" ;
var o3 _textweight = "" ;
var o3 _captionsizeunit = "px" ;
var o3 _captiondecoration = "" ;
var o3 _captionstyle = "" ;
var o3 _captionweight = "" ;
var o3 _closesizeunit = "px" ;
var o3 _closedecoration = "" ;
var o3 _closestyle = "" ;
var o3 _closeweight = "" ;
////////
// PLUGIN FUNCTIONS
////////
// Function which sets runtime variables to their default values
function setCSSStyleVariables ( ) {
o3 _padunit = ol _padunit ;
o3 _heightunit = ol _heightunit ;
o3 _widthunit = ol _widthunit ;
o3 _textsizeunit = ol _textsizeunit ;
o3 _textdecoration = ol _textdecoration ;
o3 _textstyle = ol _textstyle ;
o3 _textweight = ol _textweight ;
o3 _captionsizeunit = ol _captionsizeunit ;
o3 _captiondecoration = ol _captiondecoration ;
o3 _captionstyle = ol _captionstyle ;
o3 _captionweight = ol _captionweight ;
o3 _closesizeunit = ol _closesizeunit ;
o3 _closedecoration = ol _closedecoration ;
o3 _closestyle = ol _closestyle ;
o3 _closeweight = ol _closeweight ;
}
// Parses CSS Style commands.
function parseCSSStyleExtras ( pf , i , ar ) {
var k = i ;
if ( k < ar . length ) {
if ( ar [ k ] == CSSSTYLE ) { eval ( pf + 'css=' + ar [ k ] ) ; return k ; }
if ( ar [ k ] == PADUNIT ) { eval ( pf + 'padunit="' + ar [ ++ k ] + '"' ) ; return k ; }
if ( ar [ k ] == HEIGHTUNIT ) { eval ( pf + 'heightunit="' + ar [ ++ k ] + '"' ) ; return k ; }
if ( ar [ k ] == WIDTHUNIT ) { eval ( pf + 'widthunit="' + ar [ ++ k ] + '"' ) ; return k ; }
if ( ar [ k ] == TEXTSIZEUNIT ) { eval ( pf + 'textsizeunit="' + ar [ ++ k ] + '"' ) ; return k ; }
if ( ar [ k ] == TEXTDECORATION ) { eval ( pf + 'textdecoration="' + ar [ ++ k ] + '"' ) ; return k ; }
if ( ar [ k ] == TEXTSTYLE ) { eval ( pf + 'textstyle="' + ar [ ++ k ] + '"' ) ; return k ; }
if ( ar [ k ] == TEXTWEIGHT ) { eval ( pf + 'textweight="' + ar [ ++ k ] + '"' ) ; return k ; }
if ( ar [ k ] == CAPTIONSIZEUNIT ) { eval ( pf + 'captionsizeunit="' + ar [ ++ k ] + '"' ) ; return k ; }
if ( ar [ k ] == CAPTIONDECORATION ) { eval ( pf + 'captiondecoration="' + ar [ ++ k ] + '"' ) ; return k ; }
if ( ar [ k ] == CAPTIONSTYLE ) { eval ( pf + 'captionstyle="' + ar [ ++ k ] + '"' ) ; return k ; }
if ( ar [ k ] == CAPTIONWEIGHT ) { eval ( pf + 'captionweight="' + ar [ ++ k ] + '"' ) ; return k ; }
if ( ar [ k ] == CLOSESIZEUNIT ) { eval ( pf + 'closesizeunit="' + ar [ ++ k ] + '"' ) ; return k ; }
if ( ar [ k ] == CLOSEDECORATION ) { eval ( pf + 'closedecoration="' + ar [ ++ k ] + '"' ) ; return k ; }
if ( ar [ k ] == CLOSESTYLE ) { eval ( pf + 'closestyle="' + ar [ ++ k ] + '"' ) ; return k ; }
if ( ar [ k ] == CLOSEWEIGHT ) { eval ( pf + 'closeweight="' + ar [ ++ k ] + '"' ) ; return k ; }
}
return - 1 ;
}
////////
// LAYER GENERATION FUNCTIONS
////////
// Makes simple table without caption
function ol _content _simple _cssstyle ( text ) {
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>' ;
set _background ( "" ) ;
return txt ;
}
// Makes table with caption and optional close link
function ol _content _caption _cssstyle ( text , title , close ) {
var nameId ;
closing = "" ;
closeevent = "onMouseOver" ;
if ( o3 _closeclick == 1 ) closeevent = ( o3 _closetitle ? "title='" + o3 _closetitle + "'" : "" ) + " onClick" ;
if ( o3 _capicon != "" ) {
nameId = ' hspace=\"5\"' + ' align=\"middle\" alt=\"\"' ;
if ( typeof o3 _dragimg != 'undefined' && o3 _dragimg ) nameId = ' hspace=\"5\"' + ' name=\"' + o3 _dragimg + '\" id=\"' + o3 _dragimg + '\" align=\"middle\" alt=\"Drag Enabled\" title=\"Drag Enabled\"' ;
o3 _capicon = '<img src=\"' + o3 _capicon + '\"' + nameId + ' />' ;
}
if ( close != "" ) {
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>' ;
}
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>' ;
set _background ( "" ) ;
return txt ;
}
// Sets the background picture, padding and lots more. :)
function ol _content _background _cssstyle ( text , picture , hasfullhtml ) {
if ( hasfullhtml ) {
txt = text ;
} else {
var pU , hU , wU ;
pU = ( o3 _padunit == '%' ? '%' : '' ) ;
hU = ( o3 _heightunit == '%' ? '%' : '' ) ;
wU = ( o3 _widthunit == '%' ? '%' : '' ) ;
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>' ;
}
set _background ( picture ) ;
return txt ;
}
////////
// PLUGIN REGISTRATIONS
////////
registerRunTimeFunction ( setCSSStyleVariables ) ;
registerCmdLineFunction ( parseCSSStyleExtras ) ;
registerHook ( "ol_content_simple" , ol _content _simple _cssstyle , FALTERNATE , CSSSTYLE ) ;
registerHook ( "ol_content_caption" , ol _content _caption _cssstyle , FALTERNATE , CSSSTYLE ) ;
registerHook ( "ol_content_background" , ol _content _background _cssstyle , FALTERNATE , CSSSTYLE ) ;
}