# weforms/1.6.1/assets/components/modal/index.js

weForms – Easy Drag &amp; Drop Contact Form Builder For WordPress, version 1.6.1. 27 lines.

- Page: https://pluginprobe.com/plugins/weforms/1.6.1/code/assets/components/modal/index.js
- Raw: https://pluginprobe.com/plugins/weforms/1.6.1/raw/assets/components/modal/index.js
- Modified: 2020-11-11T12:52:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/weforms/1.6.1/code/assets/components/modal/index.js#L10-L20`.

```javascript
Vue.component('wpuf-modal', {
    template: '#tmpl-wpuf-modal',
    props: {
        show: Boolean,
        onClose: Function
    },

    mounted: function () {
        var self = this;

        $('body').on( 'keydown', function(e) {
            if (self.show && e.keyCode === 27) {
                self.closeModal();
            }
        });
    },

    methods: {
        closeModal: function() {
            if ( typeof this.onClose !== 'undefined' ) {
                this.onClose();
            } else {
                this.$emit('hideModal');
            }
        }
    }
});
```
