Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Calendar.prototype.showAtElement = function(element, operation) {
  2.   function setup(e) {
  3.     if (e.x < 0) {
  4.       e.x = 0;
  5.     }
  6.     if (e.y < 0) {
  7.       e.y = 0;
  8.     }
  9.    
  10.     var boundCalcDiv = document.createElement("div");
  11.     var boundCalcDivStyle = boundCalcDiv.style;
  12.     boundCalcDivStyle.position = "absolute";
  13.     boundCalcDivStyle.right = boundCalcDivStyle.bottom = boundCalcDivStyle.width = boundCalcDivStyle.height = "0px";
  14.     document.body.appendChild(boundCalcDiv);
  15.     var pos = Calendar.getAbsolutePos(boundCalcDiv);
  16.     document.body.removeChild(boundCalcDiv);
  17.     if (Calendar.is_ie) {
  18.       pos.y += document.body.scrollTop;
  19.       pos.x += document.body.scrollLeft;
  20.     } else {
  21.       pos.y += window.scrollY;
  22.       pos.x += window.scrollX;
  23.     }
  24.  
  25.     var offset = e.x + e.width - pos.x;
  26.     if (offset > 0) {
  27.       e.x -= offset;
  28.     }
  29.  
  30.     offset = e.y + e.height - pos.y;
  31.     if (offset > 0) {
  32.       e.y -= offset;
  33.     }
  34.   }
  35.  
  36.   var cal = this;
  37.   var e = Calendar.getAbsolutePos(element);
  38.   if (!operation || typeof operation != "string") {
  39.     this.showAt(e.x, e.y + element.offsetHeight);
  40.     return true;
  41.   }
  42.  
  43.   this.element.style.display = "block";
  44.  
  45.   Calendar.continuation_for_the_fucking_khtml_browser = function() {
  46.     var x = cal.element.offsetWidth;
  47.     var y = cal.element.offsetHeight;
  48.  
  49.     cal.element.style.display = "none";
  50.     var type = operation.substr(0, 1);
  51.  
  52.     var op = "l";
  53.     if (operation.length > 1) {
  54.       op = operation.substr(1, 1);
  55.     }
  56.     switch(type) {
  57.       case "T":
  58.         e.y -= y;
  59.         break;
  60.       case "B":
  61.         e.y += c.offsetHeight;
  62.         break;
  63.       case "C":
  64.         e.y += (c.offsetHeight - y) / 2;
  65.         break;
  66.       case "t":
  67.         e.y += c.offsetHeight - y;
  68.         break;
  69.       case "b":
  70.         break;
  71.     }
  72.     switch(op) {
  73.       case "L":
  74.         e.x -= x;
  75.         break;
  76.       case "R":
  77.         e.x += element.offsetWidth;
  78.         break;
  79.       case "C":
  80.         e.x += (element.offsetWidth - x) / 2;
  81.         break;
  82.       case "l":
  83.         e.x += element.offsetWidth - x;
  84.         break;
  85.       case "r":
  86.         break;
  87.     }
  88.     e.width = x;
  89.     e.height = y + 40;
  90.  
  91.     cal.monthsCombo.style.display = "none";
  92.     setup(e);
  93.     cal.showAt(e.x, e.y);
  94.   };
  95.   if (Calendar.is_khtml) {
  96.     setTimeout("Calendar.continuation_for_the_fucking_khtml_browser()", 10);
  97.   } else {
  98.     Calendar.continuation_for_the_fucking_khtml_browser();
  99.   }
  100. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement