{"version":3,"file":"Modal.js","sources":["misc/Modal.js"],"sourcesContent":["var Modal = (function($, undefined) {\n\n function Modal(id, options) {\n var self = this;\n self.id = '#' + id;\n if ($(self.id)[0] === undefined) {\n Modal.createForm(id);\n }\n self.options = $.extend({}, Modal.defaultOptions, options);\n self.title(self.options.title);\n if (self.options.url != null) {\n $(self.id).find(\"#loadingModalBody\").show();\n $.get(self.options.url)\n .done(function(html) {\n self.body(html);\n $(self.id).find(\"#loadingModalBody\").hide();\n });\n } else {\n self.body(self.options.body);\n }\n self.cancelText(self.options.cancelText);\n self.acceptText(self.options.acceptText);\n self.showCancelButton(self.options.showCancelButton);\n self.showAcceptButton(self.options.showAcceptButton);\n self.cancelCallback = self.options.cancelCallback;\n self.acceptCallback = self.options.acceptCallback;\n $(self.id).modal({ show: false });\n $(self.id).find('.modal-cancel').click(function () { self.cancelCallback(); });\n $(self.id).find('.modal-accept').click(function () { self.acceptCallback(); });\n if (self.options.isLarge)\n $(self.id).find('.modal-dialog').addClass('modal-lg');\n\n var acceptButtonHidden = $(self.id).find('.modal-acceptButton').css('display') == 'none';\n var cancelButtonHidden = $(self.id).find('.modal-cancelButton').css('display') == 'none';\n if (acceptButtonHidden && !cancelButtonHidden) {\n $('.modal-cancelButton').addClass('col-xs-12 col-sm-3 col-sm-offset-9');\n } else if (!acceptButtonHidden && cancelButtonHidden) {\n $('.modal-acceptButton').addClass('col-xs-12 col-sm-3 col-sm-offset-9');\n } else {\n $('.modal-acceptButton').addClass('col-xs-6 col-sm-3 col-sm-offset-6');\n $('.modal-cancelButton').addClass('col-xs-6 col-sm-3');\n }\n\n if (self.options.acceptButtonShouldNotCloseModal) {\n $('.modal-accept').removeAttr('data-dismiss');\n }\n }\n\n Modal.defaultOptions = {\n title: '',\n body: '',\n url: null,\n cancelText: 'No',\n acceptText: 'Yes',\n showCancelButton: true,\n showAcceptButton: true,\n acceptButtonShouldNotCloseModal: false,\n cancelCallback: function() {},\n acceptCallback: function () { },\n isLarge: false\n };\n\n Modal.prototype.show = function() {\n $(this.id).modal('show');\n };\n\n Modal.prototype.hide = function() {\n $(this.id).modal('hide');\n };\n\n Modal.prototype.option = function (property, value) {\n if (value !== undefined)\n this.set(property, value);\n return this.options[property];\n }\n\n Modal.prototype.set = function (property, value) {\n this.options[property] = value;\n var element = $(this.id).find('.modal-' + property)[0];\n if (element != undefined)\n $(element).html(value);\n if (property === 'showCancelButton') {\n var $cancelText = $(this.id).find('.modal-cancelButton').show();\n if (value) $cancelText.show();\n else $cancelText.hide();\n }\n if (property === 'showAcceptButton') {\n var $acceptText = $(this.id).find('.modal-acceptButton').show();\n if (value) $acceptText.show();\n else $acceptText.hide();\n }\n }\n\n Modal.prototype.title = function(value) { return this.option('title', value); }\n Modal.prototype.body = function (value) { return this.option('body', value); }\n Modal.prototype.cancelText = function(value) { return this.option('cancelText', value); }\n Modal.prototype.acceptText = function(value) { return this.option('acceptText', value); }\n Modal.prototype.showCancelButton = function (value) { this.option('showCancelButton', value); }\n Modal.prototype.showAcceptButton = function (value) { this.option('showAcceptButton', value); }\n\n Modal.createForm = function(id) {\n $('body').append(\n '