Wikipedista:Ján Kepler/common.js

Z Wikipedie, otevřené encyklopedie

Poznámka: Po uložení musíte vyprázdnit mezipaměť vašeho prohlížeče, jinak změny neuvidíte.

// Skript převzatý od [[Wikipedista:Draceane/tools.js]] <nowiki>

var customizeToolbar = function () {
	// návod https://www.mediawiki.org/wiki/Extension:WikiEditor/Toolbar_customization
	$( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
		'section': 'main',
		'group': 'insert',
		'tool': 'signature'
	} );

	var addToToolbar = [{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Odkaz',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/b/b7/Interlink_alt.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '[[',
						peri: '',
						post: ']]'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Uvozovky',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/6/65/Upper_apostrophe_toolbar_symbol.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '„',
						peri: '',
						post: '“'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'ibosoba',
				type: 'button',
				icon: '//upload.wikimedia.org/wikipedia/commons/7/7d/Face_%28CoreUI_Icons_v1.0.0%29.svg',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{Infobox - osoba}}\n',
						post: ''
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'pracuje se',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/0/0c/Button_P_template.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{pracuje se||~~~~}}\n',
						post: ''
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'ibsidlosveta',
				type: 'button',
				icon: '//upload.wikimedia.org/wikipedia/commons/5/55/Toolbar_insert_xlink.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{Infobox - sídlo světa}}\n',
						post: ''
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Závěrečné sekce',
                type: 'button',
                icon: 'https://upload.wikimedia.org/wikipedia/commons/c/cb/Button_wikipedia.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: '== Odkazy ==\n=== Reference ===\n<references />\n=== Externí odkazy ===\n* {{Commonscat}}\n* \n{{Portály|',
                        peri: '',
                        post: '}}'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Pevná mezera',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/5/55/Button_nbsp_1.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '',
						peri: '&nbsp;',
						post: ''
					}
				}
			}
		}
	},
		{
		section: 'advanced',
		group: 'insert',
		tools: {
			buttonId: {
				label: 'Upravit',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/2/2e/Button_broom.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{Upravit}}',
						peri: '',
						post: ''
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'insert',
		tools: {
			buttonId: {
				label: 'Urgentně upravit',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/f/f3/Button_broom2.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:Urgentně upravit}}',
						peri: '',
						post: ''
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'insert',
		tools: {
			buttonId: {
				label: 'Neověřeno',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/0/0b/Button_fuente.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{Neověřeno}}',
						peri: '',
						post: ''
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'insert',
		tools: {
			buttonId: {
				label: 'Urgentně ověřit',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/b/b8/Bouton_Faut_sourcer.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:Urgentně ověřit}}',
						peri: '',
						post: ''
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'insert',
		tools: {
			buttonId: {
				label: 'Významnost',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/5/50/Button_tidyman.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:Významnost}}',
						peri: '',
						post: ''
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'insert',
		tools: {
			buttonId: {
				label: 'Subpahýl',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/a/a5/Button_STUB.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:Subpahýl}}',
						peri: '',
						post: ''
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'insert',
		tools: {
			buttonId: {
				label: 'Přeložit',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/1/12/Toolbaricon_bold_P.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:Přeložit}}',
						peri: '',
						post: ''
					}
				}
			}
		}
	},
		{
		section: 'advanced',
		group: 'insert',
		tools: {
			buttonId: {
				label: 'Zdroj?',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/9/94/Button_zdroj.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{Doplňte zdroj}}',
						peri: '',
						post: ''
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'insert',
		tools: {
			buttonId: {
				label: 'Fakt?',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/9/94/Button_zdroj.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:Fakt}}',
						peri: '',
						post: ''
					}
				}
			}
		}
	},
	{
		 section: 'advanced',
        group: 'insert',
        tools: {
            buttonId: {
                label: 'Reference',
                type: 'button',
                icon: 'https://upload.wikimedia.org/wikipedia/commons/3/34/Toolbar_references.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: '<references/>',
                        peri: '',
                        post: ''}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'insert',
		tools: {
			buttonId: {
				label: 'Copyvio',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/5/58/Button_black_copyright.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{copyvio|zdroj=',
						peri: '',
						post: '}}'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Zamítnuto',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/a/a0/Button_keep.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: ': {{Hotovo}} ',
						peri: '',
						post: '--~~~~'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Zamítnuto',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/1/13/Button_delete.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: ': {{Nevyřešeno}} ',
						peri: '',
						post: '--~~~~'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Spam',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/0/00/Warncreate4.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:spam}} ',
						peri: '',
						post: '--~~~~'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Experimenty0',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/3/3d/EXPBT0.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:Experimenty0}}',
						peri: ' ',
						post: '--~~~~'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Experimenty',
				type: 'button',
				icon: '//upload.wikimedia.org/wikipedia/commons/b/b0/EXPBT1.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:Experimenty}}',
						peri: ' ',
						post: '--~~~~'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Experimenty2',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/a/ae/EXPBT2.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:Experimenty2}}',
						peri: ' ',
						post: '--~~~~'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Experimenty3',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/e/e5/EXPBT3.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:Experimenty3}}',
						peri: ' ',
						post: '--~~~~'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Experimenty2o',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/3/3a/EXPBT2-o.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:Experimenty2o}}',
						peri: ' ',
						post: '--~~~~'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Experimenty3o',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/c/ca/EXPBT3-o.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:Experimenty3o}}',
						peri: ' ',
						post: '--~~~~'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Nevýznamná osoba',
				type: 'button',
				icon: '//upload.wikimedia.org/wikipedia/commons/8/83/Button_biocitas.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:Nevýznamná osoba}}',
						peri: ' ',
						post: '--~~~~'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Vítejte',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/a/a9/Button_tournesol.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:Vítejte|',
						peri: '',
						post: '}} --~~~~'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Shrnutí',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/4/48/Deletewarn1.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:Shrnutí',
						peri: '',
						post: '}} --~~~~'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Náhled',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/b/bb/Seealso.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:Náhled',
						peri: '',
						post: '}} --~~~~'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Experimenty na uživatelské stránce',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/4/41/Button_userandarticle.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{subst:ExperimentyUP|',
						peri: '',
						post: '}} --~~~~'
					}
				}
			}
		}
	},
	{
		section: 'advanced',
		group: 'format',
		tools: {
			buttonId: {
				label: 'Ping',
				type: 'button',
				icon: 'https://upload.wikimedia.org/wikipedia/commons/4/49/Button_talk.png',
				action: {
					type: 'encapsulate',
					options: {
						pre: '{{Ping|',
						peri: '',
						post: '|skrýt=ano}}'
					}
				}
			}
		}
	}];
	addToToolbar.forEach( function ( obj ) {
		$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', obj );
	} );
};

/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -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 );
		}
	} );
}

//pouze pro starý editor, inspirace
mw.loader.using( 'mediawiki.action.edit', function () {

		var button = {
			id: 'button-comment',
			imageFile: 'http://upload.wikimedia.org/wikipedia/commons/9/91/Button_cite_web.png',
			speedTip: 'Citace elektronické monografie (webu)',
			tagOpen: '<ref>{{Citace elektronické monografie\n | příjmení = \n | jméno = \n | odkaz na autora = \n | titul = \n | url = \n | datum vydání = \n | datum aktualizace = \n | datum přístupu = ' + (y = new Date().getFullYear ()) + '-' + (m = new Date ().getMonth () + 1) + '-' + (d = new Date ().getDate ()) + '\n| vydavatel = \n | místo = \n | jazyk = \n}}</ref>',
			tagClose: '',
			sampleText: ''
		};
		mw.toolbar.addButton( button.imageFile, button.speedTip, button.tagOpen, button.tagClose, button.sampleText, button.id, button.id );

} );
// </nowiki>