All pastes #475100 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-05-07 06:58 UTC
rendered paste body
    cb.center = function(x, y) {
      var c = $('#'+ cb.o.craqboxId);
      var newX;
      var newY;
      x = x || 0;
      y = y || 0;
      
      // Handle aligning.
      if (cb.o.verticalAlign) {
        var h = self.innerHeight || document.documentElement.clientHeight || $('body')[0].clientHeight || 0;
        newY = ((h - $('#'+ cb.o.craqboxId).height()) / 2) + y;
      }
      else {
        newY = (cb.o.padding + window.scrollY);
      }
      c.css('top', newY +'px');
      
      // Handle aligning.
      if (cb.o.horizontalAlign) {
        var w = $(document.body).width();
        newX = ((w + window.scrollX - cb.o.width) / 2) + x;
      }
      else {
        newX = (cb.o.padding + window.scrollX);
      }
      c.css('left', newX +'px');
      
      // Reset the hiders size.
      cb.hider();
    };