IEFixes.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // IE fixes javascript
  2. var isMSIE55 = (window.showModalDialog && window.clipboardData && window.createPopup);
  3. var doneIETransform;
  4. var doneIEAlphaFix;
  5. if (document.attachEvent)
  6. document.attachEvent('onreadystatechange', hookit);
  7. function hookit() {
  8. if (!doneIETransform && document.getElementById && document.getElementById('bodyContent')) {
  9. doneIETransform = true;
  10. relativeforfloats();
  11. fixalpha();
  12. }
  13. }
  14. // png alpha transparency fixes
  15. function fixalpha() {
  16. // bg
  17. if (isMSIE55 && !doneIEAlphaFix)
  18. {
  19. var plogo = document.getElementById('p-logo');
  20. if (!plogo) return;
  21. var logoa = plogo.getElementsByTagName('a')[0];
  22. if (!logoa) return;
  23. var bg = logoa.currentStyle.backgroundImage;
  24. var imageUrl = bg.substring(5, bg.length-2);
  25. doneIEAlphaFix = true;
  26. if (imageUrl.substr(imageUrl.length-4).toLowerCase() == '.png') {
  27. var logospan = logoa.appendChild(document.createElement('span'));
  28. logoa.style.backgroundImage = 'none';
  29. logospan.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' + imageUrl + ')';
  30. logospan.style.height = '100%';
  31. logospan.style.position = 'absolute';
  32. logospan.style.width = logoa.currentStyle.width;
  33. logospan.style.cursor = 'hand';
  34. // Center image with hack for IE5.5
  35. if (document.documentElement.dir == "rtl")
  36. {
  37. logospan.style.right = '50%';
  38. logospan.style.setExpression('marginRight', '"-" + (this.offsetWidth / 2) + "px"');
  39. }
  40. else
  41. {
  42. logospan.style.left = '50%';
  43. logospan.style.setExpression('marginLeft', '"-" + (this.offsetWidth / 2) + "px"');
  44. }
  45. logospan.style.top = '50%';
  46. logospan.style.setExpression('marginTop', '"-" + (this.offsetHeight / 2) + "px"');
  47. var linkFix = logoa.appendChild(logoa.cloneNode());
  48. linkFix.style.position = 'absolute';
  49. linkFix.style.height = '100%';
  50. linkFix.style.width = '100%';
  51. }
  52. }
  53. }
  54. // fix ie6 disappering float bug
  55. function relativeforfloats() {
  56. var bc = document.getElementById('bodyContent');
  57. if (bc) {
  58. var tables = bc.getElementsByTagName('table');
  59. var divs = bc.getElementsByTagName('div');
  60. }
  61. setrelative(tables);
  62. setrelative(divs);
  63. }
  64. function setrelative (nodes) {
  65. var i = 0;
  66. while (i < nodes.length) {
  67. if(((nodes[i].style.float && nodes[i].style.float != ('none') ||
  68. (nodes[i].align && nodes[i].align != ('none'))) &&
  69. (!nodes[i].style.position || nodes[i].style.position != 'relative')))
  70. {
  71. nodes[i].style.position = 'relative';
  72. }
  73. i++;
  74. }
  75. }
  76. // Expand links for printing
  77. String.prototype.hasClass = function(classWanted)
  78. {
  79. var classArr = this.split(/\s/);
  80. for (var i=0; i<classArr.length; i++)
  81. if (classArr[i].toLowerCase() == classWanted.toLowerCase()) return true;
  82. return false;
  83. }
  84. var expandedURLs;
  85. onbeforeprint = function() {
  86. expandedURLs = [];
  87. var contentEl = document.getElementById("content");
  88. if (contentEl)
  89. {
  90. var allLinks = contentEl.getElementsByTagName("a");
  91. for (var i=0; i < allLinks.length; i++) {
  92. if (allLinks[i].className.hasClass("external") && !allLinks[i].className.hasClass("free")) {
  93. var expandedLink = document.createElement("span");
  94. var expandedText = document.createTextNode(" (" + allLinks[i].href + ")");
  95. expandedLink.appendChild(expandedText);
  96. allLinks[i].parentNode.insertBefore(expandedLink, allLinks[i].nextSibling);
  97. expandedURLs[i] = expandedLink;
  98. }
  99. }
  100. }
  101. }
  102. onafterprint = function()
  103. {
  104. for (var i=0; i < expandedURLs.length; i++)
  105. if (expandedURLs[i])
  106. expandedURLs[i].removeNode(true);
  107. }