2 * custom templates dynamic api
5 * @link http://www.open-emr.org
6 * @author Jerry Padgett <sjpadgett@gmail.com>
7 * @copyright Copyright (c) 2019-2021 Jerry Padgett <sjpadgett@gmail.com>
8 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
11 function doTemplateEditor(_this, event, oContext = '') {
12 // has to be one of two.
13 let id = event.target.id;
16 id = event.target.name;
19 let title = '<i class="fa fa-th"></i><h4 class="ml-2">'+ xl("Text Templates") +'</h4>';
20 let url = top.webroot_url + "/library/custom_template/custom_template.php?type=" + encodeURIComponent(id) + "&ccFlag=" + encodeURIComponent(ccFlag) + "&contextName=" + encodeURIComponent(oContext);
21 dlgopen(url, '', 'modal-lg', 800, '', '', {
23 {text: xl('Do Nothing'), close: true, style: 'secondary'}
30 const bindTextArea = function () {
31 const teventElement = document.querySelectorAll("textarea, input[type='text']");
32 if (typeof teventElement === 'undefined' || teventElement === null) {
35 teventElement.forEach(item => {
36 item.addEventListener('dblclick', event => {
37 if (event.target.nodeName === "TEXTAREA") {
38 doTemplateEditor(this, event, event.target.dataset.textcontext);
39 } else if (event.target.nodeName === "INPUT" && event.target.type === "text") {
40 doTemplateEditor(this, event, 'Sentence');
47 console.log("Bound text events: ['" + location + "']");