Blame view
templates/html/common/wizefunc.js
6.62 KB
659c7d608 On regroupe les f... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
/* Go to top of page */ function topFunction() { document.body.scrollTop = 0; document.documentElement.scrollTop = 0; } /* open/close navigation optionally slide page */ function openNav(slide) { if (document.getElementById("mySidenav").getAttribute("class").split(' ')[1] == "menuClosed") { document.getElementById("mySidenav").style.width = "300px"; if (slide==1) { document.getElementById("main").style.marginLeft = "300px"; } document.getElementById("mySidenav").setAttribute("class","menu menuOpen"); /* Scroll to top when opening menu */ topFunction(); } else { document.getElementById("mySidenav").style.width = "0"; if (slide==1) { document.getElementById("main").style.marginLeft = "0"; } document.getElementById("mySidenav").setAttribute("class","menu menuClosed"); } } /* when scrolling down 20 pixel display upButton */ function scrollFunction() { if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { upButton.style.display = "block"; } else { upButton.style.display = "none"; } } /* Test if the logo is present (to avoid displaying broken link icon on chrome) */ function testLogo() { logo=document.getElementById("logoImgId"); logodiv=document.getElementById("logoDivId"); if (logo.naturalHeight == 0) { logodiv.setAttribute("style","display:none;"); } } |
d3b465ad3 Ajout d'une fonct... |
44 |
|
4fd76e81a Prise en compte d... |
45 46 47 48 |
function tagToInfo(s5=false) { /* All H4 tags */ var atags = document.getElementsByTagName('H4'); |
87b6f1b0d Utilisation de H5... |
49 50 51 52 53 54 55 56 57 58 |
/* extract configuration tags */ tags=[]; for (var i=0; i<atags.length;i++) { var s = atags[i].innerHTML; if (s.match(/^#/)) { atags[i].innerHTML = s.replace('#',''); tags.push(atags[i]); } } |
d3b465ad3 Ajout d'une fonct... |
59 60 |
var n = tags.length < 3 ? tags.length : 2; for (var i=1; i <= n; i++) { |
87b6f1b0d Utilisation de H5... |
61 62 |
/* first make the tag not displayed */ tags[i-1].setAttribute("style","display:none;"); |
4fd76e81a Prise en compte d... |
63 64 65 66 67 68 69 70 |
/* If next sibling is a <br> make it display:none too */ if (tags[i-1].nextElementSibling && tags[i-1].nextElementSibling.tagName == 'BR') { tags[i-1].nextElementSibling.setAttribute("style","display:none;"); } if (s5) { var s = tags[i-1].innerHTML; document.getElementById("footinfo"+i).innerHTML = s; } |
d3b465ad3 Ajout d'une fonct... |
71 |
} |
4fd76e81a Prise en compte d... |
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
} /* Convert the two first tags into info */ /* use tags for image/table/object attributes */ function tagToStyle() { /* All H5 tags */ var atags = document.getElementsByTagName('H5'); /* extract configuration tags */ tags=[]; for (var i=0; i<atags.length;i++) { var s = atags[i].innerHTML; if (s.match(/^#/)) { atags[i].innerHTML = s.replace('#',''); tags.push(atags[i]); } } if (tags.length > 0) { |
aca67690f Ajout de configur... |
90 |
/* Image tags */ |
4fd76e81a Prise en compte d... |
91 92 |
for (var i=0; i < tags.length; i++) { var ctag = tags[i]; |
87b6f1b0d Utilisation de H5... |
93 |
ctag.setAttribute("style","display:none;"); |
4fd76e81a Prise en compte d... |
94 95 96 97 |
/* If next sibling is a <br> make it display:none too */ if (ctag.nextElementSibling && ctag.nextElementSibling.tagName == 'BR') { ctag.nextElementSibling.setAttribute("style","display:none;"); } |
aca67690f Ajout de configur... |
98 |
var s = ctag.innerHTML; |
aca67690f Ajout de configur... |
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
/* find next img/table/zim-object */ ctag = findNextObject(ctag); /* either we found something either null */ if (ctag!=null) { var style = ctag.getAttribute("style"); var res; style = style == null ? '' : style; if (s == "left") { style = style + "float:left; margin-left:0; margin-right:1em;"; } if (s == "right") { style = style + "float:right; margin-left:1em; margin-right:0;"; } if (res = s.match(/^height(.+)$/)) { style = style + "height:"+res[1]+";"; } if (res = s.match(/^width(.+)$/)) { style = style + "width:"+res[1]+"; height:auto;"; } if (res = s.match(/^fontsize(.+)$/)) { style = style + "font-size:"+res[1]+"%;"; } ctag.setAttribute("style",style); } } } } function findNextObject(tag) { /* try to found in current */ |
87b6f1b0d Utilisation de H5... |
132 |
var objectsTagClassArray=['IMG','','TABLE','','DIV','zim-object','UL','','OL','']; |
aca67690f Ajout de configur... |
133 134 135 136 137 138 139 140 141 142 |
ob = findTagInSiblings(tag,objectsTagClassArray); if (ob == null) { ob = findTagInSiblings(tag.parentElement,objectsTagClassArray); } return ob; } function findTagInSiblings(tag,tagsToFind) { var notFound = true; var ctag = tag; |
87b6f1b0d Utilisation de H5... |
143 |
var cctag; |
aca67690f Ajout de configur... |
144 145 146 147 148 |
while (notFound) { ctag = ctag.nextElementSibling if (ctag == null) { notFound = false; break; |
87b6f1b0d Utilisation de H5... |
149 150 151 152 153 154 155 156 157 158 |
} if (isTagInList(ctag,tagsToFind)) { notFound = false; break; } /* now search into children */ if (ctag.childElementCount != 0) { for (var i=0;i<ctag.childElementCount;i++) { cctag=ctag.children[i]; if (isTagInList(cctag,tagsToFind)) { |
aca67690f Ajout de configur... |
159 |
notFound = false; |
87b6f1b0d Utilisation de H5... |
160 |
ctag=cctag; |
aca67690f Ajout de configur... |
161 |
break; |
87b6f1b0d Utilisation de H5... |
162 |
} |
aca67690f Ajout de configur... |
163 |
} |
87b6f1b0d Utilisation de H5... |
164 |
} |
aca67690f Ajout de configur... |
165 166 |
} return ctag; |
d3b465ad3 Ajout d'une fonct... |
167 |
} |
87b6f1b0d Utilisation de H5... |
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
function isTagInList(tag,tagsToFind) { yes = false; for (var i=0; i < tagsToFind.length/2 ; i++) { if (tag.tagName == tagsToFind[i*2]) { if (tagsToFind[i*2+1]=='') { yes = true; break; } else if (tag.className == tagsToFind[i*2+1]) { yes = true; break; } } } return yes; } |