r89962 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89961‎ | r89962 | r89963 >
Date:14:15, 13 June 2011
Author:neilk
Status:resolved (Comments)
Tags:
Comment:
delay lightBox behaviour until thumbnails are known to be ready
Modified paths:
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizard.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.fileApi.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js
@@ -93,9 +93,9 @@
9494 _this.upload.setThumbnail(
9595 $preview,
9696 mw.UploadWizard.config[ 'thumbnailWidth' ],
97 - mw.UploadWizard.config[ 'thumbnailMaxHeight' ]
 97+ mw.UploadWizard.config[ 'thumbnailMaxHeight' ],
 98+ true
9899 );
99 - _this.upload.setLightBox( $preview );
100100
101101 };
102102
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js
@@ -573,8 +573,9 @@
574574 * @param selector
575575 * @param width Width constraint
576576 * @param height Height constraint (optional)
 577+ * @param boolean add lightbox large preview when ready
577578 */
578 - setThumbnail: function( selector, width, height ) {
 579+ setThumbnail: function( selector, width, height, isLightBox ) {
579580 var _this = this;
580581 if ( typeof width === 'undefined' || width === null || width <= 0 ) {
581582 width = mw.UploadWizard.config['thumbnailWidth'];
@@ -625,7 +626,7 @@
626627 'margin-top': ( parseInt( ( height - image.height * scaling ) / 2, 10 ) ).toString() + 'px'
627628 } )
628629 )
629 - );
 630+ );
630631 placed = true;
631632 };
632633
@@ -635,6 +636,9 @@
636637 $.subscribeReady(
637638 'thumbnails.' + _this.index,
638639 function ( x ) {
 640+ if ( isLightBox ) {
 641+ _this.setLightBox( selector );
 642+ }
639643 if ( !placed ) {
640644 if ( x === 'api' ) {
641645 // get the thumbnail via API. This also works with an async pub/sub model; if this thumbnail was already
@@ -680,7 +684,8 @@
681685 _this.setThumbnail(
682686 $imgDiv,
683687 mw.UploadWizard.config[ 'largeThumbnailWidth' ],
684 - mw.UploadWizard.config[ 'largeThumbnailMaxHeight' ]
 688+ mw.UploadWizard.config[ 'largeThumbnailMaxHeight' ],
 689+ false /* obviously the largeThumbnail doesn't have a lightbox itself! */
685690 );
686691 return false;
687692 } ); // close thumbnail click function
@@ -1503,7 +1508,12 @@
15041509 .html( $j( '<a/>' ).html( upload.title.getMainText() ) );
15051510 var $thumbnailWrapDiv = $j( '<div></div>' ).addClass( 'mwe-upwiz-thumbnail-side' );
15061511 $thumbnailWrapDiv.append( $thumbnailDiv, $thumbnailCaption );
1507 - upload.setThumbnail( $thumbnailDiv, mw.UploadWizard.config[ 'thumbnailWidth' ], mw.UploadWizard.config[ 'thumbnailMaxHeight' ] );
 1512+ upload.setThumbnail(
 1513+ $thumbnailDiv,
 1514+ mw.UploadWizard.config[ 'thumbnailWidth' ],
 1515+ mw.UploadWizard.config[ 'thumbnailMaxHeight' ],
 1516+ false
 1517+ );
15081518
15091519 // Set the thumbnail links so that they point to the image description page
15101520 $thumbnailWrapDiv.find( 'a' ).attr( {
@@ -1616,8 +1626,12 @@
16171627 // add a preview on the deeds page
16181628 var thumbnailDiv = $j( '<div></div>' ).addClass( 'mwe-upwiz-thumbnail' );
16191629 $j( '#mwe-upwiz-deeds-thumbnails' ).append( thumbnailDiv );
1620 - _this.upload.setThumbnail( thumbnailDiv, mw.UploadWizard.config[ 'thumbnailWidth' ], mw.UploadWizard.config[ 'thumbnailMaxHeight' ] );
1621 - _this.upload.setLightBox( thumbnailDiv );
 1630+ _this.upload.setThumbnail(
 1631+ thumbnailDiv,
 1632+ mw.UploadWizard.config['thumbnailWidth'],
 1633+ mw.UploadWizard.config['thumbnailMaxHeight'],
 1634+ true
 1635+ );
16221636 }
16231637 };
16241638
Index: trunk/extensions/UploadWizard/resources/mw.fileApi.js
@@ -21,7 +21,7 @@
2222 * @return boolean
2323 */
2424 isPreviewableFile: function( file ) {
25 - var known = [ 'image/png', 'image/gif', 'image/jpeg', 'image/svg+xml'],
 25+ var known = [ /* 'image/png' */, 'image/gif', 'image/jpeg', 'image/svg+xml'],
2626 tooHuge = 10 * 1024 * 1024;
2727 return ( $.inArray( file.type, known ) !== -1 ) && file.size > 0 && file.size < tooHuge;
2828 }
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDetails.js
@@ -452,8 +452,12 @@
453453 */
454454 populate: function() {
455455 var _this = this;
456 - _this.upload.setThumbnail( _this.thumbnailDiv, mw.UploadWizard.config['thumbnailWidth'], mw.UploadWizard.config['thumbnailMaxHeight'] );
457 - _this.upload.setLightBox( _this.thumbnailDiv );
 456+ _this.upload.setThumbnail(
 457+ _this.thumbnailDiv,
 458+ mw.UploadWizard.config['thumbnailWidth'],
 459+ mw.UploadWizard.config['thumbnailMaxHeight'],
 460+ true
 461+ );
458462 _this.prefillDate();
459463 _this.prefillSource();
460464 _this.prefillAuthor();

Comments

#Comment by Brion VIBBER (talk | contribs)   18:22, 13 June 2011

(Comment bit was fixed in later commit)

I might recommend a clearer interface than an unlabeled 'true'/'false' for the lightbox setting; it's very opaque looking at the calls as to what that's supposed to mean.

Status & tagging log