// modal (function($){ $.fn.modal = function(options){ var defaults = { show:false, overlayDrop:true } var options = $.extend(defaults, options); var $btnOpen = $('[data-toggle="modal"]'); var modal = this; if(options.overlayDrop == true){ if ($('body').find('.modal-backdrop').length == 0) { $('body').prepend(''); } var overlay = $('.modal-backdrop'); } function modalShow(){ $('body').addClass('modal-open'); modal.show(); overlay.show(); } if(options.show == true){ modalShow(); } } })(jQuery); $(function(){ // modal $('[data-toggle="modal"]').click(function(){ var target = $(this).attr('data-target'); if ($('body').find('.modal-backdrop').length == 0) { $('body').prepend(''); } $('body').addClass('modal-open'); $('.modal-backdrop').show(); $(target).show(); return false; }); $('[data-toggle="modal-iframe"]').click(function(){ var target = $(this).attr('data-target'); if ($('body').find('.modal-backdrop').length == 0) { $('body').prepend(''); } $('body').addClass('modal-open'); $('.modal-backdrop').show(); $('.modal-iframe').show(); $('.modal-iframe iframe').attr('src',target); return false; }); $('[data-dismiss="modal"]').click(function(){ $('body').removeClass('modal-open'); $('.modal-backdrop').hide(); $('.modal').hide(); return false; }); $('.modal').click(function(){ if ($(this).attr('aria-hidden') !='false') { $('body').removeClass('modal-open'); $('.modal-backdrop').hide(); $('.modal').hide(); } return false; }); $('.modal-content').click(function(event){ event.stopPropagation(); }); });