MediaWiki:Gadget-Twinkle.js: Difference between revisions

m
1 revision imported: Trying MediaWiki:Gadget-Twinkle.js
(Reverted to revision 36957 by Admin (talk): Reverting back. (TW))
m (1 revision imported: Trying MediaWiki:Gadget-Twinkle.js)
(One intermediate revision by the same user not shown)
Line 15: Line 15:
  *
  *
  * This is AzaToth's Twinkle, the popular script sidekick for newbies, admins, and
  * This is AzaToth's Twinkle, the popular script sidekick for newbies, admins, and
  * every Wikipedian in between. Visit [[SV:TW]] for more information.
  * every Wikipedian in between. Visit [[WP:TW]] for more information.
  */
  */
//<nowiki>


//<nowiki>
/* global Morebits */


( function ( window, document, $, undefined ) { // Wrap with anonymous function
( function ( window, document, $, undefined ) { // Wrap with anonymous function
Line 44: Line 45:
  */
  */
Twinkle.defaultConfig.twinkle = {
Twinkle.defaultConfig.twinkle = {
// General
// General
summaryAd: " ([[SV:TW|TW]])",
summaryAd: " ([[WP:TW|TW]])",
deletionSummaryAd: " ([[SV:TW|TW]])",
deletionSummaryAd: " ([[WP:TW|TW]])",
protectionSummaryAd: " ([[SV:TW|TW]])",
protectionSummaryAd: " ([[WP:TW|TW]])",
userTalkPageMode: "window",
userTalkPageMode: "tab",
dialogLargeFont: false,
dialogLargeFont: false,
// Fluff (revert and rollback)
 
// ARV
spiWatchReport: "yes",
 
// Block
blankTalkpageOnIndefBlock: false,
 
// Fluff (revert and rollback)
openTalkPage: [ "agf", "norm", "vand" ],
openTalkPage: [ "agf", "norm", "vand" ],
openTalkPageOnAutoRevert: false,
openTalkPageOnAutoRevert: false,
Line 58: Line 66:
confirmOnFluff: false,
confirmOnFluff: false,
showRollbackLinks: [ "diff", "others" ],
showRollbackLinks: [ "diff", "others" ],
// DI (twinkleimage)
 
// DI (twinkleimage)
notifyUserOnDeli: true,
notifyUserOnDeli: true,
deliWatchPage: "default",
deliWatchPage: "default",
deliWatchUser: "default",
deliWatchUser: "default",
// PROD
 
// PROD
watchProdPages: true,
watchProdPages: true,
prodReasonDefault: "",
prodReasonDefault: "",
logProdPages: false,
logProdPages: false,
prodLogPageName: "PROD log",
prodLogPageName: "PROD log",
// CSD
 
// CSD
speedySelectionStyle: "buttonClick",
speedySelectionStyle: "buttonClick",
speedyPromptOnG7: false,
watchSpeedyPages: [ "g3", "g5", "g10", "g11", "g12" ],
watchSpeedyPages: [ "g3", "g5", "g10", "g11", "g12" ],
markSpeedyPagesAsPatrolled: true,
markSpeedyPagesAsPatrolled: false,
 
// these next two should probably be identical by default
// these next two should probably be identical by default
notifyUserOnSpeedyDeletionNomination:    [ "db", "g1", "g2", "g3", "g4", "g6", "g10", "g11", "g12", "g13", "a1", "a2", "a3", "a5", "a7", "a9", "a10", "a11", "f1", "f2", "f3", "f7", "f9", "f10", "u3", "t2", "t3", "p1", "p2" ],
notifyUserOnSpeedyDeletionNomination:    [ "db", "g1", "g2", "g3", "g4", "g6", "g10", "g11", "g12", "g13", "g14", "a1", "a2", "a3", "a5", "a7", "a9", "a10", "a11", "f1", "f2", "f3", "f7", "f9", "f10", "u3", "u5", "t2", "t3", "p1", "p2" ],
welcomeUserOnSpeedyDeletionNotification: [ "db", "g1", "g2", "g3", "g4", "g6", "g10", "g11", "g12", "g13", "a1", "a2", "a3", "a5", "a7", "a9", "a10", "a11", "f1", "f2", "f3", "f7", "f9", "f10", "u3", "t2", "t3", "p1", "p2" ],
welcomeUserOnSpeedyDeletionNotification: [ "db", "g1", "g2", "g3", "g4", "g6", "g10", "g11", "g12", "g13", "g14", "a1", "a2", "a3", "a5", "a7", "a9", "a10", "a11", "f1", "f2", "f3", "f7", "f9", "f10", "u3", "u5", "t2", "t3", "p1", "p2" ],
promptForSpeedyDeletionSummary: [ "db", "g1", "g2", "g3", "g4", "g6", "g7", "g8", "g10", "g11", "g12", "a1", "a2", "a3", "a5", "a7", "a9", "a10", "a11", "f2", "f4", "f7", "f8", "f10", "t2", "t3", "p1", "p2" ],
promptForSpeedyDeletionSummary: [],
openUserTalkPageOnSpeedyDelete: [ "db", "g1", "g2", "g3", "g4", "g5", "g10", "g11", "g12", "a1", "a3", "a7", "a9", "a10", "a11", "f3", "f7", "f9", "u3", "t2", "p1" ],
openUserTalkPageOnSpeedyDelete: [ "db", "g1", "g2", "g3", "g4", "g5", "g10", "g11", "g12", "a1", "a3", "a7", "a9", "a10", "a11", "f3", "f7", "f9", "u3", "u5", "t2", "p1" ],
deleteTalkPageOnDelete: false,
deleteTalkPageOnDelete: true,
deleteRedirectsOnDelete: true,
deleteRedirectsOnDelete: true,
deleteSysopDefaultToTag: false,
deleteSysopDefaultToTag: false,
Line 85: Line 96:
speedyLogPageName: "CSD log",
speedyLogPageName: "CSD log",
noLogOnSpeedyNomination: [ "u1" ],
noLogOnSpeedyNomination: [ "u1" ],
// Unlink
 
unlinkNamespaces: [ "0", "100" ],
// Unlink
// Warn
unlinkNamespaces: [ "0", "10", "100", "118" ],
 
// Warn
defaultWarningGroup: "1",
defaultWarningGroup: "1",
showSharedIPNotice: true,
showSharedIPNotice: true,
watchWarnings: true,
watchWarnings: true,
blankTalkpageOnIndefBlock: false,
customWarningList: [],
customWarningList: [],
// XfD
 
// XfD
xfdWatchDiscussion: "default",
xfdWatchDiscussion: "default",
xfdWatchList: "no",
xfdWatchList: "no",
xfdWatchPage: "default",
xfdWatchPage: "default",
xfdWatchUser: "default",
xfdWatchUser: "default",
// Hidden preferences
markXfdPagesAsPatrolled: true,
 
// Hidden preferences
revertMaxRevisions: 50,
revertMaxRevisions: 50,
batchdeleteChunks: 50,
batchdeleteChunks: 50,
batchDeleteMinCutOff: 5,
batchMax: 5000,
batchMax: 5000,
batchProtectChunks: 50,
batchProtectChunks: 50,
batchProtectMinCutOff: 5,
batchundeleteChunks: 50,
batchundeleteChunks: 50,
batchUndeleteMinCutOff: 5,
deliChunks: 500,
deliMax: 5000,
proddeleteChunks: 50
proddeleteChunks: 50
};
};
Line 128: Line 138:


Twinkle.defaultConfig.friendly = {
Twinkle.defaultConfig.friendly = {
// Tag
// Tag
groupByDefault: true,
groupByDefault: true,
watchTaggedPages: true,
watchTaggedPages: true,
Line 136: Line 146:
tagArticleSortOrder: "cat",
tagArticleSortOrder: "cat",
customTagList: [],
customTagList: [],
// Welcome
 
// Welcome
topWelcomes: false,
topWelcomes: false,
watchWelcomes: true,
watchWelcomes: true,
Line 147: Line 158:
customWelcomeList: [],
customWelcomeList: [],
customWelcomeSignature: true,
customWelcomeSignature: true,
// Talkback
 
// Talkback
markTalkbackAsMinor: true,
markTalkbackAsMinor: true,
insertTalkbackSignature: true,  // always sign talkback templates
insertTalkbackSignature: true,  // always sign talkback templates
Line 153: Line 165:
adminNoticeHeading: "Notice",
adminNoticeHeading: "Notice",
mailHeading: "You've got mail!",
mailHeading: "You've got mail!",
// Shared
 
// Shared
markSharedIPAsMinor: true
markSharedIPAsMinor: true
};
};
Line 188: Line 201:
return result;
return result;
};
};


/**
/**
Line 299: Line 314:
outerDiv.appendChild( h5 );
outerDiv.appendChild( h5 );


var innerDiv = null;
if ( type === "menu" ) {
if ( type === "menu" ) {
var innerDiv = document.createElement( "div" );
innerDiv = document.createElement( "div" );
innerDiv.className = innerDivClass;
innerDiv.className = innerDivClass;
outerDiv.appendChild(innerDiv);
outerDiv.appendChild(innerDiv);
Line 323: Line 339:
}
}
var link = mw.util.addPortletLink( Twinkle.getPref( "portletId" ), typeof task === "string" ? task : "#", text, id, tooltip );
var link = mw.util.addPortletLink( Twinkle.getPref( "portletId" ), typeof task === "string" ? task : "#", text, id, tooltip );
if ( $.isFunction( task ) ) {
$('.client-js .skin-vector #p-cactions').css('margin-right', 'initial');
if ( typeof task === "function" ) {
$( link ).click(function ( ev ) {
$( link ).click(function ( ev ) {
task();
task();
Line 348: Line 365:
dataType: "text"
dataType: "text"
})
})
.fail(function () { mw.util.jsMessage( "Could not load twinkleoptions.js" ); })
.fail(function () { mw.notify( "Could not load twinkleoptions.js" ); })
.done(function ( optionsText ) {
.done(function ( optionsText ) {


Line 365: Line 382:


try {
try {
var options = $.parseJSON( optionsText );
var options = JSON.parse( optionsText );


// Assuming that our options evolve, we will want to transform older versions:
// Assuming that our options evolve, we will want to transform older versions:
Line 383: Line 400:
}
}
catch ( e ) {
catch ( e ) {
mw.util.jsMessage("Could not parse twinkleoptions.js");
mw.notify("Could not parse twinkleoptions.js");
}
}
})
})
Line 394: Line 411:


Twinkle.load = function () {
Twinkle.load = function () {
    // Don't activate on special pages other than "Contributions" so that they load faster, especially the watchlist.
// Don't activate on special pages other than those on the whitelist so that
var isSpecialPage = ( mw.config.get('wgNamespaceNumber') === -1
// they load faster, especially the watchlist.
    && mw.config.get('wgCanonicalSpecialPageName') !== "Contributions"
var specialPageWhitelist = [ 'Contributions', 'DeletedContributions', 'Prefixindex' ];
    && mw.config.get('wgCanonicalSpecialPageName') !== "Prefixindex" ),
var isSpecialPage = ( mw.config.get('wgNamespaceNumber') === -1 &&
specialPageWhitelist.indexOf( mw.config.get('wgCanonicalSpecialPageName') ) === -1 );


    // Also, Twinkle is incompatible with Internet Explorer versions 8 or lower, so don't load there either.
// Also, Twinkle is incompatible with Internet Explorer versions 8 or lower,
    isOldIE = ( $.client.profile().name === 'msie' && $.client.profile().versionNumber < 9 );
// so don't load there either.
var isOldIE = ( $.client.profile().name === 'msie' &&
$.client.profile().versionNumber < 9 );


    // Prevent users that are not autoconfirmed from loading Twinkle as well.
// Prevent users that are not autoconfirmed from loading Twinkle as well.
if ( isSpecialPage || isOldIE || !Twinkle.userAuthorized ) {
if ( isSpecialPage || isOldIE || !Twinkle.userAuthorized ) {
return;
return;
}
}


// Load the modules in the order that the tabs should appears
// Prevent clickjacking
if ( window.top !== window.self ) {
return;
}
 
// Set custom Api-User-Agent header, for server-side logging purposes
Morebits.wiki.api.setApiUserAgent( 'Twinkle/2.0 (' + mw.config.get( 'wgDBname' ) + ')' );
 
// Load the modules in the order that the tabs should appear
// User/user talk-related
// User/user talk-related
Twinkle.arv();
Twinkle.arv();
Twinkle.warn();
Twinkle.warn();
if ( Morebits.userIsInGroup('sysop') ) {
Twinkle.block();
}
Twinkle.welcome();
Twinkle.welcome();
Twinkle.shared();
Twinkle.shared();
Line 428: Line 459:
Twinkle.fluff.init();
Twinkle.fluff.init();
if ( Morebits.userIsInGroup('sysop') ) {
if ( Morebits.userIsInGroup('sysop') ) {
Twinkle.delimages();
Twinkle.deprod();
Twinkle.deprod();
Twinkle.batchdelete();
Twinkle.batchdelete();
Line 435: Line 465:
}
}
// Run the initialization callbacks for any custom modules
// Run the initialization callbacks for any custom modules
$( Twinkle.initCallbacks ).each(function ( k, v ) { v(); });
Twinkle.initCallbacks.forEach(function ( func ) { func(); });
Twinkle.addInitCallback = function ( func ) { func(); };
Twinkle.addInitCallback = function ( func ) { func(); };


Line 447: Line 477:
} ( window, document, jQuery )); // End wrap with anonymous function
} ( window, document, jQuery )); // End wrap with anonymous function


// </nowiki>
//</nowiki>
14,070

edits