|
29 | 29 | $('#powertip-css').attr('href', '../css/jquery.powertip' + theme + '.css');
|
30 | 30 | }
|
31 | 31 |
|
| 32 | + // css position switcher allows testing html and body CSS position values that |
| 33 | + // changes the origin from which the tooltip is positioned. |
| 34 | + function setCssPosition() { |
| 35 | + var attributeSets = { |
| 36 | + // default positioning is static |
| 37 | + static: { position: '', left: '', right: '', top: '', bottom: '' }, |
| 38 | + absolute: { position: 'absolute', left: '50px', right: '100px', top: '25px', bottom: '75px' }, |
| 39 | + relative: { position: 'relative', left: '50px', right: '100px', top: '25px', bottom: '75px' }, |
| 40 | + fixed: { position: 'fixed', left: '50px', right: '100px', top: '25px', bottom: '75px' }, |
| 41 | + }; |
| 42 | + var posType = $('#position-switcher').val(); |
| 43 | + var $html = $(document.documentElement); |
| 44 | + var $body = $(document.body); |
| 45 | + $html.css(attributeSets['static']); |
| 46 | + $body.css(attributeSets['static']); |
| 47 | + switch(posType) { |
| 48 | + case 'html-relative': |
| 49 | + $html.css(attributeSets['relative']); |
| 50 | + break; |
| 51 | + case 'html-fixed': |
| 52 | + $html.css(attributeSets['fixed']); |
| 53 | + break; |
| 54 | + case 'html-absolute': |
| 55 | + $html.css(attributeSets['absolute']); |
| 56 | + break; |
| 57 | + case 'body-relative': |
| 58 | + $body.css(attributeSets['relative']); |
| 59 | + break; |
| 60 | + case 'body-fixed': |
| 61 | + $body.css(attributeSets['fixed']); |
| 62 | + break; |
| 63 | + case 'body-absolute': |
| 64 | + $body.css(attributeSets['absolute']); |
| 65 | + break; |
| 66 | + default: |
| 67 | + // attributes clear above |
| 68 | + break; |
| 69 | + } |
| 70 | + // Trigger resize to force recalculation of position compensation |
| 71 | + window.dispatchEvent(new Event('resize')); |
| 72 | + } |
| 73 | + |
32 | 74 | // run theme switcher on page load
|
33 | 75 | setTheme();
|
34 | 76 |
|
35 |
| - // hook theme switcher to select change |
| 77 | + // hook theme and position switcher to select change |
36 | 78 | $('#theme-switcher').on('change', setTheme);
|
| 79 | + $('#position-switcher').on('change', setCssPosition); |
37 | 80 |
|
38 | 81 | // session debug info box
|
39 | 82 | var debugOutput = $('#session pre');
|
@@ -82,6 +125,16 @@ <h1>PowerTip Edge Case Tests</h1>
|
82 | 125 | <option value="red">Red</option>
|
83 | 126 | <option value="yellow">Yellow</option>
|
84 | 127 | </select>
|
| 128 | + Tooltip Ancestor CSS Position: |
| 129 | + <select id="position-switcher"> |
| 130 | + <option value="">Default</option> |
| 131 | + <option value="html-relative">HTML relative</option> |
| 132 | + <option value="html-fixed">HTML fixed</option> |
| 133 | + <option value="html-absolute">HTML absolute</option> |
| 134 | + <option value="body-relative">BODY relative</option> |
| 135 | + <option value="body-fixed">BODY fixed</option> |
| 136 | + <option value="body-absolute">BODY absolute</option> |
| 137 | + </select> |
85 | 138 | </p>
|
86 | 139 | </header>
|
87 | 140 | <section id="open-on-load">
|
|
0 commit comments