home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 March / PCWorld_2005-03_cd.bin / komunikace / kmeleon / kmeleon09.exe / flashblock.jar / content / flashblock / director.xml < prev    next >
Extensible Markup Language  |  2004-12-05  |  2KB  |  91 lines

  1. <?xml version="1.0"?>
  2.  
  3. <bindings
  4.    xmlns="http://www.mozilla.org/xbl"
  5.    xmlns:html="http://www.w3.org/1999/xhtml"
  6. >
  7.  
  8. <binding id="flashblock">
  9.   <implementation>
  10.     <constructor>
  11.       <![CDATA[
  12.  
  13. // Check if the page that loaded the Flash site is whitelisted
  14. // Thanks to Neil on #mozilla for suggesting this method, I would never have
  15. // thought of it on my own. :-)
  16. var event = document.createEvent("Events");
  17. event.initEvent("flashblockCheckLoad", true, true);
  18. document.dispatchEvent(event);
  19. if(event.getPreventDefault() == true) {
  20.     // Whitelisted
  21.     return;
  22. }
  23.  
  24. var current = this;
  25.  
  26. // Check parent too (case of working EMBED inside broken OBJECT)
  27. if (current.overrideCTV || current.parentNode.overrideCTV) {
  28.     return;
  29. }
  30.  
  31. current.overrideCTV = true;
  32.  
  33. var placeholder = document.createElement("img");
  34.  
  35. // Set size to minimum 32x32 px.
  36. var wdth = parseInt(current.width || current.style.width);
  37. var higt = parseInt(current.height || current.style.height);
  38.  
  39. if (!wdth || wdth < 32) {
  40.     wdth = 32;
  41. }
  42.  
  43. if (!higt || higt < 32) {
  44.     higt = 32;
  45. }
  46.  
  47. // Add styling rules to placeholder div.
  48. placeholder.src = "chrome://flashblock/content/spacer.gif";
  49. placeholder.style.width = wdth + "px";
  50. placeholder.style.height = higt + "px";
  51. placeholder.style.background = "url(chrome://flashblock/content/director.png) no-repeat center";
  52. placeholder.style.MozOutline = "1px solid #dfdfdf";
  53. placeholder.style.cursor = "pointer";
  54. placeholder.style.overflow = "hidden";
  55.  
  56. // Change the placeholder background when the mouse enters/exits the div.
  57. placeholder.onmouseover = function()
  58. {
  59.     this.style.background = "url(chrome://flashblock/content/flashplay.png) no-repeat center";
  60. }
  61.  
  62. placeholder.onmouseout = function()
  63. {
  64.     this.style.background = "url(chrome://flashblock/content/director.png) no-repeat center";
  65. }
  66.  
  67. var parent = current.parentNode;
  68.  
  69. // Replace the flash document with a placeholder.
  70. // Timeout is to avoid unspecified bugginess mentioned in Jesse's origional code.
  71. setTimeout ( function ()
  72. {
  73.     parent.insertBefore(placeholder, current);
  74.     parent.removeChild(current); 
  75. }, 100);
  76.  
  77. // Replace the placeholder with the flash document.
  78. placeholder.onclick = function() 
  79. {
  80.     parent.insertBefore(current, placeholder);
  81.     parent.removeChild(placeholder);
  82. }
  83.  
  84.       ]]>
  85.     </constructor>
  86.   </implementation>
  87.  
  88. </binding>
  89.  
  90. </bindings>
  91.