Jasse

holi

Apr 2nd, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.34 KB | None | 0 0
  1. function getPageScroll(){
  2.  
  3. var yScroll;
  4.  
  5. if (self.pageYOffset) {
  6. yScroll = self.pageYOffset;
  7. } else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict
  8. yScroll = document.documentElement.scrollTop;
  9. } else if (document.body) {// all other Explorers
  10. yScroll = document.body.scrollTop;
  11. }
  12.  
  13. arrayPageScroll = new Array('',yScroll)
  14. return arrayPageScroll;
  15. }
  16.  
  17.  
  18.  
  19. function getPageSize(){
  20.  
  21. var xScroll, yScroll;
  22.  
  23. if (window.innerHeight && window.scrollMaxY) {
  24. xScroll = document.body.scrollWidth;
  25. yScroll = window.innerHeight + window.scrollMaxY;
  26. } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
  27. xScroll = document.body.scrollWidth;
  28. yScroll = document.body.scrollHeight;
  29. } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
  30. xScroll = document.body.offsetWidth;
  31. yScroll = document.body.offsetHeight;
  32. }
  33.  
  34. var windowWidth, windowHeight;
  35. if (self.innerHeight) { // all except Explorer
  36. windowWidth = self.innerWidth;
  37. windowHeight = self.innerHeight;
  38. } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
  39. windowWidth = document.documentElement.clientWidth;
  40. windowHeight = document.documentElement.clientHeight;
  41. } else if (document.body) { // other Explorers
  42. windowWidth = document.body.clientWidth;
  43. windowHeight = document.body.clientHeight;
  44. }
  45.  
  46. // for small pages with total height less then height of the viewport
  47. if(yScroll < windowHeight){
  48. pageHeight = windowHeight;
  49. } else {
  50. pageHeight = yScroll;
  51. }
  52.  
  53. // for small pages with total width less then width of the viewport
  54. if(xScroll < windowWidth){
  55. pageWidth = windowWidth;
  56. } else {
  57. pageWidth = xScroll;
  58. }
  59.  
  60. arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
  61. return arrayPageSize;
  62. }
  63.  
  64.  
  65.  
  66. function popupPM(pmLink)
  67. {
  68. // prep objects
  69. var objOverlay = document.getElementById('overlay');
  70. var objLightbox = document.getElementById('lightbox');
  71.  
  72. var arrayPageSize = getPageSize();
  73. var arrayPageScroll = getPageScroll();
  74.  
  75. if (useLightbox == '1') {
  76. objOverlay.style.height = (arrayPageSize[1] + 'px');
  77. objOverlay.style.display = 'block';
  78. }
  79.  
  80. // center lightbox and make sure that the top and left values are not negative
  81. // and the image placed outside the viewport
  82. var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - pmHeight) / 2);
  83. var lightboxLeft = ((arrayPageSize[0] - 20 - pmWidth) / 2);
  84.  
  85. objLightbox.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
  86. objLightbox.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";
  87.  
  88. objLightbox.innerHTML = '<div class="block"><div class="blockhead" style="height: 18px"><span style="float: left">Enviar mensaje privado</span><a onclick="hidePopupPM();"><img src="images/misc/cross.png"></a></div><div class="blockbody"></div><div class="blockbody" align="center"><span style="font-size: 10px">Nota: No cierres la ventana mientras se está enviando el mensaje.</span></div></div>';
  89. objLightbox.style.display = 'block';
  90.  
  91. // After image is loaded, update the overlay height as the new image might have
  92. // increased the overall page height.
  93. arrayPageSize = getPageSize();
  94. objOverlay.style.height = (arrayPageSize[1] + 'px');
  95.  
  96. YAHOO.vBulletin.vBPopupMenu.close_all(); // close any vB popups for lightbox effect
  97.  
  98. return false;
  99. }
  100.  
  101.  
  102.  
  103. function hidePopupPM()
  104. {
  105. // get objects
  106. objOverlay = document.getElementById('overlay');
  107. objLightbox = document.getElementById('lightbox');
  108.  
  109. // hide lightbox and overlay
  110. objOverlay.style.display = 'none';
  111. objLightbox.style.display = 'none';
  112. }
  113.  
  114.  
  115.  
  116. function initPopupPM() {
  117. if (!document.getElementsByTagName){ return; }
  118. var anchors = document.getElementsByTagName("a");
  119.  
  120. // loop through all anchor tags
  121. for (var i=0; i<anchors.length; i++){
  122. var anchor = anchors[i];
  123.  
  124. if (anchor.getAttribute("href") && (anchor.getAttribute("href").indexOf('newpm') !=-1)){
  125. anchor.onclick = function () {popupPM(this); return false;}
  126. }
  127. }
  128. }
  129.  
  130.  
  131.  
  132. function addLoadEvent(func)
  133. {
  134. var oldonload = window.onload;
  135. if (typeof window.onload != 'function'){
  136. window.onload = func;
  137. } else {
  138. window.onload = function(){
  139. oldonload();
  140. func();
  141. }
  142. }
  143.  
  144. }
  145.  
  146.  
  147.  
  148. addLoadEvent(initPopupPM);
Advertisement
Add Comment
Please, Sign In to add comment