Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
112 lines (105 loc) · 4.5 KB
/
Copy pathindex.html
File metadata and controls
112 lines (105 loc) · 4.5 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Multi-select Dropdown List with Checkbox by CodexWorld</title>
<script src="jquery-1.7.1.js"></script>
<script src="AutoCompleteUI.js"></script>
<link href="AutoComplete.css" rel="stylesheet" />
<style>
body {
font-family: 'Open Sans' Arial, Helvetica, sans-serif;
}
ul, li {
margin: 0;
padding: 0;
list-style: none;
}
.label {
color: #000;
font-size: 16px;
}
</style>
</head>
<body>
<textarea class="search-element"></textarea>
<script type="text/javascript">
var data = ["Reduce pain to below BASELINE level within 48 hours of admission for comfort. Patient/pcg is knowledgeable about pain, other symptoms regimen, relief measures and care for optimal relief/control.",
"Reduce pain level to below 3 or stated comfort level of pain by patient after nursing interventions/medications",
"Family/PCG will verbalize understanding of non-verbal signs of pain.", "Keep pain below BASELINE level", "Pain will remain in comfortable level during care.",
"Pain level will be assessed effectively by family/pcg and staff.", "Pt/family understands levels of pain and breakthrough pain.",
"Pt/pcg will verbalize pain level for proper adn appropriate medication doses"];
$(function () {
var selectedItems = [];
var $this;
var options = {
minLength: 0,
source: function (request, response) {
// delegate back to autocomplete, but extract the last term
//response($.ui.autocomplete.filter(data, extractLast(request.term)));
response($.map(data, function (item) {
return {
label: item
}
}));
},
focus: function () {
// prevent value inserted on focus
//$($this).autocomplete("search");
return false;
},
select: function (event, ui) {
debugger
var text = $this.val();
//ui.item.value = ui.item.value.replace(/\+/g, ' ');
text = text == null || text == undefined ? "" : text;
var checked = (text.indexOf(ui.item.value + ',') > -1 ? 'checked' : '');
if (checked == 'checked') {
this.value = this.value.replace(ui.item.value + ',\n', '')
}
else {
var terms = split(this.value);
console.log(terms)
// remove the current input
terms.pop();
// add the selected item
terms.push(ui.item.value);
// add placeholder to get the comma-and-space at the end
terms.push("");
this.value = terms.join(",\n");
}
return false;
},
open: function () {
$("ul.ui-menu").width($(this).innerWidth());
}
}
$('textarea[class*="search-element"]').live('keydown', function () {
bindAutoComplete($this, options);
}).live('focus', function () {
$this = $(this);
var text = $this.val();
bindAutoComplete($this, options);
$($this).autocomplete("search");
})
})
function bindAutoComplete(ele, options) {
var text = ele.val();
text = text == null || text == undefined ? "" : text;
$(ele).autocomplete(options).data("autocomplete")._renderItem = function (ul, item) {
var checked = (text.indexOf(item.label + ',') > -1 ? 'checked' : '');
return $("<li></li>")
.data("item.autocomplete", item)
.append('<a href="javascript:;"><input type="checkbox"' + checked + '/>' + item.label + '</a>')
.appendTo(ul);
};
}
function split(val) {
return val.split(/,\n\s*/);
}
function extractLast(term) {
return split(term).pop();
}
</script>
</body>
</html>