servus 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/.yardopts +6 -0
- data/CHANGELOG.md +7 -0
- data/IDEAS.md +5 -0
- data/READme.md +147 -42
- data/Rakefile +33 -0
- data/builds/servus-0.1.3.gem +0 -0
- data/builds/servus-0.1.4.gem +0 -0
- data/docs/core/1_overview.md +77 -0
- data/docs/core/2_architecture.md +92 -0
- data/docs/core/3_service_objects.md +121 -0
- data/docs/features/1_schema_validation.md +119 -0
- data/docs/features/2_error_handling.md +121 -0
- data/docs/features/3_async_execution.md +81 -0
- data/docs/features/4_logging.md +64 -0
- data/docs/guides/1_common_patterns.md +90 -0
- data/docs/guides/2_migration_guide.md +175 -0
- data/docs/integration/1_configuration.md +51 -0
- data/docs/integration/2_testing.md +164 -0
- data/docs/integration/3_rails_integration.md +99 -0
- data/docs/yard/Servus/Base.html +1645 -0
- data/docs/yard/Servus/Config.html +582 -0
- data/docs/yard/Servus/Extensions/Async/Call.html +400 -0
- data/docs/yard/Servus/Extensions/Async/Errors/AsyncError.html +140 -0
- data/docs/yard/Servus/Extensions/Async/Errors/JobEnqueueError.html +154 -0
- data/docs/yard/Servus/Extensions/Async/Errors/ServiceNotFoundError.html +154 -0
- data/docs/yard/Servus/Extensions/Async/Errors.html +128 -0
- data/docs/yard/Servus/Extensions/Async/Ext.html +119 -0
- data/docs/yard/Servus/Extensions/Async/Job.html +310 -0
- data/docs/yard/Servus/Extensions/Async.html +141 -0
- data/docs/yard/Servus/Extensions.html +117 -0
- data/docs/yard/Servus/Generators/ServiceGenerator.html +261 -0
- data/docs/yard/Servus/Generators.html +115 -0
- data/docs/yard/Servus/Helpers/ControllerHelpers.html +457 -0
- data/docs/yard/Servus/Helpers.html +115 -0
- data/docs/yard/Servus/Railtie.html +134 -0
- data/docs/yard/Servus/Support/Errors/AuthenticationError.html +287 -0
- data/docs/yard/Servus/Support/Errors/BadRequestError.html +283 -0
- data/docs/yard/Servus/Support/Errors/ForbiddenError.html +284 -0
- data/docs/yard/Servus/Support/Errors/InternalServerError.html +283 -0
- data/docs/yard/Servus/Support/Errors/NotFoundError.html +284 -0
- data/docs/yard/Servus/Support/Errors/ServiceError.html +489 -0
- data/docs/yard/Servus/Support/Errors/ServiceUnavailableError.html +290 -0
- data/docs/yard/Servus/Support/Errors/UnauthorizedError.html +200 -0
- data/docs/yard/Servus/Support/Errors/UnprocessableEntityError.html +288 -0
- data/docs/yard/Servus/Support/Errors/ValidationError.html +200 -0
- data/docs/yard/Servus/Support/Errors.html +140 -0
- data/docs/yard/Servus/Support/Logger.html +856 -0
- data/docs/yard/Servus/Support/Rescuer/BlockContext.html +585 -0
- data/docs/yard/Servus/Support/Rescuer/CallOverride.html +257 -0
- data/docs/yard/Servus/Support/Rescuer/ClassMethods.html +343 -0
- data/docs/yard/Servus/Support/Rescuer.html +267 -0
- data/docs/yard/Servus/Support/Response.html +574 -0
- data/docs/yard/Servus/Support/Validator.html +1150 -0
- data/docs/yard/Servus/Support.html +119 -0
- data/docs/yard/Servus/Testing/ExampleBuilders.html +523 -0
- data/docs/yard/Servus/Testing/ExampleExtractor.html +578 -0
- data/docs/yard/Servus/Testing.html +142 -0
- data/docs/yard/Servus.html +343 -0
- data/docs/yard/_index.html +535 -0
- data/docs/yard/class_list.html +54 -0
- data/docs/yard/css/common.css +1 -0
- data/docs/yard/css/full_list.css +58 -0
- data/docs/yard/css/style.css +503 -0
- data/docs/yard/file.1_common_patterns.html +154 -0
- data/docs/yard/file.1_configuration.html +115 -0
- data/docs/yard/file.1_overview.html +142 -0
- data/docs/yard/file.1_schema_validation.html +188 -0
- data/docs/yard/file.2_architecture.html +157 -0
- data/docs/yard/file.2_error_handling.html +190 -0
- data/docs/yard/file.2_migration_guide.html +242 -0
- data/docs/yard/file.2_testing.html +227 -0
- data/docs/yard/file.3_async_execution.html +145 -0
- data/docs/yard/file.3_rails_integration.html +160 -0
- data/docs/yard/file.3_service_objects.html +191 -0
- data/docs/yard/file.4_logging.html +135 -0
- data/docs/yard/file.ErrorHandling.html +190 -0
- data/docs/yard/file.READme.html +674 -0
- data/docs/yard/file.architecture.html +157 -0
- data/docs/yard/file.async_execution.html +145 -0
- data/docs/yard/file.common_patterns.html +154 -0
- data/docs/yard/file.configuration.html +115 -0
- data/docs/yard/file.error_handling.html +190 -0
- data/docs/yard/file.logging.html +135 -0
- data/docs/yard/file.migration_guide.html +242 -0
- data/docs/yard/file.overview.html +142 -0
- data/docs/yard/file.rails_integration.html +160 -0
- data/docs/yard/file.schema_validation.html +188 -0
- data/docs/yard/file.service_objects.html +191 -0
- data/docs/yard/file.testing.html +227 -0
- data/docs/yard/file_list.html +119 -0
- data/docs/yard/frames.html +22 -0
- data/docs/yard/index.html +674 -0
- data/docs/yard/js/app.js +344 -0
- data/docs/yard/js/full_list.js +242 -0
- data/docs/yard/js/jquery.js +4 -0
- data/docs/yard/method_list.html +542 -0
- data/docs/yard/top-level-namespace.html +110 -0
- data/lib/generators/servus/service/service_generator.rb +64 -1
- data/lib/generators/servus/service/templates/service.rb.erb +1 -1
- data/lib/servus/base.rb +258 -57
- data/lib/servus/config.rb +58 -12
- data/lib/servus/extensions/async/call.rb +50 -18
- data/lib/servus/extensions/async/errors.rb +23 -3
- data/lib/servus/extensions/async/ext.rb +10 -2
- data/lib/servus/extensions/async/job.rb +30 -9
- data/lib/servus/helpers/controller_helpers.rb +73 -37
- data/lib/servus/support/errors.rb +135 -45
- data/lib/servus/support/rescuer.rb +189 -36
- data/lib/servus/support/response.rb +49 -7
- data/lib/servus/support/validator.rb +120 -19
- data/lib/servus/testing/example_builders.rb +133 -0
- data/lib/servus/testing/example_extractor.rb +309 -0
- data/lib/servus/testing.rb +17 -0
- data/lib/servus/version.rb +1 -1
- metadata +117 -19
data/docs/yard/js/app.js
ADDED
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
(function () {
|
|
2
|
+
var localStorage = {},
|
|
3
|
+
sessionStorage = {};
|
|
4
|
+
try {
|
|
5
|
+
localStorage = window.localStorage;
|
|
6
|
+
} catch (e) {}
|
|
7
|
+
try {
|
|
8
|
+
sessionStorage = window.sessionStorage;
|
|
9
|
+
} catch (e) {}
|
|
10
|
+
|
|
11
|
+
function createSourceLinks() {
|
|
12
|
+
$(".method_details_list .source_code").before(
|
|
13
|
+
"<span class='showSource'>[<a href='#' class='toggleSource'>View source</a>]</span>"
|
|
14
|
+
);
|
|
15
|
+
$(".toggleSource").toggle(
|
|
16
|
+
function () {
|
|
17
|
+
$(this).parent().nextAll(".source_code").slideDown(100);
|
|
18
|
+
$(this).text("Hide source");
|
|
19
|
+
},
|
|
20
|
+
function () {
|
|
21
|
+
$(this).parent().nextAll(".source_code").slideUp(100);
|
|
22
|
+
$(this).text("View source");
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function createDefineLinks() {
|
|
28
|
+
var tHeight = 0;
|
|
29
|
+
$(".defines").after(" <a href='#' class='toggleDefines'>more...</a>");
|
|
30
|
+
$(".toggleDefines").toggle(
|
|
31
|
+
function () {
|
|
32
|
+
tHeight = $(this).parent().prev().height();
|
|
33
|
+
$(this).prev().css("display", "inline");
|
|
34
|
+
$(this).parent().prev().height($(this).parent().height());
|
|
35
|
+
$(this).text("(less)");
|
|
36
|
+
},
|
|
37
|
+
function () {
|
|
38
|
+
$(this).prev().hide();
|
|
39
|
+
$(this).parent().prev().height(tHeight);
|
|
40
|
+
$(this).text("more...");
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function createFullTreeLinks() {
|
|
46
|
+
var tHeight = 0;
|
|
47
|
+
$(".inheritanceTree").toggle(
|
|
48
|
+
function () {
|
|
49
|
+
tHeight = $(this).parent().prev().height();
|
|
50
|
+
$(this).parent().toggleClass("showAll");
|
|
51
|
+
$(this).text("(hide)");
|
|
52
|
+
$(this).parent().prev().height($(this).parent().height());
|
|
53
|
+
},
|
|
54
|
+
function () {
|
|
55
|
+
$(this).parent().toggleClass("showAll");
|
|
56
|
+
$(this).parent().prev().height(tHeight);
|
|
57
|
+
$(this).text("show all");
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function searchFrameButtons() {
|
|
63
|
+
$(".full_list_link").click(function () {
|
|
64
|
+
toggleSearchFrame(this, $(this).attr("href"));
|
|
65
|
+
return false;
|
|
66
|
+
});
|
|
67
|
+
window.addEventListener("message", function (e) {
|
|
68
|
+
if (e.data === "navEscape") {
|
|
69
|
+
$("#nav").slideUp(100);
|
|
70
|
+
$("#search a").removeClass("active inactive");
|
|
71
|
+
$(window).focus();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
$(window).resize(function () {
|
|
76
|
+
if ($("#search:visible").length === 0) {
|
|
77
|
+
$("#nav").removeAttr("style");
|
|
78
|
+
$("#search a").removeClass("active inactive");
|
|
79
|
+
$(window).focus();
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function toggleSearchFrame(id, link) {
|
|
85
|
+
var frame = $("#nav");
|
|
86
|
+
$("#search a").removeClass("active").addClass("inactive");
|
|
87
|
+
if (frame.attr("src") === link && frame.css("display") !== "none") {
|
|
88
|
+
frame.slideUp(100);
|
|
89
|
+
$("#search a").removeClass("active inactive");
|
|
90
|
+
} else {
|
|
91
|
+
$(id).addClass("active").removeClass("inactive");
|
|
92
|
+
if (frame.attr("src") !== link) frame.attr("src", link);
|
|
93
|
+
frame.slideDown(100);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function linkSummaries() {
|
|
98
|
+
$(".summary_signature").click(function () {
|
|
99
|
+
document.location = $(this).find("a").attr("href");
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function summaryToggle() {
|
|
104
|
+
$(".summary_toggle").click(function (e) {
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
localStorage.summaryCollapsed = $(this).text();
|
|
107
|
+
$(".summary_toggle").each(function () {
|
|
108
|
+
$(this).text($(this).text() == "collapse" ? "expand" : "collapse");
|
|
109
|
+
var next = $(this).parent().parent().nextAll("ul.summary").first();
|
|
110
|
+
if (next.hasClass("compact")) {
|
|
111
|
+
next.toggle();
|
|
112
|
+
next.nextAll("ul.summary").first().toggle();
|
|
113
|
+
} else if (next.hasClass("summary")) {
|
|
114
|
+
var list = $('<ul class="summary compact" />');
|
|
115
|
+
list.html(next.html());
|
|
116
|
+
list.find(".summary_desc, .note").remove();
|
|
117
|
+
list.find("a").each(function () {
|
|
118
|
+
$(this).html($(this).find("strong").html());
|
|
119
|
+
$(this).parent().html($(this)[0].outerHTML);
|
|
120
|
+
});
|
|
121
|
+
next.before(list);
|
|
122
|
+
next.toggle();
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return false;
|
|
126
|
+
});
|
|
127
|
+
if (localStorage.summaryCollapsed == "collapse") {
|
|
128
|
+
$(".summary_toggle").first().click();
|
|
129
|
+
} else {
|
|
130
|
+
localStorage.summaryCollapsed = "expand";
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function constantSummaryToggle() {
|
|
135
|
+
$(".constants_summary_toggle").click(function (e) {
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
localStorage.summaryCollapsed = $(this).text();
|
|
138
|
+
$(".constants_summary_toggle").each(function () {
|
|
139
|
+
$(this).text($(this).text() == "collapse" ? "expand" : "collapse");
|
|
140
|
+
var next = $(this).parent().parent().nextAll("dl.constants").first();
|
|
141
|
+
if (next.hasClass("compact")) {
|
|
142
|
+
next.toggle();
|
|
143
|
+
next.nextAll("dl.constants").first().toggle();
|
|
144
|
+
} else if (next.hasClass("constants")) {
|
|
145
|
+
var list = $('<dl class="constants compact" />');
|
|
146
|
+
list.html(next.html());
|
|
147
|
+
list.find("dt").each(function () {
|
|
148
|
+
$(this).addClass("summary_signature");
|
|
149
|
+
$(this).text($(this).text().split("=")[0]);
|
|
150
|
+
if ($(this).has(".deprecated").length) {
|
|
151
|
+
$(this).addClass("deprecated");
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
// Add the value of the constant as "Tooltip" to the summary object
|
|
155
|
+
list.find("pre.code").each(function () {
|
|
156
|
+
console.log($(this).parent());
|
|
157
|
+
var dt_element = $(this).parent().prev();
|
|
158
|
+
var tooltip = $(this).text();
|
|
159
|
+
if (dt_element.hasClass("deprecated")) {
|
|
160
|
+
tooltip = "Deprecated. " + tooltip;
|
|
161
|
+
}
|
|
162
|
+
dt_element.attr("title", tooltip);
|
|
163
|
+
});
|
|
164
|
+
list.find(".docstring, .tags, dd").remove();
|
|
165
|
+
next.before(list);
|
|
166
|
+
next.toggle();
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
return false;
|
|
170
|
+
});
|
|
171
|
+
if (localStorage.summaryCollapsed == "collapse") {
|
|
172
|
+
$(".constants_summary_toggle").first().click();
|
|
173
|
+
} else {
|
|
174
|
+
localStorage.summaryCollapsed = "expand";
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function generateTOC() {
|
|
179
|
+
if ($("#filecontents").length === 0) return;
|
|
180
|
+
var _toc = $('<ol class="top"></ol>');
|
|
181
|
+
var show = false;
|
|
182
|
+
var toc = _toc;
|
|
183
|
+
var counter = 0;
|
|
184
|
+
var tags = ["h2", "h3", "h4", "h5", "h6"];
|
|
185
|
+
var i;
|
|
186
|
+
var curli;
|
|
187
|
+
if ($("#filecontents h1").length > 1) tags.unshift("h1");
|
|
188
|
+
for (i = 0; i < tags.length; i++) {
|
|
189
|
+
tags[i] = "#filecontents " + tags[i];
|
|
190
|
+
}
|
|
191
|
+
var lastTag = parseInt(tags[0][1], 10);
|
|
192
|
+
$(tags.join(", ")).each(function () {
|
|
193
|
+
if ($(this).parents(".method_details .docstring").length != 0) return;
|
|
194
|
+
if (this.id == "filecontents") return;
|
|
195
|
+
show = true;
|
|
196
|
+
var thisTag = parseInt(this.tagName[1], 10);
|
|
197
|
+
if (this.id.length === 0) {
|
|
198
|
+
var proposedId = $(this).attr("toc-id");
|
|
199
|
+
if (typeof proposedId != "undefined") this.id = proposedId;
|
|
200
|
+
else {
|
|
201
|
+
var proposedId = $(this)
|
|
202
|
+
.text()
|
|
203
|
+
.replace(/[^a-z0-9-]/gi, "_");
|
|
204
|
+
if ($("#" + proposedId).length > 0) {
|
|
205
|
+
proposedId += counter;
|
|
206
|
+
counter++;
|
|
207
|
+
}
|
|
208
|
+
this.id = proposedId;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
if (thisTag > lastTag) {
|
|
212
|
+
for (i = 0; i < thisTag - lastTag; i++) {
|
|
213
|
+
if (typeof curli == "undefined") {
|
|
214
|
+
curli = $("<li/>");
|
|
215
|
+
toc.append(curli);
|
|
216
|
+
}
|
|
217
|
+
toc = $("<ol/>");
|
|
218
|
+
curli.append(toc);
|
|
219
|
+
curli = undefined;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (thisTag < lastTag) {
|
|
223
|
+
for (i = 0; i < lastTag - thisTag; i++) {
|
|
224
|
+
toc = toc.parent();
|
|
225
|
+
toc = toc.parent();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
var title = $(this).attr("toc-title");
|
|
229
|
+
if (typeof title == "undefined") title = $(this).text();
|
|
230
|
+
curli = $('<li><a href="#' + this.id + '">' + title + "</a></li>");
|
|
231
|
+
toc.append(curli);
|
|
232
|
+
lastTag = thisTag;
|
|
233
|
+
});
|
|
234
|
+
if (!show) return;
|
|
235
|
+
html =
|
|
236
|
+
'<div id="toc"><p class="title hide_toc"><a href="#"><strong>Table of Contents</strong></a></p></div>';
|
|
237
|
+
$("#content").prepend(html);
|
|
238
|
+
$("#toc").append(_toc);
|
|
239
|
+
$("#toc .hide_toc").toggle(
|
|
240
|
+
function () {
|
|
241
|
+
$("#toc .top").slideUp("fast");
|
|
242
|
+
$("#toc").toggleClass("hidden");
|
|
243
|
+
$("#toc .title small").toggle();
|
|
244
|
+
},
|
|
245
|
+
function () {
|
|
246
|
+
$("#toc .top").slideDown("fast");
|
|
247
|
+
$("#toc").toggleClass("hidden");
|
|
248
|
+
$("#toc .title small").toggle();
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function navResizeFn(e) {
|
|
254
|
+
if (e.which !== 1) {
|
|
255
|
+
navResizeFnStop();
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
sessionStorage.navWidth = e.pageX.toString();
|
|
260
|
+
$(".nav_wrap").css("width", e.pageX);
|
|
261
|
+
$(".nav_wrap").css("-ms-flex", "inherit");
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function navResizeFnStop() {
|
|
265
|
+
$(window).unbind("mousemove", navResizeFn);
|
|
266
|
+
window.removeEventListener("message", navMessageFn, false);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function navMessageFn(e) {
|
|
270
|
+
if (e.data.action === "mousemove") navResizeFn(e.data.event);
|
|
271
|
+
if (e.data.action === "mouseup") navResizeFnStop();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function navResizer() {
|
|
275
|
+
$("#resizer").mousedown(function (e) {
|
|
276
|
+
e.preventDefault();
|
|
277
|
+
$(window).mousemove(navResizeFn);
|
|
278
|
+
window.addEventListener("message", navMessageFn, false);
|
|
279
|
+
});
|
|
280
|
+
$(window).mouseup(navResizeFnStop);
|
|
281
|
+
|
|
282
|
+
if (sessionStorage.navWidth) {
|
|
283
|
+
navResizeFn({ which: 1, pageX: parseInt(sessionStorage.navWidth, 10) });
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function navExpander() {
|
|
288
|
+
if (typeof pathId === "undefined") return;
|
|
289
|
+
var done = false,
|
|
290
|
+
timer = setTimeout(postMessage, 500);
|
|
291
|
+
function postMessage() {
|
|
292
|
+
if (done) return;
|
|
293
|
+
clearTimeout(timer);
|
|
294
|
+
var opts = { action: "expand", path: pathId };
|
|
295
|
+
document.getElementById("nav").contentWindow.postMessage(opts, "*");
|
|
296
|
+
done = true;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
window.addEventListener(
|
|
300
|
+
"message",
|
|
301
|
+
function (event) {
|
|
302
|
+
if (event.data === "navReady") postMessage();
|
|
303
|
+
return false;
|
|
304
|
+
},
|
|
305
|
+
false
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function mainFocus() {
|
|
310
|
+
var hash = window.location.hash;
|
|
311
|
+
if (hash !== "" && $(hash)[0]) {
|
|
312
|
+
$(hash)[0].scrollIntoView();
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
setTimeout(function () {
|
|
316
|
+
$("#main").focus();
|
|
317
|
+
}, 10);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function navigationChange() {
|
|
321
|
+
// This works around the broken anchor navigation with the YARD template.
|
|
322
|
+
window.onpopstate = function () {
|
|
323
|
+
var hash = window.location.hash;
|
|
324
|
+
if (hash !== "" && $(hash)[0]) {
|
|
325
|
+
$(hash)[0].scrollIntoView();
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
$(document).ready(function () {
|
|
331
|
+
navResizer();
|
|
332
|
+
navExpander();
|
|
333
|
+
createSourceLinks();
|
|
334
|
+
createDefineLinks();
|
|
335
|
+
createFullTreeLinks();
|
|
336
|
+
searchFrameButtons();
|
|
337
|
+
linkSummaries();
|
|
338
|
+
summaryToggle();
|
|
339
|
+
constantSummaryToggle();
|
|
340
|
+
generateTOC();
|
|
341
|
+
mainFocus();
|
|
342
|
+
navigationChange();
|
|
343
|
+
});
|
|
344
|
+
})();
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
|
|
3
|
+
var $clicked = $(null);
|
|
4
|
+
var searchTimeout = null;
|
|
5
|
+
var searchCache = [];
|
|
6
|
+
var caseSensitiveMatch = false;
|
|
7
|
+
var ignoreKeyCodeMin = 8;
|
|
8
|
+
var ignoreKeyCodeMax = 46;
|
|
9
|
+
var commandKey = 91;
|
|
10
|
+
|
|
11
|
+
RegExp.escape = function(text) {
|
|
12
|
+
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function escapeShortcut() {
|
|
16
|
+
$(document).keydown(function(evt) {
|
|
17
|
+
if (evt.which == 27) {
|
|
18
|
+
window.parent.postMessage('navEscape', '*');
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function navResizer() {
|
|
24
|
+
$(window).mousemove(function(e) {
|
|
25
|
+
window.parent.postMessage({
|
|
26
|
+
action: 'mousemove', event: {pageX: e.pageX, which: e.which}
|
|
27
|
+
}, '*');
|
|
28
|
+
}).mouseup(function(e) {
|
|
29
|
+
window.parent.postMessage({action: 'mouseup'}, '*');
|
|
30
|
+
});
|
|
31
|
+
window.parent.postMessage("navReady", "*");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function clearSearchTimeout() {
|
|
35
|
+
clearTimeout(searchTimeout);
|
|
36
|
+
searchTimeout = null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function enableLinks() {
|
|
40
|
+
// load the target page in the parent window
|
|
41
|
+
$('#full_list li').on('click', function(evt) {
|
|
42
|
+
$('#full_list li').removeClass('clicked');
|
|
43
|
+
$clicked = $(this);
|
|
44
|
+
$clicked.addClass('clicked');
|
|
45
|
+
evt.stopPropagation();
|
|
46
|
+
|
|
47
|
+
if (evt.target.tagName === 'A') return true;
|
|
48
|
+
|
|
49
|
+
var elem = $clicked.find('> .item .object_link a')[0];
|
|
50
|
+
var e = evt.originalEvent;
|
|
51
|
+
var newEvent = new MouseEvent(evt.originalEvent.type);
|
|
52
|
+
newEvent.initMouseEvent(e.type, e.canBubble, e.cancelable, e.view, e.detail, e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.button, e.relatedTarget);
|
|
53
|
+
elem.dispatchEvent(newEvent);
|
|
54
|
+
evt.preventDefault();
|
|
55
|
+
return false;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function enableToggles() {
|
|
60
|
+
// show/hide nested classes on toggle click
|
|
61
|
+
$('#full_list a.toggle').on('click', function(evt) {
|
|
62
|
+
evt.stopPropagation();
|
|
63
|
+
evt.preventDefault();
|
|
64
|
+
$(this).parent().parent().toggleClass('collapsed');
|
|
65
|
+
$(this).attr('aria-expanded', function (i, attr) {
|
|
66
|
+
return attr == 'true' ? 'false' : 'true'
|
|
67
|
+
});
|
|
68
|
+
highlight();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// navigation of nested classes using keyboard
|
|
72
|
+
$('#full_list a.toggle').on('keypress',function(evt) {
|
|
73
|
+
// enter key is pressed
|
|
74
|
+
if (evt.which == 13) {
|
|
75
|
+
evt.stopPropagation();
|
|
76
|
+
evt.preventDefault();
|
|
77
|
+
$(this).parent().parent().toggleClass('collapsed');
|
|
78
|
+
$(this).attr('aria-expanded', function (i, attr) {
|
|
79
|
+
return attr == 'true' ? 'false' : 'true'
|
|
80
|
+
});
|
|
81
|
+
highlight();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function populateSearchCache() {
|
|
87
|
+
$('#full_list li .item').each(function() {
|
|
88
|
+
var $node = $(this);
|
|
89
|
+
var $link = $node.find('.object_link a');
|
|
90
|
+
if ($link.length > 0) {
|
|
91
|
+
searchCache.push({
|
|
92
|
+
node: $node,
|
|
93
|
+
link: $link,
|
|
94
|
+
name: $link.text(),
|
|
95
|
+
fullName: $link.attr('title').split(' ')[0]
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function enableSearch() {
|
|
102
|
+
$('#search input').keyup(function(event) {
|
|
103
|
+
if (ignoredKeyPress(event)) return;
|
|
104
|
+
if (this.value === "") {
|
|
105
|
+
clearSearch();
|
|
106
|
+
} else {
|
|
107
|
+
performSearch(this.value);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
$('#full_list').after("<div id='noresults' role='status' style='display: none'></div>");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function ignoredKeyPress(event) {
|
|
115
|
+
if (
|
|
116
|
+
(event.keyCode > ignoreKeyCodeMin && event.keyCode < ignoreKeyCodeMax) ||
|
|
117
|
+
(event.keyCode == commandKey)
|
|
118
|
+
) {
|
|
119
|
+
return true;
|
|
120
|
+
} else {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function clearSearch() {
|
|
126
|
+
clearSearchTimeout();
|
|
127
|
+
$('#full_list .found').removeClass('found').each(function() {
|
|
128
|
+
var $link = $(this).find('.object_link a');
|
|
129
|
+
$link.text($link.text());
|
|
130
|
+
});
|
|
131
|
+
$('#full_list, #content').removeClass('insearch');
|
|
132
|
+
$clicked.parents().removeClass('collapsed');
|
|
133
|
+
highlight();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function performSearch(searchString) {
|
|
137
|
+
clearSearchTimeout();
|
|
138
|
+
$('#full_list, #content').addClass('insearch');
|
|
139
|
+
$('#noresults').text('').hide();
|
|
140
|
+
partialSearch(searchString, 0);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function partialSearch(searchString, offset) {
|
|
144
|
+
var lastRowClass = '';
|
|
145
|
+
var i = null;
|
|
146
|
+
for (i = offset; i < Math.min(offset + 50, searchCache.length); i++) {
|
|
147
|
+
var item = searchCache[i];
|
|
148
|
+
var searchName = (searchString.indexOf('::') != -1 ? item.fullName : item.name);
|
|
149
|
+
var matchString = buildMatchString(searchString);
|
|
150
|
+
var matchRegexp = new RegExp(matchString, caseSensitiveMatch ? "" : "i");
|
|
151
|
+
if (searchName.match(matchRegexp) == null) {
|
|
152
|
+
item.node.removeClass('found');
|
|
153
|
+
item.link.text(item.link.text());
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
item.node.addClass('found');
|
|
157
|
+
item.node.removeClass(lastRowClass).addClass(lastRowClass == 'r1' ? 'r2' : 'r1');
|
|
158
|
+
lastRowClass = item.node.hasClass('r1') ? 'r1' : 'r2';
|
|
159
|
+
item.link.html(item.name.replace(matchRegexp, "<strong>$&</strong>"));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if(i == searchCache.length) {
|
|
163
|
+
searchDone();
|
|
164
|
+
} else {
|
|
165
|
+
searchTimeout = setTimeout(function() {
|
|
166
|
+
partialSearch(searchString, i);
|
|
167
|
+
}, 0);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function searchDone() {
|
|
172
|
+
searchTimeout = null;
|
|
173
|
+
highlight();
|
|
174
|
+
var found = $('#full_list li:visible').size();
|
|
175
|
+
if (found === 0) {
|
|
176
|
+
$('#noresults').text('No results were found.');
|
|
177
|
+
} else {
|
|
178
|
+
// This is read out to screen readers
|
|
179
|
+
$('#noresults').text('There are ' + found + ' results.');
|
|
180
|
+
}
|
|
181
|
+
$('#noresults').show();
|
|
182
|
+
$('#content').removeClass('insearch');
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function buildMatchString(searchString, event) {
|
|
186
|
+
caseSensitiveMatch = searchString.match(/[A-Z]/) != null;
|
|
187
|
+
var regexSearchString = RegExp.escape(searchString);
|
|
188
|
+
if (caseSensitiveMatch) {
|
|
189
|
+
regexSearchString += "|" +
|
|
190
|
+
$.map(searchString.split(''), function(e) { return RegExp.escape(e); }).
|
|
191
|
+
join('.+?');
|
|
192
|
+
}
|
|
193
|
+
return regexSearchString;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function highlight() {
|
|
197
|
+
$('#full_list li:visible').each(function(n) {
|
|
198
|
+
$(this).removeClass('even odd').addClass(n % 2 == 0 ? 'odd' : 'even');
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Expands the tree to the target element and its immediate
|
|
204
|
+
* children.
|
|
205
|
+
*/
|
|
206
|
+
function expandTo(path) {
|
|
207
|
+
var $target = $(document.getElementById('object_' + path));
|
|
208
|
+
$target.addClass('clicked');
|
|
209
|
+
$target.removeClass('collapsed');
|
|
210
|
+
$target.parentsUntil('#full_list', 'li').removeClass('collapsed');
|
|
211
|
+
|
|
212
|
+
$target.find('a.toggle').attr('aria-expanded', 'true')
|
|
213
|
+
$target.parentsUntil('#full_list', 'li').each(function(i, el) {
|
|
214
|
+
$(el).find('> div > a.toggle').attr('aria-expanded', 'true');
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
if($target[0]) {
|
|
218
|
+
window.scrollTo(window.scrollX, $target.offset().top - 250);
|
|
219
|
+
highlight();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function windowEvents(event) {
|
|
224
|
+
var msg = event.data;
|
|
225
|
+
if (msg.action === "expand") {
|
|
226
|
+
expandTo(msg.path);
|
|
227
|
+
}
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
window.addEventListener("message", windowEvents, false);
|
|
232
|
+
|
|
233
|
+
$(document).ready(function() {
|
|
234
|
+
escapeShortcut();
|
|
235
|
+
navResizer();
|
|
236
|
+
enableLinks();
|
|
237
|
+
enableToggles();
|
|
238
|
+
populateSearchCache();
|
|
239
|
+
enableSearch();
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
})();
|