Sha256: 4d730c9b1b33881d54d36820f01c9d617c71c589697219da15c2332569b76410

Contents?: true

Size: 874 Bytes

Versions: 90

Compression:

Stored size: 874 Bytes

Contents

export default class {
    // takes a jquery selector for a select field
    // create a custom change event with the data when it changes
    constructor(element) {
        this.changeHandlers = []
        this.element = element
        element.on('change', (e) => {
            this.change(this.data())
        })
    }

    data() {
        return this.element.find(":selected").data()
    }

    isEmpty() {
        return this.element.children().length === 0
    }

    /**
     * returns undefined or true
     */
    isSharing() {
        return this.data()["sharing"]
    }

    on(eventName, handler) {
        switch (eventName) {
            case "change":
                return this.changeHandlers.push(handler)
        }
    }

    change(data) {
        for (let fn of this.changeHandlers) {
          setTimeout(function() { fn(data) }, 0)
        }
    }
}

Version data entries

90 entries across 90 versions & 2 rubygems

Version Path
hyrax-5.1.0.pre.beta1 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-5.0.4 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-5.0.3 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-5.0.2 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-5.0.1 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-5.0.0 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-5.0.0.rc3 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-5.0.0.rc2 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-5.0.0.rc1 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-3.6.0 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-4.0.0 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-4.0.0.rc3 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-4.0.0.rc2 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-4.0.0.rc1 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-3.5.0 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-4.0.0.beta2 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-3.4.2 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-4.0.0.beta1 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-3.4.1 app/assets/javascripts/hyrax/editor/admin_set_widget.es6
hyrax-3.4.0 app/assets/javascripts/hyrax/editor/admin_set_widget.es6