From: Rob Church Date: Sat, 14 Jul 2007 23:54:00 +0000 (+0000) Subject: * Indicate when a preview is unavailable/failed X-Git-Tag: 1.31.0-rc.0~52097 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=bf2a2cd71ebf5bb7911234dcd6fe10da7161d5cb;p=lhc%2Fweb%2Fwiklou.git * Indicate when a preview is unavailable/failed * Show a little progress "spinner" during the AJAX request --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 3d9e0e819f..a5f399e5c1 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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: diff --git a/includes/Skin.php b/includes/Skin.php index aa5623773a..21b60ec200 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -1652,5 +1652,5 @@ END; wfProfileOut( $fname ); return $bar; } -} - + +} \ No newline at end of file diff --git a/includes/SpecialUpload.php b/includes/SpecialUpload.php index 75a0f6a6ca..00cf7ef35b 100644 --- a/includes/SpecialUpload.php +++ b/includes/SpecialUpload.php @@ -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 " ); if( $useAjaxLicencePreview ) { $wgOut->addHtml( " - + + " ); } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 362ed4d09f..2c7c795603 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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)', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index d8e7a6d1fc..2351877ee3 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -827,6 +827,7 @@ $wgMessageStructure = array( 'license', 'nolicense', 'licenses', + 'license-nopreview', 'upload_source_url', 'upload_source_file', ), diff --git a/skins/common/images/spinner.gif b/skins/common/images/spinner.gif new file mode 100644 index 0000000000..1cca4cc355 Binary files /dev/null and b/skins/common/images/spinner.gif differ diff --git a/skins/common/upload.js b/skins/common/upload.js index 3fc5fa0a47..d6f589fb90 100644 --- a/skins/common/upload.js +++ b/skins/common/upload.js @@ -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 ); \ No newline at end of file diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index 58d2fe6148..e37cd4c39e 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -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)) {