/** * A utility object for quickly and conveniently generating dialog boxes. * Unfortunately, this doesn't dynamically create new boxes; it reuses the same one * over and over again. It turns out dynamically generating new dialog boxes * is a pain! So we can't stack them. * * @constructor * @this {BlockPyDialog} * @param {Object} main - The main BlockPy instance * @param {HTMLElement} tag - The HTML object this is attached to. */ function BlockPyDialog(main, tag) { this.main = main; this.tag = tag; this.titleTag = tag.find('.modal-title'); this.bodyTag = tag.find('.modal-body'); } /** * A simple externally available function for popping up a dialog * message. This menu will be draggable by its title. * * @param {String} title - The title of the message dialog. Can have HTML. * @param {String} body - The body of the message dialog. Can have HTML. * @param {function} onclose - A function to be run when the user closes the dialog. */ BlockPyDialog.prototype.show = function(title, body, onclose) { this.titleTag.html(title); this.bodyTag.html(body); this.tag.modal('open'); // this.tag.draggable({ // 'handle': '.modal-title' // }); this.tag.on('hidden.bs.modal', function (e) { if (onclose !== undefined) { onclose(); } }); }