VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/www/html/libs/absol-form/js/components/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/libs/absol-form/js/components/DualComboBox.js
import FCore from "../core/FCore";
import ScalableComponent from "../core/ScalableComponent";
import ComboBox from "./ComboBox";
import inheritComponentClass from "../core/inheritComponentClass";
import InputAttributeHandlers, {InputAttributeNames} from "./handlers/InputAttributeHandlers";
import {AssemblerInstance} from "../core/Assembler";
import DomSignal from "absol/src/HTML5/DomSignal";

var _ = FCore._;

/***
 * @extends ScalableComponent
 * @constructor
 */
function DualComboBox() {
    ScalableComponent.call(this);
}

inheritComponentClass(DualComboBox, ScalableComponent);

DualComboBox.prototype.tag = "DualComboBox";

DualComboBox.prototype.menuIcon = 'span.mdi.mdi-chevron-double-down';

Object.assign(DualComboBox.prototype.attributeHandlers, InputAttributeHandlers);

DualComboBox.prototype.attributeHandlers.value = {
    set: function (value) {
        var prev = (this.domElt.value || [null, null]).join('/');
        this.domElt.value = value;
        var cur = (this.domElt.value || [null, null]).join('/');
        if (prev !== cur) {
            this.pinFire('value');
        }
    },
    get: function () {
        return this.domElt.value;
    }
};
DualComboBox.prototype.attributeHandlers.searchable = ComboBox.prototype.attributeHandlers.searchable;
DualComboBox.prototype.attributeHandlers.strictValue = ComboBox.prototype.attributeHandlers.strictValue;
DualComboBox.prototype.attributeHandlers.treeList = Object.assign({}, ComboBox.prototype.attributeHandlers.list, {
    set: function (items) {
        var prev = (this.domElt.value || [null, null]).join('/');
        this.domElt.items = items;
        var cur = (this.domElt.value || [null, null]).join('/');
        if (prev !== cur) {
            this.pinFire('value');
        }
    },
    descriptor: {
        type: 'SelectTreeList'
    },
    export: function () {
        var treeList = this.domElt.items;
        return treeList.map(function copyItem(item) {
            var newItem = { value: item.value, text: item.text };
            if (item.items && item.items.length)
                newItem.items = item.items.map(copyItem);
            return newItem;
        });
    }
});

DualComboBox.prototype.pinHandlers.treeList = {
    receives: function (value) {
        this.attributes.treeList = value;
    },
    descriptor: {
        type: 'SelectTreeList'
    }
};

DualComboBox.prototype.pinHandlers.value = ComboBox.prototype.pinHandlers.value;

DualComboBox.prototype.onCreate = function () {
    ScalableComponent.prototype.onCreate.call(this);
};


DualComboBox.prototype.onCreated = function () {
    ScalableComponent.prototype.onCreated.call(this);
    var self = this;
    if (!this.domElt.domSignal) {
        this.domElt.$domSignal = _('attachhook').addTo(this.domElt);
        this.domElt.domSignal = new DomSignal(this.domElt.$domSignal);
    }
    this.domSignal = this.domElt.domSignal;
    this.domSignal.on('pinFireAll', this.pinFireAll.bind(this));
    this.view.on('change', function () {
        self.emit("change", { type: 'change', value: this.value }, self);
        self.pinFire('value');
        self.notifyChange();
    });
};

DualComboBox.prototype.render = function () {
    return _('dualselectmenu');
};


DualComboBox.prototype.getAcceptsAttributeNames = function () {
    return ScalableComponent.prototype.getAcceptsAttributeNames.call(this).concat(["treeList", 'value', 'searchable'])
        .concat(InputAttributeNames);
};


DualComboBox.prototype.getAcceptsEventNames = function () {
    return ScalableComponent.prototype.getAcceptsEventNames.call(this).concat(['change']);
};


DualComboBox.prototype.measureMinSize = function () {
    var minWidthStyle = this.domElt ? parseFloat(this.domElt.getComputedStyleValue('min-width').replace('px')) : 24;
    return { width: Math.max(minWidthStyle, 24), height: 25 };
};

DualComboBox.prototype.createDataBindingDescriptor = function () {
    var thisC = this;
    var subObj = {};
    Object.defineProperties(subObj, {
        value: {
            configurable: true,
            enumerable: true,
            set: function (value) {
                thisC.setAttribute('value', value);
            },
            get: function () {
                return thisC.getAttribute('value');
            }
        },
        treeList: {
            enumerable: false,
            configurable: true,
            get: function () {
                return thisC.getAttribute('treeList');
            },
            set: function (value) {
                thisC.setAttribute('treeList', value);
            }
        }
    });

    return {
        set: function (value) {
            Object.assign(subObj, value);
        },
        get: function () {
            return subObj;
        }
    };
};

AssemblerInstance.addClass(DualComboBox);

export default DualComboBox;

VaKeR 2022