nicer js
[plewww.git] / plekit / niftycorner / nifty_init.js
1 /*
2   $Id$
3
4  instead of explicitly calling
5  Nifty ('div#$id','medium');
6  on every single element as the original niftycube.js recommends,
7  we just do that on every element that has one of the
8  the nifty-{small,medium,big} class set
9 */
10
11 var nifty_inited = false;
12
13 function nifty_init () {
14   
15   if ( nifty_inited ) return;
16   const sizes = { 0: 'small', 1: 'medium', 2: 'big', length: 3}
17   for (const [int, size] of Object.entries(sizes)) {
18
19     let elements = document.getElementsByClassName('nifty-'+size)
20     for (const element of elements) {
21       // use Rounded rather than Nifty
22       // the latter needs an id that some elements don't have
23       // plus, it's more efficient anyway
24       pleRounded(element, size)
25     }
26   }
27   nifty_inited = true
28 }