Пример #1
0
Table.prototype.setProperties = function(t)
{
    ReactComponent.prototype.setProperties.call(this, t);
    if (t.weights !== undefined)
    {
        if (ReactComponent.isNull(t.weights))
        {
            this.weights = null;
            this.markDirty();
        }
        else
        {
            var list = t.weights;
            var newWeights = [];
            while (Prolog._is_compound(list) && Prolog._term_functor(list) == Constants.listFunctor)
            {
                newWeights.push(ReactComponent.numericValueOr(Prolog._term_arg(list, 0), 0));
                list = Prolog._term_arg(list, 1);
            }
            if (list != Constants.emptyListAtom)
                console.log("Bad weights list!");
            // If the weights have changed, relayout
            if (this.weights == null || newWeights.length != this.weights.length || !newWeights.every(function(v,i) { return v === this.weights[i]}.bind(this)))
                this.markDirty();
            this.weights = newWeights;
        }
    }
}
Пример #2
0
Grid.prototype.setProperties = function(t)
{
    ReactComponent.prototype.setProperties.call(this, t);
    var must_relayout = false;
    if (t.weights !== undefined)
    {
        var list = t.weights;
        var newWeights = [];
        while (Prolog._is_compound(list) && Prolog._term_functor(list) == Constants.listFunctor)
        {
            newWeights.push(ReactComponent.numericValueOr(Prolog._term_arg(list, 0), 0));
            list = Prolog._term_arg(list, 1);
        }
        if (list != Constants.emptyListAtom)
            console.log("Bad weights list!");
        // If the weights have changed, relayout
        if (newWeights.length != this.weights.length || !newWeights.every(function(v,i) { return v === this.weights[i]}.bind(this)))
            must_relayout = true;
        this.weights = newWeights;
    }
    /* Not supported in table grid
    if (t.gap !== undefined)
    {
        if (ReactComponent.isNull(t.gap))
            this.getDOMNode().style['grid-gap'] = "";
        else
            this.getDOMNode().style['grid-gap'] = Prolog._atom_chars(t.gap);
    }
    */
    if (must_relayout)
        this.relayout();
}