Advertisement
Guest User

Untitled

a guest
Dec 5th, 2012
595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. __d("DOMDimensions", ["DOMQuery", "Style"], function (a, b, c, d, e, f) {
  2. var g = b('DOMQuery'),
  3. h = b('Style'),
  4. i = {
  5. getElementDimensions: function (j) {
  6. return {
  7. width: j.offsetWidth || 0,
  8. height: j.offsetHeight || 0
  9. };
  10. },
  11. getViewportDimensions: function () {
  12. var j = (window && window.innerWidth) || (document && document.documentElement && document.documentElement.clientWidth) || (document && document.body && document.body.clientWidth) || 0,
  13. k = (window && window.innerHeight) || (document && document.documentElement && document.documentElement.clientHeight) || (document && document.body && document.body.clientHeight) || 0;
  14. return {
  15. width: j,
  16. height: k
  17. };
  18. },
  19. getViewportWithoutScrollbarDimensions: function () {
  20. var j = (document && document.documentElement && document.documentElement.clientWidth) || (document && document.body && document.body.clientWidth) || 0,
  21. k = (document && document.documentElement && document.documentElement.clientHeight) || (document && document.body && document.body.clientHeight) || 0;
  22. return {
  23. width: j,
  24. height: k
  25. };
  26. },
  27. getDocumentDimensions: function (j) {
  28. j = j || document;
  29. var k = g.getDocumentScrollElement(j),
  30. l = k.scrollWidth || 0,
  31. m = k.scrollHeight || 0;
  32. return {
  33. width: l,
  34. height: m
  35. };
  36. },
  37. measureElementBox: function (j, k, l, m, n) {
  38. var o;
  39. switch (k) {
  40. case 'left':
  41. case 'right':
  42. case 'top':
  43. case 'bottom':
  44. o = [k];
  45. break;
  46. case 'width':
  47. o = ['left', 'right'];
  48. break;
  49. case 'height':
  50. o = ['top', 'bottom'];
  51. break;
  52. default:
  53. throw Error('Invalid plane: ' + k);
  54. }
  55. var p = function (q, r) {
  56. var s = 0;
  57. for (var t = 0; t < o.length; t++) s += parseInt(h.get(j, q + '-' + o[t] + r), 10) || 0;
  58. return s;
  59. };
  60. return (l ? p('padding', '') : 0) + (m ? p('border', '-width') : 0) + (n ? p('margin', '') : 0);
  61. }
  62. };
  63. e.exports = i;
  64. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement