MediaWiki:Common.js: различия между версиями

<div style="color: #555555; font-size: 80%; font-style: italic; font-family: serif; text-align: center;">Материал из '''Библиотеки Теопедии''', http://ru.teopedia.org/lib</div>
Перейти к навигации Перейти к поиску
м
м
Строка 13: Строка 13:
 
group: 'format',
 
group: 'format',
 
tools: {
 
tools: {
 +
"underline": {
 +
label: 'Подчёркивание',
 +
type: 'button',
 +
icon: '//upload.wikimedia.org/wikipedia/commons/f/fd/Button_underline.png',
 +
action: {
 +
type: 'encapsulate',
 +
options: {
 +
pre: "<u>",
 +
post: "</u>"
 +
}
 +
}
 +
},
 +
"double_underline": {
 +
label: 'Двойное подчёркивание',
 +
type: 'button',
 +
icon: '//upload.wikimedia.org/wikipedia/commons/4/45/Button_double.png',
 +
action: {
 +
type: 'encapsulate',
 +
options: {
 +
pre: "{{Стиль С-Двойное подчёркивание|",
 +
post: "}}"
 +
}
 +
}
 +
},
 +
"justify-center": {
 +
label: 'Выравнивание по центру',
 +
type: 'button',
 +
icon: '//upload.wikimedia.org/wikipedia/commons/5/5f/Button_center.png',
 +
action: {
 +
type: 'encapsulate',
 +
options: {
 +
pre: "<center>",
 +
post: "</center>"
 +
}
 +
}
 +
},
 +
"justify-right": {
 +
label: 'Выравнивание справа',
 +
type: 'button',
 +
icon: '//upload.wikimedia.org/wikipedia/commons/a/a5/Button_align_right.png',
 +
action: {
 +
type: 'encapsulate',
 +
options: {
 +
pre: "{{Стиль А-Текст справа|",
 +
post: "}}"
 +
}
 +
}
 +
},
 +
"columns": {
 +
label: 'Разбить текст на колонки',
 +
type: 'button',
 +
icon: '//upload.wikimedia.org/wikipedia/commons/0/04/Button_multicol.png',
 +
action: {
 +
type: 'encapsulate',
 +
options: {
 +
pre: "{{Колонки начинаются||ширина=|размер=}}",
 +
post: "{{Колонки завершаются}}"
 +
}
 +
}
 +
},
 
"category": {
 
"category": {
 
label: 'Категория',
 
label: 'Категория',
Строка 25: Строка 85:
 
}
 
}
 
},
 
},
"hyphen": {
+
"dash": {
label: 'Дефис',
+
label: 'Тире',
 
type: 'button',
 
type: 'button',
 
icon: '//upload.wikimedia.org/wikipedia/commons/c/cd/Button_mdash.png',
 
icon: '//upload.wikimedia.org/wikipedia/commons/c/cd/Button_mdash.png',

Версия 07:32, 1 сентября 2020

/* Размещённый здесь код JavaScript будет загружаться пользователям при обращении к каждой странице */

///$(document).ready(function(){
//	alert();
//});

mw.loader.using('common.site.styles');

/** -pm- Изменяем панель инструментов в редакторе WikiEditor **/
var customizeToolbar = function () {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"underline": {
			label: 'Подчёркивание',
			type: 'button',
			icon: '//upload.wikimedia.org/wikipedia/commons/f/fd/Button_underline.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "<u>",
					post: "</u>"
				}
			}
		},
		"double_underline": {
			label: 'Двойное подчёркивание',
			type: 'button',
			icon: '//upload.wikimedia.org/wikipedia/commons/4/45/Button_double.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "{{Стиль С-Двойное подчёркивание|",
					post: "}}"
				}
			}
		},
		"justify-center": {
			label: 'Выравнивание по центру',
			type: 'button',
			icon: '//upload.wikimedia.org/wikipedia/commons/5/5f/Button_center.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "<center>",
					post: "</center>"
				}
			}
		},
		"justify-right": {
			label: 'Выравнивание справа',
			type: 'button',
			icon: '//upload.wikimedia.org/wikipedia/commons/a/a5/Button_align_right.png',
			action: { 
				type: 'encapsulate',
				options: {
					pre: "{{Стиль А-Текст справа|",
					post: "}}"
				}
			}
		},
		"columns": {
			label: 'Разбить текст на колонки',
			type: 'button',
			icon: '//upload.wikimedia.org/wikipedia/commons/0/04/Button_multicol.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "{{Колонки начинаются||ширина=|размер=}}",
					post: "{{Колонки завершаются}}"
				}
			}
		},
		"category": {
			label: 'Категория',
			type: 'button',
			icon: '//upload.wikimedia.org/wikipedia/commons/c/c4/Toolbar_category.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "[[Категория:",
					post: "]]"
				}
			}
		},
		"dash": {
			label: 'Тире',
			type: 'button',
			icon: '//upload.wikimedia.org/wikipedia/commons/c/cd/Button_mdash.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "–",
					post: ""
				}
			}
		},
		"quot_main": {
			label: 'Кавычки основные',
			type: 'button',
			icon: '//upload.wikimedia.org/wikipedia/commons/a/ac/Norwegian_quote_sign.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "«",
					post: "»"
				}
			}
		}
	}
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	section: 'main',
	groups: {
		list: {
			tools: {
				templatesA: {
					label: 'Стили абзаца',
					type: 'select',
					list: {
						'Style-A-avtor': {label: 'Автор', action: {type: 'encapsulate',
							options: {pre: '{{Стиль А-Автор|', post: '}}'} } },
						'Style-A-data-dnevnika': {label: 'Дата дневника', action: {type: 'encapsulate',
							options: {pre: '{{Стиль А-Дата дневника|', post: '}}'} } },
						'Style-A-zagolovok': {label: 'Заголовок', action: {type: 'encapsulate',
							options: {pre: '{{Стиль А-Заголовок|', post: '}}'} } },
						'Style-A-zagolovok-urovnya': {label: 'Заголовок уровня', action: {type: 'encapsulate',
							options: {pre: '{{Стиль А-Заголовок уровня|2|', post: '}}'} } },
						'Style-A-kniga': {label: 'Книга', action: {type: 'encapsulate',
							options: {pre: '{{Стиль А-Книга|', post: '}}'} } },
						'Style-A-podzagolovok': {label: 'Подзаголовок', action: {type: 'encapsulate',
							options: {pre: '{{Стиль А-Подзаголовок|', post: '}}'} } },
						'Style-A-podpis': {label: 'Подпись', action: {type: 'encapsulate',
							options: {pre: '{{Стиль А-Подпись|', post: '}}'} } },
						'Style-A-prim-per': {label: 'Прим. переводчика', action: {type: 'encapsulate',
							options: {pre: '{{Стиль А-Прим. пер.|', post: '}}'} } },
						'Style-A-tekst-v-centre': {label: 'Текст в центре', action: {type: 'encapsulate',
						'Style-A-stih': {label: 'Стих', action: {type: 'encapsulate',
							options: {pre: '{{Стиль А-Стих| стих=', post: '| подпись=}}'} } },
							options: {pre: '{{Стиль А-Текст в центре|', post: '}}'} } },
						'Style-A-citata': {label: 'Цитата', action: {type: 'encapsulate',
							options: {pre: '{{Стиль А-Цитата|', post: '}}'} } },
						'Style-A-citata-data': {label: 'Цитата, данные отправителя', action: {type: 'encapsulate',
							options: {pre: '{{Стиль А-Цитата, данные отправителя|', post: '}}'} } },
						'Style-A-citata-podpis': {label: 'Цитата, подпись', action: {type: 'encapsulate',
							options: {pre: '{{Стиль А-Цитата, подпись|', post: '}}'} } },
						'Style-A-epigraf': {label: 'Эпиграф', action: {type: 'encapsulate',
							options: {pre: '{{Стиль А-Эпиграф|', post: '}}'} } }
					}
				},
				templatesS: {
					label: 'Стили символа',
					type: 'select',
					list: {
						'Style-S-vopros': {label: 'Вопрос', action: {type: 'encapsulate',
							options: {pre: '{{Вопрос|', post: '||~~ ~~}}'} } },
						'Style-S-vydelenie': {label: 'Выделение', action: {type: 'encapsulate',
							options: {pre: '{{Выделение|', post: '}}'} } },
						'Style-S-speaker': {label: 'Говорящий в диалоге', action: {type: 'encapsulate',
							options: {pre: '{{Стиль С-Говорящий в диалоге|', post: '}}'} } },
						'Style-S-dopolnenie': {label: 'Дополнение', action: {type: 'encapsulate',
							options: {pre: '{{Дополнение|', post: '||~~ ~~}}'} } },
						'Style-S-capitel': {label: 'Капитель', action: {type: 'encapsulate',
							options: {pre: '{{Стиль С-Капитель|', post: '}}'} } },
						'Style-S-simvol': {label: 'Символ', action: {type: 'encapsulate',
							options: {pre: '{{Стиль С-Символ|', post: '}}'} } },
						'Style-S-td-ispravlenie': {label: 'ТД-исправление', action: {type: 'encapsulate',
							options: {pre: '{{ТД-исправление|текст=|ред1=', post: '|анг1=|анг3=|инфо=|участник=~~ ~~}}'} } },
						'Style-S-prim-red': {label: 'Прим. редактора', action: {type: 'encapsulate',
							options: {pre: '{{Стиль С-Прим. ред.|', post: '}}'} } },
						'Style-S-prim-red-orig': {label: 'Прим. редактора (оригинал)', action: {type: 'encapsulate',
							options: {pre: '{{Стиль С-Прим. ред. (оригинал)|', post: '}}'} } },
						'Style-S-yaz-in': {label: 'Язык иностранный', action: {type: 'encapsulate',
							options: {pre: '{{Стиль С-Язык иностранный|', post: '}}'} } }
					}
				}
			}
		}
	}
} );
};

/* 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' ).then( function () {
		// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
		if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
			$.when(
				mw.loader.using( 'ext.wikiEditor' ), $.ready
			).then( customizeToolbar );
		}
	} );
}