Created
December 12, 2017 00:41
-
-
Save sidneydemoraes/9d335708fc0055bd1e7c287ad8727b4c to your computer and use it in GitHub Desktop.
Script para modal genérica.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([], function () { | |
return { | |
abrir: function (conteudo, callback) { | |
var self = this; | |
self.fechar(); | |
var modal = self.modalGenerica.replace('#CONTEUDO#', conteudo); | |
$("body").append(modal); | |
$("body").scrollTop(0); | |
$(document).off("click", "#modal-default .backdrop-modal, #modal-default .fechar-modal") | |
.on("click", "#modal-default .backdrop-modal, #modal-default .fechar-modal", function (e) { | |
e.preventDefault(); | |
self.fechar(); | |
if (callback && typeof callback === "function") | |
callback(); | |
}); | |
}, | |
abrirErro: function (conteudo, callback) { | |
this.fechar(); | |
this.abrir("<span class='erro'></span>" + conteudo, callback); | |
}, | |
abrirLoading: function () { | |
this.fechar(); | |
$(document).off("click", "#modal-default .backdrop-modal, #modal-default .fechar-modal"); | |
$('body').append(this.modalLoading); | |
$('body').scrollTop(0); | |
}, | |
fechar: function () { | |
if ($("#modal-default")) { | |
$("#modal-default").remove(); | |
} | |
}, | |
modalGenerica: "<div id='modal-default' class='modal-mensagens'>" + | |
"<div class='backdrop-modal'></div>" + | |
"<div class='content-modal'>" + | |
"<span class='fechar-modal'>fechar</span>" + | |
"#CONTEUDO#" + | |
"</div>" + | |
"</div>", | |
modalLoading: "<div id='modal-default' class='modal-mensagens modal-loading'>" + | |
"<div class='backdrop-modal'></div>" + | |
"<div class='content-modal'>" + | |
"<h3>Por favor, aguarde...</h3>" + | |
"<span class='loading'></span>" + | |
"</div>" + | |
"</div>" | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment