মিডিয়াৱিকি:Gadget-FloatableEditingButton.js

অসমীয়া ৱিকিপিডিয়াৰ পৰা

টোকা: প্ৰকাশ কৰাৰ পাছত পৰিৱৰ্তনসমূহ চাবৰ বাবে আপোনাৰ ব্ৰাউজাৰত কেশ্ব অগ্ৰাহ্য কৰিবলগীয়া হ'ব পাৰে।

  • ফায়াৰফক্স / চাফাৰি: Shift ধৰি ৰাখি Reload ক্লিক কৰক, বা Ctrl-F5 আৰু Ctrl-R ৰ ভিতৰত যিকোনো এটা ক্লিক কৰক (মেকত ⌘-R)
  • গুগল ক্ৰ'ম: Ctrl-Shift-R টিপক (মেকত ⌘-Shift-R)
  • ইণ্টাৰনে'ট এক্সপ্ল'ৰাৰ / এড্‌জ: Ctrl ধৰি ৰাখি Refresh ক্লিক কৰক, বা Ctrl-F5 টিপক
  • অপেৰা: Ctrl-F5 টিপক।
/*
    This scipt add some large icon at right side for Editing.
    @example Edit, Save, Preview, Go Top Button

    @Author [[User:Jayprakash12345]]
    @ImproveBy [[User:Krinkle]
    @OwnBy [[meta:Indic-TechCom]]
*/

// i18n for FloatableEditingButton
if( i18nForFloatableButton === undefined ) {
    var i18nForFloatableButton = {
        editi18n: 'সম্পাদনা কৰক',
        savei18n: 'প্ৰকাশ কৰক',
        previewi18n: 'খচৰা চাওক',
        goTopi18n: 'ওপৰলৈ যাওক'
    }
}

$(function () {

    // Get current pagename
    var pageName = mw.config.get('wgPageName');

    // Create Main Div
    var div = document.createElement('div');
        div.style ='position: fixed; right:30px; top:150px; display:block;';
        div.style.zIndex = "2147483647"; // A hack to show div allmost top
        div.id = 'iconForEditor';

    function createIcon(imageSrc, imgTooltip) {
        var element = document.createElement('img');
        element.className = 'image';
        element.width = '40';
        element.height = '40';
        element.src = imageSrc;
        element.title = imgTooltip;
        var divForIcon = document.createElement('div');
        divForIcon.appendChild(element);
        return divForIcon;
    }

    // Object for icons (div with img encapsulated inside)
    var elements = {
        editIcon: createIcon(
            'https://upload.wikimedia.org/wikipedia/commons/b/b2/Writing_Circle_Yellow.svg',
            i18nForFloatableButton.editi18n
        ),
        saveIcon: createIcon(
            'https://upload.wikimedia.org/wikipedia/commons/b/b0/Icon_Transparent_Green.png',
            i18nForFloatableButton.savei18n
        ),
        previewIcon: createIcon(
            'https://upload.wikimedia.org/wikipedia/commons/e/e2/Icon_Transparent_Yellow.png',
            i18nForFloatableButton.previewi18n
        ),
        goTopIcon: createIcon(
            'https://upload.wikimedia.org/wikipedia/commons/4/4c/Go-up.svg',
            i18nForFloatableButton.goTopi18n
        )
    };

    // Append icons into main div
    if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) === -1 ) {
        // View mode
        $(div).append(elements.editIcon, elements.goTopIcon);
    } else {
        // Edit mode
        $(div).append(elements.saveIcon, elements.previewIcon, elements.goTopIcon);
    }

    // Append the main div
    $('#mw-content-text').after( div );

    // Trigger for Edit Button
    $(elements.editIcon).on('click', function () {
        var params = {
            title: pageName,
            action: 'edit'
        };
        location.replace( mw.config.get( 'wgScript' ) + '?' + $.param( params ) );
    } );

    // Trigger for Save Button
    $(elements.saveIcon).on('click', function () {
        $('#editform').submit();
    } );

    // Trigger for Preview Button
    $(elements.previewIcon).on('click', function () {
        $('#wpPreview').click();
    } );

    // Trigger for Goto Top Button
    $(elements.goTopIcon).on('click', function () {
        location.hash = '#top';
    } );

});