source: main/trunk/model-cols-dev/peijones/js/annotator/pkg/annotator-full.min.js@ 25075

Last change on this file since 25075 was 25075, checked in by papitha, 12 years ago

jQuery-File-Upload added

File size: 82.3 KB
Line 
1(function () {
2 var h, o, b, p, n, i, l, a, e, d, c, r, s, j;
3 var m = Array.prototype.slice,
4 g = function (t, u) {
5 return function () {
6 return t.apply(u, arguments)
7 }
8 },
9 k = Object.prototype.hasOwnProperty,
10 q = function (w, u) {
11 for (var t in u) {
12 if (k.call(u, t)) {
13 w[t] = u[t]
14 }
15 }
16 function v() {
17 this.constructor = w
18 }
19 v.prototype = u.prototype;
20 w.prototype = new v;
21 w.__super__ = u.prototype;
22 return w
23 },
24 f = Array.prototype.indexOf ||
25 function (v) {
26 for (var u = 0, t = this.length; u < t; u++) {
27 if (this[u] === v) {
28 return u
29 }
30 }
31 return -1
32 };
33 if (!(typeof jQuery !== "undefined" && jQuery !== null ? (j = jQuery.fn) != null ? j.jquery : void 0 : void 0)) {
34 console.error("Annotator requires jQuery: have you included lib/vendor/jquery.js?")
35 }
36 if (!(JSON && JSON.parse && JSON.stringify)) {
37 console.error("Annotator requires a JSON implementation: have you included lib/vendor/json2.js?")
38 }
39 h = jQuery.sub();
40 h.flatten = function (u) {
41 var t;
42 t = function (w) {
43 var x, z, y, v;
44 z = [];
45 for (y = 0, v = w.length; y < v; y++) {
46 x = w[y];
47 z = z.concat(x && h.isArray(x) ? t(x) : x)
48 }
49 return z
50 };
51 return t(u)
52 };
53 h.plugin = function (u, t) {
54 return jQuery.fn[u] = function (w) {
55 var v;
56 v = Array.prototype.slice.call(arguments, 1);
57 return this.each(function () {
58 var x;
59 x = h.data(this, u);
60 if (x) {
61 return w && x[w].apply(x, v)
62 } else {
63 x = new t(this, w);
64 return h.data(this, u, x)
65 }
66 })
67 }
68 };
69 h.fn.textNodes = function () {
70 var t;
71 t = function (v) {
72 var u;
73 if (v && v.nodeType !== 3) {
74 u = [];
75 if (v.nodeType !== 8) {
76 v = v.lastChild;
77 while (v) {
78 u.push(t(v));
79 v = v.previousSibling
80 }
81 }
82 return u.reverse()
83 } else {
84 return v
85 }
86 };
87 return this.map(function () {
88 return h.flatten(t(this))
89 })
90 };
91 h.fn.xpath = function (t) {
92 var u;
93 u = this.map(function () {
94 var w, v, x;
95 x = "";
96 w = this;
97 while (w && w.nodeType === 1 && w !== t) {
98 v = h(w.parentNode).children(w.tagName).index(w) + 1;
99 v = v > 1 ? "[" + v + "]" : "";
100 x = "/" + w.tagName.toLowerCase() + v + x;
101 w = w.parentNode
102 }
103 return x
104 });
105 return u.get()
106 };
107 h.escape = function (t) {
108 return t.replace(/&(?!\w+;)/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;")
109 };
110 h.fn.escape = function (t) {
111 if (arguments.length) {
112 return this.html(h.escape(t))
113 }
114 return this.html()
115 };
116 l = ["log", "debug", "info", "warn", "exception", "assert", "dir", "dirxml", "trace", "group", "groupEnd", "groupCollapsed", "time", "timeEnd", "profile", "profileEnd", "count", "clear", "table", "error", "notifyFirebug", "firebug", "userObjects"];
117 if (typeof console !== "undefined" && console !== null) {
118 if (!(console.group != null)) {
119 console.group = function (t) {
120 return console.log("GROUP: ", t)
121 }
122 }
123 if (!(console.groupCollapsed != null)) {
124 console.groupCollapsed = console.group
125 }
126 for (d = 0, r = l.length; d < r; d++) {
127 i = l[d];
128 if (!(console[i] != null)) {
129 console[i] = function () {
130 return console.log("Not implemented: console." + name)
131 }
132 }
133 }
134 } else {
135 this.console = {};
136 for (c = 0, s = l.length; c < s; c++) {
137 i = l[c];
138 this.console[i] = function () {}
139 }
140 this.console.error = function () {
141 var t;
142 t = 1 <= arguments.length ? m.call(arguments, 0) : [];
143 return alert("ERROR: " + (t.join(", ")))
144 };
145 this.console.warn = function () {
146 var t;
147 t = 1 <= arguments.length ? m.call(arguments, 0) : [];
148 return alert("WARNING: " + (t.join(", ")))
149 }
150 }
151 b = (function () {
152 t.prototype.events = {};
153 t.prototype.options = {};
154 t.prototype.element = null;
155
156 function t(v, u) {
157 this.options = h.extend(true, {}, this.options, u);
158 this.element = h(v);
159 this.on = this.subscribe;
160 this.addEvents()
161 }
162 t.prototype.addEvents = function () {
163 var x, z, y, u, w, B, A, v;
164 B = this.events;
165 v = [];
166 for (y in B) {
167 z = B[y];
168 A = y.split(" "), u = 2 <= A.length ? m.call(A, 0, w = A.length - 1) : (w = 0, []), x = A[w++];
169 v.push(this.addEvent(u.join(" "), x, z))
170 }
171 return v
172 };
173 t.prototype.addEvent = function (u, w, x) {
174 var y, v;
175 y = g(function () {
176 return this[x].apply(this, arguments)
177 }, this);
178 v = typeof u === "string" && u.replace(/\s+/g, "") === "";
179 if (v) {
180 u = this.element
181 }
182 if (typeof u === "string") {
183 this.element.delegate(u, w, y)
184 } else {
185 if (this.isCustomEvent(w)) {
186 this.subscribe(w, y)
187 } else {
188 h(u).bind(w, y)
189 }
190 }
191 return this
192 };
193 t.prototype.isCustomEvent = function (v) {
194 var u;
195 u = "blur focus focusin focusout load resize scroll unload click dblclick\nmousedown mouseup mousemove mouseover mouseout mouseenter mouseleave\nchange select submit keydown keypress keyup error".split(/[^a-z]+/);
196 v = v.split(".")[0];
197 return h.inArray(v, u) === -1
198 };
199 t.prototype.publish = function () {
200 this.element.triggerHandler.apply(this.element, arguments);
201 return this
202 };
203 t.prototype.subscribe = function (u, w) {
204 var v;
205 v = function () {
206 return w.apply(this, [].slice.call(arguments, 1))
207 };
208 v.guid = w.guid = (h.guid += 1);
209 this.element.bind(u, v);
210 return this
211 };
212 t.prototype.unsubscribe = function () {
213 this.element.unbind.apply(this.element, arguments);
214 return this
215 };
216 return t
217 })();
218 p = {};
219 p.sniff = function (t) {
220 if (t.commonAncestorContainer != null) {
221 return new p.BrowserRange(t)
222 } else {
223 if (typeof t.start === "string") {
224 return new p.SerializedRange(t)
225 } else {
226 if (t.start && typeof t.start === "object") {
227 return new p.NormalizedRange(t)
228 } else {
229 console.error("Couldn't not sniff range type");
230 return false
231 }
232 }
233 }
234 };
235 p.BrowserRange = (function () {
236 function t(u) {
237 this.commonAncestorContainer = u.commonAncestorContainer;
238 this.startContainer = u.startContainer;
239 this.startOffset = u.startOffset;
240 this.endContainer = u.endContainer;
241 this.endOffset = u.endOffset
242 }
243 t.prototype.normalize = function (C) {
244 var B, x, D, A, w, v, z, u, y;
245 if (this.tainted) {
246 console.error("You may only call normalize() once on a BrowserRange!");
247 return false
248 } else {
249 this.tainted = true
250 }
251 v = {};
252 D = {};
253 y = ["start", "end"];
254 for (z = 0, u = y.length; z < u; z++) {
255 w = y[z];
256 x = this[w + "Container"];
257 A = this[w + "Offset"];
258 if (x.nodeType === 1) {
259 B = x.childNodes[A];
260 x = B || x.childNodes[A - 1];
261 while (x.nodeType !== 3) {
262 x = x.firstChild
263 }
264 A = B ? 0 : x.nodeValue.length
265 }
266 v[w] = x;
267 v[w + "Offset"] = A
268 }
269 D.start = v.startOffset > 0 ? v.start.splitText(v.startOffset) : v.start;
270 if (v.start === v.end) {
271 if ((v.endOffset - v.startOffset) < D.start.nodeValue.length) {
272 D.start.splitText(v.endOffset - v.startOffset)
273 }
274 D.end = D.start
275 } else {
276 if (v.endOffset < v.end.nodeValue.length) {
277 v.end.splitText(v.endOffset)
278 }
279 D.end = v.end
280 }
281 D.commonAncestor = this.commonAncestorContainer;
282 while (D.commonAncestor.nodeType !== 1) {
283 D.commonAncestor = D.commonAncestor.parentNode
284 }
285 return new p.NormalizedRange(D)
286 };
287 t.prototype.serialize = function (u, v) {
288 return this.normalize(u).serialize(u, v)
289 };
290 return t
291 })();
292 p.NormalizedRange = (function () {
293 function t(u) {
294 this.commonAncestor = u.commonAncestor;
295 this.start = u.start;
296 this.end = u.end
297 }
298 t.prototype.normalize = function (u) {
299 return this
300 };
301 t.prototype.limit = function (y) {
302 var u, x, v, w, A, z;
303 u = h.grep(this.textNodes(), function (B) {
304 return B.parentNode === y || h.contains(y, B.parentNode)
305 });
306 if (!u.length) {
307 return null
308 }
309 this.start = u[0];
310 this.end = u[u.length - 1];
311 v = h(this.start).parents();
312 z = h(this.end).parents();
313 for (w = 0, A = z.length; w < A; w++) {
314 x = z[w];
315 if (v.index(x) !== -1) {
316 this.commonAncestor = x;
317 break
318 }
319 }
320 return this
321 };
322 t.prototype.serialize = function (w, x) {
323 var v, u, y;
324 u = function (D, C) {
325 var B, A, F, I, H, G, E, z;
326 if (x) {
327 I = h(D).parents(":not(" + x + ")").eq(0)
328 } else {
329 I = h(D).parent()
330 }
331 G = I.xpath(w)[0];
332 H = I.textNodes();
333 A = H.slice(0, H.index(D));
334 F = 0;
335 for (E = 0, z = A.length; E < z; E++) {
336 B = A[E];
337 F += B.nodeValue.length
338 }
339 if (C) {
340 return [G, F + D.nodeValue.length]
341 } else {
342 return [G, F]
343 }
344 };
345 y = u(this.start);
346 v = u(this.end, true);
347 return new p.SerializedRange({
348 start: y[0],
349 end: v[0],
350 startOffset: y[1],
351 endOffset: v[1]
352 })
353 };
354 t.prototype.text = function () {
355 var u;
356 return ((function () {
357 var w, y, x, v;
358 x = this.textNodes();
359 v = [];
360 for (w = 0, y = x.length; w < y; w++) {
361 u = x[w];
362 v.push(u.nodeValue)
363 }
364 return v
365 }).call(this)).join("")
366 };
367 t.prototype.textNodes = function () {
368 var u, x, v, w;
369 v = h(this.commonAncestor).textNodes();
370 w = [v.index(this.start), v.index(this.end)], x = w[0], u = w[1];
371 return h.makeArray(v.slice(x, (u + 1) || 9000000000))
372 };
373 return t
374 })();
375 p.SerializedRange = (function () {
376 function t(u) {
377 this.start = u.start;
378 this.startOffset = u.startOffset;
379 this.end = u.end;
380 this.endOffset = u.endOffset
381 }
382 t.prototype._nodeFromXPath = function (u) {
383 var z, y, v, x, w;
384 y = function (B, A) {
385 if (A == null) {
386 A = null
387 }
388 return document.evaluate(B, document, A, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
389 };
390 if (!h.isXMLDoc(document.documentElement)) {
391 return y(u)
392 } else {
393 z = document.createNSResolver(document.ownerDocument === null ? document.documentElement : document.ownerDocument.documentElement);
394 x = y(u, z);
395 if (!x) {
396 u = ((function () {
397 var B, D, C, A;
398 C = u.split("/");
399 A = [];
400 for (B = 0, D = C.length; B < D; B++) {
401 w = C[B];
402 A.push(w && w.indexOf(":") === -1 ? w.replace(/^([a-z]+)/, "xhtml:$1") : w)
403 }
404 return A
405 })()).join("/");
406 v = document.lookupNamespaceURI(null);
407 z = function (A) {
408 if (A === "xhtml") {
409 return v
410 } else {
411 return document.documentElement.getAttribute("xmlns:" + A)
412 }
413 };
414 x = y(u, z)
415 }
416 return x
417 }
418 };
419 t.prototype.normalize = function (G) {
420 var K, D, C, I, A, F, H, E, B, z, v, u, L, J, y, x, w;
421 H = h(G).xpath()[0];
422 B = this.start.split("/");
423 C = this.end.split("/");
424 D = [];
425 E = {};
426 for (I = 0, y = B.length; 0 <= y ? I < y : I > y; 0 <= y ? I++ : I--) {
427 if (B[I] === C[I]) {
428 D.push(B[I])
429 } else {
430 break
431 }
432 }
433 K = H + D.join("/");
434 E.commonAncestorContainer = this._nodeFromXPath(K);
435 if (!E.commonAncestorContainer) {
436 console.error("Error deserializing range: can't find XPath '" + K + "'. Is this the right document?");
437 return null
438 }
439 x = ["start", "end"];
440 for (v = 0, L = x.length; v < L; v++) {
441 F = x[v];
442 A = 0;
443 w = h(this._nodeFromXPath(H + this[F])).textNodes();
444 for (u = 0, J = w.length; u < J; u++) {
445 z = w[u];
446 if (A + z.nodeValue.length >= this[F + "Offset"]) {
447 E[F + "Container"] = z;
448 E[F + "Offset"] = this[F + "Offset"] - A;
449 break
450 } else {
451 A += z.nodeValue.length
452 }
453 }
454 }
455 return new p.BrowserRange(E).normalize(G)
456 };
457 t.prototype.serialize = function (u, v) {
458 return this.normalize(u).serialize(u, v)
459 };
460 t.prototype.toObject = function () {
461 return {
462 start: this.start,
463 startOffset: this.startOffset,
464 end: this.end,
465 endOffset: this.endOffset
466 }
467 };
468 return t
469 })();
470 a = {
471 getGlobal: function () {
472 return (function () {
473 return this
474 })()
475 },
476 mousePosition: function (t, v) {
477 var u;
478 u = h(v).offset();
479 return {
480 top: t.pageY - u.top,
481 left: t.pageX - u.left
482 }
483 }
484 };
485 e = this.Annotator;
486 o = (function () {
487 q(t, b);
488 t.prototype.events = {
489 ".annotator-adder button click": "onAdderClick",
490 ".annotator-adder button mousedown": "onAdderMousedown",
491 ".annotator-hl mouseover": "onHighlightMouseover",
492 ".annotator-hl mouseout": "startViewerHideTimer"
493 };
494 t.prototype.html = {
495 hl: '<span class="annotator-hl"></span>',
496 adder: '<div class="annotator-adder"><button>Annotate</button></div>',
497 wrapper: '<div class="annotator-wrapper"></div>'
498 };
499 t.prototype.options = {};
500 t.prototype.plugins = {};
501 t.prototype.editor = null;
502 t.prototype.viewer = null;
503 t.prototype.selectedRanges = null;
504 t.prototype.mouseIsDown = false;
505 t.prototype.ignoreMouseup = false;
506 t.prototype.viewerHideTimer = null;
507
508 function t(w, v) {
509 this.onDeleteAnnotation = g(this.onDeleteAnnotation, this);
510 this.onEditAnnotation = g(this.onEditAnnotation, this);
511 this.onAdderClick = g(this.onAdderClick, this);
512 this.onAdderMousedown = g(this.onAdderMousedown, this);
513 this.onHighlightMouseover = g(this.onHighlightMouseover, this);
514 this.checkForEndSelection = g(this.checkForEndSelection, this);
515 this.checkForStartSelection = g(this.checkForStartSelection, this);
516 this.clearViewerHideTimer = g(this.clearViewerHideTimer, this);
517 this.startViewerHideTimer = g(this.startViewerHideTimer, this);
518 this.showViewer = g(this.showViewer, this);
519 this.onEditorSubmit = g(this.onEditorSubmit, this);
520 this.onEditorHide = g(this.onEditorHide, this);
521 this.showEditor = g(this.showEditor, this);
522 var u, x, y;
523 t.__super__.constructor.apply(this, arguments);
524 this.plugins = {};
525 if (!t.supported()) {
526 return this
527 }
528 this._setupDocumentEvents()._setupWrapper()._setupViewer()._setupEditor();
529 y = this.html;
530 for (u in y) {
531 x = y[u];
532 if (u !== "wrapper") {
533 this[u] = h(x).appendTo(this.wrapper).hide()
534 }
535 }
536 }
537 t.prototype._setupWrapper = function () {
538 this.wrapper = h(this.html.wrapper);
539 this.element.find("script").remove();
540 this.element.wrapInner(this.wrapper);
541 this.wrapper = this.element.find(".annotator-wrapper");
542 return this
543 };
544 t.prototype._setupViewer = function () {
545 this.viewer = new t.Viewer();
546 this.viewer.hide().on("edit", this.onEditAnnotation).on("delete", this.onDeleteAnnotation).addField({
547 load: g(function (v, u) {
548 h(v).escape(u.text || "");
549 return this.publish("annotationViewerTextField", [v, u])
550 }, this)
551 }).element.appendTo(this.wrapper).bind({
552 mouseover: this.clearViewerHideTimer,
553 mouseout: this.startViewerHideTimer
554 });
555 return this
556 };
557 t.prototype._setupEditor = function () {
558 this.editor = new t.Editor();
559 this.editor.hide().on("hide", this.onEditorHide).on("save", this.onEditorSubmit).addField({
560 type: "textarea",
561 label: "Comments\u2026",
562 load: function (v, u) {
563 return h(v).find("textarea").val(u.text || "")
564 },
565 submit: function (v, u) {
566 return u.text = h(v).find("textarea").val()
567 }
568 });
569 this.editor.element.appendTo(this.wrapper);
570 return this
571 };
572 t.prototype._setupDocumentEvents = function () {
573 h(document).bind({
574 mouseup: this.checkForEndSelection,
575 mousedown: this.checkForStartSelection
576 });
577 return this
578 };
579 t.prototype.getSelectedRanges = function () {
580 var x, v, u, w;
581 w = a.getGlobal().getSelection();
582 u = [];
583 if (!w.isCollapsed) {
584 u = (function () {
585 var z, y;
586 y = [];
587 for (v = 0, z = w.rangeCount; 0 <= z ? v < z : v > z; 0 <= z ? v++ : v--) {
588 x = new p.BrowserRange(w.getRangeAt(v));
589 y.push(x.normalize().limit(this.wrapper[0]))
590 }
591 return y
592 }).call(this)
593 }
594 return h.grep(u, function (y) {
595 return y
596 })
597 };
598 t.prototype.createAnnotation = function () {
599 var u;
600 u = {};
601 this.publish("beforeAnnotationCreated", [u]);
602 return u
603 };
604 t.prototype.setupAnnotation = function (u, w) {
605 var v, A, z, x, y, B;
606 if (w == null) {
607 w = true
608 }
609 u.ranges || (u.ranges = this.selectedRanges);
610 A = (function () {
611 var D, F, E, C;
612 E = u.ranges;
613 C = [];
614 for (D = 0, F = E.length; D < F; D++) {
615 z = E[D];
616 x = p.sniff(z);
617 C.push(x.normalize(this.wrapper[0]))
618 }
619
620 return C
621 }).call(this);
622 A = h.grep(A, function (C) {
623 return C !== null
624 });
625 u.quote = [];
626 u.ranges = [];
627 u.highlights = [];
628 for (y = 0, B = A.length; y < B; y++) {
629 v = A[y];
630 u.quote.push(h.trim(v.text()));
631 u.ranges.push(v.serialize(this.wrapper[0], ".annotator-hl"));
632 h.merge(u.highlights, this.highlightRange(v))
633 }
634 u.quote = u.quote.join(" / ");
635 h(u.highlights).data("annotation", u);
636 if (w) {
637 this.publish("annotationCreated", [u])
638 }
639
640 var rangeString = u.ranges[0].startOffset + "_" + u.ranges[0].endOffset;
641
642 /*
643 var found = false;
644 for(var i = 0; i < gs.annotationArray.keys.length; i++){if(gs.annotationArray.keys[i] == rangeString){found = true; break;}}
645
646 if(!found)
647 {
648 gs.annotationArray.keys.push(rangeString);
649 }
650 gs.annotationArray[rangeString] = u;
651 console.log("(setup) Adding " + u.quote + ", " + u.text + ", " + u.tags + " to " + rangeString);
652 showRebuildOption();
653 */
654 return u
655 };
656 t.prototype.updateAnnotation = function (u) {
657 this.publish("beforeAnnotationUpdated", [u]);
658 this.publish("annotationUpdated", [u]);
659 return u
660 };
661 t.prototype.deleteAnnotation = function (u) {
662 var w, v, y, x;
663 x = u.highlights;
664
665 for (v = 0, y = x.length; v < y; v++) {
666 w = x[v];
667 h(w).replaceWith(w.childNodes)
668 }
669
670 var rangeString = u.ranges[0].startOffset + "_" + u.ranges[0].endOffset;
671 gs.toDeleteArray[rangeString] = u;
672 gs.toDeleteArray.keys.push(rangeString);
673 gs.annotationArray[rangeString] = null;
674 showRebuildOption();
675 this.publish("annotationDeleted", [u]);
676 return u
677 };
678 t.prototype.loadAnnotations = function (v) {
679 var w, u;
680 if (v == null) {
681 v = []
682 }
683 u = g(function (z) {
684 var B, x, y, A;
685 if (z == null) {
686 z = []
687 }
688 x = z.splice(0, 10);
689 for (y = 0, A = x.length; y < A; y++) {
690 B = x[y];
691 this.setupAnnotation(B, false)
692 }
693 if (z.length > 0) {
694 return setTimeout((function () {
695 return u(z)
696 }), 100)
697 } else {
698 return this.publish("annotationsLoaded", [w])
699 }
700 }, this);
701 w = v.slice();
702 if (v.length) {
703 u(v)
704 }
705 return this
706 };
707 t.prototype.dumpAnnotations = function () {
708 if (this.plugins.Store) {
709 return this.plugins.Store.dumpAnnotations()
710 } else {
711 return console.warn("Can't dump annotations without Store plugin.")
712 }
713 };
714 t.prototype.highlightRange = function (v) {
715 var u, w, x;
716 return u = (function () {
717 var z, B, A, y;
718 A = v.textNodes();
719 y = [];
720 for (z = 0, B = A.length; z < B; z++) {
721 w = A[z];
722 x = this.hl.clone().show();
723 y.push(h(w).wrap(x).parent().get(0))
724 }
725 return y
726 }).call(this)
727 };
728 t.prototype.addPlugin = function (w, v) {
729 var u, x;
730 if (this.plugins[w]) {
731 console.error("You cannot have more than one instance of any plugin.")
732 } else {
733 u = t.Plugin[w];
734 if (typeof u === "function") {
735 this.plugins[w] = new u(this.element[0], v);
736 this.plugins[w].annotator = this;
737 if (typeof (x = this.plugins[w]).pluginInit === "function") {
738 x.pluginInit()
739 }
740 } else {
741 console.error("Could not load " + w + " plugin. Have you included the appropriate <script> tag?")
742 }
743 }
744 return this
745 };
746 t.prototype.showEditor = function (u, v) {
747 this.editor.element.css(v);
748 this.editor.load(u);
749 return this
750 };
751 t.prototype.onEditorHide = function () {
752 this.publish("annotationEditorHidden", [this.editor]);
753 return this.ignoreMouseup = false
754 };
755 t.prototype.onEditorSubmit = function (u) {
756 this.publish("annotationEditorSubmit", [this.editor, u]);
757 if (u.ranges === void 0) {
758 return this.setupAnnotation(u)
759 } else {
760 return this.updateAnnotation(u)
761 }
762 };
763 t.prototype.showViewer = function (v, u) {
764 this.viewer.element.css(u);
765 this.viewer.load(v);
766 return this.publish("annotationViewerShown", [this.viewer, v])
767 };
768 t.prototype.startViewerHideTimer = function () {
769 if (!this.viewerHideTimer) {
770 return this.viewerHideTimer = setTimeout(h.proxy(this.viewer.hide, this.viewer), 250)
771 }
772 };
773 t.prototype.clearViewerHideTimer = function () {
774 clearTimeout(this.viewerHideTimer);
775 return this.viewerHideTimer = false
776 };
777 t.prototype.checkForStartSelection = function (u) {
778 if (!(u && this.isAnnotator(u.target))) {
779 this.startViewerHideTimer();
780 return this.mouseIsDown = true
781 }
782 };
783 t.prototype.checkForEndSelection = function (x) {
784 var u, v, w, z, y;
785 this.mouseIsDown = false;
786 if (this.ignoreMouseup) {
787 return
788 }
789 this.selectedRanges = this.getSelectedRanges();
790 y = this.selectedRanges;
791 for (w = 0, z = y.length; w < z; w++) {
792 v = y[w];
793 u = v.commonAncestor;
794 if (this.isAnnotator(u)) {
795 return
796 }
797 }
798 if (x && this.selectedRanges.length) {
799 return this.adder.css(a.mousePosition(x, this.wrapper[0])).show()
800 } else {
801 return this.adder.hide()
802 }
803 };
804 t.prototype.isAnnotator = function (u) {
805 return !!h(u).parents().andSelf().filter("[class^=annotator-]").not(this.wrapper).length
806 };
807 t.prototype.onHighlightMouseover = function (u) {
808 var v;
809 this.clearViewerHideTimer();
810 if (this.mouseIsDown || this.viewer.isShown()) {
811 return false
812 }
813 v = h(u.target).parents(".annotator-hl").andSelf().map(function () {
814 return h(this).data("annotation")
815 });
816 return this.showViewer(h.makeArray(v), a.mousePosition(u, this.wrapper[0]))
817 };
818 t.prototype.onAdderMousedown = function (u) {
819 if (u != null) {
820 u.preventDefault()
821 }
822 return this.ignoreMouseup = true
823 };
824 t.prototype.onAdderClick = function (v) {
825 var u;
826 if (v != null) {
827 v.preventDefault()
828 }
829 u = this.adder.position();
830 this.adder.hide();
831 return this.showEditor(this.createAnnotation(), u)
832 };
833 t.prototype.onEditAnnotation = function (u) {
834 var v;
835 v = this.viewer.element.position();
836 this.viewer.hide();
837 return this.showEditor(u, v)
838 };
839 t.prototype.onDeleteAnnotation = function (u) {
840 this.viewer.hide();
841 return this.deleteAnnotation(u)
842 };
843 return t
844 })();
845 o.Plugin = (function () {
846 q(t, b);
847
848 function t(v, u) {
849 t.__super__.constructor.apply(this, arguments)
850 }
851 t.prototype.pluginInit = function () {};
852 return t
853 })();
854 o.$ = h;
855 o.supported = function () {
856 return (function () {
857 return !!this.getSelection
858 })()
859 };
860 o.noConflict = function () {
861 a.getGlobal().Annotator = e;
862 return this
863 };
864 h.plugin("annotator", o);
865 this.Annotator = o;
866 o.Widget = (function () {
867 q(t, b);
868 t.prototype.classes = {
869 hide: "annotator-hide",
870 invert: {
871 x: "annotator-invert-x",
872 y: "annotator-invert-y"
873 }
874 };
875
876 function t(v, u) {
877 t.__super__.constructor.apply(this, arguments);
878 this.classes = h.extend({}, o.Widget.prototype.classes, this.classes)
879 }
880 t.prototype.checkOrientation = function () {
881 var x, y, u, w, v;
882 this.resetOrientation();
883 v = h(a.getGlobal());
884 w = this.element.children(":first");
885 y = w.offset();
886 u = {
887 top: v.scrollTop(),
888 right: v.width() + v.scrollLeft()
889 };
890 x = {
891 top: y.top,
892 right: y.left + w.width()
893 };
894 if ((x.top - u.top) < 0) {
895 this.invertY()
896 }
897 if ((x.right - u.right) > 0) {
898 this.invertX()
899 }
900 return this
901 };
902 t.prototype.resetOrientation = function () {
903 this.element.removeClass(this.classes.invert.x).removeClass(this.classes.invert.y);
904 return this
905 };
906 t.prototype.invertX = function () {
907 this.element.addClass(this.classes.invert.x);
908 return this
909 };
910 t.prototype.invertY = function () {
911 this.element.addClass(this.classes.invert.y);
912 return this
913 };
914 return t
915 })();
916 o.Editor = (function () {
917 q(t, o.Widget);
918 t.prototype.events = {
919 "form submit": "submit",
920 ".annotator-save click": "submit",
921 ".annotator-cancel click": "hide",
922 ".annotator-cancel mouseover": "onCancelButtonMouseover",
923 "textarea keydown": "processKeypress"
924 };
925 t.prototype.classes = {
926 hide: "annotator-hide",
927 focus: "annotator-focus"
928 };
929 t.prototype.html = '<div class="annotator-outer annotator-editor">\n <form class="annotator-widget">\n <ul class="annotator-listing"></ul>\n <div class="annotator-controls">\n <a href="#cancel" class="annotator-cancel">Cancel</a>\n <a href="#save" class="annotator-save annotator-focus">Save</a>\n </div>\n <span class="annotator-resize"></span>\n </form>\n</div>';
930 t.prototype.options = {};
931
932 function t(u) {
933 this.onCancelButtonMouseover = g(this.onCancelButtonMouseover, this);
934 this.processKeypress = g(this.processKeypress, this);
935 this.submit = g(this.submit, this);
936 this.load = g(this.load, this);
937 this.hide = g(this.hide, this);
938 this.show = g(this.show, this);
939 t.__super__.constructor.call(this, h(this.html)[0], u);
940 this.fields = [];
941 this.annotation = {};
942 this.setupDragabbles()
943 }
944 t.prototype.show = function (u) {
945 if (u != null) {
946 u.preventDefault()
947 }
948 this.element.removeClass(this.classes.hide);
949 this.element.find(".annotator-save").addClass(this.classes.focus);
950 this.element.find(":input:first").focus();
951 return this.checkOrientation().publish("show")
952 };
953 t.prototype.hide = function (u) {
954 if (u != null) {
955 u.preventDefault()
956 }
957 this.element.addClass(this.classes.hide);
958 return this.publish("hide")
959 };
960 t.prototype.load = function (u) {
961 var w, v, y, x;
962 this.annotation = u;
963 this.publish("load", [this.annotation]);
964 x = this.fields;
965 for (v = 0, y = x.length; v < y; v++) {
966 w = x[v];
967 w.load(w.element, this.annotation)
968 }
969 return this.show()
970 };
971 t.prototype.submit = function (v) {
972 var w, u, y, x;
973 if (v != null) {
974 v.preventDefault()
975 }
976 x = this.fields;
977 for (u = 0, y = x.length; u < y; u++) {
978 w = x[u];
979 w.submit(w.element, this.annotation)
980 }
981 this.publish("save", [this.annotation]);
982 return this.hide()
983 };
984 t.prototype.addField = function (v) {
985 var w, x, u;
986 x = h.extend({
987 id: "annotator-field-" + (new Date()).getTime(),
988 type: "input",
989 label: "",
990 load: function () {},
991 submit: function () {}
992 }, v);
993 u = null;
994 w = h('<li class="annotator-item" />');
995 x.element = w[0];
996 switch (x.type) {
997 case "textarea":
998 u = h("<textarea />");
999 break;
1000 case "input":
1001 case "checkbox":
1002 u = h("<input />")
1003 }
1004 w.append(u);
1005 u.attr({
1006 id: x.id,
1007 placeholder: x.label
1008 });
1009 if (x.type === "checkbox") {
1010 u[0].type = "checkbox";
1011 w.addClass("annotator-checkbox");
1012 w.append(h("<label />", {
1013 "for": x.id,
1014 html: x.label
1015 }))
1016 }
1017 this.element.find("ul:first").append(w);
1018 this.fields.push(x);
1019 return x.element
1020 };
1021 t.prototype.checkOrientation = function () {
1022 var u, w, v;
1023 t.__super__.checkOrientation.apply(this, arguments);
1024 v = this.element.find("ul");
1025 u = this.element.find(".annotator-controls");
1026 w = function () {
1027 return v.children().each(function () {
1028 return h(this).parent().prepend(this)
1029 })
1030 };
1031 if (this.element.hasClass(this.classes.invert.y) && v.is(":first-child")) {
1032 u.insertBefore(v);
1033 w()
1034 } else {
1035 if (u.is(":first-child")) {
1036 u.insertAfter(v);
1037 w()
1038 }
1039 }
1040 return this
1041 };
1042 t.prototype.processKeypress = function (u) {
1043 if (u.keyCode === 27) {
1044 return this.hide()
1045 } else {
1046 if (u.keyCode === 13 && !u.shiftKey) {
1047 return this.submit()
1048 }
1049 }
1050 };
1051 t.prototype.onCancelButtonMouseover = function () {
1052 return this.element.find("." + this.classes.focus).removeClass(this.classes.focus)
1053 };
1054 t.prototype.setupDragabbles = function () {
1055 var w, D, z, u, y, B, x, v, A, C;
1056 u = null;
1057 w = this.classes;
1058 z = this.element;
1059 A = null;
1060 v = z.find(".annotator-resize");
1061 D = z.find(".annotator-controls");
1062 C = false;
1063 y = function (E) {
1064 if (E.target === this) {
1065 u = {
1066 element: this,
1067 top: E.pageY,
1068 left: E.pageX
1069 };
1070 A = z.find("textarea:first");
1071 h(window).bind({
1072 "mouseup.annotator-editor-resize": x,
1073 "mousemove.annotator-editor-resize": B
1074 });
1075 return E.preventDefault()
1076 }
1077 };
1078 x = function () {
1079 u = null;
1080 return h(window).unbind(".annotator-editor-resize")
1081 };
1082 B = g(function (I) {
1083 var J, G, F, E, H;
1084 if (u && C === false) {
1085 J = {
1086 top: I.pageY - u.top,
1087 left: I.pageX - u.left
1088 };
1089 if (u.element === v[0]) {
1090 E = A.outerHeight();
1091 H = A.outerWidth();
1092 G = z.hasClass(w.invert.x) ? -1 : 1;
1093 F = z.hasClass(w.invert.y) ? 1 : -1;
1094 A.height(E + (J.top * F));
1095 A.width(H + (J.left * G));
1096 if (A.outerHeight() !== E) {
1097 u.top = I.pageY
1098 }
1099 if (A.outerWidth() !== H) {
1100 u.left = I.pageX
1101 }
1102 } else {
1103 if (u.element === D[0]) {
1104 z.css({
1105 top: parseInt(z.css("top"), 10) + J.top,
1106 left: parseInt(z.css("left"), 10) + J.left
1107 });
1108 u.top = I.pageY;
1109 u.left = I.pageX
1110 }
1111 }
1112 C = true;
1113 return setTimeout(function () {
1114 return C = false
1115 }, 1000 / 60)
1116 }
1117 }, this);
1118 v.bind("mousedown", y);
1119 return D.bind("mousedown", y)
1120 };
1121 return t
1122 })();
1123 o.Viewer = (function () {
1124 q(t, o.Widget);
1125 t.prototype.events = {
1126 ".annotator-edit click": "onEditClick",
1127 ".annotator-delete click": "onDeleteClick"
1128 };
1129 t.prototype.classes = {
1130 hide: "annotator-hide",
1131 showControls: "annotator-visible"
1132 };
1133 t.prototype.html = {
1134 element: '<div class="annotator-outer annotator-viewer">\n <ul class="annotator-widget annotator-listing"></ul>\n</div>',
1135 item: '<li class="annotator-annotation annotator-item">\n <span class="annotator-controls">\n <button class="annotator-edit">Edit</button>\n <button class="annotator-delete">Delete</button>\n </span>\n</li>'
1136 };
1137
1138 function t(u) {
1139 this.onDeleteClick = g(this.onDeleteClick, this);
1140 this.onEditClick = g(this.onEditClick, this);
1141 this.load = g(this.load, this);
1142 this.hide = g(this.hide, this);
1143 this.show = g(this.show, this);
1144 t.__super__.constructor.call(this, h(this.html.element)[0], u);
1145 this.item = h(this.html.item)[0];
1146 this.fields = [];
1147 this.annotations = []
1148 }
1149 t.prototype.show = function (v) {
1150 var u;
1151 if (v != null) {
1152 v.preventDefault()
1153 }
1154 u = this.element.find(".annotator-controls").addClass(this.classes.showControls);
1155 setTimeout((g(function () {
1156 return u.removeClass(this.classes.showControls)
1157 }, this)), 500);
1158 this.element.removeClass(this.classes.hide);
1159 return this.checkOrientation().publish("show")
1160 };
1161 t.prototype.isShown = function () {
1162 return !this.element.hasClass(this.classes.hide)
1163 };
1164 t.prototype.hide = function (u) {
1165 if (u != null) {
1166 //u.preventDefault()
1167 }
1168 this.element.addClass(this.classes.hide);
1169 return this.publish("hide")
1170 };
1171 t.prototype.load = function (C) {
1172 var z, B, G, H, F, A, E, I, D, y, w, u, J, x, v;
1173 this.annotations = C || [];
1174 D = this.element.find("ul:first").empty();
1175 x = this.annotations;
1176 for (y = 0, u = x.length; y < u; y++) {
1177 z = x[y];
1178 I = h(this.item).clone().appendTo(D).data("annotation", z);
1179 G = I.find(".annotator-controls");
1180 F = G.find(".annotator-edit");
1181 H = G.find(".annotator-delete");
1182 B = {
1183 showEdit: function () {
1184 return F.removeAttr("disabled")
1185 },
1186 hideEdit: function () {
1187 return F.attr("disabled", "disabled")
1188 },
1189 showDelete: function () {
1190 return H.removeAttr("disabled")
1191 },
1192 hideDelete: function () {
1193 return H.attr("disabled", "disabled")
1194 }
1195 };
1196 v = this.fields;
1197 for (w = 0, J = v.length; w < J; w++) {
1198 E = v[w];
1199 A = h(E.element).clone().appendTo(I)[0];
1200 E.load(A, z, B)
1201 }
1202 }
1203 this.publish("load", [this.annotations]);
1204 return this.show()
1205 };
1206 t.prototype.addField = function (u) {
1207 var v;
1208 v = h.extend({
1209 load: function () {}
1210 }, u);
1211 v.element = h("<div />")[0];
1212 this.fields.push(v);
1213 v.element;
1214 return this
1215 };
1216 t.prototype.onEditClick = function (u) {
1217 return this.onButtonClick(u, "edit")
1218 };
1219 t.prototype.onDeleteClick = function (u) {
1220 return this.onButtonClick(u, "delete")
1221 };
1222 t.prototype.onButtonClick = function (w, u) {
1223 var v;
1224 v = h(w.target).parents(".annotator-annotation");
1225 return this.publish(u, [v.data("annotation")])
1226 };
1227 return t
1228 })();
1229 o = o || {};
1230 o.Notification = (function () {
1231 q(t, b);
1232 t.prototype.events = {
1233 click: "hide"
1234 };
1235 t.prototype.options = {
1236 html: "<div class='annotator-notice'></div>",
1237 classes: {
1238 show: "annotator-notice-show",
1239 info: "annotator-notice-info",
1240 success: "annotator-notice-success",
1241 error: "annotator-notice-error"
1242 }
1243 };
1244
1245 function t(u) {
1246 this.hide = g(this.hide, this);
1247 this.show = g(this.show, this);
1248 t.__super__.constructor.call(this, h(this.options.html).appendTo(document.body)[0], u)
1249 }
1250 t.prototype.show = function (v, u) {
1251 if (u == null) {
1252 u = o.Notification.INFO
1253 }
1254 h(this.element).addClass(this.options.classes.show).addClass(this.options.classes[u]).escape(v || "");
1255 setTimeout(this.hide, 5000);
1256 return this
1257 };
1258 t.prototype.hide = function () {
1259 h(this.element).removeClass(this.options.classes.show);
1260 return this
1261 };
1262 return t
1263 })();
1264 o.Notification.INFO = "show";
1265 o.Notification.SUCCESS = "success";
1266 o.Notification.ERROR = "error";
1267 h(function () {
1268 var t;
1269 t = new o.Notification;
1270 o.showNotification = t.show;
1271 return o.hideNotification = t.hide
1272 });
1273 o.Plugin.Tags = (function () {
1274 q(t, o.Plugin);
1275
1276 function t() {
1277 this.setAnnotationTags = g(this.setAnnotationTags, this);
1278 this.updateField = g(this.updateField, this);
1279 t.__super__.constructor.apply(this, arguments)
1280 }
1281 t.prototype.field = null;
1282 t.prototype.input = null;
1283 t.prototype.pluginInit = function () {
1284 if (!o.supported()) {
1285 return
1286 }
1287 this.field = this.annotator.editor.addField({
1288 label: "Add some tags here\u2026",
1289 load: this.updateField,
1290 submit: this.setAnnotationTags
1291 });
1292 this.annotator.viewer.addField({
1293 load: this.updateViewer
1294 });
1295 if (this.annotator.plugins.Filter) {
1296 this.annotator.plugins.Filter.addFilter({
1297 label: "Tag",
1298 property: "tags",
1299 isFiltered: o.Plugin.Tags.filterCallback
1300 })
1301 }
1302 return this.input = h(this.field).find(":input")
1303 };
1304 t.prototype.parseTags = function (v) {
1305 var u;
1306 v = h.trim(v);
1307 u = [];
1308 if (v) {
1309 u = v.split(/\s+/)
1310 }
1311 return u
1312 };
1313 t.prototype.stringifyTags = function (u) {
1314 return u.join(" ")
1315 };
1316 t.prototype.updateField = function (w, u) {
1317 var v;
1318 v = "";
1319 if (u.tags) {
1320 v = this.stringifyTags(u.tags)
1321 }
1322 return this.input.val(v)
1323 };
1324 t.prototype.setAnnotationTags = function (v, u) {
1325 return u.tags = this.parseTags(this.input.val())
1326 };
1327 t.prototype.updateViewer = function (v, u) {
1328 v = h(v);
1329 if (u.tags && h.isArray(u.tags) && u.tags.length) {
1330 return v.addClass("annotator-tags").html(function () {
1331 var w;
1332 return w = h.map(u.tags, function (x) {
1333 return '<span class="annotator-tag">' + o.$.escape(x) + "</span>"
1334 }).join(" ")
1335 })
1336 } else {
1337 return v.remove()
1338 }
1339 };
1340 return t
1341 })();
1342 o.Plugin.Tags.filterCallback = function (z, B) {
1343 var y, x, w, C, v, u, t, A;
1344 if (B == null) {
1345 B = []
1346 }
1347 w = 0;
1348 x = [];
1349 if (z) {
1350 x = z.split(/\s+/g);
1351 for (v = 0, t = x.length; v < t; v++) {
1352 y = x[v];
1353 if (B.length) {
1354 for (u = 0, A = B.length; u < A; u++) {
1355 C = B[u];
1356 if (C.indexOf(y) !== -1) {
1357 w += 1
1358 }
1359 }
1360 }
1361 }
1362 }
1363 return w === x.length
1364 };
1365 n = function (u) {
1366 var y, t, x, v, w, z;
1367 v = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(.([0-9]+))?)?(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";
1368 y = u.match(new RegExp(v));
1369 x = 0;
1370 t = new Date(y[1], 0, 1);
1371 if (y[3]) {
1372 t.setMonth(y[3] - 1)
1373 }
1374 if (y[5]) {
1375 t.setDate(y[5])
1376 }
1377 if (y[7]) {
1378 t.setHours(y[7])
1379 }
1380 if (y[8]) {
1381 t.setMinutes(y[8])
1382 }
1383 if (y[10]) {
1384 t.setSeconds(y[10])
1385 }
1386 if (y[12]) {
1387 t.setMilliseconds(Number("0." + y[12]) * 1000)
1388 }
1389 if (y[14]) {
1390 x = (Number(y[16]) * 60) + Number(y[17]);
1391 x *= (z = y[15] === "-") != null ? z : {
1392 1: -1
1393 }
1394 }
1395 x -= t.getTimezoneOffset();
1396 w = Number(t) + (x * 60 * 1000);
1397 t.setTime(Number(w));
1398 return t
1399 };
1400 o.Plugin.Auth = (function () {
1401 q(t, o.Plugin);
1402 t.prototype.options = {
1403 token: null,
1404 tokenUrl: "/auth/token",
1405 autoFetch: true
1406 };
1407
1408 function t(v, u) {
1409 this.haveValidToken = g(this.haveValidToken, this);
1410 t.__super__.constructor.apply(this, arguments);
1411 this.element.data("annotator:auth", this);
1412 this.waitingForToken = [];
1413 if (this.options.token) {
1414 this.setToken(this.options.token)
1415 } else {
1416 this.requestToken()
1417 }
1418 }
1419 t.prototype.requestToken = function () {
1420 this.requestInProgress = true;
1421 return h.getJSON(this.options.tokenUrl, g(function (v, u, w) {
1422 if (u !== "success") {
1423 return console.error("Couldn't get auth token: " + u, w)
1424 } else {
1425 this.setToken(v);
1426 return this.requestInProgress = false
1427 }
1428 }, this))
1429 };
1430 t.prototype.setToken = function (v) {
1431 var u;
1432 this.token = v;
1433 if (this.haveValidToken()) {
1434 if (this.options.autoFetch) {
1435 this.refreshTimeout = setTimeout((g(function () {
1436 return this.requestToken()
1437 }, this)), (this.timeToExpiry() - 2) * 1000)
1438 }
1439 this.updateHeaders();
1440 u = [];
1441 while (this.waitingForToken.length > 0) {
1442 u.push(this.waitingForToken.pop().apply())
1443 }
1444 return u
1445 } else {
1446 console.warn("Didn't get a valid token.");
1447 if (this.options.autoFetch) {
1448 console.warn("Getting a new token in 10s.");
1449 return setTimeout((g(function () {
1450 return this.requestToken()
1451 }, this)), 10 * 1000)
1452 }
1453 }
1454 };
1455 t.prototype.haveValidToken = function () {
1456 var u;
1457 u = this.token && this.token.authToken && this.token.authTokenIssueTime && this.token.authTokenTTL && this.token.accountId && this.token.userId;
1458 return u && this.timeToExpiry() > 0
1459 };
1460 t.prototype.timeToExpiry = function () {
1461 var w, u, v, x;
1462 v = new Date().getTime() / 1000;
1463 u = n(this.token.authTokenIssueTime).getTime() / 1000;
1464 w = u + this.token.authTokenTTL;
1465 x = w - v;
1466 if (x > 0) {
1467 return x
1468 } else {
1469 return 0
1470 }
1471 };
1472 t.prototype.updateHeaders = function () {
1473 var u;
1474 u = this.element.data("annotator:headers");
1475 return this.element.data("annotator:headers", h.extend(u, {
1476 "x-annotator-auth-token": this.token.authToken,
1477 "x-annotator-auth-token-issue-time": this.token.authTokenIssueTime,
1478 "x-annotator-auth-token-ttl": this.token.authTokenTTL,
1479 "x-annotator-account-id": this.token.accountId,
1480 "x-annotator-user-id": this.token.userId
1481 }))
1482 };
1483 t.prototype.withToken = function (u) {
1484 if (!(u != null)) {
1485 return
1486 }
1487 if (this.haveValidToken()) {
1488 return u()
1489 } else {
1490 this.waitingForToken.push(u);
1491 if (!this.requestInProgress) {
1492 return this.requestToken()
1493 }
1494 }
1495 };
1496 return t
1497 })();
1498 o.Plugin.Store = (function () {
1499 q(t, o.Plugin);
1500 t.prototype.events = {
1501 annotationCreated: "annotationCreated",
1502 annotationDeleted: "annotationDeleted",
1503 annotationUpdated: "annotationUpdated"
1504 };
1505 t.prototype.options = {
1506 prefix: "/store",
1507 autoFetch: true,
1508 annotationData: {},
1509 loadFromSearch: false,
1510 urls: {
1511 create: "/annotations",
1512 read: "/annotations/:id",
1513 update: "/annotations/:id",
1514 destroy: "/annotations/:id",
1515 search: "/search"
1516 }
1517 };
1518
1519 function t(v, u) {
1520 this._onError = g(this._onError, this);
1521 this._onBeforeSend = g(this._onBeforeSend, this);
1522 this._onLoadAnnotationsFromSearch = g(this._onLoadAnnotationsFromSearch, this);
1523 this._onLoadAnnotations = g(this._onLoadAnnotations, this);
1524 this._getAnnotations = g(this._getAnnotations, this);
1525 t.__super__.constructor.apply(this, arguments);
1526 this.annotations = []
1527 }
1528 t.prototype.pluginInit = function () {
1529 var u;
1530 if (!o.supported()) {
1531 return
1532 }
1533 u = this.element.data("annotator:auth");
1534 if (u) {
1535 return u.withToken(this._getAnnotations)
1536 } else {
1537 return this._getAnnotations()
1538 }
1539 };
1540 t.prototype._getAnnotations = function () {
1541 if (this.options.loadFromSearch) {
1542 return this.loadAnnotationsFromSearch(this.options.loadFromSearch)
1543 } else {
1544 return this.loadAnnotations()
1545 }
1546 };
1547 t.prototype.annotationCreated = function (u) {
1548 if (f.call(this.annotations, u) < 0) {
1549 this.registerAnnotation(u);
1550 return this._apiRequest("create", u, g(function (v) {
1551 if (!(v.id != null)) {
1552 console.warn("Warning: No ID returned from server for annotation ", u)
1553 }
1554 return this.updateAnnotation(u, v)
1555 }, this))
1556 } else {
1557 return this.updateAnnotation(u, {})
1558 }
1559 };
1560 t.prototype.annotationUpdated = function (u) {
1561 if (f.call(this.annotations, u) >= 0) {
1562 return this._apiRequest("update", u, (g(function (v) {
1563 return this.updateAnnotation(u, v)
1564 }, this)))
1565 }
1566 };
1567 t.prototype.annotationDeleted = function (u) {
1568 if (f.call(this.annotations, u) >= 0) {
1569 return this._apiRequest("destroy", u, (g(function () {
1570 return this.unregisterAnnotation(u)
1571 }, this)))
1572 }
1573 };
1574 t.prototype.registerAnnotation = function (u) {
1575 return this.annotations.push(u)
1576 };
1577 t.prototype.unregisterAnnotation = function (u) {
1578 return this.annotations.splice(this.annotations.indexOf(u), 1)
1579 };
1580 t.prototype.updateAnnotation = function (u, v) {
1581 if (f.call(this.annotations, u) < 0) {
1582 console.error("Trying to update unregistered annotation!")
1583 } else {
1584 h.extend(u, v)
1585 }
1586
1587 var rangeString = u.ranges[0].startOffset + "_" + u.ranges[0].endOffset;
1588
1589 var found = false;
1590 for(var i = 0; i < gs.annotationArray.keys.length; i++){if(gs.annotationArray.keys[i] == rangeString){found = true; break;}}
1591
1592 if(!found)
1593 {
1594 gs.annotationArray.keys.push(rangeString);
1595 }
1596 gs.annotationArray[rangeString] = u;
1597 console.log("(setup) Adding " + u.quote + ", " + u.text + ", " + u.tags + " to " + rangeString);
1598 showRebuildOption();
1599 return h(u.highlights).data("annotation", u)
1600 };
1601 t.prototype.loadAnnotations = function () {
1602 return this._apiRequest("read", null, this._onLoadAnnotations)
1603 };
1604 t.prototype._onLoadAnnotations = function (u) {
1605 if (u == null) {
1606 u = []
1607 }
1608 this.annotations = u;
1609 return this.annotator.loadAnnotations(u.slice())
1610 };
1611 t.prototype.loadAnnotationsFromSearch = function (u) {
1612 return this._apiRequest("search", u, this._onLoadAnnotationsFromSearch)
1613 };
1614 t.prototype._onLoadAnnotationsFromSearch = function (u) {
1615 if (u == null) {
1616 u = {}
1617 }
1618 return this._onLoadAnnotations(u.rows || [])
1619 };
1620 t.prototype.dumpAnnotations = function () {
1621 var w, v, y, x, u;
1622 x = this.annotations;
1623 u = [];
1624 for (v = 0, y = x.length; v < y; v++) {
1625 w = x[v];
1626 u.push(JSON.parse(this._dataFor(w)))
1627 }
1628 return u
1629 };
1630 t.prototype._apiRequest = function (x, y, z) {
1631 var A, v, w, u;
1632 A = y && y.id;
1633 u = this._urlFor(x, A);
1634 v = this._apiRequestOptions(x, y, z);
1635 w = h.ajax(u, v);
1636 w._id = A;
1637 w._action = x;
1638 return w
1639 };
1640 t.prototype._apiRequestOptions = function (v, w, x) {
1641 var u;
1642 u = {
1643 type: this._methodFor(v),
1644 beforeSend: this._onBeforeSend,
1645 dataType: "json",
1646 success: x ||
1647 function () {},
1648 error: this._onError
1649 };
1650 if (v === "search") {
1651 u = h.extend(u, {
1652 data: w
1653 })
1654 } else {
1655 u = h.extend(u, {
1656 data: w && this._dataFor(w),
1657 contentType: "application/json; charset=utf-8"
1658 })
1659 }
1660 return u
1661 };
1662 t.prototype._urlFor = function (w, x) {
1663 var u, v;
1664 u = x != null ? "/" + x : "";
1665 v = this.options.prefix || "/";
1666 v += this.options.urls[w];
1667 v = v.replace(/\/:id/, u);
1668 return v
1669 };
1670 t.prototype._methodFor = function (v) {
1671 var u;
1672 u = {
1673 create: "POST",
1674 read: "GET",
1675 update: "PUT",
1676 destroy: "DELETE",
1677 search: "GET"
1678 };
1679 return u[v]
1680 };
1681 t.prototype._dataFor = function (u) {
1682 var v, w;
1683 w = u.highlights;
1684 delete u.highlights;
1685 h.extend(u, this.options.annotationData);
1686 v = JSON.stringify(u);
1687 if (w) {
1688 u.highlights = w
1689 }
1690 return v
1691 };
1692 t.prototype._onBeforeSend = function (y) {
1693 var x, v, w, u;
1694 x = this.element.data("annotator:headers");
1695 if (x) {
1696 u = [];
1697 for (v in x) {
1698 w = x[v];
1699 u.push(y.setRequestHeader(v, w))
1700 }
1701 return u
1702 }
1703 };
1704 t.prototype._onError = function (w) {
1705 var v, u;
1706 v = w._action;
1707 u = "Sorry we could not " + v + " this annotation";
1708 if (w._action === "search") {
1709 u = "Sorry we could not search the store for annotations"
1710 } else {
1711 if (w._action === "read" && !w._id) {
1712 u = "Sorry we could not " + v + " the annotations from the store"
1713 }
1714 }
1715 switch (w.status) {
1716 case 401:
1717 u = "Sorry you are not allowed to " + v + " this annotation";
1718 break;
1719 case 404:
1720 u = "Sorry we could not connect to the annotations store";
1721 break;
1722 case 500:
1723 u = "Sorry something went wrong with the annotation store"
1724 }
1725 o.showNotification(u, o.Notification.ERROR);
1726 return console.error("API request failed: '" + w.status + "'")
1727 };
1728 return t
1729 })();
1730 o.Plugin.Filter = (function () {
1731 q(t, o.Plugin);
1732 t.prototype.events = {
1733 ".annotator-filter-property input focus": "_onFilterFocus",
1734 ".annotator-filter-property input blur": "_onFilterBlur",
1735 ".annotator-filter-property input keyup": "_onFilterKeyup",
1736 ".annotator-filter-previous click": "_onPreviousClick",
1737 ".annotator-filter-next click": "_onNextClick",
1738 ".annotator-filter-clear click": "_onClearClick"
1739 };
1740 t.prototype.classes = {
1741 active: "annotator-filter-active",
1742 hl: {
1743 hide: "annotator-hl-filtered",
1744 active: "annotator-hl-active"
1745 }
1746 };
1747 t.prototype.html = {
1748 // element: '<div class="annotator-filter">\n <strong>Navigate:</strong>\n <span class="annotator-filter-navigation">\n <button class="annotator-filter-previous">Previous</button>\n <button class="annotator-filter-next">Next</button>\n </span>\n <strong>Filter by:</strong>\n</div>',
1749 filter: '<span class="annotator-filter-property">\n <label></label>\n <input/>\n <button class="annotator-filter-clear">Clear</button>\n</span>'
1750 };
1751 t.prototype.options = {
1752 appendTo: "body",
1753 filters: [],
1754 addAnnotationFilter: true,
1755 isFiltered: function (v, x) {
1756 var u, w, z, y;
1757 if (!(v && x)) {
1758 return false
1759 }
1760 y = v.split(/\s*/);
1761 for (w = 0, z = y.length; w < z; w++) {
1762 u = y[w];
1763 if (x.indexOf(u) === -1) {
1764 return false
1765 }
1766 }
1767 return true
1768 }
1769 };
1770
1771 function t(v, u) {
1772 this._onPreviousClick = g(this._onPreviousClick, this);
1773 this._onNextClick = g(this._onNextClick, this);
1774 this._onFilterKeyup = g(this._onFilterKeyup, this);
1775 this._onFilterBlur = g(this._onFilterBlur, this);
1776 this._onFilterFocus = g(this._onFilterFocus, this);
1777 this.updateHighlights = g(this.updateHighlights, this);
1778 v = h(this.html.element).appendTo(this.options.appendTo);
1779 t.__super__.constructor.call(this, v, u);
1780 this.filter = h(this.html.filter);
1781 this.filters = [];
1782 this.current = 0
1783 }
1784 t.prototype.pluginInit = function () {
1785 var v, u, x, w;
1786 w = this.options.filters;
1787 for (u = 0, x = w.length; u < x; u++) {
1788 v = w[u];
1789 this.addFilter(v)
1790 }
1791 this.updateHighlights();
1792 this._setupListeners()._insertSpacer();
1793 if (this.options.addAnnotationFilter === true) {
1794 return this.addFilter({
1795 label: "Annotation",
1796 property: "text"
1797 })
1798 }
1799 };
1800 t.prototype._insertSpacer = function () {
1801 var v, u;
1802 u = h("html");
1803 v = parseInt(u.css("padding-top"), 10) || 0;
1804 u.css("padding-top", v + this.element.outerHeight());
1805 return this
1806 };
1807 t.prototype._setupListeners = function () {
1808 var w, u, v, x;
1809 u = ["annotationsLoaded", "annotationCreated", "annotationUpdated", "annotationDeleted"];
1810 for (v = 0, x = u.length; v < x; v++) {
1811 w = u[v];
1812 this.annotator.subscribe(w, this.updateHighlights)
1813 }
1814 return this
1815 };
1816 t.prototype.addFilter = function (u) {
1817 var w, v;
1818 v = h.extend({
1819 label: "",
1820 property: "",
1821 isFiltered: this.options.isFiltered
1822 }, u);
1823 if (!((function () {
1824 var y, A, z, x;
1825 z = this.filters;
1826 x = [];
1827 for (y = 0, A = z.length; y < A; y++) {
1828 w = z[y];
1829 if (w.property === v.property) {
1830 x.push(w)
1831 }
1832 }
1833 return x
1834 }).call(this)).length) {
1835 v.id = "annotator-filter-" + v.property;
1836 v.annotations = [];
1837 v.element = this.filter.clone().appendTo(this.element);
1838 v.element.find("label").html(v.label).attr("for", v.id);
1839 v.element.find("input").attr({
1840 id: v.id,
1841 placeholder: "Filter by " + v.label + "\u2026"
1842 });
1843 v.element.find("button").hide();
1844 v.element.data("filter", v);
1845 this.filters.push(v)
1846 }
1847 return this
1848 };
1849 t.prototype.updateFilter = function (x) {
1850 var u, z, v, y, w, B, A;
1851 x.annotations = [];
1852 this.updateHighlights();
1853 this.resetHighlights();
1854 v = h.trim(x.element.find("input").val());
1855 if (v) {
1856 z = this.highlights.map(function () {
1857 return h(this).data("annotation")
1858 });
1859 A = h.makeArray(z);
1860 for (w = 0, B = A.length; w < B; w++) {
1861 u = A[w];
1862 y = u[x.property];
1863 if (x.isFiltered(v, y)) {
1864 x.annotations.push(u)
1865 }
1866 }
1867 return this.filterHighlights()
1868 }
1869 };
1870 t.prototype.updateHighlights = function () {
1871 this.highlights = this.annotator.element.find(".annotator-hl:visible");
1872 return this.filtered = this.highlights.not(this.classes.hl.hide)
1873 };
1874 t.prototype.filterHighlights = function () {
1875 var v, x, y, B, z, A, C, u, w;
1876 v = h.grep(this.filters, function (D) {
1877 return !!D.annotations.length
1878 });
1879 B = ((w = v[0]) != null ? w.annotations : void 0) || [];
1880 if (v.length > 1) {
1881 y = [];
1882 h.each(v, function () {
1883 return h.merge(y, this.annotations)
1884 });
1885 C = [];
1886 B = [];
1887 h.each(y, function () {
1888 if (h.inArray(this, C) === -1) {
1889 return C.push(this)
1890 } else {
1891 return B.push(this)
1892 }
1893 })
1894 }
1895 z = this.highlights;
1896 for (A = 0, u = B.length; A < u; A++) {
1897 x = B[A];
1898 z = z.not(x.highlights)
1899 }
1900 z.addClass(this.classes.hl.hide);
1901 this.filtered = this.highlights.not(this.classes.hl.hide);
1902 return this
1903 };
1904 t.prototype.resetHighlights = function () {
1905 this.highlights.removeClass(this.classes.hl.hide);
1906 this.filtered = this.highlights;
1907 return this
1908 };
1909 t.prototype._onFilterFocus = function (v) {
1910 var u;
1911 u = h(v.target);
1912 u.parent().addClass(this.classes.active);
1913 return u.next("button").show()
1914 };
1915 t.prototype._onFilterBlur = function (v) {
1916 var u;
1917 if (!v.target.value) {
1918 u = h(v.target);
1919 u.parent().removeClass(this.classes.active);
1920 return u.next("button").hide()
1921 }
1922 };
1923 t.prototype._onFilterKeyup = function (v) {
1924 var u;
1925 u = h(v.target).parent().data("filter");
1926 if (u) {
1927 return this.updateFilter(u)
1928 }
1929 };
1930 t.prototype._findNextHighlight = function (z) {
1931 var v, w, B, A, y, x, u, C;
1932 if (!this.highlights.length) {
1933 return this
1934 }
1935 x = z ? 0 : -1;
1936 C = z ? -1 : 0;
1937 u = z ? "lt" : "gt";
1938 v = this.highlights.not("." + this.classes.hl.hide);
1939 B = v.filter("." + this.classes.hl.active);
1940 if (!B.length) {
1941 B = v.eq(x)
1942 }
1943 w = B.data("annotation");
1944 A = v.index(B[0]);
1945 y = v.filter(":" + u + "(" + A + ")").not(w.highlights).eq(C);
1946 if (!y.length) {
1947 y = v.eq(C)
1948 }
1949 return this._scrollToHighlight(y.data("annotation").highlights)
1950 };
1951 t.prototype._onNextClick = function (u) {
1952 return this._findNextHighlight()
1953 };
1954 t.prototype._onPreviousClick = function (u) {
1955 return this._findNextHighlight(true)
1956 };
1957 t.prototype._scrollToHighlight = function (u) {
1958 u = h(u);
1959 this.highlights.removeClass(this.classes.hl.active);
1960 u.addClass(this.classes.hl.active);
1961 return h("html, body").animate({
1962 scrollTop: u.offset().top - (this.element.height() + 20)
1963 }, 150)
1964 };
1965 t.prototype._onClearClick = function (u) {
1966 return h(u.target).prev("input").val("").keyup().blur()
1967 };
1968 return t
1969 })();
1970 o.Plugin.Markdown = (function () {
1971 q(t, o.Plugin);
1972 t.prototype.events = {
1973 annotationViewerTextField: "updateTextField"
1974 };
1975
1976 function t(v, u) {
1977 this.updateTextField = g(this.updateTextField, this);
1978 if ((typeof Showdown !== "undefined" && Showdown !== null ? Showdown.converter : void 0) != null) {
1979 t.__super__.constructor.apply(this, arguments);
1980 this.converter = new Showdown.converter()
1981 } else {
1982 console.error("To use the Markdown plugin, you must include Showdown into the page first.")
1983 }
1984 }
1985 t.prototype.updateTextField = function (v, u) {
1986 var w;
1987 w = o.$.escape(u.text || "");
1988 return h(v).html(this.convert(w))
1989 };
1990 t.prototype.convert = function (u) {
1991 return this.converter.makeHtml(u)
1992 };
1993 return t
1994 })();
1995 o.Plugin.Unsupported = (function () {
1996 q(t, o.Plugin);
1997
1998 function t() {
1999 t.__super__.constructor.apply(this, arguments)
2000 }
2001 t.prototype.options = {
2002 message: "Sorry your current browser does not support the Annotator"
2003 };
2004 t.prototype.pluginInit = function () {
2005 if (!o.supported()) {
2006 return h(g(function () {
2007 o.showNotification(this.options.message);
2008 if ((window.XMLHttpRequest === void 0) && (ActiveXObject !== void 0)) {
2009 return h("html").addClass("ie6")
2010 }
2011 }, this))
2012 }
2013 };
2014 return t
2015 })();
2016 o.Plugin.Permissions = (function () {
2017 q(t, o.Plugin);
2018 t.prototype.events = {
2019 beforeAnnotationCreated: "addFieldsToAnnotation"
2020 };
2021 t.prototype.options = {
2022 showViewPermissionsCheckbox: true,
2023 showEditPermissionsCheckbox: true,
2024 userId: function (u) {
2025 return u
2026 },
2027 userString: function (u) {
2028 return u
2029 },
2030 userAuthorize: function (u, v) {
2031 return this.userId(u) === v
2032 },
2033 user: "",
2034 permissions: {
2035 read: [],
2036 update: [],
2037 "delete": [],
2038 admin: []
2039 }
2040 };
2041
2042 function t(v, u) {
2043 this.updateViewer = g(this.updateViewer, this);
2044 this.updateAnnotationPermissions = g(this.updateAnnotationPermissions, this);
2045 this.updatePermissionsField = g(this.updatePermissionsField, this);
2046 this.addFieldsToAnnotation = g(this.addFieldsToAnnotation, this);
2047 t.__super__.constructor.apply(this, arguments);
2048 if (this.options.user) {
2049 this.setUser(this.options.user);
2050 delete this.options.user
2051 }
2052 }
2053 t.prototype.pluginInit = function () {
2054 var u, v;
2055 if (!o.supported()) {
2056 return
2057 }
2058 v = this;
2059 u = function (x, w) {
2060 return function (z, y) {
2061 return v[x].call(v, w, z, y)
2062 }
2063 };
2064 if (this.options.showViewPermissionsCheckbox === true) {
2065 this.annotator.editor.addField({
2066 type: "checkbox",
2067 label: "Allow anyone to <strong>view</strong> this annotation",
2068 load: u("updatePermissionsField", "read"),
2069 submit: u("updateAnnotationPermissions", "read")
2070 })
2071 }
2072 /*
2073 if (this.options.showEditPermissionsCheckbox === true) {
2074 this.annotator.editor.addField({
2075 type: "checkbox",
2076 label: "Allow anyone to <strong>edit</strong> this annotation",
2077 load: u("updatePermissionsField", "update"),
2078 submit: u("updateAnnotationPermissions", "update")
2079 })
2080 }
2081 */
2082 console.log(this.annotator.editor);
2083 this.annotator.viewer.addField({
2084 load: this.updateViewer
2085 });
2086 if (this.annotator.plugins.Filter) {
2087 return this.annotator.plugins.Filter.addFilter({
2088 label: "User",
2089 property: "user",
2090 isFiltered: g(function (y, x) {
2091 var w, z, B, A;
2092 x = this.options.userString(x);
2093 if (!(y && x)) {
2094 return false
2095 }
2096 A = y.split(/\s*/);
2097 for (z = 0, B = A.length; z < B; z++) {
2098 w = A[z];
2099 if (x.indexOf(w) === -1) {
2100 return false
2101 }
2102 }
2103 return true
2104 }, this)
2105 })
2106 }
2107 };
2108 t.prototype.setUser = function (u) {
2109 return this.user = u
2110 };
2111 t.prototype.addFieldsToAnnotation = function (u) {
2112 if (u) {
2113 u.permissions = this.options.permissions;
2114 if (this.user) {
2115 return u.user = this.user
2116 }
2117 }
2118 };
2119 t.prototype.authorize = function (y, u, v) {
2120 var w, z, x, A;
2121 if (v === void 0) {
2122 v = this.user
2123 }
2124 if (u.permissions) {
2125 z = u.permissions[y] || [];
2126 if (z.length === 0) {
2127 return true
2128 }
2129 for (x = 0, A = z.length; x < A; x++) {
2130 w = z[x];
2131 if (this.options.userAuthorize.call(this.options, v, w)) {
2132 return true
2133 }
2134 }
2135 return false
2136 } else {
2137 if (u.user) {
2138 return v && this.options.userId(v) === u.user
2139 }
2140 }
2141 return true
2142 };
2143 t.prototype.updatePermissionsField = function (w, y, u) {
2144 var x, v;
2145 y = h(y).show();
2146 v = y.find("input").removeAttr("disabled");
2147 if (!this.authorize("admin", u)) {
2148 y.hide()
2149 }
2150 if (this.authorize(w, u || {}, null)) {
2151 v.attr("checked", "checked");
2152 x = {
2153 permissions: this.options.permissions
2154 };
2155 if (this.authorize(w, x, null)) {
2156 return v.attr("disabled", "disabled")
2157 }
2158 } else {
2159 return v.removeAttr("checked")
2160 }
2161 };
2162 t.prototype.updateAnnotationPermissions = function (w, x, u) {
2163 var y, v;
2164 if (!u.permissions) {
2165 u.permissions = this.options.permissions
2166 }
2167 y = w + "-permissions";
2168 if (h(x).find("input").is(":checked")) {
2169 h.data(u, y, u.permissions[w]);
2170 return u.permissions[w] = []
2171 } else {
2172 v = h.data(u, y);
2173 if (v) {
2174 return u.permissions[w] = v
2175 }
2176 }
2177 };
2178 t.prototype.updateViewer = function (x, u, w) {
2179 var v, y;
2180 x = h(x);
2181 y = this.options.userString(u.user);
2182 if (u.user && y && typeof y === "string") {
2183 v = o.$.escape(this.options.userString(u.user));
2184 x.html(v).addClass("annotator-user")
2185 } else {
2186 x.remove()
2187 }
2188 if (u.permissions) {
2189 if (!this.authorize("update", u)) {
2190 w.hideEdit()
2191 }
2192 if (!this.authorize("delete", u)) {
2193 return w.hideDelete()
2194 }
2195 } else {
2196 if (u.user && !this.authorize(null, u)) {
2197 w.hideEdit();
2198 return w.hideDelete()
2199 }
2200 }
2201 };
2202 return t
2203 })();
2204 o.prototype.setupPlugins = function (w, E) {
2205 var B, D, u, t, y, v, A, C, z, x;
2206 if (w == null) {
2207 w = {}
2208 }
2209 if (E == null) {
2210 E = {}
2211 }
2212 z = a.getGlobal();
2213 y = {
2214 Tags: {},
2215 Filter: {
2216 filters: [{
2217 label: "User",
2218 property: "user"
2219 }, {
2220 label: "Tags",
2221 property: "tags"
2222 }]
2223 },
2224 Unsupported: {}
2225 };
2226 if (z.Showdown) {
2227 y.Markdown = {}
2228 }
2229 A = w.userId, C = w.userName, B = w.accountId, D = w.authToken;
2230 if (A && C && B && D) {
2231 v = z.location.href.split(/#|\?/).shift() || "";
2232 h.extend(y, {
2233 Store: {
2234 prefix: w.storeUri || "http://annotateit.org/api",
2235 annotationData: {
2236 uri: v
2237 },
2238 loadFromSearch: {
2239 uri: v,
2240 all_fields: 1
2241 }
2242 },
2243 Permissions: {
2244 user: {
2245 id: w.userId,
2246 name: w.userName
2247 },
2248 permissions: {
2249 read: [w.userId],
2250 update: [w.userId],
2251 "delete": [w.userId],
2252 admin: [w.userId]
2253 },
2254 userId: function (F) {
2255 if (F != null ? F.id : void 0) {
2256 return F.id
2257 } else {
2258 return ""
2259 }
2260 },
2261 userString: function (F) {
2262 if (F != null ? F.name : void 0) {
2263 return F.name
2264 } else {
2265 return ""
2266 }
2267 }
2268 }
2269 });
2270 this.element.data({
2271 "annotator:headers": {
2272 "X-Annotator-User-Id": w.userId,
2273 "X-Annotator-Account-Id": w.accountId,
2274 "X-Annotator-Auth-Token": w.authToken
2275 }
2276 })
2277 }
2278 h.extend(y, E);
2279 x = [];
2280 for (u in y) {
2281 if (!k.call(y, u)) {
2282 continue
2283 }
2284 t = y[u];
2285 if (t !== null && t !== false) {
2286 x.push(this.addPlugin(u, t))
2287 }
2288 }
2289 return x
2290 }
2291}).call(this);
Note: See TracBrowser for help on using the repository browser.