Comparing version 1.2.2 to 1.2.3
$(function() { | ||
// Open / close modal state | ||
$(document).on("change", ".modal-state", function() { | ||
if ($(this).is(":checked")) { | ||
$("body").addClass("modal-open"); | ||
} else { | ||
$("body").removeClass("modal-open"); | ||
} | ||
}); | ||
var openModal = function($modal) { | ||
$modal.addClass('modal-open'); | ||
$modal.find('input.modal-state').prop('checked', true).trigger('change'); | ||
}; | ||
var closeModal = function($modal) { | ||
$modal.removeClass('modal-open'); | ||
$modal.find('input.modal-state').prop('checked', false).trigger('change'); | ||
}; | ||
// Close modal on close button and clicking outside of modal | ||
$(document).on("click", ".modal-fade-screen, .modal-close", function() { | ||
$(".modal-state:checked").prop("checked", false).change(); | ||
var $modal = $(this).closest('.modal'); | ||
closeModal($modal); | ||
}); | ||
@@ -23,3 +25,4 @@ | ||
e.preventDefault(); | ||
$('#'+$(this).data('rkd-modal-id')+' input.modal-state').prop('checked', true).trigger('change'); | ||
var $modal = $('#'+$(this).data('rkd-modal-id')); | ||
openModal($modal); | ||
}); | ||
@@ -47,3 +50,3 @@ | ||
// Open modal | ||
$modal.find('input.modal-state').prop('checked', true).change(); | ||
openModal($modal); | ||
@@ -50,0 +53,0 @@ // Take content inside of this element |
@@ -1,1 +0,1 @@ | ||
$(function(){$(document).on("change",".modal-state",function(){$(this).is(":checked")?$("body").addClass("modal-open"):$("body").removeClass("modal-open")}),$(document).on("click",".modal-fade-screen, .modal-close",function(){$(".modal-state:checked").prop("checked",!1).change()}),$(document).on("click",".modal-inner",function(a){a.stopPropagation()}),$(document).on("click",".rkd-modal",function(a){a.preventDefault(),$("#"+$(this).data("rkd-modal-id")+" input.modal-state").prop("checked",!0).trigger("change")}),$(document).on("click",".rkd-modal-ajax, .rkd-modal-this",function(a){a.preventDefault();var b,c=$(this).data("rkd-modal-id");c?b=$("#"+c):(b=createAjaxModal(),$(this).data("rkd-modal-id",b.attr("id")));var d=b.find(".loading");if(b.find("input.modal-state").prop("checked",!0).change(),$(this).hasClass("rkd-modal-this"))return b.find(".modal-content").html($(this).html()),void d.hide();if(!b.hasClass("content-loaded")){var e=$(this).data("rkd-modal-selector");d.show(),$.ajax($(this).attr("href")).done(function(a){e?a=$(a).find(e):$(a).find(".rkd-modal-content")&&(a=$(a).find(".rkd-modal-content")),b.find(".modal-content").html(a),b.addClass("content-loaded")}).fail(function(){b.find(".modal-content").html("Something went wrong. Please try again later.")}).always(function(){d.hide()})}})});var createAjaxModal=function(){var a="_"+Math.random().toString(36).substr(2,9),b='<div class="modal" id="'+a+'"><input class="modal-state" type="checkbox" /><div class="modal-fade-screen"><div class="modal-inner"><!-- Close button--><div class="modal-close"></div><!-- Loader --><div class="sk-three-bounce loading"><div class="sk-child sk-bounce1"></div><div class="sk-child sk-bounce2"></div><div class="sk-child sk-bounce3"></div></div><!-- Content will be loaded in here with AJAX --><div class="modal-content"></div></div></div></div>';return $("body").append(b),$("#"+a)}; | ||
$(function(){var a=function(a){a.addClass("modal-open"),a.find("input.modal-state").prop("checked",!0).trigger("change")},b=function(a){a.removeClass("modal-open"),a.find("input.modal-state").prop("checked",!1).trigger("change")};$(document).on("click",".modal-fade-screen, .modal-close",function(){var a=$(this).closest(".modal");b(a)}),$(document).on("click",".modal-inner",function(a){a.stopPropagation()}),$(document).on("click",".rkd-modal",function(b){b.preventDefault();var c=$("#"+$(this).data("rkd-modal-id"));a(c)}),$(document).on("click",".rkd-modal-ajax, .rkd-modal-this",function(b){b.preventDefault();var c,d=$(this).data("rkd-modal-id");d?c=$("#"+d):(c=createAjaxModal(),$(this).data("rkd-modal-id",c.attr("id")));var e=c.find(".loading");if(a(c),$(this).hasClass("rkd-modal-this"))return c.find(".modal-content").html($(this).html()),void e.hide();if(!c.hasClass("content-loaded")){var f=$(this).data("rkd-modal-selector");e.show(),$.ajax($(this).attr("href")).done(function(a){f?a=$(a).find(f):$(a).find(".rkd-modal-content")&&(a=$(a).find(".rkd-modal-content")),c.find(".modal-content").html(a),c.addClass("content-loaded")}).fail(function(){c.find(".modal-content").html("Something went wrong. Please try again later.")}).always(function(){e.hide()})}})});var createAjaxModal=function(){var a="_"+Math.random().toString(36).substr(2,9),b='<div class="modal" id="'+a+'"><input class="modal-state" type="checkbox" /><div class="modal-fade-screen"><div class="modal-inner"><!-- Close button--><div class="modal-close"></div><!-- Loader --><div class="sk-three-bounce loading"><div class="sk-child sk-bounce1"></div><div class="sk-child sk-bounce2"></div><div class="sk-child sk-bounce3"></div></div><!-- Content will be loaded in here with AJAX --><div class="modal-content"></div></div></div></div>';return $("body").append(b),$("#"+a)}; |
{ | ||
"name": "rkd-modal", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Plain content and AJAX supported modal.", | ||
@@ -5,0 +5,0 @@ "main": "Gruntfile.js", |
@@ -1,2 +0,2 @@ | ||
![npm](https://img.shields.io/npm/dt/rkd-modal.svg) | ||
[![npm](https://img.shields.io/npm/dt/rkd-modal.svg)](https://www.npmjs.com/package/rkd-modal) | ||
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) | ||
@@ -3,0 +3,0 @@ |
$(function() { | ||
// Open / close modal state | ||
$(document).on("change", ".modal-state", function() { | ||
if ($(this).is(":checked")) { | ||
$("body").addClass("modal-open"); | ||
} else { | ||
$("body").removeClass("modal-open"); | ||
} | ||
}); | ||
var openModal = function($modal) { | ||
$modal.addClass('modal-open'); | ||
$modal.find('input.modal-state').prop('checked', true).trigger('change'); | ||
}; | ||
var closeModal = function($modal) { | ||
$modal.removeClass('modal-open'); | ||
$modal.find('input.modal-state').prop('checked', false).trigger('change'); | ||
}; | ||
// Close modal on close button and clicking outside of modal | ||
$(document).on("click", ".modal-fade-screen, .modal-close", function() { | ||
$(".modal-state:checked").prop("checked", false).change(); | ||
var $modal = $(this).closest('.modal'); | ||
closeModal($modal); | ||
}); | ||
@@ -23,3 +25,4 @@ | ||
e.preventDefault(); | ||
$('#'+$(this).data('rkd-modal-id')+' input.modal-state').prop('checked', true).trigger('change'); | ||
var $modal = $('#'+$(this).data('rkd-modal-id')); | ||
openModal($modal); | ||
}); | ||
@@ -47,3 +50,3 @@ | ||
// Open modal | ||
$modal.find('input.modal-state').prop('checked', true).change(); | ||
openModal($modal); | ||
@@ -50,0 +53,0 @@ // Take content inside of this element |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
494
29704