MediaWiki‐ノート:Monobook.js
[編集]
Wikipedia‐ノート:ネタばれに注意#折りたたみ式のTemplateの提案においてネタバレ用のテンプレートの試作が行われています。つきましては、そのテンプレートの有効な運用のために、NavigationBarShowDefault=0とすることによって初期値を「折りたたまれた」状態にしようかと思うのですが、問題ありますでしょうか? --Calvero 2006年11月2日 (木) 19:32 (UTC)
- 変更してみました。--Calvero 2006年11月10日 (金) 13:20 (UTC)
ta['zh-unwatch'] = new Array('w','停止監視');
From MediaWiki:Monobook.js[編集]
Please add the folowing code, thanks. This code is for show/hide structure used in en -- Cat chi? 2006年2月26日 (日) 20:36 (UTC)
function addLoadEvent(func)
{
if (window.addEventListener) window.addEventListener("load", func, false); else if (window.attachEvent) window.attachEvent("onload", func);
}
// ============================================================ // BEGIN Dynamic Navigation Bars (experimantal) // set up the words in your language var NavigationBarHide = '[ Hide ]'; var NavigationBarShow = '[ Show ]'; // set up max count of Navigation Bars on page, // if there are more, all will be hidden // NavigationBarShowDefault = 0; // all bars will be hidden // NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden var NavigationBarShowDefault = 1; // shows and hides content and picture (if available) of navigation bars // Parameters: // indexNavigationBar: the index of navigation bar to be toggled function toggleNavigationBar(indexNavigationBar) { var NavToggle = document.getElementById("NavToggle" + indexNavigationBar); var NavFrame = document.getElementById("NavFrame" + indexNavigationBar); if (!NavFrame || !NavToggle) { return false; } // if shown now if (NavToggle.firstChild.data == NavigationBarHide) { for ( var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) { if (NavChild.className == 'NavPic') { NavChild.style.display = 'none'; } if (NavChild.className == 'NavContent') { NavChild.style.display = 'none'; } } NavToggle.firstChild.data = NavigationBarShow; // if hidden now } else if (NavToggle.firstChild.data == NavigationBarShow) { for ( var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) { if (NavChild.className == 'NavPic') { NavChild.style.display = 'block'; } if (NavChild.className == 'NavContent') { NavChild.style.display = 'block'; } } NavToggle.firstChild.data = NavigationBarHide; } } // adds show/hide-button to navigation bars function createNavigationBarToggleButton() { var indexNavigationBar = 0; // iterate over all < div >-elements for( var i=0; NavFrame = document.getElementsByTagName("div")[i]; i++ ) { // if found a navigation bar if (NavFrame.className == "NavFrame") { indexNavigationBar++; var NavToggle = document.createElement("a"); NavToggle.className = 'NavToggle'; NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar); NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');'); var NavToggleText = document.createTextNode(NavigationBarHide); NavToggle.appendChild(NavToggleText); // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked) for( var j=0; j < NavFrame.childNodes.length; j++ ) { if (NavFrame.childNodes[j].className == "NavHead") { NavFrame.childNodes[j].appendChild(NavToggle); } } NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar); } } // if more Navigation Bars found than Default: hide all if (NavigationBarShowDefault < indexNavigationBar) { for( var i=1; i<=indexNavigationBar; i++ ) { toggleNavigationBar(i); } } } addLoadEvent(createNavigationBarToggleButton); // END Dynamic Navigation Bars // ============================================================
[編集]
現在の Dynamic Navigation Bars は div要素にしか対応していませんが、此れを dl,dt,dd要素にも対応したものにして戴ければ幸いです。--kahusi (會話) 2007年5月16日 (水) 06:50 (UTC) % enでは Monobook.js が Common.js に統合されている様で。
LinkFA()[編集]
LinkFA()
の部分は Common.js に移せませんか。英語版では monobook 以外のスキンにも対応しています。 --fryed-peach 2008年4月27日 (日) 06:10 (UTC)
整理提案[編集]
このページは古くなったコードを含んでいるので、整理を提案します。
- 冒頭の tooltips and access keys 部分 (addLoadEvent の直前まで) は削除。これはツールチップやアクセスキーを定義したコードですが、今では MediaWiki に実装されているので必要ありません(モノブック以外のスキンで試してみてください)。
- addLoadEvent() は削除。addOnloadHook() で代替
- LinkFA() は末尾の addLoadEvent を addOnloadHook に変えて、MediaWiki:Common.js に移動。
すべての他のいくつかのスキンでも動作するようになります。 - addLoadEvent(forcePreview) を addOnloadHook(forcePreview) に書き換え
以上の対処でどうでしょうか。--fryed-peach [会話|投稿] 2009年1月8日 (木) 14:59 (UTC) 修正。--fryed-peach [会話|投稿] 2009年1月10日 (土) 14:12 (UTC)
- 反対意見は出ていないので、保護ページの編集依頼に出しておきます。変更後のソースを載せます。--fryed-peach [会話|投稿] 2009年1月19日 (月) 05:38 (UTC)
/*<source lang="javascript">*/ /* ここに記述したJavaScriptはモノブック・スキンの利用者に影響します */ // Force IP to preview before saving changes. // Copyright Marc Mongenet, 2006 function forcePreview() { if (wgUserName != null) return; var saveButton = document.getElementById("wpSave"); if (!saveButton) return; if (location.search.search(/&action=edit/) == -1) return; saveButton.disabled = true; saveButton.style.fontWeight = "normal"; document.getElementById("wpPreview").style.fontWeight = "bold"; } addOnloadHook(forcePreview); /*</source>*/
- 対処 反映いたしました。対応が遅くなって申し訳ありません。言い訳になりますが、しばらく異論がなければ編集しようと考えていたところ、MediaWiki‐ノート:Common.jsでの告知もあり、タイミングをはかり損ねてしまっていました。--mizusumashi(月間感謝賞を応援します) 2009年1月22日 (木) 10:28 (UTC)
- 対処ありがとうございます。初めは、こちらで提案して一週間後依頼にだそうかと思っていたのですが、Common.js の編集も伴うのであちらでも提案したほうがトラブルが防げるかと、後になって考え直したため、依頼が遅れてしまいました。--fryed-peach [会話|投稿] 2009年1月22日 (木) 13:33 (UTC)