Difference between revisions of "MediaWiki:Common.js"

From GATE
Line 644: Line 644:
 
$(function() {
 
$(function() {
 
     $( '#wpTextbox1' ).on( 'wikiEditor-toolbar-buildSection-characters', function (event, section) {
 
     $( '#wpTextbox1' ).on( 'wikiEditor-toolbar-buildSection-characters', function (event, section) {
         section.pages.symbols.characters.push('\u0303');
+
         section.pages.latin.characters.push('\u0303');
 
     });
 
     });
 
});
 
});

Revision as of 09:45, 23 January 2018

/* Any JavaScript here will be loaded for all users on every page load. */
var customizeToolbar = function () {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'sections': {
		'edition': {
			'type': 'toolbar', // Can also be 'booklet'
			'label': 'Edition'
			// or 'labelMsg': 'section-emoticons-label' for a localized label
		}
	}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	section: 'edition',
	groups: {
		'tei': {
			'label': 'TEI'
		}
	}
} );

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'edition',
        group: 'tei',
	tools: {
		"head": {
			label: 'Head: "the <head> element is used to identify a heading prefixed to the start of any textual division, at any level" (TEI P5).',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/d/db/TEI_Head22px.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<head>',
					post: "</head>"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'edition',
        group: 'tei',
	tools: {
		"paragraph": {
			label: 'Paragraph: the <p> tag "marks paragraphs in prose" (TEI P5)',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/b/b3/TEI_P22px.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<p>',
					post: "</p>"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'edition',
        group: 'tei',
	tools: {
		"lb": {
			label: 'Line break: "<lb> (line break) marks the start of a new (typographic) line in some edition or version of a text" (TEI P5).',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/1/1b/TEI_Lb22px.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<lb/>',
					ownline: false
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'edition',
        group: 'tei',
	tools: {
		"pb": {
			label: 'Page break: "<pb> (page break) marks the start of a new page in a paginated document" (TEI P5).',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/2/28/TEI_Pb22px.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<pb/>',
					ownline: true
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'edition',
        group: 'tei',
	tools: {
		"abbreviation": {
			label: 'Abbreviation: "<abbr> (abbreviation) contains an abbreviation of any sort." (TEI P5).',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/f/f7/TEI_Abbr22px.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<abbr>',
					post: "</abbr>"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'edition',
        group: 'tei',
	tools: {
		"add": {
			label: 'Addition: "<add> (addition) contains letters, words, or phrases inserted in the source text by an author, scribe, or a previous annotator or corrector" (TEI P5).',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/0/09/TEI_Add22px.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<add>',
					post: "</add>"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'edition',
        group: 'tei',
	tools: {
		"del": {
			label: 'Deletion: "<del> (deletion) contains a letter, word, or passage deleted, marked as deleted, or otherwise indicated as superfluous or spurious in the copy text by an author, scribe, or a previous annotator or corrector" (TEI P5).',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/b/bb/TEI_Del22px.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<del>',
					post: "</del>"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'edition',
        group: 'tei',
	tools: {
		"gap": {
			label: 'Gap: "<gap> indicates a point where material has been omitted in a transcription, whether for editorial reasons described in the TEI header, as part of sampling practice, or because the material is illegible, invisible, or inaudible" (TEI P5).',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/3/3e/TEI_Gap22px.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<gap/>',
					ownline: false
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'edition',
        group: 'tei',
	tools: {
		"unclear": {
			label: 'Unclear: "<unclear> contains a word, phrase, or passage which cannot be transcribed with certainty because it is illegible or inaudible in the source" (TEI P5).',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/c/c7/TEI_Unclear22px.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<unclear>',
					post: "</unclear>"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'edition',
        group: 'tei',
	tools: {
		"sic": {
			label: 'Sic: "<sic> (Latin for thus or so) contains text reproduced although apparently incorrect or inaccurate" (TEI P5).',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/9/91/TEI_Sic22px.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<sic>',
					post: "</sic>"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'edition',
        group: 'tei',
	tools: {
		"underline": {
			label: 'Underline: marks underlined text.',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/b/b5/TEI_Und22px.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<hi rend="underline">',
					post: "</hi>"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'edition',
        group: 'tei',
	tools: {
		"superscript": {
			label: 'Superscript: marks a superscripted text.',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/9/92/TEI_Sup22px.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<hi rend="superscript">',
					post: "</hi>"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'edition',
        group: 'tei',
	tools: {
		"note": {
			label: 'Note: "<note> contains a note or annotation" (TEI P5).',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/f/f1/TEI_Note22px.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<note>',
					post: "</note>"
				}
			}
		}
	}
});
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	section: 'edition',
	groups: {
		'text': {
			'label': 'Text'
		}
	}
} );
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'edition',
        group: 'text',
	tools: {
		"jointed": {
			label: 'Jointed text',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/1/18/Jointed.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<span title="" style="background:PaleGreen">[[isJointed::',
					post: "]]</span>"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'edition',
        group: 'text',
	tools: {
		"disjointed": {
			label: 'Disjointed text',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/5/5a/Disjointed.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<span title="" style="background:Gold">[[isDisjointed::',
					post: "]]</span>"
				}
			}
		}
	}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'edition',
        group: 'text',
	tools: {
		"error": {
			label: 'Grammatical error',
			type: 'button',
			icon: 'https://upload.wikimedia.org/wikipedia/commons/2/23/Toolbar_cross.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<span title="" style="color:red">ˣ</span>[[isGrammaticalError::',
					post: "]]"
				}
			}
		}
	}
});

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'sections': {
		'annotation': {
			'type': 'toolbar', // Can also be 'booklet'
			'label': 'Annotation'
			// or 'labelMsg': 'section-emoticons-label' for a localized label
		}
	}
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	section: 'annotation',
	groups: {
		'entities': {
			'label': 'Entities'
		}
	}
} );

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'annotation',
        group: 'entities',
	tools: {
		"name": {
			label: 'Annotate names',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/5/57/Icon_Users.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '[[citesName::',
					post: "]]"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'annotation',
        group: 'entities',
	tools: {
		"place": {
			label: 'Annotate places',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/7/76/Icon_Placeholder.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '[[citesPlace::',
					post: "]]"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'annotation',
        group: 'entities',
	tools: {
		"work": {
			label: 'Annotate works',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/e/e0/Icon_work.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '[[citesWork::',
					post: "]]"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'annotation',
        group: 'entities',
	tools: {
		"object": {
			label: 'Annotate objects',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/7/7e/Icon_object.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '[[citesObject::',
					post: "]]"
				}
			}
		}
	}
});
/*
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'annotation',
        group: 'entities',
	tools: {
		"language": {
			label: 'Annotate language',
			type: 'select',
			list: {
                      'Guaranì': {
                        labelMsg: 'wikieditor-toolbar-tool-heading-2',
                        action: {
                          type: 'encapsulate',
                          options: {
                            pre: '== ',
                            periMsg: 'wikieditor-toolbar-tool-heading-example',
                            post: ' ==',
                            regex: /^(\s*)(={1,6})(.*?)\2(\s*)$/,
                            regexReplace: '$1==$3==$4',
                            ownline: true
                          }
                        }
                      },
                      'heading-3': {
                        labelMsg: 'wikieditor-toolbar-tool-heading-3',
                        action: {
                          type: 'encapsulate',
                          options: {
                            pre: '=== ',
                            periMsg: 'wikieditor-toolbar-tool-heading-example',
                            post: ' ===',
                            regex: /^(\s*)(={1,6})(.*?)\2(\s*)$/,
                            regexReplace: '$1===$3===$4',
                            ownline: true
                          }
                        }
                      }
},
		}
	}
});
*/
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'annotation',
        group: 'entities',
	tools: {
		"term": {
			label: 'Annotate terms',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/b/b3/Icon_term.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '[[Glossary-term::',
					post: "]]"
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'annotation',
        group: 'entities',
	tools: {
		"language": {
			label: 'Annotate languages',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/0/05/Icon_language.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '[[citesLanguage::',
					post: "]]"
				}
			}
		}
	}
});


$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'advanced',
        group: 'format',
	tools: {
		"center": {
			label: 'Center text',
			type: 'button',
			icon: 'https://upload.wikimedia.org/wikipedia/commons/c/c3/Toolbaricon_justify-center.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<center>',
					post: "</center>"
				}
			}
		}
	}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'advanced',
        group: 'insert',
	tools: {
		"center": {
			label: 'Signature',
			type: 'button',
			icon: 'https://upload.wikimedia.org/wikipedia/commons/b/be/Insert-signature3.svg',
			action: {
				type: 'encapsulate',
				options: {
					pre: '-- [[User:ManciniWiki|ManciniWiki]] ([[User talk:ManciniWiki|talk]]) 11:17, 22 December 2017 (CET)',
					ownline: false
				}
			}
		}
	}
});
/*
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	section: 'annotation',
	groups: {
		'opinions': {
			'label': 'Opinions'
		}
	}
} );
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'annotation',
        group: 'opinions',
	tools: {
		"assent": {
			label: 'Assent',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/e/e8/Assent_Annotation_Button_05.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<span title="Assent" style="background:PaleGreen">[[Assent::≡≡]]</span>',
					ownline: false
				}
			}
		}
	}
});

$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'annotation',
        group: 'opinions',
	tools: {
		"dissent": {
			label: 'Dissent',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/8/87/Dissent_Annotation_Button.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<span title="Dissent" style="background:OrangeRed">[[Dissent::≠≠]]</span>',
					ownline: false
				}
			}
		}
	}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'annotation',
        group: 'opinions',
	tools: {
		"laudation": {
			label: 'Laudation',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/9/94/Laudation_Annotation_Button.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<span title="Laudation" style="background:Pink">[[Laudation::++]]</span>',
					ownline: false
				}
			}
		}
	}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'annotation',
        group: 'opinions',
	tools: {
		"question": {
			label: 'Question',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/2/26/Question_Annotation_Button.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<span style="background:Yellow">',
					post: '</span>'
				}
			}
		}
	}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'annotation',
        group: 'opinions',
	tools: {
		"recommendation": {
			label: 'Recommendation',
			type: 'button',
			icon: 'http://gate.unigre.it/mediawiki/images/0/0f/Recomendation_Annotation_Button.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<span title="Recommendation" style="background:PaleTurquoise" >[[Recommendation::++++]]</span>',
					ownline: false
				}
			}
		}
	}
}); */
}; 

$(function() {
    $( '#wpTextbox1' ).on( 'wikiEditor-toolbar-buildSection-characters', function (event, section) {
        section.pages.latin.characters.push('\u0303');
    });
});

/* 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.toolbar' ), $.ready
			).then( function(){ window.setTimeout(customizeToolbar, 1000); } );
		}
	 } );
}

$('div#bodyContent a').click(function(e) {
	if ($(e.target.hash)) {
		var hash = e.currentTarget.hash.substring(1);
		var anchorTag = $("span[id='" + hash + "']");
		$('html, div#content.mw-body').animate({
			scrollTop : anchorTag.offset().top - 52
		}, 250);
	}
});