* (bug 3318) UI workarounds for disabled items in license selector
authorBrion Vibber <brion@users.mediawiki.org>
Sun, 1 Jan 2006 01:05:21 +0000 (01:05 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sun, 1 Jan 2006 01:05:21 +0000 (01:05 +0000)
  MSIE/Win: items now grayed out, JS will revert to 'non selected' if clicked
  Safari: JS will revert to 'non selected' if clicked (but not gray)
  MSIE/Mac: indented items now visible (JS hack)

RELEASE-NOTES
includes/Licenses.php
includes/SpecialUpload.php
skins/common/upload.js [new file with mode: 0644]

index b311c5d..45066c3 100644 (file)
@@ -382,6 +382,11 @@ fully support the editing toolbar, but was found to be too confusing.
     namespace are changed
 * Removed $wgUseCategoryMagic option, categories are now enabled unconditionally
 * (bug 4359) red [[user:#id]] links generated in [[special:Log]]
+* (bug 3318) UI workarounds for disabled items in license selector
+  MSIE/Win: items now grayed out, JS will revert to 'non selected' if clicked
+  Safari: JS will revert to 'non selected' if clicked (but not gray)
+  MSIE/Mac: indented items now visible (JS hack)
+
 
 === Caveats ===
 
index 4294e2f..5a5df29 100644 (file)
@@ -101,6 +101,7 @@ class Licenses {
                                        array(
                                                'value' => '',
                                                'disabled' => 'disabled',
+                                               'style' => 'color: GrayText', // for MSIE
                                        ),
                                        $depth
                                );
index 9f8b63f..0f738e5 100644 (file)
@@ -609,10 +609,13 @@ class UploadForm {
                <tr>" );
        
        if ( $licenseshtml != '' ) {
+               global $wgStylePath;
                $wgOut->addHTML( "
                        <td align='right'><label for='wpLicense'>$license:</label></td>
                        <td align='left'>
-                               <select name='wpLicense' id='wpLicense' tabindex='4'>
+                               <script type='text/javascript' src=\"$wgStylePath/common/upload.js\"></script>
+                               <select name='wpLicense' id='wpLicense' tabindex='4'
+                                       onchange='licenseSelectorCheck()'
                                        <option value=''>$nolicense</option>
                                        $licenseshtml
                                </select>
diff --git a/skins/common/upload.js b/skins/common/upload.js
new file mode 100644 (file)
index 0000000..160fbf2
--- /dev/null
@@ -0,0 +1,23 @@
+function licenseSelectorCheck() {
+       var selector = document.getElementById("wpLicense");
+       if (selector.selectedIndex > 0 &&
+               selector.options[selector.selectedIndex].value == "" ) {
+               // Browser is broken, doesn't respect disabled attribute on <option>
+               selector.selectedIndex = 0;
+       }
+}
+
+function licenseSelectorFixup() {
+       // for MSIE/Mac; non-breaking spaces cause the <option> not to render
+       // but, for some reason, setting the text to itself works
+       var selector = document.getElementById("wpLicense");
+       var ua = navigator.userAgent;
+       var isMacIe = (ua.indexOf("MSIE") != -1) && (ua.indexOf("Mac") != -1);
+       if (isMacIe) {
+               for (var i = 0; i < selector.options.length; i++) {
+                       selector.options[i].text = selector.options[i].text;
+               }
+       }
+}
+
+addOnloadHook(licenseSelectorFixup);