{"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            '<div class=\"modal fade\" tabindex=\"-1\" id=\"' + id +'\">' +\n            '   <div class=\"modal-dialog\">' +\n            '       <div class=\"modal-content\">' +\n            '           <div class=\"modal-header\">' +\n            '               <button type=\"button\" class=\"close modal-cancel\" data-dismiss=\"modal\"><span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Close</span></button>' +\n            '               <h3 class=\"modal-title\"></h3>' +\n            '           </div>' +\n            '           <div class=\"modal-body\"><div id=\"loadingModalBody\" class=\"text-center\" style=\"display: none;\"><img alt=\"Loading...\" src=\"//assets.stullercloud.com/web/static/i/ajaxloaders/small-ajax-loader.gif\" /></div></div>' +\n            '           <div class=\"modal-footer\">' +\n            '               <div>' +\n            '                   <div class=\"modal-acceptButton\">' +\n            '                       <span class=\"StullerButton largeButton primary\">' +\n            '                           <button id=\"modal-primaryButton\" type=\"button\" class=\"modal-acceptText modal-accept fullWidth\" data-dismiss=\"modal\"></button>' +\n            '                       </span>' +\n            '                   </div>' +\n            '                   <div class=\"modal-cancelButton\">' +\n            '                       <span class=\"StullerButton largeButton secondary\">' +\n            '                           <button id=\"modal-secondaryButton\" type=\"button\" class=\"modal-cancelText modal-cancel fullWidth\" data-dismiss=\"modal\"></button>' +\n            '                       </span>' +\n            '                   </div>' +\n            '               </div>' +\n            '           </div>' +\n            '       </div>' +\n            '   </div>' +\n            '</div>'\n        );\n    }                                    \n    return Modal;\n}(jQuery));"],"names":["Modal","$","undefined","id","options","self","this","acceptButtonHidden","createForm","extend","defaultOptions","title","url","find","show","get","done","html","body","hide","cancelText","acceptText","showCancelButton","showAcceptButton","cancelCallback","acceptCallback","modal","click","isLarge","addClass","css","cancelButtonHidden","acceptButtonShouldNotCloseModal","removeAttr","prototype","option","property","value","set","element","$cancelText","$acceptText","append","jQuery"],"mappings":"AAAA,IAAIA,MAAS,SAASC,EAAGC,GAErB,SAASF,EAAMG,EAAIC,GACf,IAAIC,EAAOC,KA6BPC,GA5BJF,EAAKF,GAAK,IAAMA,EACZF,EAAEI,EAAKF,IAAI,KAAOD,GAClBF,EAAMQ,WAAWL,GAErBE,EAAKD,QAAUH,EAAEQ,OAAO,GAAIT,EAAMU,eAAgBN,GAClDC,EAAKM,MAAMN,EAAKD,QAAQO,OACA,MAApBN,EAAKD,QAAQQ,KACbX,EAAEI,EAAKF,IAAIU,KAAK,qBAAqBC,OACrCb,EAAEc,IAAIV,EAAKD,QAAQQ,KACdI,KAAK,SAASC,GACXZ,EAAKa,KAAKD,GACVhB,EAAEI,EAAKF,IAAIU,KAAK,qBAAqBM,UAG7Cd,EAAKa,KAAKb,EAAKD,QAAQc,MAE3Bb,EAAKe,WAAWf,EAAKD,QAAQgB,YAC7Bf,EAAKgB,WAAWh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