diff options
Diffstat (limited to 'server/sonar-web/src/main/js/components/common/modal-form.js')
-rw-r--r-- | server/sonar-web/src/main/js/components/common/modal-form.js | 113 |
1 files changed, 57 insertions, 56 deletions
diff --git a/server/sonar-web/src/main/js/components/common/modal-form.js b/server/sonar-web/src/main/js/components/common/modal-form.js index aa23023c279..86ae8b89387 100644 --- a/server/sonar-web/src/main/js/components/common/modal-form.js +++ b/server/sonar-web/src/main/js/components/common/modal-form.js @@ -1,67 +1,68 @@ -define(['components/common/modals'], function (ModalView) { +import _ from 'underscore'; +import ModalView from 'components/common/modals'; - return ModalView.extend({ +export default ModalView.extend({ - ui: function () { - return { - messagesContainer: '.js-modal-messages' - }; - }, + ui: function () { + return { + messagesContainer: '.js-modal-messages' + }; + }, - events: function () { - return _.extend(ModalView.prototype.events.apply(this, arguments), { - 'keydown input,textarea,select': 'onInputKeydown', - 'submit form': 'onFormSubmit' - }); - }, + events: function () { + return _.extend(ModalView.prototype.events.apply(this, arguments), { + 'keydown input,textarea,select': 'onInputKeydown', + 'submit form': 'onFormSubmit' + }); + }, - onRender: function () { - ModalView.prototype.onRender.apply(this, arguments); - var that = this; - setTimeout(function () { - that.$(':tabbable').first().focus(); - }, 0); - }, + onRender: function () { + ModalView.prototype.onRender.apply(this, arguments); + var that = this; + setTimeout(function () { + that.$(':tabbable').first().focus(); + }, 0); + }, - onInputKeydown: function (e) { - if (e.keyCode === 27) { - // escape - this.destroy(); - } - }, + onInputKeydown: function (e) { + if (e.keyCode === 27) { + // escape + this.destroy(); + } + }, - onFormSubmit: function (e) { - e.preventDefault(); - }, + onFormSubmit: function (e) { + e.preventDefault(); + }, - showErrors: function (errors, warnings) { - var container = this.ui.messagesContainer.empty(); - if (_.isArray(errors)) { - errors.forEach(function (error) { - var html = '<div class="alert alert-danger">' + error.msg + '</div>'; - container.append(html); - }); - } - if (_.isArray(warnings)) { - warnings.forEach(function (warn) { - var html = '<div class="alert alert-warning">' + warn.msg + '</div>'; - container.append(html); - }); - } - this.ui.messagesContainer.scrollParent().scrollTop(0); - }, + showErrors: function (errors, warnings) { + var container = this.ui.messagesContainer.empty(); + if (_.isArray(errors)) { + errors.forEach(function (error) { + var html = '<div class="alert alert-danger">' + error.msg + '</div>'; + container.append(html); + }); + } + if (_.isArray(warnings)) { + warnings.forEach(function (warn) { + var html = '<div class="alert alert-warning">' + warn.msg + '</div>'; + container.append(html); + }); + } + this.ui.messagesContainer.scrollParent().scrollTop(0); + }, - disableForm: function () { - var form = this.$('form'); - this.disabledFields = form.find(':input:not(:disabled)'); - this.disabledFields.prop('disabled', true); - }, + disableForm: function () { + var form = this.$('form'); + this.disabledFields = form.find(':input:not(:disabled)'); + this.disabledFields.prop('disabled', true); + }, - enableForm: function () { - if (this.disabledFields != null) { - this.disabledFields.prop('disabled', false); - } + enableForm: function () { + if (this.disabledFields != null) { + this.disabledFields.prop('disabled', false); } - }); - + } }); + + |