Difference between revisions of "User:Root/common.js"

From www.PSALTIKI.info
Jump to: navigation, search
m
m
Line 53: Line 53:
 
   });
 
   });
 
*/
 
*/
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
+
 
'section': 'info',
+
var customizeToolbar = function () {
'pages': {
+
/* Your code goes here */
'colors': {
+
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'layout': 'table',
+
'sections': {
'label': 'Colors',
+
'emoticons': {
'headings': [
+
'type': 'toolbar', // Can also be 'booklet'
{ text: 'Name' }, // or use textMsg for localization, see also above
+
'label': 'Emoticons'
{ text: 'Temperature' },
+
// or 'labelMsg': 'section-emoticons-label' for a localized label
{ text: 'Swatch' }
 
],
 
'rows': [
 
{
 
'name': { text: 'Red' },
 
'temp': { text: 'Warm' },
 
'swatch': { html: '<div style="width:10px;height:10px;background-color:red;">' }
 
},
 
{
 
'name': { text: 'Blue' },
 
'temp': { text: 'Cold' },
 
'swatch': { html: '<div style="width:10px;height:10px;background-color:blue;">' }
 
},
 
{
 
'name': { text: 'Silver' },
 
'temp': { text: 'Neutral' },
 
'swatch': { html: '<div style="width:10px;height:10px;background-color:silver;">' }
 
}
 
]
 
 
}
 
}
 
}
 
}
 
} );
 
} );
 +
};
 +
 +
/* 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( customizeToolbar );
 +
}
 +
} );
 +
}

Revision as of 03:00, 22 June 2017

/**
 * Extra buttons in toolbar
 * @stats [[File:Krinkle_InsertWikiEditorButton.js]]
 */
$.ajax({
	url: '//localhost:8001/index.php?title=MediaWiki:InsertWikiEditorButton.js&action=raw&ctype=text/javascript',
	dataType: 'script',
	cache: true
}).done(function () {

	// Happy face
	krInsertWikiEditorButton({
		id: "mw-text-blue",
		icon: "/images/BoutonsDefaut03.png",
		label: 'make-text-blue',
		insertBefore: '<font color="blue">',
		insertAfter: '</font>',
		sampleText: 'past your text'
	});

	// Monkey
	krInsertWikiEditorButton({
		id: 'mw-text-red',
		icon: '/images/redtext.png',
		label: 'make-text-red',
		insertBefore: '<font color="red">',
		insertAfter: '</font>',
		sampleText: 'past your text'
	});

});


/*
  $('#wpTextbox1').wikiEditor('addToToolbar', {
    section: 'main',
    group: 'format',
    tools: {
      'bluetext': {
        label: 'Blue text',
        type: 'button',
        icon: '/images/BoutonsDefaut03.png',
        action: {
          type: 'encapsulate',
          options: {
            pre: "<font color='blue'>",
            peri: "Insert comment here",
            post: "</font>"
          }
        }
      }
    }
  });
*/

var customizeToolbar = function () {
	/* Your code goes here */
	$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'sections': {
		'emoticons': {
			'type': 'toolbar', // Can also be 'booklet'
			'label': 'Emoticons'
			// or 'labelMsg': 'section-emoticons-label' for a localized label
		}
	}
} );
};

/* 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( customizeToolbar );
		}
	} );
}