| 16 | |
| 17 | module.exports = (ModalView = (function () { |
| 18 | ModalView = class ModalView extends CocoView { |
| 19 | static initClass () { |
| 20 | this.prototype.className = 'modal fade' |
| 21 | this.prototype.closeButton = true |
| 22 | this.prototype.closesOnClickOutside = true |
| 23 | this.prototype.modalWidthPercent = null |
| 24 | this.prototype.plain = false |
| 25 | this.prototype.instant = false |
| 26 | this.prototype.template = require('app/templates/core/modal-base') |
| 27 | this.prototype.trapsFocus = true |
| 28 | |
| 29 | this.prototype.events = { |
| 30 | 'click a': 'toggleModal', |
| 31 | 'click button': 'toggleModal', |
| 32 | 'click li': 'toggleModal', |
| 33 | 'click [data-i18n]': 'onClickTranslatedElement', |
| 34 | } |
| 35 | |
| 36 | this.prototype.shortcuts = |
| 37 | { esc: 'onEsc' } |
| 38 | |
| 39 | this.prototype.subscriptions = |
| 40 | {} |
| 41 | } |
| 42 | |
| 43 | constructor (options) { |
| 44 | super(...arguments) |
| 45 | if ((options != null ? options.instant : undefined) || this.instant) { this.className = this.className.replace(' fade', '') } |
| 46 | if ((options != null ? options.closeButton : undefined) != null) { this.closeButton = options.closeButton } |
| 47 | if (options != null ? options.modalWidthPercent : undefined) { this.modalWidthPercent = options.modalWidthPercent } |
| 48 | if (this.options == null) { this.options = {} } |
| 49 | if ((options != null ? options.trapsFocus : undefined) != null) { this.trapsFocus = options.trapsFocus } |
| 50 | } |
| 51 | |
| 52 | getRenderData (c) { |
| 53 | c = super.getRenderData(c) |
| 54 | c.marked = marked |
| 55 | return c |
| 56 | } |
| 57 | |
| 58 | render () { |
| 59 | __guardMethod__(this.focusTrap, 'deactivate', o => o.deactivate()) |
| 60 | super.render() |
| 61 | this.trapFocus() |
| 62 | } |
| 63 | |
| 64 | afterRender () { |
| 65 | super.afterRender() |
| 66 | if (this.modalWidthPercent) { |
| 67 | this.$el.find('.modal-dialog').css({ width: `${this.modalWidthPercent}%` }) |
| 68 | } |
| 69 | this.$el.on('hide.bs.modal', () => { |
| 70 | if (!this.hidden) { this.onHidden() } |
| 71 | this.hidden = true |
| 72 | }) |
| 73 | if (this.plain) { return this.$el.find('.background-wrapper').addClass('plain') } |
| 74 | } |
| 75 |
nothing calls this directly
no outgoing calls
no test coverage detected