"Wikitravel has a speed and convenience the books' publishers can only envy." — Time Europe
User:Tatata/test/4
From Wikitravel Shared
< User:Tatata | test
Contents
[edit] XHTML
[edit] Upload file button
[edit] current system
<tr> <td></td> <td align='left'><input tabindex='9' type='submit' name='wpUpload' value="Upload file" title="Start upload [s]" accesskey="s" /></td> </tr>
[edit] new system at page loaded
Add "disabled" attribute to "input" element.
<tr> <td></td> <td align='left'><input tabindex='9' type='submit' name='wpUpload' value="Upload file" title="Start upload [s]" accesskey="s" disabled="disabled" /></td> </tr>
[edit] js
- where to implement?
- how
- Testing
- Windows XP - SP3
- Firefox 3.0.10 - OK
- Safari 3.2.3 - OK (load error on 3 files that are generated by JavaScript)
- Internet Explorer 7 - OK
- Windows XP - SP3
- Side effect
- Maybe, "Upload file" button will always be disabled on language versions which don't have MediaWiki:Licenses.
- ar:MediaWiki:Licenses - none.
- ca:MediaWiki:Licenses - none.
- de:MediaWiki:Licenses - none.
- en:MediaWiki:Licenses - ok.
- eo:MediaWiki:Licenses - none.
- es:MediaWiki:Licenses - none.
- fi:MediaWiki:Licenses - none.
- fr:MediaWiki:Licenses - ok.
- he:MediaWiki:Licenses - none.
- hi:MediaWiki:Licenses - none.
- hu:MediaWiki:Licenses - ok, but some mistakes.
- it:MediaWiki:Licenses - none.
- ja:MediaWiki:Licenses - ok.
- nl:MediaWiki:Licenses - none.
- pl:MediaWiki:Licenses - none.
- pt:MediaWiki:Licenses - ok.
- ro:MediaWiki:Licenses - none.
- ru:MediaWiki:Licenses - none.
- sv:MediaWiki:Licenses - ok.
- zh:MediaWiki:Licenses - none.
- Maybe, "Upload file" button will always be disabled on language versions which don't have MediaWiki:Licenses.
[edit] licenseSelectorCheck
Check selection and perform removeAttribute/setAttribute here, since this function is invoked at "onchange" attribute of "select" element.
[edit] current script
function licenseSelectorCheck() {
var selector = document.getElementById( "wpLicense" );
var selection = selector.options[selector.selectedIndex].value;
if( selector.selectedIndex > 0 ) {
if( selection == "" ) {
// Option disabled, but browser is broken and doesn't respect this
selector.selectedIndex = 0;
}
}
// We might show a preview
wgUploadLicenseObj.fetchPreview( selection );
}
[edit] new script
function licenseSelectorCheck() {
var selector = document.getElementById( "wpLicense" );
var selection = selector.options[selector.selectedIndex].value;
var uploadbutton = document.getElementsByName( "wpUpload" ).item(0); // license check
if( selector.selectedIndex > 0 ) {
uploadbutton.removeAttribute("disabled"); // license check
if( selection == "" ) {
// Option disabled, but browser is broken and doesn't respect this
selector.selectedIndex = 0;
}
}
else { // license check
uploadbutton.setAttribute("disabled", "disabled"); // license check
} // license check
// We might show a preview
wgUploadLicenseObj.fetchPreview( selection );
}
[edit] licenseSelectorFixup
Perform setAttribute here at the time page loaded, since this function is set at "addOnloadHook" of the js file.
[edit] current script
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");
if (selector) {
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;
}
}
}
}
[edit] new script
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");
if (selector) {
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;
}
}
}
var uploadbutton = document.getElementsByName( "wpUpload" ).item(0); // license check
uploadbutton.setAttribute("disabled", "disabled"); // license check
}

