diff options
| author | fisharebest <fisharebest@gmail.com> | 2012-07-24 10:26:04 +0000 |
|---|---|---|
| committer | fisharebest <fisharebest@gmail.com> | 2012-07-24 10:26:04 +0000 |
| commit | d3e45cb99d1be2b6afc86c19fcfecbef609d377a (patch) | |
| tree | ae8d7a89d028639a492b998fe25be7552cf1d3c7 | |
| parent | 45eab8452eb724e302e7254bce82a0b6f804afbd (diff) | |
| download | webtrees-d3e45cb99d1be2b6afc86c19fcfecbef609d377a.tar.gz webtrees-d3e45cb99d1be2b6afc86c19fcfecbef609d377a.tar.bz2 webtrees-d3e45cb99d1be2b6afc86c19fcfecbef609d377a.zip | |
Contribution from Matt N: combine lightbox LTR and RTL scripts into a single file.
| -rw-r--r-- | modules_v3/lightbox/js/tip_balloon.js | 31 | ||||
| -rw-r--r-- | modules_v3/lightbox/js/tip_balloon_RTL.js | 233 | ||||
| -rw-r--r-- | modules_v3/lightbox/module.php | 7 |
3 files changed, 21 insertions, 250 deletions
diff --git a/modules_v3/lightbox/js/tip_balloon.js b/modules_v3/lightbox/js/tip_balloon.js index 53dddea4a6..8467a0aaa2 100644 --- a/modules_v3/lightbox/js/tip_balloon.js +++ b/modules_v3/lightbox/js/tip_balloon.js @@ -76,9 +76,17 @@ balloon.OnCreateContentString = function() { if(!tt_aV[BALLOON]) return false; - + var aImg, sImgZ, sCssCrn, sVaT, sVaB, sCssImg; + var isRtl = textDirection == "rtl"; + var iImgTopStart = isRtl ? 3 : 1; + var iImgTopEnd = isRtl ? 1 : 3; + var iImgBorderStart = isRtl ? 4 : 8; + var iImgBorderEnd = isRtl ? 8 : 4; + var iImgButtonStart = isRtl ? 5 : 7; + var iImgBottomEnd = isRtl ? 7 : 5; + // Cache balloon images in advance: // Either use the pre-cached default images... if(tt_aV[BALLOONIMGPATH] == config.BalloonImgPath) @@ -95,7 +103,7 @@ balloon.OnCreateContentString = function() tt_sContent = '<table border="0" cellpadding="0" cellspacing="0" style="width:auto;padding:0px;margin:0px;left:0px;top:0px;"><tr>' // Left-top corner + '<td' + sCssCrn + sVaB + '>' - + '<img src="' + aImg[1].src + '" width="' + tt_aV[BALLOONEDGESIZE] + '" height="' + tt_aV[BALLOONEDGESIZE] + sImgZ + + '<img src="' + aImg[iImgTopStart].src + '" width="' + tt_aV[BALLOONEDGESIZE] + '" height="' + tt_aV[BALLOONEDGESIZE] + sImgZ + '</td>' // Top border + '<td valign="bottom" style="position:relative;padding:0px;margin:0px;overflow:hidden;">' @@ -105,13 +113,13 @@ balloon.OnCreateContentString = function() + '</td>' // Right-top corner + '<td' + sCssCrn + sVaB + '>' - + '<img src="' + aImg[3].src + '" width="' + tt_aV[BALLOONEDGESIZE] + '" height="' + tt_aV[BALLOONEDGESIZE] + sImgZ + + '<img src="' + aImg[iImgTopEnd].src + '" width="' + tt_aV[BALLOONEDGESIZE] + '" height="' + tt_aV[BALLOONEDGESIZE] + sImgZ + '</td>' + '</tr><tr>' // Left border - + '<td style="position:relative;padding:0px;margin:0px;width:' + tt_aV[BALLOONEDGESIZE] + 'px;overflow:hidden;background-image:url(' + aImg[8].src + ');">' + + '<td style="position:relative;padding:0px;margin:0px;width:' + tt_aV[BALLOONEDGESIZE] + 'px;overflow:hidden;background-image:url(' + aImg[iImgBorderStart].src + ');">' // Redundant image for bugous old Geckos that won't auto-expand TD height to 100% - + '<img width="' + tt_aV[BALLOONEDGESIZE] + '" height="100%" src="' + aImg[8].src + sImgZ + + '<img width="' + tt_aV[BALLOONEDGESIZE] + '" height="100%" src="' + aImg[iImgBorderStart].src + sImgZ + '</td>' // Content + '<td id="bALlO0nBdY" style="position:relative;line-height:normal;' @@ -125,14 +133,14 @@ balloon.OnCreateContentString = function() + ';width:' + ((balloon.width > 0) ? (balloon.width + 'px') : 'auto') + ';">' + tt_sContent + '</td>' // Right border - + '<td style="position:relative;padding:0px;margin:0px;width:' + tt_aV[BALLOONEDGESIZE] + 'px;overflow:hidden;background-image:url(' + aImg[4].src + ');">' + + '<td style="position:relative;padding:0px;margin:0px;width:' + tt_aV[BALLOONEDGESIZE] + 'px;overflow:hidden;background-image:url(' + aImg[iImgBorderEnd].src + ');">' // Image redundancy for bugous old Geckos that won't auto-expand TD height to 100% - + '<img width="' + tt_aV[BALLOONEDGESIZE] + '" height="100%" src="' + aImg[4].src + sImgZ + + '<img width="' + tt_aV[BALLOONEDGESIZE] + '" height="100%" src="' + aImg[iImgBorderEnd].src + sImgZ + '</td>' + '</tr><tr>' // Left-bottom corner + '<td' + sCssCrn + sVaT + '>' - + '<img src="' + aImg[7].src + '" width="' + tt_aV[BALLOONEDGESIZE] + '" height="' + tt_aV[BALLOONEDGESIZE] + sImgZ + + '<img src="' + aImg[iImgButtonStart].src + '" width="' + tt_aV[BALLOONEDGESIZE] + '" height="' + tt_aV[BALLOONEDGESIZE] + sImgZ + '</td>' // Bottom border + '<td valign="top" style="position:relative;padding:0px;margin:0px;overflow:hidden;">' @@ -141,7 +149,7 @@ balloon.OnCreateContentString = function() + '</td>' // Right-bottom corner + '<td' + sCssCrn + sVaT + '>' - + '<img src="' + aImg[5].src + '" width="' + tt_aV[BALLOONEDGESIZE] + '" height="' + tt_aV[BALLOONEDGESIZE] + sImgZ + + '<img src="' + aImg[iImgButtonEnd].src + '" width="' + tt_aV[BALLOONEDGESIZE] + '" height="' + tt_aV[BALLOONEDGESIZE] + sImgZ + '</td>' + '</tr></table>'; return true; @@ -185,8 +193,9 @@ balloon.OnMoveAfter = function() function Balloon_CalcStemX() { - var x = tt_musX - tt_x + tt_aV[BALLOONSTEMOFFSET] - tt_aV[BALLOONEDGESIZE]; - return Math.max(Math.min(x, tt_w - tt_aV[BALLOONSTEMWIDTH] - (tt_aV[BALLOONEDGESIZE] << 1) - 2), 2); + var rtlMultiplier = (textDirection == "rtl" ? -1 : 1); + var x = rtlMultiplier * tt_musX - tt_x + tt_aV[BALLOONSTEMOFFSET] - tt_aV[BALLOONEDGESIZE]; + return Math.max(Math.min(x, tt_w - tt_aV[BALLOONSTEMWIDTH] - (tt_aV[BALLOONEDGESIZE] << 1) - 2), rtlMultiplier * 2); } function Balloon_CacheImgs(sPath) diff --git a/modules_v3/lightbox/js/tip_balloon_RTL.js b/modules_v3/lightbox/js/tip_balloon_RTL.js deleted file mode 100644 index 57ed62937d..0000000000 --- a/modules_v3/lightbox/js/tip_balloon_RTL.js +++ /dev/null @@ -1,233 +0,0 @@ -/* -tip_balloon.js v. 1.51 - -The latest version is available at -http://www.walterzorn.com -or http://www.devira.com -or http://www.walterzorn.de - -Initial author: Walter Zorn -Last modified: 3.6.2008 - -Extension for the tooltip library wz_tooltip.js. -Implements balloon tooltips. -*/ - -// Make sure that the core file wz_tooltip.js is included first -if(typeof config == "undefined") - alert("Error:\nThe core tooltip script file 'wz_tooltip.js' must be included first, before the plugin files!"); - -// Here we define new global configuration variable(s) (as members of the -// predefined "config." class). -// From each of these config variables, wz_tooltip.js will automatically derive -// a command which can be passed to Tip() or TagToTip() in order to customize -// tooltips individually. These command names are just the config variable -// name(s) translated to uppercase, -// e.g. from config. Balloon a command BALLOON will automatically be -// created. - -//=================== GLOBAL TOOPTIP CONFIGURATION =========================// - -config. Balloon = false // true or false - set to true if you want this to be the default behaviour -config. BalloonImgPath = WT_STATIC_URL+WT_MODULES_DIR+"lightbox/js/tip_balloon/" // Path to images (border, corners, stem), in quotes. Path must be relative to your HTML file. - -// Sizes of balloon images -config. BalloonEdgeSize = 6 // Integer - sidelength of quadratic corner images -config. BalloonStemWidth = 15 // Integer -config. BalloonStemHeight = 19 // Integer -config. BalloonStemOffset = -7 // Integer - horizontal offset of left stem edge from mouse (recommended: -stemwidth/2 to center the stem above the mouse) - -//======= END OF TOOLTIP CONFIG, DO NOT CHANGE ANYTHING BELOW ==============// - - - - - -// Create a new tt_Extension object (make sure that the name of that object, -// here balloon, is unique amongst the extensions available for wz_tooltips.js): -var balloon = new tt_Extension(); - -// Implement extension eventhandlers on which our extension should react - -balloon.OnLoadConfig = function() -{ - if(tt_aV[BALLOON]) - { - // Turn off native style properties which are not appropriate - balloon.padding = Math.max(tt_aV[PADDING] - tt_aV[BALLOONEDGESIZE], 0); - balloon.width = tt_aV[WIDTH]; - //if(tt_bBoxOld) - // balloon.width += (balloon.padding << 1); - tt_aV[BORDERWIDTH] = 0; - tt_aV[WIDTH] = 0; - tt_aV[PADDING] = 0; - tt_aV[BGCOLOR] = ""; - tt_aV[BGIMG] = ""; - tt_aV[SHADOW] = false; - // Append slash to img path if missing - if(tt_aV[BALLOONIMGPATH].charAt(tt_aV[BALLOONIMGPATH].length - 1) != '/') - tt_aV[BALLOONIMGPATH] += "/"; - return true; - } - return false; -}; - -balloon.OnCreateContentString = function() -{ - if(!tt_aV[BALLOON]) - return false; - - var aImg, sImgZ, sCssCrn, sVaT, sVaB, sCssImg; - - // Cache balloon images in advance: - // Either use the pre-cached default images... - if(tt_aV[BALLOONIMGPATH] == config.BalloonImgPath) - aImg = balloon.aDefImg; - // ...or load images from different directory - else - aImg = Balloon_CacheImgs(tt_aV[BALLOONIMGPATH]); - sCssCrn = ' style="position:relative;width:' + tt_aV[BALLOONEDGESIZE] + 'px;padding:0px;margin:0px;overflow:hidden;line-height:0px;'; - sVaT = 'vertical-align:top;" valign="top"'; - sVaB = 'vertical-align:bottom;" valign="bottom"'; - sCssImg = 'padding:0px;margin:0px;border:0px;'; - sImgZ = '" style="' + sCssImg + '" />'; - - tt_sContent = '<table border="0" cellpadding="0" cellspacing="0" style="width:auto;padding:0px;margin:0px;left:0px;top:0px;"><tr>' - // Left-top corner - + '<td' + sCssCrn + sVaB + '>' - + '<img src="' + aImg[3].src + '" width="' + tt_aV[BALLOONEDGESIZE] + '" height="' + tt_aV[BALLOONEDGESIZE] + sImgZ - + '</td>' - // Top border - + '<td valign="bottom" style="position:relative;padding:0px;margin:0px;overflow:hidden;">' - + '<img id="bALlOOnT" style="position:relative;top:1px;z-index:1;display:none;' + sCssImg + '" src="' + aImg[9].src + '" width="' + tt_aV[BALLOONSTEMWIDTH] + '" height="' + tt_aV[BALLOONSTEMHEIGHT] + '" />' - + '<div style="position:relative;z-index:0;padding:0px;margin:0px;overflow:hidden;width:auto;height:' + tt_aV[BALLOONEDGESIZE] + 'px;background-image:url(' + aImg[2].src + ');">' - + '</div>' - + '</td>' - // Right-top corner - + '<td' + sCssCrn + sVaB + '>' - + '<img src="' + aImg[1].src + '" width="' + tt_aV[BALLOONEDGESIZE] + '" height="' + tt_aV[BALLOONEDGESIZE] + sImgZ - + '</td>' - + '</tr><tr>' - // Left border - + '<td style="position:relative;padding:0px;margin:0px;width:' + tt_aV[BALLOONEDGESIZE] + 'px;overflow:hidden;background-image:url(' + aImg[4].src + ');">' - // Redundant image for bugous old Geckos that won't auto-expand TD height to 100% - + '<img width="' + tt_aV[BALLOONEDGESIZE] + '" height="100%" src="' + aImg[4].src + sImgZ - + '</td>' - // Content - + '<td id="bALlO0nBdY" style="position:relative;line-height:normal;' - + ';background-image:url(' + aImg[0].src + ')' - + ';color:' + tt_aV[FONTCOLOR] - + ';font-family:' + tt_aV[FONTFACE] - + ';font-size:' + tt_aV[FONTSIZE] - + ';font-weight:' + tt_aV[FONTWEIGHT] - + ';text-align:' + tt_aV[TEXTALIGN] - + ';padding:' + balloon.padding + 'px' - + ';width:' + ((balloon.width > 0) ? (balloon.width + 'px') : 'auto') - + ';">' + tt_sContent + '</td>' - // Right border - + '<td style="position:relative;padding:0px;margin:0px;width:' + tt_aV[BALLOONEDGESIZE] + 'px;overflow:hidden;background-image:url(' + aImg[8].src + ');">' - // Image redundancy for bugous old Geckos that won't auto-expand TD height to 100% - + '<img width="' + tt_aV[BALLOONEDGESIZE] + '" height="100%" src="' + aImg[8].src + sImgZ - + '</td>' - + '</tr><tr>' - // Left-bottom corner - + '<td' + sCssCrn + sVaT + '>' - + '<img src="' + aImg[5].src + '" width="' + tt_aV[BALLOONEDGESIZE] + '" height="' + tt_aV[BALLOONEDGESIZE] + sImgZ - + '</td>' - // Bottom border - + '<td valign="top" style="position:relative;padding:0px;margin:0px;overflow:hidden;">' - + '<div style="position:relative;left:0px;top:0px;padding:0px;margin:0px;overflow:hidden;width:auto;height:' + tt_aV[BALLOONEDGESIZE] + 'px;background-image:url(' + aImg[6].src + ');"></div>' - + '<img id="bALlOOnB" style="position:relative;top:-1px;left:2px;z-index:1;display:none;' + sCssImg + '" src="' + aImg[10].src + '" width="' + tt_aV[BALLOONSTEMWIDTH] + '" height="' + tt_aV[BALLOONSTEMHEIGHT] + '" />' - + '</td>' - // Right-bottom corner - + '<td' + sCssCrn + sVaT + '>' - + '<img src="' + aImg[7].src + '" width="' + tt_aV[BALLOONEDGESIZE] + '" height="' + tt_aV[BALLOONEDGESIZE] + sImgZ - + '</td>' - + '</tr></table>'; - return true; -}; - -balloon.OnSubDivsCreated = function() -{ - if(tt_aV[BALLOON]) - { - balloon.iStem = tt_aV[ABOVE] * 1; - balloon.aStem = [tt_GetElt("bALlOOnT"), tt_GetElt("bALlOOnB")]; - balloon.aStem[balloon.iStem].style.display = "inline"; - if (balloon.width < -1) - Balloon_MaxW(); - return true; - } - return false; -}; - -// Display the stem appropriately -balloon.OnMoveAfter = function() -{ - if(tt_aV[BALLOON]) - { - var iStem = (tt_aV[ABOVE] != tt_bJmpVert) * 1; - - // Tooltip position vertically flipped? - if(iStem != balloon.iStem) - { - // Display opposite stem - balloon.aStem[balloon.iStem].style.display = "none"; - balloon.aStem[iStem].style.display = "inline"; - balloon.iStem = iStem; - } - - balloon.aStem[iStem].style.left = Balloon_CalcStemX() + "px"; - return true; - } - return false; -}; - -function Balloon_CalcStemX() -{ - // var x = tt_musX - tt_x + tt_aV[BALLOONSTEMOFFSET] - tt_aV[BALLOONEDGESIZE]; - // return Math.max(Math.min(x, tt_w - tt_aV[BALLOONSTEMWIDTH] - (tt_aV[BALLOONEDGESIZE] << 1) - 2), 2); - var x = -tt_musX - tt_x + tt_aV[BALLOONSTEMOFFSET] - tt_aV[BALLOONEDGESIZE]; - return Math.max(Math.min(x, tt_w - tt_aV[BALLOONSTEMWIDTH] - (tt_aV[BALLOONEDGESIZE] << 1) - 2), -2); -} - -function Balloon_CacheImgs(sPath) -{ - var asImg = ["background", "lt", "t", "rt", "r", "rb", "b", "lb", "l", "stemt", "stemb"], - n = asImg.length, - aImg = new Array(n), - img; - - while(n) - {--n; - img = aImg[n] = new Image(); - img.src = sPath + asImg[n] + ".gif"; // Change to ".png" if you want to use PNG images - } - return aImg; -} - -function Balloon_MaxW() -{ - var bdy = tt_GetElt("bALlO0nBdY"); - - if (bdy) - { - var iAdd = tt_bBoxOld ? (balloon.padding << 1) : 0, w = tt_GetDivW(bdy); - if (w > -balloon.width + iAdd) - bdy.style.width = (-balloon.width + iAdd) + "px"; - } -} - -// This mechanism pre-caches the default images specified by -// congif.BalloonImgPath, so, whenever a balloon tip using these default images -// is created, no further server connection is necessary. -function Balloon_PreCacheDefImgs() -{ - // Append slash to img path if missing - if(config.BalloonImgPath.charAt(config.BalloonImgPath.length - 1) != '/') - config.BalloonImgPath += "/"; - // Preload default images into array - balloon.aDefImg = Balloon_CacheImgs(config.BalloonImgPath); -} - -Balloon_PreCacheDefImgs(); diff --git a/modules_v3/lightbox/module.php b/modules_v3/lightbox/module.php index 522fb70bf5..33382a5e9e 100644 --- a/modules_v3/lightbox/module.php +++ b/modules_v3/lightbox/module.php @@ -59,6 +59,7 @@ class lightbox_WT_Module extends WT_Module implements WT_Module_Config, WT_Modul echo file_get_contents(WT_MODULES_DIR.$this->getName().'/js/wz_tooltip.js'); echo file_get_contents(WT_MODULES_DIR.$this->getName().'/js/tip_centerwindow.js'); echo file_get_contents(WT_MODULES_DIR.$this->getName().'/js/clsource_music.js'); + echo file_get_contents(WT_MODULES_DIR.$this->getName().'/js/tip_balloon.js'); break; default: header('HTTP/1.0 404 Not Found'); @@ -224,12 +225,6 @@ class lightbox_WT_Module extends WT_Module implements WT_Module_Config, WT_Modul $js.='var CB_SlShowTime = "'.get_module_setting('lightbox', 'LB_SS_SPEED', '6').'"; // Slide show timer var CB_Animation = "'.get_module_setting('lightbox', 'LB_TRANSITION', 'warp').'";'; // Next/Prev Image transition effect - if ($TEXT_DIRECTION=='ltr') { - $js.=file_get_contents(WT_MODULES_DIR.$this->getName().'/js/tip_balloon.js'); - } else { - $js.=file_get_contents(WT_MODULES_DIR.$this->getName().'/js/tip_balloon_RTL.js'); - } - $controller->addExternalJavascript('module.php?mod='.$this->getName().'&mod_action=js'); $controller->addInlineJavascript($js); return true; |
