ميدياويكي:Gadget-WikiEditor.js

من ويكيبيديا، الموسوعة الحرة

ملاحظة: بعد الحفظ، قد يلزمك إفراغ الكاش لرؤية التغييرات.

//removings
var customizeToolbar=function(){$("#wpTextbox1").wikiEditor("removeFromToolbar",{section:"main",group:"format",tool:"bold"}).wikiEditor("removeFromToolbar",{section:"main",group:"format",tool:"italic"}).wikiEditor("removeFromToolbar",{section:"main",group:"insert"}).wikiEditor("removeFromToolbar",{section:"help"}).wikiEditor("removeFromToolbar",{section:"characters"})};if($.inArray(mw.config.get("wgAction"),["edit","submit"])!==-1){mw.loader.using("user.options",function(){if(mw.user.options.get("usebetatoolbar")){mw.loader.using("ext.wikiEditor",function(){$(document).ready(customizeToolbar)})}})}

var customizeToolbar = function() {
	/*code goes here*/

/*	//§action 
	$("#wpTextbox1").wikiEditor("addToToolbar", {
		section: "main",
		group: "format", //"action" actually
		tools: {


		}
	});*/




	//§insert
	$('#wpTextbox1').wikiEditor('addToToolbar', {
		'section': 'main',
		'groups': {
			'ins': { // "insert"
				'label': '' // or use labelMsg for a localized label, see above
			}
		}
	});
	$('#wpTextbox1').wikiEditor('addToToolbar', {
		'section': 'main',
		'group': 'ins',
		'tools': {
			save: {
				label: "حفظ",
				type: "button",
				icon: "//upload.wikimedia.org/wikipedia/commons/f/f6/Toolbar_save_changes.png",
				action: {
					type: "callback",
					execute: function(context) {
						$('#editform').submit();
					}
				}
			},
			preview: {
				label: "معاينة",
				type: "button",
				icon: "//upload.wikimedia.org/wikipedia/commons/b/bd/Toolbar_preview.png",
				action: {
					type: "callback",
					execute: function(context) {
						$('#wpPreview').click();
					}
				}
			},
			bold: {
				label: "b",
				type: "button",
				icon: "//commons.wikimedia.org/w/load.php?modules=oojs-ui.styles.icons-editing-styling&image=bold&format=rasterized&lang=ar&version=29d8adb8cee9",
				action: {
					type: "encapsulate",
					options: {
						pre: "'''",
						peri: "\{\{نسخ:اسم_الصفحة_الأساسي\}\}",
						post: "'''",
					}
				}
			},
			internallink: {
				label: "wl",
				type: "button",
				icon: "//upload.wikimedia.org/wikipedia/commons/4/48/Toolbar_Insert_link.png",
				action: {
					type: "encapsulate",
					options: {
						pre: "[[",
						peri: "en:",
						post: "]]",
					}
				}
			},
			template: {
				label: "tl",
				type: "button",
				icon: "//upload.wikimedia.org/wikipedia/commons/4/4a/Norwegian_template_sign.png",
				action: {
					type: "encapsulate",
					options: {
						pre: "{{",
						peri: "توضيح",
						post: "}}",
					}
				}
			},
			ref: {
				label: "ref",
				type: "button",
				icon: "//upload.wikimedia.org/wikipedia/commons/a/a1/Toolbaricon_insert_reference_plus.png",
				action: {
					type: "encapsulate",
					options: {
						pre: "<ref>\n",
						peri: "[]",
						post: "\n</ref>",
					}
				}
			},
			references: {
				label: "refs",
				type: "button",
				icon: "//upload.wikimedia.org/wikipedia/commons/3/34/Toolbar_references.png",
				action: {
					type: "encapsulate",
					options: {
						pre: "==مراجع==\n{{مراجع}}",
					}
				}
			}

		}
	});



	//§format
	$('#wpTextbox1').wikiEditor('addToToolbar', {
		'section': 'main',
		'groups': {
			'form': { // "format"
				'label': '' // or use labelMsg for a localized label, see above
			}
		}
	});
/*	$("#wpTextbox1").wikiEditor("addToToolbar", {
		section: "main",
		group: "form",
		tools: {

		}
	});*/

	/*code ends here*/
};

/* 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', 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);
		}
	});
}
// Add the customizations to LiquidThreads' edit toolbar, if available
mw.hook('ext.lqt.textareaCreated').add(customizeToolbar);

mw.util.addCSS('*[class^="group group-codeeditor"]{float: left !important;}');