Участник:Dronych/ListingButtons.js
Замечание: Возможно, после публикации вам придётся очистить кэш своего браузера, чтобы увидеть изменения.
- Firefox / Safari: Удерживая клавишу Shift, нажмите на панели инструментов Обновить либо нажмите Ctrl+F5 или Ctrl+R (⌘+R на Mac)
- Google Chrome: Нажмите Ctrl+Shift+R (⌘+Shift+R на Mac)
- Internet Explorer / Edge: Удерживая Ctrl, нажмите Обновить либо нажмите Ctrl+F5
- Opera: Нажмите Ctrl+F5.
// Add listing buttons in edit toolbar
var customizeToolbar = function() {
$( function() {
if ( typeof $.fn.wikiEditor != 'undefined' ) {
$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
'section': 'main',
'group': 'insert',
'tool': 'reference'
});
}
});
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'groups': {
'listings': {
'label': 'Объекты' // or use labelMsg for a localized label, see above
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'listings',
'tools': {
'Listings': {
label: 'Достопримечательности', // or use labelMsg for a localized label, see above
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/b/b7/Italian_traffic_signs_-_icona_museo.svg',
action: {
type: 'encapsulate',
options: {
pre: '{{listing|type=see| lat=| long= |wdid=\n| name=',
post: ' | alt= | image=\n| address= | directions=\n| url= | facebook= | vkontakte=\n| phone= | email= | skype=\n| hours= | price=\n| lastedit=' + getCurrentLastEditDate() + '\n| description=\n}}' // text to be inserted
}
}
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'listings',
'tools': {
'Listings': {
label: 'Чем заняться', // or use labelMsg for a localized label, see above
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/5/56/Italian_traffic_signs_-_icona_teatro.svg',
action: {
type: 'encapsulate',
options: {
pre: '{{listing|type=do| lat=| long= |wdid=\n| name=',
post: ' | alt= | image=\n| address= | directions=\n| url= | facebook= | vkontakte=\n| phone= | email= | skype=\n| hours= | price=\n| lastedit=' + getCurrentLastEditDate() + '\n| description=\n}}' // text to be inserted
}
}
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'listings',
'tools': {
'Listings': {
label: 'Транспорт', // or use labelMsg for a localized label, see above
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/5/51/Italian_traffic_signs_-_icona_aeroporto.svg',
action: {
type: 'encapsulate',
options: {
pre: '{{listing|type=go| lat=| long= |wdid=\n| name=',
post: ' | alt= | image=\n| address= | directions=\n| url= | facebook= | vkontakte=\n| phone= | email= | skype=\n| hours= | price=\n| lastedit=' + getCurrentLastEditDate() + '\n| description=\n}}' // text to be inserted
}
}
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'listings',
'tools': {
'Listings': {
label: 'Покупки', // or use labelMsg for a localized label, see above
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/a/a1/Italian_traffic_signs_-_icona_supermercato.svg',
action: {
type: 'encapsulate',
options: {
pre: '{{listing|type=buy| lat=| long=\n| name=',
post: ' | alt= | image=\n| address= | directions=\n| url= | facebook= | vkontakte=\n| phone= | email= | skype=\n| hours= | price=\n| lastedit=' + getCurrentLastEditDate() + '\n| description=\n}}' // text to be inserted
}
}
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'listings',
'tools': {
'Listings': {
label: 'Еда', // or use labelMsg for a localized label, see above
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/2/2c/Italian_traffic_signs_-_icona_ristorante.svg',
action: {
type: 'encapsulate',
options: {
pre: '{{listing|type=eat| lat=| long=\n| name=',
post: ' | alt= | image=\n| address= | directions=\n| url= | facebook= | vkontakte=\n| phone= | email= | skype=\n| hours= | price=\n| lastedit=' + getCurrentLastEditDate() + '\n| description=\n}}' // text to be inserted
}
}
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'listings',
'tools': {
'Listings': {
label: 'Ночная жизнь', // or use labelMsg for a localized label, see above
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/a/a5/Verre_cocktail.svg',
action: {
type: 'encapsulate',
options: {
pre: '{{listing|type=drink| lat=| long=\n| name=',
post: ' | alt= | image=\n| address= | directions=\n| url= | facebook= | vkontakte=\n| phone= | email= | skype=\n| hours= | price=\n| lastedit=' + getCurrentLastEditDate() + '\n| description=\n}}' // text to be inserted
}
}
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'listings',
'tools': {
'Listings': {
label: 'Ночлег', // or use labelMsg for a localized label, see above
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/2/25/Pictograms-nps-lodging.svg',
action: {
type: 'encapsulate',
options: {
pre: '{{listing|type=sleep| lat=| long=\n| name=',
post: ' | alt= | image=\n| address= | directions=\n| url= | facebook= | vkontakte=\n| phone= | email= | skype=\n| hours= | price=\n| lastedit=' + getCurrentLastEditDate() + '\n| description=\n}}' // text to be inserted
}
}
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'listings',
'tools': {
'Listings': {
label: 'Другое', // or use labelMsg for a localized label, see above
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/7/7e/Italian_traffic_signs_-_icona_informazioni.svg',
action: {
type: 'encapsulate',
options: {
pre: '{{listing|type=other| lat=| long=\n| name=',
post: ' | alt= | image=\n| address= | directions=\n| url= | facebook= | vkontakte=\n| phone= | email= | skype=\n| hours= | price=\n| lastedit=' + getCurrentLastEditDate() + '\n| description=\n}}' // text to be inserted
}
}
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'listings',
'tools': {
'Listings': {
label: 'Окрестности', // or use labelMsg for a localized label, see above
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/d/d9/Pictograms-nps-motor_bike_trail.svg',
action: {
type: 'encapsulate',
options: {
pre: '{{listing|type=vicinity| lat=| long= |wdid=\n| name=',
post: ' | alt= | image=\n| address= | directions=\n| url= | facebook= | vkontakte=\n| phone= | email= | skype=\n| hours= | price=\n| lastedit=' + getCurrentLastEditDate() + '\n| description=\n}}' // text to be inserted
}
}
}
}
} );
function getCurrentLastEditDate() {
// return the date as "2015-01-15"
var d = new Date();
var year = d.getFullYear();
// Date.getMonth() returns 0-11
var month = d.getMonth() + 1;
if (month < 10) month = '0' + month;
var day = d.getDate();
if (day < 10) day = '0' + day;
return year + '-' + month + '-' + day;
}
};
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar . . . */
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
mw.loader.using( 'user.options', function () {
if ( mw.user.options.get('usebetatoolbar') ) {
mw.loader.using( 'ext.wikiEditor', function () {
$(document).ready( customizeToolbar );
} );
}
} );
}