"미디어위키:Common.js"의 두 版 사이의 差異

編輯 要約 없음
태그: 되돌려진 寄與(기여)
(EighteenChild (토론)의 9171판 편집을 되돌림)
태그: 編輯(편집) 取消(취소)
1番째 줄: 1番째 줄:
/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */
/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */


window.addEventListener('DOMContentLoaded', function() {
mw.loader.using(['mediawiki.util'], function() {
    document.querySelector('input#searchInput').addEventListener('input', function() {
        $(this).trigger('keypress');
    });
     if(window.matchMedia) {
     if(window.matchMedia) {
         var match = window.matchMedia('(prefers-color-scheme: dark)');
         var match = window.matchMedia('(prefers-color-scheme: dark)');
12番째 줄: 15番째 줄:
         });
         });
     }
     }
});
mw.loader.using(['mediawiki.util'], function() {
    document.querySelector('input#searchInput').addEventListener('input', function() {
        $(this).trigger('keypress');
    });
});
});



2023年10月23日(月)11時35分 版

/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */

mw.loader.using(['mediawiki.util'], function() {
    document.querySelector('input#searchInput').addEventListener('input', function() {
        $(this).trigger('keypress');
    });
    if(window.matchMedia) {
        var match = window.matchMedia('(prefers-color-scheme: dark)');
        if(match.matches) {
            document.body.classList.add('dark-mode');
        }
        match.addEventListener('change', function(event) {
            var darkMode = event.matches;
            document.body.classList.toggle('dark-mode', darkMode);
        });
    }
});

var customizeToolbar = function () {
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'advanced',
        'group': 'format',
        'tools': {
            'cite': {
                label: '註釋',
                type: 'button',
                icon: '//upload.wikimedia.org/wikipedia/commons/4/4f/Cite_icon.svg',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: "{{*|",
                        peri: "內容",
                        post: "}}"
                    }
                }
            }
        }
    } );
};

/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -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' ), $.ready
			).then( customizeToolbar );
		}
	} );
}