Tweaks, code style, clearer apis, various fixes
This commit is contained in:
parent
826ac1a4e1
commit
66823ebd5b
@ -103,7 +103,7 @@ select .afch-input {
|
||||
margin: 0px;
|
||||
padding: 5px;
|
||||
vertical-align: middle;
|
||||
width: 30%;
|
||||
width: 25%;
|
||||
min-width: 150px;
|
||||
}
|
||||
|
||||
@ -233,10 +233,6 @@ div.disabled-button {
|
||||
border-color: #FFDC00;
|
||||
}
|
||||
|
||||
.comment #afchContent {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#commentText {
|
||||
height: 100px;
|
||||
width: 60%;
|
||||
@ -244,7 +240,7 @@ div.disabled-button {
|
||||
|
||||
/* TAG FOR G13 DELETION */
|
||||
|
||||
.tag-g13 {
|
||||
.g13 {
|
||||
background-color: #FF851B; /* orange */
|
||||
border-color: #FF851B;
|
||||
}
|
||||
|
@ -114,6 +114,10 @@
|
||||
|
||||
this.additionalData = {};
|
||||
|
||||
this.toString = function () {
|
||||
return this.rawTitle;
|
||||
};
|
||||
|
||||
this.getText = function ( usecache ) {
|
||||
var deferred = $.Deferred();
|
||||
|
||||
@ -165,6 +169,7 @@
|
||||
|
||||
if ( this.additionalData.creator ) {
|
||||
deferred.resolve( this.additionalData.creator );
|
||||
return deferred;
|
||||
}
|
||||
|
||||
request = {
|
||||
@ -294,8 +299,10 @@
|
||||
token: AFCH.consts.editToken
|
||||
};
|
||||
|
||||
// Depending on mode, set appendtext=text or prependtext=text,
|
||||
// which overrides the default text option
|
||||
if ( options.mode ) {
|
||||
request[options.mode] = true;
|
||||
request[options.mode] = options.contents;
|
||||
}
|
||||
|
||||
AFCH.api.post( request )
|
||||
@ -338,16 +345,16 @@
|
||||
* - hide: {bool}, default false
|
||||
* @return {$.Deferred} Resolves with success/failure
|
||||
*/
|
||||
notifyUser: function ( user, data ) {
|
||||
notifyUser: function ( user, options ) {
|
||||
var deferred = $.Deferred(),
|
||||
userTalkPage = new mw.Title( user, 3 ); // User talk namespace
|
||||
|
||||
AFCH.actions.editPage( userTalkPage.getPrefixedText(), {
|
||||
contents: data.message,
|
||||
summary: data.summary,
|
||||
contents: options.message,
|
||||
summary: options.summary || 'Notifying user',
|
||||
mode: 'appendtext',
|
||||
statusText: 'Notifying',
|
||||
hide: data.hide || false
|
||||
hide: options.hide
|
||||
} )
|
||||
.done( function () {
|
||||
deferred.resolve();
|
||||
|
@ -93,7 +93,7 @@
|
||||
commentTemplates.push( {
|
||||
// If we can't find a timestamp, set it to unicorns, because everyone
|
||||
// knows that unicorns always come first.
|
||||
timestamp: AFCH.parseForTimestamp( template.params['1'] ) || 'unicorns',
|
||||
timestamp: AFCH.parseForTimestamp( template.params['1'], /* mwstyle */ true ) || 'unicorns',
|
||||
text: template.params['1']
|
||||
} );
|
||||
}
|
||||
@ -135,14 +135,14 @@
|
||||
// Useful list of "what to do" in each situation.
|
||||
var statusCases = {
|
||||
// Declined
|
||||
'd': function () {
|
||||
d: function () {
|
||||
if ( !sub.isPending && !sub.isDraft && !sub.isUnderReview ) {
|
||||
sub.isDeclined = true;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
// Draft
|
||||
't': function () {
|
||||
t: function () {
|
||||
// If it's been submitted or declined, remove draft tag
|
||||
if ( sub.isPending || sub.isDeclined || sub.isUnderReview ) {
|
||||
return false;
|
||||
@ -151,7 +151,7 @@
|
||||
return true;
|
||||
},
|
||||
// Under review
|
||||
'r': function () {
|
||||
r: function () {
|
||||
if ( !sub.isPending && !sub.isDeclined ) {
|
||||
sub.isUnderReview = true;
|
||||
}
|
||||
@ -342,7 +342,7 @@
|
||||
{
|
||||
this.addNewTemplate( {
|
||||
status: newStatus,
|
||||
params: newParams || {}
|
||||
params: newParams
|
||||
} );
|
||||
} else {
|
||||
// Just modify the template at the top of the stack. Update its
|
||||
@ -382,16 +382,15 @@
|
||||
|
||||
/**
|
||||
* Add a new comment to the beginning of this.comments
|
||||
* @param {object} data object with properties of template
|
||||
* - text (default: '')
|
||||
* @param {string} text comment text
|
||||
* @return {bool} success
|
||||
*/
|
||||
AFCH.Submission.prototype.addNewComment = function ( data ) {
|
||||
this.comments.unshift( $.extend( {
|
||||
AFCH.Submission.prototype.addNewComment = function ( text ) {
|
||||
this.comments.unshift( {
|
||||
// Unicorns are explained in loadDataFromTemplates()
|
||||
timestamp: AFCH.parseForTimestamp( data.text ) || 'unicorns',
|
||||
text: ''
|
||||
}, data ) );
|
||||
timestamp: AFCH.parseForTimestamp( text, /* mwstyle */ true ) || 'unicorns',
|
||||
text: text
|
||||
} );
|
||||
|
||||
// Reparse :P
|
||||
this.sortAndParseInternalData();
|
||||
@ -589,8 +588,6 @@
|
||||
afchSubmission.parse(),
|
||||
loadViews
|
||||
).then( function ( submission ) {
|
||||
AFCH.log( 'rendering main view...' );
|
||||
|
||||
// Render the base buttons view
|
||||
loadView( 'main', {
|
||||
title: submission.shortTitle,
|
||||
@ -897,7 +894,7 @@
|
||||
newParams['3'] = data.declineTextarea;
|
||||
// But otherwise if addtional text has been entered we just add it as a new comment
|
||||
} else if ( data.declineTextarea ) {
|
||||
afchSubmission.addNewComment( { text: data.declineTextarea } );
|
||||
afchSubmission.addNewComment( data.declineTextarea );
|
||||
}
|
||||
|
||||
// If a user has entered something in the declineTextfield (for example, a URL or an
|
||||
@ -906,10 +903,13 @@
|
||||
newParams['3'] = data.declineTextfield;
|
||||
}
|
||||
|
||||
// FIXME: Handle blanking and csd-ing!
|
||||
|
||||
// Now update the submission status
|
||||
afchSubmission.setStatus( 'd', newParams );
|
||||
|
||||
text.updateAfcTemplates( afchSubmission.makeWikicode() );
|
||||
text.cleanUp();
|
||||
|
||||
afchPage.edit( {
|
||||
contents: text.get(),
|
||||
@ -931,11 +931,12 @@
|
||||
|
||||
function handleComment ( data ) {
|
||||
var text = data.afchText,
|
||||
comment = data.commentText + ' ~~~~';
|
||||
comment = $.trim( data.commentText ) + ' ~~~~';
|
||||
|
||||
afchSubmission.addNewComment( { text: comment } );
|
||||
afchSubmission.addNewComment( comment );
|
||||
text.updateAfcTemplates( afchSubmission.makeWikicode() );
|
||||
|
||||
text.cleanUp();
|
||||
afchPage.edit( {
|
||||
contents: text.get(),
|
||||
summary: 'Commenting on submission'
|
||||
@ -974,6 +975,7 @@
|
||||
afchSubmission.setStatus( '', { u: submitter } );
|
||||
|
||||
text.updateAfcTemplates( afchSubmission.makeWikicode() );
|
||||
text.cleanUp();
|
||||
|
||||
afchPage.edit( {
|
||||
contents: text.get(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user