Skip to content

Commit

Permalink
New dialog implementation-continued. (openemr#1307)
Browse files Browse the repository at this point in the history
* New dialog implementation-continued.

* travis fix.

* addressed code review.

* travis

* another dialog update

* Disclosure save redo for browser compatibility.

* travis
  • Loading branch information
sjpadgett committed Dec 19, 2017
1 parent 9901294 commit 5b194f7
Show file tree
Hide file tree
Showing 37 changed files with 592 additions and 445 deletions.
11 changes: 6 additions & 5 deletions interface/main/calendar/add_edit_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ function setEventDate($start_date, $recurrence)
" if(window.opener.pattrk){" .
" window.opener.pattrk.submit()\n " . // This is for patient flow board page refresh}
" }};\n";
echo " window.close();\n";
echo " dlgclose();\n";
echo "</script>\n</body>\n</html>\n";
exit();
}
Expand Down Expand Up @@ -1111,7 +1111,7 @@ function setpatient(pid, lname, fname, dob) {
// This invokes the find-patient popup.
function sel_patient() {
let title = '<?php echo xlt('Patient Search'); ?>';
dlgopen('find_patient_popup.php', 'findPatient', 700, 200, '', title);
dlgopen('find_patient_popup.php', 'findPatient', 650, 300, '', title);
}

// This is for callback by the find-group popup.
Expand All @@ -1128,7 +1128,8 @@ function setgroup(gid, name, end_date) {
// This invokes the find-group popup.
function sel_group() {
top.restoreSession();
dlgopen('find_group_popup.php', '_blank', 500, 400);
let title = '<?php echo xlt('Group Search'); ?>';
dlgopen('find_group_popup.php', '_blank', 650, 300, '', title);
}

// Do whatever is needed when a new event category is selected.
Expand Down Expand Up @@ -1362,7 +1363,7 @@ function find_available(extra) {
top.restoreSession();
opener.document.location="../../new/new.php";
// Close the window
window.close();
dlgclose();
</script>';
}

Expand Down Expand Up @@ -1989,7 +1990,7 @@ function isRegularRepeat($repeat)
$("#form_duplicate").click(function(e) { validateform(e,"duplicate"); });
$("#find_available").click(function() { find_available(''); });
$("#form_delete").click(function() { deleteEvent(); });
$("#cancel").click(function() { window.close(); });
$("#cancel").click(function() { dlgclose(); });

// buttons affecting the modification of a repeating event
$("#all_events").click(function() { $("#recurr_affect").val("all"); EnableForm(); SubmitForm(); });
Expand Down
8 changes: 4 additions & 4 deletions interface/main/calendar/find_appt_popup.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ function doOneDay($catid, $udate, $starttime, $duration, $prefcatid)
echo "function mytimeout() {\n";
echo " opener.top.restoreSession();\n";
echo " opener.document.forms[0].submit();\n";
echo " window.close();\n";
echo " dlgclose();\n";
echo "}\n";
echo "</script></head><body onload='setTimeout(\"mytimeout()\",2500);'><h4></br>..." .
xlt('Time slot is available, saving event') . "...</h4></body></html>";
Expand All @@ -299,7 +299,7 @@ function setappt(year,mon,mday,hours,minutes) {
alert('<?php echo xls('The destination form was closed; I cannot act on your selection.'); ?>');
else
opener.setappt(year,mon,mday,hours,minutes);
window.close();
dlgclose();
return false;
}

Expand Down Expand Up @@ -471,7 +471,7 @@ function setappt(year,mon,mday,hours,minutes) {
if (confirm('<?php echo xls('On this date there is a holiday, use it anyway?'); ?>')) {
opener.top.restoreSession();
opener.document.forms[0].submit();
window.close();
dlgclose();
} <?php
} else {
//Someone is going to have to go over this with a fine-toothed comb because I couldn't really parse the original here
Expand All @@ -484,7 +484,7 @@ function setappt(year,mon,mday,hours,minutes) {
} ?>
opener.top.restoreSession();
opener.document.forms[0].submit();
window.close();
dlgclose();
}
<?php
}
Expand Down
2 changes: 1 addition & 1 deletion interface/main/calendar/find_group_popup.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ function selgid(gid, name, end_date) {
alert("<?php echo htmlspecialchars(xl('The destination form was closed; I cannot act on your selection.'), ENT_QUOTES); ?>");
else
opener.setgroup(gid, name, end_date);
window.close();
dlgclose();
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions interface/main/calendar/find_patient_popup.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function selpid(pid, lname, fname, dob) {
alert("<?php echo htmlspecialchars(xl('The destination form was closed; I cannot act on your selection.'), ENT_QUOTES); ?>");
else
opener.setpatient(pid, lname, fname, dob);
window.close();
dlgclose();
return false;
}

Expand Down Expand Up @@ -167,7 +167,7 @@ function selpid(pid, lname, fname, dob) {
title='<?php echo htmlspecialchars(xl('If name, any part of lastname or lastname,firstname'), ENT_QUOTES); ?>'>
&nbsp;
<input type='submit' id="submitbtn" value='<?php echo htmlspecialchars(xl('Search'), ENT_QUOTES); ?>'>
<!-- &nbsp; <input type='button' value='<?php //echo htmlspecialchars(xl('Close'), ENT_QUOTES); ?>' onclick='window.close()' /> -->
<!-- &nbsp; <input type='button' value='<?php //echo htmlspecialchars(xl('Close'), ENT_QUOTES); ?>' onclick='dlgclose()' /> -->
<div id="searchspinner"><img src="<?php echo $GLOBALS['webroot'] ?>/interface/pic/ajax-loader.gif"></div>
</form>
</div>
Expand Down
14 changes: 9 additions & 5 deletions interface/main/dated_reminders/dated_reminders_add.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
// ------------ 2) communicate with user
echo ' alert("'.addslashes(xl('Reminder Sent')).'");';
// ------------ 3) close this window
echo ' window.close();';
echo ' dlgclose();';
echo '</script></body></html>';
// --------- stop script from executing further
exit;
Expand Down Expand Up @@ -142,7 +142,10 @@
<html>
<head>
<title><?php echo xlt('Send a Reminder') ?></title>

<link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/bootstrap-3-3-4/dist/css/bootstrap.min.css">
<?php if ($_SESSION['language_direction'] == 'rtl') { ?>
<link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative'] ?>/bootstrap-rtl-3-3-4/dist/css/bootstrap-rtl.min.css">
<?php } ?>
<link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
<link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">

Expand All @@ -151,6 +154,7 @@
<script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js?v=<?php echo $v_js_includes; ?>"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
<script src="<?php echo $GLOBALS['assets_static_relative']; ?>/bootstrap-3-3-4/dist/js/bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
<script language="JavaScript">
$(document).ready(function (){
Expand Down Expand Up @@ -250,7 +254,7 @@
})

function sel_patient(){
window.open('../../main/calendar/find_patient_popup.php', '_newDRPat', '' + ",width=" + 500 + ",height=" + 400 + ",left=" + 25 + ",top=" + 25 + ",screenX=" + 25 + ",screenY=" + 25);
dlgopen('../../main/calendar/find_patient_popup.php', '_newDRPat', 650, 400, '', '');
}

function setpatient(pid, lname, fname, dob){
Expand Down Expand Up @@ -279,7 +283,7 @@ function selectAll(){
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>


<h1><?php echo xlt('Send a Reminder') ?></h1>
<h4><?php echo xlt('Send a Reminder') ?></h4>
<form id="addDR" style="margin:0 0 10px 0;" id="newMessage" method="post" onsubmit="return top.restoreSession()">
<div style="text-align:center; color:red" id="errorMessage"></div>

Expand Down Expand Up @@ -391,7 +395,7 @@ function selectAll(){
$remindersArray[$RA['messageID']]['dDate'] = $RA['dDate'];
}

echo '<h2>',xlt('Messages You have sent Today'),'</h2>';
echo '<h4>',xlt('Messages You have sent Today'),'</h4>';
echo '<table border="1" width="100%" cellpadding="5px" id="logTable">
<thead>
<tr>
Expand Down
23 changes: 8 additions & 15 deletions interface/main/finder/patient_select.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
}
</style>

<script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>

<?php if ($popup) { ?>
<script type="text/javascript" src="../../../library/topdialog.js"></script>
Expand Down Expand Up @@ -520,25 +520,18 @@ function submitList(offset) {
});

var SelectPatient = function (eObj) {
<?php

// The layout loads just the demographics frame here, which in turn
// will set the pid and load all the other frames.
$newPage = "../../patient_file/summary/demographics.php?set_pid=";
$target = "document";
?>
objID = eObj.id;
var parts = objID.split("~");
<?php if (!$popup) {
echo "top.restoreSession();\n";
} ?>
<?php if ($popup) {
echo "opener.";
}
<?php if (!$popup) { ?>
top.restoreSession();
document.location.href = "../../patient_file/summary/demographics.php?set_pid=" + parts[0];
<?php } else if ($popup) { ?>
dlgclose("srchDone", parts[0]);
<?php } ?>

echo $target; ?>.location.href = '<?php echo $newPage; ?>' + parts[0];
<?php if ($popup) {
echo "window.close();\n";
} ?>
return true;
}

Expand Down
15 changes: 10 additions & 5 deletions interface/main/left_nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,15 @@ function genFindBlock()
<html>
<head>
<title>Navigation</title>

<link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/bootstrap-3-3-4/dist/css/bootstrap.min.css">
<?php if ($_SESSION['language_direction'] == 'rtl') { ?>
<link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative'] ?>/bootstrap-rtl-3-3-4/dist/css/bootstrap-rtl.min.css">
<?php } ?>
<link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
<link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative'];?>/font-awesome-4-6-3/css/font-awesome.css" type="text/css">
<style type="text/css">
body {
font-size:8pt;
font-size:9pt;
font-weight:normal;
padding: 5px 3px 5px 3px;
}
Expand All @@ -416,7 +419,9 @@ function genFindBlock()
border-color: #000000;
background-color:transparent;
}

#navigation-slide, #navigation-slide * {
font-size:unset !important;
}
#navigation ul {
background-color:transparent;
}
Expand All @@ -434,9 +439,9 @@ function genFindBlock()
vertical-align:middle;
}
</style>

