http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88358
Revision: 88358
Author: kaldari
Date: 2011-05-17 22:25:59 +0000 (Tue, 17 May 2011)
Log Message:
-----------
refactored to depend less on templates, you can now build most items with just
an image and text
Modified Paths:
--------------
trunk/extensions/WikiLove/WikiLove.api.php
trunk/extensions/WikiLove/WikiLove.php
trunk/extensions/WikiLove/patches/WikiLoveLog.sql
trunk/extensions/WikiLove/wikiLove.css
trunk/extensions/WikiLove/wikiLove.js
Added Paths:
-----------
trunk/extensions/WikiLove/defaultTypes.js
Modified: trunk/extensions/WikiLove/WikiLove.api.php
===================================================================
--- trunk/extensions/WikiLove/WikiLove.api.php 2011-05-17 22:19:27 UTC (rev
88357)
+++ trunk/extensions/WikiLove/WikiLove.api.php 2011-05-17 22:25:59 UTC (rev
88358)
@@ -15,10 +15,6 @@
$this->dieUsageMsg( array( 'invalidtitle',
$params['title'] ) );
}
- if ( strlen( $params['template'] ) > 0 && stripos(
$params['text'], $params['template'] ) === false ) {
- $this->dieUsage( 'Template could not be found in the
message!', 'invalidtemplate' );
- }
-
if ( $wgWikiLoveLogging ) {
$this->saveInDb( $talk, $params['subject'],
$params['text'], $params['type'], $params['template'] );
}
@@ -48,7 +44,6 @@
* @param $subject
* @param $text
* @param $type
- * @param $template
* @return void
*/
private function saveInDb( $talk, $subject, $text, $type, $template ) {
@@ -59,7 +54,6 @@
'wl_sender_id' => $wgUser->getId(),
'wl_receiver_id' => User::newFromName(
$talk->getSubjectPage()->getBaseText() )->getId(),
'wl_type' => $type,
- 'wl_template' => $template,
'wl_subject' => $subject,
'wl_message' => $text,
'wl_email' => 0,
@@ -90,9 +84,6 @@
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => true,
),
- 'template' => array(
- ApiBase::PARAM_TYPE => 'string',
- ),
'type' => array(
ApiBase::PARAM_TYPE => 'string',
),
@@ -102,10 +93,9 @@
public function getParamDescription() {
return array(
'title' => 'Title of the user or user talk page to send
WikiLove to',
- 'text' => 'Raw ikitext to add in the new section',
+ 'text' => 'Raw wikitext to add in the new section',
'token' => 'Edit token. You can get one of these
through prop=info',
'subject' => 'Subject header of the new section',
- 'template' => 'Template name used in the wikitext (for
statistics)',
'type' => array( 'Type of WikiLove (for statistics);
this corresponds with a type',
'selected in the left menu, and
optionally a subtype after that',
'(e.g. "barnstar-normal" or "kitten")',
@@ -117,9 +107,9 @@
return array(
'Give WikiLove to another user.',
"WikiLove is a positive message posted to a user's talk
page through a",
- 'convenient interface with preset images and templates.
This action adds',
- 'the specified wikitext to a certain talk page. For
statistical purposes,',
- 'the type and template (among the other data) are
logged.',
+ 'convenient interface with preset or locally defined
templates. This action',
+ 'adds the specified wikitext to a certain talk page.
For statistical purposes,',
+ 'the type and other data are logged.',
);
}
@@ -130,10 +120,6 @@
'code' => 'nologging',
'info' => 'Warning: action was not logged!'
),
- array(
- 'code' => 'invalidtemplate',
- 'info' => 'Template could not be found in the
message!'
- ),
) );
}
Modified: trunk/extensions/WikiLove/WikiLove.php
===================================================================
--- trunk/extensions/WikiLove/WikiLove.php 2011-05-17 22:19:27 UTC (rev
88357)
+++ trunk/extensions/WikiLove/WikiLove.php 2011-05-17 22:25:59 UTC (rev
88358)
@@ -80,7 +80,10 @@
$wgResourceModules += array(
'ext.wikiLove' => $wikiLoveTpl + array(
- 'scripts' => 'wikiLove.js',
+ 'scripts' => array(
+ 'wikiLove.js',
+ 'defaultTypes.js',
+ ),
'styles' => 'wikiLove.css',
'messages' => array(
'wikilove-dialog-title',
@@ -90,7 +93,8 @@
'wikilove-get-started-list-2',
'wikilove-get-started-list-3',
'wikilove-add-details',
- 'wikilove-gallery',
+ 'wikilove-image',
+ 'wikilove-header',
'wikilove-title',
'wikilove-enter-message',
'wikilove-omit-sig',
@@ -98,10 +102,12 @@
'wikilove-preview',
'wikilove-button-send',
'wikilove-type-makeyourown',
+ 'wikilove-err-header',
'wikilove-err-title',
'wikilove-err-msg',
'wikilove-err-image',
'wikilove-err-sig',
+ 'wikilove-barnstar-header',
),
'dependencies' => array(
'jquery.ui.dialog',
Added: trunk/extensions/WikiLove/defaultTypes.js
===================================================================
--- trunk/extensions/WikiLove/defaultTypes.js (rev 0)
+++ trunk/extensions/WikiLove/defaultTypes.js 2011-05-17 22:25:59 UTC (rev
88358)
@@ -0,0 +1,57 @@
+$.wikiLove.types = {
+ // example type, could be removed later (also no i18n)
+ 'barnstar': {
+ name: 'Barnstar', // name of the type (appears in the types
menu)
+ fields: [ 'header', 'title', 'image' ], // fields to ask for in
form if not specified in config
+ select: 'Select a barnstar:', // subtype select label
+ subtypes: { // some different subtypes
+ // note that when not using subtypes you should use
these subtype options
+ // for the top-level type
+ 'original': {
+ option: 'Original barnstar', // option listed
in the select list
+ 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
+ header: mw.msg( 'wikilove-barnstar-header' ),
// header that appears at the top of the talk page post (optional)
+ title: 'The Original Barnstar', // title that
appears inside the award box (optional)
+ image: 'Original Barnstar Hires.png', // image
for the award
+ mail: 'Hello $7!\n\nI just awarded you a
barnstar.' // message to use in email notification; $7 is replaced by the
recipient's username
+ },
+ 'editors': {
+ option: 'Editor\'s barnstar',
+ descr: 'The Editor\'s Barnstar is awarded to
individuals who display particularly fine decisions in general editing.',
+ header: mw.msg( 'wikilove-barnstar-header' ),
+ title: 'The Editor\'s Barnstar',
+ image: 'Editors Barnstar Hires.png',
+ mail: 'Hello $7!\n\nI just awarded you a
barnstar.'
+ },
+ 'tireless': {
+ option: 'Tireless contributor barnstar',
+ descr: 'The Tireless Contributor Barnstar is
awarded to especially tireless Wikipedians who contribute an especially large
body of work without sacrificing quality.',
+ header: mw.msg( 'wikilove-barnstar-header' ),
+ title: 'The Editor\'s Barnstar',
+ image: 'Tireless Contributor Barnstar
Hires.gif',
+ mail: 'Hello $7!\n\nI just awarded you a
barnstar.'
+ }
+ },
+ showNotify: true, // add email notices as an option for each
award of this type
+ icon: mw.config.get( 'wgServer' ) + mw.config.get(
'wgScriptPath' ) +
'/extensions/WikiLove/images/icons/wikilove-icon-barnstar.png' // icon for
left-side menu
+ },
+ 'cats': {
+ name: 'Cat',
+ fields: [ 'header' ],
+ header: 'A kitten for you!',
+ text: '[[$3|left|150px]]\n$1\n\n~~~~\n<br style="clear:
both"/>', // $3 is the image filename
+ gallery: {
+ // right now we can only query the local wiki (not e.g.
commons)
+ category: 'Category:Cats',
+ total: 100, // total number of pictures to retrieve,
and to randomise
+ num: 3, // number of pictures to show from the
randomised set
+ width: 145 // width of each picture in pixels in the
interface (not in the template)
+ }
+ },
+ // default type, nice to leave this one in place when adding other types
+ 'makeyourown': {
+ name: mw.msg( 'wikilove-type-makeyourown' ),
+ fields: [ 'header', 'title', 'image' ],
+ imageSize: '150px'
+ }
+}
\ No newline at end of file
Modified: trunk/extensions/WikiLove/patches/WikiLoveLog.sql
===================================================================
--- trunk/extensions/WikiLove/patches/WikiLoveLog.sql 2011-05-17 22:19:27 UTC
(rev 88357)
+++ trunk/extensions/WikiLove/patches/WikiLoveLog.sql 2011-05-17 22:25:59 UTC
(rev 88358)
@@ -9,7 +9,6 @@
`wl_sender_id` int(11) NOT NULL,
`wl_receiver_id` int(11) NOT NULL,
`wl_type` varchar(64) NOT NULL,
- `wl_template` varchar(64) NOT NULL,
`wl_subject` varchar(255) NOT NULL,
`wl_message` blob NOT NULL,
`wl_email` bool NOT NULL default '0'
Modified: trunk/extensions/WikiLove/wikiLove.css
===================================================================
--- trunk/extensions/WikiLove/wikiLove.css 2011-05-17 22:19:27 UTC (rev
88357)
+++ trunk/extensions/WikiLove/wikiLove.css 2011-05-17 22:25:59 UTC (rev
88358)
@@ -244,7 +244,7 @@
width: 300px;
}
-#wikiLoveDialog #wlAddDetails .wlOmitSig {
+#wikiLoveDialog #wlAddDetails .wlNote {
font-weight: light;
font-size: 0.9em;
float: right;
@@ -255,13 +255,9 @@
resize: none;
}
-#wikiLoveDialog #wlAddDetails #wlNotify {
- float: left;
-}
-
#wikiLoveDialog .wlSpinner {
float: right;
- margin-top: 6px;
+ margin-top: 0.9em;
display: none;
}
@@ -292,6 +288,9 @@
#wikiLoveDialog #wlGallerySpinner .wlSpinner {
float: none;
position: absolute;
+ top: 0;
+ left: 50%;
+ margin-left: -8px;
z-index: -1;
}
@@ -320,6 +319,12 @@
display: block;
}
+#wikiLoveDialog #wlSubtypeDescription {
+ margin: 5px 0px 8px 15px;
+ font-size: 1.0em;
+ line-height: 1.2em;
+}
+
#wikiLoveDialog input[type=checkbox] {
display:inline-box;
margin: 5px 0px 5px 0px;
Modified: trunk/extensions/WikiLove/wikiLove.js
===================================================================
--- trunk/extensions/WikiLove/wikiLove.js 2011-05-17 22:19:27 UTC (rev
88357)
+++ trunk/extensions/WikiLove/wikiLove.js 2011-05-17 22:25:59 UTC (rev
88358)
@@ -1,51 +1,5 @@
( function( $ ) { $.wikiLove = {
- types: {
- // example type, could be removed later (also no i18n)
- 'barnstar': {
- descr: 'Barnstar', // description in the types menu
- select: 'Select a barnstar:', // subtype select label
- subtypes: { // some different subtypes
- // note that when not using subtypes you should
use these subtype options
- // for the top-level type
- 'original': {
- title: 'An Original Barnstar for you!',
// subject title for the message
- descr: 'Original barnstar', //
description in the menu
- text: '{{subst:The Original Barnstar|$1
~~~~}}', // message text, $1 is replaced by the user message
- template: 'The Original Barnstar', //
template that is used, for statistics
- mail: 'Hello $2!\n\nI just awarded you
a barnstar.' // message to use in email notification; $2 is replaced by the
recipient's username
- },
- 'special': {
- title: null, // no predefined title,
allows the user to enter a title
- descr: 'Special barnstar',
- text: '{{subst:The Special Barnstarl|$1
~~~~}}',
- template: 'The Special Barnstar',
- mail: 'Hello $2!\n\nI just awarded you
the special barnstar.'
- }
- },
- showNotify: true, // add email notices as an option for
each award of this type
- icon: mw.config.get( 'wgServer' ) + mw.config.get(
'wgScriptPath' ) +
'/extensions/WikiLove/images/icons/wikilove-icon-barnstar.png'
- },
- 'cat': {
- descr: 'Cat',
- title: null,
- text: '[[$3|left|150px]]\n$1\n\n~~~~\n<br style="clear:
both"/>', // $3 is the image filename
- template: '',
- gallery: {
- // right now we can only query the local wiki
(not e.g. commons)
- category: 'Category:Cats',
- total: 100, // total number of pictures to
retrieve, and to randomise
- num: 3, // number of pictures to show from the
randomised set
- width: 145 // width of each picture in pixels
in the interface (not in the template)
- }
- },
- // default type, nice to leave this one in place when adding
other types
- 'makeyourown': {
- title: null,
- descr: mw.msg( 'wikilove-type-makeyourown' ),
- text: "$1",
- template: ''
- }
- },
+
$dialog: null, // dialog jQuery object
editToken: '', // edit token used for the final AJAX call
currentTypeId: null, // id of the currently selected type (e.g.
'barnstar' or 'makeyourown')
@@ -54,7 +8,15 @@
previewData: null, // data of the currently previewed thing is set here
emailable: false,
gallery: {},
- imageTitle: '',
+ defaultText: '{| style="background-color: $5; border: 1px solid $6;"\n\
+|rowspan="2" style="vertical-align: middle; padding: 5px;" | [[Image:$3|$4]]\n\
+|style="font-size: x-large; padding: 3px; height: 1.5em;" | \'\'\'$2\'\'\'\n\
+|-\n\
+|style="vertical-align: middle; padding: 3px;" | $1 ~~~~\n\
+|}',
+ defaultBackgroundColor: '#fdffe7',
+ defaultBorderColor: '#fceb92',
+ defaultImageSize: '100px',
/*
* Opens the dialog and builds it if necessary.
@@ -62,8 +24,8 @@
openDialog: function() {
if ( $.wikiLove.$dialog === null ) {
// Load local configuration
- var wikiLoveConfigUrl = wgServer + wgScript + '?' +
$.param( { 'title': 'MediaWiki:WikiLove.js', 'action': 'raw', 'ctype':
'text/javascript' } );
- mw.loader.load( wikiLoveConfigUrl );
+ //var wikiLoveConfigUrl = wgServer + wgScript + '?' +
$.param( { 'title': 'MediaWiki:WikiLove.js', 'action': 'raw', 'ctype':
'text/javascript' } );
+ //mw.loader.load( wikiLoveConfigUrl );
// Find out if we can email the user
$.wikiLove.getEmailable();
@@ -86,7 +48,7 @@
$buttonInside.addClass( 'wlNoIcon' );
}
- $buttonInside.append( '<div
class="wlLinkText">' + $.wikiLove.types[typeId].descr + '</div>' );
+ $buttonInside.append( '<div
class="wlLinkText">' + $.wikiLove.types[typeId].name + '</div>' );
$button.append( '<div
class="wlLeftCap"></div>');
$button.append( $buttonInside );
@@ -113,16 +75,21 @@
var $addDetails = $( '<div id="wlAddDetails"></div>' )
.append( '<span class="wlNumber">2</span>' )
.append( '<h3>' + mw.msg(
'wikilove-add-details' ) + '</h3>' )
- .append( '<label for="wlSubtype"
id="wlSubtypeLabel"></label>' )
.append( $( '<form id="wlPreviewForm"></form>' )
+ .append( '<label for="wlSubtype"
id="wlSubtypeLabel"></label>' )
.append( '<select
id="wlSubtype"></select>' )
- .append( '<label id="wlGalleryLabel">'
+ mw.msg( 'wikilove-gallery' ) + '</label>' )
+ .append( '<div
id="wlSubtypeDescription"/>' )
+ .append( '<label id="wlGalleryLabel">'
+ mw.msg( 'wikilove-image' ) + '</label>' )
.append( '<div id="wlGallerySpinner">'
+ spinner + '</div>' )
.append( '<div id="wlGallery"/>' )
- .append( '<label for="wlTitle"
id="wlTitleLabel">' + mw.msg( 'wikilove-title' ) + '</label>' )
+ .append( '<label for="wlHeader"
id="wlHeaderLabel">' + mw.msg( 'wikilove-header' ) + '</label>' )
+ .append( '<input type="text"
class="text" id="wlHeader"/>' )
+ .append( '<label for="wlTitle"
id="wlTitleLabel">' + mw.msg( 'wikilove-title' ) + '</label>' )
.append( '<input type="text"
class="text" id="wlTitle"/>' )
- .append( '<label for="wlMessage"
id="wlMessageLabel">' + mw.msg( 'wikilove-enter-message' ) + '</label>' )
- .append( '<span class="wlOmitSig">' +
mw.msg( 'wikilove-omit-sig' ) + '</span>' )
+ .append( '<label for="wlImage"
id="wlImageLabel">' + mw.msg( 'wikilove-image' ) + '</label>' )
+ .append( '<input type="text"
class="text" id="wlImage"/>' )
+ .append( '<label for="wlMessage"
id="wlMessageLabel">' + mw.msg( 'wikilove-enter-message' ) + '</label>' )
+ .append( '<span class="wlNote">' +
mw.msg( 'wikilove-omit-sig' ) + '</span>' )
.append( '<textarea
id="wlMessage"></textarea>' )
.append( $('<div
id="wlNotify"></div>').html('<input type="checkbox" id="wlNotifyCheckbox"
name="notify"/> <label for="wlNotifyCheckbox">Notify user by email</label>') )
.append( $('<button class="submit"
id="wlButtonPreview" type="submit"></button>').button({ label: mw.msg(
'wikilove-button-preview' ), icons: { primary:'ui-icon-search' } }) )
@@ -149,6 +116,7 @@
.append( $preview )
.dialog({
width: 800,
+ position: ['center', 80],
autoOpen: false,
title: mw.msg( 'wikilove-dialog-title'
),
modal: true,
@@ -190,7 +158,7 @@
// add all the subtypes to the menu
while setting their subtype ids in jQuery data
var subtype =
$.wikiLove.types[$.wikiLove.currentTypeId].subtypes[subtypeId];
$( '#wlSubtype' ).append(
- $( '<option>' + subtype.descr +
'</option>' ).data( 'subtypeId', subtypeId )
+ $( '<option>' + subtype.option
+ '</option>' ).data( 'subtypeId', subtypeId )
);
}
$( '#wlSubtype' ).show();
@@ -225,6 +193,7 @@
$.wikiLove.currentSubtypeId = newSubtypeId;
$.wikiLove.currentTypeOrSubtype =
$.wikiLove.types[$.wikiLove.currentTypeId]
.subtypes[$.wikiLove.currentSubtypeId];
+ $( '#wlSubtypeDescription' ).html(
$.wikiLove.currentTypeOrSubtype.descr );
$.wikiLove.updateAllDetails();
$( '#wlPreview' ).hide();
$.wikiLove.previewData = null;
@@ -259,30 +228,64 @@
},
/*
- * Called when type or subtype changes, updates controls. Currently
only updates title label and textbox.
+ * Called when type or subtype changes, updates controls.
*/
updateAllDetails: function() {
$( '#wikiLoveDialog' ).find( '.wlError' ).remove();
+ // only show the description if it exists for this type or
subtype
+ if( typeof $.wikiLove.currentTypeOrSubtype.descr == 'string' ) {
+ $( '#wlSubtypeDescription').show();
+ } else {
+ $( '#wlSubtypeDescription').hide();
+ }
+
+ // show or hide header label and textbox depending on whether a
predefined header exists
+ var needsHeader = $.inArray( 'header',
$.wikiLove.types[$.wikiLove.currentTypeId].fields );
+ if( typeof $.wikiLove.currentTypeOrSubtype.header == 'string'
|| needsHeader == -1 ) {
+ $( '#wlHeaderLabel').hide();
+ $( '#wlHeader' ).hide();
+ $( '#wlHeader' ).val(
$.wikiLove.currentTypeOrSubtype.header );
+ } else if ( needsHeader != -1 ) {
+ $( '#wlHeaderLabel').show();
+ $( '#wlHeader' ).show();
+ $( '#wlHeader' ).val( '' );
+ }
+
// show or hide title label and textbox depending on whether a
predefined title exists
- if( typeof $.wikiLove.currentTypeOrSubtype.title == 'string' ) {
+ var needsTitle = $.inArray( 'title',
$.wikiLove.types[$.wikiLove.currentTypeId].fields );
+ if( typeof $.wikiLove.currentTypeOrSubtype.title == 'string' ||
needsTitle == -1 ) {
$( '#wlTitleLabel').hide();
$( '#wlTitle' ).hide();
$( '#wlTitle' ).val(
$.wikiLove.currentTypeOrSubtype.title );
- } else {
+ } else if ( needsTitle != -1 ) {
$( '#wlTitleLabel').show();
$( '#wlTitle' ).show();
$( '#wlTitle' ).val( '' );
}
+ // show or hide image label and textbox depending on whether a
predefined image exists
+ var needsTitle = $.inArray( 'image',
$.wikiLove.types[$.wikiLove.currentTypeId].fields );
+ if( typeof $.wikiLove.currentTypeOrSubtype.image == 'string' ||
needsTitle == -1 ) {
+ $( '#wlImageLabel').hide();
+ $( '#wlImage' ).hide();
+ $( '#wlImage' ).val(
$.wikiLove.currentTypeOrSubtype.image );
+ } else if ( needsTitle != -1 ) {
+ $( '#wlImageLabel').show();
+ $( '#wlImage' ).show();
+ $( '#wlImage' ).val( '' );
+ }
+
if( typeof $.wikiLove.currentTypeOrSubtype.gallery == 'object'
) {
$( '#wlGalleryLabel' ).show();
$( '#wlGallery' ).show();
+ $( '#wlGallerySpinner' ).show();
$.wikiLove.makeGallery();
}
else {
$( '#wlGalleryLabel' ).hide();
$( '#wlGallery' ).hide();
+ $( '#wlGallerySpinner' ).hide();
}
if( $.wikiLove.types[$.wikiLove.currentTypeId].showNotify ) {
@@ -302,12 +305,12 @@
$( '#wikiLoveDialog' ).find( '.wlError' ).remove();
if( typeof $.wikiLove.currentTypeOrSubtype.gallery == 'object'
) {
- if ( !$.wikiLove.imageTitle ) {
+ if ( $( '#wlImage' ).val().length <= 0 ) {
$.wikiLove.showError( 'wikilove-err-image' );
return false;
}
}
- if( $( '#wlTitle' ).val().length <= 0 ) {
- $.wikiLove.showError( 'wikilove-err-title' ); return
false;
+ if( $( '#wlHeader' ).val().length <= 0 ) {
+ $.wikiLove.showError( 'wikilove-err-header' ); return
false;
}
if( $( '#wlMessage' ).val().length <= 0 ) {
$.wikiLove.showError( 'wikilove-err-msg' ); return
false;
@@ -318,15 +321,24 @@
$.wikiLove.showError( 'wikilove-err-sig' ); return
false;
}
- var msg = $.wikiLove.prepareMsg(
$.wikiLove.currentTypeOrSubtype.text );
+ if ( $.wikiLove.currentTypeOrSubtype.text ) {
+ var text = $.wikiLove.currentTypeOrSubtype.text;
+ } else {
+ var text = $.wikiLove.defaultText;
+ }
+ var msg = $.wikiLove.prepareMsg(
+ text,
+ $.wikiLove.currentTypeOrSubtype.imageSize,
+ $.wikiLove.currentTypeOrSubtype.backgroundColor,
+ $.wikiLove.currentTypeOrSubtype.borderColor
+ );
- $.wikiLove.doPreview( '==' + $( '#wlTitle' ).val() + "==\n" +
msg );
+ $.wikiLove.doPreview( '==' + $( '#wlHeader' ).val() + "==\n" +
msg );
$.wikiLove.previewData = {
- 'title': $( '#wlTitle' ).val(),
+ 'header': $( '#wlHeader' ).val(),
'msg': msg,
'type': $.wikiLove.currentTypeId
+ ($.wikiLove.currentSubtypeId != null ? '-' +
$.wikiLove.currentSubtypeId : ''),
- 'template': $.wikiLove.currentTypeOrSubtype.template,
'notify': $( '#wlNotifyCheckbox:checked' ).val()
};
return false;
@@ -339,21 +351,40 @@
/*
* Prepares a message or e-mail body by replacing placeholders.
* $1: message entered by the user
- * $2: username of the recipient
- * $3: title of the chosen image
+ * $2: title of the item
+ * $3: title of the image
+ * $4: image size
+ * $5: background color
+ * $6: border color
+ * $7: username of the recipient
*/
- prepareMsg: function( msg ) {
- // replace the raw message
- msg = msg.replace( '$1', $( '#wlMessage' ).val() );
+ prepareMsg: function( msg, imageSize, backgroundColor, borderColor ) {
- // replace the username we're sending to
- msg = msg.replace( '$2', wgTitle );
+ msg = msg.replace( '$1', $( '#wlMessage' ).val() ); // replace
the raw message
+ msg = msg.replace( '$2', $( '#wlTitle' ).val() ); // replace
the title
+ msg = msg.replace( '$3', $( '#wlImage' ).val() ); // replace
the image
- // replace the image filename
- if ( $.wikiLove.imageTitle ) {
- msg = msg.replace( '$3', $.wikiLove.imageTitle );
+ if ( imageSize ) {
+ var myImageSize = imageSize;
+ } else {
+ var myImageSize = $.wikiLove.defaultImageSize;
}
+ if ( backgroundColor ) {
+ var myBackgroundColor = backgroundColor;
+ } else {
+ var myBackgroundColor =
$.wikiLove.defaultBackgroundColor;
+ }
+ if ( borderColor ) {
+ var myBorderColor = borderColor;
+ } else {
+ var myBorderColor = $.wikiLove.defaultBorderColor;
+ }
+ msg = msg.replace( '$4', myImageSize ); // replace the image
size
+ msg = msg.replace( '$5', myBackgroundColor ); // replace the
background color
+ msg = msg.replace( '$6', myBorderColor ); // replace the border
color
+ msg = msg.replace( '$7', wgTitle ); // replace the username
we're sending to
+
return msg;
},
@@ -395,15 +426,15 @@
*/
submitSend: function( e ) {
e.preventDefault();
- $.wikiLove.doSend( $.wikiLove.previewData.title,
$.wikiLove.previewData.msg,
- $.wikiLove.previewData.type,
$.wikiLove.previewData.template, $.wikiLove.previewData.notify );
+ $.wikiLove.doSend( $.wikiLove.previewData.header,
$.wikiLove.previewData.msg,
+ $.wikiLove.previewData.type,
$.wikiLove.previewData.notify );
return false;
},
/*
* Fires the final AJAX request and then redirects to the talk page
where the content is added.
*/
- doSend: function( subject, wikitext, type, template, notify ) {
+ doSend: function( subject, wikitext, type, notify ) {
$( '#wlPreview .wlSpinner' ).fadeIn( 200 );
$.ajax({
url: mw.config.get( 'wgServer' ) + mw.config.get(
'wgScriptPath' ) + '/api.php?',
@@ -411,7 +442,6 @@
'action': 'wikiLove',
'format': 'json',
'title': mw.config.get( 'wgPageName' ),
- 'template': template,
'type': type,
'text': wikitext,
'subject': subject,
@@ -505,9 +535,8 @@
.attr(
'src', page.imageinfo[0].url )
.attr(
'width', $.wikiLove.currentTypeOrSubtype.gallery.width )
.hide()
- .load(
function() { $( this ).fadeIn( 400 ); } );
+ .load(
function() { $( this ).css( 'display', 'inline-block' ); } );
-
// append the
image to the gallery and also make sure it's selectable
$( '#wlGallery'
).append(
$( '<a
href="#"></a>' )
@@ -517,7 +546,7 @@
e.preventDefault();
$( '#wlGallery a' ).removeClass( 'selected' );
$( this ).addClass( 'selected' );
-
$.wikiLove.imageTitle = $.wikiLove.gallery[$( this ).attr( 'id' )];
+
$( '#wlImage' ).val( $.wikiLove.gallery[$( this ).attr( 'id' )] );
return false;
})
);
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs