Skip to content

Commit e494bac

Browse files
committed
Adding Guest Suggestion List and appending guests, remove guests part A
1 parent 150eb77 commit e494bac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+12059
-6
lines changed

.DS_Store

0 Bytes
Binary file not shown.

app/.DS_Store

2 KB
Binary file not shown.

app/assets/.DS_Store

6 KB
Binary file not shown.

app/assets/css/.DS_Store

6 KB
Binary file not shown.

app/assets/css/autocomplete.css

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.autocomplete {
2+
/*the container must be positioned relative:*/
3+
position: relative;
4+
}
5+
6+
.autocomplete-items {
7+
position: absolute;
8+
border: 1px solid #d4d4d4;
9+
border-bottom: none;
10+
border-top: none;
11+
z-index: 99;
12+
/*position the autocomplete items to be the same width as the container:*/
13+
top: 100%;
14+
left: 0;
15+
right: 0;
16+
}
17+
18+
.autocomplete-items div {
19+
padding: 10px;
20+
cursor: pointer;
21+
background-color: #fff;
22+
border-bottom: 1px solid #d4d4d4;
23+
}
24+
25+
.autocomplete-items div:hover {
26+
/*when hovering an item:*/
27+
background-color: #e9e9e9;
28+
}
29+
30+
.autocomplete-active {
31+
/*when navigating through the items using the arrow keys:*/
32+
background-color: DodgerBlue !important;
33+
color: #ffffff;
34+
}
35+
36+
.removeItem{
37+
margin-left: 5%;
38+
cursor: pointer;
39+
border-radius: 50%;
40+
background: #e50000;
41+
}

app/assets/js/.DS_Store

6 KB
Binary file not shown.

