[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 /* 2 tip_centerwindow.js v. 1.21 3 4 The latest version is available at 5 http://www.walterzorn.com 6 or http://www.devira.com 7 or http://www.walterzorn.de 8 9 Initial author: Walter Zorn 10 Last modified: 3.6.2008 11 12 Extension for the tooltip library wz_tooltip.js. 13 Centers a sticky tooltip in the window's visible clientarea, 14 optionally even if the window is being scrolled or resized. 15 */ 16 17 // Make sure that the core file wz_tooltip.js is included first 18 if(typeof config == "undefined") 19 alert("Error:\nThe core tooltip script file 'wz_tooltip.js' must be included first, before the plugin files!"); 20 21 // Here we define new global configuration variable(s) (as members of the 22 // predefined "config." class). 23 // From each of these config variables, wz_tooltip.js will automatically derive 24 // a command which can be passed to Tip() or TagToTip() in order to customize 25 // tooltips individually. These command names are just the config variable 26 // name(s) translated to uppercase, 27 // e.g. from config. CenterWindow a command CENTERWINDOW will automatically be 28 // created. 29 30 //=================== GLOBAL TOOPTIP CONFIGURATION =========================// 31 config. CenterWindow = false // true or false - set to true if you want this to be the default behaviour 32 config. CenterAlways = false // true or false - recenter if window is resized or scrolled 33 //======= END OF TOOLTIP CONFIG, DO NOT CHANGE ANYTHING BELOW ==============// 34 35 36 // Create a new tt_Extension object (make sure that the name of that object, 37 // here ctrwnd, is unique amongst the extensions available for 38 // wz_tooltips.js): 39 var ctrwnd = new tt_Extension(); 40 41 // Implement extension eventhandlers on which our extension should react 42 ctrwnd.OnLoadConfig = function() 43 { 44 if(tt_aV[CENTERWINDOW]) 45 { 46 // Permit CENTERWINDOW only if the tooltip is sticky 47 if(tt_aV[STICKY]) 48 { 49 if(tt_aV[CENTERALWAYS]) 50 { 51 // IE doesn't support style.position "fixed" 52 if(tt_ie) 53 tt_AddEvtFnc(window, "scroll", Ctrwnd_DoCenter); 54 else 55 tt_aElt[0].style.position = "fixed"; 56 tt_AddEvtFnc(window, "resize", Ctrwnd_DoCenter); 57 } 58 return true; 59 } 60 tt_aV[CENTERWINDOW] = false; 61 } 62 return false; 63 }; 64 // We react on the first OnMouseMove event to center the tip on that occasion 65 ctrwnd.OnMoveBefore = Ctrwnd_DoCenter; 66 ctrwnd.OnKill = function() 67 { 68 if(tt_aV[CENTERWINDOW] && tt_aV[CENTERALWAYS]) 69 { 70 tt_RemEvtFnc(window, "resize", Ctrwnd_DoCenter); 71 if(tt_ie) 72 tt_RemEvtFnc(window, "scroll", Ctrwnd_DoCenter); 73 else 74 tt_aElt[0].style.position = "absolute"; 75 } 76 return false; 77 }; 78 // Helper function 79 function Ctrwnd_DoCenter() 80 { 81 if(tt_aV[CENTERWINDOW]) 82 { 83 var x, y, dx, dy; 84 85 // Here we use some functions and variables (tt_w, tt_h) which the 86 // extension API of wz_tooltip.js provides for us 87 if(tt_ie || !tt_aV[CENTERALWAYS]) 88 { 89 dx = tt_GetScrollX(); 90 dy = tt_GetScrollY(); 91 } 92 else 93 { 94 dx = 0; 95 dy = 0; 96 } 97 // Position the tip, offset from the center by OFFSETX and OFFSETY 98 x = (tt_GetClientW() - tt_w) / 2 + dx + tt_aV[OFFSETX]; 99 y = (tt_GetClientH() - tt_h) / 2 + dy + tt_aV[OFFSETY]; 100 tt_SetTipPos(x, y); 101 return true; 102 } 103 return false; 104 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |