Автодосматривающие, Бюрократы, Патрулирующие, Администраторы интерфейса, Project members, Управляющие подписками push-уведомлений, Выверяющие, Скрывающие, Администраторы, Редакторы виджетов
5802
правки
Нет описания правки |
Нет описания правки |
||
Строка 1: | Строка 1: | ||
/* Размещённый здесь код JavaScript будет загружаться пользователям при обращении к каждой странице */ | /* Размещённый здесь код JavaScript будет загружаться пользователям при обращении к каждой странице */ | ||
/ | //Collapsiblе: | ||
var NavigationBarShowDefault = 2 | |||
var NavigationBarHide = '[скрыть]' | |||
var NavigationBarShow = '[показать]' | |||
function collapsibleTables(){ | |||
var Table, HRow, HCell, btn, a, tblIdx = 0, colTables = [] | |||
var allTables = document.getElementsByTagName('table') | |||
for (var i=0; Table = allTables[i]; i++){ | |||
if (!$(Table).hasClass('collapsible')) continue | |||
if (!(HRow=Table.rows[0])) continue | |||
if (!(HCell=HRow.getElementsByTagName('th')[0])) continue | |||
Table.id = 'collapsibleTable' + tblIdx | |||
btn = document.createElement('span') | |||
btn.style.cssText = 'float:right; font-weight:normal; font-size:smaller' | |||
a = document.createElement('a') | |||
a.id = 'collapseButton' + tblIdx | |||
a.href = 'javascript:collapseTable(' + tblIdx + ');' | |||
a.style.color = HCell.style.color | |||
a.appendChild(document.createTextNode(NavigationBarHide)) | |||
btn.appendChild(a) | |||
HCell.insertBefore(btn, HCell.childNodes[0]) | |||
colTables[tblIdx++] = Table | |||
} | |||
for (var i=0; i < tblIdx; i++) | |||
if ((tblIdx > NavigationBarShowDefault && $(colTables[i]).hasClass('autocollapse')) || $(colTables[i]).hasClass('collapsed')) | |||
collapseTable(i) | |||
} | |||
function collapseTable (idx){ | |||
var Table = document.getElementById('collapsibleTable' + idx) | |||
var btn = document.getElementById('collapseButton' + idx) | |||
if (!Table || !btn) return false | |||
var Rows = Table.rows | |||
var isShown = (btn.firstChild.data == NavigationBarHide) | |||
btn.firstChild.data = isShown ? NavigationBarShow : NavigationBarHide | |||
var disp = isShown ? 'none' : Rows[0].style.display | |||
for (var i=1; i < Rows.length; i++) | |||
Rows[i].style.display = disp | |||
} | |||
function collapsibleDivs(){ | |||
var navIdx = 0, colNavs = [], i, NavFrame | |||
var divs = document.getElementById('content').getElementsByTagName('div') | |||
for (i=0; NavFrame = divs[i]; i++) { | |||
if (!$(NavFrame).hasClass('NavFrame')) continue | |||
NavFrame.id = 'NavFrame' + navIdx | |||
var a = document.createElement('a') | |||
a.className = 'NavToggle' | |||
a.id = 'NavToggle' + navIdx | |||
a.href = 'javascript:collapseDiv(' + navIdx + ');' | |||
a.appendChild(document.createTextNode(NavigationBarHide)) | |||
for (var j=0; j < NavFrame.childNodes.length; j++) | |||
if ($(NavFrame.childNodes[j]).hasClass('NavHead')) | |||
NavFrame.childNodes[j].appendChild(a) | |||
colNavs[navIdx++] = NavFrame | |||
} | } | ||
for (i=0; i < navIdx; i++) | |||
if ((navIdx > NavigationBarShowDefault && !$(colNavs[i]).hasClass('expanded')) || $(colNavs[i]).hasClass('collapsed')) | |||
collapseDiv(i) | |||
} | |||
function collapseDiv(idx) { | |||
var div = document.getElementById('NavFrame' + idx) | |||
var btn = document.getElementById('NavToggle' + idx) | |||
if (!div || !btn) return false | |||
var isShown = (btn.firstChild.data == NavigationBarHide) | |||
btn.firstChild.data = isShown ? NavigationBarShow : NavigationBarHide | |||
var disp = isShown ? 'none' : 'block' | |||
for (var child = div.firstChild; child != null; child = child.nextSibling) | |||
if ($(child).hasClass('NavPic') || $(child).hasClass('NavContent')) | |||
child.style.display = disp | |||
} | } | ||
function newSectionLink(){ | |||
var plus = document.getElementById('ca-addsection') | |||
if (!plus) return | |||
var custom = document.getElementById('add-custom-section') | |||
if (!custom) return | |||
plus.firstChild.setAttribute('href', custom.getElementsByTagName('a')[0].href) | |||
} | |||
} | |||
function editZeroSection(){ | |||
var body = document.getElementById('bodyContent') | |||
if (!body) return | |||
var h2s = body.getElementsByTagName('H2') | |||
var h2 = h2s[0] | |||
if (!h2) return | |||
if (h2.parentNode.id == 'toctitle') h2 = h2s[1] | |||
if (!h2) return | |||
var span = h2.firstChild | |||
if (!span || span.className != 'editsection') return | |||
var zero = span.cloneNode(true) | |||
body.insertBefore(zero, body.firstChild) | |||
var a = zero.getElementsByTagName('a')[0] | |||
if (a.href.indexOf('§ion=T') == -1 ) a.title = a.title.replace(/:.*$/,': 0') | |||
else a.title = 'Править секцию: 0' | |||
a.href = mw.config.get('wgScript') + '?title=' + encodeURIComponent(mw.config.get('wgPageName')) + '&action=edit§ion=0'; | |||
} | } | ||
//Execution | |||
if (mw.config.get('wgCanonicalNamespace') == 'Special') { | |||
switch (mw.config.get('wgCanonicalSpecialPageName')) { | |||
case 'Upload': importScript('MediaWiki:Upload.js'); break | |||
} | |||
} else if (mw.config.get('wgAction') != 'history') { | |||
$(editZeroSection) | |||
$(collapsibleDivs) | |||
$(collapsibleTables) | |||
if (navigator.appName=='Microsoft Internet Explorer' && document.createStyleSheet) { | |||
document.createStyleSheet().addRule('.IPA', 'font-family: "Doulos SIL", "Charis SIL", Gentium, "DejaVu Sans", Code2000, "TITUS Cyberbit Basic", "Arial Unicode MS", "Lucida Sans Unicode", "Chrysanthi Unicode";') | |||
} | |||
if (mw.config.get('wgNamespaceNumber') != 0) { | |||
$(newSectionLink) | |||
} | |||
if (mw.config.get('wgAction')=='edit' || mw.config.get('wgAction')=='submit') importScript('MediaWiki:Editpage.js') | |||
} | |||
importScript("MediaWiki:LanguageSelection.js"); |