r88785 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88784‎ | r88785 | r88786 >
Date:11:59, 25 May 2011
Author:janpaul123
Status:ok
Tags:
Comment:
Modified paths:
  • /trunk/extensions/WikiLove/WikiLove.php (modified) (history)
  • /trunk/extensions/WikiLove/defaultTypes.js (deleted) (history)
  • /trunk/extensions/WikiLove/images (deleted) (history)
  • /trunk/extensions/WikiLove/jquery.elastic.js (deleted) (history)
  • /trunk/extensions/WikiLove/modules (added) (history)
  • /trunk/extensions/WikiLove/modules/ext.wikiLove (added) (history)
  • /trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js (added) (history)
  • /trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.css (added) (history)
  • /trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.defaultOptions.js (added) (history)
  • /trunk/extensions/WikiLove/modules/ext.wikiLove/images (added) (history)
  • /trunk/extensions/WikiLove/modules/jquery.elastic (added) (history)
  • /trunk/extensions/WikiLove/modules/jquery.elastic/jquery.elastic.js (added) (history)
  • /trunk/extensions/WikiLove/wikiLove.css (deleted) (history)
  • /trunk/extensions/WikiLove/wikiLove.js (deleted) (history)

Diff [purge]

Index: trunk/extensions/WikiLove/wikiLove.css
@@ -1,373 +0,0 @@
2 -/* include fix from r87101 here for older versions; these three blocks can become deprecated later */
3 -div.vectorTabs span {
4 - display: inline-block;
5 - /* @embed */
6 - background-image: url(images/tab-break.png);
7 - background-position: bottom right;
8 - background-repeat: no-repeat;
9 -}
10 -
11 -div.vectorTabs li a {
12 - background-image: none;
13 -}
14 -
15 -#ca-unwatch.icon,
16 -#ca-watch.icon {
17 - margin-right: 0px;
18 -}
19 -
20 -/* icon style */
21 -#ca-wikilove.icon a {
22 - margin: 0;
23 - padding: 0;
24 - outline: none;
25 - display: block;
26 - width: 27px;
27 - /* This hides the text but shows the background image */
28 - padding-top: 3.1em;
29 - margin-top: 0;
30 - /* Only applied in IE6 */
31 - margin-top: -0.8em !ie;
32 - height: 0;
33 - overflow: hidden;
34 - /* @embed */
35 - background-image: url(images/heart-icons.png);
36 -}
37 -#ca-wikilove.icon a {
38 - background-position: 5px 60%;
39 -}
40 -#ca-wikilove.icon a:hover,
41 -#ca-wikilove.icon a:focus {
42 - background-position: -19px 60%;
43 -}
44 -
45 -/* dialog */
46 -#mw-wikilove-dialog {
47 - margin: 10px;
48 -}
49 -
50 -/* dialog type selection */
51 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type {
52 - float: left;
53 - width: 250px;
54 -}
55 -
56 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type ul {
57 - list-style: none;
58 - margin: 0;
59 - padding: 0;
60 -}
61 -
62 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type ul li,
63 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a
64 -{
65 - display: block;
66 - width: 250px;
67 - height: 66px;
68 - padding: 0;
69 - margin: 0;
70 - position: relative;
71 - text-decoration: none;
72 - outline: none;
73 -}
74 -
75 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:hover,
76 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:focus {
77 - text-decoration:none;
78 -}
79 -
80 -/* IGNORED BY IE6 */
81 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type ul > li,
82 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type ul li > a {
83 - display: inline-block;
84 -}
85 -
86 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-left-cap,
87 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-right-cap {
88 - padding: 0;
89 - margin: 0;
90 - width: 6px;
91 - height: 66px;
92 - position: absolute;
93 - top: 0px;
94 -}
95 -
96 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-left-cap,
97 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-right-cap,
98 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-icon-box {
99 - /* @embed */
100 - background-image: url(images/select-sprite.png);
101 - background-repeat: no-repeat;
102 -}
103 -
104 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-left-cap {
105 - /* @noflip */
106 - left: 0px;
107 - background-position: 0px 0px;
108 -}
109 -
110 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:hover .mw-wikilove-left-cap,
111 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:focus .mw-wikilove-left-cap {
112 - background-position: -6px 0px;
113 -}
114 -
115 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a.selected .mw-wikilove-left-cap {
116 - background-position: -12px 0px;
117 -}
118 -
119 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-right-cap {
120 - /* @noflip */
121 - right: 0px;
122 - background-position: -18px 0px;
123 -}
124 -
125 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:hover .mw-wikilove-right-cap,
126 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:focus .mw-wikilove-right-cap {
127 - background-position: -25px 0px;
128 -}
129 -
130 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a.selected .mw-wikilove-right-cap {
131 - background-position: -32px 0px;
132 -}
133 -
134 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-inside {
135 - padding: 0;
136 - margin: 0;
137 - width: 238px;
138 - height: 66px;
139 - position: absolute;
140 - top: 0px;
141 - left: 6px;
142 -
143 - /* @embed */
144 - background-image: url(images/select-bg-sprite.png);
145 - background-position: 0px 0px;
146 - background-repeat: repeat-x;
147 -}
148 -
149 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:hover .mw-wikilove-inside,
150 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:focus .mw-wikilove-inside {
151 - background-position: 0px -66px;
152 -}
153 -
154 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a.selected .mw-wikilove-inside {
155 - background-position: 0px -132px;
156 -}
157 -
158 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-icon-box {
159 - padding: 0;
160 - margin: 0;
161 - width: 53px;
162 - height: 53px;
163 - position: absolute;
164 - left: 0px;
165 - top: 5px;
166 - background-position: -42px 0px;
167 -}
168 -
169 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-icon-box img {
170 - padding: 0;
171 - margin: 0;
172 - width: 53px;
173 - height: 53px;
174 - position: absolute:
175 - top: 0px;
176 - left: 0px;
177 -}
178 -
179 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:hover .mw-wikilove-icon-box,
180 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:focus .mw-wikilove-icon-box {
181 - background-position: -97px 0px;
182 -}
183 -
184 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a.selected .mw-wikilove-icon-box {
185 - background-position: -152px 0px;
186 -}
187 -
188 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-link-text {
189 - padding: 0;
190 - margin: 0;
191 - width: 170px;
192 - height: 53px;
193 - position: absolute;
194 - left: 64px;
195 - top: 5px;
196 - line-height: 53px;
197 - font-size: 1.2em;
198 - font-weight: bold;
199 - text-decoration: none;
200 - color: white;
201 -}
202 -
203 -/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-no-icon .mw-wikilove-link-text {
204 - left: 3px;
205 -}
206 -
207 -/* dialog get started */
208 -/*#mw-wikilove-dialog*/ #mw-wikilove-get-started {
209 - float: right;
210 - width: 380px;
211 - margin-top: 40px;
212 - padding-top: 4px;
213 - padding-left: 70px;
214 - font-size: 1.1em;
215 -
216 - /* @embed */
217 - background-image: url(images/get-started-ltr.png);
218 - background-position: top left;
219 - background-repeat: no-repeat;
220 -}
221 -
222 -/*#mw-wikilove-dialog*/ #mw-wikilove-get-started h2 {
223 - border: none;
224 - font-weight: bold;
225 -}
226 -
227 -/*#mw-wikilove-dialog*/ #mw-wikilove-get-started ol {
228 - margin-left: 1.5em;
229 -}
230 -
231 -/* dialog add details */
232 -/*#mw-wikilove-dialog*/ #mw-wikilove-add-details {
233 - float: right;
234 - width: 480px;
235 - margin-bottom: 5px;
236 -}
237 -
238 -/*#mw-wikilove-dialog*/ #mw-wikilove-add-details label {
239 - font-weight: bold;
240 - font-size: 1.1em;
241 -}
242 -
243 -/*#mw-wikilove-dialog*/ #mw-wikilove-add-details .text {
244 - display: block;
245 - width: 300px;
246 -}
247 -
248 -/*#mw-wikilove-dialog*/ #mw-wikilove-add-details .mw-wikilove-note {
249 - font-weight: light;
250 - font-size: 0.9em;
251 - float: right;
252 - color: #999;
253 -}
254 -
255 -/*#mw-wikilove-dialog*/ #mw-wikilove-add-details textarea {
256 - resize: none;
257 -}
258 -
259 -#mw-wikilove-dialog .mw-wikilove-spinner {
260 - float: right;
261 - margin-top: 0.9em;
262 - display: none;
263 -
264 - /* @embed */
265 - background-image: url(images/spinner.gif);
266 - background-position: 0px 0px;
267 - background-repeat: repeat-x;
268 - width: 16px;
269 - height: 16px;
270 -}
271 -
272 -/* add details gallery */
273 -/*#mw-wikilove-dialog*/ #mw-wikilove-gallery {
274 - min-height: 40px;
275 - position: relative;
276 -}
277 -
278 -/*#mw-wikilove-dialog*/ #mw-wikilove-gallery img {
279 - margin-right: 5px;
280 - margin-bottom: 5px;
281 - padding: 5px;
282 -}
283 -
284 -/*#mw-wikilove-dialog*/ #mw-wikilove-gallery a:hover img,
285 -/*#mw-wikilove-dialog*/ #mw-wikilove-gallery a:focus img {
286 - background-color: #aacfe9;
287 -}
288 -
289 -/*#mw-wikilove-dialog*/ #mw-wikilove-gallery a.selected img {
290 - background-color: #f56427;
291 -}
292 -
293 -/*#mw-wikilove-dialog*/ #mw-wikilove-gallery-spinner {
294 - float: none;
295 - position: absolute;
296 - top: 0;
297 - left: 50%;
298 - margin-left: -8px;
299 - z-index: -1;
300 -}
301 -
302 -/* dialog preview */
303 -/*#mw-wikilove-dialog*/ #mw-wikilove-preview {
304 - float: right;
305 - width: 480px;
306 -}
307 -
308 -/*#mw-wikilove-dialog #mw-wikilove-preview*/ #mw-wikilove-preview-area {
309 - margin-left: 15px;
310 - width: 465px;
311 - overflow: auto;
312 -}
313 -
314 -/*#mw-wikilove-dialog #mw-wikilove-preview*/ #mw-wikilove-preview-area .editsection {
315 - display: none;
316 -}
317 -
318 -/* dialog misc */
319 -#mw-wikilove-dialog input[type=text],
320 -#mw-wikilove-dialog textarea,
321 -#mw-wikilove-dialog select {
322 - margin: 5px 0px 5px 15px;
323 - max-width: 460px;
324 - display: block;
325 -}
326 -
327 -/*#mw-wikilove-dialog*/ #wlSubtypeDescription {
328 - margin: 5px 0px 8px 15px;
329 - font-size: 1.0em;
330 - line-height: 1.2em;
331 -}
332 -
333 -#mw-wikilove-dialog input[type=checkbox] {
334 - display:inline-box;
335 - margin: 5px 0px 5px 0px;
336 -}
337 -
338 -#mw-wikilove-dialog select {
339 - padding: 1px 0;
340 -}
341 -
342 -#mw-wikilove-dialog .submit {
343 - float: right;
344 -}
345 -
346 -#mw-wikilove-dialog .mw-wikilove-number {
347 - color: white;
348 - float: left;
349 - display: block;
350 - width: 32px;
351 - height: 32px;
352 - line-height: 32px;
353 - text-align: center;
354 - margin-right: 5px;
355 - font-size: 1.5em;
356 - font-weight: bold;
357 -
358 - /* @embed */
359 - background-image: url(images/number.png);
360 - background-position: center;
361 - background-repeat: no-repeat;
362 -}
363 -
364 -#mw-wikilove-dialog .mw-wikilove-error {
365 - /* @embed */
366 - background-image: url(images/alert.png);
367 - background-position: center left;
368 - background-repeat: no-repeat;
369 - color: red;
370 - font-weight: bold;
371 - line-height: 32px;
372 - padding-left: 34px;
373 - padding-bottom: 3px;
374 -}
Index: trunk/extensions/WikiLove/defaultTypes.js
@@ -1,68 +0,0 @@
2 -$.wikiLove.types = {
3 - // example type, could be removed later (also no i18n)
4 - 'barnstar': {
5 - name: 'Barnstar', // name of the type (appears in the types menu)
6 - select: 'Select a barnstar:', // subtype select label
7 - subtypes: { // some different subtypes
8 - // note that when not using subtypes you should use these subtype options
9 - // for the top-level type
10 - 'original': {
11 - fields: [ 'notify' ], // fields to ask for in form
12 - option: 'Original barnstar', // option listed in the select list
13 - descr: 'This barnstar is given to recognize particularly fine contributions to Wikipedia, to let people know that their hard work is seen and appreciated.', // description
14 - header: 'A barnstar for you!', // header that appears at the top of the talk page post (optional)
15 - title: 'The Original Barnstar', // title that appears inside the award box (optional)
16 - image: 'Original Barnstar Hires.png', // image for the award
17 - mail: 'Hello $7!\n\nI just awarded you a barnstar.' // message to use in email notification; $7 is replaced by the recipient's username
18 - },
19 - 'editors': {
20 - fields: [ 'notify' ],
21 - option: 'Editor\'s barnstar',
22 - descr: 'The Editor\'s Barnstar is awarded to individuals who display particularly fine decisions in general editing.',
23 - header: 'A barnstar for you!',
24 - title: 'The Editor\'s Barnstar',
25 - image: 'Editors Barnstar Hires.png',
26 - mail: 'Hello $7!\n\nI just awarded you a barnstar.'
27 - },
28 - 'tireless': {
29 - fields: [ 'title', 'notify' ],
30 - option: 'Tireless contributor barnstar',
31 - descr: 'The Tireless Contributor Barnstar is awarded to especially tireless Wikipedians who contribute an especially large body of work without sacrificing quality.',
32 - header: 'A barnstar for you!',
33 - title: 'Tireless contributor barnstar',
34 - image: 'Tireless Contributor Barnstar Hires.gif',
35 - mail: 'Hello $7!\n\nI just awarded you a barnstar.'
36 - }
37 - },
38 - icon: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/extensions/WikiLove/images/icons/wikilove-icon-barnstar.png' // icon for left-side menu
39 - },
40 - 'puppy': {
41 - name: 'Puppy',
42 - fields: [ 'header' ],
43 - header: 'A puppy for you!',
44 - text: '[[$3|left|150px]]\n$1\n\n~~~~\n<br style="clear: both"/>', // custom text
45 - gallery: {
46 - // right now we can only query the local wiki (not e.g. commons)
47 - category: 'Category:Puppies',
48 - total: 100, // total number of pictures to retrieve, and to randomise
49 - num: 3, // number of pictures to show from the randomised set
50 - width: 145 // width of each picture in pixels in the interface (not in the template)
51 - }
52 - },
53 - 'kitten': {
54 - name: 'Kitten',
55 - fields: [ 'header' ],
56 - header: 'A kitten for you!',
57 - text: '[[$3|left|150px]]\n$1\n\n~~~~\n<br style="clear: both"/>', // $3 is the image filename
58 - gallery: {
59 - imageList: ['File:Cucciolo gatto Bibo.jpg','File:Kitten (06) by Ron.jpg','File:Kitten-stare.jpg'],
60 - width: 145
61 - }
62 - },
63 - // default type, nice to leave this one in place when adding other types
64 - 'makeyourown': {
65 - name: mw.msg( 'wikilove-type-makeyourown' ),
66 - fields: [ 'header', 'title', 'image', 'notify' ],
67 - imageSize: '150px'
68 - }
69 -}
\ No newline at end of file
Index: trunk/extensions/WikiLove/wikiLove.js
@@ -1,596 +0,0 @@
2 -( function( $ ) { $.wikiLove = {
3 -
4 - $dialog: null, // dialog jQuery object
5 - currentTypeId: null, // id of the currently selected type (e.g. 'barnstar' or 'makeyourown')
6 - currentSubtypeId: null, // id of the currently selected subtype (e.g. 'original' or 'special')
7 - currentTypeOrSubtype: null, // content of the current (sub)type (i.e. an object with title, descr, text, etc.)
8 - previewData: null, // data of the currently previewed thing is set here
9 - emailable: false,
10 - gallery: {},
11 - defaultText: '{| style="background-color: $5; border: 1px solid $6;"\n\
12 -|rowspan="2" style="vertical-align: middle; padding: 5px;" | [[Image:$3|$4]]\n\
13 -|style="font-size: x-large; padding: 3px; height: 1.5em;" | \'\'\'$2\'\'\'\n\
14 -|-\n\
15 -|style="vertical-align: middle; padding: 3px;" | $1 ~~~~\n\
16 -|}',
17 - defaultBackgroundColor: '#fdffe7',
18 - defaultBorderColor: '#fceb92',
19 - defaultImageSize: '100px',
20 -
21 - /*
22 - * Opens the dialog and builds it if necessary.
23 - */
24 - openDialog: function() {
25 - if ( $.wikiLove.$dialog === null ) {
26 - // Load local configuration
27 - var wikiLoveConfigUrl = wgServer + wgScript + '?' + $.param( { 'title': 'MediaWiki:WikiLove.js', 'action': 'raw', 'ctype': 'text/javascript' } );
28 - mw.loader.load( wikiLoveConfigUrl );
29 -
30 - // Test to see if the 'E-mail this user' link exists
31 - $.wikiLove.emailable = $( '#t-emailuser' ).length ? true : false;
32 -
33 - // Build a type list like this:
34 - var $typeList = $( '<ul id="mw-wikilove-types"></ul>' );
35 - for( var typeId in $.wikiLove.types ) {
36 - var $button = $( '<a href="#"></a>' );
37 - var $buttonInside = $( '<div class="mw-wikilove-inside"></div>' );
38 -
39 - if( typeof $.wikiLove.types[typeId].icon == 'string' ) {
40 - $buttonInside.append( '<div class="mw-wikilove-icon-box"><img src="'
41 - + mw.html.escape( $.wikiLove.types[typeId].icon ) + '"/></div>' );
42 - }
43 - else {
44 - $buttonInside.addClass( 'mw-wikilove-no-icon' );
45 - }
46 -
47 - $buttonInside.append( '<div class="mw-wikilove-link-text">' + $.wikiLove.types[typeId].name + '</div>' );
48 -
49 - $button.append( '<div class="mw-wikilove-left-cap"></div>');
50 - $button.append( $buttonInside );
51 - $button.append( '<div class="mw-wikilove-right-cap"></div>');
52 - $button.data( 'typeId', typeId );
53 - $typeList.append( $( '<li tabindex="0"></li>' ).append( $button ) );
54 - }
55 -
56 - $.wikiLove.$dialog = $( '\
57 -<div id="mw-wikilove-dialog">\
58 -<div id="mw-wikilove-select-type">\
59 - <span class="mw-wikilove-number">1</span>\
60 - <h3><html:msg key="wikilove-select-type"/></h3>\
61 - <ul id="mw-wikilove-types"></ul>\
62 -</div>\
63 -<div id="mw-wikilove-get-started">\
64 - <h2><html:msg key="wikilove-get-started-header"/></h2>\
65 - <ol>\
66 - <li><html:msg key="wikilove-get-started-list-1"/></li>\
67 - <li><html:msg key="wikilove-get-started-list-2"/></li>\
68 - <li><html:msg key="wikilove-get-started-list-3"/></li>\
69 - </ol>\
70 -</div>\
71 -<div id="mw-wikilove-add-details">\
72 - <span class="mw-wikilove-number">2</span>\
73 - <h3><html:msg key="wikilove-add-details"/></h3>\
74 - <form id="mw-wikilove-preview-form">\
75 - <label for="mw-wikilove-subtype" id="mw-wikilove-subtype-label"></label>\
76 - <select id="mw-wikilove-subtype"></select>\
77 - <div id="mw-wikilove-subtype-description"></div>\
78 - <label id="mw-wikilove-gallery-label"><html:msg key="wikilove-image"/></label>\
79 - <div id="mw-wikilove-gallery">\
80 - <div id="mw-wikilove-gallery-spinner" class="mw-wikilove-spinner"></div>\
81 - <div id="mw-wikilove-gallery-content"></div>\
82 - </div>\
83 - <label for="mw-wikilove-header" id="mw-wikilove-header-label"><html:msg key="wikilove-header"/></label>\
84 - <input type="text" class="text" id="mw-wikilove-header"/>\
85 - <label for="mw-wikilove-title" id="mw-wikilove-title-label"><html:msg key="wikilove-title"/></label>\
86 - <input type="text" class="text" id="mw-wikilove-title"/>\
87 - <label for="mw-wikilove-image" id="mw-wikilove-image-label"><html:msg key="wikilove-image"/></label>\
88 - <input type="text" class="text" id="mw-wikilove-image"/>\
89 - <label for="mw-wikilove-message" id="mw-wikilove-message-label"><html:msg key="wikilove-enter-message"/></label>\
90 - <span class="mw-wikilove-note"><html:msg key="wikilove-omit-sig"/></span>\
91 - <textarea id="mw-wikilove-message"></textarea>\
92 - <div id="mw-wikilove-notify">\
93 - <input type="checkbox" id="mw-wikilove-notify-checkbox" name="notify"/>\
94 - <label for="mw-wikilove-notify-checkbox"><html:msg key="wikilove-notify"/></label>\
95 - </div>\
96 - <button class="submit" id="mw-wikilove-button-preview" type="submit"></button>\
97 - <div id="mw-wikilove-preview-spinner" class="mw-wikilove-spinner"></div>\
98 - </form>\
99 -</div>\
100 -<div id="mw-wikilove-preview">\
101 - <span class="mw-wikilove-number">3</span>\
102 - <h3><html:msg key="wikilove-preview"/></h3>\
103 - <div id="mw-wikilove-preview-area"></div>\
104 - <form id="mw-wikilove-send-form">\
105 - <button class="submit" id="mw-wikilove-button-send" type="submit"></button>\
106 - <div id="mw-wikilove-send-spinner" class="mw-wikilove-spinner"></div>\
107 - </form>\
108 -</div>\
109 -</div>' );
110 - $.wikiLove.$dialog.localize();
111 -
112 - $.wikiLove.$dialog.dialog({
113 - width: 800,
114 - position: ['center', 80],
115 - autoOpen: false,
116 - title: mw.msg( 'wikilove-dialog-title' ),
117 - modal: true,
118 - resizable: false
119 - });
120 -
121 - $( '#mw-wikilove-button-preview' ).button( { label: mw.msg( 'wikilove-button-preview' ), icons: { primary:'ui-icon-search' } } );
122 - $( '#mw-wikilove-button-send' ).button( { label: mw.msg( 'wikilove-button-send' ) } );
123 - $( '#mw-wikilove-add-details' ).hide();
124 - $( '#mw-wikilove-preview' ).hide();
125 - $( '#mw-wikilove-types' ).replaceWith( $typeList );
126 -
127 - $( '#mw-wikilove-types a' ).click( $.wikiLove.clickType );
128 - $( '#mw-wikilove-subtype' ).change( $.wikiLove.changeSubtype );
129 - $( '#mw-wikilove-preview-form' ).submit( $.wikiLove.submitPreview );
130 - $( '#mw-wikilove-send-form' ).click( $.wikiLove.submitSend );
131 - $( '#mw-wikilove-message' ).elastic(); // have the message textarea grow automatically
132 - }
133 -
134 - $.wikiLove.$dialog.dialog( 'open' );
135 - },
136 -
137 - /*
138 - * Handler for the left menu. Selects a new type and initialises next section
139 - * depending on whether or not to show subtypes.
140 - */
141 - clickType: function( e ) {
142 - e.preventDefault();
143 - $( '#mw-wikilove-get-started' ).hide(); // always hide the get started section
144 -
145 - var newTypeId = $( this ).data( 'typeId' );
146 - if( $.wikiLove.currentTypeId != newTypeId ) { // only do stuff when a different type is selected
147 - $.wikiLove.currentTypeId = newTypeId;
148 - $.wikiLove.currentSubtypeId = null; // reset the subtype id
149 -
150 - $( '#mw-wikilove-types a' ).removeClass( 'selected' );
151 - $( this ).addClass( 'selected' ); // highlight the new type in the menu
152 -
153 - if( typeof $.wikiLove.types[$.wikiLove.currentTypeId].subtypes == 'object' ) {
154 - // we're dealing with subtypes here
155 - $.wikiLove.currentTypeOrSubtype = null; // reset the (sub)type object until a subtype is selected
156 - $( '#mw-wikilove-subtype' ).html( '' ); // clear the subtype menu
157 -
158 - for( var subtypeId in $.wikiLove.types[$.wikiLove.currentTypeId].subtypes ) {
159 - // add all the subtypes to the menu while setting their subtype ids in jQuery data
160 - var subtype = $.wikiLove.types[$.wikiLove.currentTypeId].subtypes[subtypeId];
161 - $( '#mw-wikilove-subtype' ).append(
162 - $( '<option></option>' ).text( subtype.option ).data( 'subtypeId', subtypeId )
163 - );
164 - }
165 - $( '#mw-wikilove-subtype' ).show();
166 -
167 - // change and show the subtype label depending on the type
168 - $( '#mw-wikilove-subtype-label' ).text( $.wikiLove.types[$.wikiLove.currentTypeId].select || mw.msg( 'wikilove-select-type' ) );
169 - $( '#mw-wikilove-subtype-label' ).show();
170 - $.wikiLove.changeSubtype(); // update controls depending on the currently selected (i.e. first) subtype
171 - }
172 - else {
173 - // there are no subtypes, just use this type for the current (sub)type
174 - $.wikiLove.currentTypeOrSubtype = $.wikiLove.types[$.wikiLove.currentTypeId];
175 - $( '#mw-wikilove-subtype' ).hide();
176 - $( '#mw-wikilove-subtype-label' ).hide();
177 - $.wikiLove.updateAllDetails(); // update controls depending on this type
178 - }
179 -
180 - $( '#mw-wikilove-add-details' ).show();
181 - $( '#mw-wikilove-preview' ).hide();
182 - $.wikiLove.previewData = null;
183 - }
184 - },
185 -
186 - /*
187 - * Handler for changing the subtype.
188 - */
189 - changeSubtype: function() {
190 - // find out which subtype is selected
191 - var newSubtypeId = $( '#mw-wikilove-subtype option:selected' ).first().data( 'subtypeId' );
192 - if( $.wikiLove.currentSubtypeId != newSubtypeId ) { // only change stuff when a different subtype is selected
193 - $.wikiLove.currentSubtypeId = newSubtypeId;
194 - $.wikiLove.currentTypeOrSubtype = $.wikiLove.types[$.wikiLove.currentTypeId]
195 - .subtypes[$.wikiLove.currentSubtypeId];
196 - $( '#mw-wikilove-subtype-description' ).html( $.wikiLove.currentTypeOrSubtype.descr );
197 - $.wikiLove.updateAllDetails();
198 - $( '#mw-wikilove-preview' ).hide();
199 - $.wikiLove.previewData = null;
200 - }
201 - },
202 -
203 - /*
204 - * Called when type or subtype changes, updates controls.
205 - */
206 - updateAllDetails: function() {
207 - $( '#wikiLoveDialog' ).find( '.mw-wikilove-error' ).remove();
208 -
209 - // only show the description if it exists for this type or subtype
210 - if( typeof $.wikiLove.currentTypeOrSubtype.descr == 'string' ) {
211 - $( '#mw-wikilove-subtype-description').show();
212 - } else {
213 - $( '#mw-wikilove-subtype-description').hide();
214 - }
215 -
216 - // show or hide header label and textbox depending on whether a predefined header exists
217 - if( $.inArray( 'header', $.wikiLove.currentTypeOrSubtype.fields ) >= 0 ) {
218 - $( '#mw-wikilove-header-label').show();
219 - $( '#mw-wikilove-header' ).show();
220 - } else {
221 - $( '#mw-wikilove-header-label').hide();
222 - $( '#mw-wikilove-header' ).hide();
223 - }
224 - $( '#mw-wikilove-header' ).val( $.wikiLove.currentTypeOrSubtype.header || '' );
225 -
226 - // show or hide title label and textbox depending on whether a predefined title exists
227 - if( $.inArray( 'title', $.wikiLove.currentTypeOrSubtype.fields ) >= 0 ) {
228 - $( '#mw-wikilove-title-label').show();
229 - $( '#mw-wikilove-title' ).show();
230 - } else {
231 - $( '#mw-wikilove-title-label').hide();
232 - $( '#mw-wikilove-title' ).hide();
233 - }
234 - $( '#mw-wikilove-title' ).val( $.wikiLove.currentTypeOrSubtype.title || '' );
235 -
236 - // show or hide image label and textbox depending on whether a predefined image exists
237 - if( $.inArray( 'image', $.wikiLove.currentTypeOrSubtype.fields ) >= 0 ) {
238 - $( '#mw-wikilove-image-label').show();
239 - $( '#mw-wikilove-image' ).show();
240 - } else {
241 - $( '#mw-wikilove-image-label').hide();
242 - $( '#mw-wikilove-image' ).hide();
243 - }
244 - $( '#mw-wikilove-image' ).val( $.wikiLove.currentTypeOrSubtype.image || '' );
245 -
246 - if( typeof $.wikiLove.currentTypeOrSubtype.gallery == 'object' ) {
247 - if( $.wikiLove.currentTypeOrSubtype.gallery.imageList instanceof Array) {
248 - $( '#mw-wikilove-gallery-label' ).show();
249 - $( '#mw-wikilove-gallery' ).show();
250 - $.wikiLove.showGallery(); // build gallery from array of images
251 - } else {
252 - // gallery is a category
253 - $( '#mw-wikilove-gallery-label' ).show();
254 - $( '#mw-wikilove-gallery' ).show();
255 - $.wikiLove.makeGallery(); // build gallery from category
256 - }
257 - }
258 - else {
259 - $( '#mw-wikilove-gallery-label' ).hide();
260 - $( '#mw-wikilove-gallery' ).hide();
261 - }
262 -
263 - if( $.inArray( 'notify', $.wikiLove.currentTypeOrSubtype.fields ) >= 0 && $.wikiLove.emailable ) {
264 - $( '#mw-wikilove-notify' ).show();
265 - } else {
266 - $( '#mw-wikilove-notify' ).hide();
267 - $( '#mw-wikilove-notify-checkbox' ).attr('checked', false);
268 - }
269 - },
270 -
271 - /*
272 - * Handler for clicking the preview button. Builds data for AJAX request.
273 - */
274 - submitPreview: function( e ) {
275 - e.preventDefault();
276 - $( '#mw-wikilove-preview' ).hide();
277 - $( '#wikiLoveDialog' ).find( '.wlError' ).remove();
278 -
279 - if( typeof $.wikiLove.currentTypeOrSubtype.gallery == 'object' ) {
280 - if ( $( '#mw-wikilove-image' ).val().length <= 0 ) {
281 - $.wikiLove.showError( 'wikilove-err-image' ); return false;
282 - }
283 - }
284 - if( $( '#mw-wikilove-header' ).val().length <= 0 ) {
285 - $.wikiLove.showError( 'wikilove-err-header' ); return false;
286 - }
287 - if( $( '#mw-wikilove-message' ).val().length <= 0 ) {
288 - $.wikiLove.showError( 'wikilove-err-msg' ); return false;
289 - }
290 -
291 - // If there isn't a signature already in the message, throw an error
292 - if ( $( '#mw-wikilove-message' ).val().indexOf( '~~~' ) >= 0 ) {
293 - $.wikiLove.showError( 'wikilove-err-sig' ); return false;
294 - }
295 -
296 - var msg = $.wikiLove.prepareMsg(
297 - $.wikiLove.currentTypeOrSubtype.text || $.wikiLove.defaultText,
298 - $.wikiLove.currentTypeOrSubtype.imageSize,
299 - $.wikiLove.currentTypeOrSubtype.backgroundColor,
300 - $.wikiLove.currentTypeOrSubtype.borderColor
301 - );
302 -
303 - $.wikiLove.doPreview( '==' + $( '#mw-wikilove-header' ).val() + "==\n" + msg );
304 - $.wikiLove.previewData = {
305 - 'header': $( '#mw-wikilove-header' ).val(),
306 - 'msg': msg,
307 - 'type': $.wikiLove.currentTypeId
308 - + ($.wikiLove.currentSubtypeId !== null ? '-' + $.wikiLove.currentSubtypeId : '')
309 - };
310 -
311 - if ( $( '#mw-wikilove-notify-checkbox:checked' ).val() && $.wikiLove.emailable ) {
312 - $.wikiLove.previewData.mail = $.wikiLove.prepareMsg( $.wikiLove.currentTypeOrSubtype.mail );
313 - }
314 - },
315 -
316 - showError: function( errmsg ) {
317 - $( '#mw-wikilove-add-details' ).append( $( '<div class="mw-wikilove-error"></div>' ).text( mw.msg( errmsg ) ) );
318 - },
319 -
320 - /*
321 - * Prepares a message or e-mail body by replacing placeholders.
322 - * $1: message entered by the user
323 - * $2: title of the item
324 - * $3: title of the image
325 - * $4: image size
326 - * $5: background color
327 - * $6: border color
328 - * $7: username of the recipient
329 - */
330 - prepareMsg: function( msg, imageSize, backgroundColor, borderColor ) {
331 -
332 - msg = msg.replace( '$1', $( '#mw-wikilove-message' ).val() ); // replace the raw message
333 - msg = msg.replace( '$2', $( '#mw-wikilove-title' ).val() ); // replace the title
334 - msg = msg.replace( '$3', $( '#mw-wikilove-image' ).val() ); // replace the image
335 -
336 - var myImageSize = imageSize || $.wikiLove.defaultImageSize;
337 - var myBackgroundColor = backgroundColor || $.wikiLove.defaultBackgroundColor;
338 - var myBorderColor = borderColor || $.wikiLove.defaultBorderColor;
339 -
340 - msg = msg.replace( '$4', myImageSize ); // replace the image size
341 - msg = msg.replace( '$5', myBackgroundColor ); // replace the background color
342 - msg = msg.replace( '$6', myBorderColor ); // replace the border color
343 -
344 - msg = msg.replace( '$7', wgTitle ); // replace the username we're sending to
345 -
346 - return msg;
347 - },
348 -
349 - /*
350 - * Fires AJAX request for previewing wikitext.
351 - */
352 - doPreview: function( wikitext ) {
353 - $( '#mw-wikilove-preview-spinner' ).fadeIn( 200 );
354 - $.ajax({
355 - url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php?',
356 - data: {
357 - 'action': 'parse',
358 - 'format': 'json',
359 - 'text': wikitext,
360 - 'prop': 'text',
361 - 'pst': true
362 - },
363 - dataType: 'json',
364 - type: 'POST',
365 - success: function( data ) {
366 - $.wikiLove.showPreview( data.parse.text['*'] );
367 - $( '#mw-wikilove-preview-spinner' ).fadeOut( 200 );
368 - }
369 - });
370 - },
371 -
372 - /*
373 - * Callback for the preview function. Sets the preview area with the HTML and fades it in.
374 - */
375 - showPreview: function( html ) {
376 - $( '#mw-wikilove-preview-area' ).html( html );
377 - $( '#mw-wikilove-preview' ).fadeIn( 200 );
378 - },
379 -
380 - /*
381 - * Handler for the send (final submit) button. Builds data for AJAX request.
382 - * The type sent for statistics is 'typeId-subtypeId' when using subtypes,
383 - * or simply 'typeId' otherwise.
384 - */
385 - submitSend: function( e ) {
386 - e.preventDefault();
387 - $.wikiLove.doSend( $.wikiLove.previewData.header, $.wikiLove.previewData.msg,
388 - $.wikiLove.previewData.type, $.wikiLove.previewData.notify );
389 - },
390 -
391 - /*
392 - * Fires the final AJAX request and then redirects to the talk page where the content is added.
393 - */
394 - doSend: function( subject, wikitext, type, mail ) {
395 - $( '#mw-wikilove-send-spinner' ).fadeIn( 200 );
396 -
397 - var sendData = {
398 - 'action': 'wikilove',
399 - 'format': 'json',
400 - 'title': mw.config.get( 'wgPageName' ),
401 - 'type': type,
402 - 'text': wikitext,
403 - 'subject': subject,
404 - 'token': mw.user.tokens.get( 'editToken' )
405 - };
406 -
407 - if ( mail ) {
408 - sendData.email = mail;
409 - }
410 -
411 - $.ajax({
412 - url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php?',
413 - data: sendData,
414 - dataType: 'json',
415 - type: 'POST',
416 - success: function( data ) {
417 - $( '#mw-wikilove-send-spinner' ).fadeOut( 200 );
418 -
419 - if ( typeof data.error !== 'undefined' ) {
420 - $( '#mw-wikilove-preview' ).append( '<div class="wlError">' + mw.html.escape( data.error.info ) + '<div>' );
421 - return;
422 - }
423 -
424 - if ( typeof data.redirect !== 'undefined'
425 - && data.redirect.pageName == mw.config.get( 'wgPageName' ) ) {
426 - // unfortunately, when on the talk page we cannot reload and then
427 - // jump to the correct section, because when we set the hash (#...)
428 - // the page won't reload...
429 - window.location.reload();
430 - }
431 - else {
432 - window.location = mw.util.wikiUrlencode(
433 - mw.config.get( 'wgArticlePath' ).replace( '$1', data.redirect.pageName )
434 - + '#' + data.redirect.fragment );
435 - }
436 - }
437 - });
438 - },
439 -
440 - /*
441 - * This function is called if the gallery is an array of images. It retrieves the image
442 - * thumbnails from the API, and constructs a thumbnail gallery with them.
443 - */
444 - showGallery: function() {
445 - $( '#mw-wikilove-gallery-content' ).html( '' );
446 - $.wikiLove.gallery = {};
447 - $( '#mw-wikilove-gallery-spinner' ).fadeIn( 200 );
448 -
449 - $.each( $.wikiLove.currentTypeOrSubtype.gallery.imageList, function(index, value) {
450 -
451 - $.ajax({
452 - url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php',
453 - data: {
454 - 'action' : 'query',
455 - 'format' : 'json',
456 - 'prop' : 'imageinfo',
457 - 'iiprop' : 'mime|url',
458 - 'titles' : value,
459 - 'iiurlwidth' : $.wikiLove.currentTypeOrSubtype.gallery.width
460 - },
461 - dataType: 'json',
462 - type: 'POST',
463 - success: function( data ) {
464 - $( '#mw-wikilove-gallery-spinner' ).fadeOut( 200 );
465 -
466 - if ( !data || !data.query || !data.query.pages ) {
467 - return;
468 - }
469 - $.each( data.query.pages, function( id, page ) {
470 - if ( page.imageinfo && page.imageinfo.length ) {
471 - // build an image tag with the correct url and width
472 - $img = $( '<img/>' )
473 - .attr( 'src', page.imageinfo[0].thumburl )
474 - .attr( 'width', $.wikiLove.currentTypeOrSubtype.gallery.width )
475 - .hide()
476 - .load( function() { $( this ).css( 'display', 'inline-block' ); } );
477 - $( '#mw-wikilove-gallery-content' ).append(
478 - $( '<a href="#"></a>' )
479 - .attr( 'id', 'mw-wikilove-gallery-img-' + index )
480 - .append( $img )
481 - .click( function( e ) {
482 - e.preventDefault();
483 - $( '#mw-wikilove-gallery a' ).removeClass( 'selected' );
484 - $( this ).addClass( 'selected' );
485 - $( '#mw-wikilove-image' ).val( $.wikiLove.gallery[$( this ).attr( 'id' )] );
486 - })
487 - );
488 - $.wikiLove.gallery['mw-wikilove-gallery-img-' + index] = page.title;
489 - }
490 - } );
491 - }
492 - });
493 -
494 - });
495 - },
496 -
497 - /*
498 - * This is a bit of a hack to show some random images. A predefined set of image infos are
499 - * retrieved using the API. Then we randomise this set ourselves and select some images to
500 - * show. Eventually we probably want to make a custom API call that does this properly and
501 - * also allows for using remote galleries such as Commons, which is now prohibited by JS.
502 - */
503 - makeGallery: function() {
504 - $( '#mw-wikilove-gallery-content' ).html( '' );
505 - $.wikiLove.gallery = {};
506 - $( '#mw-wikilove-gallery-spinner' ).fadeIn( 200 );
507 -
508 - $.ajax({
509 - url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php',
510 - data: {
511 - 'action' : 'query',
512 - 'format' : 'json',
513 - 'prop' : 'imageinfo',
514 - 'iiprop' : 'mime|url',
515 - 'iiurlwidth' : $.wikiLove.currentTypeOrSubtype.gallery.width,
516 - 'generator' : 'categorymembers',
517 - 'gcmtitle' : $.wikiLove.currentTypeOrSubtype.gallery.category,
518 - 'gcmnamespace': 6,
519 - 'gcmsort' : 'timestamp',
520 - 'gcmlimit' : $.wikiLove.currentTypeOrSubtype.gallery.total
521 - },
522 - dataType: 'json',
523 - type: 'POST',
524 - success: function( data ) {
525 - // clear
526 - $( '#mw-wikilove-gallery-content' ).html( '' );
527 - $.wikiLove.gallery = {};
528 -
529 - // if we have any images at all
530 - if( data.query) {
531 - // get the page keys which are just ids
532 - var keys = Object.keys( data.query.pages );
533 -
534 - // try to find "num" images to show
535 - for( var i=0; i<$.wikiLove.currentTypeOrSubtype.gallery.num; i++ ) {
536 - // continue looking for a new image until we have found one thats valid
537 - // or until we run out of images
538 - while( keys.length > 0 ) {
539 - // get a random page
540 - var id = Math.floor( Math.random() * keys.length );
541 - var page = data.query.pages[keys[id]];
542 -
543 - // remove the random page from the keys array
544 - keys.splice(id, 1);
545 -
546 - // only add the image if it's actually an image
547 - if( page.imageinfo[0].mime.substr(0,5) == 'image' ) {
548 - // build an image tag with the correct url and width
549 - var $img = $( '<img/>' )
550 - .attr( 'src', page.imageinfo[0].url )
551 - .attr( 'width', $.wikiLove.currentTypeOrSubtype.gallery.width )
552 - .hide()
553 - .load( function() { $( this ).css( 'display', 'inline-block' ); } );
554 -
555 - // append the image to the gallery and also make sure it's selectable
556 - $( '#mw-wikilove-gallery-content' ).append(
557 - $( '<a href="#"></a>' )
558 - .attr( 'id', 'mw-wikilove-gallery-img-' + i )
559 - .append( $img )
560 - .click( function( e ) {
561 - e.preventDefault();
562 - $( '#mw-wikilove-gallery a' ).removeClass( 'selected' );
563 - $( this ).addClass( 'selected' );
564 - $( '#mw-wikilove-image' ).val( $.wikiLove.gallery[$( this ).attr( 'id' )] );
565 - })
566 - );
567 -
568 - // save the page title into an array so we know which image id maps to which title
569 - $.wikiLove.gallery['mw-wikilove-gallery-img-' + i] = page.title;
570 - break;
571 - }
572 - }
573 - }
574 - }
575 - if( $.wikiLove.gallery.length <= 0 ) {
576 - $( '#mw-wikilove-gallery' ).hide();
577 - $( '#mw-wikilove-gallery-label' ).hide();
578 - }
579 -
580 - $( '#mw-wikilove-gallery-spinner' ).fadeOut( 200 );
581 - }
582 - });
583 - },
584 -
585 - /*
586 - * Init function which is called upon page load. Binds the WikiLove icon to opening the dialog.
587 - */
588 - init: function() {
589 - $( '#ca-wikilove a' ).click( function( e ) {
590 - $.wikiLove.openDialog();
591 - e.preventDefault();
592 - });
593 - }
594 -};
595 -
596 -$( document ).ready( $.wikiLove.init );
597 -} ) ( jQuery );
Index: trunk/extensions/WikiLove/jquery.elastic.js
@@ -1,133 +0,0 @@
2 -/**
3 -* @name Elastic
4 -* @descripton Elastic is jQuery plugin that grow and shrink your textareas automatically
5 -* @version 1.6.5
6 -* @requires jQuery 1.2.6+
7 -*
8 -* @author Jan Jarfalk
9 -* @author-email jan.jarfalk@unwrongest.com
10 -* @author-website http://www.unwrongest.com
11 -*
12 -* @licence MIT License - http://www.opensource.org/licenses/mit-license.php
13 -*
14 -* This file has been downloaded from http://unwrongest.com/projects/elastic/, please notify the author of
15 -* any changes.
16 -*/
17 -
18 -(function(jQuery){
19 - jQuery.fn.extend({
20 - elastic: function() {
21 -
22 - // We will create a div clone of the textarea
23 - // by copying these attributes from the textarea to the div.
24 - var mimics = [
25 - 'paddingTop',
26 - 'paddingRight',
27 - 'paddingBottom',
28 - 'paddingLeft',
29 - 'fontSize',
30 - 'lineHeight',
31 - 'fontFamily',
32 - 'width',
33 - 'fontWeight'];
34 -
35 - return this.each( function() {
36 -
37 - // Elastic only works on textareas
38 - if ( this.type != 'textarea' ) {
39 - return false;
40 - }
41 -
42 - var $textarea = jQuery(this),
43 - $twin = jQuery('<div />').css({'position': 'absolute','display':'none','word-wrap':'break-word'}),
44 - lineHeight = parseInt($textarea.css('line-height'),10) || parseInt($textarea.css('font-size'),'10'),
45 - minheight = parseInt($textarea.css('height'),10) || lineHeight*3,
46 - maxheight = parseInt($textarea.css('max-height'),10) || Number.MAX_VALUE,
47 - goalheight = 0;
48 -
49 - // Opera returns max-height of -1 if not set
50 - if (maxheight < 0) { maxheight = Number.MAX_VALUE; }
51 -
52 - // Append the twin to the DOM
53 - // We are going to meassure the height of this, not the textarea.
54 - $twin.appendTo($textarea.parent());
55 -
56 - // Copy the essential styles (mimics) from the textarea to the twin
57 - var i = mimics.length;
58 - while(i--){
59 - $twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString()));
60 - }
61 -
62 -
63 - // Sets a given height and overflow state on the textarea
64 - function setHeightAndOverflow(height, overflow){
65 - var curratedHeight = Math.floor(parseInt(height,10));
66 - if($textarea.height() != curratedHeight){
67 - $textarea.css({'height': curratedHeight + 'px','overflow':overflow});
68 - }
69 - }
70 -
71 -
72 - // This function will update the height of the textarea if necessary
73 - function update() {
74 -
75 - // Get curated content from the textarea.
76 - var textareaContent = $textarea.val().replace(/&/g,'&amp;').replace(/ {2}/g, '&nbsp;').replace(/<|>/g, '&gt;').replace(/\n/g, '<br />');
77 -
78 - // Compare curated content with curated twin.
79 - var twinContent = $twin.html().replace(/<br>/ig,'<br />');
80 -
81 - if(textareaContent+'&nbsp;' != twinContent){
82 -
83 - // Add an extra white space so new rows are added when you are at the end of a row.
84 - $twin.html(textareaContent+'&nbsp;');
85 -
86 - // Change textarea height if twin plus the height of one line differs more than 3 pixel from textarea height
87 - if(Math.abs($twin.height() + lineHeight - $textarea.height()) > 3){
88 -
89 - var goalheight = $twin.height()+lineHeight;
90 - if(goalheight >= maxheight) {
91 - setHeightAndOverflow(maxheight,'auto');
92 - } else if(goalheight <= minheight) {
93 - setHeightAndOverflow(minheight,'hidden');
94 - } else {
95 - setHeightAndOverflow(goalheight,'hidden');
96 - }
97 -
98 - }
99 -
100 - }
101 -
102 - }
103 -
104 - // Hide scrollbars
105 - $textarea.css({'overflow':'hidden'});
106 -
107 - // Update textarea size on keyup, change, cut and paste
108 - $textarea.bind('keyup change cut paste', function(){
109 - update();
110 - });
111 -
112 - // Compact textarea on blur
113 - // Lets animate this....
114 - $textarea.bind('blur',function(){
115 - if($twin.height() < maxheight){
116 - if($twin.height() > minheight) {
117 - $textarea.height($twin.height());
118 - } else {
119 - $textarea.height(minheight);
120 - }
121 - }
122 - });
123 -
124 - // And this line is to catch the browser paste event
125 - $textarea.live('input paste',function(e){ setTimeout( update, 250); });
126 -
127 - // Run update once when elastic is initialized
128 - update();
129 -
130 - });
131 -
132 - }
133 - });
134 -})(jQuery);
\ No newline at end of file
Index: trunk/extensions/WikiLove/WikiLove.php
@@ -71,19 +71,15 @@
7272 $wgAPIModules['wikilove'] = 'WikiLoveApi';
7373
7474 // resources
75 -$wikiLoveTpl = array(
76 - 'localBasePath' => dirname( __FILE__ ),
77 - 'remoteExtPath' => 'WikiLove',
78 - 'group' => 'ext.wikiLove',
79 -);
80 -
8175 $wgResourceModules += array(
82 - 'ext.wikiLove' => $wikiLoveTpl + array(
83 - 'scripts' => array(
84 - 'wikiLove.js',
85 - 'defaultTypes.js',
 76+ 'ext.wikiLove' => array(
 77+ 'localBasePath' => dirname( __FILE__ ) . '/modules/ext.wikiLove',
 78+ 'remoteExtPath' => 'WikiLove/modules/ext.wikiLove',
 79+ 'scripts' => array(
 80+ 'ext.wikiLove.core.js',
 81+ 'ext.wikiLove.defaultOptions.js',
8682 ),
87 - 'styles' => 'wikiLove.css',
 83+ 'styles' => 'ext.wikiLove.css',
8884 'messages' => array(
8985 'wikilove-dialog-title',
9086 'wikilove-select-type',
@@ -116,7 +112,9 @@
117113 'jquery.localize',
118114 ),
119115 ),
120 - 'jquery.elastic' => $wikiLoveTpl + array(
 116+ 'jquery.elastic' => array(
 117+ 'localBasePath' => dirname( __FILE__ ) . '/modules/jquery.elastic',
 118+ 'remoteExtPath' => 'WikiLove/modules/jquery.elastic',
121119 'scripts' => 'jquery.elastic.js',
122120 ),
123121 );
Index: trunk/extensions/WikiLove/modules/jquery.elastic/jquery.elastic.js
@@ -0,0 +1,133 @@
 2+/**
 3+* @name Elastic
 4+* @descripton Elastic is jQuery plugin that grow and shrink your textareas automatically
 5+* @version 1.6.5
 6+* @requires jQuery 1.2.6+
 7+*
 8+* @author Jan Jarfalk
 9+* @author-email jan.jarfalk@unwrongest.com
 10+* @author-website http://www.unwrongest.com
 11+*
 12+* @licence MIT License - http://www.opensource.org/licenses/mit-license.php
 13+*
 14+* This file has been downloaded from http://unwrongest.com/projects/elastic/, please notify the author of
 15+* any changes.
 16+*/
 17+
 18+(function(jQuery){
 19+ jQuery.fn.extend({
 20+ elastic: function() {
 21+
 22+ // We will create a div clone of the textarea
 23+ // by copying these attributes from the textarea to the div.
 24+ var mimics = [
 25+ 'paddingTop',
 26+ 'paddingRight',
 27+ 'paddingBottom',
 28+ 'paddingLeft',
 29+ 'fontSize',
 30+ 'lineHeight',
 31+ 'fontFamily',
 32+ 'width',
 33+ 'fontWeight'];
 34+
 35+ return this.each( function() {
 36+
 37+ // Elastic only works on textareas
 38+ if ( this.type != 'textarea' ) {
 39+ return false;
 40+ }
 41+
 42+ var $textarea = jQuery(this),
 43+ $twin = jQuery('<div />').css({'position': 'absolute','display':'none','word-wrap':'break-word'}),
 44+ lineHeight = parseInt($textarea.css('line-height'),10) || parseInt($textarea.css('font-size'),'10'),
 45+ minheight = parseInt($textarea.css('height'),10) || lineHeight*3,
 46+ maxheight = parseInt($textarea.css('max-height'),10) || Number.MAX_VALUE,
 47+ goalheight = 0;
 48+
 49+ // Opera returns max-height of -1 if not set
 50+ if (maxheight < 0) { maxheight = Number.MAX_VALUE; }
 51+
 52+ // Append the twin to the DOM
 53+ // We are going to meassure the height of this, not the textarea.
 54+ $twin.appendTo($textarea.parent());
 55+
 56+ // Copy the essential styles (mimics) from the textarea to the twin
 57+ var i = mimics.length;
 58+ while(i--){
 59+ $twin.css(mimics[i].toString(),$textarea.css(mimics[i].toString()));
 60+ }
 61+
 62+
 63+ // Sets a given height and overflow state on the textarea
 64+ function setHeightAndOverflow(height, overflow){
 65+ var curratedHeight = Math.floor(parseInt(height,10));
 66+ if($textarea.height() != curratedHeight){
 67+ $textarea.css({'height': curratedHeight + 'px','overflow':overflow});
 68+ }
 69+ }
 70+
 71+
 72+ // This function will update the height of the textarea if necessary
 73+ function update() {
 74+
 75+ // Get curated content from the textarea.
 76+ var textareaContent = $textarea.val().replace(/&/g,'&amp;').replace(/ {2}/g, '&nbsp;').replace(/<|>/g, '&gt;').replace(/\n/g, '<br />');
 77+
 78+ // Compare curated content with curated twin.
 79+ var twinContent = $twin.html().replace(/<br>/ig,'<br />');
 80+
 81+ if(textareaContent+'&nbsp;' != twinContent){
 82+
 83+ // Add an extra white space so new rows are added when you are at the end of a row.
 84+ $twin.html(textareaContent+'&nbsp;');
 85+
 86+ // Change textarea height if twin plus the height of one line differs more than 3 pixel from textarea height
 87+ if(Math.abs($twin.height() + lineHeight - $textarea.height()) > 3){
 88+
 89+ var goalheight = $twin.height()+lineHeight;
 90+ if(goalheight >= maxheight) {
 91+ setHeightAndOverflow(maxheight,'auto');
 92+ } else if(goalheight <= minheight) {
 93+ setHeightAndOverflow(minheight,'hidden');
 94+ } else {
 95+ setHeightAndOverflow(goalheight,'hidden');
 96+ }
 97+
 98+ }
 99+
 100+ }
 101+
 102+ }
 103+
 104+ // Hide scrollbars
 105+ $textarea.css({'overflow':'hidden'});
 106+
 107+ // Update textarea size on keyup, change, cut and paste
 108+ $textarea.bind('keyup change cut paste', function(){
 109+ update();
 110+ });
 111+
 112+ // Compact textarea on blur
 113+ // Lets animate this....
 114+ $textarea.bind('blur',function(){
 115+ if($twin.height() < maxheight){
 116+ if($twin.height() > minheight) {
 117+ $textarea.height($twin.height());
 118+ } else {
 119+ $textarea.height(minheight);
 120+ }
 121+ }
 122+ });
 123+
 124+ // And this line is to catch the browser paste event
 125+ $textarea.live('input paste',function(e){ setTimeout( update, 250); });
 126+
 127+ // Run update once when elastic is initialized
 128+ update();
 129+
 130+ });
 131+
 132+ }
 133+ });
 134+})(jQuery);
\ No newline at end of file
Property changes on: trunk/extensions/WikiLove/modules/jquery.elastic/jquery.elastic.js
___________________________________________________________________
Added: svn:eol-style
1135 + native
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.css
@@ -0,0 +1,373 @@
 2+/* include fix from r87101 here for older versions; these three blocks can become deprecated later */
 3+div.vectorTabs span {
 4+ display: inline-block;
 5+ /* @embed */
 6+ background-image: url(images/tab-break.png);
 7+ background-position: bottom right;
 8+ background-repeat: no-repeat;
 9+}
 10+
 11+div.vectorTabs li a {
 12+ background-image: none;
 13+}
 14+
 15+#ca-unwatch.icon,
 16+#ca-watch.icon {
 17+ margin-right: 0px;
 18+}
 19+
 20+/* icon style */
 21+#ca-wikilove.icon a {
 22+ margin: 0;
 23+ padding: 0;
 24+ outline: none;
 25+ display: block;
 26+ width: 27px;
 27+ /* This hides the text but shows the background image */
 28+ padding-top: 3.1em;
 29+ margin-top: 0;
 30+ /* Only applied in IE6 */
 31+ margin-top: -0.8em !ie;
 32+ height: 0;
 33+ overflow: hidden;
 34+ /* @embed */
 35+ background-image: url(images/heart-icons.png);
 36+}
 37+#ca-wikilove.icon a {
 38+ background-position: 5px 60%;
 39+}
 40+#ca-wikilove.icon a:hover,
 41+#ca-wikilove.icon a:focus {
 42+ background-position: -19px 60%;
 43+}
 44+
 45+/* dialog */
 46+#mw-wikilove-dialog {
 47+ margin: 10px;
 48+}
 49+
 50+/* dialog type selection */
 51+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type {
 52+ float: left;
 53+ width: 250px;
 54+}
 55+
 56+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type ul {
 57+ list-style: none;
 58+ margin: 0;
 59+ padding: 0;
 60+}
 61+
 62+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type ul li,
 63+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a
 64+{
 65+ display: block;
 66+ width: 250px;
 67+ height: 66px;
 68+ padding: 0;
 69+ margin: 0;
 70+ position: relative;
 71+ text-decoration: none;
 72+ outline: none;
 73+}
 74+
 75+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:hover,
 76+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:focus {
 77+ text-decoration:none;
 78+}
 79+
 80+/* IGNORED BY IE6 */
 81+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type ul > li,
 82+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type ul li > a {
 83+ display: inline-block;
 84+}
 85+
 86+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-left-cap,
 87+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-right-cap {
 88+ padding: 0;
 89+ margin: 0;
 90+ width: 6px;
 91+ height: 66px;
 92+ position: absolute;
 93+ top: 0px;
 94+}
 95+
 96+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-left-cap,
 97+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-right-cap,
 98+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-icon-box {
 99+ /* @embed */
 100+ background-image: url(images/select-sprite.png);
 101+ background-repeat: no-repeat;
 102+}
 103+
 104+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-left-cap {
 105+ /* @noflip */
 106+ left: 0px;
 107+ background-position: 0px 0px;
 108+}
 109+
 110+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:hover .mw-wikilove-left-cap,
 111+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:focus .mw-wikilove-left-cap {
 112+ background-position: -6px 0px;
 113+}
 114+
 115+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a.selected .mw-wikilove-left-cap {
 116+ background-position: -12px 0px;
 117+}
 118+
 119+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-right-cap {
 120+ /* @noflip */
 121+ right: 0px;
 122+ background-position: -18px 0px;
 123+}
 124+
 125+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:hover .mw-wikilove-right-cap,
 126+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:focus .mw-wikilove-right-cap {
 127+ background-position: -25px 0px;
 128+}
 129+
 130+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a.selected .mw-wikilove-right-cap {
 131+ background-position: -32px 0px;
 132+}
 133+
 134+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-inside {
 135+ padding: 0;
 136+ margin: 0;
 137+ width: 238px;
 138+ height: 66px;
 139+ position: absolute;
 140+ top: 0px;
 141+ left: 6px;
 142+
 143+ /* @embed */
 144+ background-image: url(images/select-bg-sprite.png);
 145+ background-position: 0px 0px;
 146+ background-repeat: repeat-x;
 147+}
 148+
 149+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:hover .mw-wikilove-inside,
 150+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:focus .mw-wikilove-inside {
 151+ background-position: 0px -66px;
 152+}
 153+
 154+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a.selected .mw-wikilove-inside {
 155+ background-position: 0px -132px;
 156+}
 157+
 158+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-icon-box {
 159+ padding: 0;
 160+ margin: 0;
 161+ width: 53px;
 162+ height: 53px;
 163+ position: absolute;
 164+ left: 0px;
 165+ top: 5px;
 166+ background-position: -42px 0px;
 167+}
 168+
 169+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-icon-box img {
 170+ padding: 0;
 171+ margin: 0;
 172+ width: 53px;
 173+ height: 53px;
 174+ position: absolute:
 175+ top: 0px;
 176+ left: 0px;
 177+}
 178+
 179+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:hover .mw-wikilove-icon-box,
 180+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a:focus .mw-wikilove-icon-box {
 181+ background-position: -97px 0px;
 182+}
 183+
 184+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a.selected .mw-wikilove-icon-box {
 185+ background-position: -152px 0px;
 186+}
 187+
 188+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-link-text {
 189+ padding: 0;
 190+ margin: 0;
 191+ width: 170px;
 192+ height: 53px;
 193+ position: absolute;
 194+ left: 64px;
 195+ top: 5px;
 196+ line-height: 53px;
 197+ font-size: 1.2em;
 198+ font-weight: bold;
 199+ text-decoration: none;
 200+ color: white;
 201+}
 202+
 203+/*#mw-wikilove-dialog*/ #mw-wikilove-select-type a .mw-wikilove-no-icon .mw-wikilove-link-text {
 204+ left: 3px;
 205+}
 206+
 207+/* dialog get started */
 208+/*#mw-wikilove-dialog*/ #mw-wikilove-get-started {
 209+ float: right;
 210+ width: 380px;
 211+ margin-top: 40px;
 212+ padding-top: 4px;
 213+ padding-left: 70px;
 214+ font-size: 1.1em;
 215+
 216+ /* @embed */
 217+ background-image: url(images/get-started-ltr.png);
 218+ background-position: top left;
 219+ background-repeat: no-repeat;
 220+}
 221+
 222+/*#mw-wikilove-dialog*/ #mw-wikilove-get-started h2 {
 223+ border: none;
 224+ font-weight: bold;
 225+}
 226+
 227+/*#mw-wikilove-dialog*/ #mw-wikilove-get-started ol {
 228+ margin-left: 1.5em;
 229+}
 230+
 231+/* dialog add details */
 232+/*#mw-wikilove-dialog*/ #mw-wikilove-add-details {
 233+ float: right;
 234+ width: 480px;
 235+ margin-bottom: 5px;
 236+}
 237+
 238+/*#mw-wikilove-dialog*/ #mw-wikilove-add-details label {
 239+ font-weight: bold;
 240+ font-size: 1.1em;
 241+}
 242+
 243+/*#mw-wikilove-dialog*/ #mw-wikilove-add-details .text {
 244+ display: block;
 245+ width: 300px;
 246+}
 247+
 248+/*#mw-wikilove-dialog*/ #mw-wikilove-add-details .mw-wikilove-note {
 249+ font-weight: light;
 250+ font-size: 0.9em;
 251+ float: right;
 252+ color: #999;
 253+}
 254+
 255+/*#mw-wikilove-dialog*/ #mw-wikilove-add-details textarea {
 256+ resize: none;
 257+}
 258+
 259+#mw-wikilove-dialog .mw-wikilove-spinner {
 260+ float: right;
 261+ margin-top: 0.9em;
 262+ display: none;
 263+
 264+ /* @embed */
 265+ background-image: url(images/spinner.gif);
 266+ background-position: 0px 0px;
 267+ background-repeat: repeat-x;
 268+ width: 16px;
 269+ height: 16px;
 270+}
 271+
 272+/* add details gallery */
 273+/*#mw-wikilove-dialog*/ #mw-wikilove-gallery {
 274+ min-height: 40px;
 275+ position: relative;
 276+}
 277+
 278+/*#mw-wikilove-dialog*/ #mw-wikilove-gallery img {
 279+ margin-right: 5px;
 280+ margin-bottom: 5px;
 281+ padding: 5px;
 282+}
 283+
 284+/*#mw-wikilove-dialog*/ #mw-wikilove-gallery a:hover img,
 285+/*#mw-wikilove-dialog*/ #mw-wikilove-gallery a:focus img {
 286+ background-color: #aacfe9;
 287+}
 288+
 289+/*#mw-wikilove-dialog*/ #mw-wikilove-gallery a.selected img {
 290+ background-color: #f56427;
 291+}
 292+
 293+/*#mw-wikilove-dialog*/ #mw-wikilove-gallery-spinner {
 294+ float: none;
 295+ position: absolute;
 296+ top: 0;
 297+ left: 50%;
 298+ margin-left: -8px;
 299+ z-index: -1;
 300+}
 301+
 302+/* dialog preview */
 303+/*#mw-wikilove-dialog*/ #mw-wikilove-preview {
 304+ float: right;
 305+ width: 480px;
 306+}
 307+
 308+/*#mw-wikilove-dialog #mw-wikilove-preview*/ #mw-wikilove-preview-area {
 309+ margin-left: 15px;
 310+ width: 465px;
 311+ overflow: auto;
 312+}
 313+
 314+/*#mw-wikilove-dialog #mw-wikilove-preview*/ #mw-wikilove-preview-area .editsection {
 315+ display: none;
 316+}
 317+
 318+/* dialog misc */
 319+#mw-wikilove-dialog input[type=text],
 320+#mw-wikilove-dialog textarea,
 321+#mw-wikilove-dialog select {
 322+ margin: 5px 0px 5px 15px;
 323+ max-width: 460px;
 324+ display: block;
 325+}
 326+
 327+/*#mw-wikilove-dialog*/ #wlSubtypeDescription {
 328+ margin: 5px 0px 8px 15px;
 329+ font-size: 1.0em;
 330+ line-height: 1.2em;
 331+}
 332+
 333+#mw-wikilove-dialog input[type=checkbox] {
 334+ display:inline-box;
 335+ margin: 5px 0px 5px 0px;
 336+}
 337+
 338+#mw-wikilove-dialog select {
 339+ padding: 1px 0;
 340+}
 341+
 342+#mw-wikilove-dialog .submit {
 343+ float: right;
 344+}
 345+
 346+#mw-wikilove-dialog .mw-wikilove-number {
 347+ color: white;
 348+ float: left;
 349+ display: block;
 350+ width: 32px;
 351+ height: 32px;
 352+ line-height: 32px;
 353+ text-align: center;
 354+ margin-right: 5px;
 355+ font-size: 1.5em;
 356+ font-weight: bold;
 357+
 358+ /* @embed */
 359+ background-image: url(images/number.png);
 360+ background-position: center;
 361+ background-repeat: no-repeat;
 362+}
 363+
 364+#mw-wikilove-dialog .mw-wikilove-error {
 365+ /* @embed */
 366+ background-image: url(images/alert.png);
 367+ background-position: center left;
 368+ background-repeat: no-repeat;
 369+ color: red;
 370+ font-weight: bold;
 371+ line-height: 32px;
 372+ padding-left: 34px;
 373+ padding-bottom: 3px;
 374+}
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.css
___________________________________________________________________
Added: svn:eol-style
1375 + native
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.defaultOptions.js
@@ -0,0 +1,68 @@
 2+$.wikiLove.types = {
 3+ // example type, could be removed later (also no i18n)
 4+ 'barnstar': {
 5+ name: 'Barnstar', // name of the type (appears in the types menu)
 6+ select: 'Select a barnstar:', // subtype select label
 7+ subtypes: { // some different subtypes
 8+ // note that when not using subtypes you should use these subtype options
 9+ // for the top-level type
 10+ 'original': {
 11+ fields: [ 'notify' ], // fields to ask for in form
 12+ option: 'Original barnstar', // option listed in the select list
 13+ descr: 'This barnstar is given to recognize particularly fine contributions to Wikipedia, to let people know that their hard work is seen and appreciated.', // description
 14+ header: 'A barnstar for you!', // header that appears at the top of the talk page post (optional)
 15+ title: 'The Original Barnstar', // title that appears inside the award box (optional)
 16+ image: 'Original Barnstar Hires.png', // image for the award
 17+ mail: 'Hello $7!\n\nI just awarded you a barnstar.' // message to use in email notification; $7 is replaced by the recipient's username
 18+ },
 19+ 'editors': {
 20+ fields: [ 'notify' ],
 21+ option: 'Editor\'s barnstar',
 22+ descr: 'The Editor\'s Barnstar is awarded to individuals who display particularly fine decisions in general editing.',
 23+ header: 'A barnstar for you!',
 24+ title: 'The Editor\'s Barnstar',
 25+ image: 'Editors Barnstar Hires.png',
 26+ mail: 'Hello $7!\n\nI just awarded you a barnstar.'
 27+ },
 28+ 'tireless': {
 29+ fields: [ 'title', 'notify' ],
 30+ option: 'Tireless contributor barnstar',
 31+ descr: 'The Tireless Contributor Barnstar is awarded to especially tireless Wikipedians who contribute an especially large body of work without sacrificing quality.',
 32+ header: 'A barnstar for you!',
 33+ title: 'Tireless contributor barnstar',
 34+ image: 'Tireless Contributor Barnstar Hires.gif',
 35+ mail: 'Hello $7!\n\nI just awarded you a barnstar.'
 36+ }
 37+ },
 38+ icon: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/extensions/WikiLove/images/icons/wikilove-icon-barnstar.png' // icon for left-side menu
 39+ },
 40+ 'puppy': {
 41+ name: 'Puppy',
 42+ fields: [ 'header' ],
 43+ header: 'A puppy for you!',
 44+ text: '[[$3|left|150px]]\n$1\n\n~~~~\n<br style="clear: both"/>', // custom text
 45+ gallery: {
 46+ // right now we can only query the local wiki (not e.g. commons)
 47+ category: 'Category:Puppies',
 48+ total: 100, // total number of pictures to retrieve, and to randomise
 49+ num: 3, // number of pictures to show from the randomised set
 50+ width: 145 // width of each picture in pixels in the interface (not in the template)
 51+ }
 52+ },
 53+ 'kitten': {
 54+ name: 'Kitten',
 55+ fields: [ 'header' ],
 56+ header: 'A kitten for you!',
 57+ text: '[[$3|left|150px]]\n$1\n\n~~~~\n<br style="clear: both"/>', // $3 is the image filename
 58+ gallery: {
 59+ imageList: ['File:Cucciolo gatto Bibo.jpg','File:Kitten (06) by Ron.jpg','File:Kitten-stare.jpg'],
 60+ width: 145
 61+ }
 62+ },
 63+ // default type, nice to leave this one in place when adding other types
 64+ 'makeyourown': {
 65+ name: mw.msg( 'wikilove-type-makeyourown' ),
 66+ fields: [ 'header', 'title', 'image', 'notify' ],
 67+ imageSize: '150px'
 68+ }
 69+}
