둘러보기 메뉴
검색
바뀐글
임의글
개인 도구
가입하기
로그인
도움말
도움말
질문게시판
자주 묻는 질문
커뮤니티
실시간 채팅방
가입인사게시판
자유게시판
뉴스게시판
제재안게시판
최근 토론
페미위키
공지사항
개선 요청
바뀐글
임의글
파일 올리기
다면 분류 목록
특수 문서 목록
소도구:edittools.js 문서 원본 보기
이름공간
소도구
토론
주시
도구
여기를 가리키는 문서
가리키는 글의 최근 바뀜
문서 정보
위키베이스 항목
행위
보기
읽기
원본 보기
역사 보기
←
소도구:edittools.js
문서 편집 권한이 없습니다. 다음 이유를 확인해주세요.
요청한 명령은 다음 중 하나의 권한을 가진 사용자에게 제한됩니다:
사용자
,
Seeders
.
소도구
이름공간의 문서를 편집할 권한이 없습니다.
문서를 고치려면 이메일 인증 절차가 필요합니다.
사용자 환경 설정
에서 이메일 주소를 입력하고 이메일 주소 인증을 해주시기 바랍니다.
문서의 원본을 보거나 복사할 수 있습니다.
/** * EditTools support: add a selector, change <a> into buttons. * The special characters to insert are defined at [[MediaWiki:Edittools]]. * * @author Arnomane, 2006 (on the commons.wikimedia.org/wiki/MediaWiki:Edittools.js) * @author Kaganer, 2007 (adapting to www.mediawiki.org) * @author Krinkle, 2012 * @source www.mediawiki.org/wiki/MediaWiki:Gadget-Edittools.js * @revision 2012-02-29 */ /*jslint browser: true*/ /*global jQuery, mediaWiki*/ (function ($, mw) { 'use strict'; var conf, editTools, $sections; conf = { initialSubset: window.EditTools_initial_subset === undefined ? window.EditTools_initial_subset : 0, }; editTools = { /** * Creates the selector */ setup: function () { var $container, $select, initial; if (mw.toolbar === undefined) return; $container = $('#mw-edittools-charinsert'); if (!$container.length) { return; } $sections = $container.find('.mw-edittools-section'); if ($sections.length <= 1) { // Only care if there is more than one return; } $select = $('<select>').css('display', 'inline'); initial = conf.initialSubset; if (isNaN(initial) || initial < 0 || initial >= $select.length) { initial = 0; } $sections.each(function (i, el) { var $section, sectionTitle, $option; $section = $(el); sectionTitle = $section.data('sectionTitle'); $option = $('<option>') .text(sectionTitle) .prop('value', i) .prop('selected', i === initial); $select.append($option); }); $select.change(editTools.handleOnchange); $container.prepend($select); editTools.chooseSection(initial); }, /** * Handle onchange event of the <select> * * @context {Element} * @param e {jQuery.Event} */ handleOnchange: function () { editTools.chooseSection(Number($(this).val())); return true; }, /** * Toggle the currently visible section * * @param sectionNr {Number} * @param setFocus {Boolean} */ chooseSection: function (sectionNr) { var $choise = $sections.eq(sectionNr); if ($choise.length !== 1) { return; } // Making these buttons is a little slow, // If we made them all at once the browser would hang // for over 2 seconds, so instead we're doing it on-demand // for each section. No need to do it twice thoguh, so remember // in data whether it was done already if (!$choise.data('charInsert.buttonsMade')) { $choise.data('charInsert.buttonsMade', true); editTools.makeButtons($choise); } $choise.show(); $sections.not($choise).hide(); }, /** * Convert the <a onclick> links to buttons in a given section. * * @param $section {jQuery} */ makeButtons: function ($section) { var $links; if (!$section.length) { return; } $links = $section.find('a'); $links.each(function (i, a) { var $a, $button, start, end; $a = $(a); $button = $('<input>').attr('type', 'button'); start = $a.data('mw-charinsert-start'); end = $a.data('mw-charinsert-end'); if (start !== undefined && end !== undefined) { $button.click(function (e) { e.preventDefault(); mw.toolbar.insertTags(start, end, ''); }); } else { $button[0].onclick = a.onclick; } $button[0].value = $a.text(); $a.replaceWith($button); }); }, }; $(document).ready(editTools.setup); })(jQuery, mediaWiki);
소도구:edittools.js
문서로 돌아갑니다.
다른 언어