forked from blockchain/unused-My-Wallet
-
Notifications
You must be signed in to change notification settings - Fork 2
/
frame-modal.min.js
1 lines (1 loc) · 1.57 KB
/
frame-modal.min.js
1
$.fn.center=function(){this.css("top",Math.max(($(window).height()-this.height())/2+$(window).scrollTop(),10)+"px");this.css("left",Math.max(($(window).width()-this.width())/2+$(window).scrollLeft(),10)+"px");return this};$(window).resize(function(){$(".modal:visible").center()});function showFrameModal(a){var c=$("#frame-modal");var f="";if(a.top_right){f='<span style="float:right;padding-top:5px;padding-right:10px;">'+a.top_right+"</a></span>"}try{c.modal("hide");c.remove()}catch(d){console.log(d)}var b="iframe";if(APP_NAME=="javascript_chrome"){b="webview"}$("body").append('<div id="frame-modal" class="modal hide"><div class="modal-header"><button type="button" class="close" data-dismiss="modal">×</button>'+f+"<h3>"+a.title+'</h3></div><div class="modal-body" style="overflow-y:hidden;"><'+b+' border="0" scrolling="auto" style="overflow-y:hidden;border-style:none;"></'+b+'></div><div class="modal-footer btn-group">'+a.description+' <a class="btn btn-secondary">Close</a></div></div>');c=$("#frame-modal");c.modal({keyboard:true,backdrop:"static",show:true});var g=c.find(b);if(b=="webview"){g.get(0).addEventListener("newwindow",function(h){h.preventDefault();window.open(h.targetUrl)});g.get(0).addEventListener("permissionrequest",function(h){if(h.permission==="download"){h.request.allow()}})}try{hidePopovers()}catch(d){}if(a.width){c.find(".modal-body").css("width",a.width)}if(a.height){g.css("height",a.height)}c.find(".btn.btn-primary").unbind().click(function(){c.modal("hide")});c.find(".btn.btn-secondary").unbind().click(function(){c.modal("hide")});g.attr("src",a.src);c.center()};