sequenceserver 0.7.9 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sequenceserver might be problematic. Click here for more details.
- data/lib/sequenceserver.rb +55 -57
- data/lib/sequenceserver/blast.rb +51 -158
- data/lib/sequenceserver/database.rb +8 -2
- data/lib/sequenceserver/helpers.rb +14 -12
- data/lib/sequenceserver/options.rb +132 -0
- data/lib/sequenceserver/sequencehelpers.rb +4 -30
- data/public/css/bootstrap.dropdown.css +29 -0
- data/public/css/bootstrap.icons.css +155 -0
- data/public/css/bootstrap.min.css +399 -314
- data/public/css/bootstrap.modal.css +28 -0
- data/public/css/custom.css +183 -23
- data/public/img/glyphicons-halflings-white.png +0 -0
- data/public/img/glyphicons-halflings.png +0 -0
- data/public/js/bootstrap-typeahead.js +298 -0
- data/public/js/bootstrap.dropdown.js +92 -0
- data/public/js/bootstrap.modal.js +7 -0
- data/public/js/bootstrap.transition.js +7 -0
- data/public/js/jquery.index.js +67 -0
- data/public/js/jquery.scrollspy.js +74 -0
- data/public/js/jquery.ui.js +57 -0
- data/public/js/sequenceserver.blast.js +96 -37
- data/public/js/sequenceserver.js +157 -85
- data/public/js/store.min.js +2 -0
- data/public/js/yaml.js +24 -0
- data/sequenceserver.gemspec +5 -2
- data/tests/run +26 -0
- data/tests/test_sequencehelpers.rb +10 -18
- data/tests/test_sequenceserver_blast.rb +60 -0
- data/views/_options.erb +144 -0
- data/views/search.erb +133 -145
- metadata +135 -52
@@ -0,0 +1,28 @@
|
|
1
|
+
/*!
|
2
|
+
* Bootstrap v2.0.3
|
3
|
+
*
|
4
|
+
* Copyright 2012 Twitter, Inc
|
5
|
+
* Licensed under the Apache License v2.0
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
*
|
8
|
+
* Designed and built with all the love in the world @twitter by @mdo and @fat.
|
9
|
+
*/
|
10
|
+
.clearfix{*zoom:1;}.clearfix:before,.clearfix:after{display:table;content:"";}
|
11
|
+
.clearfix:after{clear:both;}
|
12
|
+
.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0;}
|
13
|
+
.input-block-level{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;}
|
14
|
+
.modal-open .dropdown-menu{z-index:2050;}
|
15
|
+
.modal-open .dropdown.open{*z-index:2050;}
|
16
|
+
.modal-open .popover{z-index:2060;}
|
17
|
+
.modal-open .tooltip{z-index:2070;}
|
18
|
+
.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:#000000;}.modal-backdrop.fade{opacity:0;}
|
19
|
+
.modal-backdrop,.modal-backdrop.fade.in{opacity:0.8;filter:alpha(opacity=80);}
|
20
|
+
.modal{position:fixed;top:50%;left:50%;z-index:1050;overflow:auto;width:560px;margin:-250px 0 0 -280px;background-color:#ffffff;border:1px solid #999;border:1px solid rgba(0, 0, 0, 0.3);*border:1px solid #999;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);-moz-box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box;}.modal.fade{-webkit-transition:opacity .3s linear, top .3s ease-out;-moz-transition:opacity .3s linear, top .3s ease-out;-ms-transition:opacity .3s linear, top .3s ease-out;-o-transition:opacity .3s linear, top .3s ease-out;transition:opacity .3s linear, top .3s ease-out;top:-25%;}
|
21
|
+
.modal.fade.in{top:50%;}
|
22
|
+
.modal-header{padding:9px 15px;border-bottom:1px solid #eee;}.modal-header .close{margin-top:2px;}
|
23
|
+
.modal-body{overflow-y:auto;max-height:400px;padding:15px;}
|
24
|
+
.modal-form{margin-bottom:0;}
|
25
|
+
.modal-footer{padding:14px 15px 15px;margin-bottom:0;text-align:right;background-color:#f5f5f5;border-top:1px solid #ddd;-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px;-webkit-box-shadow:inset 0 1px 0 #ffffff;-moz-box-shadow:inset 0 1px 0 #ffffff;box-shadow:inset 0 1px 0 #ffffff;*zoom:1;}.modal-footer:before,.modal-footer:after{display:table;content:"";}
|
26
|
+
.modal-footer:after{clear:both;}
|
27
|
+
.modal-footer .btn+.btn{margin-left:5px;margin-bottom:0;}
|
28
|
+
.modal-footer .btn-group .btn+.btn{margin-left:-1px;}
|
data/public/css/custom.css
CHANGED
@@ -1,8 +1,26 @@
|
|
1
|
-
/* generic */
|
2
1
|
html, body{
|
3
2
|
height: 100%;
|
4
3
|
}
|
5
4
|
|
5
|
+
pre {
|
6
|
+
font-family: Monospace;
|
7
|
+
}
|
8
|
+
|
9
|
+
br.large {
|
10
|
+
line-height: 28px;
|
11
|
+
}
|
12
|
+
|
13
|
+
.control-group {
|
14
|
+
margin-bottom: 0px;
|
15
|
+
}
|
16
|
+
|
17
|
+
.nojs-error {
|
18
|
+
margin-top: 10px;
|
19
|
+
padding: 10px;
|
20
|
+
color: white;
|
21
|
+
background-color: red;
|
22
|
+
}
|
23
|
+
|
6
24
|
.offset-left {
|
7
25
|
margin-left: 20px;
|
8
26
|
}
|
@@ -19,52 +37,151 @@ html, body{
|
|
19
37
|
|
20
38
|
fieldset legend {
|
21
39
|
padding-left: 2%;
|
40
|
+
margin-bottom: 0px;
|
41
|
+
font-size: 16px;
|
42
|
+
font-weight: bold;
|
43
|
+
border: 0px;
|
22
44
|
}
|
23
45
|
|
24
|
-
/* contextual */
|
25
46
|
body {
|
26
47
|
background-color: #2B3E42;
|
27
48
|
}
|
28
49
|
|
29
50
|
.page {
|
30
|
-
|
31
|
-
border-radius: 10px 10px 10px 10px;
|
51
|
+
border-radius: 6px 6px 6px 6px;
|
32
52
|
margin: 50px 0px;
|
33
53
|
}
|
34
54
|
|
35
55
|
#banner {
|
36
56
|
background: #EBCD7B;
|
37
57
|
padding: 2%;
|
38
|
-
border-radius:
|
58
|
+
border-radius: 6px 6px 0px 0px;
|
39
59
|
text-align: center;
|
40
60
|
}
|
41
61
|
|
62
|
+
#blast {
|
63
|
+
background-color: white;
|
64
|
+
padding-top: 20px;
|
65
|
+
padding-bottom: 20px;
|
66
|
+
margin: 0px;
|
67
|
+
}
|
68
|
+
|
69
|
+
.detached-top {
|
70
|
+
border-top-left-radius: 6px;
|
71
|
+
border-top-right-radius: 6px;
|
72
|
+
}
|
73
|
+
|
74
|
+
.detached-bottom {
|
75
|
+
border-radius: 0px 0px 6px 6px;
|
76
|
+
}
|
77
|
+
|
42
78
|
#sequence {
|
43
|
-
|
79
|
+
height: 198px;
|
80
|
+
width: 890px;
|
81
|
+
display: block;
|
82
|
+
margin: 0 auto;
|
83
|
+
}
|
84
|
+
|
85
|
+
.notifications {
|
86
|
+
height: 0px;
|
87
|
+
position: relative;
|
88
|
+
top: -12px;
|
89
|
+
}
|
90
|
+
|
91
|
+
.notification {
|
92
|
+
margin: 0 auto;
|
93
|
+
z-index: 1050;
|
94
|
+
border-radius: 6px;
|
95
|
+
-webkit-border-radius: 6px;
|
96
|
+
-moz-border-radius: 6px;
|
97
|
+
box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
|
98
|
+
-webkit-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
|
99
|
+
-moz-box-shadow: 0 3px 7px rgba(0, 0, 0, 0.3);
|
100
|
+
font-size: 14px;
|
101
|
+
font-weight: bold;
|
102
|
+
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
|
103
|
+
text-align: center;
|
104
|
+
padding: 6px 12px 6px 12px;
|
105
|
+
}
|
106
|
+
|
107
|
+
#sequence-type {
|
108
|
+
font-style: italic;
|
109
|
+
}
|
110
|
+
|
111
|
+
#nucleotide-sequence-notification, #protein-sequence-notification {
|
112
|
+
width: 250px;
|
113
|
+
}
|
114
|
+
|
115
|
+
#mixed-sequence-notification {
|
116
|
+
width: 740px;
|
117
|
+
}
|
118
|
+
|
119
|
+
.databases {
|
120
|
+
padding-bottom: 10px;
|
121
|
+
}
|
122
|
+
|
123
|
+
span.highlight {
|
124
|
+
font-weight: bold;
|
44
125
|
}
|
45
126
|
|
46
127
|
.advanced label {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
128
|
+
display: inline-block;
|
129
|
+
font-size: 16px;
|
130
|
+
font-weight: bold;
|
131
|
+
padding-left: 2%;
|
51
132
|
}
|
52
133
|
|
53
134
|
.advanced input {
|
135
|
+
width: 440px;
|
54
136
|
margin: 1% 1%;
|
55
137
|
}
|
56
138
|
|
57
|
-
.advanced
|
58
|
-
|
59
|
-
margin: 0% 1% 1%;
|
139
|
+
.advanced span {
|
140
|
+
cursor: pointer;
|
60
141
|
}
|
61
142
|
|
62
|
-
|
143
|
+
.hover-focus {
|
144
|
+
background-color: #FFC;
|
145
|
+
}
|
146
|
+
|
147
|
+
#method, #methods li {
|
148
|
+
text-transform: uppercase;
|
149
|
+
}
|
150
|
+
|
151
|
+
#methods li {
|
152
|
+
font-size: 15px;
|
153
|
+
text-align: center;
|
154
|
+
padding-top: 4px;
|
155
|
+
padding-bottom: 4px;
|
156
|
+
cursor: pointer;
|
157
|
+
}
|
158
|
+
|
159
|
+
.dropdown-menu li {
|
160
|
+
border-bottom: 1px solid #ccc;
|
161
|
+
}
|
162
|
+
|
163
|
+
.dropdown-menu li:last-child {
|
164
|
+
border-bottom: 0px;
|
165
|
+
}
|
166
|
+
|
167
|
+
#methods > button {
|
168
|
+
height: 38px;
|
169
|
+
}
|
170
|
+
|
171
|
+
.results {
|
172
|
+
background-color: #2B3E42;
|
173
|
+
padding-top: 20px;
|
174
|
+
padding-bottom: 20px;
|
175
|
+
}
|
176
|
+
|
177
|
+
#result {
|
178
|
+
padding: 20px;
|
179
|
+
background-color: white;
|
63
180
|
border-radius: 6px;
|
64
181
|
-moz-border-radius: 6px;
|
65
182
|
}
|
66
183
|
|
67
|
-
.resultn{
|
184
|
+
.resultn {
|
68
185
|
background-color: #dfefe6;
|
69
186
|
margin: 18px 0px 18px 0px;
|
70
187
|
border-radius: 6px;
|
@@ -73,25 +190,68 @@ body {
|
|
73
190
|
border: 1px solid transparent;
|
74
191
|
}
|
75
192
|
|
76
|
-
.
|
193
|
+
ul.index {
|
194
|
+
list-style: none;
|
195
|
+
position: fixed;
|
196
|
+
margin-left: 710px;
|
197
|
+
padding: 15px;
|
198
|
+
width: 200px;
|
199
|
+
top: 5px;
|
200
|
+
}
|
201
|
+
|
202
|
+
ul.index li {
|
203
|
+
padding: 3%;
|
204
|
+
}
|
205
|
+
|
206
|
+
ul.index li.focussed {
|
207
|
+
background-color: #08C;
|
208
|
+
}
|
209
|
+
|
210
|
+
ul.index li.focussed a {
|
211
|
+
color: white;
|
212
|
+
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);
|
213
|
+
}
|
214
|
+
|
215
|
+
ul.index li:visited {
|
216
|
+
}
|
217
|
+
|
218
|
+
div.focussed {
|
77
219
|
border: 1px solid black;
|
78
220
|
}
|
79
221
|
|
80
222
|
#underbar {
|
81
223
|
background: #EBCD7B;
|
82
224
|
padding: 1%;
|
83
|
-
border-radius:
|
225
|
+
border-bottom-right-radius: 6px;
|
226
|
+
border-bottom-left-radius: 6px;
|
84
227
|
text-align: center;
|
85
228
|
}
|
86
229
|
|
87
|
-
|
88
|
-
|
230
|
+
#spinner {
|
231
|
+
color: gray;
|
232
|
+
background-color: transparent;
|
233
|
+
border: none;
|
234
|
+
box-shadow: none;
|
235
|
+
overflow: hidden;
|
89
236
|
}
|
90
237
|
|
91
|
-
|
92
|
-
|
238
|
+
#spinner > div {
|
239
|
+
height: 200px;
|
240
|
+
}
|
241
|
+
|
242
|
+
#social p {
|
243
|
+
font-size: 14px;
|
93
244
|
}
|
94
245
|
|
95
|
-
|
96
|
-
|
246
|
+
#social .buttons {
|
247
|
+
width: 268px;
|
248
|
+
margin: 0px auto;
|
249
|
+
}
|
250
|
+
|
251
|
+
.button-container {
|
252
|
+
width: 74px;
|
253
|
+
height: 32px;
|
254
|
+
float: left;
|
255
|
+
margin-right: 20px;
|
256
|
+
text-align: center;
|
97
257
|
}
|
Binary file
|
Binary file
|
@@ -0,0 +1,298 @@
|
|
1
|
+
/* =============================================================
|
2
|
+
* bootstrap-typeahead.js v2.0.3
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#typeahead
|
4
|
+
* =============================================================
|
5
|
+
* Copyright 2012 Twitter, Inc.
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
* ============================================================ */
|
19
|
+
|
20
|
+
|
21
|
+
!function($){
|
22
|
+
|
23
|
+
"use strict"; // jshint ;_;
|
24
|
+
|
25
|
+
|
26
|
+
/* TYPEAHEAD PUBLIC CLASS DEFINITION
|
27
|
+
* ================================= */
|
28
|
+
|
29
|
+
var Typeahead = function (element, options) {
|
30
|
+
this.$element = $(element)
|
31
|
+
this.options = $.extend({}, $.fn.typeahead.defaults, options)
|
32
|
+
this.matcher = this.options.matcher || this.matcher
|
33
|
+
this.sorter = this.options.sorter || this.sorter
|
34
|
+
this.highlighter = this.options.highlighter || this.highlighter
|
35
|
+
this.updater = this.options.updater || this.updater
|
36
|
+
this.$menu = $(this.options.menu).appendTo('body')
|
37
|
+
this.source = this.options.source
|
38
|
+
this.shown = false
|
39
|
+
this.listen()
|
40
|
+
}
|
41
|
+
|
42
|
+
Typeahead.prototype = {
|
43
|
+
|
44
|
+
constructor: Typeahead
|
45
|
+
|
46
|
+
, select: function () {
|
47
|
+
var val = this.$menu.find('.active').attr('data-value')
|
48
|
+
this.$element
|
49
|
+
.val(this.updater(val))
|
50
|
+
.change()
|
51
|
+
return this.hide()
|
52
|
+
}
|
53
|
+
|
54
|
+
, updater: function (item) {
|
55
|
+
return item
|
56
|
+
}
|
57
|
+
|
58
|
+
, show: function () {
|
59
|
+
var pos = $.extend({}, this.$element.offset(), {
|
60
|
+
height: this.$element[0].offsetHeight
|
61
|
+
})
|
62
|
+
|
63
|
+
this.$menu.css({
|
64
|
+
top: pos.top + pos.height
|
65
|
+
, left: pos.left
|
66
|
+
})
|
67
|
+
|
68
|
+
this.$menu.show()
|
69
|
+
this.shown = true
|
70
|
+
return this
|
71
|
+
}
|
72
|
+
|
73
|
+
, hide: function () {
|
74
|
+
this.$menu.hide()
|
75
|
+
this.shown = false
|
76
|
+
return this
|
77
|
+
}
|
78
|
+
|
79
|
+
, lookup: function (event) {
|
80
|
+
var that = this
|
81
|
+
, items
|
82
|
+
, q
|
83
|
+
|
84
|
+
this.query = this.$element.val()
|
85
|
+
|
86
|
+
if (!this.query) {
|
87
|
+
return this.shown ? this.hide() : this
|
88
|
+
}
|
89
|
+
|
90
|
+
//console.log(that.matcher);
|
91
|
+
|
92
|
+
items = $.grep(this.source, function (item) {
|
93
|
+
//console.log(item.toLowerCase());
|
94
|
+
//console.log(this);
|
95
|
+
//console.log(~item.toLowerCase().indexOf(this.query.toLowerCase()));
|
96
|
+
//console.log(that.matcher(item));
|
97
|
+
return that.matcher(item)
|
98
|
+
})
|
99
|
+
|
100
|
+
//console.log(typeof(this.query.toLowerCase()));
|
101
|
+
console.log(items);
|
102
|
+
|
103
|
+
items = this.sorter(items)
|
104
|
+
|
105
|
+
if (!items.length) {
|
106
|
+
return this.shown ? this.hide() : this
|
107
|
+
}
|
108
|
+
|
109
|
+
return this.render(items.slice(0, this.options.items)).show()
|
110
|
+
}
|
111
|
+
|
112
|
+
, matcher: function (item) {
|
113
|
+
console.log(item.toLowerCase());
|
114
|
+
console.log(this.query.toLowerCase());
|
115
|
+
var val = item.toLowerCase().indexOf(this.query.toLowerCase());
|
116
|
+
console.log(val);
|
117
|
+
return ~val;
|
118
|
+
}
|
119
|
+
|
120
|
+
, sorter: function (items) {
|
121
|
+
var beginswith = []
|
122
|
+
, caseSensitive = []
|
123
|
+
, caseInsensitive = []
|
124
|
+
, item
|
125
|
+
|
126
|
+
while (item = items.shift()) {
|
127
|
+
if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
|
128
|
+
else if (~item.indexOf(this.query)) caseSensitive.push(item)
|
129
|
+
else caseInsensitive.push(item)
|
130
|
+
}
|
131
|
+
|
132
|
+
return beginswith.concat(caseSensitive, caseInsensitive)
|
133
|
+
}
|
134
|
+
|
135
|
+
, highlighter: function (item) {
|
136
|
+
var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&')
|
137
|
+
return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
|
138
|
+
return '<strong>' + match + '</strong>'
|
139
|
+
})
|
140
|
+
}
|
141
|
+
|
142
|
+
, render: function (items) {
|
143
|
+
var that = this
|
144
|
+
|
145
|
+
items = $(items).map(function (i, item) {
|
146
|
+
i = $(that.options.item).attr('data-value', item)
|
147
|
+
i.find('a').html(that.highlighter(item))
|
148
|
+
return i[0]
|
149
|
+
})
|
150
|
+
|
151
|
+
items.first().addClass('active')
|
152
|
+
this.$menu.html(items)
|
153
|
+
return this
|
154
|
+
}
|
155
|
+
|
156
|
+
, next: function (event) {
|
157
|
+
var active = this.$menu.find('.active').removeClass('active')
|
158
|
+
, next = active.next()
|
159
|
+
|
160
|
+
if (!next.length) {
|
161
|
+
next = $(this.$menu.find('li')[0])
|
162
|
+
}
|
163
|
+
|
164
|
+
next.addClass('active')
|
165
|
+
}
|
166
|
+
|
167
|
+
, prev: function (event) {
|
168
|
+
var active = this.$menu.find('.active').removeClass('active')
|
169
|
+
, prev = active.prev()
|
170
|
+
|
171
|
+
if (!prev.length) {
|
172
|
+
prev = this.$menu.find('li').last()
|
173
|
+
}
|
174
|
+
|
175
|
+
prev.addClass('active')
|
176
|
+
}
|
177
|
+
|
178
|
+
, listen: function () {
|
179
|
+
this.$element
|
180
|
+
.on('blur', $.proxy(this.blur, this))
|
181
|
+
.on('keypress', $.proxy(this.keypress, this))
|
182
|
+
.on('keyup', $.proxy(this.keyup, this))
|
183
|
+
|
184
|
+
if ($.browser.webkit || $.browser.msie) {
|
185
|
+
this.$element.on('keydown', $.proxy(this.keypress, this))
|
186
|
+
}
|
187
|
+
|
188
|
+
this.$menu
|
189
|
+
.on('click', $.proxy(this.click, this))
|
190
|
+
.on('mouseenter', 'li', $.proxy(this.mouseenter, this))
|
191
|
+
}
|
192
|
+
|
193
|
+
, keyup: function (e) {
|
194
|
+
switch(e.keyCode) {
|
195
|
+
case 40: // down arrow
|
196
|
+
case 38: // up arrow
|
197
|
+
break
|
198
|
+
|
199
|
+
case 9: // tab
|
200
|
+
case 13: // enter
|
201
|
+
if (!this.shown) return
|
202
|
+
this.select()
|
203
|
+
break
|
204
|
+
|
205
|
+
case 27: // escape
|
206
|
+
if (!this.shown) return
|
207
|
+
this.hide()
|
208
|
+
break
|
209
|
+
|
210
|
+
default:
|
211
|
+
this.lookup()
|
212
|
+
}
|
213
|
+
|
214
|
+
e.stopPropagation()
|
215
|
+
e.preventDefault()
|
216
|
+
}
|
217
|
+
|
218
|
+
, keypress: function (e) {
|
219
|
+
if (!this.shown) return
|
220
|
+
|
221
|
+
switch(e.keyCode) {
|
222
|
+
case 9: // tab
|
223
|
+
case 13: // enter
|
224
|
+
case 27: // escape
|
225
|
+
e.preventDefault()
|
226
|
+
break
|
227
|
+
|
228
|
+
case 38: // up arrow
|
229
|
+
if (e.type != 'keydown') break
|
230
|
+
e.preventDefault()
|
231
|
+
this.prev()
|
232
|
+
break
|
233
|
+
|
234
|
+
case 40: // down arrow
|
235
|
+
if (e.type != 'keydown') break
|
236
|
+
e.preventDefault()
|
237
|
+
this.next()
|
238
|
+
break
|
239
|
+
}
|
240
|
+
|
241
|
+
e.stopPropagation()
|
242
|
+
}
|
243
|
+
|
244
|
+
, blur: function (e) {
|
245
|
+
var that = this
|
246
|
+
setTimeout(function () { that.hide() }, 150)
|
247
|
+
}
|
248
|
+
|
249
|
+
, click: function (e) {
|
250
|
+
e.stopPropagation()
|
251
|
+
e.preventDefault()
|
252
|
+
this.select()
|
253
|
+
}
|
254
|
+
|
255
|
+
, mouseenter: function (e) {
|
256
|
+
this.$menu.find('.active').removeClass('active')
|
257
|
+
$(e.currentTarget).addClass('active')
|
258
|
+
}
|
259
|
+
|
260
|
+
}
|
261
|
+
|
262
|
+
|
263
|
+
/* TYPEAHEAD PLUGIN DEFINITION
|
264
|
+
* =========================== */
|
265
|
+
|
266
|
+
$.fn.typeahead = function (option) {
|
267
|
+
return this.each(function () {
|
268
|
+
var $this = $(this)
|
269
|
+
, data = $this.data('typeahead')
|
270
|
+
, options = typeof option == 'object' && option
|
271
|
+
if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
|
272
|
+
if (typeof option == 'string') data[option]()
|
273
|
+
})
|
274
|
+
}
|
275
|
+
|
276
|
+
$.fn.typeahead.defaults = {
|
277
|
+
source: []
|
278
|
+
, items: 8
|
279
|
+
, menu: '<ul class="typeahead dropdown-menu"></ul>'
|
280
|
+
, item: '<li><a href="#"></a></li>'
|
281
|
+
}
|
282
|
+
|
283
|
+
$.fn.typeahead.Constructor = Typeahead
|
284
|
+
|
285
|
+
|
286
|
+
/* TYPEAHEAD DATA-API
|
287
|
+
* ================== */
|
288
|
+
|
289
|
+
$(function () {
|
290
|
+
$('body').on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
|
291
|
+
var $this = $(this)
|
292
|
+
if ($this.data('typeahead')) return
|
293
|
+
e.preventDefault()
|
294
|
+
$this.typeahead($this.data())
|
295
|
+
})
|
296
|
+
})
|
297
|
+
|
298
|
+
}(window.jQuery);
|