ಮೀಡಿಯವಿಕಿ:Gadget-Twinkle.js: ಪರಿಷ್ಕರಣೆಗಳ ನಡುವಿನ ವ್ಯತ್ಯಾಸ
Content deleted Content added
ಚುNo edit summary |
imported>Amalthea v2.0-270-g1b7f180: welcome: the long-awaited overhaul; warn: use Wikipedia.preview; morebits: new Wikipedia.preview + more; tag: re-add {{expert-subject}}; morebits: destroy SimpleWindow objects when closed; morebits: fix QuickForm subgroup bug |
||
೪೧ ನೇ ಸಾಲು:
Twinkle.defaultConfig.twinkle = {
// General
summaryAd: " ([[
deletionSummaryAd: " ([[
protectionSummaryAd: " ([[
userTalkPageMode: "window",
dialogLargeFont: false,
೧೦೯ ನೇ ಸಾಲು:
Twinkle.defaultConfig.twinkle.portletArea = 'right-navigation';
Twinkle.defaultConfig.twinkle.portletId = 'p-twinkle';
Twinkle.defaultConfig.twinkle.portletName = '
Twinkle.defaultConfig.twinkle.portletType = 'menu';
Twinkle.defaultConfig.twinkle.portletNext = 'p-search';
೧೩೧ ನೇ ಸಾಲು:
topWelcomes: false,
watchWelcomes: true,
insertUsername: true,
quickWelcomeMode: "norm",
quickWelcomeTemplate: "welcome",
Line ೧೪೨ ⟶ ೧೩೯:
markTalkbackAsMinor: true,
insertTalkbackSignature: true, // always sign talkback templates
talkbackHeading: "
adminNoticeHeading: "Notice",
// Shared
Line ೭೮೯ ⟶ ೭೮೬:
"disputed": "article has questionable factual accuracy",
"essay-like": "article is written like an essay and needs cleanup",
"expert-subject": "article needs attention from an expert on the subject",
"external links": "article's external links may not follow content policies or guidelines",
"fansite": "article resembles a fansite",
Line ೮೯೯ ⟶ ೮೯೭:
"Information and detail": [
"context",
"expert-subject",
"metricate",
"overly detailed",
Line ೨,೦೪೯ ⟶ ೨,೦೪೮:
Twinkle.welcome.callback = function friendlywelcomeCallback( uid ) {
if( uid === mw.config.get('wgUserName') && !confirm( 'Are you really sure you want to welcome yourself?...' ) ){
return;
}
var Window = new SimpleWindow( 600,
Window.setTitle( "Welcome user" );
Window.setScriptName( "
Window.addFooterLink( "Welcoming Committee", "WP:WC" );
Window.addFooterLink( "Twinkle help", "WP:TW/DOC#welcome" );
var form = new QuickForm( Twinkle.welcome.callback.evaluate
form.append({
type: 'select',
name: 'type',
label: 'Type of welcome: ',
event: Twinkle.welcome.populateWelcomeList,
list: [
{ type: 'option', value: 'standard', label: 'Standard welcomes', selected: !isIPAddress(mw.config.get('wgTitle')) },
{ type: 'option', value: 'anonymous', label: 'IP user welcomes', selected: isIPAddress(mw.config.get('wgTitle')) },
{ type: 'option', value: 'wikiProject', label: 'WikiProject welcomes' },
{ type: 'option', value: 'nonEnglish', label: 'Non-English welcomes' }
]
});
form.append( { type: 'div', id: 'welcomeWorkArea' } );
form.append( {
type: 'input',
name: 'article',
label: '* Linked article (if supported by template):',
value:( QueryString.exists( 'vanarticle' ) ? QueryString.get( 'vanarticle' ) : '' ),
tooltip: 'An article might be linked
} );
var previewlink = document.createElement( 'a' );
$(previewlink).click(function(){
Twinkle.welcome.callbacks.preview(result); // |result| is defined below
});
previewlink.style.cursor = "pointer";
previewlink.textContent = 'Preview';
form.append( { type: 'div', name: 'welcomepreview', label: [ previewlink ] } );
form.append( { type: 'submit' } );
var result = form.render();
Window.setContent( result );
Window.display();
// initialize the welcome list
var evt = document.createEvent( "Event" );
evt.initEvent( 'change', true, true );
result.type.dispatchEvent( evt );
};
Twinkle.welcome.populateWelcomeList = function(e) {
var type = e.target.value;
var $workarea = $(e.target.form).find("div#welcomeWorkArea");
var div = new QuickForm.element({
type: "div",
id: "welcomeWorkArea"
});
if ((type === "standard" || type === "anonymous") && Twinkle.getFriendlyPref("customWelcomeList").length) {
div.append({ type: 'header', label: 'Custom welcome templates' });
div.append({
type: 'radio',
name: 'template',
list: Twinkle.getFriendlyPref("customWelcomeList"),
event: Twinkle.welcome.selectTemplate
});
}
// the first radio button under each type should be automatically checked
var checkedFirst = false;
var appendTemplates = function(list) {
div.append({
type: 'radio',
name: 'template',
list: list.map(function(obj) {
var properties = Twinkle.welcome.templates[obj];
var result = (properties ? {
value: obj,
label: "{{" + obj + "}}: " + properties.description + (properties.linkedArticle ? "\u00A0*" : ""), // U+00A0 NO-BREAK SPACE
tooltip: properties.tooltip, // may be undefined
checked: !checkedFirst
} : {
value: obj,
label: "{{" + obj + "}}",
checked: !checkedFirst
});
if (!checkedFirst) {
checkedFirst = true;
}
return result;
}),
event: Twinkle.welcome.selectTemplate
});
};
switch (type) {
case "standard":
div.append({ type: 'header', label: 'General welcome templates' });
appendTemplates([
"welcome",
"welcome-short",
"welcome-personal",
"welcome-graphical",
"welcome-menu",
"welcome-screen",
"welcome-belated",
"welcome student",
"welcome teacher"
]);
div.append({ type: 'header', label: 'Problem user welcome templates' });
appendTemplates([
"welcomelaws",
"first article",
"welcomevandal",
"welcomenpov",
"welcomespam",
"welcomeunsourced",
"welcomeauto",
"welcome-COI"
]);
break;
case "anonymous":
div.append({ type: 'header', label: 'Anonymous user welcome templates' });
appendTemplates([
"welcome-anon",
"welcome-anon-test",
"welcome-anon-vandal",
"welcome-anon-constructive"
]);
break;
case "wikiProject":
div.append({ type: 'header', label: 'WikiProject-specific welcome templates' });
appendTemplates([
"welcome-au",
"welcome-bio",
"welcome-cal",
"welcome-conserv",
"welcome-cycling",
"welcome-dbz",
"welcome-et",
"welcome-in",
"welcome-de",
"welcome-math",
"welcome-med",
"welcome-no",
"welcome-phys",
"welcome-pl",
"welcome-rugbyunion",
"welcome-ru",
"welcome-starwars",
"welcome-ch",
"welcome-uk",
"welcome-usroads",
"welcome-videogames"
]);
break;
case "nonEnglish":
div.append({ type: 'header', label: 'Non-English welcome templates' });
appendTemplates([
"welcomeen-sq",
"welcomeen-zh",
"welcomeen-nl",
"welcomeen-fi",
"welcomeen-fr",
"welcomeen-de",
"welcomeen-he",
"welcomeen-ja",
"welcomeen-ko",
"welcomeen-mr",
"welcomeen-ml",
"welcomeen-pt",
"welcomeen-ru",
"welcomeen-es",
"welcomeen-sv",
"welcomeen-uk"
]);
break;
}
var rendered = div.render();
rendered.className = "quickform-scrollbox";
$workarea.replaceWith(rendered);
Twinkle.welcome.selectTemplate({ target: e.target.form.template[0] });
};
Twinkle.welcome.selectTemplate = function(e) {
var properties = Twinkle.welcome.templates[e.target.values];
e.target.form.article.disabled = (properties ? !properties.linkedArticle : false);
};
// A list of welcome templates and their properties and syntax
// The four fields that are available are "description", "linkedArticle", "syntax", and "tooltip".
// The three magic words that can be used in the "syntax" field are:
// - $USERNAME$ - replaced by the welcomer's username, depending on user's preferences
// - $ARTICLE$ - replaced by an article name, if "linkedArticle" is true
// - $HEADER$ - adds a level 2 header (most templates already include this)
Twinkle.welcome.templates = {
"welcome": {
description: "standard welcome",
linkedArticle: true,
syntax: "{{subst:welcome|$USERNAME$|art=$ARTICLE$}} ~~~~"
},
"welcome-short": {
linkedArticle: false,
syntax: "{{subst:welcome-short|$USERNAME$}} $EXTRA$ ~~~~"
},
"welcome-personal": {
description: "more personal welcome, including a plate of cookies",
linkedArticle: false,
syntax: "{{subst:welcome-personal|$USERNAME$}} ~~~~"
},
"welcome-graphical": {
description: "colorful welcome message with table of about 20 links",
linkedArticle: false,
syntax: "$HEADER$ {{subst:welcome-graphical|$EXTRA$}}"
},
"welcome-menu": {
linkedArticle: false,
syntax: "$HEADER$ {{subst:welcome-menu}}"
},
"welcome-screen": {
description: "welcome message with clear, annotated table of 10 links",
linkedArticle: false,
syntax: "$HEADER$ {{subst:welcome-screen}}"
},
"welcome-belated": {
description: "welcome for users with more substantial contributions",
linkedArticle: false,
syntax: "{{subst:welcome-belated|$USERNAME$}}"
},
"welcome student": {
description: "welcome for students editing as part of an educational class project",
linkedArticle: false,
syntax: "$HEADER$ {{subst:welcome student|$USERNAME$}} ~~~~"
},
"welcome teacher": {
linkedArticle: false,
syntax: "$HEADER$ {{subst:welcome teacher|$USERNAME$}} ~~~~"
},
"welcomelaws": {
description: "welcome with information about copyrights, NPOV, the sandbox, and vandalism",
linkedArticle: false,
syntax: "{{subst:welcomelaws|$USERNAME$}}"
},
"first article": {
description: "for someone whose first article did not meet page creation guidelines",
linkedArticle: true,
syntax: "{{subst:first article|$ARTICLE$|$USERNAME$}}"
},
"welcomevandal": {
description: "for someone whose initial efforts appear to be vandalism",
linkedArticle: true,
syntax: "{{subst:welcomevandal|$ARTICLE$|$USERNAME$}}"
},
"welcomenpov": {
description: "for someone whose initial efforts do not adhere to the neutral point of view policy",
linkedArticle: true,
syntax: "{{subst:welcomenpov|$ARTICLE$|$USERNAME$}} ~~~~"
},
"welcomespam": {
description: "welcome with additional discussion of anti-spamming policies",
linkedArticle: true,
syntax: "{{subst:welcomespam|$ARTICLE$|$USERNAME$}} ~~~~"
},
"welcomeunsourced": {
description: "for someone whose initial efforts are unsourced",
linkedArticle: true,
syntax: "{{subst:welcomeunsourced|$ARTICLE$|$USERNAME$}} ~~~~"
},
"welcomeauto": {
description: "for someone who created an autobiographical article",
linkedArticle: true,
syntax: "{{subst:welcomeauto|$USERNAME$|art=$ARTICLE$}} ~~~~"
},
"welcome-COI": {
description: "for someone who has edited in areas where they may have a conflict of interest",
linkedArticle: true,
syntax: "{{subst:welcome-COI|$USERNAME$|art=$ARTICLE$}} ~~~~"
},
// ANONYMOUS USER WELCOMES
"welcome-anon": {
description: "for anonymous users; encourages creating an account",
linkedArticle: true,
syntax: "{{subst:welcome-anon|art=$ARTICLE$}} ~~~~"
},
"welcome-anon-test": {
description: "for anonymous users who have performed test edits",
linkedArticle: true,
syntax: "{{subst:welcome-anon-test|$ARTICLE$|$USERNAME$}} ~~~~"
},
"welcome-anon-vandal": {
description: "for anonymous users who have vandalized a page",
linkedArticle: true,
syntax: "{{subst:welcome-anon-vandal|$ARTICLE$|$USERNAME$}}"
},
"welcome-anon-constructive": {
description: "for anonymous users who fight vandalism and edit constructively",
linkedArticle: true,
syntax: "{{subst:welcome-anon-constructive|art=$ARTICLE$}} ~~~~"
},
// WIKIPROJECT-SPECIFIC WELCOMES
"welcome-au": {
description: "welcome for users with an apparent interest in Australia topics",
linkedArticle: false,
syntax: "{{subst:welcome-au}} ~~~~"
},
"welcome-bio": {
description: "welcome for users with an apparent interest in biographical topics",
linkedArticle: false,
syntax: "{{subst:welcome-bio}} ~~~~"
},
"welcome-cal": {
description: "welcome for users with an apparent interest in California topics",
linkedArticle: false,
syntax: "{{subst:welcome-cal}} ~~~~"
},
"welcome-conserv": {
description: "welcome for users with an apparent interest in conservatism topics",
linkedArticle: false,
syntax: "{{subst:welcome-conserv}}"
},
"welcome-cycling": {
linkedArticle: false,
syntax: "{{subst:welcome-cycling}} ~~~~"
},
"welcome-dbz": {
description: "welcome for users with an apparent interest in Dragon Ball topics",
linkedArticle: false,
syntax: "{{subst:welcome-dbz}}"
},
"welcome-et": {
description: "welcome for users with an apparent interest in Estonia topics",
linkedArticle: false,
syntax: "{{subst:welcome-et}}"
},
"welcome-in": {
description: "welcome for users with an apparent interest in India topics",
linkedArticle: false,
syntax: "{{subst:welcome-in}} ~~~~"
},
"welcome-de": {
description: "welcome for users with an apparent interest in Germany topics",
linkedArticle: false,
syntax: "{{subst:welcome-de}} ~~~~"
},
"welcome-math": {
description: "welcome for users with an apparent interest in mathematical topics",
linkedArticle: false,
syntax: "{{subst:welcome-math}} ~~~~"
},
"welcome-med": {
description: "welcome for users with an apparent interest in medicine topics",
linkedArticle: false,
syntax: "{{subst:welcome-med}} ~~~~"
},
"welcome-no": {
description: "welcome for users with an apparent interest in Norway topics",
linkedArticle: false,
syntax: "{{subst:welcome-no}} ~~~~"
},
"welcome-phys": {
description: "welcome for users with an apparent interest in physics topics",
linkedArticle: false,
syntax: "{{subst:welcome-phys}} ~~~~"
},
"welcome-pl": {
description: "welcome for users with an apparent interest in Poland topics",
linkedArticle: false,
syntax: "{{subst:welcome-pl}} ~~~~"
},
"welcome-rugbyunion": {
description: "welcome for users with an apparent interest in rugby union topics",
linkedArticle: false,
syntax: "{{subst:welcome-rugbyunion}} ~~~~"
},
"welcome-ru": {
description: "welcome for users with an apparent interest in Russia topics",
linkedArticle: false,
syntax: "{{subst:welcome-ru}} ~~~~"
},
"welcome-starwars": {
description: "welcome for users with an apparent interest in Star Wars topics",
linkedArticle: false,
syntax: "{{subst:welcome-starwars}} ~~~~"
},
"welcome-ch": {
description: "welcome for users with an apparent interest in Switzerland topics",
linkedArticle: false,
syntax: "{{subst:welcome-ch}} ~~~~"
},
"welcome-uk": {
description: "welcome for users with an apparent interest in Ukraine topics",
linkedArticle: false,
syntax: "{{subst:welcome-uk}} ~~~~"
},
"welcome-usroads": {
description: "welcome for users with an apparent interest in US roads topics",
linkedArticle: false,
syntax: "{{subst:welcome-usroads}}"
},
"welcome-videogames": {
description: "welcome for users with an apparent interest in video game topics",
linkedArticle: false,
syntax: "{{subst:welcome-videogames}}"
},
// NON-ENGLISH WELCOMES
"welcomeen-sq": {
description: "welcome for users whose first language appears to be Albanian",
linkedArticle: false,
syntax: "{{subst:welcomeen-sq}}"
},
"welcomeen-zh": {
description: "welcome for users whose first language appears to be Chinese",
linkedArticle: false,
syntax: "{{subst:welcomeen-zh}}"
},
"welcomeen-nl": {
description: "welcome for users whose first language appears to be Dutch",
linkedArticle: false,
syntax: "{{subst:welcomeen-nl}}"
},
"welcomeen-fi": {
description: "welcome for users whose first language appears to be Finnish",
linkedArticle: false,
syntax: "{{subst:welcomeen-fi}}"
},
"welcomeen-fr": {
description: "welcome for users whose first language appears to be French",
linkedArticle: false,
syntax: "{{subst:welcomeen-fr}}"
},
"welcomeen-de": {
description: "welcome for users whose first language appears to be German",
linkedArticle: false,
syntax: "{{subst:welcomeen-de}}"
},
"welcomeen-he": {
description: "welcome for users whose first language appears to be Hebrew",
linkedArticle: false,
syntax: "{{subst:welcomeen-he}}"
},
"welcomeen-ja": {
description: "welcome for users whose first language appears to be Japanese",
linkedArticle: false,
syntax: "{{subst:welcomeen-ja}}"
},
"welcomeen-ko": {
description: "welcome for users whose first language appears to be Korean",
linkedArticle: false,
syntax: "{{subst:welcomeen-ko}}"
},
"welcomeen-mr": {
description: "welcome for users whose first language appears to be Marathi",
linkedArticle: false,
syntax: "{{subst:welcomeen-mr}}"
},
"welcomeen-ml": {
description: "welcome for users whose first language appears to be Malayalam",
linkedArticle: false,
syntax: "{{subst:welcomeen-ml}}"
},
"welcomeen-pt": {
description: "welcome for users whose first language appears to be Portuguese",
linkedArticle: false,
syntax: "{{subst:welcomeen-pt}}"
},
"welcomeen-ru": {
description: "welcome for users whose first language appears to be Russian",
linkedArticle: false,
syntax: "{{subst:welcomeen-ru}}"
},
"welcomeen-es": {
description: "welcome for users whose first language appears to be Spanish",
linkedArticle: false,
syntax: "{{subst:welcomeen-es}}"
},
"welcomeen-sv": {
description: "welcome for users whose first language appears to be Swedish",
linkedArticle: false,
syntax: "{{subst:welcomeen-sv}}"
},
"welcomeen-uk": {
description: "welcome for users whose first language appears to be Ukrainian",
linkedArticle: false,
syntax: "{{subst:welcomeen-uk}}"
}
};
Twinkle.welcome.getTemplateWikitext = function(template, article) {
var properties = Twinkle.welcome.
if (properties) {
return properties.syntax.
replace("$USERNAME$", Twinkle.getFriendlyPref("insertUsername") ? mw.config.get("wgUserName") : "").
replace("$ARTICLE$", article ? article : "").
replace(/\$HEADER\$\s*/, "== Welcome ==\n\n").
replace("$EXTRA$", ""); // EXTRA is not implemented yet
} else {
return "{{subst:" + template + (article ? ("|art=" + article) : "") + "}} ~~~~";
}
};
Twinkle.welcome.callbacks = {
preview: function(form) {
var previewDialog = new SimpleWindow(750, 400);
previewDialog.setTitle("Welcome template preview");
previewDialog.setScriptName("Welcome user");
previewDialog.setModality(true);
var previewdiv = document.createElement("div");
previewdiv.style.marginLeft = previewdiv.style.marginRight = "0.5em";
previewdiv.style.fontSize = "small";
previewDialog.setContent(previewdiv);
var previewer = new Wikipedia.preview(previewdiv);
previewer.beginRender(Twinkle.welcome.getTemplateWikitext(form.getChecked("template"), form.article.value));
var submit = document.createElement("input");
submit.setAttribute("type", "submit");
submit.setAttribute("value", "Close");
previewDialog.addContent(submit);
previewDialog.display();
$(submit).click(function(e) {
previewDialog.close();
});
},
main: function( pageobj ) {
var params = pageobj.getCallbackParameters();
var
// abort if mode is auto and form is not empty
if( pageobj.exists() && params.mode === 'auto' ) {
Line ೨,೪೨೬ ⟶ ೨,೬೦೬:
return;
}
var welcomeText = Twinkle.welcome.getTemplateWikitext(params.value, params.article);
if( Twinkle.getFriendlyPref('topWelcomes') ) {
text
} else {
text += "\n" + welcomeText;
}
var summaryText = "
" welcome template
pageobj.setPageText(text);
pageobj.setEditSummary(summaryText + Twinkle.getPref('summaryAd'));
pageobj.setWatchlist(Twinkle.getFriendlyPref('watchWelcomes'));
pageobj.setCreateOption('recreate');
Line ೨,೪೯೨ ⟶ ೨,೬೨೬:
Twinkle.welcome.callback.evaluate = function friendlywelcomeCallbackEvaluate(e) {
var form = e.target;
var params = {
value:
article:
mode: 'manual'
};
SimpleWindow.setButtonsEnabled( false );
Status.init(
Wikipedia.actionCompleted.redirect = mw.config.get('wgPageName');
Line ೫,೦೯೪ ⟶ ೫,೨೨೫:
helptip: "Doing so adds to the personal element of welcoming a user - you will be able to see how they are coping as a newbie, and possibly help them.",
type: "boolean"
},
{
Line ೫,೧೧೦ ⟶ ೫,೨೩೦:
label: "Add your username to the template (where applicable)",
helptip: "Some welcome templates have an opening sentence like \"Hi, I'm <username>. Welcome\" etc. If you turn off this option, these templates will not display your username in that way.",
type: "boolean"
},
Line ೧೧,೨೨೨ ⟶ ೧೧,೩೩೬:
previewlink.style.cursor = "pointer";
previewlink.textContent = 'Preview';
more.append( { type: 'div',
more.append( { type: 'div', id: 'twinklewarn-previewbox', style: 'display: none' } );
more.append( { type:'submit', label:'Submit' } );
Line ೧೧,೨೩೦ ⟶ ೧೧,೩೪೫:
Window.display();
result.main_group.root = result;
result.previewer = new Wikipedia.preview($(result).find('div#twinklewarn-previewbox').last()[0]);
// We must init the first choice (General Note);
Line ೧೨,೩೮೦ ⟶ ೧೨,೪೯೬:
$(e.target.root.reason).parent().hide();
e.target.root.previewer.closePreview();
} else if( e.target.root.block_timer ) {
// hide the block-related fields
Line ೧೨,೩೯೮ ⟶ ೧೨,೫೧೪:
$(e.target.root.reason).parent().show();
e.target.root.previewer.closePreview();
}
};
Line ೧೨,೪೭೭ ⟶ ೧೨,೫೯೩:
preview: function(form) {
var templatename = form.sub_group.value;
var templatetext = '{{subst:' + templatename;
Line ೧೨,೫೩೮ ⟶ ೧೨,೬೩೦:
}
form.previewer.beginRender(templatetext);
},
main: function( pageobj ) {
Line ೧೪,೩೬೯ ⟶ ೧೪,೪೪೦:
// Load the modules in the order that the tabs should appears
// User/user talk-related
Twinkle.welcome();
// Deletion
// Maintenance
// Misc. ones last
Twinkle.diff();
Line ೧೪,೩೯೦ ⟶ ೧೪,೪೬೧:
//Twinkle.closer(); -- disabled for the moment, as it is disliked among Twinkle users -- TTO 2011-05-30
Twinkle.delimages();
Twinkle.batchdelete();
Twinkle.batchprotect();
|