-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathhtml-model-usage.htm
233 lines (173 loc) · 8.32 KB
/
html-model-usage.htm
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<!DOCTYPE html>
<html>
<head>
<title>HTML Model Usage</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel="stylesheet" type="text/css" href="basic/basic.min.css">
<script src="basic/basic.min.js" type="text/javascript" charset="utf-8"></script>
<script src="components/ui-core.js" type="text/javascript" charset="utf-8"></script>
<script src="components/ui-item-list.js" type="text/javascript" charset="utf-8"></script>
<script src="components/ui-search-box.js" type="text/javascript" charset="utf-8"></script>
<style>
.item-model {
position: relative;
display: block;
width: 100%;
height: 100%;
background-color: transparent;
border: 0px solid white;
}
.item-model.background {
position:absolute;
top: 2px;
left: 20px;
width: calc(100% - 40px);
height: calc(100% - 4px);
background-color: transparent;
border-radius: 13px;
transition: background-color 0.3s ease 0s;
}
.item-model.background.selected {
background-color: whitesmoke;
}
.item-model.icon {
position:absolute;
left: 30px;
top: 12px;
width: 70px;
height: 70px;
border-radius: 4px;
background-color: transparent;
border-width: 0px;
}
.item-model.title {
position:absolute;
left: 120px;
top: 25px;
width: 280px;
height: auto;
font-family: opensans;
font-size: 20px;
text-align: left;
color: #4A4A4A;
}
.item-model.description {
position:absolute;
left: 120px;
top: 49px;
width: 280px;
height: auto;
color: gray;
font-family: opensans;
font-size: 14px;
text-align: left;
}
</style>
<script>
const itemDataList = [
{ title:"Broccoli", desc:"Vegetable", iconFile:"assets/fruids/brokoli.png", searchText: "Broccoli Vegetable" },
{ title:"Strawberry", desc:"Fruit", iconFile:"assets/fruids/cilek.png", searchText: "Strawberry Fruit" },
{ title:"Tomato", desc:"Vegetable", iconFile:"assets/fruids/domates.png", searchText: "Tomato Vegetable" },
{ title:"Apple", desc:"Fruit", iconFile:"assets/fruids/elma.png", searchText: "Apple Fruit" },
{ title:"Carrot", desc:"Vegetable", iconFile:"assets/fruids/havuc.png", searchText: "Carrot Vegetable" },
{ title:"Watermelon", desc:"Fruit", iconFile:"assets/fruids/karpuz.png", searchText: "Watermelon Fruit" },
{ title:"Lemon", desc:"Fruit", iconFile:"assets/fruids/limon.png", searchText: "Lemon Fruit" },
{ title:"Banana", desc:"Fruit", iconFile:"assets/fruids/muz.png", searchText: "Banana Fruit" },
{ title:"Pomegranate", desc:"Fruit", iconFile:"assets/fruids/nar.png", searchText: "Pomegranate Fruit" },
{ title:"Eggplant", desc:"Vegetable", iconFile:"assets/fruids/patlican.png", searchText: "Eggplant Vegetable" },
{ title:"Blueberry", desc:"Fruit", iconFile:"assets/fruids/yabanmersini.png", searchText: "Blueberry Fruit" },
{ title:"Green Pepper", desc:"Vegetable", iconFile:"assets/fruids/yesilbiber.png", searchText: "Green Pepper Vegetable" }
];
const start = function() {
const box = createBox(0, 0, getDefaultContainerBox().width, getDefaultContainerBox().height);
page.boxSearchPage = box;
box.color = "transparent";
box.scrollY = 0;
// #1
// BOX: Search container.
box.boxSearch = createBox(0, 0, box.width, 105);
box.add(that);
that.color = "transparent";
that.border = 0;
// UI SEARCH BOX: Search box in boxSearch.
UISearchBox.resetDefault();
box.boxSearch.uiSearchBox = UISearchBox.create({ width: box.width - 40 });
box.boxSearch.add(that);
// Show
that.left = 20;
that.bottom = 20;
// #2
// UI ITEM LIST: Items (VERTICAL)
box.uiItemList = UIItemList.create({
width: box.width,
height: box.height - box.boxSearch.height
});
box.add(that);
that.color = "transparent";
that.top = box.boxSearch.height;
that.setItemAlignment(UIItemList.alignType.VERTICAL);
that.setInnerSpaces(0, 10, 0, 10);
that.setItemCreationFunction(createItem);
that.createItemsByDataList(itemDataList);
that.onSelectionChange(selectedItemChanged);
// Show
that.aline(box.boxSearch, "bottom");
// Connect search box with plant item list.
box.boxSearch.uiSearchBox.onSearch(function (searchText, uiSearchBox) {
box.uiItemList.searchItemByText(searchText);
});
page.onResize(pageResized);
}
const createItem = function(itemData, uiItemList) {
const ITEM_WIDTH = uiItemList.width;
const ITEM_HEIGHT = 94;
// BOX: Item container.
const item = createBox();
item.color = "transparent";
item.width = ITEM_WIDTH;
item.height = ITEM_HEIGHT;
item.html = `
<div class="item-model">
<div class="item-model background"></div>
<img class="item-model icon" src="${itemData.iconFile}">
<div class="item-model title">${itemData.title}</div>
<div class="item-model description">${itemData.desc}</div>
</div>
`;
//console.log(item.element.childNodes[1].outerHTML);
item.backgroundElement = item.element.childNodes[1].childNodes[1];
// NOTE: check js/page/search-page.js file for using without HTML and CSS.
makeBasicObject(item);
return item;
}
const selectedItemChanged = function(uiItemList, clickedItem, prevClickedItem) {
if (!clickedItem.isSelected()) {
if (prevClickedItem) {
prevClickedItem.backgroundElement.className = "item-model background";
uiItemList.removeItemFromSelectedList(prevClickedItem);
}
clickedItem.backgroundElement.className = "item-model background selected";
uiItemList.addItemToSelectedList(clickedItem);
}
console.log("Selected item: " + clickedItem.getIndex() + "-" + clickedItem.getData().title);
}
const pageResized = function() {
/*
// Resize when page size changes.
// NOTE: It does not need to be used for mobile app template.
page.boxSearchPage.width = getDefaultContainerBox().width;
page.boxSearchPage.height = getDefaultContainerBox().height;
page.boxSearchPage.boxSearch.width = getDefaultContainerBox().width;
page.boxSearchPage.boxSearch.uiSearchBox.width = box.width - 40;
page.boxSearchPage.uiItemList.width = page.boxSearchPage.width;
page.boxSearchPage.uiItemList.height = page.boxSearchPage.height - page.boxSearchPage.boxSearch.height;
page.boxSearchPage.uiItemList.forEach(function(item) {
item.width = page.boxSearchPage.uiItemList.width;
});
*/
}
</script>
</head>
<body></body>
</html>