「MediaWiki:Common.js」の版間の差分
細 t5 |
細 t5 |
||
| 72行目: | 72行目: | ||
/* スマホめにゅー */ | /* スマホめにゅー */ | ||
(function() { | (function() { | ||
function | function injectCustomMenu() { | ||
if ($('#p-custom- | if ($('#p-custom-links').length) return; | ||
var $ | var $navUl = $('#p-navigation'); | ||
var $personalUl = $('#p-personal'); | |||
if ($ | if ($navUl.length && $personalUl.length) { | ||
var items = [ | var items = [ | ||
{ label: '方針', url: '/wiki/Wiki:方針', icon: 'notice' }, | { label: '方針', url: '/wiki/Wiki:方針', icon: 'notice' }, | ||
| 85行目: | 86行目: | ||
]; | ]; | ||
var html = ''; | var html = '<ul id="p-custom-links" class="toggle-list__list">'; | ||
items.forEach(function(item) { | items.forEach(function(item) { | ||
html += '<li class=" | html += '<li class="toggle-list-item">' + | ||
'<a href="' + item.url + '" class="mw-ui-icon mw-ui-icon-before mw-ui-icon-' + item.icon + '">' + | '<a href="' + item.url + '" class="toggle-list-item__anchor mw-ui-icon mw-ui-icon-before mw-ui-icon-' + item.icon + '">' + | ||
'<span>' + item.label + '</span>' + | '<span class="toggle-list-item__label">' + item.label + '</span>' + | ||
'</a>' + | '</a>' + | ||
'</li>'; | '</li>'; | ||
}); | }); | ||
html += '</ul>'; | |||
$navUl.after(html); | |||
$ | console.log("Custom menu injected between navigation and personal."); | ||
} | } | ||
} | } | ||
$(document).ready( | $(document).ready(injectCustomMenu); | ||
var timer = setInterval( | var timer = setInterval(injectCustomMenu, 500); | ||
setTimeout(function() { clearInterval(timer); }, 5000); | setTimeout(function() { clearInterval(timer); }, 5000); | ||
})(); | })(); | ||
console.log("OK Common.js") | console.log("OK Common.js") | ||