Добро пожаловать на Lesta Games Wiki!

Участник:Degit22:ru/common.js — различия между версиями

Перейти к: навигация, поиск
Версия 10:36, 21 июля 2016Версия 10:41, 21 июля 2016
Строка 16:Строка 16:
  
  
? e.onmousemove=positiontip; 
  
  
Строка 24:Строка 23:
  var str = '<div style="border:1px dotted;background:#efefef;padding:5px 1em;"><p style="text-align:center;"><b>'+Math.round(coords.bottom) + ' ' + (offset.top + $(this).height()) +' '+ e.clientX+':'+e.clientY+'</b></p> <dl>';  var str = '<div style="border:1px dotted;background:#efefef;padding:5px 1em;"><p style="text-align:center;"><b>'+Math.round(coords.bottom) + ' ' + (offset.top + $(this).height()) +' '+ e.clientX+':'+e.clientY+'</b></p> <dl>';
  
? //var items = [];+ var items = [];
? //$.each(obj.data, function(key, val){+ $.each(obj.data, function(key, val){
? // items.push('<dt>' + key + ':</dt><dd>' + val + '</dd>');+ items.push('<dt>' + key + ':</dt><dd>' + val + '</dd>');
? //});+ });
  
? //str += items.join('') + ' </dl></div><p>&nbsp;</p>';+ str += items.join('') + ' </dl></div><p>&nbsp;</p>';
  
  $("#dropDownBox2").html(str);  $("#dropDownBox2").html(str);
Строка 38:Строка 37:
  $("#dropDownBox2").hide();  $("#dropDownBox2").hide();
 }); });
? 
?function positiontip(e) { 
? var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft; 
? var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop; 
? var winwidth=ie? ietruebody().clientWidth : window.innerWidth-20 
? var winheight=ie? ietruebody().clientHeight : window.innerHeight-20 
?  
? var rightedge=ie? winwidth-event.clientX : winwidth-e.clientX; 
? var bottomedge=ie? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY; 
? 
? if (rightedge < tipobj.offsetWidth) tipobj.style.left=curX-tipobj.offsetWidth+"px"; 
? else tipobj.style.left=curX+"px"; 
? 
? if (bottomedge < tipobj.offsetHeight) tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px" 
? else tipobj.style.top=curY+offsetfromcursorY+"px"; 
?} 

Версия 10:41, 21 июля 2016

/* Функционал всплывающих подсказок с ТТХ модулей */
var isDropDownBox2 = false;
tipobj=document.getElementById('dropDownBox2');

$('.commentDrop').hover(
function(e){
  var target = e.target;
  if (!isDropDownBox2) {
    $('#bodyContent').append('<div id="dropDownBox2" style="position:fixed;"></div>');
    isDropDownBox2 = true;
  }
  var coords = target.getBoundingClientRect();
  var offset = $(this).position();
  var top = coords.bottom; //offset.top + $(this).height();
  //alert(coords.bottom + ' ' + top);





  var obj = $.parseJSON($(this).find(".commentData").text());

  var str = '<div style="border:1px dotted;background:#efefef;padding:5px 1em;"><p style="text-align:center;"><b>'+Math.round(coords.bottom) + ' ' + (offset.top + $(this).height()) +' '+ e.clientX+':'+e.clientY+'</b></p> <dl>';

  var items = [];
  $.each(obj.data, function(key, val){
    items.push('<dt>' + key + ':</dt><dd>' + val + '</dd>');
  });

  str += items.join('') + ' </dl></div><p>&nbsp;</p>';

  $("#dropDownBox2").html(str);
  $("#dropDownBox2").css({"top": e.clientY + "px", "left": e.clientX + "px"})
  $("#dropDownBox2").show();
},
function(){
  $("#dropDownBox2").hide();
});