| Total Complexity | 9 |
| Complexity/F | 1.29 |
| Lines of Code | 63 |
| Function Count | 7 |
| 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 | modal: true, |
||
| 14 | open: () => { |
||
| 15 | const TIMEOUT_TO_LOOK_SMOOTH = 50; |
||
| 16 | window.setTimeout(() => { |
||
| 17 | // hack to ensure this dialog is in front of other open dialogs, e.g. the footnote dialog. |
||
| 18 | this.$form.dialog('moveToTop'); |
||
| 19 | }, TIMEOUT_TO_LOOK_SMOOTH); |
||
| 20 | }, |
||
| 21 | }); |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Hide this form/dialog |
||
| 26 | * |
||
| 27 | * @return {void} |
||
| 28 | */ |
||
| 29 | hide() { |
||
| 30 | if (this.hasBeenOpened) { |
||
| 31 | this.$form.dialog('close'); |
||
| 32 | } |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Bind a callback to an event on the form |
||
| 37 | * |
||
| 38 | * @param {string} eventName name of the event, can contain namespaces (e.g. click.myPlugin ) |
||
| 39 | * @param {function} callback the handler function to be attached to the event |
||
| 40 | * |
||
| 41 | * @return {void} |
||
| 42 | */ |
||
| 43 | on(eventName, callback) { |
||
| 44 | this.$form.on(eventName, callback); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Remove a handler from an event |
||
| 49 | * |
||
| 50 | * @param {string} eventName name of the event, can contain namespaces (e.g. click.myPlugin ) |
||
| 51 | * |
||
| 52 | * @return {void} |
||
| 53 | */ |
||
| 54 | off(eventName) { |
||
| 55 | this.$form.off(eventName); |
||
| 56 | } |
||
| 57 | |||
| 58 | destroy() { |
||
| 59 | this.$form.remove(); |
||
| 60 | } |
||
| 61 | } |
||
| 62 | |||
| 63 | export default NodeForm; |
||
| 64 |