Участник:Vladis13/Gadget-OftenUsedToolbar.js

Материал из Википедии — свободной энциклопедии
Перейти к навигации Перейти к поиску
// Справка https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization


function customizeToolbar() {
	
  var $target = $('#wpTextbox1');

  if (!$('.group-ruws').length) {
    $target.wikiEditor('addToToolbar', { section:'main', groups: {'ruws':{}}});
    mw.util.addCSS('.wikiEditor-ui-toolbar .group-insert {border-right:1px solid #DDD}');
  }

  // Определение выпадающих меню. Сначала определяются sections с типом booklet.
  // В них список вкладок (pages) со страницами. 
  // В них списки (characters) вставляемых литералов.
  // label - отображаемое название
  // Часто надо чтобы вставляемый литерал обёртывался вокруг выделеного слова в тексте. 
  //    Это определяется в 'pre' и 'post' - литералы, вставляемые перед и после выделенного текста, соответственно.
  
  
  // Дополнительные спецсимволы
  $target.wikiEditor('addToToolbar', {sections: {'extchars': {type: 'booklet', label: 'Еще'}}});
  $target.wikiEditor('addToToolbar', {section: 'extchars', pages: {
    	'lang': {
    		layout: 'characters',
    		label:'Языки + Кириллица',
    		characters: [
    			// Без маркера
    			{label:'en',  action: {type:'encapsulate', options: {pre:"{\{lang|en|",  post:"}}"}}},
    			{label:'de',  action: {type:'encapsulate', options: {pre:"{\{lang|de|",  post:"}}"}}},
    			{label:'fr',  action: {type:'encapsulate', options: {pre:"{\{lang|fr|",  post:"}}"}}},
    			{label:'it',  action: {type:'encapsulate', options: {pre:"{\{lang|it|",  post:"}}"}}},
    			{label:'es',  action: {type:'encapsulate', options: {pre:"{\{lang|es|",  post:"}}"}}},
    			{label:'cu',  action: {type:'encapsulate', options: {pre:"{\{lang|cu|",  post:"}}"}}},
    			{label:'grc', action: {type:'encapsulate', options: {pre:"{\{lang|grc|", post:"}}"}}},
    			{label:'el',  action: {type:'encapsulate', options: {pre:"{\{lang|el|",  post:"}}"}}},
    			{label:'la',  action: {type:'encapsulate', options: {pre:"{\{lang|la|",  post:"}}"}}},
    			{label:'uk',  action: {type:'encapsulate', options: {pre:"{\{lang|uk|",  post:"}}"}}},
    			{label:'cs',  action: {type:'encapsulate', options: {pre:"{\{lang|cs|",  post:"}}"}}},
    			{label:'pl',  action: {type:'encapsulate', options: {pre:"{\{lang|pl|",  post:"}}"}}},
    			{label:'he',  action: {type:'encapsulate', options: {pre:"{\{lang|he|",  post:"}}‎"}}},
    			{label:'ar',  action: {type:'encapsulate', options: {pre:"{\{lang|ar|",  post:"}}"}}},
    			
    			// С маркером
    			{label:'* en',  action: {type:'encapsulate', options: {pre:"{\{lang-en|",  post:"}}"}}},
    			{label:'* de',  action: {type:'encapsulate', options: {pre:"{\{lang-de|",  post:"}}"}}},
    			{label:'* fr',  action: {type:'encapsulate', options: {pre:"{\{lang-fr|",  post:"}}"}}},
    			{label:'* it',  action: {type:'encapsulate', options: {pre:"{\{lang-it|",  post:"}}"}}},
    			{label:'* es',  action: {type:'encapsulate', options: {pre:"{\{lang-es|",  post:"}}"}}},
    			{label:'* cu',  action: {type:'encapsulate', options: {pre:"{\{lang-cu|",  post:"}}"}}},
    			{label:'* grc', action: {type:'encapsulate', options: {pre:"{\{lang-grc|", post:"}}"}}},
    			{label:'* el',  action: {type:'encapsulate', options: {pre:"{\{lang-el|",  post:"}}"}}},
    			{label:'* la',  action: {type:'encapsulate', options: {pre:"{\{lang-la|",  post:"}}"}}},
    			{label:'* uk',  action: {type:'encapsulate', options: {pre:"{\{lang-uk|",  post:"}}"}}},
    			{label:'* cs',  action: {type:'encapsulate', options: {pre:"{\{lang-cs|",  post:"}}"}}},
    			{label:'* pl',  action: {type:'encapsulate', options: {pre:"{\{lang-pl|",  post:"}}"}}},
    			{label:'* he',  action: {type:'encapsulate', options: {pre:"{\{lang-he|",  post:"}}‎"}}},
    			{label:'* ar',  action: {type:'encapsulate', options: {pre:"{\{lang-ar|",  post:"}}"}}},
    			
    			// Кириллица
    			'Ѣ', 'ѣ', 'Ѳ', 'ѳ', 'Ѵ', 'ѵ', 'Ѱ', 'ѱ', 'ѱ҃', 'Ѯ', 'ѯ', 'ѯ҃', 'Ѫ', 'ѫ', 'Ѭ', 'ѭ', 'Ѧ', 'ѧ', 'Ѩ', 'ѩ', 
    			'Ѻ', 'ѻ҃', 'Ѡ', 'ѡ', 'Ѿ', 'ѿ', 'І', 'і', 'Ї', 'ї', 'Є', 'є', 'Ѥ', 'ѥ', 'Ѹ', 'ѹ', 'Ѕ', 'ѕ', 'ıа', '҂', '҃', '҄', '҅', '҆' ,'ſ'
			]
		},
		'greek1': {
			layout: 'characters',
			label: 'Греческий (α)', 
			characters: [ 
				'α', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', 'ἇ', 'ὰ', 'ά', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 
				'β', 'γ', 'δ', 'ε', 'ἐ', 'ἑ', 'ἒ', 'ἓ', 'ἔ', 'ἕ', 'ὲ', 'έ', 'ζ',
				'η', 'ἠ', 'ἡ', 'ἢ', 'ἣ', 'ἤ', 'ἥ', 'ἦ', 'ἧ', 'ὴ', 'ή', 'ᾐ', 'ᾑ', 'ᾒ', 'ᾓ', 'ᾔ', 'ᾕ', 'ᾖ', 'ᾗ', 'ῂ', 'ῃ', 'ῄ', 'ῆ', 'ῇ', 
				'θ', 'ι', 'ἰ', 'ἱ', 'ἲ', 'ἳ', 'ἴ', 'ἵ', 'ἶ', 'ἷ', 'ὶ', 'ί', 'ῐ', 'ῑ', 'ῒ', 'ΐ', 'ῖ', 'ῗ',
				'κ', 'λ', 'μ', 'ν', 'ξ', 'ο', 'ὀ', 'ὁ', 'ὂ', 'ὃ', 'ὄ', 'ὅ', 'ὸ', 'ό', 'π', 'ρ', 'ῤ', 'ῥ', 'σ', 'ς', 'τ',
				'υ', 'ὐ', 'ὑ', 'ὒ', 'ὓ', 'ὔ', 'ὕ', 'ὖ', 'ὗ', 'ὺ', 'ύ', 'ῠ', 'ῡ', 'ῢ', 'ΰ', 'ῦ', 'ῧ', 'φ', 'χ', 'ψ', 
				'ω', 'ὠ', 'ὡ', 'ὢ', 'ὣ', 'ὤ', 'ὥ', 'ὦ', 'ὧ', 'ὼ', 'ώ', 'ᾠ', 'ᾡ', 'ᾢ', 'ᾣ', 'ᾤ', 'ᾥ', 'ᾦ', 'ᾧ', 'ῲ', 'ῳ', 'ῴ', 'ῶ', 'ῷ'
			]
		},
		'greek2': {
			layout: 'characters',
			label: 'Греческий (Α)', 
			characters: [ 
				'Α', 'Ἀ', 'Ἁ', 'Ἂ', 'Ἃ', 'Ἄ', 'Ἅ', 'Ἆ', 'Ἇ', 'Ὰ', 'Ά', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'Ᾰ', 'Ᾱ', 'ᾼ',
				'Β', 'Γ', 'Δ', 'Ε', 'Ἐ', 'Ἑ', 'Ἒ', 'Ἓ', 'Ἔ', 'Ἕ', 'Ὲ', 'Έ', 'Ζ',
				'Η', 'Ἠ', 'Ἡ', 'Ἢ', 'Ἣ', 'Ἤ', 'Ἥ', 'Ἦ', 'Ἧ', 'Ὴ', 'Ή', 'ᾘ', 'ᾙ', 'ᾚ', 'ᾛ', 'ᾜ', 'ᾝ', 'ᾞ', 'ᾟ', 'ῌ', 
				'Θ', 'Ι', 'Ἰ', 'Ἱ', 'Ἲ', 'Ἳ', 'Ἴ', 'Ἵ', 'Ἶ', 'Ἷ', 'Ὶ', 'Ί', 'Ῐ', 'Ῑ',
				'Κ', 'Λ', 'Μ', 'Ν', 'Ξ', 'Ο', 'Ὀ', 'Ὁ', 'Ὂ', 'Ὃ', 'Ὄ', 'Ὅ', 'Ὸ', 'Ό',
				'Π', 'Ρ', 'Ῥ', 'Σ', 'Τ', 'Υ', 'Ὑ', 'Ὓ', 'Ὕ', 'Ὗ', 'Ὺ', 'Ύ', 'Ῠ', 'Ῡ', 'Φ', 'Χ', 'Ψ', 
				'Ω', 'Ὠ', 'Ὡ', 'Ὢ', 'Ὣ', 'Ὤ', 'Ὥ', 'Ὦ', 'Ὧ', 'Ὼ', 'Ώ', 'ᾨ', 'ᾩ', 'ᾪ', 'ᾫ', 'ᾬ', 'ᾭ', 'ᾮ', 'ᾯ', 'ῼ', 
				'᾽', '᾿', '῀', '῁', '῍', '῎', '῏', '῝', '῞', '῟', '῭', '΅', '`', '´', '῾'
			]
		},
		'hebrew': {
			layout: 'characters',
			label: 'Иврит 2',
			characters: [
    			{label:'he',  action: {type:'encapsulate', options: {pre:"{\{lang|he|",  post:"}}‎"}}},
				"\u05d0", "\u05d1", "\u05d2", "\u05d3", "\u05d4", "\u05d5", "\u05d6", "\u05d7", "\u05d8",
				"\u05d9", "\u05db", "\u05da", "\u05dc", "\u05de", "\u05dd", "\u05e0", "\u05df", "\u05e1",
				"\u05e2", "\u05e4", "\u05e3", "\u05e6", "\u05e5", "\u05e7", "\u05e8", "\u05e9", "\u05ea",
				"\u05f3", "\u05f4", "\u05f0", "\u05f1", "\u05f2", "\u05be",
				"\ufb1d", "\ufb1e", "\ufb1f", "\ufb20", "\ufb2a", "\ufb2b", "\ufb2e", "\ufb2f", "\ufb30",
				"\ufb31", "\ufb32", "\ufb33", "\ufb34", "\ufb35", "\ufb36", "\ufb38", "\ufb39", "\ufb3a",
				"\ufb3b", "\ufb3c", "\ufb3e", "\ufb40", "\ufb41", "\ufb43", "\ufb44", "\ufb46", "\ufb47",
				"\ufb48", "\ufb49", "\ufb4a", "\ufb4b", "\ufb4c", "\ufb4d", "\ufb4e", "\ufb4f"
			]
		}
    }
  });

  // Разметка
  $target.wikiEditor('addToToolbar', {sections: {'ext': {type: 'booklet', label: 'Разметка'}}});
  $target.wikiEditor('addToToolbar', {section: 'ext', pages: {
  	        'templates': {
        	layout: 'characters',
        	label: 'Шаблоны',
        	characters: [ 
        		{label: "{{ВТ-РСКД}}", action: {type: 'encapsulate', options: { pre: "{\{ВТ-РСКД|", post: "}}" }}},
        		{label: "{{ВТ-ЭСБЕ}}", action: {type: 'encapsulate', options: { pre: "{\{ВТ-ЭСБЕ|", post: "}}" }}},
    		]
		},
        'general': {
        	layout: 'characters',
        	label: 'Общая',
        	characters: [ 
        		{label: "{{}}", action: {type: 'encapsulate', options: { pre: "{\{", post: "}}" }}},
        		{label: "{{|}}", action: {type: 'encapsulate', options: { pre: "{\{|", post: "}}" }}},
  				{label:'колонтитул',  action: {type:'encapsulate', options: {pre:"{\{колонтитул|",  post:"||}}"}}},
  				{label:'перен',  action: {type:'encapsulate', options: {pre:"{\{перенос|",  post:"|}}"}}},
  				{label:'перен2', action: {type:'encapsulate', options: {pre:"{\{перенос2||",  post:"}}"}}},
        		{label: "nop", action: {type: 'encapsulate', options: { pre: "{\{nop}}" }}},
				{label: "ВАР", action: {type: 'encapsulate', options: { pre: "{\{ВАР\n|", post: "\n|}}" }}},
				{label: "ВАР2", action: {type: 'encapsulate', options: { pre: "<section begin=\"\" />\n{\{ВАР2\n|", post: "\n|}}<section end=\"\" />" }}},
				{label: "rfloat", action: {type: 'encapsulate', options: { pre: "{\{rfloat||title=", post: "}}" }}},
        		{label: "Razr", action: {type: 'encapsulate', options: { pre: "{\{razr|", post: "}}" }}},
        		{label: "Razr2", action: {type: 'encapsulate', options: { pre: "{\{razr2|", post: "}}" }}},
        		{label: "Рубрика", action: {type: 'encapsulate', options: { pre: "{\{рубрика|", post: "}}" }}},
        		{label: "Рубрика2", action: {type: 'encapsulate', options: { pre: "{\{рубрика|", post: "|формат=i|nodot=}}" }}},
        		{label: "Oncolor", action: {type: 'encapsulate', options: { pre: "{\{oncolor|#ddd||", post: "}}" }}},
        		{label: "Indent", action: {type: 'encapsulate', options: { pre: "{\{indent|", post: "}}" }}},
        		{label: "Right", action: {type: 'encapsulate', options: { pre: "{\{right|", post: "}}" }}},
        		{label: "N", action: {type: 'encapsulate', options: { pre: "{\{n||", post: "|}}" }}},
        		{label: "Shift", action: {type: 'encapsulate', options: { pre: "{\{shift|", post: "||}}" }}},
        		{label: "Опечатка", action: {type: 'encapsulate', options: { pre: "{\{опечатка|", post: "||О1}}" }}},
        		{label: "Так в тексте", action: {type: 'encapsulate', options: { pre: "{\{Так в тексте|", post: "}}" }}},
        		{label: "<u>", action: {type: 'encapsulate', options: { pre: "<u>", post: "</u>" }}},
        		{label: "<s>", action: {type: 'encapsulate', options: { pre: "<s>", post: "</s>" }}},
        		{label: "<center>", action: {type: 'encapsulate', options: { pre: "<center>", post: "</center>" }}},
        		{label: "<poem>", action: {type: 'encapsulate', options: { pre: "<poem>\n", post: "\n</poem>" }}},
        		{label: "<code>", action: {type: 'encapsulate', options: { pre: "<code>", post: "</code>" }}},
        		{label: "<source>", action: {type: 'encapsulate', options: { pre: "<source lang=''>", post: "</source>" }}},
        		{label: "<pre>", action: {type: 'encapsulate', options: { pre: "<pre>", post: "</pre>" }}},
        		{label: "&nbsp;", action: {type: 'encapsulate', options: { pre: "&nbsp;", post: "" }}},
        		{label: "U+00A0", action: {type: 'replace', options: { pre: "\u00a0" }}},
        		{label: "ЕДО", action: {type: 'encapsulate', options: { pre: "{\{ЕДО||", post: "}}" }}},
        		{label: "Dotted TOC", action: {type: 'encapsulate', options: { pre: "{\{Dotted TOC||", post: "}}" }}},
        		{label: "Poemx", action: {type: 'encapsulate', options: { pre: "{\{poemx|mode=var||\n", post: "\n|}}" }}},
        		{label: "Poem-on", action: {type: 'encapsulate', options: { pre: "{\{poem-on|}}\n", post: "\n{\{poem-off}}" }}},
        		{label: "Poemx1", action: {type: 'encapsulate', options: { pre: "{\{poemx1||\n", post: "\n|}}" }}},
        		{label: "Poem-title", action: {type: 'encapsulate', options: { pre: "{\{poem-title|", post: "}}" }}},
        		{label: "Poem-section", action: {type: 'encapsulate', options: { pre: "{\{poem-section|", post: "}}" }}},
        		{label: "Razr-center", action: {type: 'encapsulate', options: { pre: "{\{razr-center|", post: "}}" }}},
        		{label: "Эпиграф", action: {type: 'encapsulate', options: { pre: "{\{эпиграф||", post: "\n||}}" }}},
        		{label: "Эпиграф2", action: {type: 'encapsulate', options: { pre: "{\{эпиграф2|", post: "\n||50}}" }}},
        		{label: "№", action: {type: 'encapsulate', options: { pre: "{\{№|", post: "}}" }}},
        		{label: "Ext", action: {type: 'encapsulate', options: { pre: "{\{ext|1|", post: "}}" }}},
        		{label: "Noindent", action: {type: 'encapsulate', options: { pre: "{\{noindent|1=", post: "}}" }}},
        		{label: "Nobr", action: {type: 'encapsulate', options: { pre: "{\{nobr|1=", post: "}}" }}},
        		{label: "Small-caps", action: {type: 'encapsulate', options: { pre: "{\{sc|", post: "}}" }}},
        		{label: "Ditto", action: {type: 'encapsulate', options: { pre: "{\{ditto|", post: "}}" }}},
        		{label: "Прим. ВТ", action: {type: 'encapsulate', options: { pre: "{\{Примечание ВТ|", post: "}}" }}},
        		{label: "Прим-я ВТ", action: {type: 'replace', options: { pre: "{\{Примечания ВТ}}" }}}
    		]
		},
		'layout1': {
			layout: 'characters',
			label: 'Структура 1', 
			characters: [ 
				{label: "<div text>", action: {type: 'encapsulate', options: { pre: "<div class='text'>", post: "</div>" }}},
				{label: "<div drama>", action: {type: 'encapsulate', options: { pre: "<div class='drama text'>", post: "</div>" }}},
				{label: "<div columns>", action: {type: 'encapsulate', options: { pre: "<div style='columns:3;-moz-columns:3;-webkit-columns:3;'>", post: "</div>" }}},
				{label: "<ref>", action: {type: 'encapsulate', options: { pre: "<ref>", post: "</ref>" }}},
				{label: "<ref name>", action: {type: 'encapsulate', options: { pre: "<ref name=''>", post: "</ref>" }}},
				{label: "<refs>", action: {type: 'encapsulate', options: { pre: "{{примечания|title=Примечания}}", post: "", ownline: true }}},
				{label: "ref+", action: {type: 'encapsulate', options: { pre: "{\{ref+|", post: "||}}" }}},
				{label: "p+", action: {type: 'encapsulate', options: { pre: "{\{p+|", post: "}}" }}},
				{label: "см. также", action: {type: 'encapsulate', options: { pre: "== См. также ==", post: "", ownline: true }}},
				{label: "ссылки", action: {type: 'encapsulate', options: { pre: "== Ссылки ==", post: "", ownline: true }}},
				{label: "Отексте", action: {type: 'encapsulate', options: { pre: "{\{Отексте\n| АВТОР                 = \n| НЕТ_АВТОРА            = \n| АВТОРЫ                = \n| НАЗВАНИЕ              = \n| ЧАСТЬ                 = \n| ПОДЗАГОЛОВОК          = \n| ИЗЦИКЛА               = \n| ИЗСБОРНИКА            = \n| СОДЕРЖАНИЕ            = \n| ДАТАСОЗДАНИЯ          = \n| ДАТАПУБЛИКАЦИИ        = \n| ЯЗЫКОРИГИНАЛА         = \n| НАЗВАНИЕОРИГИНАЛА     = \n| ПОДЗАГОЛОВОКОРИГИНАЛА = \n| ПЕРЕВОДЧИК            = \n| ИСТОЧНИК              = \n| ДРУГОЕ                = \n| ВИКИПЕДИЯ             = \n| ИЗОБРАЖЕНИЕ           = \n| ОПИСАНИЕИЗОБРАЖЕНИЯ   = \n| ПРЕДЫДУЩИЙ            = \n| СЛЕДУЮЩИЙ             = \n| КАЧЕСТВО              = \n| НЕОДНОЗНАЧНОСТЬ       = \n}}", post: "" }}},
				{label: "Отексте (lite)", action: {type: 'encapsulate', options: { pre: "{\{Отексте\n| АВТОР                 = \n| НАЗВАНИЕ              = \n| ЧАСТЬ                 = \n| ПОДЗАГОЛОВОК          = \n| ИЗЦИКЛА               = \n| ИЗСБОРНИКА            = \n| СОДЕРЖАНИЕ            = \n| ДАТАСОЗДАНИЯ          = \n| ДАТАПУБЛИКАЦИИ        = \n| ИСТОЧНИК              = \n| ДРУГОЕ                = \n| ВИКИПЕДИЯ             = \n| ОГЛАВЛЕНИЕ            = \n| КАЧЕСТВО              = \n| НЕОДНОЗНАЧНОСТЬ       = \n}}", post: "" }}},
				{label: "Обавторе", action: {type: 'encapsulate', options: { pre: "{\{Обавторе\n| ФАМИЛИЯ            = \n| ИМЕНА              = \n| ПЕРВАЯБУКВАФАМИЛИИ = \n| ВАРИАНТЫИМЁН       = \n| ОПИСАНИЕ           = \n| ДРУГОЕ             = \n| ДАТАРОЖДЕНИЯ       = \n| МЕСТОРОЖДЕНИЯ      = \n| ДАТАСМЕРТИ         = \n| МЕСТОСМЕРТИ        = \n| ИЗОБРАЖЕНИЕ        = \n| ВИКИПЕДИЯ          = \n| ВИКИЦИТАТНИК       = \n| ВИКИСКЛАД          = \n| ВИКИЛИВР           = \n| ЭСБЕ               = \n| Google             = \n}}\n", post: "" }}},
				{label: "Цитата", action: {type: 'encapsulate', options: { pre: "{\{начало цитаты}}\n", post: "\n{\{конец цитаты}}" }}},
				{label: "Версии", action: {type: 'encapsulate', options: { pre: "{\{версии|\n", post: "\n}}" }}},
				{label: "Книга", action: {type: 'encapsulate', options: { pre: "{\{книга|автор=|часть=|заглавие=|оригинал=|ссылка=|издание=|место=|издательство=|год=|том=|страницы=|страниц=|isbn=", post: "}}" }}},
				{label: "Статья", action: {type: 'encapsulate', options: { pre: "{\{статья|автор=|заглавие=|оригинал=|ссылка=|издание=|тип=|место=|год=|том=|номер=|страницы=", post: "}}" }}},
				{label: "ТСД|СЕКЦИЯ=+", action: {type: 'encapsulate', options: { pre: "|СЕКЦИЯ=", post: "+" }}},
				{label: "РСКД/", action: {type: 'encapsulate', options: { pre: "РСКД/", post: "" }}},
				{label: "{{РСКД-греч.|}}", action: {type: 'encapsulate', options: { pre: "{\{РСКД-греч.|", post: "}}" }}},
				{label: "ПБЭ", action: {type: 'encapsulate', options: { pre: "{\{ПБЭ\n|ВИКИПЕДИЯ=\n|ВИКИТЕКА=\n|ВИКИСКЛАД=\n|ВИКИЦИТАТНИК=\n|ВИКИСЛОВАРЬ=\n|ЭСБЕ=\n|МЭСБЕ=\n|ЕЭБЕ=\n|НЭС=\n|БЭАН=\n|КАЧЕСТВО=4\n}}", post: "" }}},
				{label: "ПБЭ/Автор", action: {type: 'encapsulate', options: { pre: "{\{ПБЭ/Автор|", post: "}}" }}},
				{label: "РБС", action: {type: 'encapsulate', options: { pre: "{\{РБС\n|ВИКИПЕДИЯ=\n|ВИКИТЕКА=\n|ВИКИСКЛАД=\n|ВИКИЦИТАТНИК=\n|ВИКИСЛОВАРЬ=\n|ЭСБЕ=\n|МЭСБЕ=\n|ЕЭБЕ=\n|НЭС=\n|БЭАН=\n|КАЧЕСТВО=\n}}", post: "" }}},
				{label: "РБС/Автор", action: {type: 'encapsulate', options: { pre: "{\{РБС/Автор|", post: "}}" }}},
				{label: "JE", action: {type: 'encapsulate', options: { pre: "{\{JE||", post: "}}" }}},
				{label: "ЕЭБЕ/Подпись", action: {type: 'encapsulate', options: { pre: "{\{ЕЭБЕ/Подпись|", post: "}}" }}},
				{label: "ЭСБЕ", action: {type: 'encapsulate', options: { pre: "{\{ЭСБЕ\n|ВИКИПЕДИЯ=\n|ВИКИТЕКА=\n|ВИКИСКЛАД=\n|ВИКИЦИТАТНИК=\n|ВИКИСЛОВАРЬ=\n|ВИКИНОВОСТИ=\n|ВИКИВИДЫ=\n|КАЧЕСТВО=\n}}", post: "" }}},
				{label: "ЭСБЕ/Автор2", action: {type: 'encapsulate', options: { pre: "{\{ЭСБЕ/Автор2|", post: "}}" }}},
				{label: "ЭСБЕ/дубль", action: {type: 'encapsulate', options: { pre: "== См. также ==\n{\{ЭСБЕ/дубль|", post: "||}}" }}},
				{label: "ЭСБЕ/Ссылка", action: {type: 'encapsulate', options: { pre: "{\{ЭСБЕ/Ссылка||", post: "|до=|razr=}}" }}},
				{label: "ЭСБЕ/Перен.", action: {type: 'encapsulate', options: { pre: "{\{ЭСБЕ/Перенаправление||", post: "|до=}}" }}},
				{label: "ЭСБЕ/Перен2", action: {type: 'encapsulate', options: { pre: "{\{ЭСБЕ/Перенаправление2|", post: "|}}" }}},
				{label: "ЭСБЕ/Нет статьи", action: {type: 'encapsulate', options: { pre: "{\{ЭСБЕ/Нет статьи|", post: "|}}" }}},
				{label: "ЭЛ/Ссылка", action: {type: 'encapsulate', options: { pre: "{\{ЭЛ/Ссылка||", post: "}}" }}},
				{label: "Lsafe", action: {type: 'encapsulate', options: { pre: "{\{Lsafe|", post: "|}}" }}},
				{label: "''Lsafe''", action: {type: 'encapsulate', options: { pre: "''{\{Lsafe|", post: "|}}''" }}},
				{label: "Статья в словнике", action: {type: 'encapsulate', options: { pre: "{\{Статья в словнике|", post: "|||}}" }}},
				{label:'<-w->',  action: {type:'encapsulate', options: {pre:"</div>",  post:"<div class=innertext>"}}},
				{label: "re", action: {type: 'encapsulate', options: { pre: "{\{re|", post: "||}}" }}},
				{label: "rem", action: {type: 'encapsulate', options: { pre: "{\{rem|", post: "}}" }}},
				{label: "rem2", action: {type: 'encapsulate', options: { pre: "{\{rem2|", post: "}}" }}},
				{label: "Реплика", action: {type: 'encapsulate', options: { pre: "{\{Реплика|", post: "}}" }}},
				{label: "ремарка", action: {type: 'encapsulate', options: { pre: "{\{ремарка|", post: "}}" }}}
			]
		},
  		'layout2': {
  			layout: 'characters',
  			label: 'Структура 2',
  			characters: [
  				{label:'дробь',  action: {type:'encapsulate', options: {pre:"{\{дробь|",  post:"}}"}}},
  				{label:'якорь',  action: {type:'encapsulate', options: {pre:"{\{якорь|",  post:"}}"}}},
  				{label:'shift',  action: {type:'encapsulate', options: {pre:"{\{shift|",  post:"}}"}}},
  				{label:'акут',   action: {type:'replace', options: {pre:"{\{акут}}"}}},
  				{label:'гравис', action: {type:'replace', options: {pre:"{\{гравис}}"}}},
  				{label:'fsp',    action: {type:'replace', options: {pre:"{\{fsp}}"}}},
  				{label:'trh',    action: {type:'replace', options: {pre:"{\{trh}}"}}},
  				{label:'tr',     action: {type:'replace', options: {pre:"{\{tr}}"}}},
  				{label:'trc',    action: {type:'replace', options: {pre:"{\{trc}}"}}},
  				{label:'trr',    action: {type:'replace', options: {pre:"{\{trr}}"}}},
  				{label:'th',     action: {type:'replace', options: {pre:"{\{th}}"}}},
  				{label:'td',     action: {type:'replace', options: {pre:"{\{td}}"}}},
  				{label:'tdr',    action: {type:'replace', options: {pre:"{\{tdr}}"}}},
  				{label:'td-',    action: {type:'replace', options: {pre:"{\{td-}}"}}},
  				{label:'td=',    action: {type:'replace', options: {pre:"{\{td=}}"}}},
  				{label:'trh…',   action: {type:'encapsulate', options: {pre:"{\{trh|",  post:"}}"}}},
  				{label:'tr…',    action: {type:'encapsulate', options: {pre:"{\{tr|",  post:"}}"}}},
  				{label:'trc…',   action: {type:'encapsulate', options: {pre:"{\{trc|",  post:"}}"}}},
  				{label:'trr…',   action: {type:'encapsulate', options: {pre:"{\{trr|",  post:"}}"}}},
  				{label:'th…',    action: {type:'encapsulate', options: {pre:"{\{th|",  post:"}}"}}},
  				{label:'td…',    action: {type:'encapsulate', options: {pre:"{\{td|",  post:"}}"}}},
  				{label:'tdr…',   action: {type:'encapsulate', options: {pre:"{\{tdr|",  post:"}}"}}},
  				{label:'td-…',   action: {type:'encapsulate', options: {pre:"{\{td-|",  post:"}}"}}},
  				{label:'td=…',   action: {type:'encapsulate', options: {pre:"{\{td=|",  post:"}}"}}},
  				{label:'хим1',   action: {type:'encapsulate', options: {pre:"{\{хим1||",  post:"|||left=|right=}}"}}},
  				{label:'stack',  action: {type:'encapsulate', options: {pre:"{\{stack|5|",  post:"||}}"}}},
  				{label:'inferior',     action: {type:'encapsulate', options: {pre:"{\{inferior|",  post:"|}}"}}},
  				{label:'inline float', action: {type:'encapsulate', options: {pre:"{\{inline float|r|200|",  post:"||hi=}}"}}},
  				{label:'#expr',  action: {type:'encapsulate', options: {pre:"{\{#expr:",  post:"}}"}}},
  				{label:'#if',    action: {type:'encapsulate', options: {pre:"{\{#if:",  post:"\n|\n|\n}}"}}},
  				{label:'#ifeq',  action: {type:'encapsulate', options: {pre:"{\{#ifeq:",  post:"|\n|\n|\n}}"}}},
  				{label:'#iferror',     action: {type:'encapsulate', options: {pre:"{\{#iferror:",  post:"\n|\n|\n}}"}}},
  				{label:'#ifexpr',      action: {type:'encapsulate', options: {pre:"{\{#ifexpr:",  post:"\n|\n|\n}}"}}},
  				{label:'#switch',      action: {type:'encapsulate', options: {pre:"{\{#switch:",  post:"\n|\n|\n}}"}}},
  				{label:'#titleparts',  action: {type:'encapsulate', options: {pre:"{\{#titleparts:",  post:"|1|1}}"}}},
   				{label:'sblock',  action: {type:'encapsulate', options: {pre:"{\{sblock||",  post:"}}"}}},
   				{label:'iblock',  action: {type:'encapsulate', options: {pre:"{\{iblock||",  post:"}}"}}},
   				{label:'stable',  action: {type:'encapsulate', options: {pre:"{\{stable||",  post:"}}"}}},
   				{label:'srow',  action: {type:'encapsulate', options: {pre:"{\{srow||",  post:"}}"}}},
   				{label:'scell',  action: {type:'encapsulate', options: {pre:"{\{scell||",  post:"}}"}}},
 			]
  		},
        'special': {
        	layout: 'characters',
        	label: 'Разное', 
        	characters: [ 
        		{label: "2О", action: {type: 'encapsulate', options: { pre: "{\{2О|", post: "|}}" }}},
        		{label: "Ref-en", action: {type: 'encapsulate', options: { pre: "{\{ref-en}}", post: "" }}},
        		{label: "Lbrace", action: {type: 'encapsulate', options: { pre: "{\{lbrace|", post: "}}" }}},
        		{label: "Rbrace", action: {type: 'encapsulate', options: { pre: "{\{rbrace|", post: "}}" }}},
        		{label: "Ключ сортировки", action: {type: 'encapsulate', options: { pre: "{{КЛЮЧ_СОРТИРОВКИ:", post: "}}" }}},
        		{label: "NOTOC", action: {type: 'encapsulate', options: { pre: "__NOTOC__", post: "" }}},
        		{label: "TOC", action: {type: 'encapsulate', options: { pre: "__TOC__", post: "" }}},
        		{label: "FORCETOC", action: {type: 'encapsulate', options: { pre: "__FORCETOC__", post: "" }}},
        		{label: "NOEDITSECTION", action: {type: 'encapsulate', options: { pre: "__NOEDITSECTION__", post: "" }}},
        		{label: "nowiki", action: {type: 'encapsulate', options: { pre: "<nowiki>", post: "</nowiki>" }}},
        		{label: "includeonly", action: {type: 'encapsulate', options: { pre: "<includeonly>", post: "</includeonly>" }}},
        		{label: "noinclude", action: {type: 'encapsulate', options: { pre: "<noinclude>", post: "</noinclude>" }}},
        		{label: "КачествоТекста", action: {type: 'encapsulate', options: { pre: "{\{КачествоТекста|", post: "}}" }}},
        		{label: "RusGov", action: {type: 'encapsulate', options: { pre: "{\{RusGov}}", post: "" }}},
        		{label: "Неоднозн.", action: {type: 'encapsulate', options: { pre: "{\{неоднозначность}}", post: "" }}},
        		{label: "Unsigned", action: {type: 'encapsulate', options: { pre: "{\{unsigned|", post: "}}", 'periMsg': "участник" }}},
        		{label: "Источник", action: {type: 'encapsulate', options: { pre: "{\{Источник|", post: "|}}" }}},
        		{label: "Bgw", action: {type: 'encapsulate', options: { pre: "{\{bgw|\u007e\u007e\u007e\u007e}}", post: "" }}},
        		{label: "Delete", action: {type: 'encapsulate', options: { pre: "{\{delete}}", post: "" }}},
        		{label: "*удал.", action: {type: 'encapsulate', options: { pre: "{\{closed2|1=Удалено. ~~\~~|text=", post: "}}" }}},
        		{label: "*оставл.", action: {type: 'encapsulate', options: { pre: "{\{closed2|1=Оставлено. ~~\~~|text=", post: "}}" }}},
        		{label: "*эвак.", action: {type: 'encapsulate', options: { pre: "{\{closed2|1={\{wikilivres.ru||Эвакуировано}}. ~~\~~|text=", post: "}}" }}},
        		"\u2020", "\u2022", "\u2026", "\u2032", "\u2033", "\u2034",
        		"\u2190", "\u2191", "\u2192", "\u2193", "\u2194", "\u2195", "\u2212", "\u221e", "\u22ee",
    		]
        },
      }
  });
  
  // Math
  $target.wikiEditor('addToToolbar', {sections: {'math': {type: 'booklet', label: 'Math'}}});
  $target.wikiEditor('addToToolbar', {section: 'math', pages: {
  	'math-general': {
  		layout: 'characters',
  		label: 'Math', 
  		characters: [ 
  			{label: "<center>",  action: {type: 'encapsulate', options: { pre: "<center>", post: "</center>" }}},
  			{label: "<math>",    action: {type: 'encapsulate', options: { pre: "<math>", post: "</math>" }}},
  			{label: "<math> ds", action: {type: 'encapsulate', options: { pre: "<math>\\displaystyle ", post: "</math>" }}},
  			{label: 'NumBlk',    action: {type: 'encapsulate', options: { pre:"{\{NumBlk|",  post:"|}}"}}},
  			
  			// blocks
  			{label: '\\frac',   action: {type: 'encapsulate', options: { pre:"\\frac{",  post:"}{}"}}},
  			{label: "^{...}",   action: {type: 'encapsulate', options: { pre: "^{", post: "}" }}},
  			{label: "_{...}",   action: {type: 'encapsulate', options: { pre: "_{", post: "}" }}},
  			{label: "big()",    action: {type: 'encapsulate', options: { pre: "\\left(", post: "\\right)" }}},
  			{label: "big[]",    action: {type: 'encapsulate', options: { pre: "\\left[", post: "\\right]" }}},
  			{label: "big{}",    action: {type: 'encapsulate', options: { pre: "\\left\\{", post: "\\right\\}" }}},
  			{label: '\\sqrt',   action: {type: 'encapsulate', options: { pre:"\\sqrt{",  post:"}"}}},
  			{label: '\\sqrt[]', action: {type: 'encapsulate', options: { pre:"\\sqrt[]{",  post:"}"}}},
  			{label: 'align',    action: {type: 'encapsulate', options: { pre:"\\begin{align}\n",  post:"\n\\end{align}"}}},
  			{label: 'matrix',   action: {type: 'encapsulate', options: { pre:"\\begin{matrix}\n",  post:"\n\\end{matrix}"}}},
  			{label: '\\mathrm', action: {type: 'encapsulate', options: { pre:"\\mathrm{",  post:"}"}}},
  			
  			// functions
  			{label: 'ds',       action: {type: 'replace', options: {pre: "\\displaystyle "}}},
  			{label: 'sin',      action: {type: 'replace', options: {pre: "\\sin\\,"}}},
  			{label: 'cos',      action: {type: 'replace', options: {pre: "\\cos\\,"}}},
  			{label: 'tg',       action: {type: 'replace', options: {pre: "\\mathrm{tg}\\,"}}},
  			{label: 'ctg',      action: {type: 'replace', options: {pre: "\\mathrm{ctg}\\,"}}},
  			{label: 'sec',      action: {type: 'replace', options: {pre: "\\sec\\,"}}},
  			{label: 'cosec',    action: {type: 'replace', options: {pre: "\\mathrm{cosec}\\,"}}},
  			{label: 'log',      action: {type: 'replace', options: {pre: "\\log "}}},
  			{label: 'lg',       action: {type: 'replace', options: {pre: "\\lg "}}},
  			{label: 'int',      action: {type: 'replace', options: {pre: "\\int "}}},
  			{label: '(limits)', action: {type: 'replace', options: {pre: "\\limits"}}},
  			{label: 'sum',      action: {type: 'replace', options: {pre: "\\sum "}}},
  			{label: 'lim',      action: {type: 'replace', options: {pre: "\\lim "}}},
  			
  			// operators
  			{label: '±',        action: {type: 'replace', options: {pre: "\\pm"}}},
  			{label: '∓',        action: {type: 'replace', options: {pre: "\\mp"}}},
  			{label: '·',        action: {type: 'replace', options: {pre: "\\cdot"}}},
  			{label: '...',      action: {type: 'replace', options: {pre: "\\dots"}}},
  			{label: '×',        action: {type: 'replace', options: {pre: "\\times"}}},
  			{label: '≈',        action: {type: 'replace', options: {pre: "\\approx"}}},
  			{label: '°',        action: {type: 'replace', options: {pre: "^\\circ"}}},
  			{label: '∞',        action: {type: 'replace', options: {pre: "\\infty"}}},
  			{label: '∂',        action: {type: 'replace', options: {pre: "\\partial"}}},
  			]
  			},
    'math-greek': {
  		layout: 'characters',
    	label: 'Greek',
    	characters: [
  			{label: "<math>",   action: {type: 'encapsulate', options: { pre: "<math>", post: "</math>" }}},
  			{label: '\\frac',   action: {type: 'encapsulate', options: { pre:"\\frac{",  post:"}{}"}}},
  			
    		// uppercase
    		{label: '\u0391', action: {type: 'replace', options: {pre: "\\Alpha"}}},
    		{label: '\u0392', action: {type: 'replace', options: {pre: "\\Beta"}}},
    		{label: '\u0393', action: {type: 'replace', options: {pre: "\\Gamma"}}},
    		{label: '\u0394', action: {type: 'replace', options: {pre: "\\Delta"}}},
    		{label: '\u0395', action: {type: 'replace', options: {pre: "\\Epsilon"}}},
    		{label: '\u0396', action: {type: 'replace', options: {pre: "\\Zeta"}}},
    		{label: '\u0397', action: {type: 'replace', options: {pre: "\\Eta"}}},
    		{label: '\u0398', action: {type: 'replace', options: {pre: "\\Theta"}}},
    		{label: '\u0399', action: {type: 'replace', options: {pre: "\\Iota"}}},
    		{label: '\u039a', action: {type: 'replace', options: {pre: "\\Kappa"}}},
    		{label: '\u039b', action: {type: 'replace', options: {pre: "\\Lambda"}}},
    		{label: '\u039c', action: {type: 'replace', options: {pre: "\\Mu"}}},
    		{label: '\u039d', action: {type: 'replace', options: {pre: "\\Nu"}}},
    		{label: '\u039e', action: {type: 'replace', options: {pre: "\\Xi"}}},
    		{label: '\u039f', action: {type: 'replace', options: {pre: "\\Omicron"}}},
    		{label: '\u03a0', action: {type: 'replace', options: {pre: "\\Pi"}}},
    		{label: '\u03a1', action: {type: 'replace', options: {pre: "\\Rho"}}},
    		{label: '\u03a3', action: {type: 'replace', options: {pre: "\\Sigma"}}},
    		{label: '\u03a4', action: {type: 'replace', options: {pre: "\\Tau"}}},
    		{label: '\u03a5', action: {type: 'replace', options: {pre: "\\Upsilon"}}},
    		{label: '\u03a6', action: {type: 'replace', options: {pre: "\\Phi"}}},
    		{label: '\u03a7', action: {type: 'replace', options: {pre: "\\Chi"}}},
    		{label: '\u03a8', action: {type: 'replace', options: {pre: "\\Psi"}}},
    		{label: '\u03a9', action: {type: 'replace', options: {pre: "\\Omega"}}},
    		
    		// lowercase
    		{label: '\u03b1', action: {type: 'replace', options: {pre: "\\alpha"}}},
    		{label: '\u03b2', action: {type: 'replace', options: {pre: "\\beta"}}},
    		{label: '\u03b3', action: {type: 'replace', options: {pre: "\\gamma"}}},
    		{label: '\u03b4', action: {type: 'replace', options: {pre: "\\delta"}}},
    		{label: '\u03b5', action: {type: 'replace', options: {pre: "\\epsilon"}}},
    		{label: '\u03b6', action: {type: 'replace', options: {pre: "\\zeta"}}},
    		{label: '\u03b7', action: {type: 'replace', options: {pre: "\\eta"}}},
    		{label: '\u03b8', action: {type: 'replace', options: {pre: "\\theta"}}},
    		{label: '\u03b9', action: {type: 'replace', options: {pre: "\\iota"}}},
    		{label: '\u03ba', action: {type: 'replace', options: {pre: "\\kappa"}}},
    		{label: '\u03bb', action: {type: 'replace', options: {pre: "\\lambda"}}},
    		{label: '\u03bc', action: {type: 'replace', options: {pre: "\\mu"}}},
    		{label: '\u03bd', action: {type: 'replace', options: {pre: "\\nu"}}},
    		{label: '\u03be', action: {type: 'replace', options: {pre: "\\xi"}}},
    		{label: '\u03bf', action: {type: 'replace', options: {pre: "\\omicron"}}},
    		{label: '\u03c0', action: {type: 'replace', options: {pre: "\\pi"}}},
    		{label: '\u03c1', action: {type: 'replace', options: {pre: "\\rho"}}},
    		{label: '\u03c3', action: {type: 'replace', options: {pre: "\\sigma"}}},
    		{label: '\u03c4', action: {type: 'replace', options: {pre: "\\tau"}}},
    		{label: '\u03c5', action: {type: 'replace', options: {pre: "\\upsilon"}}},
    		{label: '\u03c6', action: {type: 'replace', options: {pre: "\\phi"}}},
    		{label: '\u03c7', action: {type: 'replace', options: {pre: "\\chi"}}},
    		{label: '\u03c8', action: {type: 'replace', options: {pre: "\\psi"}}},
    		{label: '\u03c9', action: {type: 'replace', options: {pre: "\\omega"}}},
    		
    		// variants
    		{label: '\u03f5', action: {type: 'replace', options: {pre: "\\varepsilon"}}},
    		{label: '\u03d1', action: {type: 'replace', options: {pre: "\\vartheta"}}},
    		{label: '\u03f0', action: {type: 'replace', options: {pre: "\\varkappa"}}},
    		{label: '\u03d6', action: {type: 'replace', options: {pre: "\\varpi"}}},
    		{label: '\u03f1', action: {type: 'replace', options: {pre: "\\varrho"}}},
    		{label: '\u03c2', action: {type: 'replace', options: {pre: "\\varsigma"}}},
    		{label: '\u03d5', action: {type: 'replace', options: {pre: "\\varphi"}}},
    		]
    	}
    }});
  
}

