ميدياويكي:Gadget-Extra-Edittools.js

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

//[[ويكيبيديا:إضافة أدوات تحرير#النص الأول]]
function pre(text) {
    return '<pre>' + text + '</pre>';
}
var customizeToolbar = function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'sections': {
                'extra': {
                        'type': 'toolbar', // Can also be 'booklet'
                        'label': 'إضافة'
                }
        }
} );
mw.loader.using('ext.wikiEditor').then(function () {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'extra',
        'groups': {
                'format': {
                        'label': 'تنسيق'
                }
        }
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'extra',
        'group': 'format',
        'tools': {
                'plainlink': {
                        label: 'وصلة بسيطة',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/9/91/Toolbar_Insert_ilink.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<span class=\"plainlinks\">",
                                        post: "</span>",
                                }
                        }
                },
                'sourcelang': {
                        label: 'لغة برمجة',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/6/6d/Toolbaricon_bold_P-1.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<source lang=\"text\">",
                                        post: "</source>",
                                }
                        }
                },
                'code': {
                        label: 'نص برمجة',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/6/62/Toolbar_code.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<code>",
                                        post: "</code>",
                                }
                        }
                },
                'pre': {
                        label: 'نص خام',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/b/b9/Toolbar_pre_vector.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<pre>",
                                        post: "</pre>",
                                }
                        }
                },
                'ltr': {
                        label: 'يسار',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/8/81/Toolbaricon_justify-left.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<div class=\"mw-content-ltr\">",
                                        post: "</div>",
                                }
                        }
                },
                'hiddencomment': {
                        label: 'تعليق مخفي',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/1/11/Toolbaricon_hiddencomment.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<!-- ",
                                        post: " -->",
                                }
                        }
                } 
        }
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'extra',
        'groups': {
                'insert': {
                        'label': 'إدراج'
                }
        }
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'extra',
        'group': 'insert',
        'tools': {
                'internallink': {
                        label: 'وصلة داخلية',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/4/48/Toolbar_Insert_link.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "[[",
                                        post: "]]",
                                }
                        }
                },
                'externallink': {
                        label: 'وصلة خارجية',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/5/55/Toolbar_insert_xlink.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "[",
                                        post: "]",
                                }
                        }
                },
                'template': {
                        label: 'قالب',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/d/dd/Vector_toolbar_template_button.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "{{",
                                        post: "}}",
                                }
                        }
                },
                'seealso': {
                        label: 'انظر أيضا',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/3/3b/Toolbaricon_regular_a_to_b.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "== انظر أيضا ==\n* [[",
                                        post: "]]\n",
                                }
                        }
                },
                'ref': {
                        label: 'إضافة مرجع',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/a/a1/Toolbaricon_insert_reference_plus.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "<ref>",
                                        post: "</ref>",
                                }
                        }
                },
                'references': {
                        label: 'مراجع',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/8/8d/Wikieditor-references.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "== المراجع ==\n{{مراجع}}\n",
                                }
                        }
                },
                'stub': {
                        label: 'بذرة',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/0/05/Toolbar_microstub.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "{{بذرة",
                                        post: "}}",
                                }
                        }
                },
                'category': {
                        label: 'تصنيف',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/c/c4/Toolbar_category.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "[[تصنيف:",
                                        post: "]]",
                                }
                        }
                },
                'layoutstub': {
                        label: 'نسق بذرة',
                        type: 'button',
                        icon: '//upload.wikimedia.org/wikipedia/commons/3/33/Toolbar_welcome.png',
                        action: {
                                type: 'encapsulate',
                                options: {
                                        pre: "'''{{",
                                        peri: 'نسخ:اسم_الصفحة_الأساسي', 
                                        post: "}}''' <ref></ref>\n\n==انظر أيضا==\n*[[]]\n\n==مراجع==\n{{مراجع}}\n\n{{بذرة}}\n\n[[تصنيف:]]",
                                }
                        }
                }
        }
} );

        $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
            'section': 'main',
            groups: {
                'heading': {
                    tools: {
                        'heading': {
                            label: 'قالب',
                            type: 'select',
                            list: {
                                'about' : {
                                    label: 'وضح',
                                    action: {
                                        type: 'encapsulate',
                                        options: {
                                            pre: pre('وضح'),
                                            //peri: peri('نص'),
                                            post: '}}',
                                            ownline: true
                                        }
                                    }
                                },
                                'references' : {
                                    label: ('مراجع'),
                                    action: {
                                        type: 'encapsulate',
                                        options: {
                                            pre: pre('مراجع'),
                                            post: '}}',
                                            ownline: false
                                        }
                                    }
                                },
                                'stub' : {
                                    label: ('بذرة'),
                                    action: {
                                        type: 'encapsulate',
                                        options: {
                                            pre: pre('بذرة'),
                                            post: '}}',
                                            ownline: false
                                        }
                                    }
                                },
                                'disambiguation' : {
                                    label: ('توضيح'),
                                    action: {
                                        type: 'encapsulate',
                                        options: {
                                            pre: pre('توضيح'),
                                            post: '}}',
                                            ownline: false
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        });
});
};

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 );
                        } );
                }
        } );
}