\ No newline at end of file
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.defaultOptions.js
___________________________________________________________________
Added: svn:eol-style
170 + native
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/images/heart-icons.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/images/heart-icons.png
___________________________________________________________________
Added: svn:mime-type
271 + image/png
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/images/spinner.gif
Cannot display: file marked as a binary type.
svn:mime-type = image/gif
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/images/spinner.gif
___________________________________________________________________
Added: svn:mime-type
372 + image/gif
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/images/get-started-ltr.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/images/get-started-ltr.png
___________________________________________________________________
Added: svn:mime-type
473 + image/png
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/images/get-started-rtl.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/images/get-started-rtl.png
___________________________________________________________________
Added: svn:mime-type
574 + image/png
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/images/heart.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/images/heart.png
___________________________________________________________________
Added: svn:mime-type
675 + image/png
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/images/select-sprite.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/images/select-sprite.png
___________________________________________________________________
Added: svn:mime-type
776 + image/png
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/images/heart-hover.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/images/heart-hover.png
___________________________________________________________________
Added: svn:mime-type
877 + image/png
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/images/alert.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/images/alert.png
___________________________________________________________________
Added: svn:mime-type
978 + image/png
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/images/icons/wikilove-icon-cookie.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/images/icons/wikilove-icon-cookie.png
___________________________________________________________________
Added: svn:mime-type
1079 + image/png
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/images/icons/wikilove-icon-wikiproject.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/images/icons/wikilove-icon-wikiproject.png
___________________________________________________________________
Added: svn:mime-type
1180 + image/png
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/images/icons/wikilove-icon-welcome.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/images/icons/wikilove-icon-welcome.png
___________________________________________________________________
Added: svn:mime-type
1281 + image/png
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/images/icons/wikilove-icon-barnstar.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/images/icons/wikilove-icon-barnstar.png
___________________________________________________________________
Added: svn:mime-type
1382 + image/png
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/images/icons/wikilove-icon-beer.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/images/icons/wikilove-icon-beer.png
___________________________________________________________________
Added: svn:mime-type
1483 + image/png
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/images/icons/wikilove-icon-kitten.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/images/icons/wikilove-icon-kitten.png
___________________________________________________________________
Added: svn:mime-type
1584 + image/png
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/images/number.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/images/number.png
___________________________________________________________________
Added: svn:mime-type
1685 + image/png
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/images/tab-break.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/images/tab-break.png
___________________________________________________________________
Added: svn:mime-type
1786 + image/png
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/images/select-bg-sprite.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/images/select-bg-sprite.png
___________________________________________________________________
Added: svn:mime-type
1887 + image/png
Index: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js
@@ -0,0 +1,596 @@
 2+( function( $ ) { $.wikiLove = {
 3+
 4+ $dialog: null, // dialog jQuery object
 5+ currentTypeId: null, // id of the currently selected type (e.g. 'barnstar' or 'makeyourown')
 6+ currentSubtypeId: null, // id of the currently selected subtype (e.g. 'original' or 'special')
 7+ currentTypeOrSubtype: null, // content of the current (sub)type (i.e. an object with title, descr, text, etc.)
 8+ previewData: null, // data of the currently previewed thing is set here
 9+ emailable: false,
 10+ gallery: {},
 11+ defaultText: '{| style="background-color: $5; border: 1px solid $6;"\n\
 12+|rowspan="2" style="vertical-align: middle; padding: 5px;" | [[Image:$3|$4]]\n\
 13+|style="font-size: x-large; padding: 3px; height: 1.5em;" | \'\'\'$2\'\'\'\n\
 14+|-\n\
 15+|style="vertical-align: middle; padding: 3px;" | $1 ~~~~\n\
 16+|}',
 17+ defaultBackgroundColor: '#fdffe7',
 18+ defaultBorderColor: '#fceb92',
 19+ defaultImageSize: '100px',
 20+
 21+ /*
 22+ * Opens the dialog and builds it if necessary.
 23+ */
 24+ openDialog: function() {
 25+ if ( $.wikiLove.$dialog === null ) {
 26+ // Load local configuration
 27+ var wikiLoveConfigUrl = wgServer + wgScript + '?' + $.param( { 'title': 'MediaWiki:WikiLove.js', 'action': 'raw', 'ctype': 'text/javascript' } );
 28+ mw.loader.load( wikiLoveConfigUrl );
 29+
 30+ // Test to see if the 'E-mail this user' link exists
 31+ $.wikiLove.emailable = $( '#t-emailuser' ).length ? true : false;
 32+
 33+ // Build a type list like this:
 34+ var $typeList = $( '<ul id="mw-wikilove-types"></ul>' );
 35+ for( var typeId in $.wikiLove.types ) {
 36+ var $button = $( '<a href="#"></a>' );
 37+ var $buttonInside = $( '<div class="mw-wikilove-inside"></div>' );
 38+
 39+ if( typeof $.wikiLove.types[typeId].icon == 'string' ) {
 40+ $buttonInside.append( '<div class="mw-wikilove-icon-box"><img src="'
 41+ + mw.html.escape( $.wikiLove.types[typeId].icon ) + '"/></div>' );
 42+ }
 43+ else {
 44+ $buttonInside.addClass( 'mw-wikilove-no-icon' );
 45+ }
 46+
 47+ $buttonInside.append( '<div class="mw-wikilove-link-text">' + $.wikiLove.types[typeId].name + '</div>' );
 48+
 49+ $button.append( '<div class="mw-wikilove-left-cap"></div>');
 50+ $button.append( $buttonInside );
 51+ $button.append( '<div class="mw-wikilove-right-cap"></div>');
 52+ $button.data( 'typeId', typeId );
 53+ $typeList.append( $( '<li tabindex="0"></li>' ).append( $button ) );
 54+ }
 55+
 56+ $.wikiLove.$dialog = $( '\
 57+<div id="mw-wikilove-dialog">\
 58+<div id="mw-wikilove-select-type">\
 59+ <span class="mw-wikilove-number">1</span>\
 60+ <h3><html:msg key="wikilove-select-type"/></h3>\
 61+ <ul id="mw-wikilove-types"></ul>\
 62+</div>\
 63+<div id="mw-wikilove-get-started">\
 64+ <h2><html:msg key="wikilove-get-started-header"/></h2>\
 65+ <ol>\
 66+ <li><html:msg key="wikilove-get-started-list-1"/></li>\
 67+ <li><html:msg key="wikilove-get-started-list-2"/></li>\
 68+ <li><html:msg key="wikilove-get-started-list-3"/></li>\
 69+ </ol>\
 70+</div>\
 71+<div id="mw-wikilove-add-details">\
 72+ <span class="mw-wikilove-number">2</span>\
 73+ <h3><html:msg key="wikilove-add-details"/></h3>\
 74+ <form id="mw-wikilove-preview-form">\
 75+ <label for="mw-wikilove-subtype" id="mw-wikilove-subtype-label"></label>\
 76+ <select id="mw-wikilove-subtype"></select>\
 77+ <div id="mw-wikilove-subtype-description"></div>\
 78+ <label id="mw-wikilove-gallery-label"><html:msg key="wikilove-image"/></label>\
 79+ <div id="mw-wikilove-gallery">\
 80+ <div id="mw-wikilove-gallery-spinner" class="mw-wikilove-spinner"></div>\
 81+ <div id="mw-wikilove-gallery-content"></div>\
 82+ </div>\
 83+ <label for="mw-wikilove-header" id="mw-wikilove-header-label"><html:msg key="wikilove-header"/></label>\
 84+ <input type="text" class="text" id="mw-wikilove-header"/>\
 85+ <label for="mw-wikilove-title" id="mw-wikilove-title-label"><html:msg key="wikilove-title"/></label>\
 86+ <input type="text" class="text" id="mw-wikilove-title"/>\
 87+ <label for="mw-wikilove-image" id="mw-wikilove-image-label"><html:msg key="wikilove-image"/></label>\
 88+ <input type="text" class="text" id="mw-wikilove-image"/>\
 89+ <label for="mw-wikilove-message" id="mw-wikilove-message-label"><html:msg key="wikilove-enter-message"/></label>\
 90+ <span class="mw-wikilove-note"><html:msg key="wikilove-omit-sig"/></span>\
 91+ <textarea id="mw-wikilove-message"></textarea>\
 92+ <div id="mw-wikilove-notify">\
 93+ <input type="checkbox" id="mw-wikilove-notify-checkbox" name="notify"/>\
 94+ <label for="mw-wikilove-notify-checkbox"><html:msg key="wikilove-notify"/></label>\
 95+ </div>\
 96+ <button class="submit" id="mw-wikilove-button-preview" type="submit"></button>\
 97+ <div id="mw-wikilove-preview-spinner" class="mw-wikilove-spinner"></div>\
 98+ </form>\
 99+</div>\
 100+<div id="mw-wikilove-preview">\
 101+ <span class="mw-wikilove-number">3</span>\
 102+ <h3><html:msg key="wikilove-preview"/></h3>\
 103+ <div id="mw-wikilove-preview-area"></div>\
 104+ <form id="mw-wikilove-send-form">\
 105+ <button class="submit" id="mw-wikilove-button-send" type="submit"></button>\
 106+ <div id="mw-wikilove-send-spinner" class="mw-wikilove-spinner"></div>\
 107+ </form>\
 108+</div>\
 109+</div>' );
 110+ $.wikiLove.$dialog.localize();
 111+
 112+ $.wikiLove.$dialog.dialog({
 113+ width: 800,
 114+ position: ['center', 80],
 115+ autoOpen: false,
 116+ title: mw.msg( 'wikilove-dialog-title' ),
 117+ modal: true,
 118+ resizable: false
 119+ });
 120+
 121+ $( '#mw-wikilove-button-preview' ).button( { label: mw.msg( 'wikilove-button-preview' ), icons: { primary:'ui-icon-search' } } );
 122+ $( '#mw-wikilove-button-send' ).button( { label: mw.msg( 'wikilove-button-send' ) } );
 123+ $( '#mw-wikilove-add-details' ).hide();
 124+ $( '#mw-wikilove-preview' ).hide();
 125+ $( '#mw-wikilove-types' ).replaceWith( $typeList );
 126+
 127+ $( '#mw-wikilove-types a' ).click( $.wikiLove.clickType );
 128+ $( '#mw-wikilove-subtype' ).change( $.wikiLove.changeSubtype );
 129+ $( '#mw-wikilove-preview-form' ).submit( $.wikiLove.submitPreview );
 130+ $( '#mw-wikilove-send-form' ).click( $.wikiLove.submitSend );
 131+ $( '#mw-wikilove-message' ).elastic(); // have the message textarea grow automatically
 132+ }
 133+
 134+ $.wikiLove.$dialog.dialog( 'open' );
 135+ },
 136+
 137+ /*
 138+ * Handler for the left menu. Selects a new type and initialises next section
 139+ * depending on whether or not to show subtypes.
 140+ */
 141+ clickType: function( e ) {
 142+ e.preventDefault();
 143+ $( '#mw-wikilove-get-started' ).hide(); // always hide the get started section
 144+
 145+ var newTypeId = $( this ).data( 'typeId' );
 146+ if( $.wikiLove.currentTypeId != newTypeId ) { // only do stuff when a different type is selected
 147+ $.wikiLove.currentTypeId = newTypeId;
 148+ $.wikiLove.currentSubtypeId = null; // reset the subtype id
 149+
 150+ $( '#mw-wikilove-types a' ).removeClass( 'selected' );
 151+ $( this ).addClass( 'selected' ); // highlight the new type in the menu
 152+
 153+ if( typeof $.wikiLove.types[$.wikiLove.currentTypeId].subtypes == 'object' ) {
 154+ // we're dealing with subtypes here
 155+ $.wikiLove.currentTypeOrSubtype = null; // reset the (sub)type object until a subtype is selected
 156+ $( '#mw-wikilove-subtype' ).html( '' ); // clear the subtype menu
 157+
 158+ for( var subtypeId in $.wikiLove.types[$.wikiLove.currentTypeId].subtypes ) {
 159+ // add all the subtypes to the menu while setting their subtype ids in jQuery data
 160+ var subtype = $.wikiLove.types[$.wikiLove.currentTypeId].subtypes[subtypeId];
 161+ $( '#mw-wikilove-subtype' ).append(
 162+ $( '<option></option>' ).text( subtype.option ).data( 'subtypeId', subtypeId )
 163+ );
 164+ }
 165+ $( '#mw-wikilove-subtype' ).show();
 166+
 167+ // change and show the subtype label depending on the type
 168+ $( '#mw-wikilove-subtype-label' ).text( $.wikiLove.types[$.wikiLove.currentTypeId].select || mw.msg( 'wikilove-select-type' ) );
 169+ $( '#mw-wikilove-subtype-label' ).show();
 170+ $.wikiLove.changeSubtype(); // update controls depending on the currently selected (i.e. first) subtype
 171+ }
 172+ else {
 173+ // there are no subtypes, just use this type for the current (sub)type
 174+ $.wikiLove.currentTypeOrSubtype = $.wikiLove.types[$.wikiLove.currentTypeId];
 175+ $( '#mw-wikilove-subtype' ).hide();
 176+ $( '#mw-wikilove-subtype-label' ).hide();
 177+ $.wikiLove.updateAllDetails(); // update controls depending on this type
 178+ }
 179+
 180+ $( '#mw-wikilove-add-details' ).show();
 181+ $( '#mw-wikilove-preview' ).hide();
 182+ $.wikiLove.previewData = null;
 183+ }
 184+ },
 185+
 186+ /*
 187+ * Handler for changing the subtype.
 188+ */
 189+ changeSubtype: function() {
 190+ // find out which subtype is selected
 191+ var newSubtypeId = $( '#mw-wikilove-subtype option:selected' ).first().data( 'subtypeId' );
 192+ if( $.wikiLove.currentSubtypeId != newSubtypeId ) { // only change stuff when a different subtype is selected
 193+ $.wikiLove.currentSubtypeId = newSubtypeId;
 194+ $.wikiLove.currentTypeOrSubtype = $.wikiLove.types[$.wikiLove.currentTypeId]
 195+ .subtypes[$.wikiLove.currentSubtypeId];
 196+ $( '#mw-wikilove-subtype-description' ).html( $.wikiLove.currentTypeOrSubtype.descr );
 197+ $.wikiLove.updateAllDetails();
 198+ $( '#mw-wikilove-preview' ).hide();
 199+ $.wikiLove.previewData = null;
 200+ }
 201+ },
 202+
 203+ /*
 204+ * Called when type or subtype changes, updates controls.
 205+ */
 206+ updateAllDetails: function() {
 207+ $( '#wikiLoveDialog' ).find( '.mw-wikilove-error' ).remove();
 208+
 209+ // only show the description if it exists for this type or subtype
 210+ if( typeof $.wikiLove.currentTypeOrSubtype.descr == 'string' ) {
 211+ $( '#mw-wikilove-subtype-description').show();
 212+ } else {
 213+ $( '#mw-wikilove-subtype-description').hide();
 214+ }
 215+
 216+ // show or hide header label and textbox depending on whether a predefined header exists
 217+ if( $.inArray( 'header', $.wikiLove.currentTypeOrSubtype.fields ) >= 0 ) {
 218+ $( '#mw-wikilove-header-label').show();
 219+ $( '#mw-wikilove-header' ).show();
 220+ } else {
 221+ $( '#mw-wikilove-header-label').hide();
 222+ $( '#mw-wikilove-header' ).hide();
 223+ }
 224+ $( '#mw-wikilove-header' ).val( $.wikiLove.currentTypeOrSubtype.header || '' );
 225+
 226+ // show or hide title label and textbox depending on whether a predefined title exists
 227+ if( $.inArray( 'title', $.wikiLove.currentTypeOrSubtype.fields ) >= 0 ) {
 228+ $( '#mw-wikilove-title-label').show();
 229+ $( '#mw-wikilove-title' ).show();
 230+ } else {
 231+ $( '#mw-wikilove-title-label').hide();
 232+ $( '#mw-wikilove-title' ).hide();
 233+ }
 234+ $( '#mw-wikilove-title' ).val( $.wikiLove.currentTypeOrSubtype.title || '' );
 235+
 236+ // show or hide image label and textbox depending on whether a predefined image exists
 237+ if( $.inArray( 'image', $.wikiLove.currentTypeOrSubtype.fields ) >= 0 ) {
 238+ $( '#mw-wikilove-image-label').show();
 239+ $( '#mw-wikilove-image' ).show();
 240+ } else {
 241+ $( '#mw-wikilove-image-label').hide();
 242+ $( '#mw-wikilove-image' ).hide();
 243+ }
 244+ $( '#mw-wikilove-image' ).val( $.wikiLove.currentTypeOrSubtype.image || '' );
 245+
 246+ if( typeof $.wikiLove.currentTypeOrSubtype.gallery == 'object' ) {
 247+ if( $.wikiLove.currentTypeOrSubtype.gallery.imageList instanceof Array) {
 248+ $( '#mw-wikilove-gallery-label' ).show();
 249+ $( '#mw-wikilove-gallery' ).show();
 250+ $.wikiLove.showGallery(); // build gallery from array of images
 251+ } else {
 252+ // gallery is a category
 253+ $( '#mw-wikilove-gallery-label' ).show();
 254+ $( '#mw-wikilove-gallery' ).show();
 255+ $.wikiLove.makeGallery(); // build gallery from category
 256+ }
 257+ }
 258+ else {
 259+ $( '#mw-wikilove-gallery-label' ).hide();
 260+ $( '#mw-wikilove-gallery' ).hide();
 261+ }
 262+
 263+ if( $.inArray( 'notify', $.wikiLove.currentTypeOrSubtype.fields ) >= 0 && $.wikiLove.emailable ) {
 264+ $( '#mw-wikilove-notify' ).show();
 265+ } else {
 266+ $( '#mw-wikilove-notify' ).hide();
 267+ $( '#mw-wikilove-notify-checkbox' ).attr('checked', false);
 268+ }
 269+ },
 270+
 271+ /*
 272+ * Handler for clicking the preview button. Builds data for AJAX request.
 273+ */
 274+ submitPreview: function( e ) {
 275+ e.preventDefault();
 276+ $( '#mw-wikilove-preview' ).hide();
 277+ $( '#wikiLoveDialog' ).find( '.wlError' ).remove();
 278+
 279+ if( typeof $.wikiLove.currentTypeOrSubtype.gallery == 'object' ) {
 280+ if ( $( '#mw-wikilove-image' ).val().length <= 0 ) {
 281+ $.wikiLove.showError( 'wikilove-err-image' ); return false;
 282+ }
 283+ }
 284+ if( $( '#mw-wikilove-header' ).val().length <= 0 ) {
 285+ $.wikiLove.showError( 'wikilove-err-header' ); return false;
 286+ }
 287+ if( $( '#mw-wikilove-message' ).val().length <= 0 ) {
 288+ $.wikiLove.showError( 'wikilove-err-msg' ); return false;
 289+ }
 290+
 291+ // If there isn't a signature already in the message, throw an error
 292+ if ( $( '#mw-wikilove-message' ).val().indexOf( '~~~' ) >= 0 ) {
 293+ $.wikiLove.showError( 'wikilove-err-sig' ); return false;
 294+ }
 295+
 296+ var msg = $.wikiLove.prepareMsg(
 297+ $.wikiLove.currentTypeOrSubtype.text || $.wikiLove.defaultText,
 298+ $.wikiLove.currentTypeOrSubtype.imageSize,
 299+ $.wikiLove.currentTypeOrSubtype.backgroundColor,
 300+ $.wikiLove.currentTypeOrSubtype.borderColor
 301+ );
 302+
 303+ $.wikiLove.doPreview( '==' + $( '#mw-wikilove-header' ).val() + "==\n" + msg );
 304+ $.wikiLove.previewData = {
 305+ 'header': $( '#mw-wikilove-header' ).val(),
 306+ 'msg': msg,
 307+ 'type': $.wikiLove.currentTypeId
 308+ + ($.wikiLove.currentSubtypeId !== null ? '-' + $.wikiLove.currentSubtypeId : '')
 309+ };
 310+
 311+ if ( $( '#mw-wikilove-notify-checkbox:checked' ).val() && $.wikiLove.emailable ) {
 312+ $.wikiLove.previewData.mail = $.wikiLove.prepareMsg( $.wikiLove.currentTypeOrSubtype.mail );
 313+ }
 314+ },
 315+
 316+ showError: function( errmsg ) {
 317+ $( '#mw-wikilove-add-details' ).append( $( '<div class="mw-wikilove-error"></div>' ).text( mw.msg( errmsg ) ) );
 318+ },
 319+
 320+ /*
 321+ * Prepares a message or e-mail body by replacing placeholders.
 322+ * $1: message entered by the user
 323+ * $2: title of the item
 324+ * $3: title of the image
 325+ * $4: image size
 326+ * $5: background color
 327+ * $6: border color
 328+ * $7: username of the recipient
 329+ */
 330+ prepareMsg: function( msg, imageSize, backgroundColor, borderColor ) {
 331+
 332+ msg = msg.replace( '$1', $( '#mw-wikilove-message' ).val() ); // replace the raw message
 333+ msg = msg.replace( '$2', $( '#mw-wikilove-title' ).val() ); // replace the title
 334+ msg = msg.replace( '$3', $( '#mw-wikilove-image' ).val() ); // replace the image
 335+
 336+ var myImageSize = imageSize || $.wikiLove.defaultImageSize;
 337+ var myBackgroundColor = backgroundColor || $.wikiLove.defaultBackgroundColor;
 338+ var myBorderColor = borderColor || $.wikiLove.defaultBorderColor;
 339+
 340+ msg = msg.replace( '$4', myImageSize ); // replace the image size
 341+ msg = msg.replace( '$5', myBackgroundColor ); // replace the background color
 342+ msg = msg.replace( '$6', myBorderColor ); // replace the border color
 343+
 344+ msg = msg.replace( '$7', wgTitle ); // replace the username we're sending to
 345+
 346+ return msg;
 347+ },
 348+
 349+ /*
 350+ * Fires AJAX request for previewing wikitext.
 351+ */
 352+ doPreview: function( wikitext ) {
 353+ $( '#mw-wikilove-preview-spinner' ).fadeIn( 200 );
 354+ $.ajax({
 355+ url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php?',
 356+ data: {
 357+ 'action': 'parse',
 358+ 'format': 'json',
 359+ 'text': wikitext,
 360+ 'prop': 'text',
 361+ 'pst': true
 362+ },
 363+ dataType: 'json',
 364+ type: 'POST',
 365+ success: function( data ) {
 366+ $.wikiLove.showPreview( data.parse.text['*'] );
 367+ $( '#mw-wikilove-preview-spinner' ).fadeOut( 200 );
 368+ }
 369+ });
 370+ },
 371+
 372+ /*
 373+ * Callback for the preview function. Sets the preview area with the HTML and fades it in.
 374+ */
 375+ showPreview: function( html ) {
 376+ $( '#mw-wikilove-preview-area' ).html( html );
 377+ $( '#mw-wikilove-preview' ).fadeIn( 200 );
 378+ },
 379+
 380+ /*
 381+ * Handler for the send (final submit) button. Builds data for AJAX request.
 382+ * The type sent for statistics is 'typeId-subtypeId' when using subtypes,
 383+ * or simply 'typeId' otherwise.
 384+ */
 385+ submitSend: function( e ) {
 386+ e.preventDefault();
 387+ $.wikiLove.doSend( $.wikiLove.previewData.header, $.wikiLove.previewData.msg,
 388+ $.wikiLove.previewData.type, $.wikiLove.previewData.notify );
 389+ },
 390+
 391+ /*
 392+ * Fires the final AJAX request and then redirects to the talk page where the content is added.
 393+ */
 394+ doSend: function( subject, wikitext, type, mail ) {
 395+ $( '#mw-wikilove-send-spinner' ).fadeIn( 200 );
 396+
 397+ var sendData = {
 398+ 'action': 'wikilove',
 399+ 'format': 'json',
 400+ 'title': mw.config.get( 'wgPageName' ),
 401+ 'type': type,
 402+ 'text': wikitext,
 403+ 'subject': subject,
 404+ 'token': mw.user.tokens.get( 'editToken' )
 405+ };
 406+
 407+ if ( mail ) {
 408+ sendData.email = mail;
 409+ }
 410+
 411+ $.ajax({
 412+ url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php?',
 413+ data: sendData,
 414+ dataType: 'json',
 415+ type: 'POST',
 416+ success: function( data ) {
 417+ $( '#mw-wikilove-send-spinner' ).fadeOut( 200 );
 418+
 419+ if ( typeof data.error !== 'undefined' ) {
 420+ $( '#mw-wikilove-preview' ).append( '<div class="wlError">' + mw.html.escape( data.error.info ) + '<div>' );
 421+ return;
 422+ }
 423+
 424+ if ( typeof data.redirect !== 'undefined'
 425+ && data.redirect.pageName == mw.config.get( 'wgPageName' ) ) {
 426+ // unfortunately, when on the talk page we cannot reload and then
 427+ // jump to the correct section, because when we set the hash (#...)
 428+ // the page won't reload...
 429+ window.location.reload();
 430+ }
 431+ else {
 432+ window.location = mw.util.wikiUrlencode(
 433+ mw.config.get( 'wgArticlePath' ).replace( '$1', data.redirect.pageName )
 434+ + '#' + data.redirect.fragment );
 435+ }
 436+ }
 437+ });
 438+ },
 439+
 440+ /*
 441+ * This function is called if the gallery is an array of images. It retrieves the image
 442+ * thumbnails from the API, and constructs a thumbnail gallery with them.
 443+ */
 444+ showGallery: function() {
 445+ $( '#mw-wikilove-gallery-content' ).html( '' );
 446+ $.wikiLove.gallery = {};
 447+ $( '#mw-wikilove-gallery-spinner' ).fadeIn( 200 );
 448+
 449+ $.each( $.wikiLove.currentTypeOrSubtype.gallery.imageList, function(index, value) {
 450+
 451+ $.ajax({
 452+ url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php',
 453+ data: {
 454+ 'action' : 'query',
 455+ 'format' : 'json',
 456+ 'prop' : 'imageinfo',
 457+ 'iiprop' : 'mime|url',
 458+ 'titles' : value,
 459+ 'iiurlwidth' : $.wikiLove.currentTypeOrSubtype.gallery.width
 460+ },
 461+ dataType: 'json',
 462+ type: 'POST',
 463+ success: function( data ) {
 464+ $( '#mw-wikilove-gallery-spinner' ).fadeOut( 200 );
 465+
 466+ if ( !data || !data.query || !data.query.pages ) {
 467+ return;
 468+ }
 469+ $.each( data.query.pages, function( id, page ) {
 470+ if ( page.imageinfo && page.imageinfo.length ) {
 471+ // build an image tag with the correct url and width
 472+ $img = $( '<img/>' )
 473+ .attr( 'src', page.imageinfo[0].thumburl )
 474+ .attr( 'width', $.wikiLove.currentTypeOrSubtype.gallery.width )
 475+ .hide()
 476+ .load( function() { $( this ).css( 'display', 'inline-block' ); } );
 477+ $( '#mw-wikilove-gallery-content' ).append(
 478+ $( '<a href="#"></a>' )
 479+ .attr( 'id', 'mw-wikilove-gallery-img-' + index )
 480+ .append( $img )
 481+ .click( function( e ) {
 482+ e.preventDefault();
 483+ $( '#mw-wikilove-gallery a' ).removeClass( 'selected' );
 484+ $( this ).addClass( 'selected' );
 485+ $( '#mw-wikilove-image' ).val( $.wikiLove.gallery[$( this ).attr( 'id' )] );
 486+ })
 487+ );
 488+ $.wikiLove.gallery['mw-wikilove-gallery-img-' + index] = page.title;
 489+ }
 490+ } );
 491+ }
 492+ });
 493+
 494+ });
 495+ },
 496+
 497+ /*
 498+ * This is a bit of a hack to show some random images. A predefined set of image infos are
 499+ * retrieved using the API. Then we randomise this set ourselves and select some images to
 500+ * show. Eventually we probably want to make a custom API call that does this properly and
 501+ * also allows for using remote galleries such as Commons, which is now prohibited by JS.
 502+ */
 503+ makeGallery: function() {
 504+ $( '#mw-wikilove-gallery-content' ).html( '' );
 505+ $.wikiLove.gallery = {};
 506+ $( '#mw-wikilove-gallery-spinner' ).fadeIn( 200 );
 507+
 508+ $.ajax({
 509+ url: mw.config.get( 'wgServer' ) + mw.config.get( 'wgScriptPath' ) + '/api.php',
 510+ data: {
 511+ 'action' : 'query',
 512+ 'format' : 'json',
 513+ 'prop' : 'imageinfo',
 514+ 'iiprop' : 'mime|url',
 515+ 'iiurlwidth' : $.wikiLove.currentTypeOrSubtype.gallery.width,
 516+ 'generator' : 'categorymembers',
 517+ 'gcmtitle' : $.wikiLove.currentTypeOrSubtype.gallery.category,
 518+ 'gcmnamespace': 6,
 519+ 'gcmsort' : 'timestamp',
 520+ 'gcmlimit' : $.wikiLove.currentTypeOrSubtype.gallery.total
 521+ },
 522+ dataType: 'json',
 523+ type: 'POST',
 524+ success: function( data ) {
 525+ // clear
 526+ $( '#mw-wikilove-gallery-content' ).html( '' );
 527+ $.wikiLove.gallery = {};
 528+
 529+ // if we have any images at all
 530+ if( data.query) {
 531+ // get the page keys which are just ids
 532+ var keys = Object.keys( data.query.pages );
 533+
 534+ // try to find "num" images to show
 535+ for( var i=0; i<$.wikiLove.currentTypeOrSubtype.gallery.num; i++ ) {
 536+ // continue looking for a new image until we have found one thats valid
 537+ // or until we run out of images
 538+ while( keys.length > 0 ) {
 539+ // get a random page
 540+ var id = Math.floor( Math.random() * keys.length );
 541+ var page = data.query.pages[keys[id]];
 542+
 543+ // remove the random page from the keys array
 544+ keys.splice(id, 1);
 545+
 546+ // only add the image if it's actually an image
 547+ if( page.imageinfo[0].mime.substr(0,5) == 'image' ) {
 548+ // build an image tag with the correct url and width
 549+ var $img = $( '<img/>' )
 550+ .attr( 'src', page.imageinfo[0].url )
 551+ .attr( 'width', $.wikiLove.currentTypeOrSubtype.gallery.width )
 552+ .hide()
 553+ .load( function() { $( this ).css( 'display', 'inline-block' ); } );
 554+
 555+ // append the image to the gallery and also make sure it's selectable
 556+ $( '#mw-wikilove-gallery-content' ).append(
 557+ $( '<a href="#"></a>' )
 558+ .attr( 'id', 'mw-wikilove-gallery-img-' + i )
 559+ .append( $img )
 560+ .click( function( e ) {
 561+ e.preventDefault();
 562+ $( '#mw-wikilove-gallery a' ).removeClass( 'selected' );
 563+ $( this ).addClass( 'selected' );
 564+ $( '#mw-wikilove-image' ).val( $.wikiLove.gallery[$( this ).attr( 'id' )] );
 565+ })
 566+ );
 567+
 568+ // save the page title into an array so we know which image id maps to which title
 569+ $.wikiLove.gallery['mw-wikilove-gallery-img-' + i] = page.title;
 570+ break;
 571+ }
 572+ }
 573+ }
 574+ }
 575+ if( $.wikiLove.gallery.length <= 0 ) {
 576+ $( '#mw-wikilove-gallery' ).hide();
 577+ $( '#mw-wikilove-gallery-label' ).hide();
 578+ }
 579+
 580+ $( '#mw-wikilove-gallery-spinner' ).fadeOut( 200 );
 581+ }
 582+ });
 583+ },
 584+
 585+ /*
 586+ * Init function which is called upon page load. Binds the WikiLove icon to opening the dialog.
 587+ */
 588+ init: function() {
 589+ $( '#ca-wikilove a' ).click( function( e ) {
 590+ $.wikiLove.openDialog();
 591+ e.preventDefault();
 592+ });
 593+ }
 594+};
 595+
 596+$( document ).ready( $.wikiLove.init );
 597+} ) ( jQuery );
Property changes on: trunk/extensions/WikiLove/modules/ext.wikiLove/ext.wikiLove.core.js
___________________________________________________________________
Added: svn:eol-style
1598 + native

Status & tagging log