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