MediaWiki:Common.js
From Frack - Hackerspace Friesland
Jump to navigationJump to searchNote: After saving, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Any JavaScript here will be loaded for all users on every page load. */ // Masonry for the [[Projecten]] & [[Kennis]] pages if ($(".masonry_box").length) { $.getScript("/w/extensions/JavaScript/jquery.masonry.min.js", function() { $('.masonry_box').masonry({ itemSelector: '.tegel', columnWidth: 350, isAnimated: true, isFitWidth: true }); }); } // Tooltips for all content pages. These tooltips occur for user and skill boxes window.pg || $(document).ready(function($) { var isTouchscreen = 0; var timerLength = 300; $('.tooltipContainer').each(function() { var tooltipNode, hideTimer, showTimer, checkFlip = false; function hide(refLink) { if (tooltipNode && tooltipNode.parentNode == document.body) { hideTimer = setTimeout(function() { $(tooltipNode).animate({opacity: 0}, 100, function() { document.body.removeChild(tooltipNode) }) }, 100) } } function show() { if (!tooltipNode.parentNode || tooltipNode.parentNode.nodeType === 11) { document.body.appendChild(tooltipNode); checkFlip = true; } $(tooltipNode).stop().animate({opacity: 1}, 100) clearTimeout(hideTimer); } $(this)['hover'](function(e) { var _this = this; showTimer && clearTimeout(showTimer); showTimer = setTimeout(function() { var tooltipData = $(_this).find('.tooltipData')[0]; if (!tooltipNode) { tooltipNode = document.createElement('ul'); tooltipNode.className = "tooltip"; var listItem = tooltipNode.appendChild(document.createElement('li')); listItem.appendChild(tooltipData.cloneNode(true)); tooltipNode.appendChild(document.createElement('li')); $(tooltipNode).hover(show, hide); } show(); var o = $(_this).offset(), oH = tooltipNode.offsetHeight; $(tooltipNode).css({top: o.top - oH, left: o.left - 7 }); if (tooltipNode.offsetHeight > oH) { // is it squished against the right side of the page? $(tooltipNode).css({left:'auto',right:0}); tooltipNode.lastChild.style.marginLeft = (o.left - tooltipNode.offsetLeft) + 'px'; } if (checkFlip) { // is part of it above the top of the screen? if (o.top < tooltipNode.offsetHeight + ( window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0)) { $(tooltipNode).addClass('TTflipped').css({top: o.top + 12}); } else if (tooltipNode.className === 'tooltip TTflipped') { // cancel previous $(tooltipNode).removeClass('TTflipped'); } checkFlip = false; } }, timerLength); }, function() { clearTimeout(showTimer); hide(this); }) }); });