-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
184 lines (158 loc) · 5.58 KB
/
index.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
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
<!DOCTYPE html>
<html>
<head>
<title>Goleki.js</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css">
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css"> -->
<!-- <link rel="stylesheet" href="/dist/goleki.css"> -->
<style type="text/css">
body section {
margin-bottom: 50px;
}
</style>
</head>
<body>
<div class="container" style="min-height: 1500px;">
<div class="col-md-9">
<section>
<div class="form-group">
<label>Basic</label>
<input type="text" name="basic" class="form-control input-lg basic" placeholder="Search repositories of github...." style="margin-bottom: 20px;" />
</div>
</section>
<section>
<div class="form-group">
<label>Custom Template</label>
<input type="text" name="custom_template" class="form-control custom_template" placeholder="Search repositories of github...." />
</div>
</section>
<section>
<div class="form-group">
<div class="form-group has-feedback">
<label>Using loading</label>
<input type="text" name="loading" class="form-control with_loading" />
<span class="form-control-feedback el_loading" aria-hidden="true">
<img src="/assets/loading-git.gif" style="width: 16px; height: 16px;">
</span>
</div>
</div>
</section>
<section>
<div class="form-group">
<label>Event</label>
<input type="text" name="event" class="form-control event_example" placeholder="Search repositories of github...." />
</div>
</section>
<section>
<div class="form-group">
<label>Local Data</label>
<input type="text" name="event" class="form-control local_data" placeholder="Search repositories of github...." />
</div>
</section>
<section>
<div class="form-group">
<label>Custom Params</label>
<input type="text" name="event" class="form-control custom_params" placeholder="Search repositories of github...." />
</div>
</section>
</div>
<div class="col-md-3"></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js" type="text/javascript"></script>
<script src="/src/goleki.js" type="text/javascript"></script>
<script type="text/javascript">
var basic = $('.basic').goleki({
source: 'https://api.github.com/search/repositories',
jsonData: 'items',
templates: {
empty: 'ya gak onok lo prend',
item: function(obj) {
return '<a style="color: grey;"><span>'+ obj.full_name +'</span></a>';
}
}
});
basic.on('goleki:select', function(e, cok, obj) {
console.log($(this));
});
var custom_template = $('.custom_template').goleki({
source: 'https://api.github.com/search/repositories',
jsonData: 'items',
templates: {
containerAutocomplete: '<div style="background: whitesmoke; position: absolute; border: 1px solid #a0a0a0; border-radius: 6px;"></div>',
item: function(obj) {
return '<a data-result="'+ obj.full_name +'" class="media" style="margin:0px;">\n '+
' <div class="media-left">\n '+
' <img class="media-object" src="'+ obj.owner.avatar_url +'&s=48" style="width: 24px; height: 24px;">\n '+
' </div>\n '+
' <div class="media-body">\n '+
' <h4 class="media-heading">'+ obj.full_name +'</h4>\n '+
' <small>'+ obj.owner.login +'</small>\n '+
' </div>\n '+
'</div>';
},
empty: function(el) {
console.log(this);
return '<a>Keyword ini "<b>'+ el.val() +'</b>" kosong. ga ada isinya</a>';
},
fail: function(el) {
return '<a>pfqp3iewhpia '+ el.val() +'</a>';
}
}
});
var with_loading = $('.with_loading').goleki({
source: 'https://api.github.com/search/repositories',
jsonData: 'items',
templates: {
item: function(obj) {
return '<a style="color: grey;"><span>'+ obj.full_name +'</span></a>';
},
loading: $('.el_loading')
}
});
$('.event_example').goleki({
source: 'https://api.github.com/search/repositories',
jsonData: 'items',
onSelectItem: function(e, instance, $el, obj) {
e.preventDefault();
console.log(e, instance, $el, obj);
alert(obj.full_name +' is owned by '+ obj.owner.login);
},
templates: {
item: function(obj) {
return '<a href="'+ obj.html_url +'" style="color: green;">'+ obj.full_name +'</a>';
}
}
});
var localData = [
'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California',
'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii',
'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana',
'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota',
'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire',
'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota',
'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island',
'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont',
'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'
];
var localData = $('.local_data').goleki({
source: localData,
templates: {}
});
var custom_params = $('.custom_params').goleki({
source: 'http://instasuite.dev/ajax/coba',
sourceParams: {
keyword: 'input_q',
page: 'input_page'
},
jsonData: 'data',
templates: {
empty: 'ya gak onok lo prend',
item: function(obj) {
return '<a style="color: grey;"><span>'+ obj.username +'</span></a>';
}
}
});
</script>
</body>
</html>