github.com/emc-advanced-dev/unik@v0.0.0-20190717152701-a58d3e8e33b7/docs/examples/example-nodejs-fileserver/static/js/mobile.js (about) 1 window.onload = function(){ 2 var getNavi = document.getElementById('navigation'); 3 4 var mobile = document.createElement("span"); 5 mobile.setAttribute("id","mobile-navigation"); 6 getNavi.parentNode.insertBefore(mobile,getNavi); 7 8 document.getElementById('mobile-navigation').onclick = function(){ 9 var a = getNavi.getAttribute('style'); 10 if(a){ 11 getNavi.removeAttribute('style'); 12 document.getElementById('mobile-navigation').style.backgroundImage='url(images/mobile/mobile-menu.png)'; 13 } else { 14 getNavi.style.display='block'; 15 document.getElementById('mobile-navigation').style.backgroundImage='url(images/mobile/mobile-close.png)'; 16 } 17 }; 18 var getElm = getNavi.getElementsByTagName("LI"); 19 for(var i=0;i<getElm.length;i++){ 20 if(getElm[i].children.length>1){ 21 var smenu = document.createElement("span"); 22 smenu.setAttribute("class","mobile-submenu"); 23 smenu.setAttribute("OnClick","submenu("+i+")"); 24 getElm[i].appendChild(smenu); 25 }; 26 }; 27 submenu = function (i){ 28 var sub = getElm[i].children[1]; 29 var b = sub.getAttribute('style'); 30 if(b){ 31 sub.removeAttribute('style'); 32 getElm[i].lastChild.style.backgroundImage='url(images/mobile/mobile-expand.png)'; 33 getElm[i].lastChild.style.backgroundColor='rgba(98, 0, 49, 0.91)'; 34 } else { 35 sub.style.display='block'; 36 getElm[i].lastChild.style.backgroundImage='url(images/mobile/mobile-collapse.png)'; 37 getElm[i].lastChild.style.backgroundColor='rgba(0, 0, 0, 0.91)'; 38 } 39 }; 40 };