pietern-bdoc 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +70 -0
- data/Manifest.txt +16 -0
- data/README.rdoc +80 -0
- data/bin/bdoc +4 -0
- data/lib/bdoc.rb +81 -0
- data/public/app/gdoc.css +210 -0
- data/public/app/gdoc.js +402 -0
- data/public/app/jquery.js +19 -0
- data/public/app/liquidmetal.js +88 -0
- data/public/app/screen.css +251 -0
- data/public/app/selector.js +216 -0
- data/templates/index.html +45 -0
- data/test/test_bdoc.rb +11 -0
- data/test/test_helper.rb +3 -0
- metadata +86 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/* -----------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
Blueprint CSS Framework 0.8
|
|
5
|
+
http://blueprintcss.org
|
|
6
|
+
|
|
7
|
+
* Copyright (c) 2007-Present. See LICENSE for more info.
|
|
8
|
+
* See README for instructions on how to use Blueprint.
|
|
9
|
+
* For credits and origins, see AUTHORS.
|
|
10
|
+
* This is a compressed file. See the sources in the 'src' directory.
|
|
11
|
+
|
|
12
|
+
----------------------------------------------------------------------- */
|
|
13
|
+
|
|
14
|
+
/* reset.css */
|
|
15
|
+
html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;}
|
|
16
|
+
body {line-height:1.5;}
|
|
17
|
+
table {border-collapse:separate;border-spacing:0;}
|
|
18
|
+
caption, th, td {text-align:left;font-weight:normal;}
|
|
19
|
+
table, td, th {vertical-align:middle;}
|
|
20
|
+
blockquote:before, blockquote:after, q:before, q:after {content:"";}
|
|
21
|
+
blockquote, q {quotes:"" "";}
|
|
22
|
+
a img {border:none;}
|
|
23
|
+
|
|
24
|
+
/* typography.css */
|
|
25
|
+
body {font-size:75%;color:#222;background:#fff;font-family:"Helvetica Neue", Arial, Helvetica, sans-serif;}
|
|
26
|
+
h1, h2, h3, h4, h5, h6 {font-weight:normal;color:#111;}
|
|
27
|
+
h1 {font-size:3em;line-height:1;margin-bottom:0.5em;}
|
|
28
|
+
h2 {font-size:2em;margin-bottom:0.75em;}
|
|
29
|
+
h3 {font-size:1.5em;line-height:1;margin-bottom:1em;}
|
|
30
|
+
h4 {font-size:1.2em;line-height:1.25;margin-bottom:1.25em;}
|
|
31
|
+
h5 {font-size:1em;font-weight:bold;margin-bottom:1.5em;}
|
|
32
|
+
h6 {font-size:1em;font-weight:bold;}
|
|
33
|
+
h1 img, h2 img, h3 img, h4 img, h5 img, h6 img {margin:0;}
|
|
34
|
+
p {margin:0 0 1.5em;}
|
|
35
|
+
p img.left {float:left;margin:1.5em 1.5em 1.5em 0;padding:0;}
|
|
36
|
+
p img.right {float:right;margin:1.5em 0 1.5em 1.5em;}
|
|
37
|
+
a:focus, a:hover {color:#000;}
|
|
38
|
+
a {color:#009;text-decoration:underline;}
|
|
39
|
+
blockquote {margin:1.5em;color:#666;font-style:italic;}
|
|
40
|
+
strong {font-weight:bold;}
|
|
41
|
+
em, dfn {font-style:italic;}
|
|
42
|
+
dfn {font-weight:bold;}
|
|
43
|
+
sup, sub {line-height:0;}
|
|
44
|
+
abbr, acronym {border-bottom:1px dotted #666;}
|
|
45
|
+
address {margin:0 0 1.5em;font-style:italic;}
|
|
46
|
+
del {color:#666;}
|
|
47
|
+
pre {margin:1.5em 0;white-space:pre;}
|
|
48
|
+
pre, code, tt {font:1em 'andale mono', 'lucida console', monospace;line-height:1.5;}
|
|
49
|
+
li ul, li ol {margin:0 1.5em;}
|
|
50
|
+
ul, ol {margin:0 1.5em 1.5em 1.5em;}
|
|
51
|
+
ul {list-style-type:disc;}
|
|
52
|
+
ol {list-style-type:decimal;}
|
|
53
|
+
dl {margin:0 0 1.5em 0;}
|
|
54
|
+
dl dt {font-weight:bold;}
|
|
55
|
+
dd {margin-left:1.5em;}
|
|
56
|
+
table {margin-bottom:1.4em;width:100%;}
|
|
57
|
+
th {font-weight:bold;}
|
|
58
|
+
thead th {background:#c3d9ff;}
|
|
59
|
+
th, td, caption {padding:4px 10px 4px 5px;}
|
|
60
|
+
tr.even td {background:#e5ecf9;}
|
|
61
|
+
tfoot {font-style:italic;}
|
|
62
|
+
caption {background:#eee;}
|
|
63
|
+
.small {font-size:.8em;margin-bottom:1.875em;line-height:1.875em;}
|
|
64
|
+
.large {font-size:1.2em;line-height:2.5em;margin-bottom:1.25em;}
|
|
65
|
+
.hide {display:none;}
|
|
66
|
+
.quiet {color:#666;}
|
|
67
|
+
.loud {color:#000;}
|
|
68
|
+
.highlight {background:#ff0;}
|
|
69
|
+
.added {background:#060;color:#fff;}
|
|
70
|
+
.removed {background:#900;color:#fff;}
|
|
71
|
+
.first {margin-left:0;padding-left:0;}
|
|
72
|
+
.last {margin-right:0;padding-right:0;}
|
|
73
|
+
.top {margin-top:0;padding-top:0;}
|
|
74
|
+
.bottom {margin-bottom:0;padding-bottom:0;}
|
|
75
|
+
|
|
76
|
+
/* grid.css */
|
|
77
|
+
.container {width:950px;margin:0 auto;}
|
|
78
|
+
.showgrid {background:url(src/grid.png);}
|
|
79
|
+
.column, div.span-1, div.span-2, div.span-3, div.span-4, div.span-5, div.span-6, div.span-7, div.span-8, div.span-9, div.span-10, div.span-11, div.span-12, div.span-13, div.span-14, div.span-15, div.span-16, div.span-17, div.span-18, div.span-19, div.span-20, div.span-21, div.span-22, div.span-23, div.span-24 {float:left;margin-right:10px;}
|
|
80
|
+
.last, div.last {margin-right:0;}
|
|
81
|
+
.span-1 {width:30px;}
|
|
82
|
+
.span-2 {width:70px;}
|
|
83
|
+
.span-3 {width:110px;}
|
|
84
|
+
.span-4 {width:150px;}
|
|
85
|
+
.span-5 {width:190px;}
|
|
86
|
+
.span-6 {width:230px;}
|
|
87
|
+
.span-7 {width:270px;}
|
|
88
|
+
.span-8 {width:310px;}
|
|
89
|
+
.span-9 {width:350px;}
|
|
90
|
+
.span-10 {width:390px;}
|
|
91
|
+
.span-11 {width:430px;}
|
|
92
|
+
.span-12 {width:470px;}
|
|
93
|
+
.span-13 {width:510px;}
|
|
94
|
+
.span-14 {width:550px;}
|
|
95
|
+
.span-15 {width:590px;}
|
|
96
|
+
.span-16 {width:630px;}
|
|
97
|
+
.span-17 {width:670px;}
|
|
98
|
+
.span-18 {width:710px;}
|
|
99
|
+
.span-19 {width:750px;}
|
|
100
|
+
.span-20 {width:790px;}
|
|
101
|
+
.span-21 {width:830px;}
|
|
102
|
+
.span-22 {width:870px;}
|
|
103
|
+
.span-23 {width:910px;}
|
|
104
|
+
.span-24, div.span-24 {width:950px;margin:0;}
|
|
105
|
+
input.span-1, textarea.span-1, select.span-1 {width:30px!important;}
|
|
106
|
+
input.span-2, textarea.span-2, select.span-2 {width:50px!important;}
|
|
107
|
+
input.span-3, textarea.span-3, select.span-3 {width:90px!important;}
|
|
108
|
+
input.span-4, textarea.span-4, select.span-4 {width:130px!important;}
|
|
109
|
+
input.span-5, textarea.span-5, select.span-5 {width:170px!important;}
|
|
110
|
+
input.span-6, textarea.span-6, select.span-6 {width:210px!important;}
|
|
111
|
+
input.span-7, textarea.span-7, select.span-7 {width:250px!important;}
|
|
112
|
+
input.span-8, textarea.span-8, select.span-8 {width:290px!important;}
|
|
113
|
+
input.span-9, textarea.span-9, select.span-9 {width:330px!important;}
|
|
114
|
+
input.span-10, textarea.span-10, select.span-10 {width:370px!important;}
|
|
115
|
+
input.span-11, textarea.span-11, select.span-11 {width:410px!important;}
|
|
116
|
+
input.span-12, textarea.span-12, select.span-12 {width:450px!important;}
|
|
117
|
+
input.span-13, textarea.span-13, select.span-13 {width:490px!important;}
|
|
118
|
+
input.span-14, textarea.span-14, select.span-14 {width:530px!important;}
|
|
119
|
+
input.span-15, textarea.span-15, select.span-15 {width:570px!important;}
|
|
120
|
+
input.span-16, textarea.span-16, select.span-16 {width:610px!important;}
|
|
121
|
+
input.span-17, textarea.span-17, select.span-17 {width:650px!important;}
|
|
122
|
+
input.span-18, textarea.span-18, select.span-18 {width:690px!important;}
|
|
123
|
+
input.span-19, textarea.span-19, select.span-19 {width:730px!important;}
|
|
124
|
+
input.span-20, textarea.span-20, select.span-20 {width:770px!important;}
|
|
125
|
+
input.span-21, textarea.span-21, select.span-21 {width:810px!important;}
|
|
126
|
+
input.span-22, textarea.span-22, select.span-22 {width:850px!important;}
|
|
127
|
+
input.span-23, textarea.span-23, select.span-23 {width:890px!important;}
|
|
128
|
+
input.span-24, textarea.span-24, select.span-24 {width:940px!important;}
|
|
129
|
+
.append-1 {padding-right:40px;}
|
|
130
|
+
.append-2 {padding-right:80px;}
|
|
131
|
+
.append-3 {padding-right:120px;}
|
|
132
|
+
.append-4 {padding-right:160px;}
|
|
133
|
+
.append-5 {padding-right:200px;}
|
|
134
|
+
.append-6 {padding-right:240px;}
|
|
135
|
+
.append-7 {padding-right:280px;}
|
|
136
|
+
.append-8 {padding-right:320px;}
|
|
137
|
+
.append-9 {padding-right:360px;}
|
|
138
|
+
.append-10 {padding-right:400px;}
|
|
139
|
+
.append-11 {padding-right:440px;}
|
|
140
|
+
.append-12 {padding-right:480px;}
|
|
141
|
+
.append-13 {padding-right:520px;}
|
|
142
|
+
.append-14 {padding-right:560px;}
|
|
143
|
+
.append-15 {padding-right:600px;}
|
|
144
|
+
.append-16 {padding-right:640px;}
|
|
145
|
+
.append-17 {padding-right:680px;}
|
|
146
|
+
.append-18 {padding-right:720px;}
|
|
147
|
+
.append-19 {padding-right:760px;}
|
|
148
|
+
.append-20 {padding-right:800px;}
|
|
149
|
+
.append-21 {padding-right:840px;}
|
|
150
|
+
.append-22 {padding-right:880px;}
|
|
151
|
+
.append-23 {padding-right:920px;}
|
|
152
|
+
.prepend-1 {padding-left:40px;}
|
|
153
|
+
.prepend-2 {padding-left:80px;}
|
|
154
|
+
.prepend-3 {padding-left:120px;}
|
|
155
|
+
.prepend-4 {padding-left:160px;}
|
|
156
|
+
.prepend-5 {padding-left:200px;}
|
|
157
|
+
.prepend-6 {padding-left:240px;}
|
|
158
|
+
.prepend-7 {padding-left:280px;}
|
|
159
|
+
.prepend-8 {padding-left:320px;}
|
|
160
|
+
.prepend-9 {padding-left:360px;}
|
|
161
|
+
.prepend-10 {padding-left:400px;}
|
|
162
|
+
.prepend-11 {padding-left:440px;}
|
|
163
|
+
.prepend-12 {padding-left:480px;}
|
|
164
|
+
.prepend-13 {padding-left:520px;}
|
|
165
|
+
.prepend-14 {padding-left:560px;}
|
|
166
|
+
.prepend-15 {padding-left:600px;}
|
|
167
|
+
.prepend-16 {padding-left:640px;}
|
|
168
|
+
.prepend-17 {padding-left:680px;}
|
|
169
|
+
.prepend-18 {padding-left:720px;}
|
|
170
|
+
.prepend-19 {padding-left:760px;}
|
|
171
|
+
.prepend-20 {padding-left:800px;}
|
|
172
|
+
.prepend-21 {padding-left:840px;}
|
|
173
|
+
.prepend-22 {padding-left:880px;}
|
|
174
|
+
.prepend-23 {padding-left:920px;}
|
|
175
|
+
div.border {padding-right:4px;margin-right:5px;border-right:1px solid #eee;}
|
|
176
|
+
div.colborder {padding-right:24px;margin-right:25px;border-right:1px solid #eee;}
|
|
177
|
+
.pull-1 {margin-left:-40px;}
|
|
178
|
+
.pull-2 {margin-left:-80px;}
|
|
179
|
+
.pull-3 {margin-left:-120px;}
|
|
180
|
+
.pull-4 {margin-left:-160px;}
|
|
181
|
+
.pull-5 {margin-left:-200px;}
|
|
182
|
+
.pull-6 {margin-left:-240px;}
|
|
183
|
+
.pull-7 {margin-left:-280px;}
|
|
184
|
+
.pull-8 {margin-left:-320px;}
|
|
185
|
+
.pull-9 {margin-left:-360px;}
|
|
186
|
+
.pull-10 {margin-left:-400px;}
|
|
187
|
+
.pull-11 {margin-left:-440px;}
|
|
188
|
+
.pull-12 {margin-left:-480px;}
|
|
189
|
+
.pull-13 {margin-left:-520px;}
|
|
190
|
+
.pull-14 {margin-left:-560px;}
|
|
191
|
+
.pull-15 {margin-left:-600px;}
|
|
192
|
+
.pull-16 {margin-left:-640px;}
|
|
193
|
+
.pull-17 {margin-left:-680px;}
|
|
194
|
+
.pull-18 {margin-left:-720px;}
|
|
195
|
+
.pull-19 {margin-left:-760px;}
|
|
196
|
+
.pull-20 {margin-left:-800px;}
|
|
197
|
+
.pull-21 {margin-left:-840px;}
|
|
198
|
+
.pull-22 {margin-left:-880px;}
|
|
199
|
+
.pull-23 {margin-left:-920px;}
|
|
200
|
+
.pull-24 {margin-left:-960px;}
|
|
201
|
+
.pull-1, .pull-2, .pull-3, .pull-4, .pull-5, .pull-6, .pull-7, .pull-8, .pull-9, .pull-10, .pull-11, .pull-12, .pull-13, .pull-14, .pull-15, .pull-16, .pull-17, .pull-18, .pull-19, .pull-20, .pull-21, .pull-22, .pull-23, .pull-24 {float:left;position:relative;}
|
|
202
|
+
.push-1 {margin:0 -40px 1.5em 40px;}
|
|
203
|
+
.push-2 {margin:0 -80px 1.5em 80px;}
|
|
204
|
+
.push-3 {margin:0 -120px 1.5em 120px;}
|
|
205
|
+
.push-4 {margin:0 -160px 1.5em 160px;}
|
|
206
|
+
.push-5 {margin:0 -200px 1.5em 200px;}
|
|
207
|
+
.push-6 {margin:0 -240px 1.5em 240px;}
|
|
208
|
+
.push-7 {margin:0 -280px 1.5em 280px;}
|
|
209
|
+
.push-8 {margin:0 -320px 1.5em 320px;}
|
|
210
|
+
.push-9 {margin:0 -360px 1.5em 360px;}
|
|
211
|
+
.push-10 {margin:0 -400px 1.5em 400px;}
|
|
212
|
+
.push-11 {margin:0 -440px 1.5em 440px;}
|
|
213
|
+
.push-12 {margin:0 -480px 1.5em 480px;}
|
|
214
|
+
.push-13 {margin:0 -520px 1.5em 520px;}
|
|
215
|
+
.push-14 {margin:0 -560px 1.5em 560px;}
|
|
216
|
+
.push-15 {margin:0 -600px 1.5em 600px;}
|
|
217
|
+
.push-16 {margin:0 -640px 1.5em 640px;}
|
|
218
|
+
.push-17 {margin:0 -680px 1.5em 680px;}
|
|
219
|
+
.push-18 {margin:0 -720px 1.5em 720px;}
|
|
220
|
+
.push-19 {margin:0 -760px 1.5em 760px;}
|
|
221
|
+
.push-20 {margin:0 -800px 1.5em 800px;}
|
|
222
|
+
.push-21 {margin:0 -840px 1.5em 840px;}
|
|
223
|
+
.push-22 {margin:0 -880px 1.5em 880px;}
|
|
224
|
+
.push-23 {margin:0 -920px 1.5em 920px;}
|
|
225
|
+
.push-24 {margin:0 -960px 1.5em 960px;}
|
|
226
|
+
.push-1, .push-2, .push-3, .push-4, .push-5, .push-6, .push-7, .push-8, .push-9, .push-10, .push-11, .push-12, .push-13, .push-14, .push-15, .push-16, .push-17, .push-18, .push-19, .push-20, .push-21, .push-22, .push-23, .push-24 {float:right;position:relative;}
|
|
227
|
+
.prepend-top {margin-top:1.5em;}
|
|
228
|
+
.append-bottom {margin-bottom:1.5em;}
|
|
229
|
+
.box {padding:1.5em;margin-bottom:1.5em;background:#E5ECF9;}
|
|
230
|
+
hr {background:#ddd;color:#ddd;clear:both;float:none;width:100%;height:.1em;margin:0 0 1.45em;border:none;}
|
|
231
|
+
hr.space {background:#fff;color:#fff;}
|
|
232
|
+
.clearfix:after, .container:after {content:"\0020";display:block;height:0;clear:both;visibility:hidden;overflow:hidden;}
|
|
233
|
+
.clearfix, .container {display:block;}
|
|
234
|
+
.clear {clear:both;}
|
|
235
|
+
|
|
236
|
+
/* forms.css */
|
|
237
|
+
label {font-weight:bold;}
|
|
238
|
+
fieldset {padding:1.4em;margin:0 0 1.5em 0;border:1px solid #ccc;}
|
|
239
|
+
legend {font-weight:bold;font-size:1.2em;}
|
|
240
|
+
input.text, input.title, textarea, select {margin:0.5em 0;border:1px solid #bbb;}
|
|
241
|
+
input.text:focus, input.title:focus, textarea:focus, select:focus {border:1px solid #666;}
|
|
242
|
+
input.text, input.title {width:300px;padding:5px;}
|
|
243
|
+
input.title {font-size:1.5em;}
|
|
244
|
+
textarea {width:390px;height:250px;padding:5px;}
|
|
245
|
+
.error, .notice, .success {padding:.8em;margin-bottom:1em;border:2px solid #ddd;}
|
|
246
|
+
.error {background:#FBE3E4;color:#8a1f11;border-color:#FBC2C4;}
|
|
247
|
+
.notice {background:#FFF6BF;color:#514721;border-color:#FFD324;}
|
|
248
|
+
.success {background:#E6EFC2;color:#264409;border-color:#C6D880;}
|
|
249
|
+
.error a {color:#8a1f11;}
|
|
250
|
+
.notice a {color:#514721;}
|
|
251
|
+
.success a {color:#264409;}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
(function($) {
|
|
2
|
+
$.quickselect = function(select, data, options) { this.init(select, data, options); };
|
|
3
|
+
|
|
4
|
+
$.extend($.quickselect.prototype, {
|
|
5
|
+
settings: {
|
|
6
|
+
selectedClass: "qs_selected",
|
|
7
|
+
preloadCache: function(entry) {
|
|
8
|
+
return entry.name;
|
|
9
|
+
},
|
|
10
|
+
renderResultRow: function(entry) {
|
|
11
|
+
return $('<li/>').html(entry.name);
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
input: null,
|
|
15
|
+
resultContainer: null,
|
|
16
|
+
resultList: null,
|
|
17
|
+
data: [],
|
|
18
|
+
cache: [],
|
|
19
|
+
results: [],
|
|
20
|
+
lastAbbreviation: null,
|
|
21
|
+
abbreviationBeforeFocus: null,
|
|
22
|
+
selectedIndex: 0,
|
|
23
|
+
picked: false,
|
|
24
|
+
dropdownMouseover: false, // Workaround for poor IE behaviors
|
|
25
|
+
|
|
26
|
+
init: function(input, data, options) {
|
|
27
|
+
this.settings = {
|
|
28
|
+
selectedClass: "qs_selected",
|
|
29
|
+
preloadCache: function(entry) {
|
|
30
|
+
return entry.name;
|
|
31
|
+
},
|
|
32
|
+
renderResultRow: function(entry) {
|
|
33
|
+
return $('<li/>').html(entry.name);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
$.extend(this.settings, options);
|
|
37
|
+
this.input = $(input);
|
|
38
|
+
this.data = data;
|
|
39
|
+
this.preloadCache();
|
|
40
|
+
this.renderControls();
|
|
41
|
+
this.wire();
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
preloadCache: function() {
|
|
45
|
+
this.cache = $.map(this.data, this.settings.preloadCache);
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
renderControls: function() {
|
|
49
|
+
this.resultContainer = $('<div class="results"><ul></ul></div>');
|
|
50
|
+
this.input.after(this.resultContainer);
|
|
51
|
+
this.resultList = this.resultContainer.find('ul');
|
|
52
|
+
|
|
53
|
+
// disable native autocomplete
|
|
54
|
+
this.input.attr('autocomplete', 'off');
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
wire: function() {
|
|
58
|
+
var self = this;
|
|
59
|
+
|
|
60
|
+
this.input.click(function() {
|
|
61
|
+
self.lastAbbreviation = null;
|
|
62
|
+
self.focus();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
this.input.mouseup(function(event) {
|
|
66
|
+
// This is so Safari selection actually occurs.
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
this.input.focus(function() {
|
|
71
|
+
self.abbreviationBeforeFocus = self.input.val();
|
|
72
|
+
if (!self.picked) self.filterResults();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
this.input.blur(function() {
|
|
76
|
+
// if (!self.dropdownMouseover) {
|
|
77
|
+
// self.hide();
|
|
78
|
+
// if (!self.picked) self.reset();
|
|
79
|
+
// }
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
this.resultList.mouseover(function (event) {
|
|
83
|
+
if (event.target.tagName == "LI") {
|
|
84
|
+
var rows = self.resultContainer.find("li");
|
|
85
|
+
self.markSelected(rows.index($(event.target)), false);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
this.resultList.mouseleave(function () {
|
|
89
|
+
self.markSelected(-1);
|
|
90
|
+
});
|
|
91
|
+
this.resultList.mouseup(function (event) {
|
|
92
|
+
self.pickSelected();
|
|
93
|
+
});
|
|
94
|
+
this.resultList.mouseover(function (event) {
|
|
95
|
+
self.dropdownMouseover = true;
|
|
96
|
+
});
|
|
97
|
+
this.resultList.mouseleave(function (event) {
|
|
98
|
+
self.dropdownMouseover = false;
|
|
99
|
+
});
|
|
100
|
+
this.resultList.mousedown(function (event) {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
this.input.keyup(function(event) {
|
|
105
|
+
switch (event.keyCode) {
|
|
106
|
+
case 13: // return
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
self.pickSelected();
|
|
109
|
+
break;
|
|
110
|
+
case 27: // esc
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
self.input.trigger('cancel.qs');
|
|
113
|
+
self.reset();
|
|
114
|
+
break;
|
|
115
|
+
default:
|
|
116
|
+
self.filterResults();
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
this.input.keydown(function(event) {
|
|
122
|
+
switch (event.keyCode) {
|
|
123
|
+
case 33: // pgup
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
self.markFirst();
|
|
126
|
+
break;
|
|
127
|
+
case 34: // pgedown
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
self.markLast();
|
|
130
|
+
break;
|
|
131
|
+
case 38: // up
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
self.moveSelected(-1);
|
|
134
|
+
break;
|
|
135
|
+
case 40: // down
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
self.moveSelected(1);
|
|
138
|
+
break;
|
|
139
|
+
case 13: // return
|
|
140
|
+
case 27: // esc
|
|
141
|
+
event.preventDefault();
|
|
142
|
+
event.stopPropagation();
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
filterResults: function() {
|
|
149
|
+
var abbreviation = this.input.val();
|
|
150
|
+
if (abbreviation == this.lastAbbreviation) return;
|
|
151
|
+
|
|
152
|
+
this.results = $.map(this.cache, function(entry, index) {
|
|
153
|
+
var score = LiquidMetal.score(entry, abbreviation);
|
|
154
|
+
if (score > 0.0)
|
|
155
|
+
return { score: score, index: index };
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
this.sortResults();
|
|
159
|
+
this.renderDropdown();
|
|
160
|
+
this.markFirst();
|
|
161
|
+
this.lastAbbreviation = abbreviation;
|
|
162
|
+
this.picked = false;
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
sortResults: function() {
|
|
166
|
+
this.results.sort(function(a, b) { return b.score - a.score; });
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
renderDropdown: function() {
|
|
170
|
+
var self = this;
|
|
171
|
+
var list = this.resultList.html("");
|
|
172
|
+
$.each(this.results, function(i) {
|
|
173
|
+
if (self.settings.renderLimit != undefined && i >= self.settings.renderLimit) return false;
|
|
174
|
+
list.append(self.settings.renderResultRow(self.data[this.index]));
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
markSelected: function(n, scroll) {
|
|
179
|
+
if (n < 0 || n >= this.resultList.children().length) return;
|
|
180
|
+
this.selectedIndex = n;
|
|
181
|
+
|
|
182
|
+
var klass = this.settings.selectedClass;
|
|
183
|
+
var rows = this.resultList.find('li');
|
|
184
|
+
rows.removeClass(klass);
|
|
185
|
+
|
|
186
|
+
var selected = $(rows[n]).addClass(klass);
|
|
187
|
+
|
|
188
|
+
if (scroll != false && false) {
|
|
189
|
+
// Scroll result list to make the selected
|
|
190
|
+
this.resultContainer.scrollTop(
|
|
191
|
+
selected.offset().top -
|
|
192
|
+
this.resultContainer.offset().top +
|
|
193
|
+
this.resultContainer.scrollTop() +
|
|
194
|
+
(selected.height() / 2) -
|
|
195
|
+
(this.resultContainer.height() / 2)
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
pickSelected: function() {
|
|
201
|
+
var selected = this.results[this.selectedIndex];
|
|
202
|
+
if (selected) {
|
|
203
|
+
this.input.trigger('select.qs', [selected.index, this.data[selected.index]]);
|
|
204
|
+
} else {
|
|
205
|
+
this.reset();
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
moveSelected: function(n) { this.markSelected(this.selectedIndex+n); },
|
|
210
|
+
markFirst: function() { this.markSelected(0); },
|
|
211
|
+
markLast: function() { this.markSelected(this.results.length - 1); },
|
|
212
|
+
reset: function() { this.input.val(this.abbreviationBeforeFocus); },
|
|
213
|
+
focus: function() { this.input.focus(); },
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
})(jQuery);
|