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

편집 요약 없음
편집 요약 없음
28번째 줄: 28번째 줄:
console.log('넌 값이 얼마니'+where_top);
console.log('넌 값이 얼마니'+where_top);
console.log('넌 값이 얼마니'+$(iter).offset().left);
console.log('넌 값이 얼마니'+$(iter).offset().left);
console.log('넌 값이 얼마니'+$(iter).width()/2);
alert('넌 값이 얼마니'+$(iter).width()/2);
iter.tooltip = baloon;
iter.tooltip = baloon;



2015년 5월 31일 (일) 13:12 판

var ref_tags = $("[id^=cite_ref]");
$(ref_tags).each(function(index ,iter)
{
	var a = $(iter).children("a")[0];
	var ref_text = $($(a).attr("href")).children(".reference-text")[0];
	var ref_text = $(ref_text).html();
	var baloon = document.createElement("div");
	var arrow = document.createElement("div");
	var inner = document.createElement("div");

	baloon.className = "tooltip bottom fade";
	arrow.className = "tooltip-arrow";
	inner.className = "tooltip-inner";
	$(inner).html(ref_text);

	$(baloon).append(arrow);
	$(baloon).append(inner);
	$('body').after(baloon);

	var baloonWidth = $(baloon).width()/2;
	var iterWidth = $(iter).width()/2;
	var where_top = $(iter).offset().top+15;
	var where_left = $(iter).offset().left-baloonWidth+iterWidth;

	$(baloon).css("top",where_top);
	$(baloon).css("left",where_left);

	console.log('넌 값이 얼마니'+where_top);
	console.log('넌 값이 얼마니'+$(iter).offset().left);
	alert('넌 값이 얼마니'+$(iter).width()/2);
	iter.tooltip = baloon;

	$(iter).hover(
		function(e)
		{
			var bal = this.tooltip;
			baloon.className = "tooltip bottom fade in";
		},
		function(e)
		{
			var bal = this.tooltip;
			baloon.className = "tooltip bottom fade";
		}
	);
});