r60994 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60993‎ | r60994 | r60995 >
Date:23:36, 12 January 2010
Author:simetrical
Status:resolved (Comments)
Tags:
Comment:
Merge IEFixes.js into wikibits.js

Not actually tested, but it should theoretically work fine. This
previously wasn't getting loaded for skins other than Monobook, Modern,
and Vector, and each one had separate code to load it.

I also removed <meta http-equiv="imagetoolbar" content="no" />. This
was added by Gabriel Wicke without explanation as part of the original
davinci.pt back in r2786, in March 2004. As far as I can tell, it
disables some minor feature of IE6 for some reason. I assume it can be
removed completely at this point. If not, it should be readded without
the conditional comment, which is probably unnecessary.
Modified paths:
  • /trunk/phase3/skins/Modern.php (modified) (history)
  • /trunk/phase3/skins/MonoBook.php (modified) (history)
  • /trunk/phase3/skins/Vector.php (modified) (history)
  • /trunk/phase3/skins/common/IEFixes.js (deleted) (history)
  • /trunk/phase3/skins/common/wikibits.js (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/IEFixes.js
@@ -1,127 +0,0 @@
2 -// IE fixes javascript
3 -
4 -var isMSIE55 = (window.showModalDialog && window.clipboardData && window.createPopup);
5 -var doneIETransform;
6 -var doneIEAlphaFix;
7 -
8 -if (document.attachEvent)
9 - document.attachEvent('onreadystatechange', hookit);
10 -
11 -function hookit() {
12 - if (!doneIETransform && document.getElementById && document.getElementById('bodyContent')) {
13 - doneIETransform = true;
14 - relativeforfloats();
15 - fixalpha();
16 - }
17 -}
18 -
19 -// png alpha transparency fixes
20 -function fixalpha( logoId ) {
21 - // bg
22 - if (isMSIE55 && !doneIEAlphaFix)
23 - {
24 - var plogo = document.getElementById( logoId || 'p-logo' );
25 - if (!plogo) return;
26 -
27 - var logoa = plogo.getElementsByTagName('a')[0];
28 - if (!logoa) return;
29 -
30 - var bg = logoa.currentStyle.backgroundImage;
31 - var imageUrl = bg.substring(5, bg.length-2);
32 -
33 - doneIEAlphaFix = true;
34 -
35 - if (imageUrl.substr(imageUrl.length-4).toLowerCase() == '.png') {
36 - var logospan = logoa.appendChild(document.createElement('span'));
37 -
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"');
57 -
58 - var linkFix = logoa.appendChild(logoa.cloneNode());
59 - linkFix.style.position = 'absolute';
60 - linkFix.style.height = '100%';
61 - linkFix.style.width = '100%';
62 - }
63 - }
64 -}
65 -
66 -// fix ie6 disappering float bug
67 -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);
75 -}
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 - }
87 -}
88 -
89 -
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;
98 -}
99 -
100 -var expandedURLs;
101 -
102 -onbeforeprint = function() {
103 - expandedURLs = [];
104 -
105 - var contentEl = document.getElementById("content");
106 -
107 - if (contentEl)
108 - {
109 - var allLinks = contentEl.getElementsByTagName("a");
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 - }
121 -}
122 -
123 -onafterprint = function()
124 -{
125 - for (var i=0; i < expandedURLs.length; i++)
126 - if (expandedURLs[i])
127 - expandedURLs[i].removeNode(true);
128 -}
Index: trunk/phase3/skins/common/wikibits.js
@@ -25,6 +25,8 @@
2626 var opera7_bugs = is_opera_seven && !is_opera_95;
2727 var opera95_bugs = /opera\/(9\.5)/.test( clientPC );
2828 }
 29+// Start at 4 to minimize the chance of breaking on IE10 :)
 30+var ie6_bugs = /msie [4-6]/.test( clientPC );
