(function (b) { var a = (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7 && parseInt(jQuery.browser.version, 10) > 4); if (b.proxy === undefined) { b.extend({ proxy: function (d, c) { if (d) { proxy = function () { return d.apply(c || this, arguments) } } return proxy } }) } b.extend(jQuery.easing, { easeOutBack: function (f, g, e, k, j, h) { if (h == undefined) { h = 1.70158 } return k * ((g = g / j - 1) * g * ((h + 1) * g + h) + 1) + e } }); b.extend(b.expr[":"], { value: function (c) { return b(c).val() } }); b.extend({ MsgBoxObject: { defaults: { name: "jquery-msgbox", zIndex: 10000, width: 420, height: "auto", background: "#FFFFFF", modal: true, overlay: { "background-color": "#000000", opacity: 0.5 }, showDuration: 200, closeDuration: 100, moveDuration: 500, shake: { distance: 10, duration: 100, transition: "easeOutBack", loops: 2 }, form: { active: false, action: "#", method: "post" }, emergefrom: "top" }, options: {}, esqueleto: { msgbox: [], wrapper: [], form: [], buttons: [], inputs: [] }, visible: false, i: 0, animation: false, config: function (c) { this.options = b.extend(true, this.options, c); this.overlay.element.css(this.options.overlay); this.overlay.options.hideOnClick = !this.options.modal; this.esqueleto.msgbox.css({ width: this.options.width, height: this.options.height, "background-color": this.options.background }); this.moveBox() }, overlay: { create: function (c) { this.options = c; this.element = b('<div id="' + new Date().getTime() + '"></div>'); this.element.css(b.extend({}, { position: "fixed", top: 0, left: 0, opacity: 0, display: "none", "z-index": this.options.zIndex }, this.options.style)); this.element.click(b.proxy(function (d) { if (this.options.hideOnClick) { if (!this.options.callback === undefined) { this.options.callback() } else { this.hide() } } d.preventDefault() }, this)); this.hidden = true; this.inject(); return this }, inject: function () { this.target = b(document.body); this.target.append(this.element); if (a) { this.element.css({ position: "absolute" }); var d = parseInt(this.element.css("zIndex")); if (!d) { d = 1; var c = this.element.css("position"); if (c == "static" || !c) { this.element.css({ position: "relative" }) } this.element.css({ zIndex: d }) } d = (!!(this.options.zIndex || this.options.zIndex === 0) && d > this.options.zIndex) ? this.options.zIndex : d - 1; if (d < 0) { d = 1 } this.shim = b('<iframe id="IF_' + new Date().getTime() + '" scrolling="no" frameborder=0 src=""></div>'); this.shim.css({ zIndex: d, position: "absolute", top: 0, left: 0, border: "none", width: 0, height: 0, opacity: 0 }); this.shim.insertAfter(this.element); b("html, body").css({ height: "100%", width: "100%", "margin-left": 0, "margin-right": 0 }) } }, resize: function (c, e) { this.element.css({ height: 0, width: 0 }); if (this.shim) { this.shim.css({ height: 0, width: 0 }) } var d = { x: b(document).width(), y: b(document).height() }; this.element.css({ width: "100%", height: e ? e : d.y }); if (this.shim) { this.shim.css({ height: 0, width: 0 }); this.shim.css({ position: "absolute", left: 0, top: 0, width: this.element.width(), height: e ? e : d.y }) } return this }, show: function () { if (!this.hidden) { return this } if (this.transition) { this.transition.stop() } this.target.bind("resize", b.proxy(this.resize, this)); this.resize(); if (this.shim) { this.shim.css({ display: "block" }) } this.hidden = false; this.transition = this.element.fadeIn(this.options.showDuration, b.proxy(function () { this.element.trigger("show") }, this)); return this }, hide: function () { if (this.hidden) { return this } if (this.transition) { this.transition.stop() } this.target.unbind("resize"); if (this.shim) { this.shim.css({ display: "none" }) } this.hidden = true; this.transition = this.element.fadeOut(this.options.closeDuration, b.proxy(function () { this.element.trigger("hide"); this.element.css({ height: 0, width: 0 }) }, this)); return this } }, create: function () { this.options = b.extend(true, this.defaults, this.options); this.overlay.create({ style: this.options.overlay, hideOnClick: !this.options.modal, zIndex: this.options.zIndex - 1, showDuration: this.options.showDuration, closeDuration: this.options.closeDuration }); this.esqueleto.msgbox = b('<div class="' + this.options.name + '"></div>'); this.esqueleto.msgbox.css({ display: "none", position: "absolute", top: 0, left: 0, width: this.options.width, height: this.options.height, "z-index": this.options.zIndex, "word-wrap": "break-word", "-moz-box-shadow": "0 0 15px rgba(0, 0, 0, 0.5)", "-webkit-box-shadow": "0 0 15px rgba(0, 0, 0, 0.5)", "box-shadow": "0 0 15px rgba(0, 0, 0, 0.5)", "-moz-border-radius": "6px", "-webkit-border-radius": "6px", "border-radius": "6px", "background-color": this.options.background }); this.esqueleto.wrapper = b('<div class="' + this.options.name + '-wrapper"></div>'); this.esqueleto.msgbox.append(this.esqueleto.wrapper); this.esqueleto.form = b('<form action="' + this.options.formaction + '" method="post"></form>'); this.esqueleto.wrapper.append(this.esqueleto.form); this.esqueleto.wrapper.css({ height: (a ? 80 : "auto"), "min-height": 80, zoom: 1 }); b("body").append(this.esqueleto.msgbox); this.addevents(); return this.esqueleto.msgbox }, addevents: function () { b(window).bind("resize", b.proxy(function () { if (this.visible) { this.overlay.resize(); this.moveBox() } }, this)); b(window).bind("scroll", b.proxy(function () { if (this.visible) { this.moveBox() } }, this)); this.esqueleto.msgbox.bind("keydown", b.proxy(function (c) { if (c.keyCode == 27) { this.close(false) } }, this)); this.esqueleto.form.bind("submit", b.proxy(function (c) { b("input[type=submit]:first, button[type=submit]:first, button:first", this.esqueleto.form).trigger("click"); if (!options.form.active) { c.preventDefault() } }, this)); this.overlay.element.bind("show", b.proxy(function () { b(this).triggerHandler("show") }, this)); this.overlay.element.bind("hide", b.proxy(function () { b(this).triggerHandler("close") }, this)) }, show: function (c, d, f) { var e = ["alert", "info", "error", "prompt", "confirm"]; this.esqueleto.msgbox.queue(this.options.name, b.proxy(function (h) { d = b.extend(true, { type: "alert", form: { active: false} }, d || {}); if (d.buttons === undefined) { if (d.type == "confirm" || d.type == "prompt") { var j = [{ type: "submit", value: "Enviar" }, { type: "cancel", value: "Cancelar"}] } else { var j = [{ type: "submit", value: "Enviar"}] } } else { var j = d.buttons } if (d.inputs === undefined && d.type == "prompt") { var g = [{ type: "text", name: "prompt", value: ""}] } else { var g = d.inputs } this.callback = b.isFunction(f) ? f : function (k) { }; if (g !== undefined) { this.esqueleto.inputs = b('<div class="' + this.options.name + '-inputs"></div>'); this.esqueleto.form.append(this.esqueleto.inputs); b.each(g, b.proxy(function (l, k) { if (k.type == "text" || k.type == "password") { iLabel = k.label ? '<label class="' + this.options.name + '-label">' + k.label : ""; fLabel = k.label ? "</label>" : ""; k.value = k.value === undefined ? "" : k.value; iRequired = k.required === undefined || k.required == false ? "" : 'required="true"'; iName = k.name === undefined ? this.options.name + "-label-" + l : k.name; this.esqueleto.inputs.append(b(iLabel + '<input type="' + k.type + '" name="' + iName + '" value="' + k.value + '" autocomplete="off" ' + iRequired + "/>" + fLabel)) } else { if (k.type == "checkbox") { iLabel = k.label ? '<label class="' + this.options.name + '-label">' : ""; fLabel = k.label ? k.label + "</label>" : ""; k.value = k.value === undefined ? "1" : k.value; iName = k.name === undefined ? this.options.name + "-label-" + l : k.name; this.esqueleto.inputs.append(b(iLabel + '<input type="' + k.type + '" style="display:inline; width:auto;" name="' + iName + '" value="' + k.value + '" autocomplete="off"/> ' + fLabel)) } else { if (k.type == "file") { iLabel = k.label ? '<label class="' + this.options.name + '-label">' : ""; fLabel = k.label ? k.label + "</label>" : ""; k.value = k.value === undefined ? "1" : k.value; iName = k.name === undefined ? this.options.name + "-label-" + l : k.name; this.esqueleto.inputs.append(b('<a href="#" id="upbtn">up</a>"')) } } } }, this)) } this.esqueleto.buttons = b('<div class="' + this.options.name + '-buttons"></div>'); this.esqueleto.form.append(this.esqueleto.buttons); if (d.form.active) { this.esqueleto.form.attr("action", d.form.action === undefined ? "#" : d.form.action); this.esqueleto.form.attr("method", d.form.method === undefined ? "post" : d.form.method); this.options.form.active = true } else { this.esqueleto.form.attr("action", "#"); this.esqueleto.form.attr("method", "post"); this.options.form.active = false } if (d.type == "alert" || d.type == "info" || d.type == "error" || d.type == "confirm") { b.each(j, b.proxy(function (l, k) { if (k.type == "submit") { this.esqueleto.buttons.append(b('<a href="javascript:;" class="option link-ok">' + k.value + "</a>").bind("click", b.proxy(function (m) { this.close(k.value); m.preventDefault() }, this))) } else { if (k.type == "cancel") { this.esqueleto.buttons.append(b('<a href="javascript:;" class="option link-cancelar">' + k.value + "</a>").bind("click", b.proxy(function (m) { this.close(false); m.preventDefault() }, this))) } } }, this)) } else { if (d.type == "prompt") { b.each(j, b.proxy(function (l, k) { if (k.type == "submit") { this.esqueleto.buttons.append(b('<a href="javascript:;" class="option link-ok">' + k.value + "</a>").bind("click", b.proxy(function (m) { if (b('input[required="true"]:not(:value)').length > 0) { b('input[required="true"]:not(:value):first').focus(); this.shake() } else { if (this.options.form.active) { return true } else { this.close(this.toArguments(b("input", this.esqueleto.inputs))) } } m.preventDefault() }, this))) } else { if (k.type == "cancel") { this.esqueleto.buttons.append(b('<a href="javascript:;" class="option link-cancelar">' + k.value + "</a>").bind("click", b.proxy(function (m) { this.close(false); m.preventDefault() }, this))) } } }, this)) } } this.esqueleto.form.prepend(c); b.each(e, b.proxy(function (k, l) { this.esqueleto.wrapper.removeClass(this.options.name + "-" + l) }, this)); this.esqueleto.wrapper.addClass(this.options.name + "-" + d.type); this.moveBox(); this.visible = true; this.overlay.show(); this.esqueleto.msgbox.css({ display: "block", left: ((b(document).width() - this.options.width) / 2) }); this.moveBox(); setTimeout(b.proxy(function () { var k = b("input, button", this.esqueleto.msgbox); if (k.length) { k.get(0).focus() } }, this), this.options.moveDuration) }, this)); this.i++; if (this.i == 1) { this.esqueleto.msgbox.dequeue(this.options.name) } }, toArguments: function (c) { return b.map(c, function (d) { return b(d).val() }) }, moveBox: function () { var f = { x: b(window).width(), y: b(window).height() }; var e = { x: b(window).scrollLeft(), y: b(window).scrollTop() }; var d = this.esqueleto.msgbox.outerHeight(); var g = 0; var c = 0; g = e.x + ((f.x - this.options.width) / 2); if (this.options.emergefrom == "bottom") { c = (e.y + f.y + 80) } else { c = (e.y - d) - 80 } if (this.visible) { if (this.animation) { this.animation.stop } this.animation = this.esqueleto.msgbox.animate({ left: g, top: e.y + ((f.y - d) / 2) }, { duration: this.options.moveDuration, queue: false, easing: "easeOutBack" }) } else { this.esqueleto.msgbox.css({ top: c, left: g }) } }, close: function (c) { this.esqueleto.msgbox.css({ display: "none", top: 0 }); this.visible = false; if (b.isFunction(this.callback)) { this.callback.apply(this, b.makeArray(c)) } setTimeout(b.proxy(function () { this.i--; this.esqueleto.msgbox.dequeue(this.options.name) }, this), this.options.closeDuration); if (this.i == 1) { this.overlay.hide() } this.moveBox(); this.esqueleto.form.empty() }, shake: function () { var c = this.options.shake.distance; var k = this.options.shake.duration; var g = this.options.shake.transition; var j = this.options.shake.loops; var f = this.esqueleto.msgbox.position().left; var h = this.esqueleto.msgbox; for (i = 0; i < j; i++) { h.animate({ left: f + c }, k, g); h.animate({ left: f - c }, k, g) } h.animate({ left: f + c }, k, g); h.animate({ left: f }, k, g) } }, msgbox: function (c, d, e) { if (typeof c == "object") { b.MsgBoxObject.config(c) } else { return b.MsgBoxObject.show(c, d, e) } } }); b(function () { b.MsgBoxObject.create() }) })(jQuery);

