Total Complexity | 7 |
Complexity/F | 1.4 |
Lines of Code | 55 |
Function Count | 5 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | class NodeForm { |
||
2 | /** |
||
3 | * Show this form in a jQueryUI dialog |
||
4 | * |
||
5 | * @return {void} |
||
6 | */ |
||
7 | show() { |
||
8 | this.hasBeenOpened = true; |
||
9 | this.$form.dialog({ |
||
10 | title: this.name, |
||
11 | width: 800, |
||
12 | appendTo: '.dokuwiki', |
||
13 | }); |
||
14 | } |
||
15 | |||
16 | /** |
||
17 | * Hide this form/dialog |
||
18 | * |
||
19 | * @return {void} |
||
20 | */ |
||
21 | hide() { |
||
22 | if (this.hasBeenOpened) { |
||
23 | this.$form.dialog('close'); |
||
24 | } |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * Bind a callback to an event on the form |
||
29 | * |
||
30 | * @param {string} eventName name of the event, can contain namespaces (e.g. click.myPlugin ) |
||
31 | * @param {function} callback the handler function to be attached to the event |
||
32 | * |
||
33 | * @return {void} |
||
34 | */ |
||
35 | on(eventName, callback) { |
||
36 | this.$form.on(eventName, callback); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Remove a handler from an event |
||
41 | * |
||
42 | * @param {string} eventName name of the event, can contain namespaces (e.g. click.myPlugin ) |
||
43 | * |
||
44 | * @return {void} |
||
45 | */ |
||
46 | off(eventName) { |
||
47 | this.$form.off(eventName); |
||
48 | } |
||
49 | |||
50 | destroy() { |
||
51 | this.$form.remove(); |
||
52 | } |
||
53 | } |
||
54 | |||
55 | export default NodeForm; |
||
56 |