2931
3032 // Global external objects used by this script.
3133 /*extern ta, stylepath, skin */
@@ -999,3 +1001,130 @@
10001002 //note: all skins should call runOnloadHook() at the end of html output,
10011003 // so the below should be redundant. It's there just in case.
10021004 hookEvent("load", runOnloadHook);
 1005+
 1006+if ( ie6_bugs ) {
 1007+ var isMSIE55 = (window.showModalDialog && window.clipboardData && window.createPopup);
 1008+ var doneIETransform;
 1009+ var doneIEAlphaFix;
 1010+
 1011+ if (document.attachEvent)
 1012+ document.attachEvent('onreadystatechange', hookit);
 1013+
 1014+ function hookit() {
 1015+ if (!doneIETransform && document.getElementById && document.getElementById('bodyContent')) {
 1016+ doneIETransform = true;
 1017+ relativeforfloats();
 1018+ fixalpha();
 1019+ }
 1020+ }
 1021+
 1022+ // png alpha transparency fixes
 1023+ function fixalpha( logoId ) {
 1024+ // bg
 1025+ if (isMSIE55 && !doneIEAlphaFix)
 1026+ {
 1027+ var plogo = document.getElementById( logoId || 'p-logo' );
 1028+ if (!plogo) return;
 1029+
 1030+ var logoa = plogo.getElementsByTagName('a')[0];
 1031+ if (!logoa) return;
 1032+
 1033+ var bg = logoa.currentStyle.backgroundImage;
 1034+ var imageUrl = bg.substring(5, bg.length-2);
 1035+
 1036+ doneIEAlphaFix = true;
 1037+
 1038+ if (imageUrl.substr(imageUrl.length-4).toLowerCase() == '.png') {
 1039+ var logospan = logoa.appendChild(document.createElement('span'));
 1040+
 1041+ logoa.style.backgroundImage = 'none';
 1042+ logospan.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=' + imageUrl + ')';
 1043+ logospan.style.height = '100%';
 1044+ logospan.style.position = 'absolute';
 1045+ logospan.style.width = logoa.currentStyle.width;
 1046+ logospan.style.cursor = 'hand';
 1047+ // Center image with hack for IE5.5
 1048+ if (document.documentElement.dir == "rtl")
 1049+ {
 1050+ logospan.style.right = '50%';
 1051+ logospan.style.setExpression('marginRight', '"-" + (this.offsetWidth / 2) + "px"');
 1052+ }
 1053+ else
 1054+ {
 1055+ logospan.style.left = '50%';
 1056+ logospan.style.setExpression('marginLeft', '"-" + (this.offsetWidth / 2) + "px"');
 1057+ }
 1058+ logospan.style.top = '50%';
 1059+ logospan.style.setExpression('marginTop', '"-" + (this.offsetHeight / 2) + "px"');
 1060+
 1061+ var linkFix = logoa.appendChild(logoa.cloneNode());
 1062+ linkFix.style.position = 'absolute';
 1063+ linkFix.style.height = '100%';
 1064+ linkFix.style.width = '100%';
 1065+ }
 1066+ }
 1067+ }
 1068+
 1069+ // fix ie6 disappering float bug
 1070+ function relativeforfloats() {
 1071+ var bc = document.getElementById('bodyContent');
 1072+ if (bc) {
 1073+ var tables = bc.getElementsByTagName('table');
 1074+ var divs = bc.getElementsByTagName('div');
 1075+ }
 1076+ setrelative(tables);
 1077+ setrelative(divs);
 1078+ }
 1079+ function setrelative (nodes) {
 1080+ var i = 0;
 1081+ while (i < nodes.length) {
 1082+ if(((nodes[i].style.float && nodes[i].style.float != ('none') ||
 1083+ (nodes[i].align && nodes[i].align != ('none'))) &&
 1084+ (!nodes[i].style.position || nodes[i].style.position != 'relative')))
 1085+ {
 1086+ nodes[i].style.position = 'relative';
 1087+ }
 1088+ i++;
 1089+ }
 1090+ }
 1091+
 1092+
 1093+ // Expand links for printing
 1094+
 1095+ String.prototype.hasClass = function(classWanted)
 1096+ {
 1097+ var classArr = this.split(/\s/);
 1098+ for (var i=0; i<classArr.length; i++)
 1099+ if (classArr[i].toLowerCase() == classWanted.toLowerCase()) return true;
 1100+ return false;
 1101+ }
 1102+
 1103+ var expandedURLs;
 1104+
 1105+ onbeforeprint = function() {
 1106+ expandedURLs = [];
 1107+
 1108+ var contentEl = document.getElementById("content");
 1109+
 1110+ if (contentEl)
 1111+ {
 1112+ var allLinks = contentEl.getElementsByTagName("a");
 1113+
 1114+ for (var i=0; i < allLinks.length; i++) {
 1115+ if (allLinks[i].className.hasClass("external") && !allLinks[i].className.hasClass("free")) {
 1116+ var expandedLink = document.createElement("span");
 1117+ var expandedText = document.createTextNode(" (" + allLinks[i].href + ")");
 1118+ expandedLink.appendChild(expandedText);
 1119+ allLinks[i].parentNode.insertBefore(expandedLink, allLinks[i].nextSibling);
 1120+ expandedURLs[i] = expandedLink;
 1121+ }
 1122+ }
 1123+ }
 1124+ }
 1125+
 1126+ onafterprint = function() {
 1127+ for (var i=0; i < expandedURLs.length; i++)
 1128+ if (expandedURLs[i])
 1129+ expandedURLs[i].removeNode(true);
 1130+ }
 1131+}
