base-layout.js 1.8 KB
/* global slickgrid, edit */

var layout = {
    content_height: function() {
        "use strict";
        return $(window).height() - $('#main_menu').height();
    },

    grid_height: function() {
        "use strict";
        var by_form = $('#by-form-container');
        var by_form_height = edit.reader? by_form.innerHeight() : 0;
        return $('#left').innerHeight() - by_form_height;
    },

    adjust_grid_size: function() {
        "use strict";
        if (window.slickgrid && slickgrid.element) {
            slickgrid.element.height(layout.grid_height());
            if (slickgrid.grid) {
                slickgrid.grid.resizeCanvas();
                // slickgrid.grid.autosizeColumns();
            }
        }
    },

    adjust_tabs: function() {
        "use strict";
        var right = $('#right');
        var height = right.height() - right.find('.ui-tabs-nav').height() - 35;
        right.find('.ui-tabs-panel').height(height);
        right.width(
            $('#content').width() - $('#left').width() - $('.vsplitbar').width());
    },

    left_width: 280
};

$(function () {
    "use strict";
    if ($.fn.splitter) {
        var content = $('#content'), left = $('#left');
        content.innerHeight(layout.content_height());
        $(window).resize(function() {
            content.innerHeight(layout.content_height());
        });
        left.bind('resize', function (e) {
            layout.adjust_grid_size();
            e.stopPropagation(); // potrzebne, bo inaczej się zapętla
        });
        $('#right').bind('resize', function (e) {
            layout.adjust_tabs();
            e.stopPropagation();
        });
        content.splitter({
            type: 'v',
            minLeft: 200, sizeLeft: layout.left_width, minRight: 100,
            resizeToWidth: true
        });
    }
});