app/assets/js/autocomplete.js

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
var selectedGuests = [];
2+
function guestIsAlreadyAdded(array, guestObject){
3+
for (var i = 0; i < array.length; i++) {
4+
if(array[i].name == guestObject.name && array[i].id == guestObject.id){
5+
return true;
6+
}
7+
}
8+
return false;
9+
}
10+
function autocomplete(inp, arr) {
11+
/*the autocomplete function takes two arguments,
12+
the text field element and an array of possible autocompleted values:*/
13+
var currentFocus;
14+
/*execute a function when someone writes in the text field:*/
15+
inp.addEventListener("input", function(e) {
16+
var a, b, i, val = this.value;
17+
/*close any already open lists of autocompleted values*/
18+
closeAllLists();
19+
if (!val) { return false;}
20+
currentFocus = -1;
21+
/*create a DIV element that will contain the items (values):*/
22+
a = document.createElement("DIV");
23+
a.setAttribute("id", this.id + "autocomplete-list");
24+
a.setAttribute("class", "autocomplete-items");
25+
/*append the DIV element as a child of the autocomplete container:*/
26+
this.parentNode.appendChild(a);
27+
/*for each item in the array...*/
28+
for (i = 0; i < arr.length; i++) {
29+
/*check if the item starts with the same letters as the text field value:*/
30+
if (arr[i].name.substr(0, val.length).toUpperCase() == val.toUpperCase()) {
31+
/*create a DIV element for each matching element:*/
32+
b = document.createElement("DIV");
33+
/*make the matching letters bold:*/
34+
b.innerHTML = "<strong>" + arr[i].name.substr(0, val.length) + "</strong>";
35+
b.innerHTML += arr[i].name.substr(val.length);
36+
/*insert a input field that will hold the current array item's value:*/
37+
b.innerHTML += "<input type='hidden' id='name' value='" + arr[i].name + "'>";
38+
b.innerHTML += "<input type='hidden' id='id' value='" + arr[i].id + "'>";
39+
/*execute a function when someone clicks on the item value (DIV element):*/
40+
b.addEventListener("click", function(e) {
41+
elementoLi = document.createElement("LI");
42+
var guestName = this.getElementsByTagName("input")[0].value;
43+
var guestId = this.getElementsByTagName("input")[1].value;
44+
elementoLi.setAttribute("class", "guest_" + guestId);
45+
// push values to array of selected guests
46+
if(!guestIsAlreadyAdded(selectedGuests, {id: guestId, name: guestName})){
47+
selectedGuests.push({id: guestId, name: guestName});
48+
49+
elementoLi.innerHTML =
50+
"<div>" +
51+
"<img src=\"http://www.skywardimaging.com/wp-content/uploads/2015/11/default-user-image.png\" height=\"20\" width=\"20\" style=\"margin:5%\"></img>" +
52+
guestName +
53+
"<a class=\"removeItem\"> x</a>"
54+
"</div>" ;
55+
var guestList = document.getElementById("invitedGuests");
56+
guestList.appendChild(elementoLi);
57+
}
58+
/*close the list of autocompleted values,
59+
(or any other open lists of autocompleted values:*/
60+
closeAllLists();
61+
});
62+
a.appendChild(b);
63+
}
64+
}
65+
66+
for (i = 0; i < arr.length; i++) {
67+
/*check if the item starts with the same letters as the text field value:*/
68+
if (arr[i].name.toUpperCase().includes(val.toUpperCase()) && arr[i].name.substr(0, val.length).toUpperCase() != val.toUpperCase()) {
69+
/*create a DIV element for each matching element:*/
70+
b = document.createElement("DIV");
71+
72+
var startingPosition = arr[i].name.toUpperCase().indexOf(val.toUpperCase());
73+
/*make the matching letters bold:*/
74+
b.innerHTML = arr[i].name.substr(0, startingPosition -1);
75+
b.innerHTML += "<strong>" + arr[i].name.substr(startingPosition, val.length) + "</strong>";
76+
b.innerHTML += arr[i].name.substr(val.length);
77+
78+
/*insert a input field that will hold the current array item's value:*/
79+
b.innerHTML += "<input type='hidden' id='name' value='" + arr[i].name + "'>";
80+
b.innerHTML += "<input type='hidden' id='id' value='" + arr[i].id + "'>";
81+
/*execute a function when someone clicks on the item value (DIV element):*/
82+
b.addEventListener("click", function(e) {
83+
elementoLi = document.createElement("LI");
84+
var guestName = this.getElementsByTagName("input")[0].value;
85+
var guestId = this.getElementsByTagName("input")[1].value;
86+
elementoLi.setAttribute("class", "guest_" + guestId);
87+
// push values to array of selected guests
88+
if(!guestIsAlreadyAdded(selectedGuests, {id: guestId, name: guestName})){
89+
selectedGuests.push({id: guestId, name: guestName});
90+
91+
elementoLi.innerHTML =
92+
"<div>" +
93+
"<img src=\"http://www.skywardimaging.com/wp-content/uploads/2015/11/default-user-image.png\" height=\"20\" width=\"20\" style=\"margin:5%\"></img>" +
94+
guestName +
95+
"<a class=\"removeItem\"> x</a>"
96+
"</div>" ;
97+
var guestList = document.getElementById("invitedGuests");
98+
guestList.appendChild(elementoLi);
99+
}
100+
/*close the list of autocompleted values,
101+
(or any other open lists of autocompleted values:*/
102+
closeAllLists();
103+
});
104+
a.appendChild(b);
105+
}
106+
}
107+
});
108+
/*execute a function presses a key on the keyboard:*/
109+
inp.addEventListener("keydown", function(e) {
110+
var x = document.getElementById(this.id + "autocomplete-list");
111+
if (x){
112+
x = x.getElementsByTagName("div");
113+
}
114+
if (e.keyCode == 40) {
115+
/*If the arrow DOWN key is pressed,
116+
increase the currentFocus variable:*/
117+
currentFocus++;
118+
/*and and make the current item more visible:*/
119+
addActive(x);
120+
} else if (e.keyCode == 38) { //up
121+
/*If the arrow UP key is pressed,
122+
decrease the currentFocus variable:*/
123+
currentFocus--;
124+
/*and and make the current item more visible:*/
125+
addActive(x);
126+
} else if (e.keyCode == 13) {
127+
/*If the ENTER key is pressed, prevent the form from being submitted,*/
128+
e.preventDefault();
129+
if (currentFocus > -1) {
130+
/*and simulate a click on the "active" item:*/
131+
if (x){
132+
x[currentFocus].click();
133+
}
134+
}
135+
}
136+
});
137+
138+
function addActive(x) {
139+
/*a function to classify an item as "active":*/
140+
if (!x) return false;
141+
/*start by removing the "active" class on all items:*/
142+
removeActive(x);
143+
if (currentFocus >= x.length) currentFocus = 0;
144+
if (currentFocus < 0) currentFocus = (x.length - 1);
145+
/*add class "autocomplete-active":*/
146+
x[currentFocus].classList.add("autocomplete-active");
147+
}
148+
function removeActive(x) {
149+
/*a function to remove the "active" class from all autocomplete items:*/
150+
for (var i = 0; i < x.length; i++) {
151+
x[i].classList.remove("autocomplete-active");
152+
}
153+
}
154+
function closeAllLists(elmnt) {
155+
/*close all autocomplete lists in the document,
156+
except the one passed as an argument:*/
157+
var x = document.getElementsByClassName("autocomplete-items");
158+
for (var i = 0; i < x.length; i++) {
159+
if (elmnt != x[i] && elmnt != inp) {
160+
x[i].parentNode.removeChild(x[i]);
161+
}
162+
}
163+
}
164+
165+
function removeItem(id){
166+
var positionToRemove = -1;
167+
for (var i = 0; i < selectedGuests.length; i++) {
168+
if(selectedGuests[i].id == id){
169+
positionToRemove = i;
170+
break;
171+
}
172+
}
173+
if(positionToRemove >= 0){
174+
selectedGuests.splice(positionToRemove, 1);
175+
}
176+
}
177+
/*execute a function when someone clicks in the document:*/
178+
document.addEventListener("click", function (e) {
179+
closeAllLists(e.target);
180+
if(e.target && e.target.className == 'removeItem'){
181+
var itemClassName = e.target.parentNode.parentNode.className;
182+
console.log(itemClassName);
183+
//remove html object
184+
$('.'+itemClassName).remove();
185+
//remove from array object
186+
removeItem(itemClassName.split('_')[1]);
187+
}
188+
});
189+
}

