FitLayout.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * FitLayout.js
  3. *
  4. * Copyright, Moxiecode Systems AB
  5. * Released under LGPL License.
  6. *
  7. * License: http://www.tinymce.com/license
  8. * Contributing: http://www.tinymce.com/contributing
  9. */
  10. /**
  11. * This layout manager will resize the control to be the size of it's parent container.
  12. * In other words width: 100% and height: 100%.
  13. *
  14. * @-x-less FitLayout.less
  15. * @class tinymce.ui.FitLayout
  16. * @extends tinymce.ui.AbsoluteLayout
  17. */
  18. define("tinymce/ui/FitLayout", [
  19. "tinymce/ui/AbsoluteLayout"
  20. ], function(AbsoluteLayout) {
  21. "use strict";
  22. return AbsoluteLayout.extend({
  23. /**
  24. * Recalculates the positions of the controls in the specified container.
  25. *
  26. * @method recalc
  27. * @param {tinymce.ui.Container} container Container instance to recalc.
  28. */
  29. recalc: function(container) {
  30. var contLayoutRect = container.layoutRect(), paddingBox = container.paddingBox();
  31. container.items().filter(':visible').each(function(ctrl) {
  32. ctrl.layoutRect({
  33. x: paddingBox.left,
  34. y: paddingBox.top,
  35. w: contLayoutRect.innerW - paddingBox.right - paddingBox.left,
  36. h: contLayoutRect.innerH - paddingBox.top - paddingBox.bottom
  37. });
  38. if (ctrl.recalc) {
  39. ctrl.recalc();
  40. }
  41. });
  42. }
  43. });
  44. });