Passed
Push — master ( 92cf80...05c5b5 )
by Michael
02:48
created

NodeForm.js ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 7
Bugs 0 Features 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 1
rs 10
c 7
b 0
f 0
1
class NodeForm {
2
    /**
3
     * @param {string} formID id of the respective form element
4
     *
5
     * @return {void}
6
     */
7
    constructor(formID) {
8
        this.$form = jQuery(`#${formID}`);
9
    }
10
11
    /**
12
     * Show this form in a jQueryUI dialog
13
     *
14
     * @return {void}
15
     */
16
    show() {
17
        jQuery(this.$form).dialog({
18
            title: this.name,
19
            width: 600,
20
        });
21
    }
22
23
    /**
24
     * Hide this form/dialog
25
     *
26
     * @return {void}
27
     */
28
    hide() {
29
        jQuery(this.$form).dialog('close');
30
    }
31
32
    /**
33
     * Bind a callback to an event on the form
34
     *
35
     * @param {string} eventName name of the event, can contain namespaces (e.g. click.myPlugin )
36
     * @param {function} callback the handler function to be attached to the event
37
     *
38
     * @return {void}
39
     */
40
    on(eventName, callback) {
41
        this.$form.on(eventName, callback);
42
    }
43
44
    /**
45
     * Remove a handler from an event
46
     *
47
     * @param {string} eventName name of the event, can contain namespaces (e.g. click.myPlugin )
48
     *
49
     * @return {void}
50
     */
51
    off(eventName) {
52
        this.$form.off(eventName);
53
    }
54
}
55
56
export default NodeForm;
57