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/core/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/libs/absol-form/js/core/FModel.js
import FAttributes from "./FAttributes";
import IndexedPropertyNames from "./IndexedPropertyNames";

function FModel() {
    var defaultAttribute = this.attributes;
    var attributes = new FAttributes(this);
    Object.defineProperty(this, 'attributes', {
        enumerable: true,
        set: function (value) {
            Object.assign(attributes, value)
        },
        get: function () {
            return attributes;
        }
    });
    Object.assign(this.attributes, defaultAttribute);
}

FModel.prototype.attributes = {};

/**
 * @returns {Array<String>}
 */
FModel.prototype.getAcceptsAttributeNames = function () {
    var dict = Object.assign({}, this.attributeHandlers);
    var names = Object.keys(dict);
    var indexed = IndexedPropertyNames;
    names.sort(function (a, b) {
        return indexed[a] - indexed[b];
    });
    return names;
};


/**
 * @param {String} name
 * @returns {}
 */
FModel.prototype.getAttributeDescriptor = function (name) {
    return this.attributes.getPropertyDescriptor(name);
};

/**
 * @returns {}
 */
FModel.prototype.getAttributeDescriptors = function () {
    var result = {};
    var names = this.getAcceptsAttributeNames();
    var key;
    for (var i = 0; i < names.length; ++i) {
        key = names[i];
        result[key] = this.getAttributeDescriptor(key);
    }
    return result;
};


/**
 * @param {String} name
 * @param {} value
 * @returns {} value which is set
 */
FModel.prototype.setAttribute = function (name, value) {
    this.attributes[name] = value;
};


/**
 * @param {String} name
 * @returns {} value which is set
 */
FModel.prototype.getAttribute = function (name) {
    var functionName = 'getAttribute' + name.substr(0, 1).toUpperCase() + name.substr(1);
    if (this[functionName]) {
        return this[functionName].apply(this, Array.prototype.slice.call(arguments, 1));
    }
    return this.attributes[name];
};


FModel.prototype.getAttributes = function () {
    var res = Object.assign({}, this.attributes.export());
    for (var key in res) {
        return res;
    }
    return null;
};

FModel.prototype.setAttributes = function (attributes) {
    var self = this;
    Object.keys(attributes).forEach(function (key) {
        self.setAttribute(key, attributes[key]);
    });
};


FModel.prototype.attributeHandlers = {};

FModel.prototype.getAttributeHandlers = function () {
    return this.attributeHandlers;
}

export default FModel;

VaKeR 2022