Sha256: 74d29561255d4fbdd378b052075dc4c385a5594cd97b730bcac4d549d136c524

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

include('nativeControl.js');

uki.view.declare('uki.more.view.NativeCheckbox', uki.more.view.NativeControl, function(Base) {
    this.checked = function(value) {
        if (value === undefined) return this._dom.checked;
        this._dom.checked = this._dom.defaultChecked = value;
        return this;
    };
    
    this.value = this.checked;
    
    var inputSize;
    function initInputSize () {
        if (!inputSize) {
            var input = uki.createElement('input', 'width:auto;height:auto;display:block;');
            input.type = 'checkbox';
            uki.dom.probe(input, function(input) {
                inputSize = [input.offsetWidth, input.offsetHeight];
            });
        }
    }
    
    this._setup = function() {
        Base._setup.call(this);
        this._type = 'checkbox';
    };
    
    this._layoutDom = function(rect) {
        initInputSize();
        var l = {
                left: rect.x + (rect.width - inputSize[0]) / 2,
                top:  rect.y + (rect.height - inputSize[1]) / 2
            };
        
        this._lastLayout = uki.dom.layout(this._dom.style, l, this._lastLayout);
        return true;
    };
});

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
uki-1.1.4 frameworks/uki/src/uki-more/more/view/nativeCheckbox.js
uki-1.1.3 frameworks/uki/src/uki-more/more/view/nativeCheckbox.js
uki-1.1.2 frameworks/uki/src/uki-more/more/view/nativeCheckbox.js