「利用者:Yasusushi/common.js」の版間の差分

編集の要約なし
編集の要約なし
編集の要約なし
1行目: 1行目:
// <pre lang="javascript">
function customizeToolbar() {
 
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
/************************************************************************/
'section': 'emoticons',
// ja> = ECE : 拡張型折りたたみ可能要素 =
'group': 'faces',
//  > NavFrameのように折りたたみ可能な要素を利用可能にする
'tools': {
//  > ;作者: 青子守歌
'smile': {
//  > ;URL: https://ja.wikipedia.org/wiki/User:aokomoriuta
label: '署名',
//  >
filters: [ 'body.ns-project' ],
//  > 詳しい使い方は、[[ヘルプ:拡張型折りたたみ可能要素]]を参照してください。
type: 'button',
//  >
icon: '//upload.wikimedia.org/wikipedia/commons/b/b3/Insert-signature.svg',
//  > == ライセンス ==
action: {
//  > このスクリプトは、複数ライセンスで利用可能です。
type: 'encapsulate',
//  > 選択可能なライセンスは次の通り:
options: {
//  > * クリエイティブ・コモンズ 表示-継承 3.0 非移植
pre: "--<span style="font-size:small;color:#080">やすしをやすすと[[利用者・トーク:Yasusushi|言]]ってた</span>[[利用者:Yasusushi|<span style="color:#f06">Yasusushi</span>]] 2015年11月30日 () 00:48 (JST)"
//  > * クリエイティブ・コモンズ 表示-非営利 3.0 非移植
}
//  > * GNU一般公衆利用許諾書 バージョン3.0以降
}
/************************************************************************/
}
// en> = ECE: Enhanced Collapsible Elements =
//  > This script enables collapsible elements like NavFrame.
//  > ;author: 青子守歌
//  > ;URL: https://ja.wikipedia.org/wiki/User:aokomoriuta
//   >
//   > Documentation is available at [[Help:拡張型折りたたみ可能要素]].
//  >
//  > == License ==
//  > This script is multi-licensed.
//  > You can select the license of your choice from as following:
//  > * Creative Commons Attribution-ShareAlike 3.0 Unported
//  > * Creative Commons Attribution-Noncommercial 3.0 Unported
//  > * GNU General Public License v3.0 or later
/************************************************************************/
(function($, mw, undefined)
{
 
var ece = function()
{
 
// 全ECEボタンについて
$("span.ece-button").each(function()
{
// ボタンを取得
$this = $(this);
 
// 対象ID、折りたたみ&展開ラベル、状態、本体を取得
var targettext = $this.find("span.ece-target").text();
var etext = $this.find("span.ece-etext").html();
var ctext = $this.find("span.ece-ctext").html();
var state = $this.find("span.ece-state").text();
var $body = $this.find("span.ece-body");
 
 
// 本体がなかったら
if($body.length === 0)
{
// 新しく作成し、追加
$body = $(document.createElement("span")).addClass("ece-body");
$(this).append($body);
}
}
 
} );
 
}
// 情報が取得出来たら
if((targettext.length !== 0)&&(etext.length !== 0)&&(ctext.length !== 0)&&(state.length !== 0))
{
// ボタンを作成
var $button = $("<a>").attr({href: '#'}).click(function(e){ e.preventDefault(); });
 
// クリック時に
$button.click(function()
{
// 表示・非表示を逆転
state = (state == "e") ? "c" : "e";
 
// 折りたたみ状態に応じてラベルを変更
$button.html((state == "e") ? ctext : etext);
 
// 対象の要素について
$("#mw-content-text").find(targettext).each(function()
{
// 表示と非表示を実行、
$(this)[(state == "e") ? "show" : "hide"]();
});
});
 
// 折りたたみ状態を逆転して、クリック
state = (state == "e") ? "c" : "e";
$button.click();
 
// 本体の中身をボタンに置き換え
$body.empty();
$body.append($button);
}
});
}; // var ece
 
mw.loader.using(['mediawiki.util'], function() {
  ece();
});
 
})(jQuery, mediaWiki);
 
// </pre>
6,514

回編集