Index: trunk/phase3/skins/common/protect.js |
— | — | @@ -1,44 +1,37 @@ |
2 | | -function protectInitialize(tableId, labelText) { |
3 | | - if (document.createTextNode) { |
4 | | - var box = document.getElementById(tableId); |
5 | | - if (!box) |
6 | | - return false; |
7 | | - |
8 | | - var tbody = box.getElementsByTagName('tbody')[0]; |
9 | | - var row = document.createElement('tr'); |
10 | | - tbody.appendChild(row); |
11 | | - |
12 | | - row.appendChild(document.createElement('td')); |
13 | | - var col2 = document.createElement('td'); |
14 | | - row.appendChild(col2); |
15 | | - |
16 | | - var check = document.createElement('input'); |
17 | | - check.id = "mwProtectUnchained"; |
18 | | - check.type = "checkbox"; |
19 | | - check.addEventListener( 'click', protectChainUpdate, false ); |
20 | | - col2.appendChild(check); |
21 | | - |
22 | | - var space = document.createTextNode(" "); |
23 | | - col2.appendChild(space); |
24 | | - |
25 | | - var label = document.createElement('label'); |
26 | | - label.setAttribute("for", "mwProtectUnchained"); |
27 | | - label.appendChild(document.createTextNode(labelText)); |
28 | | - col2.appendChild(label); |
29 | | - |
30 | | - if (protectAllMatch()) { |
31 | | - check.checked = false; |
32 | | - protectEnable(false); |
33 | | - } else { |
34 | | - check.checked = true; |
35 | | - protectEnable(true); |
36 | | - } |
| 2 | +function protectInitialize( tableId, labelText ) { |
| 3 | + if( !( document.createTextNode && document.getElementById && document.getElementsByTagName ) ) |
| 4 | + return false; |
37 | 5 | |
38 | | - allowCascade(); |
| 6 | + var box = document.getElementById( tableId ); |
| 7 | + if( !box ) |
| 8 | + return false; |
| 9 | + |
| 10 | + var tbody = box.getElementsByTagName( 'tbody' )[0]; |
| 11 | + var row = document.createElement( 'tr' ); |
| 12 | + tbody.appendChild( row ); |
| 13 | + |
| 14 | + row.appendChild( document.createElement( 'td' ) ); |
| 15 | + var col = document.createElement( 'td' ); |
| 16 | + row.appendChild( col ); |
| 17 | + |
| 18 | + var check = document.createElement( 'input' ); |
| 19 | + check.id = 'mwProtectUnchained'; |
| 20 | + check.type = 'checkbox'; |
| 21 | + col.appendChild( check ); |
| 22 | + addClickHandler( check, protectChainUpdate ); |
39 | 23 | |
40 | | - return true; |
41 | | - } |
42 | | - return false; |
| 24 | + col.appendChild( document.createTextNode( ' ' ) ); |
| 25 | + var label = document.createElement( 'label' ); |
| 26 | + label.setAttribute( 'for', 'mwProtectUnchained' ); |
| 27 | + label.appendChild( document.createTextNode( labelText ) ); |
| 28 | + col.appendChild( label ); |
| 29 | + |
| 30 | + check.checked = !protectAllMatch(); |
| 31 | + protectEnable( check.checked ); |
| 32 | + |
| 33 | + allowCascade(); |
| 34 | + |
| 35 | + return true; |
43 | 36 | } |
44 | 37 | |
45 | 38 | function allowCascade() { |
— | — | @@ -90,12 +83,10 @@ |
91 | 84 | } |
92 | 85 | |
93 | 86 | function protectUnchained() { |
94 | | - var unchain = document.getElementById("mwProtectUnchained"); |
95 | | - if (!unchain) { |
96 | | - alert("This shouldn't happen"); |
97 | | - return false; |
98 | | - } |
99 | | - return unchain.checked; |
| 87 | + var unchain = document.getElementById( 'mwProtectUnchained' ); |
| 88 | + return unchain |
| 89 | + ? unchain.checked |
| 90 | + : true; // No control, so we need to let the user set both levels |
100 | 91 | } |
101 | 92 | |
102 | 93 | function protectChain() { |
Index: trunk/phase3/skins/common/wikibits.js |
— | — | @@ -1302,8 +1302,24 @@ |
1303 | 1303 | } |
1304 | 1304 | } |
1305 | 1305 | |
| 1306 | +/** |
| 1307 | + * Add a click event handler to an element |
| 1308 | + * |
| 1309 | + * We use addEventListener() where available, otherwise |
| 1310 | + * we use a workaround to avoid breaking the chain |
| 1311 | + * |
| 1312 | + * @param Element element Element to add handler to |
| 1313 | + * @param callable handler Event handler callback |
| 1314 | + */ |
| 1315 | +function addClickHandler( element, handler ) { |
| 1316 | + if( window.addEventListener ) { |
| 1317 | + element.addEventListener( 'click', handler, false ); |
| 1318 | + } else if( window.attachEvent ) { |
| 1319 | + element.attachEvent( 'onclick', handler ); |
| 1320 | + } |
| 1321 | +} |
| 1322 | + |
1306 | 1323 | //note: all skins should call runOnloadHook() at the end of html output, |
1307 | 1324 | // so the below should be redundant. It's there just in case. |
1308 | 1325 | hookEvent("load", runOnloadHook); |
1309 | | - |
1310 | | -hookEvent("load", mwSetupToolbar); |
| 1326 | +hookEvent("load", mwSetupToolbar); |
\ No newline at end of file |
Index: trunk/phase3/includes/DefaultSettings.php |
— | — | @@ -1195,7 +1195,7 @@ |
1196 | 1196 | * to ensure that client-side caches don't keep obsolete copies of global |
1197 | 1197 | * styles. |
1198 | 1198 | */ |
1199 | | -$wgStyleVersion = '91'; |
| 1199 | +$wgStyleVersion = '92'; |
1200 | 1200 | |
1201 | 1201 | |
1202 | 1202 | # Server-side caching: |