/// class PD.Web.UI.Controls.GridCheckboxColumn
/// using PD.Web.UI.Controls.GridColumn

PD.Web.UI.Controls.GridCheckboxColumn =
PD.Web.UI.Controls.GridColumn.extend({

    //===================================
    // CONSTRUCTOR
    //===================================

    init: function (options) {

        this._super($.extend({
            width: 26,
            title: "&nbsp;",
            readOnly: false,
            template: $.proxy(this.template, this),
            transform: function (data) {
                return data[this.properties("field")];
            },
            attributes: {
                style: "padding:3px 3px 3px 3px;text-overflow:clip;"
            },
            headerAttributes: {
                "class": "-pd-noresize"
            }
        }, options));

    },

    //===================================
    // PUBLIC METHODS
    //===================================

    template: function (data) {

        var value = _.bind(this.properties("transform"), this)(data);
        var readOnly = this.properties("readOnly");
        var masked = this.properties("masked");

        var result = `
            <div style="width:100%;height:16px;box-sizing:border-box;position:relative;padding:2px 3px 0 3px;text-align:center;">
                <input type="checkbox" style="margin:0;" ${(value ? "checked" : "") + " " + (readOnly ? "disabled" : "")} ${masked === true ? `tabIndex="-1"` : ""}/>
                ${masked === true ? `<div style="position: absolute; inset: 0;background-color:#000000;opacity:.0001;"></div>` : ""}
            </div>`;

        return result;

    }

});