ميډياويکي:Gadget-Extra-Edittools2.js

د ويکيپېډيا، وړیا پوهنغونډ له خوا

د نور تفصيل لپاره د غځول په تنۍ کلېک وکړئيادښت: د غوره توبونو د خوندي کولو وروسته، خپل د کتنمل (بروزر) ساتل شوې حافظه تازه کړی.د نور تفصيل لپاره د غځول په تنۍ کلېک وکړئ.

  • فايرفاکس/ سفري: په دې کتنمل کې د Reload د ټکوهلو په وخت د Shift تڼۍ نيولې وساتی، او يا هم Ctrl-F5 يا Ctrl-Rتڼۍ کېښکاږۍ (په Apple Mac کمپيوټر باندې ⌘-R کېښکاږۍ)
  • گووگل کروم: په دې کتنمل کې د Ctrl-Shift-R تڼۍ کېښکاږۍ (د مک لپاره ⌘-Shift-R)
  • انټرنټ اېکسپلورر: په دې کتنمل کې د Refresh د ټکوهلو په وخت کې د Ctrl تڼۍ کېښکاږلې ونيسۍ، او يا هم د Ctrl-F5 تڼۍ کېښکاږۍ
  • اوپرا: په دې کتنمل کې د خپل براوزر ساتل شوې حافظه پدې توگه سپينولی شی Tools→Preferences
لاسوند[جوړول]
//[[ويكيبيديا:إضافة أدوات تحرير#النص الثاني]]
/*
[[:he:Mediawiki:Edittoolbar.js]]
{{Oldid|:no:MediaWiki:Common.js|10296967}}
[[:zh:Mediawiki:Gadget-Edittools-vector.js]]
*/
// Description: Modify parts of the toolbar to better suit this projects needs
(function (mw, $, undefined) {

    // function to build complete labels, just to get rid of some pesky errors
    var label = function (msg, txt, before, after) {
        var str = '';
        if (before === undefined ? true : before) str += "{" + "{";
        str += msg;
        if (after === undefined ? true : after) str += "}" + "}";
        if (txt) str += " – " + txt;
        return str;
    };

    // function to build pre-parts of the templates, just to get rid of some pesky errors
    var pre = function (msg, txt, before) {
        var str = '';
        if (before === undefined ? true : before) str += "{" + "{";
        str += msg;
        if (txt) str += txt;
        return str;
    };

    // function to build peri-parts of the templates, just to get rid of some pesky errors
    var peri = function (msg, txt, before, after) {
        var str = '';
        if (before === undefined ? true : before) str += "{" + "{";
        str += msg;
        if (txt) str += txt;
        if (after === undefined ? true : after) str += "}" + "}";
        return str;
    };

    // get timestamp for templates
    var now = new Date();
    var timestamp = now.getUTCFullYear() + '-' + (now.getUTCMonth() < 9 ? '0' : '') + (now.getUTCMonth() + 1) + '-' + (now.getUTCDate() < 9 ? '0' : '') + now.getUTCDate();

    // customization for the original toolbar
    var customizeOrigToolbar = function () {};

    // customization for the beta toolbar
    var customizeBetaToolbar = function () {

        // Add button for inserting double square brackets (popular feature of old toolbar)
        $('#wpTextbox1').wikiEditor('addToToolbar', {
            'section': 'main',
            'group': 'insert',
            'tools': {
                'references': {
                    label: 'مراجع',
                    type: 'button',
                    icon: '//upload.wikimedia.org/wikipedia/commons/7/7f/Button_poeme_transparent.png',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: "\n==مراجع==\n{{مراجع}}\n",
                        }
                    }
                },

                'category': {
                    label: 'وېشنيزه',
                    type: 'button',
                    icon: '//upload.wikimedia.org/wikipedia/commons/c/c4/Button_titre_transparent.png',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: "[[وېشنيزه:",
                            post: "]]"
                        }
                    }
                },

                'template': {
                    label: 'کينډۍ',
                    type: 'button',
                    icon: '//upload.wikimedia.org/wikipedia/commons/4/4a/Norwegian_template_sign.png',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: "{{",
                            periMsg: 'کينډۍ|',
                            post: "}}"
                        }
                    }
                }
            }
        });
        $('#wpTextbox1').wikiEditor('addToToolbar', {
            'section': 'advanced',
            'group': 'format',
            'tools': {
                'hidden': {
                    label: 'تعليق مخفي',
                    type: 'button',
                    icon: '//upload.wikimedia.org/wikipedia/commons/1/11/Toolbaricon_hiddencomment.png',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: "<!-- ",
                            periMsg: 'تعليق',
                            post: " -->"
                        }
                    }
                },
                'center': {
                    label: 'كتابة في الوسط',
                    type: 'button',
                    icon: '//upload.wikimedia.org/wikipedia/commons/thumb/c/ce/Gnome-format-justify-center.svg/22px-Gnome-format-justify-center.svg.png',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: "<center>",
                            periMsg: 'وسط',
                            post: "</center>"
                        }
                    }
                },

                'left': {
                    label: 'كتابة من اليسار',
                    type: 'button',
                    icon: '//upload.wikimedia.org/wikipedia/commons/thumb/c/ce/Gnome-format-justify-left.svg/22px-Gnome-format-justify-left.svg',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: "<div class=\"mw-content-ltr\">",
                            periMsg: 'يسار',
                            post: "</div>"
                        }
                    }
                },

                'lang': {
                    label: 'كتابة بلغة معينة',
                    type: 'button',
                    icon: '//upload.wikimedia.org/wikipedia/commons/0/09/Toolbaricon_bold_粗.png',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: "<span lang=\"und\">",
                            periMsg: 'كتابة',
                            post: '</span>'
                        }
                    }
                },

                'source': {
                    label: 'كتابة بلغة برمجة معينة',
                    type: 'button',
                    icon: '//upload.wikimedia.org/wikipedia/commons/6/6d/Toolbaricon_bold_P-1.png',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: "<source lang=\"text\">",
                            periMsg: 'كتابة برمجية',
                            post: '</source>'
                        }
                    }
                },

                'math': {
                    label: 'صيغة رياضية لاتينية',
                    type: 'button',
                    icon: '//upload.wikimedia.org/wikipedia/commons/1/1c/Toolbaricon_math.png',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: "<math>",
                            periMsg: 'صيغة رياضية',
                            post: "</math>"
                        }
                    }
                },

                'includeonly': {
                    label: 'تضمين في قالب',
                    type: 'button',
                    icon: '//upload.wikimedia.org/wikipedia/commons/b/bb/Toolbaricon_regular_I.png',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: "<includeonly>",
                            periMsg: 'قالب مضمن',
                            post: "</includeonly>"
                        }
                    }
                },

                'noinclude': {
                    label: 'إظهار في قالب',
                    type: 'button',
                    icon: '//upload.wikimedia.org/wikipedia/commons/5/55/Toolbaricon_no_include.png',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: "<noinclude>",
                            periMsg: 'قالب غير مضمن',
                            post: "</noinclude>"
                        }
                    }
                }
            }
        });

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

    /* Check if we are in edit mode and the required modules are available and then customize the toolbar */
    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 () {
                    $(customizeBetaToolbar);
                });
            }
        });
    }

})(mediaWiki, jQuery);