PIE_uncompressed.htc 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <!--
  2. PIE: CSS3 rendering for IE
  3. Version 2.0beta1
  4. http://css3pie.com
  5. Dual-licensed for use under the Apache License Version 2.0 or the General Public License (GPL) Version 2.
  6. -->
  7. <PUBLIC:COMPONENT lightWeight="true">
  8. <!-- saved from url=(0014)about:internet -->
  9. <PUBLIC:ATTACH EVENT="oncontentready" FOR="element" ONEVENT="init()" />
  10. <PUBLIC:ATTACH EVENT="ondocumentready" FOR="element" ONEVENT="init()" />
  11. <PUBLIC:ATTACH EVENT="ondetach" FOR="element" ONEVENT="cleanup()" />
  12. <script type="text/javascript">
  13. var el = element,
  14. doc = el.document,
  15. docMode = doc.documentMode || 0;
  16. // NOTE: do NOT try maintaining a long-lived variable referencing window.PIE here at the top
  17. // level because for some reason it isn't reliably set when it should be on subsequent attachments
  18. // of the behavior, resulting in double loads of the JS file.
  19. if ( !window[ 'PIE' ] && docMode < 10 ) {
  20. (function() {
  21. var queue = {},
  22. styleSheetRE, checkStyleSheets,
  23. baseUrl, tester, isIE6, script;
  24. // Create stub PIE object
  25. window[ 'PIE' ] = {
  26. 'attach': function( el ) {
  27. queue[ el[ 'uniqueID' ] ] = el;
  28. },
  29. 'detach': function( el ) {
  30. delete queue[ el[ 'uniqueID' ] ];
  31. }
  32. };
  33. // Are we in IE6?
  34. tester = doc.createElement('div');
  35. tester.innerHTML = '<!--[if IE 6]><i></i><![endif]-->';
  36. isIE6 = tester.getElementsByTagName('i')[0];
  37. // Look for a custom pie-load-path parameter in the page's url...
  38. baseUrl = doc.location.href.match(/pie-load-path=([^&]+)/);
  39. if( baseUrl ) {
  40. baseUrl = decodeURIComponent(baseUrl[1]);
  41. }
  42. // Otherwise look for a custom -pie-load-path property in the CSS for the html element...
  43. if( !baseUrl ) {
  44. baseUrl = doc.documentElement.currentStyle.getAttribute( ( isIE6 ? '' : '-' ) + 'pie-load-path' );
  45. }
  46. // Otherwise look through the stylesheets for the location of the behavior file...
  47. if( !baseUrl ) {
  48. styleSheetRE = /BEHAVIOR: url\(([^\)]*PIE[^\)]*)/i;
  49. checkStyleSheets = function( styleSheets ) {
  50. var i = styleSheets.length,
  51. url, match;
  52. while( i-- ) {
  53. match = styleSheets[ i ].cssText.match( styleSheetRE );
  54. url = match ?
  55. match[ 1 ].substring( 0, match[ 1 ].lastIndexOf( '/' )) :
  56. checkStyleSheets( styleSheets[ i ].imports );
  57. if( url ) {
  58. break;
  59. }
  60. }
  61. return url;
  62. };
  63. baseUrl = checkStyleSheets( doc.styleSheets );
  64. }
  65. // If we found the base URL, try to load the appropriate JS file from it
  66. if( baseUrl ) {
  67. script = doc.createElement( 'script' );
  68. script.onreadystatechange = function() {
  69. var PIE = window[ 'PIE' ],
  70. rs = script.readyState,
  71. id;
  72. if ( queue && ( rs === 'complete' || rs === 'loaded' ) ) {
  73. if ( 'version' in PIE ) {
  74. for( id in queue ) {
  75. if ( queue.hasOwnProperty( id ) ) {
  76. PIE[ 'attach' ]( queue[ id ] );
  77. }
  78. }
  79. queue = 0;
  80. }
  81. }
  82. };
  83. script.src = baseUrl + '/PIE_IE' + ( docMode < 9 ? '678' : '9' ) + '_uncompressed.js';
  84. ( doc.getElementsByTagName( 'head' )[0] || doc.body ).appendChild( script );
  85. }
  86. })();
  87. }
  88. function init() {
  89. if ( doc.media !== 'print' ) { // IE strangely attaches a second copy of the behavior to elements when printing
  90. var PIE = window[ 'PIE' ];
  91. if( PIE ) {
  92. PIE[ 'attach' ]( el );
  93. }
  94. }
  95. }
  96. function cleanup() {
  97. if ( doc.media !== 'print' ) {
  98. var PIE = window[ 'PIE' ];
  99. if ( PIE ) {
  100. PIE[ 'detach' ]( el );
  101. }
  102. }
  103. el = 0;
  104. }
  105. if( el.readyState === 'complete' ) {
  106. init();
  107. }
  108. </script>
  109. //# IE will sometimes hang for a long time on unload of pages with .htc behaviors
  110. //# attached to many elements, if the script block is a certain size. We can work
  111. //# around this by including an empty vbscript block at the end. For more details:
  112. //# http://www.pcreview.co.uk/forums/htc-components-512-bytes-javascript-slow-unload-t727396.html
  113. //# http://code.google.com/p/svgweb/source/browse/trunk/src/svg.htc
  114. <script type="text/vbscript"></script>
  115. </PUBLIC:COMPONENT>