r61016 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61015‎ | r61016 | r61017 >
Date:19:42, 13 January 2010
Author:simetrical
Status:ok
Tags:
Comment:
Reapply style fixes from r61006 to IEFixes.js

Also fixes indentation problems that seem to have cropped up somewhere.
Modified paths:
  • /trunk/phase3/skins/common/IEFixes.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/IEFixes.js
@@ -1,127 +1,128 @@
22 // IE fixes javascript
33
4 -var isMSIE55 = (window.showModalDialog && window.clipboardData && window.createPopup);
 4+var isMSIE55 = ( window.showModalDialog && window.clipboardData && window.createPopup );
55 var doneIETransform;
66 var doneIEAlphaFix;
77
8 -if (document.attachEvent)
9 - document.attachEvent('onreadystatechange', hookit);
 8+if ( document.attachEvent ) {
 9+ document.attachEvent( 'onreadystatechange', hookit );
 10+}
1011
1112 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+ }
1718 }
1819
1920 // png alpha transparency fixes
2021 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+ }
2628
27 - var logoa = plogo.getElementsByTagName('a')[0];
28 - if (!logoa) return;
 29+ var logoa = plogo.getElementsByTagName('a')[0];
 30+ if ( !logoa ) {
 31+ return;
 32+ }
2933
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 );
3236
33 - doneIEAlphaFix = true;
 37+ doneIEAlphaFix = true;
3438
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' ) );
3741
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"' );
5758
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+ }
6465 }
6566
6667 // fix ie6 disappering float bug
6768 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 );
7576 }
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+ }
8788 }
8889
89 -
9090 // 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;
9899 }
99100
100101 var expandedURLs;
101102
102103 onbeforeprint = function() {
103 - expandedURLs = [];
 104+ expandedURLs = [];
104105
105 - var contentEl = document.getElementById("content");
 106+ var contentEl = document.getElementById( 'content' );
106107
107 - if (contentEl)
108 - {
109 - var allLinks = contentEl.getElementsByTagName("a");
 108+ if ( contentEl ) {
 109+ var allLinks = contentEl.getElementsByTagName( 'a' );
110110
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+ }
121121 }
122122
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+ }
128129 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r61006JavaScript cleanup: add spacing, missing braces, use single quotes instead of...ashley13:17, 13 January 2010

Status & tagging log