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/FViewable.js
import FAttributes from "./FAttributes";
import IndexedPropertyNames from "./IndexedPropertyNames";

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

/***
 *
 * @type {{}|FAttributes}
 */
FViewable.prototype.style = {};

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

/***
 * @returns {AElement}
 */
FViewable.prototype.render = function () {
    throw new Error('Not Implement');
};

/**
 * @param {String} name
 * @returns {}
 */
FViewable.prototype.getStyleDescriptor = function (name) {
    var functionName = 'getStyle' + name.substr(0, 1).toUpperCase() + name.substr(1) + 'Descriptor';
    return (this[functionName] && this[functionName].apply(this, Array.prototype.slice.call(arguments, 1)))
        || this.style.getPropertyDescriptor(name);
};


/**
 * @returns {}
 */
FViewable.prototype.getStyleDescriptors = function () {
    var result = {};
    var names = this.getAcceptsStyleNames();
    var key;
    for (var i = 0; i < names.length; ++i) {
        key = names[i];
        result[key] = this.getStyleDescriptor(key);
    }
    return result;
};


/**
 * @param {String} name
 * @param {*} value
 * @returns {*} value which is set
 */
FViewable.prototype.setStyle = function (name, value) {
    return this.style.setProperty.apply(this.style, arguments);
};


/**
 * @param {String} name
 * @returns {Object} value which is set
 */
FViewable.prototype.getStyle = function (name) {
    return this.style.getProperty.apply(this.style, arguments);
};


FViewable.prototype.getStyles = function () {
    var self = this;
    var styleKeys = Object.keys(this.style).filter(function (key) {
        return self.style[key] !== undefined || self.style[key] !== null;
    });

    if (styleKeys.length > 0) {
        return styleKeys.reduce(function (ac, key) {
            ac[key] = self.style[key];
            return ac;
        }, {});
    }
    return null;
};

FViewable.prototype.setStyles = function (styles) {
    var self = this;
    Object.keys(styles).forEach(function (key){
        self.setStyle(key, styles[key]);
    });
};

FViewable.prototype.styleHandlers = {};

export default FViewable;

VaKeR 2022