app/assets/js/jslider/.DS_Store

6 KB
Binary file not shown.

app/assets/js/jslider/MIT-LICENSE.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
Copyright (c) 2012 Egor Khmelev
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
SOFTWARE.

app/assets/js/jslider/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
css_compiler: js_compiler
3+
mkdir -p bin
4+
cat css/jslider.css css/jslider.blue.css css/jslider.plastic.css css/jslider.round.css css/jslider.round.plastic.css > bin/jquery.slider.all.css
5+
java -jar tools/yuicompressor-2.4.7.jar --type=css bin/jquery.slider.all.css > bin/jquery.slider.min.css
6+
rm -f bin/jquery.slider.all.css
7+
8+
js_compiler:
9+
mkdir -p bin
10+
rm -f bin/jquery.slider.all.js bin/jquery.slider.min.js
11+
cat js/jshashtable-2.1_src.js js/jquery.numberformatter-1.2.3.js js/tmpl.js js/jquery.dependClass-0.1.js js/draggable-0.1.js js/jquery.slider.js > bin/jquery.slider.all.js
12+
uglifyjs -nc bin/jquery.slider.all.js > bin/jquery.slider.min.js
13+
rm -f bin/jquery.slider.all.js
14+
15+

app/assets/js/jslider/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# jQuery Slider plugin
2+
3+
jQuery Slider is easy to use and multifunctional jQuery plugin.
4+
5+
[Check out demos and documentations here](http://egorkhmelev.github.com/jslider/)
6+
7+
## Bugs / Pull requests
8+
9+
THIS PROJECT IS NOT MAINTAINED ANYMORE. You are free to fork it and start a new project.
10+
11+
Best fork: https://github.com/abdavid/jslider
12+
13+
## License
14+
15+
(MIT License) — Copyright &copy; 2012 Egor Khmelev

app/assets/js/jslider/bin/jquery.slider.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/assets/js/jslider/bin/jquery.slider.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
.jslider_blue .jslider-bg i,
3+
.jslider_blue .jslider-pointer { background-image: url(../img/jslider.blue.png); }
4+

app/assets/js/jslider/css/jslider.css

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
.jslider .jslider-bg i,
3+
.jslider .jslider-pointer { background: url(../img/jslider.png) no-repeat 0 0; }
4+
5+
.jslider { display: block; width: 100%; height: 1em; position: relative; top: 0.6em; font-family: Arial, sans-serif; }
6+
.jslider table { width: 100%; border-collapse: collapse; border: 0; }
7+
.jslider td, .jslider th { padding: 0; vertical-align: top; text-align: left; border: 0; }
8+
9+
.jslider table,
10+
.jslider table tr,
11+
.jslider table tr td { width: 100%; vertical-align: top; }
12+
13+
.jslider .jslider-bg { position: relative; }
14+
.jslider .jslider-bg i { height: 5px; position: absolute; font-size: 0; top: 0; }
15+
.jslider .jslider-bg .l { width: 10%; background-position: 0 0; left: 0; }
16+
.jslider .jslider-bg .f { width: 80%; left: 10%; background-repeat: repeat-x; background-position: 0 -20px; }
17+
.jslider .jslider-bg .r { width: 10%; left: 90%; background-position: right 0; }
18+
.jslider .jslider-bg .v { position: absolute; width: 60%; left: 20%; top: 0; height: 5px; background-repeat: repeat-x; background-position: 0 -40px; }
19+
20+
.jslider .jslider-pointer { width: 13px; height: 15px; background-position: 0 -60px; position: absolute; left: 20%; top: -4px; margin-left: -6px; cursor: pointer; cursor: hand; }
21+
.jslider .jslider-pointer-hover { background-position: -20px -60px; }
22+
.jslider .jslider-pointer-to { left: 80%; }
23+
24+
.jslider .jslider-label { font-size: 9px; line-height: 12px; color: black; opacity: 0.4; white-space: nowrap; padding: 0px 2px; position: absolute; top: -18px; left: 0px; }
25+
.jslider .jslider-label-to { left: auto; right: 0; }
26+
27+
.jslider .jslider-value { font-size: 9px; white-space: nowrap; padding: 1px 2px 0; position: absolute; top: -19px; left: 20%; background: white; line-height: 12px; -moz-border-radius: 2px; -webkit-border-radius: 2px; -o-border-radius: 2px; border-radius: 2px; }
28+
.jslider .jslider-value-to { left: 80%; }
29+
30+
.jslider .jslider-label small,
31+
.jslider .jslider-value small { position: relative; top: -0.4em; }
32+
33+
.jslider .jslider-scale { position: relative; top: 9px; }
34+
.jslider .jslider-scale span { position: absolute; height: 5px; border-left: 1px solid #999; font-size: 0; }
35+
.jslider .jslider-scale ins { font-size: 9px; text-decoration: none; position: absolute; left: 0px; top: 5px; color: #999; }
36+
37+
.jslider-single .jslider-pointer-to,
38+
.jslider-single .jslider-value-to,
39+
.jslider-single .jslider-bg .v,
40+
.jslider-limitless .jslider-label { display: none; }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
.jslider_plastic .jslider-bg i,
3+
.jslider_plastic .jslider-pointer { background-image: url(../img/jslider.plastic.png); }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
.jslider_round .jslider-bg i,
3+
.jslider_round .jslider-pointer { background-image: url(../img/jslider.round.png); }
4+
5+
.jslider_round .jslider-pointer { width: 17px; height: 17px; top: -6px; margin-left: -8px; }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
.jslider_round_plastic .jslider-bg i,
3+
.jslider_round_plastic .jslider-pointer { background-image: url(../img/jslider.round.plastic.png); }
4+
5+
.jslider_round_plastic .jslider-pointer { width: 18px; height: 18px; top: -7px; margin-left: -8px; }
1.11 KB
Loading
1.39 KB
Loading

app/assets/js/jslider/img/jslider.png

1.11 KB
Loading
Loading
1.93 KB
Loading

0 commit comments

Comments
 (0)