Медиавики:Gadget-blpEditNotice.js
Эзоҳ: Баъди захира намудан, Шумо метавонед тағйиротҳои худро аз хотираи браузер гузариш карда, бубинед. Дар браузерҳои Mozilla / Firefox / Safari: тугмаи Shift-ро пахш намуда бо мушак Reload-ро пахш кунед, ё Ctrl-Shift-R-ро пахш намоед (Cmd-Shift-R барои компютерҳои Apple Mac); дар браузери IE: тугмаи Ctrl-ро пахш намуда бо мушак Refresh-ро пахш намоед, ё Ctrl-F5-ро пахш намоед; дар браузери Konqueror:: бо мушак Reload-ро пахш кунед, ё тугмаи F5-ро пахш намоед; дар браузери Opera ба Шумо пурра тоза кардани хотираи браузер ба воситаи Tools→Preferences лозим аст.
// Magic editintros by [[:en:User:RockMFR]] & [[:ru:User:Jack who built the house]] (VE part)
( function () {
function addVeEditNotice( code ) {
var target = ve.init.target;
var actionsToolbar = target.actionsToolbar;
var wasNoEditNotices = !actionsToolbar.tools.notices;
if ( wasNoEditNotices ) {
if ( actionsToolbar.items[ 0 ] &&
actionsToolbar.items[ 0 ].items &&
actionsToolbar.items[ 0 ].items[ 1 ] &&
actionsToolbar.items[ 0 ].items[ 1 ] instanceof ve.ui.MWNoticesPopupTool &&
actionsToolbar.items[ 0 ].items[ 0 ] &&
actionsToolbar.items[ 0 ].items[ 0 ] instanceof ve.ui.MWHelpPopupTool
) {
var noticesPopupTool = new ve.ui.MWNoticesPopupTool( actionsToolbar.items[ 0 ] );
actionsToolbar.tools.notices = actionsToolbar.items[ 0 ].items[ 1 ] = noticesPopupTool;
noticesPopupTool.$element.insertAfter( $( '.oo-ui-tool-name-help' ) );
actionsToolbar.connect( noticesPopupTool, {
updateState: 'onUpdateState'
} );
} else {
console.error( 'Unable to add the edit notice tool to the VisualEditor toolbar' );
return;
}
}
target.remoteNotices.unshift( code );
target.editNotices.unshift( code );
actionsToolbar.tools.notices.setNotices( target.getEditNotices() );
if ( wasNoEditNotices ) {
// setTimeout for IE
setTimeout( function () {
actionsToolbar.tools.notices.getPopup().toggle( true );
}, 0 );
}
}
function addEditIntro( name ) {
$( '.mw-editsection, #ca-edit, #ca-ve-edit' ).find( 'a' ).each( function ( i, el ) {
el.href = $( this ).attr( 'href' ) + '&editintro=' + name;
} );
if ( mw.util.getParamValue( 'editintro' ) !== name ) {
var editNoticeLoaded = false;
mw.libs.ve.addPlugin( function () {
if ( !editNoticeLoaded ) {
new mw.Api().get( {
action: 'parse',
page: name,
prop: 'text',
formatversion: 2,
} ).done( function ( data ) {
if ( data && data.parse && data.parse.text !== undefined ) {
editNoticeLoaded = true;
if ( data.parse.text ) {
mw.hook( 've.activationComplete' ).add( function () {
addVeEditNotice( data.parse.text );
} );
}
}
} );
}
} );
}
}
if ( mw.config.get( 'wgNamespaceNumber' ) === 0 ) {
runAsEarlyAsPossible( function () {
var cats = mw.config.get( 'wgCategories' );
if ( !cats ) return;
if ( $.inArray( 'Википедия:Зиндагиномаи зиндагон', cats ) !== -1 ) {
addEditIntro( 'Шаблон:Editnotice/Ҳозир_зиндаҳо' );
} else if ( $.inArray( 'Википедия:Шахсиятҳо, даргузашта камтар аз як сол', cats ) !== -1 ) {
addEditIntro( 'Шаблон:Editnotice/Ба_наздикӣ_даргузаштаҳо' );
}
}, $( '#ca-history' ) );
}
}() );