import $ from "./jquery.module.js";

$.fn.extend({
    setVisibility: function (arg) {
        // If typeof arg is ...
        // string: it becomes the new value of the visibility style
        // boolean: true is "visible", false is "hidden"
        // number: similar to boolean (0 is "hidden", other values mean "visible"
        // No other types are accepted.
        let argument;
        switch (typeof arg) {
            case "string":
                argument = arg;
                break;
            case "boolean":
                argument = arg ? "visible" : "hidden";
                break;
            case "number":
                argument = arg !== 0 ? "visible" : "hidden";
                break;
            default:
                return this;
        }
        return this.css("visibility", argument);
    }
});