257818-1.html (2026B)
1 <html><head> 2 <script type="text/javascript"> 3 function cE (v) { 4 return document.createElement(v) 5 } 6 function cTN (v) { 7 return document.createTextNode(v) 8 } 9 10 function OSXBarIcon(elt) { 11 this.element = elt; 12 this.labelNode = this.element.firstChild; 13 this.labelNodeParent = this.element; 14 this.labelNodeParent.removeChild(this.labelNode); 15 16 this.contents = []; 17 var kids = this.element.childNodes; 18 for(var i=0; i<kids.length; i++) this.contents[this.contents.length] = this.element.removeChild(kids[i]); 19 this.popupSubmenu = new OSXBarSubmenu(this); 20 } 21 22 function OSXBarSubmenu(icon) { 23 this.parentIcon = icon; 24 this.create(); 25 this.addContent(); 26 } 27 OSXBarSubmenu.prototype = { 28 create : function() { 29 var p = this.popupNode = document.createElement("div"); 30 var b = document.getElementsByTagName("body").item(0); 31 if(b) b.appendChild(p); 32 this.popupNode.style.display = "none"; 33 // Uncomment next line to fix the problem 34 // var v = document.body.offsetWidth; 35 } 36 }; 37 OSXBarSubmenu.prototype.addContent = function() { 38 39 // add popup label: 40 var label = document.createElement("div"); 41 label.appendChild(document.createTextNode(this.parentIcon.label)); 42 this.popupNode.appendChild(label); 43 44 // add <li> children to the popup: 45 var contents = this.parentIcon.contents; 46 for(var i=0; i<contents.length; i++) { 47 this.popupNode.appendChild(contents[i]); 48 49 } 50 }; 51 52 </script> 53 54 <script type="text/javascript"> 55 function createControlPanel() { 56 var bar = document.getElementById("navigation"); 57 var item = cE("li"); 58 item.appendChild(cTN("aaa")); 59 var textfield = cE("input"); 60 textfield.value = 0; 61 item.appendChild(textfield); 62 bar.insertBefore(item, bar.firstChild); 63 } 64 65 window.addEventListener("load", createControlPanel); 66 </script> 67 68 <script type="text/javascript"> 69 function ssload() { 70 new OSXBarIcon(document.getElementById("navigation").childNodes[0]); 71 } 72 window.addEventListener("load",ssload); 73 74 75 </script> 76 </head> 77 78 <body> 79 <ul id="navigation"></ul> 80 </body></html>