<link rel="stylesheet" href="../../library/js/jquery.treeview-1.4.1/jquery.treeview.css" />
<script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-7-2/index.js"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-9-1/index.js"></script>
<script src="<?php echo $GLOBALS['assets_static_relative']; ?>/bootstrap-3-3-4/dist/js/bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript" src="../../library/js/jquery.treeview-1.4.1/jquery.treeview.js" ></script>

<script type="text/javascript" src="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
Expand Down
10 changes: 4 additions & 6 deletions interface/main/messages/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@
require_once("$srcdir/log.inc");
require_once("$srcdir/options.inc.php");
require_once("$srcdir/gprelations.inc.php");

use OpenEMR\Core\Header;
?>
<!DOCTYPE html>
<html>
<head>

<?php html_header_show();?>
<link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
<script type="text/javascript" src="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
<script type="text/javascript" src="../../../library/textformat.js"></script>
<script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script>
<?php Header::setupHeader(['jquery-ui']); ?>
</head>

<body class="body_top">
Expand Down
71 changes: 57 additions & 14 deletions interface/main/tabs/js/include_opener.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,56 @@
* @author Jerry Padgett <[email protected]>
* @link http:https://www.open-emr.org
*/
// Reworked to be used in both frmes and tabs u.i.. sjp 12/01/17

