<?php if (!defined('PmWiki')) exit(); /* popupiframe.php: for creating popup modal panel inside of an iframe. Copyright 2016 Christopher Jay Cox This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Simple syntax: (:popiframe:) %popframe%[[Group/PageName]] %popiframe name=uniquetarget%[[Group/PageName| Title]] Without name=uniquetarget, the href will target '#' for all links. Thus the browser will show all popiframe links as visited. You can assign unique arbitrary names to each popiframe to make it more realistic. When using this recipe in display interior wiki pages, install the included null skin and use something like: %popiframe name=uniquetarget%[[Group/PageName?skin=null| Title]] */ $RecipeInfo['PopupIFrame']['Version'] = '2018-03-22'; Markup('popiframe','directives', '/\\(:popiframe:\\)/', Keep("<div id='iModal' class='imodal'> <div class='imodal-content'> <span id='myCloseModal' class='imodal-close'>×</span> <iframe id='iModalIFrame' scrolling='auto' frameBorder='0' width=100% height=100%></iframe> </div> </div> <script> var imodal = document.getElementById('iModal'); var imodalclose = document.getElementById('myCloseModal'); function popupIModal(iurl) { document.getElementById('iModalIFrame').src = iurl; imodal.style.display = 'block'; } imodalclose.onclick = function() { imodal.style.display = 'none'; } window.onclick = function(event) { if (event.target == imodal) { imodal.style.display = 'none'; } } </script>") ); Markup('popiframe1','<links','/%popiframe\\s*(.*?)%\\[\\[(.*?)\\]\\]/', "PopupIFrame"); Markup('popiframe2','<popiframe1', "/%popiframe\\s*(.*?)%(?>\\[\\[([^|\\]]*)\\|\\s*)(.*?)\\s*\\]\\]($SuffixPattern)/", "PopupIFrame"); function PopupIFrame ($m) { global $LinkPopupIFrameFmt; // added below extract($GLOBALS["MarkupToHTML"]); @list($m0, $opts, $tgt, $lbl, $sfx) = $m; // end add $defaults = array( 'name' => '', ); $opt = array_merge($defaults, ParseArgs($opts)); $LinkPopupIFrameFmt = "<a href='#".$opt['name']."' onclick=\"popupIModal('\$LinkUrl');\">\$LinkText</a>"; return Keep(MakeLink($pagename,$tgt,$lbl,$sfx,$GLOBALS['LinkPopupIFrameFmt']),'L'); }