User:DG/common.js

From CODECS: Online Database and e-Resources for Celtic Studies
< Dennis Groenewegen
Revision as of 21:31, 12 October 2019 by DG (talk | contribs)

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Load in namespace 6 */

if (mw.config.get('wgNamespaceNumber')==6 && mw.config.get('wgAction')=='view') {
	mw.loader.load('//tools.wmflabs.org/imagemapedit/ime.js');
}


/* Medium editor */

function setupMedium() {      

			var editor = new MediumEditor('.medium-wysiwyg', {
				toolbar: {
					/* These are the default options for the toolbar,
					   if nothing is passed this is what is used */
					disableReturn: true,
					disableDoubleReturn: true,
					disableExtraSpaces: true, 
					
					allowMultiParagraphSelection: true,
					buttons: ['bold', 
							  'italic', 
							  'underline', 
							  'superscript', 
							  'subscript'
					],
					diffLeft: 0,
					diffTop: -10,
					firstButtonClass: 'medium-editor-button-first',
					lastButtonClass: 'medium-editor-button-last',
					relativeContainer: null,
					standardizeSelectionStart: false,
					static: false,
					/* options which only apply when static is true */
					align: 'center',
					sticky: false,
					updateOnEmptySelection: false,
					
					toolbar: false,
					keyboardCommands: false,
					commands: [
					{
						command: false,
						key: 'B', // for bold
						meta: true,
						shift: false
					}
					]
				}
			});

}
/* end of function now declare it  */

$(function() {
	if ($('.medium-wysiwyg')[0]) {
    
		if( typeof( MediumEditor ) === "undefined" ) {
			console.log('no MediumEditor, loading...');
			//$.when($.getScript('/vhcodecs/resources/lib/jquery.ui/jquery.ui.sortable.js')).done(function() {
					$.getScript('/vhcodecs/custom/js/medium/dist/js/medium-editor.js').done(function() {
						setupMedium();
					});
			//});
		} else setupMedium();
    
  }
});