Index: branches/new-installer/phase3/skins/common/config.js |
— | — | @@ -1,96 +1,76 @@ |
2 | | - |
3 | | -function showHelp(idx, show) { |
4 | | - var showDiv = document.getElementById( 'config-show-help-' + idx ); |
5 | | - var hideDiv = document.getElementById( 'config-hide-help-' + idx ); |
6 | | - var msgDiv = document.getElementById( 'config-help-message-' + idx ); |
7 | | - if ( !showDiv || !hideDiv || !msgDiv ) return; |
8 | | - if ( show ) { |
9 | | - showDiv.style.display = 'none'; |
10 | | - hideDiv.style.display = 'block'; |
11 | | - msgDiv.style.display = 'block'; |
12 | | - } else { |
13 | | - showDiv.style.display = 'block'; |
14 | | - hideDiv.style.display = 'none'; |
15 | | - msgDiv.style.display = 'none'; |
16 | | - } |
17 | | -} |
18 | | - |
19 | | -function hideAllDBs() { |
20 | | - for ( var i = 0; i < dbTypes.length; i++ ) { |
21 | | - elt = document.getElementById( 'DB_wrapper_' + dbTypes[i] ); |
22 | | - if ( elt ) elt.style.display = 'none'; |
23 | | - } |
24 | | -} |
25 | | -function showDBArea(type) { |
26 | | - hideAllDBs(); |
27 | | - var div = document.getElementById('DB_wrapper_' + type); |
28 | | - if (div) div.style.display = 'block'; |
29 | | -} |
30 | | -function resetDBArea() { |
31 | | - for ( var i = 0; i < dbTypes.length; i++ ) { |
32 | | - input = document.getElementById('DBType_' + dbTypes[i]); |
33 | | - if ( input && input.checked ) { |
34 | | - showDBArea( dbTypes[i] ); |
35 | | - return; |
| 2 | +(function( $ ) { |
| 3 | + $( document ).ready( function() { |
| 4 | + // Show/hide code for help text |
| 5 | + $( '.config-show-help a' ).click( function() { |
| 6 | + $(this).parent().siblings( '.config-help-message' ).show( 'slow' ); |
| 7 | + $(this).parent().siblings( '.config-hide-help' ).show(); |
| 8 | + $(this).parent().hide(); |
| 9 | + return false; |
| 10 | + } ); |
| 11 | + $( '.config-hide-help a' ).click( function() { |
| 12 | + $(this).parent().siblings( '.config-help-message' ).hide( 'slow' ); |
| 13 | + $(this).parent().siblings( '.config-show-help' ).show(); |
| 14 | + $(this).parent().hide(); |
| 15 | + return false; |
| 16 | + } ); |
| 17 | + |
| 18 | + // Show/hide code for DB-specific options |
| 19 | + // FIXME: Do we want slow, fast, or even non-animated (instantaneous) showing/hiding here? |
| 20 | + $( '.dbRadio' ).click( function() { |
| 21 | + var $checked = $( '.dbRadio:checked' ); |
| 22 | + var $wrapper = $( '#' + $checked.attr( 'rel' ) ); |
| 23 | + if ( !$wrapper.is( ':visible' ) ) { |
| 24 | + $( '.dbWrapper' ).hide( 'slow' ); |
| 25 | + $wrapper.show( 'slow' ); |
| 26 | + } |
| 27 | + } ); |
| 28 | + |
| 29 | + // Show/hide Creative Commons thingy |
| 30 | + $( '.licenseRadio' ).click( function() { |
| 31 | + var $wrapper = $( '#config-cc-wrapper' ); |
| 32 | + if ( $( '#config__LicenseCode_cc-choose' ).is( ':checked' ) ) { |
| 33 | + $wrapper.show( 'slow' ); |
| 34 | + } else { |
| 35 | + $wrapper.hide( 'slow' ); |
| 36 | + } |
| 37 | + } ); |
| 38 | + |
| 39 | + // Show/hide random stuff (email, upload) |
| 40 | + $( '.showHideRadio' ).click( function() { |
| 41 | + var $wrapper = $( '#' + $(this).attr( 'rel' ) ); |
| 42 | + if ( $(this).is( ':checked' ) ) { |
| 43 | + $wrapper.show( 'slow' ); |
| 44 | + } else { |
| 45 | + $wrapper.hide( 'slow' ); |
| 46 | + } |
| 47 | + } ); |
| 48 | + |
| 49 | + // Enable/disable "other" textboxes |
| 50 | + $( '.enableForOther' ).click( function() { |
| 51 | + var $textbox = $( '#' + $(this).attr( 'rel' ) ); |
| 52 | + if ( $(this).val() == 'other' ) { // FIXME: Ugh, this is ugly |
| 53 | + $textbox.removeAttr( 'disabled' ); |
| 54 | + } else { |
| 55 | + $textbox.attr( 'disabled', 'disabled' ); |
| 56 | + } |
| 57 | + } ); |
| 58 | + |
| 59 | + // Synchronize radio button label for sitename with textbox |
| 60 | + $label = $( 'label[for=config__NamespaceType_site-name]' ); |
| 61 | + labelText = $label.text(); |
| 62 | + $label.text( labelText.replace( '$1', '' ) ); |
| 63 | + $( '#config_wgSitename' ).bind( 'keyup change', function() { sync( $(this) ); } ); |
| 64 | + sync( $( '#config_wgSitename' ) ); |
| 65 | + function sync( $e ) { |
| 66 | + var value = $e.val() |
| 67 | + .replace( /[\[\]\{\}|#<>%+? ]/g, '_' ) |
| 68 | + .replace( /&/, '&' ) |
| 69 | + .replace( /__+/g, '_' ) |
| 70 | + .replace( /^_+/, '' ) |
| 71 | + .replace( /_+$/, '' ); |
| 72 | + value = value.substr( 0, 1 ).toUpperCase() + value.substr( 1 ); |
| 73 | + $label.text( labelText.replace( '$1', value ) ); |
36 | 74 | } |
37 | | - } |
38 | | -} |
39 | | -function enableOrDisableControlArray( sourceID, targetIDs, enable ) { |
40 | | - var source = document.getElementById( sourceID ); |
41 | | - var disabled = !!source.checked == enable ? '' : '1'; |
42 | | - if ( !source ) { |
43 | | - return; |
44 | | - } |
45 | | - for ( var i = 0; i < targetIDs.length; i++ ) { |
46 | | - var elt = document.getElementById( targetIDs[i] ); |
47 | | - if ( elt ) elt.disabled = disabled; |
48 | | - } |
49 | | -} |
50 | | -function enableControlArray( sourceID, targetIDs, enable ) { |
51 | | - enableOrDisableControlArray( sourceID, targetIDs, true ); |
52 | | -} |
53 | | -function disableControlArray( sourceID, targetIDs ) { |
54 | | - enableOrDisableControlArray( sourceID, targetIDs, false ); |
55 | | -} |
56 | | - |
57 | | -function showControlArray( sourceID, targetIDs ) { |
58 | | - var source = document.getElementById( sourceID ); |
59 | | - var show = !!source.checked == false ? '' : '1'; |
60 | | - if ( !source ) { |
61 | | - return; |
62 | | - } |
63 | | - for ( var i = 0; i < targetIDs.length; i++ ) { |
64 | | - var elt = document.getElementById( targetIDs[i] ); |
65 | | - if ( !elt ) continue; |
66 | | - if ( show ) { |
67 | | - elt.style.display = 'block'; |
68 | | - } else { |
69 | | - elt.style.display = 'none'; |
70 | | - } |
71 | | - } |
72 | | -} |
73 | | -wgSameNamespacePrefix = null; |
74 | | - |
75 | | -function setProjectNamespace() { |
76 | | - var radio = document.getElementById( 'config__NamespaceType_site-name' ); |
77 | | - if ( radio == null ) return; |
78 | | - var li = radio.parentNode; |
79 | | - var labels = li.getElementsByTagName( 'label' ); |
80 | | - if ( labels.length == 0 ) return; |
81 | | - var label = labels.item( 0 ); |
82 | | - |
83 | | - if ( wgSameNamespacePrefix == null ) { |
84 | | - wgSameNamespacePrefix = label.innerHTML; |
85 | | - } |
86 | | - var input = document.getElementById( 'config_wgSitename' ); |
87 | | - if ( input == null ) return; |
88 | | - var value = input.value; |
89 | | - value = value.replace(/[\[\]\{\}|#<>%+? ]/g, '_'); |
90 | | - value = value.replace(/&/, '&'); |
91 | | - value = value.replace(/__+/g, '_'); |
92 | | - value = value.replace(/^_+/, '').replace(/_+$/, ''); |
93 | | - value = value.substr(0, 1).toUpperCase() |
94 | | - + value.substr(1); |
95 | | - label.innerHTML = wgSameNamespacePrefix.replace('$1', value); |
96 | | -} |
97 | | - |
| 75 | + |
| 76 | + } ); |
| 77 | +})(jQuery); |
Index: branches/new-installer/phase3/skins/common/config.css |
— | — | @@ -85,6 +85,7 @@ |
86 | 86 | .config-show-help, .config-hide-help { |
87 | 87 | margin-left: 14em; |
88 | 88 | } |
| 89 | +.config-hide-help { display: none; } |
89 | 90 | .config-show-help a, .config-hide-help a { |
90 | 91 | background-image: url(images/help-22.png); |
91 | 92 | background-position: 0 0; |
— | — | @@ -93,11 +94,10 @@ |
94 | 95 | height: 26px; |
95 | 96 | padding-left: 26px; |
96 | 97 | } |
97 | | -.config-help-message { display: none; } |
98 | | -.config-hide-help { display: none; } |
99 | 98 | |
100 | 99 | .config-help-message { |
101 | 100 | font-size: 85%; |
| 101 | + display: none; |
102 | 102 | } |
103 | 103 | |
104 | 104 | .config-message { |
Index: branches/new-installer/phase3/includes/installer/WebInstaller.php |
— | — | @@ -505,15 +505,15 @@ |
506 | 506 | |
507 | 507 | return |
508 | 508 | "<div class=\"config-help-wrapper\">\n" . |
509 | | - "<div class=\"config-show-help\" id=\"config-show-help-$id\">\n" . |
510 | | - Xml::openElement( 'a', array( 'href' => "javascript:showHelp($id,true)" ) ) . |
| 509 | + "<div class=\"config-help-message\">\n" . |
| 510 | + $html . |
| 511 | + "</div>\n" . |
| 512 | + "<div class=\"config-show-help\">\n" . |
| 513 | + "<a href=\"#\">" . |
511 | 514 | wfMsgHtml( 'config-show-help' ) . |
512 | 515 | "</a></div>\n" . |
513 | | - "<div class=\"config-help-message\" id=\"config-help-message-$id\">\n" . |
514 | | - $html. |
515 | | - "</div>\n" . |
516 | | - "<div class=\"config-hide-help\" id=\"config-hide-help-$id\">\n" . |
517 | | - Xml::openElement( 'a', array( 'href' => "javascript:showHelp($id,false)" ) ) . |
| 516 | + "<div class=\"config-hide-help\">\n" . |
| 517 | + "<a href=\"#\">" . |
518 | 518 | wfMsgHtml( 'config-hide-help' ) . |
519 | 519 | "</a></div>\n</div>\n"; |
520 | 520 | } |
— | — | @@ -994,32 +994,29 @@ |
995 | 995 | $defaultType = $this->getVar( 'wgDBtype' ); |
996 | 996 | foreach ( $this->parent->getVar( '_CompiledDBs' ) as $type ) { |
997 | 997 | $installer = $this->parent->getDBInstaller( $type ); |
998 | | - $encType = Xml::encodeJsVar( $type ); |
999 | 998 | $types .= |
1000 | 999 | '<li>' . |
1001 | 1000 | Xml::radioLabel( |
1002 | 1001 | $installer->getReadableName(), |
1003 | 1002 | 'DBType', |
1004 | 1003 | $type, |
1005 | | - 'DBType_' . $type, |
| 1004 | + "DBType_$type", |
1006 | 1005 | $type == $defaultType, |
1007 | | - array( 'onclick' => "showDBArea($encType);" ) |
| 1006 | + array( 'class' => 'dbRadio', 'rel' => "DB_wrapper_$type" ) |
1008 | 1007 | ) . |
1009 | 1008 | "</li>\n"; |
1010 | 1009 | |
1011 | 1010 | $settings .= |
1012 | | - Xml::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type ) ) . |
| 1011 | + Xml::openElement( 'div', array( 'id' => 'DB_wrapper_' . $type, 'class' => 'dbWrapper' ) ) . |
1013 | 1012 | Xml::element( 'h3', array(), wfMsg( 'config-header-' . $type ) ) . |
1014 | 1013 | $installer->getConnectForm() . |
1015 | 1014 | "</div>\n"; |
1016 | 1015 | } |
1017 | 1016 | $types .= "</ul><br clear=\"left\"/>\n"; |
1018 | | - $encType = Xml::encodeJsVar( $defaultType ); |
1019 | 1017 | |
1020 | 1018 | $this->addHTML( |
1021 | 1019 | $this->parent->label( 'config-db-type', false, $types ) . |
1022 | | - $settings . |
1023 | | - "<script type=\"text/javascript\">resetDBArea();</script>\n" |
| 1020 | + $settings |
1024 | 1021 | ); |
1025 | 1022 | |
1026 | 1023 | $this->endForm(); |
— | — | @@ -1132,8 +1129,6 @@ |
1133 | 1130 | if ( $this->getVar( 'wgSitename' ) == $GLOBALS['wgSitename'] ) { |
1134 | 1131 | $this->setVar( 'wgSitename', '' ); |
1135 | 1132 | } |
1136 | | - $js = 'enableControlArray("config__NamespaceType_other", ["config_wgMetaNamespace"])'; |
1137 | | - $attribs = array( 'onclick' => $js ); |
1138 | 1133 | |
1139 | 1134 | // Set wgMetaNamespace to something valid before we show the form. |
1140 | 1135 | // $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki' |
— | — | @@ -1144,10 +1139,6 @@ |
1145 | 1140 | $this->parent->getTextBox( array( |
1146 | 1141 | 'var' => 'wgSitename', |
1147 | 1142 | 'label' => 'config-site-name', |
1148 | | - 'attribs' => array( |
1149 | | - 'onkeyup' => 'setProjectNamespace();', |
1150 | | - 'onchange' => 'setProjectNamespace();' |
1151 | | - ) |
1152 | 1143 | ) ) . |
1153 | 1144 | $this->parent->getHelpBox( 'config-site-name-help' ) . |
1154 | 1145 | $this->parent->getRadioSet( array( |
— | — | @@ -1155,13 +1146,13 @@ |
1156 | 1147 | 'label' => 'config-project-namespace', |
1157 | 1148 | 'itemLabelPrefix' => 'config-ns-', |
1158 | 1149 | 'values' => array( 'site-name', 'generic', 'other' ), |
1159 | | - 'commonAttribs' => $attribs, |
| 1150 | + 'commonAttribs' => array( 'class' => 'enableForOther', 'rel' => 'config_wgMetaNamespace' ), |
1160 | 1151 | ) ) . |
1161 | 1152 | $this->parent->getTextBox( array( |
1162 | 1153 | 'var' => 'wgMetaNamespace', |
1163 | 1154 | 'label' => '', |
| 1155 | + 'attribs' => array( 'disabled' => '' ), |
1164 | 1156 | ) ) . |
1165 | | - "<script type=\"text/javascript\">\nsetProjectNamespace();\n$js\n</script>\n" . |
1166 | 1157 | $this->parent->getHelpBox( 'config-project-namespace-help' ) . |
1167 | 1158 | $this->parent->getFieldsetStart( 'config-admin-box' ) . |
1168 | 1159 | $this->parent->getTextBox( array( |
— | — | @@ -1297,10 +1288,6 @@ |
1298 | 1289 | } |
1299 | 1290 | } |
1300 | 1291 | |
1301 | | - $licenseJs = 'showControlArray("config__LicenseCode_cc-choose", ["config-cc-wrapper"]);'; |
1302 | | - $emailJs = 'enableControlArray("config_wgEnableEmail", ["config_wgPasswordSender", "config_wgEnableUserEmail", "config_wgEnotifUserTalk", "config_wgEnotifWatchlist", "config_wgEmailAuthentication"]);'; |
1303 | | - $uploadJs = 'enableControlArray("config_wgEnableUploads", ["config_wgDeletedDirectory"]);'; |
1304 | | - |
1305 | 1292 | $this->startForm(); |
1306 | 1293 | $this->addHTML( |
1307 | 1294 | # User Rights |
— | — | @@ -1318,7 +1305,7 @@ |
1319 | 1306 | 'label' => 'config-license', |
1320 | 1307 | 'itemLabelPrefix' => 'config-license-', |
1321 | 1308 | 'values' => array_keys( $this->parent->licenses ), |
1322 | | - 'commonAttribs' => array( 'onclick' => $licenseJs ) |
| 1309 | + 'commonAttribs' => array( 'class' => 'licenseRadio' ), |
1323 | 1310 | ) ) . |
1324 | 1311 | $this->getCCChooser() . |
1325 | 1312 | $this->parent->getHelpBox( 'config-license-help' ) . |
— | — | @@ -1328,9 +1315,10 @@ |
1329 | 1316 | $this->parent->getCheckBox( array( |
1330 | 1317 | 'var' => 'wgEnableEmail', |
1331 | 1318 | 'label' => 'config-enable-email', |
1332 | | - 'attribs' => array( 'onclick' => $emailJs ), |
| 1319 | + 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'emailwrapper' ), |
1333 | 1320 | ) ) . |
1334 | 1321 | $this->parent->getHelpBox( 'config-enable-email-help' ) . |
| 1322 | + "<div id=\"emailwrapper\">" . |
1335 | 1323 | $this->parent->getTextBox( array( |
1336 | 1324 | 'var' => 'wgPasswordSender', |
1337 | 1325 | 'label' => 'config-email-sender' |
— | — | @@ -1356,6 +1344,7 @@ |
1357 | 1345 | 'label' => 'config-email-auth', |
1358 | 1346 | ) ) . |
1359 | 1347 | $this->parent->getHelpBox( 'config-email-auth-help' ) . |
| 1348 | + "</div>" . |
1360 | 1349 | $this->parent->getFieldsetEnd() |
1361 | 1350 | ); |
1362 | 1351 | |
— | — | @@ -1379,9 +1368,10 @@ |
1380 | 1369 | $this->parent->getCheckBox( array( |
1381 | 1370 | 'var' => 'wgEnableUploads', |
1382 | 1371 | 'label' => 'config-upload-enable', |
1383 | | - 'attribs' => array( 'onclick' => $uploadJs ), |
| 1372 | + 'attribs' => array( 'class' => 'showHideRadio', 'rel' => 'uploadwrapper' ), |
1384 | 1373 | ) ) . |
1385 | 1374 | $this->parent->getHelpBox( 'config-upload-help' ) . |
| 1375 | + '<div id="uploadwrapper" style="display: none;">' . |
1386 | 1376 | $this->parent->getTextBox( array( |
1387 | 1377 | 'var' => 'wgDeletedDirectory', |
1388 | 1378 | 'label' => 'config-upload-deleted', |
— | — | @@ -1392,6 +1382,7 @@ |
1393 | 1383 | 'label' => 'config-logo' |
1394 | 1384 | ) ) . |
1395 | 1385 | $this->parent->getHelpBox( 'config-logo-help' ) . |
| 1386 | + '</div>' . |
1396 | 1387 | $this->parent->getFieldsetEnd() |
1397 | 1388 | ); |
1398 | 1389 | |
— | — | @@ -1420,10 +1411,7 @@ |
1421 | 1412 | 'label' => 'config-memcached-servers', |
1422 | 1413 | ) ) . |
1423 | 1414 | $this->parent->getHelpBox( 'config-memcached-help' ) . |
1424 | | - $this->parent->getFieldsetEnd() . |
1425 | | - |
1426 | | - "<script type=\"text/javascript\">$licenseJs $emailJs $uploadJs</script>\n" |
1427 | | - |
| 1415 | + $this->parent->getFieldsetEnd() |
1428 | 1416 | ); |
1429 | 1417 | $this->endForm(); |
1430 | 1418 | } |
— | — | @@ -1466,7 +1454,7 @@ |
1467 | 1455 | } |
1468 | 1456 | |
1469 | 1457 | return |
1470 | | - "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\">\n" . |
| 1458 | + "<div class=\"config-cc-wrapper\" id=\"config-cc-wrapper\" style=\"display: none;\">\n" . |
1471 | 1459 | Xml::element( 'iframe', $iframeAttribs, '', false /* not short */ ) . |
1472 | 1460 | "</div>\n"; |
1473 | 1461 | } |
Index: branches/new-installer/phase3/includes/installer/WebInstallerOutput.php |
— | — | @@ -112,6 +112,7 @@ |
113 | 113 | <?php echo "var dbTypes = " . Xml::encodeJsVar( $dbTypes ) . ";\n"; ?> |
114 | 114 | // --> |
115 | 115 | </script> |
| 116 | + <script type="text/javascript" src="../skins/common/jquery.min.js"></script> |
116 | 117 | <script type="text/javascript" src="../skins/common/config.js"></script> |
117 | 118 | </head> |
118 | 119 | |
— | — | @@ -176,6 +177,7 @@ |
177 | 178 | <title><?php $this->outputTitle(); ?></title> |
178 | 179 | <link rel="stylesheet" type="text/css" href="../skins/monobook/main.css"/> |
179 | 180 | <link rel="stylesheet" type="text/css" href="../skins/common/config.css"/> |
| 181 | + <script type="text/javascript" src="../skins/common/jquery.min.js"></script> |
180 | 182 | <script type="text/javascript" src="../skins/common/config.js"></script> |
181 | 183 | </head> |
182 | 184 | |