* Indicate when a preview is unavailable/failed

* Show a little progress "spinner" during the AJAX request
This commit is contained in:
Rob Church 2007-07-14 23:54:00 +00:00
parent 1ec212b612
commit bf2a2cd71e
8 changed files with 42 additions and 8 deletions

View file

@ -1201,7 +1201,7 @@ $wgCacheEpoch = '20030516000000';
* to ensure that client-side caches don't keep obsolete copies of global
* styles.
*/
$wgStyleVersion = '83';
$wgStyleVersion = '84';
# Server-side caching:

View file

@ -1652,5 +1652,5 @@ END;
wfProfileOut( $fname );
return $bar;
}
}
}

View file

@ -572,7 +572,7 @@ class UploadForm {
$output = $wgParser->parse( $revision->getText(), $title, new ParserOptions() );
return $output->getText();
}
return '';
return wfMsgHtml( 'license-nopreview' );
}
/**
@ -890,7 +890,8 @@ EOT
<tr>" );
if( $useAjaxLicencePreview ) {
$wgOut->addHtml( "
<td id=\"mw-licence-preview\" colspan=\"2\"></td>
<td></td>
<td id=\"mw-licence-preview\"></td>
</tr>
<tr>" );
}

View file

@ -1417,6 +1417,7 @@ If you have this image in full resolution upload this one, otherwise change the
'license' => 'Licensing',
'nolicense' => 'None selected',
'licenses' => '-', # don't translate or duplicate this message to other languages
'license-nopreview' => '(Preview not available)',
'upload_source_url' => ' (a valid, publicly accessible URL)',
'upload_source_file' => ' (a file on your computer)',

View file

@ -827,6 +827,7 @@ $wgMessageStructure = array(
'license',
'nolicense',
'licenses',
'license-nopreview',
'upload_source_url',
'upload_source_file',
),

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -147,6 +147,7 @@ var wgUploadLicenceObj = {
if( licence in this.responseCache ) {
this.showPreview( this.responseCache[licence] );
} else {
injectSpinner( document.getElementById( 'wpLicense' ), 'licence' );
sajax_do_call( 'UploadForm::ajaxGetLicencePreview', [licence],
function( result ) {
wgUploadLicenceObj.processResult( result, licence );
@ -156,17 +157,17 @@ var wgUploadLicenceObj = {
},
'processResult' : function( result, licence ) {
removeSpinner( 'licence' );
this.showPreview( result.responseText );
this.responseCache[licence] = result.responseText;
},
'showPreview' : function( preview ) {
var previewPanel = document.getElementById( 'mw-licence-preview' );
if( previewPanel.innerHTML != preview ) {
if( previewPanel.innerHTML != preview )
previewPanel.innerHTML = preview;
}
}
}
addOnloadHook( licenseSelectorFixup );

View file

@ -1243,6 +1243,36 @@ function jsMsg( message, className ) {
return true;
}
/**
* Inject a cute little progress spinner after the specified element
*
* @param element Element to inject after
* @param id Identifier string (for use with removeSpinner(), below)
*/
function injectSpinner( element, id ) {
var spinner = document.createElement( "img" );
spinner.id = "mw-spinner-" + id;
spinner.src = stylepath + "/common/images/spinner.gif";
spinner.alt = spinner.title = "...";
if( element.nextSibling ) {
element.parentNode.insertBefore( spinner, element.nextSibling );
} else {
element.parentNode.appendChild( spinner );
}
}
/**
* Remove a progress spinner added with injectSpinner()
*
* @param id Identifier string
*/
function removeSpinner( id ) {
var spinner = document.getElementById( "mw-spinner-" + id );
if( spinner ) {
spinner.parentNode.removeChild( spinner );
}
}
function runOnloadHook() {
// don't run anything below this for non-dom browsers
if (doneOnloadHook || !(document.getElementById && document.getElementsByTagName)) {