forked from homata/brownbag
-
Notifications
You must be signed in to change notification settings - Fork 1
/
list.html
146 lines (136 loc) · 5.52 KB
/
list.html
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
<ons-page id="list-page">
<p style="text-align: center; margin-top: 10px;">
<ons-search-input
placeholder="検索"
onchange="search(this.value)"
></ons-search-input>
</p>
<ons-list>
<ons-list-header>カテゴリー</ons-list-header>
<ons-list-item>
<div class="center">
<ons-select id="type-input" style="width:100%" onchange="selectType(event)">
<option value="both">
出前&テイクアウト
</option>
<option value="catering">
出前
</option>
<option value="takeout">
テイクアウト
</option>
</ons-select>
</div>
</ons-list-item>
<ons-list-header>メニュー</ons-list-header>
<ons-list-item>
<div class="center">
<ons-select id="menu-input" style="width:100%" onchange="selectMenu(event)" >
<option value="restaurant">
洋食
</option>
<option value="chinese">
中華
</option>
<option value="lunchbox">
お弁当
</option>
</ons-select>
</div>
</ons-list-item>
<ons-list-header>店舗</ons-list-header>
<ons-lazy-repeat id="infinite-list"></ons-lazy-repeat>
</ons-list>
<script>
function search(value) {
var text = '検索文字: ' + value;
//ons.notification.alert(text);
ons.notification.toast(text, { timeout: 1000, animation: 'fall' });
}
function selectType(event) {
var value = event.target.value;
var message = "";
if (value == "both") {
message = "出前&テイクアウト";
} else if (value == "catering") {
message = "出前";
} else if (value == "takeout") {
message = "テイクアウト";
}
ons.notification.toast(message, { timeout: 1000, animation: 'fall' });
}
function selectMenu(event) {
var value = event.target.value;
var message = "";
if (value == "restaurant") {
message = "洋食";
} else if (value == "chinese") {
message = "中華";
} else if (value == "lunchbox") {
message = "お弁当";
}
ons.notification.toast(message, { timeout: 1000, animation: 'fall' });
}
// アクティブなタブが変わる前に発火します。
document.addEventListener('prechange', function(event) {
var infiniteList = document.getElementById('infinite-list');
infiniteList.delegate = {
createItemContent: function(index) {
return this.createItem(index);
},
countItems: function() {
return getShopItemCount();
},
getItem: function (index) {
var item = getShopItem(index);
if (!item) {
return null;
}
var imageurl = "shop.png";
//var imageurl = "/image/IMG_4423.jpg";
//var imageurl = "/image/shop.png";
if (item["Cover"] !== null && item["Cover"].length > 0) {
//imageurl = item["Icon"];
imageurl = "cook1.jpg"
}
var tel = item["Phone"];
if (tel === null) {
tel = "";
}
//console.log("getItem0: " + tel);
var category = item["category"];
if (category === null) {
category = "";
}
//console.log("getItem0: " + JSON.stringify(item));
var data = {
name: item["Name"],
url: imageurl,
tel: tel,
category: category
};
//console.log("getItem1: " + JSON.stringify(data));
return data;
},
createItem: function (index) {
var item = this.getItem(index);
if (!item) {
return null;
}
//console.log("createItem: " + JSON.stringify(item));
return ons.createElement(`
<ons-list-item onclick="fn.pushPage({'id':'info.html', 'title':'${item.name}', 'index':'${index}'})" modifier="chevron">
<div class="left">
<img class="list-item__thumbnail" src="${item.url}">
</div>
<div class="center">
<span class="list-item__title">${item.name}</span><span class="list-item__subtitle">カテゴリ:${item.category} TEL:${item.tel}</span>
</div>
</ons-list-item>
`);
},
};
infiniteList.refresh();
});
</script>
</ons-page>