Sha256: 5fbcdc2a9429dc5956e90ca6e4bf15bf36112aad9fd106c37ce9900502755511
Contents?: true
Size: 1.93 KB
Versions: 6
Compression:
Stored size: 1.93 KB
Contents
I"¯(function() { window.modal = { open: function(content) { var modal_html; this.close(); $("body").addClass("modal-open"); modal_html = $("<div class='modal'> <div class='modal-overlay'></div> <button class='modal-close'></button> <div class='modal-body'>" + content + "</div> </div>"); modal_html.find(".modal-overlay, .modal-close").click(function() { return modal.close(); }); $("body").append(modal_html); return $(document).trigger("page:load"); }, close: function() { $(".modal").remove(); return $("body").removeClass("modal-open"); }, openLink: function() { modal.open("Chargement..."); $.ajax({ url: this.href, dataType: "html", success: function(data, textStatus, xhr) { if (xhr.getResponseHeader("Location") === location.href || xhr.getResponseHeader("Location") === location.pathname) { location.reload(); return; } return modal.open(data); }, error: function() { return modal.open("Erreur"); } }); return false; }, openForm: function() { $.ajax({ url: this.action, dataType: "html", type: this.method.toUpperCase(), data: $(this).serialize(), success: function(data) { return modal.open(data); }, error: function() { return modal.open("Erreur"); } }); return false; }, setup: function(scope) { scope = $(scope || document); scope.find("a[data-modal=1], .modal-body a:not([data-modal=0])").off("click", modal.openLink).on("click", modal.openLink); return scope.find("form[data-modal=1], .modal-body form:not([data-modal=0])").off("submit", modal.openForm).on("submit", modal.openForm); } }; $(document).on("ready page:load", function() { return modal.setup(); }); }).call(this); :ET
Version data entries
6 entries across 6 versions & 1 rubygems