Index: trunk/phase3/skins/Vector.php
@@ -48,17 +48,6 @@
4949 $out->addStyle( 'vector/' . $style, 'screen' );
5050 }
5151 }
52 - // Append common IE fixes, which perhaps should be included in all
53 - // skins, but for now it seems each skin needs to include them
54 - // explicitly
55 - $out->addScript(
56 - '<!--[if lt IE 7]><script type="' . $wgJsMimeType . '" src="' .
57 - $wgStylePath .
58 - '/common/IEFixes.js?' .
59 - $wgStyleVersion .
60 - '"></script>' .
61 - '<meta http-equiv="imagetoolbar" content="no" /><![endif]-->'
62 - );
6352 }
6453 /**
6554 * Builds a structured array of links used for tabs and menus
Index: trunk/phase3/skins/MonoBook.php
@@ -42,13 +42,6 @@
4343
4444 $out->addStyle( 'monobook/rtl.css', 'screen', '', 'rtl' );
4545
46 - # FIXME: What is this? Should it apply to all skins?
47 - $path = htmlspecialchars( $wgStylePath );
48 - $out->addScript( <<<HTML
49 -<!--[if lt IE 7]><script type="$wgJsMimeType" src="$path/common/IEFixes.js?$wgStyleVersion"></script>
50 - <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
51 -HTML
52 - );
5346 }
5447 }
5548
Index: trunk/phase3/skins/Modern.php
@@ -36,13 +36,6 @@
3737 $out->addStyle( 'modern/main.css', 'screen' );
3838 $out->addStyle( 'modern/print.css', 'print' );
3939 $out->addStyle( 'modern/rtl.css', 'screen', '', 'rtl' );
40 -
41 - $path = htmlspecialchars( $wgStylePath );
42 - $out->addScript( <<<HTML
43 -<!--[if lt IE 7]><script type="$wgJsMimeType" src="$path/common/IEFixes.js?$wgStyleVersion"></script>
44 - <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
45 -HTML
46 - );
4740 }
4841 }
4942

Follow-up revisions

RevisionCommit summaryAuthorDate
r61010Keep IEFixes separate, load conditionally in JS...simetrical15:47, 13 January 2010
r61728MonoBook: remove three unused globals which were added in r56770 to support l...ashley20:26, 30 January 2010
r65775Backport r65774 "Improve IE6 version check to avoid false positives"...simetrical02:00, 2 May 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r2786a pretty generic xhtml / tal skingabrielwicke23:37, 22 March 2004

Comments

#Comment by Bryan (talk | contribs)   14:21, 13 January 2010

Can't we do the conditional loading of IEFixes.js in wikibits.js instead of in PHP? That way other browsers don't need to download the few extra KB.

#Comment by Simetrical (talk | contribs)   15:41, 13 January 2010

You mean like the fixes CSS? That would be possible, yeah. It would save about a kilobyte gzipped, it looks like, which is probably worth it.

#Comment by Simetrical (talk | contribs)   15:47, 13 January 2010

Done in r61010.

#Comment by TheDJ (talk | contribs)   20:56, 1 May 2010

This change is the cause of bug 23171

#Comment by Simetrical (talk | contribs)   02:02, 2 May 2010

Should be fixed in r65774. Marking resolved, I guess, not sure of the right protocol here. If the fix is wrong, I guess r65774 can be marked fixme instead of this.

Status & tagging log