미디어위키:Common.js: 두 판 사이의 차이

StayByMe
둘러보기로 이동 검색으로 이동
편집 요약 없음
태그: 되돌려진 기여
편집 요약 없음
태그: 되돌려진 기여
1번째 줄: 1번째 줄:
/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */
/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */
function ModifySidebar( action, section, name, link ) {
$( document ).ready( function() {
try {
// Set the default expanded items by their headline
switch ( section ) {
var defaultExpandItems = ['Navigation', 'Orga'];
case 'languages':
// Set the basic-name for the cookies, which save the current state of expanding
var target = 'p-lang';
var expandCookieName = 'disdance_project_wiki_nav_expanded_';
break;
case 'toolbox':
var target = 'p-tb';
break;
case 'navigation':
var target = 'p-navigation';
break;
default:
var target = 'p-' + section;
break;
}


if ( action == 'add' ) {
var maxHeights = [];
var node = document.getElementById( target )
var expandeds = [];
  .getElementsByTagName( 'div' )[0]
var labels = [];
  .getElementsByTagName( 'ul' )[0];
initNav();
});


var aNode = document.createElement( 'a' );
function initNav() {
var liNode = document.createElement( 'li' );
$( '#p-logo' ).css({'position': 'relative', 'display': 'block'});
$( '.generated-sidebar h5,#p-tb h5 ').each( function( i ) {
var id = $( this ).parent().attr( 'id' );
maxHeights[id] = $( this ).next( 'div' ).height();
var str = $( this ).html();
labels[id] = str;


aNode.appendChild( document.createTextNode( name ) );
if ( $.cookie( expandCookieName + id ) == 'false' ) {
aNode.setAttribute( 'href', link );
expandeds[id] = false;
liNode.appendChild( aNode );
minimize( $( this ) );
liNode.className = 'plainlinks';
} else if ( $.cookie( expandCookieName + id ) == 'true' ) {
node.appendChild( liNode );
expandeds[id] = true;
maximize( $( this ) );
} else if ( defaultExpandItems.indexOf( str ) == -1 ) {
expandeds[id] = false;
minimize( $( this ) );
} else {
expandeds[id] = true;
maximize( $( this ) );
}
}
$( this ).css({'cursor': 'pointer'});
$( this ).click( toggleNav );
} );
}


if ( action == 'remove' ) {
function minimize( target ) {
var list = document.getElementById( target )
var id = $( target ).parent().attr( 'id' );
  .getElementsByTagName( 'div' )[0]
// You can change the expires parameter to save the cookie longer/shorter than 7 days like in this code
  .getElementsByTagName( 'ul' )[0];
$.cookie( expandCookieName + id, 'false', { expires: 7} );
var str = labels[id] + '  ►';
$( target ).next( 'div' ).animate({'height': '0px'});
$( target ).html( str );
}


var listelements = list.getElementsByTagName( 'li' );
function maximize( target ) {
 
var id = $( target ).parent().attr( 'id' );
for ( var i = 0; i < listelements.length; i++ ) {
// You can change the expires parameter to save the cookie longer/shorter than 7 days like in this code
if (
$.cookie( expandCookieName + id, 'true', { expires: 7} );
listelements[i].getElementsByTagName( 'a' )[0].innerHTML == name ||
var str = labels[id] + '  ▼';
listelements[i].getElementsByTagName( 'a' )[0].href == link
var newHeight = maxHeights[id];
)
$( target ).next( 'div' ).animate({'height': newHeight + 'px'});
{
$( target ).html( str );
list.removeChild( listelements[i] );
}
}
}
}


 
function toggleNav( e ) {
} catch( e ) {
var id = $(e.target ).parent().attr( 'id' );
// let's just ignore what's happened
expandeds[id] = !expandeds[id];
return;
if( expandeds[id] == true ) {
maximize( e.target );
} else {
minimize( e.target );
}
}
}
}
function CustomizeModificationsOfSidebar() {
// Adds [[Special:CategoryTree|Special:CategoryTree]] to toolbox
ModifySidebar( 'add', 'toolbox', 'CategoryTree', 'https://en.wikipedia.org/wiki/Special:CategoryTree' );
// Removes [[Special:Upload|Special:Upload]] from toolbox
ModifySidebar( 'remove', 'toolbox', 'Upload file', 'https://en.wikipedia.org/wiki/Special:Upload' );
}
jQuery( CustomizeModificationsOfSidebar );

2024년 6월 25일 (화) 00:43 판

/* 이 자바스크립트 설정은 모든 문서, 모든 사용자에게 적용됩니다. */
$( document ).ready( function() {
	// Set the default expanded items by their headline
	var defaultExpandItems = ['Navigation', 'Orga'];
	// Set the basic-name for the cookies, which save the current state of expanding
	var expandCookieName = 'disdance_project_wiki_nav_expanded_';

var maxHeights = [];
	var expandeds = [];
	var labels = [];
	initNav();
});

function initNav() {
	$( '#p-logo' ).css({'position': 'relative', 'display': 'block'});
	$( '.generated-sidebar h5,#p-tb h5 ').each( function( i ) {
		var id = $( this ).parent().attr( 'id' );
		maxHeights[id] = $( this ).next( 'div' ).height();
		var str = $( this ).html();
		labels[id] = str;

if ( $.cookie( expandCookieName + id ) == 'false' ) {
			expandeds[id] = false;
			minimize( $( this ) );
		} else if ( $.cookie( expandCookieName + id ) == 'true' ) {
			expandeds[id] = true;
			maximize( $( this ) );
		} else if ( defaultExpandItems.indexOf( str ) == -1 ) {
			expandeds[id] = false;
			minimize( $( this ) );
		} else {
			expandeds[id] = true;
			maximize( $( this ) );
		}
		$( this ).css({'cursor': 'pointer'});
		$( this ).click( toggleNav );
	} );
}

function minimize( target ) {
	var id = $( target ).parent().attr( 'id' );
	// You can change the expires parameter to save the cookie longer/shorter than 7 days like in this code
	$.cookie( expandCookieName + id, 'false', { expires: 7} );
	var str = labels[id] + '  ►';
	$( target ).next( 'div' ).animate({'height': '0px'});
	$( target ).html( str );
}

function maximize( target ) {
	var id = $( target ).parent().attr( 'id' );
	// You can change the expires parameter to save the cookie longer/shorter than 7 days like in this code
	$.cookie( expandCookieName + id, 'true', { expires: 7} );
	var str = labels[id] + '  ▼';
	var newHeight = maxHeights[id];
	$( target ).next( 'div' ).animate({'height': newHeight + 'px'});
	$( target ).html( str );
}

function toggleNav( e ) {
	var id = $(e.target ).parent().attr( 'id' );
	expandeds[id] = !expandeds[id];
	if( expandeds[id] == true ) {
		maximize( e.target );
	} else {
		minimize( e.target );
	}
}