MediaWiki:Vector.js: Różnice pomiędzy wersjami

Z High School DxD Wiki
Skocz do:nawigacji, wyszukiwania
 
(Nie pokazano 13 pośrednich wersji utworzonych przez tego samego użytkownika)
Linia 1: Linia 1:
$(function(){
+
var _gaq = _gaq || [];
if ($.browser.mozilla)
+
_gaq.push(['_setAccount', 'UA-42481301-1']);
{
+
_gaq.push(['_trackPageview']);
$('#left-navigation, #right-navigation').css('top', '10.8em');
+
}
+
});
+
  
window.wgSidebar = (window.wgSidebar||{});
+
(function() {
importScript('MediaWiki:Vector.js/Sidebar.js');
+
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
 
+
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
Sidebar = {
+
})();
getItem: function(name) {
+
return $('#n-' + encodeURIComponent(name.replace(/ /g, '-')).replace(/%/g, '.'));
+
},
+
init: function() {
+
if (!window.wgSidebar)
+
return;
+
+
for (var menu in wgSidebar) {
+
var item = Sidebar.getItem(menu);
+
+
Sidebar.buildSubmenu(item, wgSidebar[menu]);
+
+
var ul = item.parent('ul');
+
+
}
+
+
console.log(ul);
+
+
ul.on('mouseenter', 'li', function() {
+
var el = $(this);
+
var pos = el.position();
+
+
$(this).children('ul').css({display:'block', left: el.width()+pos.left});
+
//parent.addClass('hover');
+
}).on('mouseleave', 'li', function() {
+
+
var submenu = $(this).children('ul');
+
if(submenu.is(':visible'))
+
{
+
submenu.css({display: 'none'});
+
}
+
});
+
+
},
+
+
+
buildSubmenu: function(menu, items)
+
{
+
var ul = $('<ul>');
+
+
menu.addClass('submenu');
+
+
for (var i in items)
+
{
+
var item = items[i];
+
var li = $('<li>');
+
+
if (typeof item === 'string')
+
{
+
var link = this.getLink(item);
+
li.append(link);
+
ul.append(li);
+
}
+
else if(typeof item === 'object')
+
{
+
for (var j in item)
+
{
+
var link = this.getLink(j);
+
li.append(link);
+
ul.append(li);
+
this.buildSubmenu(li, item[j]);
+
}
+
} else continue;
+
}
+
+
menu.append(ul);
+
},
+
getLink: function(txt, has_submenu)
+
{
+
var pos = txt.indexOf('|');
+
var article = '';
+
var caption = '';
+
+
if (pos > 0)
+
{
+
article = txt.substr(0, pos);
+
caption = txt.substr(pos + 1);
+
}
+
else
+
{
+
article = txt;
+
caption = txt;
+
}
+
+
var href = '';
+
+
if (article.length > 7 && article.substr(0,7) == 'http://')
+
{
+
href = article;
+
}
+
else
+
{
+
article = encodeURIComponent(article.replace(/ /g, '_'));
+
href = wgArticlePath.replace('$1',article);
+
}
+
+
return '<a href="' + article + '">' + caption  + '</a>';
+
}
+
}
+
 
+
//$(function(){Sidebar.init();});
+

Aktualna wersja na dzień 21:24, 6 mar 2014

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-42481301-1']);
_gaq.push(['_trackPageview']);

(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
Źródło „https://hsdxd.usermd.net/w/index.php?title=MediaWiki:Vector.js&oldid=3906