r88197 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88196‎ | r88197 | r88198 >
Date:17:17, 15 May 2011
Author:janpaul123
Status:deferred (Comments)
Tags:
Comment:
Better gallery
Modified paths:
  • /trunk/extensions/WikiLove/WikiLove.api.php (modified) (history)
  • /trunk/extensions/WikiLove/wikiLove.css (modified) (history)
  • /trunk/extensions/WikiLove/wikiLove.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiLove/wikiLove.css
@@ -266,6 +266,10 @@
267267 }
268268
269269 /* add details gallery */
 270+#wikiLoveDialog #wlGallery {
 271+ min-height: 40px;
 272+}
 273+
270274 #wikiLoveDialog #wlGallery img {
271275 margin-right: 5px;
272276 margin-bottom: 5px;
@@ -281,6 +285,16 @@
282286 background-color: #f56427;
283287 }
284288
 289+#wikiLoveDialog #wlGallerySpinner {
 290+ position: relative;
 291+}
 292+
 293+#wikiLoveDialog #wlGallerySpinner .wlSpinner {
 294+ float: none;
 295+ position: absolute;
 296+ z-index: -1;
 297+}
 298+
285299 /* dialog preview */
286300 #wikiLoveDialog #wlPreview {
287301 float: right;
Index: trunk/extensions/WikiLove/wikiLove.js
@@ -33,10 +33,10 @@
3434 template: '',
3535 gallery: {
3636 // right now we can only query the local wiki (not e.g. commons)
37 - category: 'Category:Cat',
 37+ category: 'Category:Cats',
3838 total: 100, // total number of pictures to retrieve, and to randomise
3939 num: 3, // number of pictures to show from the randomised set
40 - width: 150 // width of each picture in pixels in the interface (not in the template)
 40+ width: 145 // width of each picture in pixels in the interface (not in the template)
4141 }
4242 },
4343 // default type, nice to leave this one in place when adding other types
@@ -69,11 +69,11 @@
7070 // Find out if we can email the user
7171 $.wikiLove.getEmailable();
7272
 73+ // Reusable spinner string
 74+ var spinner = '<img class="wlSpinner" src="' + mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' )
 75+ + '/extensions/WikiLove/images/spinner.gif"/>';
 76+
