dfect 0.0.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/LICENSE +15 -0
- data/doc/api/classes/Dfect.html +872 -0
- data/doc/api/classes/Object.html +72 -0
- data/doc/api/created.rid +1 -0
- data/doc/api/css/main.css +263 -0
- data/doc/api/css/panel.css +383 -0
- data/doc/api/css/reset.css +53 -0
- data/doc/api/files/ANN_txt.html +80 -0
- data/doc/api/files/LICENSE.html +74 -0
- data/doc/api/files/lib/dfect/auto_rb.html +78 -0
- data/doc/api/files/lib/dfect_rb.html +72 -0
- data/doc/api/i/arrows.png +0 -0
- data/doc/api/i/results_bg.png +0 -0
- data/doc/api/i/tree_bg.png +0 -0
- data/doc/api/index.html +14 -0
- data/doc/api/js/jquery-1.3.2.min.js +19 -0
- data/doc/api/js/jquery-effect.js +593 -0
- data/doc/api/js/main.js +22 -0
- data/doc/api/js/searchdoc.js +606 -0
- data/doc/api/panel/index.html +63 -0
- data/doc/api/panel/search_index.js +1 -0
- data/doc/api/panel/tree.js +1 -0
- data/doc/history.erb +4 -0
- data/doc/index.erb +6 -0
- data/doc/intro.erb +78 -0
- data/doc/setup.erb +34 -0
- data/doc/usage.erb +186 -0
- data/lib/dfect/auto.rb +24 -0
- data/lib/dfect.rb +621 -0
- data/rakefile +19 -0
- data/test/dfect.rb +146 -0
- metadata +95 -0
@@ -0,0 +1,606 @@
|
|
1
|
+
Searchdoc = {};
|
2
|
+
|
3
|
+
// navigation.js ------------------------------------------
|
4
|
+
|
5
|
+
Searchdoc.Navigation = new function() {
|
6
|
+
this.initNavigation = function() {
|
7
|
+
var _this = this;
|
8
|
+
|
9
|
+
$(document).keydown(function(e) {
|
10
|
+
_this.onkeydown(e);
|
11
|
+
}).keyup(function(e) {
|
12
|
+
_this.onkeyup(e);
|
13
|
+
});
|
14
|
+
|
15
|
+
this.navigationActive = true;
|
16
|
+
}
|
17
|
+
|
18
|
+
this.setNavigationActive = function(state) {
|
19
|
+
this.navigationActive = state;
|
20
|
+
this.clearMoveTimeout();
|
21
|
+
}
|
22
|
+
|
23
|
+
|
24
|
+
this.onkeyup = function(e) {
|
25
|
+
if (!this.navigationActive) return;
|
26
|
+
switch(e.keyCode) {
|
27
|
+
case 37: //Event.KEY_LEFT:
|
28
|
+
case 38: //Event.KEY_UP:
|
29
|
+
case 39: //Event.KEY_RIGHT:
|
30
|
+
case 40: //Event.KEY_DOWN:
|
31
|
+
this.clearMoveTimeout();
|
32
|
+
break;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
this.onkeydown = function(e) {
|
37
|
+
if (!this.navigationActive) return;
|
38
|
+
switch(e.keyCode) {
|
39
|
+
case 37: //Event.KEY_LEFT:
|
40
|
+
if (this.moveLeft())
|
41
|
+
e.preventDefault();
|
42
|
+
break;
|
43
|
+
case 38: //Event.KEY_UP:
|
44
|
+
if (this.moveUp())
|
45
|
+
e.preventDefault();
|
46
|
+
this.startMoveTimeout(false);
|
47
|
+
break;
|
48
|
+
case 39: //Event.KEY_RIGHT:
|
49
|
+
if (this.moveRight())
|
50
|
+
e.preventDefault();
|
51
|
+
break;
|
52
|
+
case 40: //Event.KEY_DOWN:
|
53
|
+
if (this.moveDown())
|
54
|
+
e.preventDefault();
|
55
|
+
this.startMoveTimeout(true);
|
56
|
+
break;
|
57
|
+
case 9: //Event.KEY_TAB:
|
58
|
+
case 13: //Event.KEY_RETURN:
|
59
|
+
if (this.$current) this.select(this.$current);
|
60
|
+
break;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
this.clearMoveTimeout = function() {
|
65
|
+
clearTimeout(this.moveTimeout);
|
66
|
+
this.moveTimeout = null;
|
67
|
+
}
|
68
|
+
|
69
|
+
this.startMoveTimeout = function(isDown) {
|
70
|
+
if (!$.browser.mozilla && !$.browser.opera) return;
|
71
|
+
if (this.moveTimeout) this.clearMoveTimeout();
|
72
|
+
var _this = this;
|
73
|
+
|
74
|
+
var go = function() {
|
75
|
+
if (!_this.moveTimeout) return;
|
76
|
+
_this[isDown ? 'moveDown' : 'moveUp']();
|
77
|
+
_this.moveTimout = setTimeout(go, 100);
|
78
|
+
}
|
79
|
+
this.moveTimeout = setTimeout(go, 200);
|
80
|
+
}
|
81
|
+
|
82
|
+
this.moveRight = function() {
|
83
|
+
}
|
84
|
+
|
85
|
+
this.moveLeft = function() {
|
86
|
+
}
|
87
|
+
|
88
|
+
this.move = function(isDown) {
|
89
|
+
}
|
90
|
+
|
91
|
+
this.moveUp = function() {
|
92
|
+
return this.move(false);
|
93
|
+
}
|
94
|
+
|
95
|
+
this.moveDown = function() {
|
96
|
+
return this.move(true);
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
|
101
|
+
// scrollIntoView.js --------------------------------------
|
102
|
+
|
103
|
+
function scrollIntoView(element, view) {
|
104
|
+
var offset, viewHeight, viewScroll, height;
|
105
|
+
offset = element.offsetTop;
|
106
|
+
height = element.offsetHeight;
|
107
|
+
viewHeight = view.offsetHeight;
|
108
|
+
viewScroll = view.scrollTop;
|
109
|
+
if (offset - viewScroll + height > viewHeight) {
|
110
|
+
view.scrollTop = offset - viewHeight + height;
|
111
|
+
}
|
112
|
+
if (offset < viewScroll) {
|
113
|
+
view.scrollTop = offset;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
// searcher.js --------------------------------------------
|
119
|
+
|
120
|
+
Searchdoc.Searcher = function(data) {
|
121
|
+
this.data = data;
|
122
|
+
this.handlers = [];
|
123
|
+
}
|
124
|
+
|
125
|
+
Searchdoc.Searcher.prototype = new function() {
|
126
|
+
var CHUNK_SIZE = 1000, // search is performed in chunks of 1000 for non-bloking user input
|
127
|
+
MAX_RESULTS = 100, // do not try to find more than 100 results
|
128
|
+
huid = 1, suid = 1,
|
129
|
+
runs = 0;
|
130
|
+
|
131
|
+
|
132
|
+
this.find = function(query) {
|
133
|
+
var queries = splitQuery(query),
|
134
|
+
regexps = buildRegexps(queries),
|
135
|
+
highlighters = buildHilighters(queries),
|
136
|
+
state = { from: 0, pass: 0, limit: MAX_RESULTS, n: suid++},
|
137
|
+
_this = this;
|
138
|
+
this.currentSuid = state.n;
|
139
|
+
|
140
|
+
if (!query) return;
|
141
|
+
|
142
|
+
var run = function() {
|
143
|
+
// stop current search thread if new search started
|
144
|
+
if (state.n != _this.currentSuid) return;
|
145
|
+
|
146
|
+
var results = performSearch(_this.data, regexps, queries, highlighters, state),
|
147
|
+
hasMore = (state.limit > 0 && state.pass < 3);
|
148
|
+
|
149
|
+
triggerResults.call(_this, results, !hasMore);
|
150
|
+
if (hasMore) {
|
151
|
+
setTimeout(run, 2);
|
152
|
+
}
|
153
|
+
runs++;
|
154
|
+
};
|
155
|
+
runs = 0;
|
156
|
+
|
157
|
+
// start search thread
|
158
|
+
run();
|
159
|
+
}
|
160
|
+
|
161
|
+
/* ----- Events ------ */
|
162
|
+
this.ready = function(fn) {
|
163
|
+
fn.huid = huid;
|
164
|
+
this.handlers.push(fn);
|
165
|
+
}
|
166
|
+
|
167
|
+
/* ----- Utilities ------ */
|
168
|
+
function splitQuery(query) {
|
169
|
+
return jQuery.grep(query.split(/(\s+|\(\)?)/), function(string) { return string.match(/\S/) });
|
170
|
+
}
|
171
|
+
|
172
|
+
function buildRegexps(queries) {
|
173
|
+
return jQuery.map(queries, function(query) { return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i') });
|
174
|
+
}
|
175
|
+
|
176
|
+
function buildHilighters(queries) {
|
177
|
+
return jQuery.map(queries, function(query) {
|
178
|
+
return jQuery.map( query.split(''), function(l, i){ return '\u0001$' + (i*2+1) + '\u0002$' + (i*2+2) } ).join('')
|
179
|
+
});
|
180
|
+
}
|
181
|
+
|
182
|
+
// function longMatchRegexp(index, longIndex, regexps) {
|
183
|
+
// for (var i = regexps.length - 1; i >= 0; i--){
|
184
|
+
// if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false;
|
185
|
+
// };
|
186
|
+
// return true;
|
187
|
+
// }
|
188
|
+
|
189
|
+
|
190
|
+
/* ----- Mathchers ------ */
|
191
|
+
function matchPass1(index, longIndex, queries, regexps) {
|
192
|
+
if (index.indexOf(queries[0]) != 0) return false;
|
193
|
+
for (var i=1, l = regexps.length; i < l; i++) {
|
194
|
+
if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false;
|
195
|
+
};
|
196
|
+
return true;
|
197
|
+
}
|
198
|
+
|
199
|
+
function matchPass2(index, longIndex, queries, regexps) {
|
200
|
+
if (index.indexOf(queries[0]) == -1) return false;
|
201
|
+
for (var i=1, l = regexps.length; i < l; i++) {
|
202
|
+
if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false;
|
203
|
+
};
|
204
|
+
return true;
|
205
|
+
}
|
206
|
+
|
207
|
+
function matchPassRegexp(index, longIndex, queries, regexps) {
|
208
|
+
if (!index.match(regexps[0])) return false;
|
209
|
+
for (var i=1, l = regexps.length; i < l; i++) {
|
210
|
+
if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false;
|
211
|
+
};
|
212
|
+
return true;
|
213
|
+
}
|
214
|
+
|
215
|
+
|
216
|
+
/* ----- Highlighters ------ */
|
217
|
+
function highlightRegexp(info, queries, regexps, highlighters) {
|
218
|
+
var result = createResult(info);
|
219
|
+
for (var i=0, l = regexps.length; i < l; i++) {
|
220
|
+
result.title = result.title.replace(regexps[i], highlighters[i]);
|
221
|
+
if (i > 0)
|
222
|
+
result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
|
223
|
+
};
|
224
|
+
return result;
|
225
|
+
}
|
226
|
+
|
227
|
+
function hltSubstring(string, pos, length) {
|
228
|
+
return string.substring(0, pos) + '\u0001' + string.substring(pos, pos + length) + '\u0002' + string.substring(pos + length);
|
229
|
+
}
|
230
|
+
|
231
|
+
function highlightQuery(info, queries, regexps, highlighters) {
|
232
|
+
var result = createResult(info), pos = 0, lcTitle = result.title.toLowerCase();
|
233
|
+
pos = lcTitle.indexOf(queries[0]);
|
234
|
+
if (pos != -1) {
|
235
|
+
result.title = hltSubstring(result.title, pos, queries[0].length);
|
236
|
+
}
|
237
|
+
for (var i=1, l = regexps.length; i < l; i++) {
|
238
|
+
result.title = result.title.replace(regexps[i], highlighters[i]);
|
239
|
+
result.namespace = result.namespace.replace(regexps[i], highlighters[i]);
|
240
|
+
};
|
241
|
+
return result;
|
242
|
+
}
|
243
|
+
|
244
|
+
function createResult(info) {
|
245
|
+
var result = {};
|
246
|
+
result.title = info[0];
|
247
|
+
result.namespace = info[1];
|
248
|
+
result.path = info[2];
|
249
|
+
result.params = info[3];
|
250
|
+
result.snippet = info[4];
|
251
|
+
result.badge = info[6];
|
252
|
+
return result;
|
253
|
+
}
|
254
|
+
|
255
|
+
/* ----- Searching ------ */
|
256
|
+
function performSearch(data, regexps, queries, highlighters, state) {
|
257
|
+
var searchIndex = data.searchIndex, // search by title first and then by source
|
258
|
+
longSearchIndex = data.longSearchIndex,
|
259
|
+
info = data.info,
|
260
|
+
result = [],
|
261
|
+
i = state.from,
|
262
|
+
l = searchIndex.length,
|
263
|
+
togo = CHUNK_SIZE,
|
264
|
+
matchFunc, hltFunc;
|
265
|
+
|
266
|
+
while (state.pass < 3 && state.limit > 0 && togo > 0) {
|
267
|
+
if (state.pass == 0) {
|
268
|
+
matchFunc = matchPass1;
|
269
|
+
hltFunc = highlightQuery;
|
270
|
+
} else if (state.pass == 1) {
|
271
|
+
matchFunc = matchPass2;
|
272
|
+
hltFunc = highlightQuery;
|
273
|
+
} else if (state.pass == 2) {
|
274
|
+
matchFunc = matchPassRegexp;
|
275
|
+
hltFunc = highlightRegexp;
|
276
|
+
}
|
277
|
+
|
278
|
+
for (; togo > 0 && i < l && state.limit > 0; i++, togo--) {
|
279
|
+
if (info[i].n == state.n) continue;
|
280
|
+
if (matchFunc(searchIndex[i], longSearchIndex[i], queries, regexps)) {
|
281
|
+
info[i].n = state.n;
|
282
|
+
result.push(hltFunc(info[i], queries, regexps, highlighters));
|
283
|
+
state.limit--;
|
284
|
+
}
|
285
|
+
};
|
286
|
+
if (searchIndex.length <= i) {
|
287
|
+
state.pass++;
|
288
|
+
i = state.from = 0;
|
289
|
+
} else {
|
290
|
+
state.from = i;
|
291
|
+
}
|
292
|
+
}
|
293
|
+
return result;
|
294
|
+
}
|
295
|
+
|
296
|
+
function triggerResults(results, isLast) {
|
297
|
+
jQuery.each(this.handlers, function(i, fn) { fn.call(this, results, isLast) })
|
298
|
+
}
|
299
|
+
}
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
// panel.js -----------------------------------------------
|
305
|
+
|
306
|
+
Searchdoc.Panel = function(element, data, tree, frame) {
|
307
|
+
this.$element = $(element);
|
308
|
+
this.$input = $('input', element).eq(0);
|
309
|
+
this.$result = $('.result ul', element).eq(0);
|
310
|
+
this.frame = frame;
|
311
|
+
this.$current = null;
|
312
|
+
this.$view = this.$result.parent();
|
313
|
+
this.data = data;
|
314
|
+
this.searcher = new Searchdoc.Searcher(data.index);
|
315
|
+
this.tree = new Searchdoc.Tree($('.tree', element), tree, this);
|
316
|
+
this.init();
|
317
|
+
}
|
318
|
+
|
319
|
+
Searchdoc.Panel.prototype = $.extend({}, Searchdoc.Navigation, new function() {
|
320
|
+
var suid = 1;
|
321
|
+
|
322
|
+
this.init = function() {
|
323
|
+
var _this = this;
|
324
|
+
var observer = function() {
|
325
|
+
_this.search(_this.$input[0].value);
|
326
|
+
};
|
327
|
+
this.$input.keyup(observer);
|
328
|
+
this.$input.click(observer); // mac's clear field
|
329
|
+
|
330
|
+
this.searcher.ready(function(results, isLast) {
|
331
|
+
_this.addResults(results, isLast);
|
332
|
+
})
|
333
|
+
|
334
|
+
this.$result.click(function(e) {
|
335
|
+
_this.$current.removeClass('current');
|
336
|
+
_this.$current = $(e.target).closest('li').addClass('current');
|
337
|
+
_this.select();
|
338
|
+
_this.$input.focus();
|
339
|
+
});
|
340
|
+
|
341
|
+
this.initNavigation();
|
342
|
+
this.setNavigationActive(false);
|
343
|
+
}
|
344
|
+
|
345
|
+
this.search = function(value) {
|
346
|
+
value = jQuery.trim(value).toLowerCase();
|
347
|
+
if (value) {
|
348
|
+
this.$element.removeClass('panel_tree').addClass('panel_results');
|
349
|
+
this.tree.setNavigationActive(false);
|
350
|
+
this.setNavigationActive(true);
|
351
|
+
} else {
|
352
|
+
this.$element.addClass('panel_tree').removeClass('panel_results');
|
353
|
+
this.tree.setNavigationActive(true);
|
354
|
+
this.setNavigationActive(false);
|
355
|
+
}
|
356
|
+
if (value != this.lastQuery) {
|
357
|
+
this.lastQuery = value;
|
358
|
+
this.firstRun = true;
|
359
|
+
this.searcher.find(value);
|
360
|
+
}
|
361
|
+
}
|
362
|
+
|
363
|
+
this.addResults = function(results, isLast) {
|
364
|
+
var target = this.$result.get(0);
|
365
|
+
if (this.firstRun && (results.length > 0 || isLast)) {
|
366
|
+
this.$current = null;
|
367
|
+
this.$result.empty();
|
368
|
+
}
|
369
|
+
for (var i=0, l = results.length; i < l; i++) {
|
370
|
+
target.appendChild(renderItem.call(this, results[i]));
|
371
|
+
};
|
372
|
+
if (this.firstRun && results.length > 0) {
|
373
|
+
this.firstRun = false;
|
374
|
+
this.$current = $(target.firstChild);
|
375
|
+
this.$current.addClass('current');
|
376
|
+
scrollIntoView(this.$current[0], this.$view[0])
|
377
|
+
}
|
378
|
+
if (jQuery.browser.msie) this.$element[0].className += '';
|
379
|
+
}
|
380
|
+
|
381
|
+
this.open = function(src) {
|
382
|
+
this.frame.location.href = '../' + src;
|
383
|
+
if (this.frame.highlight) this.frame.highlight(src);
|
384
|
+
}
|
385
|
+
|
386
|
+
this.select = function() {
|
387
|
+
this.open(this.$current.data('path'));
|
388
|
+
}
|
389
|
+
|
390
|
+
this.move = function(isDown) {
|
391
|
+
if (!this.$current) return;
|
392
|
+
var $next = this.$current[isDown ? 'next' : 'prev']();
|
393
|
+
if ($next.length) {
|
394
|
+
this.$current.removeClass('current');
|
395
|
+
$next.addClass('current');
|
396
|
+
scrollIntoView($next[0], this.$view[0]);
|
397
|
+
this.$current = $next;
|
398
|
+
}
|
399
|
+
return true;
|
400
|
+
}
|
401
|
+
|
402
|
+
function renderItem(result) {
|
403
|
+
var li = document.createElement('li'),
|
404
|
+
html = '', badge = result.badge;
|
405
|
+
html += '<h1>' + hlt(result.title);
|
406
|
+
if (result.params) html += '<i>' + result.params + '</i>';
|
407
|
+
html += '</h1>';
|
408
|
+
html += '<p>';
|
409
|
+
if (typeof badge != 'undefined') {
|
410
|
+
badge = badge % 6;
|
411
|
+
html += '<span class="badge badge_' + (badge + 1) + '">' + escapeHTML(this.data.badges[badge] || 'unknown') + '</span>';
|
412
|
+
}
|
413
|
+
html += hlt(result.namespace) + '</p>';
|
414
|
+
if (result.snippet) html += '<p class="snippet">' + escapeHTML(result.snippet) + '</p>';
|
415
|
+
li.innerHTML = html;
|
416
|
+
jQuery.data(li, 'path', result.path);
|
417
|
+
return li;
|
418
|
+
}
|
419
|
+
|
420
|
+
function hlt(html) {
|
421
|
+
return escapeHTML(html).replace(/\u0001/g, '<b>').replace(/\u0002/g, '</b>')
|
422
|
+
}
|
423
|
+
|
424
|
+
function escapeHTML(html) {
|
425
|
+
return html.replace(/[&<>]/g, function(c) {
|
426
|
+
return '&#' + c.charCodeAt(0) + ';';
|
427
|
+
});
|
428
|
+
}
|
429
|
+
|
430
|
+
});
|
431
|
+
|
432
|
+
// tree.js ------------------------------------------------
|
433
|
+
|
434
|
+
Searchdoc.Tree = function(element, tree, panel) {
|
435
|
+
this.$element = $(element);
|
436
|
+
this.$list = $('ul', element);
|
437
|
+
this.tree = tree;
|
438
|
+
this.panel = panel;
|
439
|
+
this.init();
|
440
|
+
}
|
441
|
+
|
442
|
+
Searchdoc.Tree.prototype = $.extend({}, Searchdoc.Navigation, new function() {
|
443
|
+
this.init = function() {
|
444
|
+
var stopper = document.createElement('li');
|
445
|
+
stopper.className = 'stopper';
|
446
|
+
this.$list[0].appendChild(stopper);
|
447
|
+
for (var i=0, l = this.tree.length; i < l; i++) {
|
448
|
+
buildAndAppendItem.call(this, this.tree[i], 0, stopper);
|
449
|
+
};
|
450
|
+
var _this = this;
|
451
|
+
this.$list.click(function(e) {
|
452
|
+
var $target = $(e.target),
|
453
|
+
$li = $target.closest('li');
|
454
|
+
if ($target.hasClass('icon')) {
|
455
|
+
_this.toggle($li);
|
456
|
+
} else {
|
457
|
+
_this.select($li);
|
458
|
+
}
|
459
|
+
})
|
460
|
+
|
461
|
+
this.initNavigation();
|
462
|
+
if (jQuery.browser.msie) document.body.className += '';
|
463
|
+
}
|
464
|
+
|
465
|
+
this.select = function($li) {
|
466
|
+
var path = $li[0].searchdoc_tree_data.path;
|
467
|
+
if (this.$current) this.$current.removeClass('current');
|
468
|
+
this.$current = $li.addClass('current');
|
469
|
+
if (path) this.panel.open(path);
|
470
|
+
}
|
471
|
+
|
472
|
+
this.toggle = function($li) {
|
473
|
+
var closed = !$li.hasClass('closed'),
|
474
|
+
children = $li[0].searchdoc_tree_data.children;
|
475
|
+
$li.toggleClass('closed');
|
476
|
+
for (var i=0, l = children.length; i < l; i++) {
|
477
|
+
toggleVis.call(this, $(children[i].li), !closed);
|
478
|
+
};
|
479
|
+
}
|
480
|
+
|
481
|
+
this.moveRight = function() {
|
482
|
+
if (!this.$current) {
|
483
|
+
this.select(this.$list.find('li:first'));
|
484
|
+
return;
|
485
|
+
}
|
486
|
+
if (this.$current.hasClass('closed')) {
|
487
|
+
this.toggle(this.$current);
|
488
|
+
}
|
489
|
+
}
|
490
|
+
|
491
|
+
this.moveLeft = function() {
|
492
|
+
if (!this.$current) {
|
493
|
+
this.select(this.$list.find('li:first'));
|
494
|
+
return;
|
495
|
+
}
|
496
|
+
if (!this.$current.hasClass('closed')) {
|
497
|
+
this.toggle(this.$current);
|
498
|
+
} else {
|
499
|
+
var level = this.$current[0].searchdoc_tree_data.level;
|
500
|
+
if (level == 0) return;
|
501
|
+
var $next = this.$current.prevAll('li.level_' + (level - 1) + ':visible:first');
|
502
|
+
this.$current.removeClass('current');
|
503
|
+
$next.addClass('current');
|
504
|
+
scrollIntoView($next[0], this.$element[0]);
|
505
|
+
this.$current = $next;
|
506
|
+
}
|
507
|
+
}
|
508
|
+
|
509
|
+
this.move = function(isDown) {
|
510
|
+
if (!this.$current) {
|
511
|
+
this.select(this.$list.find('li:first'));
|
512
|
+
return true;
|
513
|
+
}
|
514
|
+
var next = this.$current[0];
|
515
|
+
if (isDown) {
|
516
|
+
do {
|
517
|
+
next = next.nextSibling;
|
518
|
+
if (next && next.style && next.style.display != 'none') break;
|
519
|
+
} while(next);
|
520
|
+
} else {
|
521
|
+
do {
|
522
|
+
next = next.previousSibling;
|
523
|
+
if (next && next.style && next.style.display != 'none') break;
|
524
|
+
} while(next);
|
525
|
+
}
|
526
|
+
if (next && next.className.indexOf('stopper') == -1) {
|
527
|
+
this.$current.removeClass('current');
|
528
|
+
$(next).addClass('current');
|
529
|
+
scrollIntoView(next, this.$element[0]);
|
530
|
+
this.$current = $(next);
|
531
|
+
}
|
532
|
+
return true;
|
533
|
+
}
|
534
|
+
|
535
|
+
function toggleVis($li, show) {
|
536
|
+
var closed = $li.hasClass('closed'),
|
537
|
+
children = $li[0].searchdoc_tree_data.children;
|
538
|
+
$li.css('display', show ? '' : 'none')
|
539
|
+
if (!show && this.$current && $li[0] == this.$current[0]) {
|
540
|
+
this.$current.removeClass('current');
|
541
|
+
this.$current = null;
|
542
|
+
}
|
543
|
+
for (var i=0, l = children.length; i < l; i++) {
|
544
|
+
toggleVis.call(this, $(children[i].li), show && !closed);
|
545
|
+
};
|
546
|
+
}
|
547
|
+
|
548
|
+
function buildAndAppendItem(item, level, before) {
|
549
|
+
var li = renderItem(item, level),
|
550
|
+
list = this.$list[0];
|
551
|
+
item.li = li;
|
552
|
+
list.insertBefore(li, before);
|
553
|
+
for (var i=0, l = item[3].length; i < l; i++) {
|
554
|
+
buildAndAppendItem.call(this, item[3][i], level + 1, before);
|
555
|
+
};
|
556
|
+
return li;
|
557
|
+
}
|
558
|
+
|
559
|
+
function renderItem(item, level) {
|
560
|
+
var li = document.createElement('li'),
|
561
|
+
cnt = document.createElement('div'),
|
562
|
+
h1 = document.createElement('h1'),
|
563
|
+
p = document.createElement('p'),
|
564
|
+
icon, i;
|
565
|
+
|
566
|
+
li.appendChild(cnt);
|
567
|
+
li.style.paddingLeft = getOffset(level);
|
568
|
+
cnt.className = 'content';
|
569
|
+
if (!item[1]) li.className = 'empty ';
|
570
|
+
cnt.appendChild(h1);
|
571
|
+
// cnt.appendChild(p);
|
572
|
+
h1.appendChild(document.createTextNode(item[0]));
|
573
|
+
// p.appendChild(document.createTextNode(item[4]));
|
574
|
+
if (item[2]) {
|
575
|
+
i = document.createElement('i');
|
576
|
+
i.appendChild(document.createTextNode(item[2]));
|
577
|
+
h1.appendChild(i);
|
578
|
+
}
|
579
|
+
if (item[3].length > 0) {
|
580
|
+
icon = document.createElement('div');
|
581
|
+
icon.className = 'icon';
|
582
|
+
cnt.appendChild(icon);
|
583
|
+
}
|
584
|
+
|
585
|
+
// user direct assignement instead of $()
|
586
|
+
// it's 8x faster
|
587
|
+
// $(li).data('path', item[1])
|
588
|
+
// .data('children', item[3])
|
589
|
+
// .data('level', level)
|
590
|
+
// .css('display', level == 0 ? '' : 'none')
|
591
|
+
// .addClass('level_' + level)
|
592
|
+
// .addClass('closed');
|
593
|
+
li.searchdoc_tree_data = {
|
594
|
+
path: item[1],
|
595
|
+
children: item[3],
|
596
|
+
level: level
|
597
|
+
}
|
598
|
+
li.style.display = level == 0 ? '' : 'none';
|
599
|
+
li.className += 'level_' + level + ' closed';
|
600
|
+
return li;
|
601
|
+
}
|
602
|
+
|
603
|
+
function getOffset(level) {
|
604
|
+
return 5 + 18*level + 'px';
|
605
|
+
}
|
606
|
+
});
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
4
|
+
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
6
|
+
<head>
|
7
|
+
<title>layout</title>
|
8
|
+
<link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" charset="utf-8" />
|
9
|
+
<link rel="stylesheet" href="../css/panel.css" type="text/css" media="screen" charset="utf-8" />
|
10
|
+
<script src="search_index.js" type="text/javascript" charset="utf-8"></script>
|
11
|
+
<script src="tree.js" type="text/javascript" charset="utf-8"></script>
|
12
|
+
<script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
|
13
|
+
<script src="../js/searchdoc.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script type="text/javascript" charset="utf-8">
|
15
|
+
//<![CDATA[
|
16
|
+
function placeholder() {
|
17
|
+
if (jQuery.browser.safari) return;
|
18
|
+
$('#search-label').click(function() {
|
19
|
+
$('#search').focus();
|
20
|
+
$('#search-label').hide();
|
21
|
+
});
|
22
|
+
|
23
|
+
$('#search').focus(function() {
|
24
|
+
$('#search-label').hide();
|
25
|
+
});
|
26
|
+
$('#search').blur(function() {
|
27
|
+
this.value == '' && $('#search-label').show()
|
28
|
+
});
|
29
|
+
|
30
|
+
$('#search')[0].value == '' && $('#search-label').show();
|
31
|
+
|
32
|
+
setInterval(function() { $('#search')[0].value != '' && $('#search-label').hide() }, 100)
|
33
|
+
}
|
34
|
+
$(function() {
|
35
|
+
placeholder();
|
36
|
+
new Searchdoc.Panel($('#panel'), search_data, tree, top.frames[1]);
|
37
|
+
$('#search').focus();
|
38
|
+
})
|
39
|
+
//]]>
|
40
|
+
</script>
|
41
|
+
</head>
|
42
|
+
<body>
|
43
|
+
<div class="panel panel_tree" id="panel">
|
44
|
+
<div class="header">
|
45
|
+
<div>
|
46
|
+
<label for="search" id="search-label" style="display: none">Search</label>
|
47
|
+
<table>
|
48
|
+
<tr><td>
|
49
|
+
<input type="Search" placeholder="Search" autosave="searchdoc" results="10" id="search" autocomplete="off"/>
|
50
|
+
</td></tr>
|
51
|
+
</table></div>
|
52
|
+
</div>
|
53
|
+
<div class="tree">
|
54
|
+
<ul>
|
55
|
+
</ul>
|
56
|
+
</div>
|
57
|
+
<div class="result">
|
58
|
+
<ul>
|
59
|
+
</ul>
|
60
|
+
</div>
|
61
|
+
</div>
|
62
|
+
</body>
|
63
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
var search_data = {"index":{"searchIndex":["dfect","object","<()","<<()",">()",">>()","c()","d()","e()","f()","t()","run()","stop()","ann.txt","license","dfect.rb","auto.rb"],"longSearchIndex":["dfect.rb","auto.rb","dfect","dfect","dfect","dfect","dfect","dfect","dfect","dfect","dfect","dfect","dfect","files\/ann_txt.html","files\/license.html","files\/lib\/dfect_rb.html","files\/lib\/dfect\/auto_rb.html"],"info":[["Dfect","lib\/dfect.rb","classes\/Dfect.html","","",1],["Object","lib\/dfect\/auto.rb","classes\/Object.html"," < Object","",1],["<","Dfect","classes\/Dfect.html#M000001","(&block)","Registers the given block to be executed before each nested test inside this test. ==== Examples D .<",2],["<<","Dfect","classes\/Dfect.html#M000003","(&block)","Registers the given block to be executed before all nested tests inside this test. ==== Examples D .<<",2],[">","Dfect","classes\/Dfect.html#M000002","(&block)","Registers the given block to be executed after each nested test inside this test. ==== Examples D .>",2],[">>","Dfect","classes\/Dfect.html#M000004","(&block)","Registers the given block to be executed after all nested tests inside this test. ==== Examples D .>>",2],["C","Dfect","classes\/Dfect.html#M000008","(message = nil, symbol = nil, &block)","Asserts that the given symbol is thrown when the given block is executed, and returns the value that",2],["D","Dfect","classes\/Dfect.html#M000000","(description = caller.first, &block)","Defines a new test, composed of the given description and the given block to execute. A test may contain",2],["E","Dfect","classes\/Dfect.html#M000007","(message = nil, *kinds, &block)","Asserts that one of the given kinds of exceptions is raised when the given block is executed, and returns",2],["F","Dfect","classes\/Dfect.html#M000006","(message = 'block must yield false (nil || false)', &block)","Asserts that the result of the given block is either nil or false and returns that result. ==== Parameters",2],["T","Dfect","classes\/Dfect.html#M000005","(message = 'block must yield true (!nil && !false)', &block)","Asserts that the result of the given block is neither nil nor false and returns that result. ==== Parameters",2],["run","Dfect","classes\/Dfect.html#M000009","()","Executes all tests defined thus far and stores the results in #report. ",2],["stop","Dfect","classes\/Dfect.html#M000010","()","Stops the execution of the #run method or raises an exception if that method is not currently executing.",2],["ANN.txt","files\/ANN_txt.html","files\/ANN_txt.html",""," Dfect 0.0.0 Assertion testing library for Ruby ",3],["LICENSE","files\/LICENSE.html","files\/LICENSE.html","","(the ISC license) Copyright 2009 Suraj N. Kurapati <sunaku@gmail.com> Permission to use, copy, modify,",3],["dfect.rb","files\/lib\/dfect_rb.html","files\/lib\/dfect_rb.html",""," ",3],["auto.rb","files\/lib\/dfect\/auto_rb.html","files\/lib\/dfect\/auto_rb.html","","Provides painless, automatic configuration of Dfect. Simply require() this file and Dfect will be available",3]]}}
|
@@ -0,0 +1 @@
|
|
1
|
+
var tree = [["Dfect","classes\/Dfect.html","",[]],["Object","classes\/Object.html"," < Object",[]]]
|
data/doc/history.erb
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
%|chapter "History"
|
2
|
+
%|project_history
|
3
|
+
%|section "Version 0.0.0 (2009-04-13)"
|
4
|
+
This is the first public release of **<%= $project %>**, which was inspired by [Philip Plumlee's musing](http://www.ruby-forum.com/topic/183354#801895) on alternative names for assertion methods.
|