미디어위키:Gadget-Vector.js: 두 판 사이의 차이

식물 vs 좀비 위키
편집 요약 없음
편집 요약 없음
351번째 줄: 351번째 줄:


var ACTION_OFFSET = 230;
var ACTION_OFFSET = 230;
var SEARCH_WIDTH = 195;
var SEARCH_WIDTH = 205;
var SEARCH_DOWN_OFFSET = 5;
var SEARCH_DOWN_OFFSET = 5;
var CONTENT_TOP = 24;
var CONTENT_TOP = 24;


function installSpecialPageClass() {
function syncV35Layout() {
var canonicalName =
window.mw && mw.config
? mw.config.get('wgCanonicalSpecialPageName')
: null;
var root = document.documentElement;
 
root.classList.remove(
'pvz-special-preferences',
'pvz-special-login',
'pvz-special-createaccount'
);
 
if (canonicalName === 'Preferences') {
root.classList.add('pvz-special-preferences');
}
 
if (canonicalName === 'Userlogin') {
root.classList.add('pvz-special-login');
}
 
if (canonicalName === 'CreateAccount') {
root.classList.add('pvz-special-createaccount');
}
}
 
function syncV34Layout() {
var content = document.querySelector('#content');
var content = document.querySelector('#content');
var leftNavigation = document.getElementById('left-navigation');
var leftNavigation = document.getElementById('left-navigation');
503번째 줄: 477번째 줄:
}
}


function initV34Layout() {
function initV35Layout() {
var observer;
var observer;


installSpecialPageClass();
syncV35Layout();
syncV34Layout();


window.addEventListener(
window.addEventListener(
'resize',
'resize',
syncV34Layout,
syncV35Layout,
{ passive: true }
{ passive: true }
);
);
517번째 줄: 490번째 줄:
window.addEventListener(
window.addEventListener(
'orientationchange',
'orientationchange',
syncV34Layout,
syncV35Layout,
{ passive: true }
{ passive: true }
);
);


observer = new MutationObserver(function () {
observer = new MutationObserver(function () {
window.requestAnimationFrame(function () {
window.requestAnimationFrame(syncV35Layout);
installSpecialPageClass();
syncV34Layout();
});
});
});


537번째 줄: 507번째 줄:
document.addEventListener(
document.addEventListener(
'DOMContentLoaded',
'DOMContentLoaded',
initV34Layout,
initV35Layout,
{ once: true }
{ once: true }
);
);
} else {
} else {
initV34Layout();
initV35Layout();
}
}
}());
}());