5,324
回編集
(fix editintro) |
|||
(2人の利用者による、間の15版が非表示) | |||
1行目: | 1行目: | ||
/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */ | /* <nowiki> ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */ | ||
/* URLのwithCSSパラメータで、追加のスタイルシートを読み込む | /* URLのwithCSSパラメータで、追加のスタイルシートを読み込む | ||
使われていないので無効化 有効化する場合依存関係に注意 | |||
https://www.mediawiki.org/wiki/Snippets/Load_JS_and_CSS_by_URL | |||
var extraCSS = mw.util.getParamValue('withCSS'); | var extraCSS = mw.util.getParamValue('withCSS'); | ||
if (extraCSS && extraCSS.match(/\.css$/)) { | if (extraCSS && extraCSS.match(/\.css$/)) { | ||
mw.loader.load(mw.config.get('wgServer') + mw.config.get('wgScript') + | |||
'?action=raw&ctype=text/css&title=' + | |||
mw.util.wikiUrlencode(extraCSS), 'text/css'); | |||
} | } | ||
*/ | |||
/* ソート順を改善(長音符は非対応) */ | |||
mw.config.set('tableSorterCollation', { | |||
'ア':'あ', 'ァ':'あ', 'ぁ':'あ', 'イ':'い', 'ィ':'い', 'ぃ':'い', 'ウ':'う', 'ゥ':'う', 'ぅ':'う', | |||
'エ':'え', 'ェ':'え', 'ぇ':'え', 'オ':'お', 'ォ':'お', 'ぉ':'お', | |||
'カ':'か', 'ガ':'か', 'が':'か', 'キ':'き', 'ギ':'き', 'ぎ':'き', 'ク':'く', 'グ':'く', 'ぐ':'く', | |||
'ケ':'け', 'ゲ':'け', 'げ':'け', 'コ':'こ', 'ゴ':'こ', 'ご':'こ', | |||
'サ':'さ', 'ザ':'さ', 'ざ':'さ', 'シ':'し', 'ジ':'し', 'じ':'し', 'ス':'す', 'ズ':'す', 'ず':'す', | |||
'セ':'せ', 'ゼ':'せ', 'ぜ':'せ', 'ソ':'そ', 'ゾ':'そ', 'ぞ':'そ', | |||
'タ':'た', 'ダ':'た', 'だ':'た', 'チ':'ち', 'ヂ':'ち', 'ぢ':'ち', | |||
'ツ':'つ', 'ヅ':'つ', 'ッ':'つ', 'づ':'つ', 'っ':'つ', | |||
'テ':'て', 'デ':'て', 'で':'て', 'ト':'と', 'ド':'と', 'ど':'と', | |||
'ナ':'な', 'ニ':'に', 'ヌ':'ぬ', 'ネ':'ね', 'ノ':'の', | |||
'ハ':'は', 'バ':'は', 'パ':'は', 'ば':'は', 'ぱ':'は', | |||
'ヒ':'ひ', 'ビ':'ひ', 'ピ':'ひ', 'び':'ひ', 'ぴ':'ひ', | |||
'フ':'ふ', 'ブ':'ふ', 'プ':'ふ', 'ぶ':'ふ', 'ぷ':'ふ', | |||
'ヘ':'へ', 'ベ':'へ', 'ペ':'へ', 'べ':'へ', 'ぺ':'へ', | |||
'ホ':'ほ', 'ボ':'ほ', 'ポ':'ほ', 'ぼ':'ほ', 'ぽ':'ほ', | |||
'マ':'ま', 'ミ':'み', 'ム':'む', 'メ':'め', 'モ':'も', | |||
'ヤ':'や', 'ャ':'や', 'ゃ':'や', 'ユ':'ゆ', 'ュ':'ゆ', 'ゅ':'ゆ', 'ヨ':'よ', 'ョ':'よ', 'ょ':'よ', | |||
'ラ':'ら', 'リ':'り', 'ル':'る', 'レ':'れ', 'ロ':'ろ', | |||
'ワ':'わ', 'ヲ':'を', 'ン':'ん', ' ':'', ' ':'', | |||
}); | |||
/* [[テンプレート:折り畳みボックス]] */ | /* [[テンプレート:折り畳みボックス]] */ | ||
14行目: | 39行目: | ||
function toggleCollapsible(key, e) { | function toggleCollapsible(key, e) { | ||
e.preventDefault(); | |||
if (this.hasClass('collapsed')) { | |||
this.removeClass('collapsed').find('> tbody > tr:not(:first)').fadeIn(); | |||
this.$toggle.text(collapseCaption); | |||
if (key) $.cookie(key, 'uncollapsed', { path: '/', expires: 90 }); | |||
} else { | |||
this.addClass('collapsed').find('> tbody > tr:not(:first)').fadeOut(); | |||
this.$toggle.text(expandCaption); | |||
if (key) $.cookie(key, 'collapsed', { path: '/', expires: 90 }); | |||
} | |||
} | } | ||
mw.hook('wikipage.content').add(function($content) { | mw.hook('wikipage.content').add(function($content) { | ||
/* 折り畳みボックス */ | |||
$content.find('table.collapsible').each(function() { | |||
var $table = $(this), | |||
collapse = $table.data('collapse'); | |||
if ($table.hasClass('made-collapsible') || collapse == 'plain') return; | |||
$table.addClass('made-collapsible'); | |||
var $button = $table.find('tr:first > td:first > .collapseButton'); | |||
$table.$toggle = $button.append('[<a href="#"></a>]').children(); | |||
/* | |||
if (/^cookie-(.+)$/.test(collapse)) { | |||
var key = 'collapse-' + RegExp.$1; | |||
collapse = $.cookie(key) || 'autocollapse'; | |||
$table.$toggle.on('click', $.proxy(toggleCollapsible, $table, key)); | |||
} else { | |||
$table.$toggle.on('click', $.proxy(toggleCollapsible, $table, null)); | |||
} | |||
*/ | |||
$table.$toggle.on('click', $.proxy(toggleCollapsible, $table, null)); | |||
if (collapse == 'collapsed' || (collapse == 'autocollapse' && | |||
$table.siblings('table.collapsible').length)) { | |||
$table.addClass('collapsed').find('> tbody > tr:not(:first)').hide(); | |||
$table.$toggle.text(expandCaption); | |||
} else { | |||
$table.$toggle.text(collapseCaption); | |||
} | |||
}); | |||
/* タブ */ | |||
$content.find('.tab-list').each(function() { | |||
var $tabList = $(this), | |||
$tabs = $tabList.find('> ul > li'), | |||
$tabContent = $tabList.nextAll('.tab-content'); | |||
$tabs.bind('click', function() { | |||
var $tab = $(this), | |||
index = $tab.data('tab') - 1; | |||
$tabs.removeClass('current-tab'); | |||
$tab.addClass('current-tab'); | |||
$tabContent.not($tabContent.eq(index).toggle()).hide(); | |||
}); | |||
}); | |||
}); | }); | ||
81行目: | 102行目: | ||
if (mw.config.get('wgAction') === 'edit' && | if (mw.config.get('wgAction') === 'edit' && | ||
$.inArray('autoconfirmed', mw.config.get('wgUserGroups')) < 0) { | $.inArray('autoconfirmed', mw.config.get('wgUserGroups')) < 0) { | ||
$('#wpSave').attr('disabled', 'disabled').val('投稿前にプレビューで確認してください'); | |||
$('#wpPreview').css('font-weight', 'bold'); | |||
} | |||
/* 要約欄でエンターキーを押した際に投稿されないようにする */ | |||
jQuery(document).ready(function($) { | |||
if (typeof summaryEnterRejectDisable === 'undefined' || summaryEnterRejectDisable == false) { | |||
$('#wpSummary').keypress(function(e) { | |||
if (e.keyCode == 13) { | |||
e.preventDefault(); | |||
} | |||
}); | |||
$('#wpSave').css('font-weight', 'normal'); | |||
} | |||
}); | |||
mw.loader.using( [ 'mediawiki.util' ] ).done( function () { | |||
/* カテゴリごとにeditintroを設定する */ | |||
var CATEGORY_EDITINTRO_TABLE = { | |||
'メンバー': 'ヘルプ:メンバーページのスタイル/editintro' , | |||
'元メンバー': 'ヘルプ:メンバーページのスタイル/editintro' , | |||
'シングル': 'ヘルプ:シングルページのスタイル/editintro' , | |||
}; | |||
function addEditIntro(templateName) { | |||
$( '.mw-editsection,#quickbar, #ca-edit' ).find( 'a' ).each( function ( i, el ) { | |||
el.href = $( this ).attr( 'href' ) + '&editintro=' + templateName; | |||
} ); | |||
}; | |||
if (mw.config.get('wgNamespaceNumber') == 0) { | |||
$(function(){ | |||
var catContainer = mw.config.get( 'wgCategories' ); | |||
$.each(catContainer, function(index, value) { | |||
if(ei = CATEGORY_EDITINTRO_TABLE[value]) { | |||
addEditIntro(ei); | |||
return; | |||
} | |||
}); | |||
}); | |||
} | } | ||
}); |