forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
expand_contract_js.php
58 lines (55 loc) · 2.45 KB
/
expand_contract_js.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/**
* expand contract jquery script
*
* @package OpenEMR
* @link http:https://www.open-emr.org
* @author Ranganath Pathak <[email protected]>
* @author Brady Miller <[email protected]>
* @copyright Copyright (c) 2018 Ranganath Pathak <[email protected]>
* @copyright Copyright (c) 2018 Brady Miller <[email protected]>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/
// ensure that $user_settings_php_path, $arr_files_php variables are set in the script calling this script
use OpenEMR\Common\Csrf\CsrfUtils;
?>
$(function() {
$('.expand_contract').click(function() {
var elementTitle = $(this).prop('title');
var contractTitle = <?php echo xlj('Click to Contract and set to henceforth open in Centered mode'); ?>;
var expandTitle = <?php echo xlj('Click to Expand and set to henceforth open in Expanded mode'); ?>;
var arrFiles = <?php echo json_encode($arr_files_php) ?>;
if (elementTitle == contractTitle) {
elementTitle = expandTitle;
$(this).toggleClass('fa-expand fa-compress');
$('.expandable').toggleClass('container container-fluid');
if ($(arrFiles).length) {
$.each(arrFiles, function (index, value) {
$.post( "<?php echo $GLOBALS['webroot'] ?>/library/ajax/user_settings.php",
{
target: arrFiles[index].trim(),
setting: 0,
csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
}
);
});
}
} else if (elementTitle == expandTitle) {
elementTitle = contractTitle;
$(this).toggleClass('fa-compress fa-expand');
$('.expandable').toggleClass('container-fluid container');
if ($(arrFiles).length) {
$.each(arrFiles, function (index, value) {
$.post( "<?php echo $GLOBALS['webroot'] ?>/library/ajax/user_settings.php",
{
target: arrFiles[index].trim(),
setting: 1,
csrf_token_form: <?php echo js_escape(CsrfUtils::collectCsrfToken()); ?>
}
);
});
}
}
$(this).prop('title', elementTitle);
});
});