The Pragmatic Programmer

Tulisan iseng kalo ada waktu.
See also: Other Geeks@INDC

Angry Function

This function is taken from jscalendar source code :) I found it while I was finding a way to prevent the calendar from showing beyond the screen boundary.

Calendar.continuation_for_the_fucking_khtml_browser = function() {

    var w = self.element.offsetWidth;
   
var h = self.element.offsetHeight;

    self.element.style.display = "none";

    var valign = opts.substr(0, 1);

    var halign = "l";

    if (opts.length > 1) {
      
halign = opts.substr(1, 1);
   
}

   // vertical alignment
  
switch (valign) {
     
case "T": p.y -= h; break;
     
case "B": p.y += el.offsetHeight; break;
     
case "C": p.y += (el.offsetHeight - h) / 2; break;
     
case "t": p.y += el.offsetHeight - h; break;
     
case "b": break; // already there
  
}

   // horizontal alignment
   switch (halign) {
     
case "L": p.x -= w; break;
     
case "R": p.x += el.offsetWidth; break;
     
case "C": p.x += (el.offsetWidth - w) / 2; break;
     
case "r": p.x += el.offsetWidth - w; break;
    
case "l": break; // already there
   }
   self.showAt(p.x, p.y);
};

Share this post: | | | |

Comments

No Comments