4 * Copyright, Moxiecode Systems AB
5 * Released under LGPL License.
7 * License: http://www.tinymce.com/license
8 * Contributing: http://www.tinymce.com/contributing
12 * Base layout manager class.
14 * @class tinymce.ui.Layout
16 define("tinymce/ui/Layout", [
19 ], function(Class, Tools) {
24 firstControlClass: 'first',
25 lastControlClass: 'last'
29 * Constructs a layout instance with the specified settings.
32 * @param {Object} settings Name/value object with settings.
34 init: function(settings) {
35 this.settings = Tools.extend({}, this.Defaults, settings);
39 * This method gets invoked before the layout renders the controls.
42 * @param {tinymce.ui.Container} container Container instance to preRender.
44 preRender: function(container) {
45 container.addClass(this.settings.containerClass, 'body');
49 * Applies layout classes to the container.
53 applyClasses: function(container) {
54 var self = this, settings = self.settings, items, firstClass, lastClass;
56 items = container.items().filter(':visible');
57 firstClass = settings.firstControlClass;
58 lastClass = settings.lastControlClass;
60 items.each(function(item) {
61 item.removeClass(firstClass).removeClass(lastClass);
63 if (settings.controlClass) {
64 item.addClass(settings.controlClass);
68 items.eq(0).addClass(firstClass);
69 items.eq(-1).addClass(lastClass);
73 * Renders the specified container and any layout specific HTML.
76 * @param {tinymce.ui.Container} container Container to render HTML for.
78 renderHtml: function(container) {
79 var self = this, settings = self.settings, items, html = '';
81 items = container.items();
82 items.eq(0).addClass(settings.firstControlClass);
83 items.eq(-1).addClass(settings.lastControlClass);
85 items.each(function(item) {
86 if (settings.controlClass) {
87 item.addClass(settings.controlClass);
90 html += item.renderHtml();
97 * Recalculates the positions of the controls in the specified container.
100 * @param {tinymce.ui.Container} container Container instance to recalc.
106 * This method gets invoked after the layout renders the controls.
109 * @param {tinymce.ui.Container} container Container instance to postRender.
111 postRender: function() {