7377 // Build a type list like this:
74 - // <ul id="wlTypes">
75 - // <li tabindex="0"><span>Barnstar</span></li>
76 - // <li tabindex="0"><span>Make your own</span></li>
77 - // </ul>
7878 var $typeList = $( '<ul id="wlTypes"></ul>' );
7979 for( var typeId in $.wikiLove.types ) {
8080 $button = $( '<a href="#"></a>' );
@@ -97,10 +97,6 @@
9898 }
9999
100100 // Build the left menu for selecting a type:
101 - // <div id="wlSelectType">
102 - // <h3>Select Type:</h3>
103 - // <ul id="wlTypes">...</ul>
104 - // </div>
105101 var $selectType = $( '<div id="wlSelectType"></div>' )
106102 .append( '<span class="wlNumber">1</span>' )
107103 .append( '<h3>' + mw.msg( 'wikilove-select-type' ) + '</h3>' )
@@ -115,22 +111,6 @@
116112 );
117113
118114 // Build the right top section for selecting a subtype and entering a title (optional) and message
119 - // <div id="wlAddDetails">
120 - // <h3>Add Details:</h3>
121 - //
122 - // <label for="wlSubtype" id="wlSubtypeLabel">...</label> (label depends on type)
123 - // <select id="wlSubtype">...</select> (also depends on type)
124 - //
125 - // <label for="wlTitle" id="wlTitleLabel">Title:</label> (hidden for some (sub)types)
126 - // <input type="text" class="text" id="wlTitle"/>
127 - //
128 - // <label for="wlMessage" id="wlMessageLabel">Enter a message:</label>
129 - // <span class="wlOmitSig">(without a signature)</span> (this span floats right)
130 - // <textarea id="wlMessage"></textarea> (textarea grows automatically with content)
131 - //
132 - // <input id="wlButtonPreview" class="submit" type="submit" value="Preview"/>
133 - // <img class="wlSpinner" src="..."/> (spinner for the preview button)
134 - // </div>
135115 var $addDetails = $( '<div id="wlAddDetails"></div>' )
136116 .append( '<span class="wlNumber">2</span>' )
137117 .append( '<h3>' + mw.msg( 'wikilove-add-details' ) + '</h3>' )
@@ -138,6 +118,7 @@
139119 .append( $( '<form id="wlPreviewForm"></form>' )
140120 .append( '<select id="wlSubtype"></select>' )
141121 .append( '<label id="wlGalleryLabel">' + mw.msg( 'wikilove-gallery' ) + '</label>' )
 122+ .append( '<div id="wlGallerySpinner">' + spinner + '</div>' )
142123 .append( '<div id="wlGallery"/>' )
143124 .append( '<label for="wlTitle" id="wlTitleLabel">' + mw.msg( 'wikilove-title' ) + '</label>' )
144125 .append( '<input type="text" class="text" id="wlTitle"/>' )
@@ -147,18 +128,11 @@
148129 .append( $('<div id="wlNotify"></div>').html('<input type="checkbox" id="wlNotifyCheckbox" name="notify"/> <label for="wlNotifyCheckbox">Notify user by email</label>') )
149130 .append( '<input id="wlButtonPreview" class="submit" type="submit" value="'
150131 + mw.msg( 'wikilove-button-preview' ) + '"/>' )
151 - .append( '<img class="wlSpinner" src="' + mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' )
152 - + '/extensions/WikiLove/images/spinner.gif"/>' )
 132+ .append( spinner )
153133 )
154134 .hide();
155135
156136 // Build the right bottom preview section
157 - // <div id="wlPreview">
158 - // <h3>Preview:</h3>
159 - // <div id="wlPreviewArea">...</div> (preview gets loaded here)
160 - // <input id="wlButtonSend" class="submit" type="submit" value="Send WikiLove"/>
161 - // <img class="wlSpinner" src="..."/> (another spinner for the send button)
162 - // </div>
163137 var $preview = $( '<div id="wlPreview"></div>' )
164138 .append( '<span class="wlNumber">3</span>' )
165139 .append( '<h3>' + mw.msg( 'wikilove-preview' ) + '</h3>' )
@@ -166,8 +140,7 @@
167141 .append( $( '<form id="wlSendForm"></form>' )
168142 .append( '<input id="wlButtonSend" class="submit" type="submit" value="'
169143 + mw.msg( 'wikilove-button-send' ) + '"/>' )
170 - .append( '<img class="wlSpinner" src="' + mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' )
171 - + '/extensions/WikiLove/images/spinner.gif"/>' )
 144+ .append( spinner )
172145 )
173146 .hide();
174147
@@ -488,6 +461,8 @@
489462 makeGallery: function() {
490463 $( '#wlGallery' ).html( '' );
491464 $.wikiLove.gallery = {};
 465+ $( '#wlGallerySpinner .wlSpinner' ).fadeIn( 200 );
 466+
492467 $.ajax({
493468 url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php',
494469 data: {
@@ -529,10 +504,13 @@
530505 // only add the image if it's actually an image
531506 if( page.imageinfo[0].mime.substr(0,5) == 'image' ) {
532507 // build an image tag with the correct url and width
533 - $img = $( '<img/>' );
534 - $img.attr( 'src', page.imageinfo[0].url );
535 - $img.attr( 'width', $.wikiLove.currentTypeOrSubtype.gallery.width );
 508+ $img = $( '<img/>' )
 509+ .attr( 'src', page.imageinfo[0].url )
 510+ .attr( 'width', $.wikiLove.currentTypeOrSubtype.gallery.width )
 511+ .hide()
 512+ .load( function() { $( this ).fadeIn( 400 ); } );
536513
 514+
537515 // append the image to the gallery and also make sure it's selectable
538516 $( '#wlGallery' ).append(
539517 $( '<a href="#"></a>' )
@@ -558,6 +536,8 @@
559537 $( '#wlGallery' ).hide();
560538 $( '#wlGalleryTitle' ).hide();
561539 }
 540+
 541+ $( '#wlGallerySpinner .wlSpinner' ).fadeOut( 200 );
562542 }
563543 });
564544 },
Index: trunk/extensions/WikiLove/WikiLove.api.php
@@ -15,7 +15,7 @@
1616 $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
1717 }
1818
19 - if ( stripos( $params['text'], $params['template'] ) === false ) {
 19+ if ( strlen( $params['template'] ) > 0 && stripos( $params['text'], $params['template'] ) === false ) {
2020 $this->dieUsage( 'Template could not be found in the message!', 'invalidtemplate' );
2121 }
2222

Comments

#Comment by Krinkle (talk | contribs)   19:22, 5 July 2011

Marking old as most if not all of this has been changed by later revisions.

Status & tagging log