MediaWiki:Common.js: Unterschied zwischen den Versionen
Aus Cryptshare Documentation
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 21: | Zeile 21: | ||
}, | }, | ||
makeSelection : function(selector) { | makeSelection : function(selector) { | ||
setTimeout(() | setTimeout(function() { | ||
$(selector).toggleClass("selected") | $(selector).toggleClass("selected") | ||
$('#sidebar-navigation').animate({ scrollTop: ($(selector).offset().top-300)}, 'fast'); | $('#sidebar-navigation').animate({ scrollTop: ($(selector).offset().top-300)}, 'fast'); |
Version vom 15. Oktober 2021, 05:42 Uhr
var SideBar = { normalizeName : function(name) { var normalizedName = name.replaceAll("_", " ") normalizedName = normalizedName.replaceAll("%26", "&") normalizedName = normalizedName.replaceAll("%2B", "+") return normalizedName }, getPageName : function(url) { var pos = url.lastIndexOf(":") var endPositions = ["?", "&", "#"] var lastPos for (var i = 0;i < endPositions.length;i++) { if (lastPos === -1 || lastPos === undefined) lastPos = url.indexOf(endPositions[i]) } if (lastPos === -1) return decodeURI(url.substring(pos + 1)) else return decodeURI(url.substring(pos + 1, lastPos)) }, makeSelection : function(selector) { setTimeout(function() { $(selector).toggleClass("selected") $('#sidebar-navigation').animate({ scrollTop: ($(selector).offset().top-300)}, 'fast'); }, 500) }, selectMenuItem : function(name) { console.log("SideBar Navigation - Selecting ", name) var item = $('#sidebar-navigation a:contains("' + name + '")') if (item.length === 0) // MediaWiki makes an uppercase URL in some cases item = $('#sidebar-navigation a:contains("' + name.toLowerCase() + '")') if (item.length === 0) { // Handling titles containing a minus character var splitItems = name.split(" ") var selector = '#sidebar-navigation a:contains("' for (var i = 0;i < splitItems.length;i++) { selector += splitItems[i] + '")' if (splitItems[i+1]) selector += ':contains("' } SideBar.makeSelection(selector) } else if (item) { SideBar.makeSelection(item) } }, updateSelectedMenuItem : function() { SideBar.selectMenuItem(SideBar.normalizeName(SideBar.getPageName(window.location.href))) } }