Skip to content

Commit c1a88ba

Browse files
authored
overlay click close add
1 parent bfa8191 commit c1a88ba

1 file changed

Lines changed: 48 additions & 11 deletions

File tree

js/lightWeightPopup.js

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
function closeDilog(action){
88
if(action=="inline"){
99
var inlineData = $('#lwpBody').html();
10-
setTimeout(function(){ $('body').find('.lwp-inline').html(inlineData);},100);
10+
setTimeout(function(){ $('body').find('.lwp-inline').html(inlineData); $('body').removeClass('lwp-hidden');},100);
1111
}
1212
$('.lwp').remove();
13+
$('.lwp-overlay').remove();
1314
}
1415

1516
(function($){
@@ -19,29 +20,59 @@ function closeDilog(action){
1920
$(this).on("click",function(){
2021

2122
$("body").find('.lwp').remove();
22-
w = h = u = mw = mh = t = '';
23+
w = h = u = mw = mh = t = ol = mf = '';
2324

2425
var dset = $(this).data();
2526

27+
console.log(dset);
28+
2629
if(dset.width!="" && typeof dset.width !== "undefined"){ w = dset.width;}
2730
if(dset.height!="" && typeof dset.height !== "undefined"){ h = dset.height;}
2831
if(dset.href!="" && typeof dset.href !== "undefined"){u = dset.href;}
2932
if(dset.maxWidth!="" && typeof dset.maxWidth !== "undefined"){mw = dset.maxWidth;}
3033
if(dset.maxHeight!="" && typeof dset.maxHeight !== "undefined"){mh = dset.maxHeight;}
3134
if(dset.title!="" && typeof dset.title !== "undefined"){t = dset.title;}else{t = 'Model';}
32-
35+
if(dset.overlay==true && typeof dset.overlay !== "undefined"){ol = true;}else{ol = false;}
36+
if(dset.modelFixed==true && typeof dset.modelFixed!== "undefined"){mf = 'fixed';}
37+
38+
var wh = parseInt(window.innerHeight)-parseInt(160);
39+
3340
var settings = $.extend({
3441
href : u, //Ajax url
3542
width : w, //Container width
3643
height : h, //Container height
3744
maxWidth : mw, //Container title
3845
maxHeight : mh, //Container close text/icon
3946
title : t, //Model Title
47+
overlay : ol, //Model close when click on overlay
48+
modelFixed : mf,
4049
},options);
41-
42-
$("body").append('<div class="lwp"><div id="lwp" tabindex="-1" role="dialog" style="width:'+settings.width+'; height:'+settings.height+'; max-width:'+settings.maxWidth+'; max-height:'+settings.maxHeight+'"><div id="lwpHead"><div class="title">'+settings.title+'</div><div class="close" onclick="closeDilog(\''+dset.content+'\')"><span>&times;</span></div></div><div id="lwpBody" role="document"><div class="loading"><img src="image/loader.gif"><p class="text">Please Wait..!</p></div></div></div></div>');
4350

44-
$('body').addClass('lwp-hidden');
51+
var sw = sh = smw = smh = setOL = setMF = '';
52+
53+
if(settings.width!=""){
54+
var sw = 'width:'+settings.width+';';
55+
}
56+
if(settings.height!=""){
57+
var sh = 'height:'+settings.height+';';
58+
}
59+
if(settings.maxWidth!=""){
60+
var smw = 'max-width:'+settings.maxWidth+';';
61+
}
62+
if(settings.maxHeight!=""){
63+
var smh = 'max-height:'+settings.maxHeight+';';
64+
}
65+
if(settings.overlay==true){
66+
var setOL = 'onclick="closeDilog(\''+dset.content+'\')"';
67+
}
68+
if(settings.modelFixed=='fixed'){
69+
var setMF = 'style="height:'+wh+'px"';
70+
}
71+
72+
$("body").append('<div class="lwp-overlay" '+setOL+'></div><div class="lwp" tabindex="-1" role="dialog"><div id="lwp" style="'+sw+' '+sh+' '+smw+' '+smh+'"><div id="lwpHead"><div class="title">'+settings.title+'</div><div class="close" onclick="closeDilog(\''+dset.content+'\')"><span>&times;</span></div></div><div id="lwpBody" role="document" '+setMF+'><div class="loading"><img src="image/loader.gif"><p class="text">Please Wait..!</p></div></div></div></div>');
73+
if(settings.modelFixed){
74+
$('body').addClass('lwp-hidden');
75+
}
4576
if(dset.content=='ajax'){
4677
$.ajax({
4778
method : "POST",
@@ -55,8 +86,13 @@ function closeDilog(action){
5586
}
5687

5788
if(dset.content=='iframe'){
58-
nH = $('#lwpBody').height()-50;
59-
setTimeout(function(){ $('#lwpBody').html('<iframe frameborder="0" style="height:'+nH+'px;" allowfullscreen class="lwpIframe" src="'+settings.href+'"></iframe>');},1000);
89+
var lwpHead = parseInt($('#lwpHead').innerHeight());
90+
var lwp = parseInt($('#lwp').innerHeight());
91+
console.log(lwpHead, lwp);
92+
var bh = parseInt(lwp)-parseInt(lwpHead*1);
93+
console.log(bh);
94+
95+
setTimeout(function(){ $('#lwpBody').html('<iframe frameborder="0" style="height:'+bh+'px; width:100%;" src="'+settings.href+'"></iframe>');},1000);
6096
}
6197

6298
if(dset.content=='inline'){
@@ -65,9 +101,10 @@ function closeDilog(action){
65101
setTimeout(function(){$('#lwpBody').html(data);},1000);
66102
}
67103
$('body').find('.lwp-inline').html('');
68-
}
69-
104+
}
70105
});
71106

107+
108+
72109
};
73-
}(jQuery));
110+
}(jQuery));

0 commit comments

Comments
 (0)