ui

webix.ui([see official doc])

webix.ui helper.

Please look into the linked official documentation.

External references

Official documentation page.

Code

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
(function(){

var resize = [];
var ui = webix.ui;

if (!webix.ui){
    ui = webix.ui = function(config, parent, id){
        webix._ui_creation = true;
        var multiset = webix.isArray(config);
        var node = webix.toNode((config.container||parent)||document.body);

        // solve problem with non-unique ids
        if(node._settings)
            id = _correctId(node, multiset, id);

        var top_node;
        var body_child = (node == document.body);
        if (config._settings || (node && multiset)){
            top_node = config;
        } else {
            if (node && body_child)
                config.$topView = true;
            if (!config._inner)
                config._inner = {};

            top_node = ui._view(config);
        }

        if (body_child && !top_node.setPosition && !top_node.$apiOnly)
            webix.ui._fixHeight();

        if (top_node._settings && top_node._settings._hidden && !node.$view){
            top_node._settings._container = node;
        } else if (!top_node.$apiOnly){
            if (node.appendChild)
                _appendDom(node, top_node, config);
            else if (node.destructor){
                var target = node;

                //addView or view moving with target id
                if (!id && id!==0 && !webix.isArray(top_node)){
                    id = node;
                    node = node.getParentView();
                }

                //if target supports view adding
                if (node && node._replace){
                    //if source supports view removing
                    if (top_node.getParentView && top_node.getParentView())
                        top_node.getParentView()._remove(top_node);

                    node._replace(top_node, id);
                } else {
                    var parent = target.$view.parentNode;
                    target.destructor();
                    _appendDom(parent, top_node, config);
                }
            } else
                webix.assert_error("Not existing parent:"+config.container);
        }

        webix._ui_creation = false;
        return top_node;
    };

    var _appendDom = function(node, top_node, config){
        node.appendChild(top_node._viewobj);
        //resize window with position center or top
        //do not resize other windows and elements
        // which are attached to custom html containers
        if (((!top_node.setPosition || top_node._settings.fullscreen) && node == document.body) || top_node._settings.position )
            resize.push(top_node);
        if (!config.skipResize)
            top_node.adjust();
    };

    var _correctId = function(target, multiset, id){
        //replace view
        var views = [target];
        //replace content of layout
        if (multiset)
            views = target.getChildViews();
        //replace content of window
        else if (target._body_cell)
            views = [target._body_cell];
        //add cell in layout by number
        else if (typeof id == "number"){
            return id;
        //replace cell in layout by id
        } else if (id){
            views = [webix.$$(id)];
            _deleteIds(views);
            return views[0].config.id;
        }

        _deleteIds(views);
        return id;
    };

    var _deleteIds = function(views){
        for (var i = views.length - 1; i >= 0; i--){
            //remove original id
            delete webix.ui.views[views[i].config.id];
            //create temp id
            views[i].config.id = "x"+webix.uid();
            webix.ui.views[views[i].config.id] = views[i];
            //process childs
            _deleteIds(views[i].getChildViews());
        }
    };
}