Separator.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Copyright (c) Business Objects 2006. All rights reserved. */
  2. if (typeof(bobj.crv.Separator) == 'undefined') {
  3. bobj.crv.Separator = {};
  4. }
  5. /**
  6. * Separator Constructor. Simple horizontal separator.
  7. *
  8. */
  9. bobj.crv.newSeparator = function(kwArgs) {
  10. var UPDATE = MochiKit.Base.update;
  11. kwArgs = UPDATE({
  12. id: bobj.uniqueId(),
  13. marginLeft: 4,
  14. marginRight: 4,
  15. marginTop: 0,
  16. marginBottom: 2
  17. }, kwArgs);
  18. var o = newWidget(kwArgs.id);
  19. bobj.fillIn(o, kwArgs);
  20. o.widgetType = 'Separator';
  21. // Attach member functions
  22. UPDATE(o, bobj.crv.Separator);
  23. return o;
  24. };
  25. bobj.crv.Separator.getHTML = function() {
  26. var HTML = bobj.html;
  27. var htmlStr = '';
  28. if (bobj.isBorderBoxModel()) {
  29. htmlStr = HTML.IMG({
  30. id: this.id,
  31. src: bobj.skinUri('sep.gif'),
  32. style: {
  33. 'height': 2 + 'px',
  34. 'width':'100%',
  35. 'margin-left': this.marginLeft + 'px',
  36. 'margin-right': this.marginRight + 'px',
  37. 'margin-top': this.marginTop + 'px',
  38. 'margin-bottom': this.marginBottom + 'px'
  39. }});
  40. }
  41. else {
  42. htmlStr = HTML.DIV({
  43. id : this.id,
  44. style: {
  45. 'height': 2 + 'px',
  46. 'margin-left': this.marginLeft + 'px',
  47. 'margin-right': this.marginRight + 'px',
  48. 'margin-top': this.marginTop + 'px',
  49. 'margin-bottom': this.marginBottom + 'px',
  50. 'background-image': 'url(' + bobj.skinUri('sep.gif') + ')',
  51. 'background-repeat': 'repeat-x',
  52. 'overflow': 'hidden'
  53. }});
  54. }
  55. return htmlStr + bobj.crv.getInitHTML(this.widx);
  56. };
  57. /**
  58. * @return Returns the outer height of the widget, including margins
  59. */
  60. bobj.crv.Separator.getHeight = function() {
  61. return this.layer.offsetHeight + this.marginTop + this.marginBottom;
  62. };