User:Aspallar/common.js

// importArticles({ //    type: 'script', //     articles: [ //         'u:dev:UnsafeScripts/code.js' //     ] // }); // importArticles({ //    type: 'script', //     articles: [ //         'u:dev:AddRailModule/code.js' //     ] // }); // importArticles({ //    type: 'script', //     articles: [ //         'u:dev:HideRail/code.js', //     ] // }); importArticles({   type: 'script',    articles: [        'u:dev:NullEditButton/code.js',    ] }); // importArticles({ //    type: 'script', //     articles: [ //         'u:dev:SourceEditButton/code.js', //     ] // }); $(function ($) {   $('#mw-clearyourcache').remove; }(jQuery)); console.log('Build 7'); (function ($) {   /* global mw */    'use strict';

if (document.getElementById('mdw-az2') === null) return;

var aTozNav; var pageHeader;

function initialize {

aTozNav = $('#mdw-az2'); pageHeader = document.getElementById('PageHeader');

mw.loader.using('jquery.ui.draggable', function {            $(window).scroll(function  { var pageHeaderRect = pageHeader.getBoundingClientRect; if (aTozNav.offset.top < pageHeaderRect.bottom) aTozNav.css('top', pageHeaderRect.bottom + 'px'); }).resize(function { var rect = aTozNav.get(0).getBoundingClientRect; if (rect.right > window.innerWidth || rect.bottom > window.innerHeight) { var top = rect.bottom > window.innerHeight ? rect.top - (rect.bottom - window.innerHeight) : rect.top; var left = rect.right > window.innerWidth ? rect.left - (rect.right - window.innerWidth) : rect.left; console.log({top: top, left: left}); aTozNav.offset({top: top, left: left}); }           });            aTozNav.draggable( {               create: function (event) { var target = $(event.target); var rect = document.getElementById('mdwa').getBoundingClientRect; target.css('top', Math.floor(rect.y) - target.outerHeight(true) + 'px') .css('left', Math.floor(rect.x) + 320 + 'px') .css('position', 'fixed'); },               stop: function(event, ui) { function getTop(element) { var elementTop = element.offset.top; var windowTop = $(window).scrollTop; return elementTop - windowTop; }                   var top = getTop(ui.helper); ui.helper.css('position', 'fixed').css('top', top + 'px'); },               drag: function( event, ui ) { var headerRect = pageHeader.getBoundingClientRect; var height = $(event.target).outerHeight; var top = Math.max(ui.position.top, headerRect.bottom); top = Math.min(top, window.innerHeight - height); ui.position.top = top; },               start: function(event, ui) {                   ui.helper.css('bottom', ''); },               cancel: 'a', scroll: false, containment: "document" });       });    }

$(document).ready(initialize);

}(jQuery));