* Indicate when a preview is unavailable/failed
authorRob Church <robchurch@users.mediawiki.org>
Sat, 14 Jul 2007 23:54:00 +0000 (23:54 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Sat, 14 Jul 2007 23:54:00 +0000 (23:54 +0000)
* Show a little progress "spinner" during the AJAX request

includes/DefaultSettings.php
includes/Skin.php
includes/SpecialUpload.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc
skins/common/images/spinner.gif [new file with mode: 0644]
skins/common/upload.js
skins/common/wikibits.js

index 3d9e0e8..a5f399e 100644 (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:
index aa56237..21b60ec 100644 (file)
@@ -1652,5 +1652,5 @@ END;
                wfProfileOut( $fname );
                return $bar;
        }
-}
-
+       
+}
\ No newline at end of file
index 75a0f6a..00cf7ef 100644 (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>" );
                        }
index 362ed4d..2c7c795 100644 (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)',
 
index d8e7a6d..2351877 100644 (file)
@@ -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 (file)
index 0000000..1cca4cc
Binary files /dev/null and b/skins/common/images/spinner.gif differ
index 3fc5fa0..d6f589f 100644 (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 );
\ No newline at end of file
index 58d2fe6..e37cd4c 100644 (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)) {