| | @@ -55,11 +55,11 @@ |
| 55 | 55 | from the default), the class "fossil-PopupWidget" is always set |
| 56 | 56 | in order to allow certain app-internal CSS to account for popup |
| 57 | 57 | windows in special cases. |
| 58 | 58 | |
| 59 | 59 | .style: optional object of properties to copy directly into |
| 60 | | - the element's style object. |
| 60 | + the element's style object. |
| 61 | 61 | |
| 62 | 62 | The options passed to this constructor get normalized into a |
| 63 | 63 | separate object which includes any default values for options not |
| 64 | 64 | provided by the caller. That object is available this the |
| 65 | 65 | resulting PopupWidget's options property. Default values for any |
| | @@ -161,11 +161,11 @@ |
| 161 | 161 | Sidebar: showing/hiding the widget is, as is conventional for |
| 162 | 162 | this framework, done by removing/adding the 'hidden' CSS class |
| 163 | 163 | to it, so that class must be defined appropriately. |
| 164 | 164 | */ |
| 165 | 165 | show: function(){ |
| 166 | | - var x = undefined, y = undefined, showIt, |
| 166 | + let x = undefined, y = undefined, showIt, |
| 167 | 167 | wasShown = !this.e.classList.contains('hidden'); |
| 168 | 168 | if(2===arguments.length){ |
| 169 | 169 | x = arguments[0]; |
| 170 | 170 | y = arguments[1]; |
| 171 | 171 | showIt = true; |
| | @@ -344,11 +344,12 @@ |
| 344 | 344 | - No arguments, which is equivalent to passing the string |
| 345 | 345 | ".help-buttonlet:not(.processed)". |
| 346 | 346 | |
| 347 | 347 | Passing the same element(s) more than once is a no-op: during |
| 348 | 348 | initialization, each elements get the class'processed' added to |
| 349 | | - it, and any elements with that class are skipped. |
| 349 | + it, and any elements with that class are skipped. Each element |
| 350 | + gets the 'help-buttonlet' CSS class added to it. |
| 350 | 351 | |
| 351 | 352 | All child nodes of a help buttonlet are removed from the button |
| 352 | 353 | during initialization and stashed away for use in a PopupWidget |
| 353 | 354 | when the botton is clicked. |
| 354 | 355 | |
| | @@ -374,24 +375,24 @@ |
| 374 | 375 | calculate the resulting size, then move and/or resize it. |
| 375 | 376 | |
| 376 | 377 | This algorithm/these heuristics can certainly be improved |
| 377 | 378 | upon. |
| 378 | 379 | */ |
| 379 | | - var popupRect, rectElem = ev.target; |
| 380 | + let popupRect, rectElem = ev.target; |
| 380 | 381 | while(rectElem){ |
| 381 | 382 | popupRect = rectElem.getClientRects()[0]/*undefined if off-screen!*/; |
| 382 | 383 | if(popupRect) break; |
| 383 | 384 | rectElem = rectElem.parentNode; |
| 384 | 385 | } |
| 385 | 386 | if(!popupRect) popupRect = {x:0, y:0, left:0, right:0}; |
| 386 | | - var x = popupRect.left, y = popupRect.top; |
| 387 | + let x = popupRect.left, y = popupRect.top; |
| 387 | 388 | if(x<0) x = 0; |
| 388 | 389 | if(y<0) y = 0; |
| 389 | 390 | if(rectElem){ |
| 390 | 391 | /* Try to ensure that the popup's z-level is higher than this element's */ |
| 391 | 392 | const rz = window.getComputedStyle(rectElem).zIndex; |
| 392 | | - var myZ; |
| 393 | + let myZ; |
| 393 | 394 | if(rz && !isNaN(+rz)){ |
| 394 | 395 | myZ = +rz + 1; |
| 395 | 396 | }else{ |
| 396 | 397 | myZ = 10000/*guess!*/; |
| 397 | 398 | } |
| | @@ -416,11 +417,11 @@ |
| 416 | 417 | fch.popup.show(x, y); |
| 417 | 418 | return false; |
| 418 | 419 | }; |
| 419 | 420 | f.foreachElement = function(e){ |
| 420 | 421 | if(e.classList.contains('processed')) return; |
| 421 | | - e.classList.add('processed'); |
| 422 | + e.classList.add('processed', 'help-buttonlet'); |
| 422 | 423 | e.$helpContent = []; |
| 423 | 424 | /* We have to move all child nodes out of the way because we |
| 424 | 425 | cannot hide TEXT nodes via CSS (which cannot select TEXT |
| 425 | 426 | nodes). We have to do it in two steps to avoid invaliding |
| 426 | 427 | the list during traversal. */ |
| | @@ -427,11 +428,11 @@ |
| 427 | 428 | e.childNodes.forEach((ch)=>e.$helpContent.push(ch)); |
| 428 | 429 | e.$helpContent.forEach((ch)=>ch.remove()); |
| 429 | 430 | e.addEventListener('click', f.clickHandler, false); |
| 430 | 431 | }; |
| 431 | 432 | }/*static init*/ |
| 432 | | - var elems; |
| 433 | + let elems; |
| 433 | 434 | if(!arguments.length){ |
| 434 | 435 | arguments[0] = '.help-buttonlet:not(.processed)'; |
| 435 | 436 | arguments.length = 1; |
| 436 | 437 | } |
| 437 | 438 | if(arguments.length){ |
| | @@ -443,11 +444,11 @@ |
| 443 | 444 | elems = arguments[0]; |
| 444 | 445 | } |
| 445 | 446 | } |
| 446 | 447 | if(elems) elems.forEach(f.foreachElement); |
| 447 | 448 | }, |
| 448 | | - |
| 449 | + |
| 449 | 450 | /** |
| 450 | 451 | Sets up the given element as a "help buttonlet", adding the CSS |
| 451 | 452 | class help-buttonlet to it. Any (optional) arguments after the |
| 452 | 453 | first are appended to the element using fossil.dom.append(), so |
| 453 | 454 | that they become the content for the buttonlet's popup help. |
| | @@ -465,7 +466,6 @@ |
| 465 | 466 | return elem; |
| 466 | 467 | } |
| 467 | 468 | }/*helpButtonlets*/; |
| 468 | 469 | |
| 469 | 470 | F.onDOMContentLoaded( ()=>F.helpButtonlets.setup() ); |
| 470 | | - |
| 471 | 471 | })(window.fossil); |
| 472 | 472 | |