diff options
Diffstat (limited to 'client/lib/inlinedform.js')
-rw-r--r-- | client/lib/inlinedform.js | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/client/lib/inlinedform.js b/client/lib/inlinedform.js index 15074f40..2732a2e3 100644 --- a/client/lib/inlinedform.js +++ b/client/lib/inlinedform.js @@ -13,66 +13,66 @@ // // the content when the form is close (optional) // We can only have one inlined form element opened at a time -currentlyOpenedForm = new ReactiveVar(null); +const currentlyOpenedForm = new ReactiveVar(null); InlinedForm = BlazeComponent.extendComponent({ - template: function() { + template() { return 'inlinedForm'; }, - onCreated: function() { + onCreated() { this.isOpen = new ReactiveVar(false); }, - onDestroyed: function() { + onDestroyed() { currentlyOpenedForm.set(null); }, - open: function() { + open() { // Close currently opened form, if any EscapeActions.executeUpTo('inlinedForm'); this.isOpen.set(true); currentlyOpenedForm.set(this); }, - close: function() { + close() { this.isOpen.set(false); currentlyOpenedForm.set(null); }, - getValue: function() { - var input = this.find('textarea,input[type=text]'); + getValue() { + const input = this.find('textarea,input[type=text]'); return this.isOpen.get() && input && input.value; }, - events: function() { + events() { return [{ 'click .js-close-inlined-form': this.close, 'click .js-open-inlined-form': this.open, // Pressing Ctrl+Enter should submit the form - 'keydown form textarea': function(evt) { + 'keydown form textarea'(evt) { if (evt.keyCode === 13 && (evt.metaKey || evt.ctrlKey)) { this.find('button[type=submit]').click(); } }, // Close the inlined form when after its submission - submit: function() { + submit() { if (this.currentData().autoclose !== false) { Tracker.afterFlush(() => { this.close(); }); } - } + }, }]; - } + }, }).register('inlinedForm'); // Press escape to close the currently opened inlinedForm EscapeActions.register('inlinedForm', - function() { currentlyOpenedForm.get().close(); }, - function() { return currentlyOpenedForm.get() !== null; }, { - noClickEscapeOn: '.js-inlined-form' + () => { currentlyOpenedForm.get().close(); }, + () => { return currentlyOpenedForm.get() !== null; }, { + noClickEscapeOn: '.js-inlined-form', } ); |