binding.xml (2726B)
1 <?xml version="1.0"?> 2 <xbl:bindings xmlns:xbl="http://www.mozilla.org/xbl" 3 xmlns="http://www.w3.org/1999/xhtml"> 4 <xbl:binding id="seats" inheritstyle="false"> 5 <xbl:resources> 6 <xbl:stylesheet src="chrome://mft3k/skin/stylesheets/stylesheet.css" /> 7 </xbl:resources> 8 <xbl:content> 9 <xbl:children includes="head" /> 10 <body id="stack"> 11 <div id="page"> 12 <xbl:children /> 13 </div> 14 <div id="seats"> 15 <div id="empty" /> 16 <div id="occupied" /> 17 </div> 18 </body> 19 </xbl:content> 20 <xbl:implementation> 21 <xbl:constructor><![CDATA[ 22 /* 23 This constructor adds the speech bubbles, it has nothing directly to 24 do with the stack hack 25 */ 26 27 // px offsets 28 var tom = 215; 29 var joel = 145; 30 var crow = 80; 31 32 var phrases = [ 33 [crow, "They must've spent tens of dollars on this."], 34 [joel, "I think the prop department juuust ran out of money."], 35 [tom, "I bet this was made in Canada."], 36 [joel, "I'll bet this site uses -moz-binding"], 37 [joel, "Yeah."], 38 [crow, "I know I'll never be quite the same."], 39 [joel, "This XBL is history."], 40 [crow, "We're history."], 41 [crow, "Hey! Is this From Here to Eternity?"], 42 [tom, "No, it just seems like an eternity."], 43 [tom, "It is sort of hypnotic, isn't it?"], 44 [crow, "Hip? Not. Ick!"] 45 ]; 46 47 var index = Math.floor(Math.random() * phrases.length); 48 49 // See: https://developer.mozilla.org/en/XBL/XBL_1.0_Reference/DOM_Interfaces#getAnonymousElementByAttribute 50 var node = document.getAnonymousElementByAttribute(this, 'id', 'occupied'); 51 52 node.onclick = function () { 53 // remove old speech bubble 54 while (node.hasChildNodes()) { 55 node.removeChild(node.firstChild); 56 } 57 58 // choose what new speech bubble will say 59 var speech = phrases[index]; 60 var offset = speech[0]; 61 var text = speech[1]; 62 63 // create bubble and add to dom 64 var bubble = document.createElement('div') ; 65 bubble.id = "speechbubble"; 66 bubble.textContent = text; 67 bubble.style.right = offset + "px"; 68 node.appendChild(bubble); 69 var fin = document.createElement('div'); 70 fin.id = "speechbubblefin"; 71 fin.style.right = (offset + 10) + "px"; 72 node.appendChild(fin); 73 74 // update index (it wraps around phrases) 75 index = (index + 1) % phrases.length; 76 }; 77 ]]></xbl:constructor> 78 </xbl:implementation> 79 </xbl:binding> 80 </xbl:bindings>