// Reworked to be used in both frames and tabs u.i.. sjp 12/01/17
// Removed legacy dialog support. sjp 12/16/17
// All window.close() should be removed from scripts and replaced with dlgclose() where possible
// usually anywhere dlgopen() is used. Also, top.dlgclose and parent.dlgclose() is available.
//
if (!opener) {
opener = top.get_opener(window.name);
}

window.close =
function () {
function (call, args) {
var frameName = window.name;
var wframe = opener;
if (!top.tab_mode) {
for (; wframe.name !== 'RTop' && wframe.name !== 'RBot'; wframe = wframe.parent) {
if (wframe.parent === wframe) {
wframe = window;
}
}
for (let i = 0; wframe.document.body.localName !== 'body' && i < 4; wframe = wframe[i++]) {
if (i === 3) {
console.log("Opener: unable to find modal's frame");
return false;
}
}
dialogModal = wframe.$('div#' + frameName);
} else {
var dialogModal = top.$('div#' + frameName);
wframe = top;
}

var removeFrame = dialogModal.find("iframe[name='" + frameName + "']");
if (removeFrame.length > 0) {
removeFrame.remove();
}

if (dialogModal.length > 0) {
if(call){
wframe.setCallBack(call, args);
}
dialogModal.modal('hide');
}

};

var dlgclose =
function (call, args) {
var frameName = window.name;
var wframe = opener;
if (!top.tab_mode) {
let wframe = opener;
for (; wframe.name !== 'RTop' && wframe.name !== 'RBot'; wframe = wframe.parent) {
if (wframe.parent === wframe) {
wframe = window;
Expand All @@ -46,16 +85,20 @@ window.close =
}
dialogModal = wframe.$('div#' + frameName);
} else {
var dialogModal = top.$('div#' + frameName); // This is a dynamic div.
var dialogModal = top.$('div#' + frameName);
wframe = top;
}

var removeFrame = dialogModal.find("iframe[name='" + frameName + "']");
if (removeFrame.length > 0) {
removeFrame.remove();
}
var dialogDiv = top.$("#dialogDiv");
var body = top.$("body");
var removeFrame = body.find("iframe[name='" + frameName + "']");
removeFrame.remove();
if (body.children("div.dialogIframe").length === 0) {
dialogDiv.hide();
};
if (dialogModal.length > 0) { // Will let modal's hidden event clean up.

if (dialogModal.length > 0) {
if(call){
wframe.setCallBack(call, args);
}
dialogModal.modal('hide');
};
}

};
Loading

0 comments on commit 5b194f7

Please sign in to comment.