// Proofread
function addOCR() {
  //if ( $('.ns-104').length && !$('.section-proofreadpage-tools').length ) $target.wikiEditor('addToToolbar', {sections: {'proofreadpage-tools': {type: 'toolbar', label: 'OCR'}}});
  $target.wikiEditor('addToToolbar', {section: 'proofreadpage-tools', groups: {
    'markup': {
      label: 'Разметка', 
      tools: {
        'OCR': {
          type: 'select',
          label: 'OCR', 
          list: { 
            'section':  {label: "section", action: {type: 'encapsulate', options: { pre: "<section begin=\"\" />\n", post: "\n<section end=\"\" />" }}},
            'twospell': {label: "ВАР", action: {type: 'encapsulate', options: { pre: "{\{ВАР\n|", post: "\n|}}" }}},
            'twospel2': {label: "ВАР2", action: {type: 'encapsulate', options: { pre: "<section begin=\"\" />\n{\{ВАР2\n|", post: "\n|}}<section end=\"\" />" }}},
            'hws':      {label: 'перенос',  action: {type:'encapsulate', options: {pre:"{\{перенос|",  post:"|}}"}}},
            'hwe':      {label: 'перенос2', action: {type:'encapsulate', options: {pre:"{\{перенос2||",  post:"}}"}}},
            'poemtit':  {label: "Poem-title", action: {type: 'encapsulate', options: { pre: "{\{poem-title|", post: "}}" }}},
            'noindent': {label: "Noindent", action: {type: 'encapsulate', options: { pre: "{\{noindent|", post: "}}" }}},
            'smallcap': {label: "Small-caps", action: {type: 'encapsulate', options: { pre: "{\{sc|", post: "}}" }}},
            'misspell': {label: "Опечатка2", action: {type: 'encapsulate', options: { pre: "{\{опечатка2|", 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.user.options.get('usebetatoolbar') == 1 ) {
	mw.loader.using( 'user.options' ).then( function () {
		
		$.when(mw.loader.using('ext.wikiEditor'), $.ready).then( 
			customizeToolbar 
		);
		
		// подключение кнопок только для ПИ Страница
  //      $.when (mw.loader.using(['ext.wikiEditor','ext.proofreadpage.page','ext.proofreadpage.article']), $.ready).then( 
  //      	addOCR
		// );
	});
	
}