changeset 1123:1fad569ccb4f

provide annotator javascript for digilib.annotator plugin.
author robcast
date Fri, 09 Nov 2012 11:28:44 +0100
parents 75e61bf276fe
children bd90fdfd55f7
files webapp/src/main/webapp/jquery/annotator-dl.js webapp/src/main/webapp/jquery/annotator-dl.min.js webapp/src/main/webapp/jquery/annotator.min.css webapp/src/main/webapp/jquery/digilib-ann.html webapp/src/main/webapp/jquery/jquery.digilib.annotator.js webapp/src/main/webapp/jquery/showdown.js
diffstat 6 files changed, 3283 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webapp/src/main/webapp/jquery/annotator-dl.js	Fri Nov 09 11:28:44 2012 +0100
@@ -0,0 +1,2826 @@
+/*
+** Annotator 1.2.5-dev-34a1d4e
+** https://github.com/okfn/annotator/
+**
+** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
+** Dual licensed under the MIT and GPLv3 licenses.
+** https://github.com/okfn/annotator/blob/master/LICENSE
+**
+** Built at: 2012-11-08 19:26:45Z
+*/
+
+
+(function() {
+  var $, Annotator, Delegator, LinkParser, Range, base64Decode, base64UrlDecode, createDateFromISO8601, fn, functions, g, gettext, parseToken, util, _Annotator, _gettext, _i, _j, _len, _len1, _ref, _ref1, _t,
+    __slice = [].slice,
+    __hasProp = {}.hasOwnProperty,
+    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
+    __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
+    __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
+
+  gettext = null;
+
+  if (typeof Gettext !== "undefined" && Gettext !== null) {
+    _gettext = new Gettext({
+      domain: "annotator"
+    });
+    gettext = function(msgid) {
+      return _gettext.gettext(msgid);
+    };
+  } else {
+    gettext = function(msgid) {
+      return msgid;
+    };
+  }
+
+  _t = function(msgid) {
+    return gettext(msgid);
+  };
+
+  if (!(typeof jQuery !== "undefined" && jQuery !== null ? (_ref = jQuery.fn) != null ? _ref.jquery : void 0 : void 0)) {
+    console.error(_t("Annotator requires jQuery: have you included lib/vendor/jquery.js?"));
+  }
+
+  if (!(JSON && JSON.parse && JSON.stringify)) {
+    console.error(_t("Annotator requires a JSON implementation: have you included lib/vendor/json2.js?"));
+  }
+
+  $ = jQuery.sub();
+
+  $.flatten = function(array) {
+    var flatten;
+    flatten = function(ary) {
+      var el, flat, _i, _len;
+      flat = [];
+      for (_i = 0, _len = ary.length; _i < _len; _i++) {
+        el = ary[_i];
+        flat = flat.concat(el && $.isArray(el) ? flatten(el) : el);
+      }
+      return flat;
+    };
+    return flatten(array);
+  };
+
+  $.plugin = function(name, object) {
+    return jQuery.fn[name] = function(options) {
+      var args;
+      args = Array.prototype.slice.call(arguments, 1);
+      return this.each(function() {
+        var instance;
+        instance = $.data(this, name);
+        if (instance) {
+          return options && instance[options].apply(instance, args);
+        } else {
+          instance = new object(this, options);
+          return $.data(this, name, instance);
+        }
+      });
+    };
+  };
+
+  $.fn.textNodes = function() {
+    var getTextNodes;
+    getTextNodes = function(node) {
+      var nodes;
+      if (node && node.nodeType !== 3) {
+        nodes = [];
+        if (node.nodeType !== 8) {
+          node = node.lastChild;
+          while (node) {
+            nodes.push(getTextNodes(node));
+            node = node.previousSibling;
+          }
+        }
+        return nodes.reverse();
+      } else {
+        return node;
+      }
+    };
+    return this.map(function() {
+      return $.flatten(getTextNodes(this));
+    });
+  };
+
+  $.fn.xpath = function(relativeRoot) {
+    var jq;
+    jq = this.map(function() {
+      var elem, idx, path;
+      path = '';
+      elem = this;
+      while (elem && elem.nodeType === 1 && elem !== relativeRoot) {
+        idx = $(elem.parentNode).children(elem.tagName).index(elem) + 1;
+        idx = "[" + idx + "]";
+        path = "/" + elem.tagName.toLowerCase() + idx + path;
+        elem = elem.parentNode;
+      }
+      return path;
+    });
+    return jq.get();
+  };
+
+  $.escape = function(html) {
+    return html.replace(/&(?!\w+;)/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
+  };
+
+  $.fn.escape = function(html) {
+    if (arguments.length) {
+      return this.html($.escape(html));
+    }
+    return this.html();
+  };
+
+  $.fn.reverse = []._reverse || [].reverse;
+
+  functions = ["log", "debug", "info", "warn", "exception", "assert", "dir", "dirxml", "trace", "group", "groupEnd", "groupCollapsed", "time", "timeEnd", "profile", "profileEnd", "count", "clear", "table", "error", "notifyFirebug", "firebug", "userObjects"];
+
+  if (typeof console !== "undefined" && console !== null) {
+    if (!(console.group != null)) {
+      console.group = function(name) {
+        return console.log("GROUP: ", name);
+      };
+    }
+    if (!(console.groupCollapsed != null)) {
+      console.groupCollapsed = console.group;
+    }
+    for (_i = 0, _len = functions.length; _i < _len; _i++) {
+      fn = functions[_i];
+      if (!(console[fn] != null)) {
+        console[fn] = function() {
+          return console.log(_t("Not implemented:") + (" console." + name));
+        };
+      }
+    }
+  } else {
+    this.console = {};
+    for (_j = 0, _len1 = functions.length; _j < _len1; _j++) {
+      fn = functions[_j];
+      this.console[fn] = function() {};
+    }
+    this.console['error'] = function() {
+      var args;
+      args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
+      return alert("ERROR: " + (args.join(', ')));
+    };
+    this.console['warn'] = function() {
+      var args;
+      args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
+      return alert("WARNING: " + (args.join(', ')));
+    };
+  }
+
+  Delegator = (function() {
+
+    Delegator.prototype.events = {};
+
+    Delegator.prototype.options = {};
+
+    Delegator.prototype.element = null;
+
+    function Delegator(element, options) {
+      this.options = $.extend(true, {}, this.options, options);
+      this.element = $(element);
+      this.on = this.subscribe;
+      this.addEvents();
+    }
+
+    Delegator.prototype.addEvents = function() {
+      var event, functionName, sel, selector, _k, _ref1, _ref2, _results;
+      _ref1 = this.events;
+      _results = [];
+      for (sel in _ref1) {
+        functionName = _ref1[sel];
+        _ref2 = sel.split(' '), selector = 2 <= _ref2.length ? __slice.call(_ref2, 0, _k = _ref2.length - 1) : (_k = 0, []), event = _ref2[_k++];
+        _results.push(this.addEvent(selector.join(' '), event, functionName));
+      }
+      return _results;
+    };
+
+    Delegator.prototype.addEvent = function(bindTo, event, functionName) {
+      var closure, isBlankSelector,
+        _this = this;
+      closure = function() {
+        return _this[functionName].apply(_this, arguments);
+      };
+      isBlankSelector = typeof bindTo === 'string' && bindTo.replace(/\s+/g, '') === '';
+      if (isBlankSelector) {
+        bindTo = this.element;
+      }
+      if (typeof bindTo === 'string') {
+        this.element.delegate(bindTo, event, closure);
+      } else {
+        if (this.isCustomEvent(event)) {
+          this.subscribe(event, closure);
+        } else {
+          $(bindTo).bind(event, closure);
+        }
+      }
+      return this;
+    };
+
+    Delegator.prototype.isCustomEvent = function(event) {
+      event = event.split('.')[0];
+      return $.inArray(event, Delegator.natives) === -1;
+    };
+
+    Delegator.prototype.publish = function() {
+      this.element.triggerHandler.apply(this.element, arguments);
+      return this;
+    };
+
+    Delegator.prototype.subscribe = function(event, callback) {
+      var closure;
+      closure = function() {
+        return callback.apply(this, [].slice.call(arguments, 1));
+      };
+      closure.guid = callback.guid = ($.guid += 1);
+      this.element.bind(event, closure);
+      return this;
+    };
+
+    Delegator.prototype.unsubscribe = function() {
+      this.element.unbind.apply(this.element, arguments);
+      return this;
+    };
+
+    return Delegator;
+
+  })();
+
+  Delegator.natives = (function() {
+    var key, specials, val;
+    specials = (function() {
+      var _ref1, _results;
+      _ref1 = jQuery.event.special;
+      _results = [];
+      for (key in _ref1) {
+        if (!__hasProp.call(_ref1, key)) continue;
+        val = _ref1[key];
+        _results.push(key);
+      }
+      return _results;
+    })();
+    return "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]+/).concat(specials);
+  })();
+
+  Range = {};
+
+  Range.sniff = function(r) {
+    if (r.commonAncestorContainer != null) {
+      return new Range.BrowserRange(r);
+    } else if (typeof r.start === "string") {
+      return new Range.SerializedRange(r);
+    } else if (r.start && typeof r.start === "object") {
+      return new Range.NormalizedRange(r);
+    } else {
+      console.error(_t("Could not sniff range type"));
+      return false;
+    }
+  };
+
+  Range.nodeFromXPath = function(xpath, root) {
+    var customResolver, evaluateXPath, namespace, node, segment;
+    if (root == null) {
+      root = document;
+    }
+    evaluateXPath = function(xp, nsResolver) {
+      if (nsResolver == null) {
+        nsResolver = null;
+      }
+      return document.evaluate('.' + xp, root, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
+    };
+    if (!$.isXMLDoc(document.documentElement)) {
+      return evaluateXPath(xpath);
+    } else {
+      customResolver = document.createNSResolver(document.ownerDocument === null ? document.documentElement : document.ownerDocument.documentElement);
+      node = evaluateXPath(xpath, customResolver);
+      if (!node) {
+        xpath = ((function() {
+          var _k, _len2, _ref1, _results;
+          _ref1 = xpath.split('/');
+          _results = [];
+          for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
+            segment = _ref1[_k];
+            if (segment && segment.indexOf(':') === -1) {
+              _results.push(segment.replace(/^([a-z]+)/, 'xhtml:$1'));
+            } else {
+              _results.push(segment);
+            }
+          }
+          return _results;
+        })()).join('/');
+        namespace = document.lookupNamespaceURI(null);
+        customResolver = function(ns) {
+          if (ns === 'xhtml') {
+            return namespace;
+          } else {
+            return document.documentElement.getAttribute('xmlns:' + ns);
+          }
+        };
+        node = evaluateXPath(xpath, customResolver);
+      }
+      return node;
+    }
+  };
+
+  Range.RangeError = (function(_super) {
+
+    __extends(RangeError, _super);
+
+    function RangeError(type, message, parent) {
+      this.type = type;
+      this.message = message;
+      this.parent = parent != null ? parent : null;
+      RangeError.__super__.constructor.call(this, this.message);
+    }
+
+    return RangeError;
+
+  })(Error);
+
+  Range.BrowserRange = (function() {
+
+    function BrowserRange(obj) {
+      this.commonAncestorContainer = obj.commonAncestorContainer;
+      this.startContainer = obj.startContainer;
+      this.startOffset = obj.startOffset;
+      this.endContainer = obj.endContainer;
+      this.endOffset = obj.endOffset;
+    }
+
+    BrowserRange.prototype.normalize = function(root) {
+      var it, node, nr, offset, p, r, _k, _len2, _ref1;
+      if (this.tainted) {
+        console.error(_t("You may only call normalize() once on a BrowserRange!"));
+        return false;
+      } else {
+        this.tainted = true;
+      }
+      r = {};
+      nr = {};
+      _ref1 = ['start', 'end'];
+      for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
+        p = _ref1[_k];
+        node = this[p + 'Container'];
+        offset = this[p + 'Offset'];
+        if (!((node != null) && (offset != null))) {
+          return false;
+        }
+        if (node.nodeType === 1) {
+          it = node.childNodes[offset];
+          node = it || node.childNodes[offset - 1];
+          if (node.nodeType === 1 && !node.firstChild) {
+            it = null;
+            node = node.previousSibling;
+          }
+          while (node.nodeType !== 3) {
+            node = node.firstChild;
+          }
+          offset = it ? 0 : node.nodeValue.length;
+        }
+        r[p] = node;
+        r[p + 'Offset'] = offset;
+      }
+      nr.start = r.startOffset > 0 ? r.start.splitText(r.startOffset) : r.start;
+      if (r.start === r.end) {
+        if ((r.endOffset - r.startOffset) < nr.start.nodeValue.length) {
+          nr.start.splitText(r.endOffset - r.startOffset);
+        }
+        nr.end = nr.start;
+      } else {
+        if (r.endOffset < r.end.nodeValue.length) {
+          r.end.splitText(r.endOffset);
+        }
+        nr.end = r.end;
+      }
+      nr.commonAncestor = this.commonAncestorContainer;
+      while (nr.commonAncestor.nodeType !== 1) {
+        nr.commonAncestor = nr.commonAncestor.parentNode;
+      }
+      return new Range.NormalizedRange(nr);
+    };
+
+    BrowserRange.prototype.serialize = function(root, ignoreSelector) {
+      return this.normalize(root).serialize(root, ignoreSelector);
+    };
+
+    return BrowserRange;
+
+  })();
+
+  Range.NormalizedRange = (function() {
+
+    function NormalizedRange(obj) {
+      this.commonAncestor = obj.commonAncestor;
+      this.start = obj.start;
+      this.end = obj.end;
+    }
+
+    NormalizedRange.prototype.normalize = function(root) {
+      return this;
+    };
+
+    NormalizedRange.prototype.limit = function(bounds) {
+      var nodes, parent, startParents, _k, _len2, _ref1;
+      nodes = $.grep(this.textNodes(), function(node) {
+        return node.parentNode === bounds || $.contains(bounds, node.parentNode);
+      });
+      if (!nodes.length) {
+        return null;
+      }
+      this.start = nodes[0];
+      this.end = nodes[nodes.length - 1];
+      startParents = $(this.start).parents();
+      _ref1 = $(this.end).parents();
+      for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
+        parent = _ref1[_k];
+        if (startParents.index(parent) !== -1) {
+          this.commonAncestor = parent;
+          break;
+        }
+      }
+      return this;
+    };
+
+    NormalizedRange.prototype.serialize = function(root, ignoreSelector) {
+      var end, serialization, start;
+      serialization = function(node, isEnd) {
+        var n, nodes, offset, origParent, textNodes, xpath, _k, _len2;
+        if (ignoreSelector) {
+          origParent = $(node).parents(":not(" + ignoreSelector + ")").eq(0);
+        } else {
+          origParent = $(node).parent();
+        }
+        xpath = origParent.xpath(root)[0];
+        textNodes = origParent.textNodes();
+        nodes = textNodes.slice(0, textNodes.index(node));
+        offset = 0;
+        for (_k = 0, _len2 = nodes.length; _k < _len2; _k++) {
+          n = nodes[_k];
+          offset += n.nodeValue.length;
+        }
+        if (isEnd) {
+          return [xpath, offset + node.nodeValue.length];
+        } else {
+          return [xpath, offset];
+        }
+      };
+      start = serialization(this.start);
+      end = serialization(this.end, true);
+      return new Range.SerializedRange({
+        start: start[0],
+        end: end[0],
+        startOffset: start[1],
+        endOffset: end[1]
+      });
+    };
+
+    NormalizedRange.prototype.text = function() {
+      var node;
+      return ((function() {
+        var _k, _len2, _ref1, _results;
+        _ref1 = this.textNodes();
+        _results = [];
+        for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
+          node = _ref1[_k];
+          _results.push(node.nodeValue);
+        }
+        return _results;
+      }).call(this)).join('');
+    };
+
+    NormalizedRange.prototype.textNodes = function() {
+      var end, start, textNodes, _ref1;
+      textNodes = $(this.commonAncestor).textNodes();
+      _ref1 = [textNodes.index(this.start), textNodes.index(this.end)], start = _ref1[0], end = _ref1[1];
+      return $.makeArray(textNodes.slice(start, end + 1 || 9e9));
+    };
+
+    NormalizedRange.prototype.toRange = function() {
+      var range;
+      range = document.createRange();
+      range.setStartBefore(this.start);
+      range.setEndAfter(this.end);
+      return range;
+    };
+
+    return NormalizedRange;
+
+  })();
+
+  Range.SerializedRange = (function() {
+
+    function SerializedRange(obj) {
+      this.start = obj.start;
+      this.startOffset = obj.startOffset;
+      this.end = obj.end;
+      this.endOffset = obj.endOffset;
+    }
+
+    SerializedRange.prototype.normalize = function(root) {
+      var contains, length, node, p, range, tn, _k, _l, _len2, _len3, _ref1, _ref2;
+      range = {};
+      _ref1 = ['start', 'end'];
+      for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
+        p = _ref1[_k];
+        try {
+          node = Range.nodeFromXPath(this[p], root);
+        } catch (e) {
+          throw new Range.RangeError(p, ("Error while finding " + p + " node: " + this[p] + ": ") + e, e);
+        }
+        if (!node) {
+          throw new Range.RangeError(p, "Couldn't find " + p + " node: " + this[p]);
+        }
+        length = 0;
+        _ref2 = $(node).textNodes();
+        for (_l = 0, _len3 = _ref2.length; _l < _len3; _l++) {
+          tn = _ref2[_l];
+          if (length + tn.nodeValue.length >= this[p + 'Offset']) {
+            range[p + 'Container'] = tn;
+            range[p + 'Offset'] = this[p + 'Offset'] - length;
+            break;
+          } else {
+            length += tn.nodeValue.length;
+          }
+        }
+        if (!(range[p + 'Offset'] != null)) {
+          throw new Range.RangeError("" + p + "offset", "Couldn't find offset " + this[p + 'Offset'] + " in element " + this[p]);
+        }
+      }
+      contains = !(document.compareDocumentPosition != null) ? function(a, b) {
+        return a.contains(b);
+      } : function(a, b) {
+        return a.compareDocumentPosition(b) & 16;
+      };
+      $(range.startContainer).parents().reverse().each(function() {
+        if (contains(this, range.endContainer)) {
+          range.commonAncestorContainer = this;
+          return false;
+        }
+      });
+      return new Range.BrowserRange(range).normalize(root);
+    };
+
+    SerializedRange.prototype.serialize = function(root, ignoreSelector) {
+      return this.normalize(root).serialize(root, ignoreSelector);
+    };
+
+    SerializedRange.prototype.toObject = function() {
+      return {
+        start: this.start,
+        startOffset: this.startOffset,
+        end: this.end,
+        endOffset: this.endOffset
+      };
+    };
+
+    return SerializedRange;
+
+  })();
+
+  util = {
+    uuid: (function() {
+      var counter;
+      counter = 0;
+      return function() {
+        return counter++;
+      };
+    })(),
+    getGlobal: function() {
+      return (function() {
+        return this;
+      })();
+    },
+    maxZIndex: function($elements) {
+      var all, el;
+      all = (function() {
+        var _k, _len2, _results;
+        _results = [];
+        for (_k = 0, _len2 = $elements.length; _k < _len2; _k++) {
+          el = $elements[_k];
+          if ($(el).css('position') === 'static') {
+            _results.push(-1);
+          } else {
+            _results.push(parseInt($(el).css('z-index'), 10) || -1);
+          }
+        }
+        return _results;
+      })();
+      return Math.max.apply(Math, all);
+    },
+    mousePosition: function(e, offsetEl) {
+      var offset;
+      offset = $(offsetEl).offset();
+      return {
+        top: e.pageY - offset.top,
+        left: e.pageX - offset.left
+      };
+    },
+    preventEventDefault: function(event) {
+      return event != null ? typeof event.preventDefault === "function" ? event.preventDefault() : void 0 : void 0;
+    }
+  };
+
+  _Annotator = this.Annotator;
+
+  Annotator = (function(_super) {
+
+    __extends(Annotator, _super);
+
+    Annotator.prototype.events = {
+      ".annotator-adder button click": "onAdderClick",
+      ".annotator-adder button mousedown": "onAdderMousedown",
+      ".annotator-hl mouseover": "onHighlightMouseover",
+      ".annotator-hl mouseout": "startViewerHideTimer"
+    };
+
+    Annotator.prototype.html = {
+      adder: '<div class="annotator-adder"><button>' + _t('Annotate') + '</button></div>',
+      wrapper: '<div class="annotator-wrapper"></div>'
+    };
+
+    Annotator.prototype.options = {
+      readOnly: false
+    };
+
+    Annotator.prototype.plugins = {};
+
+    Annotator.prototype.editor = null;
+
+    Annotator.prototype.viewer = null;
+
+    Annotator.prototype.selectedRanges = null;
+
+    Annotator.prototype.mouseIsDown = false;
+
+    Annotator.prototype.ignoreMouseup = false;
+
+    Annotator.prototype.viewerHideTimer = null;
+
+    function Annotator(element, options) {
+      this.onDeleteAnnotation = __bind(this.onDeleteAnnotation, this);
+
+      this.onEditAnnotation = __bind(this.onEditAnnotation, this);
+
+      this.onAdderClick = __bind(this.onAdderClick, this);
+
+      this.onAdderMousedown = __bind(this.onAdderMousedown, this);
+
+      this.onHighlightMouseover = __bind(this.onHighlightMouseover, this);
+
+      this.checkForEndSelection = __bind(this.checkForEndSelection, this);
+
+      this.checkForStartSelection = __bind(this.checkForStartSelection, this);
+
+      this.clearViewerHideTimer = __bind(this.clearViewerHideTimer, this);
+
+      this.startViewerHideTimer = __bind(this.startViewerHideTimer, this);
+
+      this.showViewer = __bind(this.showViewer, this);
+
+      this.onEditorSubmit = __bind(this.onEditorSubmit, this);
+
+      this.onEditorHide = __bind(this.onEditorHide, this);
+
+      this.showEditor = __bind(this.showEditor, this);
+      Annotator.__super__.constructor.apply(this, arguments);
+      this.plugins = {};
+      if (!Annotator.supported()) {
+        return this;
+      }
+      if (!this.options.readOnly) {
+        this._setupDocumentEvents();
+      }
+      this._setupWrapper()._setupViewer()._setupEditor();
+      this._setupDynamicStyle();
+      this.adder = $(this.html.adder).appendTo(this.wrapper).hide();
+    }
+
+    Annotator.prototype._setupWrapper = function() {
+      this.wrapper = $(this.html.wrapper);
+      this.element.find('script').remove();
+      this.element.wrapInner(this.wrapper);
+      this.wrapper = this.element.find('.annotator-wrapper');
+      return this;
+    };
+
+    Annotator.prototype._setupViewer = function() {
+      var _this = this;
+      this.viewer = new Annotator.Viewer({
+        readOnly: this.options.readOnly
+      });
+      this.viewer.hide().on("edit", this.onEditAnnotation).on("delete", this.onDeleteAnnotation).addField({
+        load: function(field, annotation) {
+          if (annotation.text) {
+            $(field).escape(annotation.text);
+          } else {
+            $(field).html("<i>" + (_t('No Comment')) + "</i>");
+          }
+          return _this.publish('annotationViewerTextField', [field, annotation]);
+        }
+      }).element.appendTo(this.wrapper).bind({
+        "mouseover": this.clearViewerHideTimer,
+        "mouseout": this.startViewerHideTimer
+      });
+      return this;
+    };
+
+    Annotator.prototype._setupEditor = function() {
+      this.editor = new Annotator.Editor();
+      this.editor.hide().on('hide', this.onEditorHide).on('save', this.onEditorSubmit).addField({
+        type: 'textarea',
+        label: _t('Comments') + '\u2026',
+        load: function(field, annotation) {
+          return $(field).find('textarea').val(annotation.text || '');
+        },
+        submit: function(field, annotation) {
+          return annotation.text = $(field).find('textarea').val();
+        }
+      });
+      this.editor.element.appendTo(this.wrapper);
+      return this;
+    };
+
+    Annotator.prototype._setupDocumentEvents = function() {
+      $(document).bind({
+        "mouseup": this.checkForEndSelection,
+        "mousedown": this.checkForStartSelection
+      });
+      return this;
+    };
+
+    Annotator.prototype._setupDynamicStyle = function() {
+      var max, sel, style, x;
+      style = $('#annotator-dynamic-style');
+      if (!style.length) {
+        style = $('<style id="annotator-dynamic-style"></style>').appendTo(document.head);
+      }
+      sel = '*' + ((function() {
+        var _k, _len2, _ref1, _results;
+        _ref1 = ['adder', 'outer', 'notice', 'filter'];
+        _results = [];
+        for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
+          x = _ref1[_k];
+          _results.push(":not(.annotator-" + x + ")");
+        }
+        return _results;
+      })()).join('');
+      max = util.maxZIndex($(document.body).find(sel));
+      max = Math.max(max, 1000);
+      style.text([".annotator-adder, .annotator-outer, .annotator-notice {", "  z-index: " + (max + 20) + ";", "}", ".annotator-filter {", "  z-index: " + (max + 10) + ";", "}"].join("\n"));
+      return this;
+    };
+
+    Annotator.prototype.getSelectedRanges = function() {
+      var browserRange, i, normedRange, r, ranges, rangesToIgnore, selection, _k, _len2;
+      selection = util.getGlobal().getSelection();
+      ranges = [];
+      rangesToIgnore = [];
+      if (!selection.isCollapsed) {
+        ranges = (function() {
+          var _k, _ref1, _results;
+          _results = [];
+          for (i = _k = 0, _ref1 = selection.rangeCount; 0 <= _ref1 ? _k < _ref1 : _k > _ref1; i = 0 <= _ref1 ? ++_k : --_k) {
+            r = selection.getRangeAt(i);
+            browserRange = new Range.BrowserRange(r);
+            normedRange = browserRange.normalize().limit(this.wrapper[0]);
+            if (normedRange === null) {
+              rangesToIgnore.push(r);
+            }
+            _results.push(normedRange);
+          }
+          return _results;
+        }).call(this);
+        selection.removeAllRanges();
+      }
+      for (_k = 0, _len2 = rangesToIgnore.length; _k < _len2; _k++) {
+        r = rangesToIgnore[_k];
+        selection.addRange(r);
+      }
+      return $.grep(ranges, function(range) {
+        if (range) {
+          selection.addRange(range.toRange());
+        }
+        return range;
+      });
+    };
+
+    Annotator.prototype.createAnnotation = function() {
+      var annotation;
+      annotation = {};
+      this.publish('beforeAnnotationCreated', [annotation]);
+      return annotation;
+    };
+
+    Annotator.prototype.setupAnnotation = function(annotation, fireEvents) {
+      var normed, normedRanges, r, root, _k, _l, _len2, _len3, _ref1;
+      if (fireEvents == null) {
+        fireEvents = true;
+      }
+      root = this.wrapper[0];
+      annotation.ranges || (annotation.ranges = this.selectedRanges);
+      normedRanges = [];
+      _ref1 = annotation.ranges;
+      for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
+        r = _ref1[_k];
+        try {
+          normedRanges.push(Range.sniff(r).normalize(root));
+        } catch (e) {
+          if (e instanceof Range.RangeError) {
+            this.publish('rangeNormalizeFail', [annotation, r, e]);
+          } else {
+            throw e;
+          }
+        }
+      }
+      annotation.quote = [];
+      annotation.ranges = [];
+      annotation.highlights = [];
+      for (_l = 0, _len3 = normedRanges.length; _l < _len3; _l++) {
+        normed = normedRanges[_l];
+        annotation.quote.push($.trim(normed.text()));
+        annotation.ranges.push(normed.serialize(this.wrapper[0], '.annotator-hl'));
+        $.merge(annotation.highlights, this.highlightRange(normed));
+      }
+      annotation.quote = annotation.quote.join(' / ');
+      $(annotation.highlights).data('annotation', annotation);
+      if (fireEvents) {
+        this.publish('annotationCreated', [annotation]);
+      }
+      return annotation;
+    };
+
+    Annotator.prototype.updateAnnotation = function(annotation) {
+      this.publish('beforeAnnotationUpdated', [annotation]);
+      this.publish('annotationUpdated', [annotation]);
+      return annotation;
+    };
+
+    Annotator.prototype.deleteAnnotation = function(annotation) {
+      var h, _k, _len2, _ref1;
+      _ref1 = annotation.highlights;
+      for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
+        h = _ref1[_k];
+        $(h).replaceWith(h.childNodes);
+      }
+      this.publish('annotationDeleted', [annotation]);
+      return annotation;
+    };
+
+    Annotator.prototype.loadAnnotations = function(annotations) {
+      var clone, loader,
+        _this = this;
+      if (annotations == null) {
+        annotations = [];
+      }
+      loader = function(annList) {
+        var n, now, _k, _len2;
+        if (annList == null) {
+          annList = [];
+        }
+        now = annList.splice(0, 10);
+        for (_k = 0, _len2 = now.length; _k < _len2; _k++) {
+          n = now[_k];
+          _this.setupAnnotation(n, false);
+        }
+        if (annList.length > 0) {
+          return setTimeout((function() {
+            return loader(annList);
+          }), 10);
+        } else {
+          return _this.publish('annotationsLoaded', [clone]);
+        }
+      };
+      clone = annotations.slice();
+      if (annotations.length) {
+        loader(annotations);
+      }
+      return this;
+    };
+
+    Annotator.prototype.dumpAnnotations = function() {
+      if (this.plugins['Store']) {
+        return this.plugins['Store'].dumpAnnotations();
+      } else {
+        return console.warn(_t("Can't dump annotations without Store plugin."));
+      }
+    };
+
+    Annotator.prototype.highlightRange = function(normedRange, cssClass) {
+      var hl, node, white, _k, _len2, _ref1, _results;
+      if (cssClass == null) {
+        cssClass = 'annotator-hl';
+      }
+      white = /^\s*$/;
+      hl = $("<span class='" + cssClass + "'></span>");
+      _ref1 = normedRange.textNodes();
+      _results = [];
+      for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
+        node = _ref1[_k];
+        if (!white.test(node.nodeValue)) {
+          _results.push($(node).wrapAll(hl).parent().show()[0]);
+        }
+      }
+      return _results;
+    };
+
+    Annotator.prototype.highlightRanges = function(normedRanges, cssClass) {
+      var highlights, r, _k, _len2;
+      if (cssClass == null) {
+        cssClass = 'annotator-hl';
+      }
+      highlights = [];
+      for (_k = 0, _len2 = normedRanges.length; _k < _len2; _k++) {
+        r = normedRanges[_k];
+        $.merge(highlights, this.highlightRange(r, cssClass));
+      }
+      return highlights;
+    };
+
+    Annotator.prototype.addPlugin = function(name, options) {
+      var klass, _base;
+      if (this.plugins[name]) {
+        console.error(_t("You cannot have more than one instance of any plugin."));
+      } else {
+        klass = Annotator.Plugin[name];
+        if (typeof klass === 'function') {
+          this.plugins[name] = new klass(this.element[0], options);
+          this.plugins[name].annotator = this;
+          if (typeof (_base = this.plugins[name]).pluginInit === "function") {
+            _base.pluginInit();
+          }
+        } else {
+          console.error(_t("Could not load ") + name + _t(" plugin. Have you included the appropriate <script> tag?"));
+        }
+      }
+      return this;
+    };
+
+    Annotator.prototype.showEditor = function(annotation, location) {
+      this.editor.element.css(location);
+      this.editor.load(annotation);
+      this.publish('annotationEditorShown', [this.editor, annotation]);
+      return this;
+    };
+
+    Annotator.prototype.onEditorHide = function() {
+      this.publish('annotationEditorHidden', [this.editor]);
+      return this.ignoreMouseup = false;
+    };
+
+    Annotator.prototype.onEditorSubmit = function(annotation) {
+      this.publish('annotationEditorSubmit', [this.editor, annotation]);
+      if (annotation.ranges === void 0) {
+        return this.setupAnnotation(annotation);
+      } else {
+        return this.updateAnnotation(annotation);
+      }
+    };
+
+    Annotator.prototype.showViewer = function(annotations, location) {
+      this.viewer.element.css(location);
+      this.viewer.load(annotations);
+      return this.publish('annotationViewerShown', [this.viewer, annotations]);
+    };
+
+    Annotator.prototype.startViewerHideTimer = function() {
+      if (!this.viewerHideTimer) {
+        return this.viewerHideTimer = setTimeout(this.viewer.hide, 250);
+      }
+    };
+
+    Annotator.prototype.clearViewerHideTimer = function() {
+      clearTimeout(this.viewerHideTimer);
+      return this.viewerHideTimer = false;
+    };
+
+    Annotator.prototype.checkForStartSelection = function(event) {
+      if (!(event && this.isAnnotator(event.target))) {
+        this.startViewerHideTimer();
+        return this.mouseIsDown = true;
+      }
+    };
+
+    Annotator.prototype.checkForEndSelection = function(event) {
+      var container, range, _k, _len2, _ref1;
+      this.mouseIsDown = false;
+      if (this.ignoreMouseup) {
+        return;
+      }
+      this.selectedRanges = this.getSelectedRanges();
+      _ref1 = this.selectedRanges;
+      for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
+        range = _ref1[_k];
+        container = range.commonAncestor;
+        if ($(container).hasClass('annotator-hl')) {
+          container = $(container).parents('[class^=annotator-hl]')[0];
+        }
+        if (this.isAnnotator(container)) {
+          return;
+        }
+      }
+      if (event && this.selectedRanges.length) {
+        return this.adder.css(util.mousePosition(event, this.wrapper[0])).show();
+      } else {
+        return this.adder.hide();
+      }
+    };
+
+    Annotator.prototype.isAnnotator = function(element) {
+      return !!$(element).parents().andSelf().filter('[class^=annotator-]').not(this.wrapper).length;
+    };
+
+    Annotator.prototype.onHighlightMouseover = function(event) {
+      var annotations;
+      this.clearViewerHideTimer();
+      if (this.mouseIsDown || this.viewer.isShown()) {
+        return false;
+      }
+      annotations = $(event.target).parents('.annotator-hl').andSelf().map(function() {
+        return $(this).data("annotation");
+      });
+      return this.showViewer($.makeArray(annotations), util.mousePosition(event, this.wrapper[0]));
+    };
+
+    Annotator.prototype.onAdderMousedown = function(event) {
+      if (event != null) {
+        event.preventDefault();
+      }
+      return this.ignoreMouseup = true;
+    };
+
+    Annotator.prototype.onAdderClick = function(event) {
+      var highlights, position, r, ranges;
+      if (event != null) {
+        event.preventDefault();
+      }
+      position = this.adder.position();
+      this.adder.hide();
+      if (this.selectedRanges && this.selectedRanges.length) {
+        ranges = (function() {
+          var _k, _len2, _ref1, _results;
+          _ref1 = this.selectedRanges;
+          _results = [];
+          for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
+            r = _ref1[_k];
+            _results.push(Range.sniff(r).normalize());
+          }
+          return _results;
+        }).call(this);
+        highlights = this.highlightRanges(ranges, 'annotator-hl annotator-hl-temporary');
+        this.editor.element.one('hide', function() {
+          var h, _k, _len2, _results;
+          _results = [];
+          for (_k = 0, _len2 = highlights.length; _k < _len2; _k++) {
+            h = highlights[_k];
+            _results.push($(h).replaceWith(h.childNodes));
+          }
+          return _results;
+        });
+      }
+      return this.showEditor(this.createAnnotation(), position);
+    };
+
+    Annotator.prototype.onEditAnnotation = function(annotation) {
+      var offset;
+      offset = this.viewer.element.position();
+      this.viewer.hide();
+      return this.showEditor(annotation, offset);
+    };
+
+    Annotator.prototype.onDeleteAnnotation = function(annotation) {
+      this.viewer.hide();
+      return this.deleteAnnotation(annotation);
+    };
+
+    return Annotator;
+
+  })(Delegator);
+
+  Annotator.Plugin = (function(_super) {
+
+    __extends(Plugin, _super);
+
+    function Plugin(element, options) {
+      Plugin.__super__.constructor.apply(this, arguments);
+    }
+
+    Plugin.prototype.pluginInit = function() {};
+
+    return Plugin;
+
+  })(Delegator);
+
+  g = util.getGlobal();
+
+  if (!(((_ref1 = g.document) != null ? _ref1.evaluate : void 0) != null)) {
+    $.getScript('http://assets.annotateit.org/vendor/xpath.min.js');
+  }
+
+  if (!(g.getSelection != null)) {
+    $.getScript('http://assets.annotateit.org/vendor/ierange.min.js');
+  }
+
+  if (!(g.JSON != null)) {
+    $.getScript('http://assets.annotateit.org/vendor/json2.min.js');
+  }
+
+  Annotator.$ = $;
+
+  Annotator.Delegator = Delegator;
+
+  Annotator.Range = Range;
+
+  Annotator._t = _t;
+
+  Annotator.supported = function() {
+    return (function() {
+      return !!this.getSelection;
+    })();
+  };
+
+  Annotator.noConflict = function() {
+    util.getGlobal().Annotator = _Annotator;
+    return this;
+  };
+
+  $.plugin('annotator', Annotator);
+
+  this.Annotator = Annotator;
+
+  Annotator.Widget = (function(_super) {
+
+    __extends(Widget, _super);
+
+    Widget.prototype.classes = {
+      hide: 'annotator-hide',
+      invert: {
+        x: 'annotator-invert-x',
+        y: 'annotator-invert-y'
+      }
+    };
+
+    function Widget(element, options) {
+      Widget.__super__.constructor.apply(this, arguments);
+      this.classes = $.extend({}, Annotator.Widget.prototype.classes, this.classes);
+    }
+
+    Widget.prototype.checkOrientation = function() {
+      var current, offset, viewport, widget, window;
+      this.resetOrientation();
+      window = $(util.getGlobal());
+      widget = this.element.children(":first");
+      offset = widget.offset();
+      viewport = {
+        top: window.scrollTop(),
+        right: window.width() + window.scrollLeft()
+      };
+      current = {
+        top: offset.top,
+        right: offset.left + widget.width()
+      };
+      if ((current.top - viewport.top) < 0) {
+        this.invertY();
+      }
+      if ((current.right - viewport.right) > 0) {
+        this.invertX();
+      }
+      return this;
+    };
+
+    Widget.prototype.resetOrientation = function() {
+      this.element.removeClass(this.classes.invert.x).removeClass(this.classes.invert.y);
+      return this;
+    };
+
+    Widget.prototype.invertX = function() {
+      this.element.addClass(this.classes.invert.x);
+      return this;
+    };
+
+    Widget.prototype.invertY = function() {
+      this.element.addClass(this.classes.invert.y);
+      return this;
+    };
+
+    Widget.prototype.isInvertedY = function() {
+      return this.element.hasClass(this.classes.invert.y);
+    };
+
+    Widget.prototype.isInvertedX = function() {
+      return this.element.hasClass(this.classes.invert.x);
+    };
+
+    return Widget;
+
+  })(Delegator);
+
+  Annotator.Editor = (function(_super) {
+
+    __extends(Editor, _super);
+
+    Editor.prototype.events = {
+      "form submit": "submit",
+      ".annotator-save click": "submit",
+      ".annotator-cancel click": "hide",
+      ".annotator-cancel mouseover": "onCancelButtonMouseover",
+      "textarea keydown": "processKeypress"
+    };
+
+    Editor.prototype.classes = {
+      hide: 'annotator-hide',
+      focus: 'annotator-focus'
+    };
+
+    Editor.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\">" + _t('Cancel') + "</a>\n<a href=\"#save\" class=\"annotator-save annotator-focus\">" + _t('Save') + "</a>\n    </div>\n  </form>\n</div>";
+
+    Editor.prototype.options = {};
+
+    function Editor(options) {
+      this.onCancelButtonMouseover = __bind(this.onCancelButtonMouseover, this);
+
+      this.processKeypress = __bind(this.processKeypress, this);
+
+      this.submit = __bind(this.submit, this);
+
+      this.load = __bind(this.load, this);
+
+      this.hide = __bind(this.hide, this);
+
+      this.show = __bind(this.show, this);
+      Editor.__super__.constructor.call(this, $(this.html)[0], options);
+      this.fields = [];
+      this.annotation = {};
+    }
+
+    Editor.prototype.show = function(event) {
+      util.preventEventDefault(event);
+      this.element.removeClass(this.classes.hide);
+      this.element.find('.annotator-save').addClass(this.classes.focus);
+      this.checkOrientation();
+      this.element.find(":input:first").focus();
+      this.setupDraggables();
+      return this.publish('show');
+    };
+
+    Editor.prototype.hide = function(event) {
+      util.preventEventDefault(event);
+      this.element.addClass(this.classes.hide);
+      return this.publish('hide');
+    };
+
+    Editor.prototype.load = function(annotation) {
+      var field, _k, _len2, _ref2;
+      this.annotation = annotation;
+      this.publish('load', [this.annotation]);
+      _ref2 = this.fields;
+      for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
+        field = _ref2[_k];
+        field.load(field.element, this.annotation);
+      }
+      return this.show();
+    };
+
+    Editor.prototype.submit = function(event) {
+      var field, _k, _len2, _ref2;
+      util.preventEventDefault(event);
+      _ref2 = this.fields;
+      for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
+        field = _ref2[_k];
+        field.submit(field.element, this.annotation);
+      }
+      this.publish('save', [this.annotation]);
+      return this.hide();
+    };
+
+    Editor.prototype.addField = function(options) {
+      var element, field, input;
+      field = $.extend({
+        id: 'annotator-field-' + util.uuid(),
+        type: 'input',
+        label: '',
+        load: function() {},
+        submit: function() {}
+      }, options);
+      input = null;
+      element = $('<li class="annotator-item" />');
+      field.element = element[0];
+      switch (field.type) {
+        case 'textarea':
+          input = $('<textarea />');
+          break;
+        case 'input':
+        case 'checkbox':
+          input = $('<input />');
+      }
+      element.append(input);
+      input.attr({
+        id: field.id,
+        placeholder: field.label
+      });
+      if (field.type === 'checkbox') {
+        input[0].type = 'checkbox';
+        element.addClass('annotator-checkbox');
+        element.append($('<label />', {
+          "for": field.id,
+          html: field.label
+        }));
+      }
+      this.element.find('ul:first').append(element);
+      this.fields.push(field);
+      return field.element;
+    };
+
+    Editor.prototype.checkOrientation = function() {
+      var controls, list;
+      Editor.__super__.checkOrientation.apply(this, arguments);
+      list = this.element.find('ul');
+      controls = this.element.find('.annotator-controls');
+      if (this.element.hasClass(this.classes.invert.y)) {
+        controls.insertBefore(list);
+      } else if (controls.is(':first-child')) {
+        controls.insertAfter(list);
+      }
+      return this;
+    };
+
+    Editor.prototype.processKeypress = function(event) {
+      if (event.keyCode === 27) {
+        return this.hide();
+      } else if (event.keyCode === 13 && !event.shiftKey) {
+        return this.submit();
+      }
+    };
+
+    Editor.prototype.onCancelButtonMouseover = function() {
+      return this.element.find('.' + this.classes.focus).removeClass(this.classes.focus);
+    };
+
+    Editor.prototype.setupDraggables = function() {
+      var classes, controls, cornerItem, editor, mousedown, onMousedown, onMousemove, onMouseup, resize, textarea, throttle,
+        _this = this;
+      this.element.find('.annotator-resize').remove();
+      if (this.element.hasClass(this.classes.invert.y)) {
+        cornerItem = this.element.find('.annotator-item:last');
+      } else {
+        cornerItem = this.element.find('.annotator-item:first');
+      }
+      if (cornerItem) {
+        $('<span class="annotator-resize"></span>').appendTo(cornerItem);
+      }
+      mousedown = null;
+      classes = this.classes;
+      editor = this.element;
+      textarea = null;
+      resize = editor.find('.annotator-resize');
+      controls = editor.find('.annotator-controls');
+      throttle = false;
+      onMousedown = function(event) {
+        if (event.target === this) {
+          mousedown = {
+            element: this,
+            top: event.pageY,
+            left: event.pageX
+          };
+          textarea = editor.find('textarea:first');
+          $(window).bind({
+            'mouseup.annotator-editor-resize': onMouseup,
+            'mousemove.annotator-editor-resize': onMousemove
+          });
+          return event.preventDefault();
+        }
+      };
+      onMouseup = function() {
+        mousedown = null;
+        return $(window).unbind('.annotator-editor-resize');
+      };
+      onMousemove = function(event) {
+        var diff, directionX, directionY, height, width;
+        if (mousedown && throttle === false) {
+          diff = {
+            top: event.pageY - mousedown.top,
+            left: event.pageX - mousedown.left
+          };
+          if (mousedown.element === resize[0]) {
+            height = textarea.outerHeight();
+            width = textarea.outerWidth();
+            directionX = editor.hasClass(classes.invert.x) ? -1 : 1;
+            directionY = editor.hasClass(classes.invert.y) ? 1 : -1;
+            textarea.height(height + (diff.top * directionY));
+            textarea.width(width + (diff.left * directionX));
+            if (textarea.outerHeight() !== height) {
+              mousedown.top = event.pageY;
+            }
+            if (textarea.outerWidth() !== width) {
+              mousedown.left = event.pageX;
+            }
+          } else if (mousedown.element === controls[0]) {
+            editor.css({
+              top: parseInt(editor.css('top'), 10) + diff.top,
+              left: parseInt(editor.css('left'), 10) + diff.left
+            });
+            mousedown.top = event.pageY;
+            mousedown.left = event.pageX;
+          }
+          throttle = true;
+          return setTimeout(function() {
+            return throttle = false;
+          }, 1000 / 60);
+        }
+      };
+      resize.bind('mousedown', onMousedown);
+      return controls.bind('mousedown', onMousedown);
+    };
+
+    return Editor;
+
+  })(Annotator.Widget);
+
+  Annotator.Viewer = (function(_super) {
+
+    __extends(Viewer, _super);
+
+    Viewer.prototype.events = {
+      ".annotator-edit click": "onEditClick",
+      ".annotator-delete click": "onDeleteClick"
+    };
+
+    Viewer.prototype.classes = {
+      hide: 'annotator-hide',
+      showControls: 'annotator-visible'
+    };
+
+    Viewer.prototype.html = {
+      element: "<div class=\"annotator-outer annotator-viewer\">\n  <ul class=\"annotator-widget annotator-listing\"></ul>\n</div>",
+      item: "<li class=\"annotator-annotation annotator-item\">\n  <span class=\"annotator-controls\">\n    <a href=\"#\" title=\"View as webpage\" class=\"annotator-link\">View as webpage</a>\n    <button title=\"Edit\" class=\"annotator-edit\">Edit</button>\n    <button title=\"Delete\" class=\"annotator-delete\">Delete</button>\n  </span>\n</li>"
+    };
+
+    Viewer.prototype.options = {
+      readOnly: false
+    };
+
+    function Viewer(options) {
+      this.onDeleteClick = __bind(this.onDeleteClick, this);
+
+      this.onEditClick = __bind(this.onEditClick, this);
+
+      this.load = __bind(this.load, this);
+
+      this.hide = __bind(this.hide, this);
+
+      this.show = __bind(this.show, this);
+      Viewer.__super__.constructor.call(this, $(this.html.element)[0], options);
+      this.item = $(this.html.item)[0];
+      this.fields = [];
+      this.annotations = [];
+    }
+
+    Viewer.prototype.show = function(event) {
+      var controls,
+        _this = this;
+      util.preventEventDefault(event);
+      controls = this.element.find('.annotator-controls').addClass(this.classes.showControls);
+      setTimeout((function() {
+        return controls.removeClass(_this.classes.showControls);
+      }), 500);
+      this.element.removeClass(this.classes.hide);
+      return this.checkOrientation().publish('show');
+    };
+
+    Viewer.prototype.isShown = function() {
+      return !this.element.hasClass(this.classes.hide);
+    };
+
+    Viewer.prototype.hide = function(event) {
+      util.preventEventDefault(event);
+      this.element.addClass(this.classes.hide);
+      return this.publish('hide');
+    };
+
+    Viewer.prototype.load = function(annotations) {
+      var annotation, controller, controls, del, edit, element, field, item, link, links, list, _k, _l, _len2, _len3, _ref2, _ref3;
+      this.annotations = annotations || [];
+      list = this.element.find('ul:first').empty();
+      _ref2 = this.annotations;
+      for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
+        annotation = _ref2[_k];
+        item = $(this.item).clone().appendTo(list).data('annotation', annotation);
+        controls = item.find('.annotator-controls');
+        link = controls.find('.annotator-link');
+        edit = controls.find('.annotator-edit');
+        del = controls.find('.annotator-delete');
+        links = new LinkParser(annotation.links || []).get('alternate', {
+          'type': 'text/html'
+        });
+        if (links.length === 0 || !(links[0].href != null)) {
+          link.remove();
+        } else {
+          link.attr('href', links[0].href);
+        }
+        if (this.options.readOnly) {
+          edit.remove();
+          del.remove();
+        } else {
+          controller = {
+            showEdit: function() {
+              return edit.removeAttr('disabled');
+            },
+            hideEdit: function() {
+              return edit.attr('disabled', 'disabled');
+            },
+            showDelete: function() {
+              return del.removeAttr('disabled');
+            },
+            hideDelete: function() {
+              return del.attr('disabled', 'disabled');
+            }
+          };
+        }
+        _ref3 = this.fields;
+        for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
+          field = _ref3[_l];
+          element = $(field.element).clone().appendTo(item)[0];
+          field.load(element, annotation, controller);
+        }
+      }
+      this.publish('load', [this.annotations]);
+      return this.show();
+    };
+
+    Viewer.prototype.addField = function(options) {
+      var field;
+      field = $.extend({
+        load: function() {}
+      }, options);
+      field.element = $('<div />')[0];
+      this.fields.push(field);
+      field.element;
+      return this;
+    };
+
+    Viewer.prototype.onEditClick = function(event) {
+      return this.onButtonClick(event, 'edit');
+    };
+
+    Viewer.prototype.onDeleteClick = function(event) {
+      return this.onButtonClick(event, 'delete');
+    };
+
+    Viewer.prototype.onButtonClick = function(event, type) {
+      var item;
+      item = $(event.target).parents('.annotator-annotation');
+      return this.publish(type, [item.data('annotation')]);
+    };
+
+    return Viewer;
+
+  })(Annotator.Widget);
+
+  LinkParser = (function() {
+
+    function LinkParser(data) {
+      this.data = data;
+    }
+
+    LinkParser.prototype.get = function(rel, cond) {
+      var d, k, keys, match, v, _k, _len2, _ref2, _results;
+      if (cond == null) {
+        cond = {};
+      }
+      cond = $.extend({}, cond, {
+        rel: rel
+      });
+      keys = (function() {
+        var _results;
+        _results = [];
+        for (k in cond) {
+          if (!__hasProp.call(cond, k)) continue;
+          v = cond[k];
+          _results.push(k);
+        }
+        return _results;
+      })();
+      _ref2 = this.data;
+      _results = [];
+      for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
+        d = _ref2[_k];
+        match = keys.reduce((function(m, k) {
+          return m && (d[k] === cond[k]);
+        }), true);
+        if (match) {
+          _results.push(d);
+        } else {
+          continue;
+        }
+      }
+      return _results;
+    };
+
+    return LinkParser;
+
+  })();
+
+  Annotator = Annotator || {};
+
+  Annotator.Notification = (function(_super) {
+
+    __extends(Notification, _super);
+
+    Notification.prototype.events = {
+      "click": "hide"
+    };
+
+    Notification.prototype.options = {
+      html: "<div class='annotator-notice'></div>",
+      classes: {
+        show: "annotator-notice-show",
+        info: "annotator-notice-info",
+        success: "annotator-notice-success",
+        error: "annotator-notice-error"
+      }
+    };
+
+    function Notification(options) {
+      this.hide = __bind(this.hide, this);
+
+      this.show = __bind(this.show, this);
+      Notification.__super__.constructor.call(this, $(this.options.html).appendTo(document.body)[0], options);
+    }
+
+    Notification.prototype.show = function(message, status) {
+      if (status == null) {
+        status = Annotator.Notification.INFO;
+      }
+      $(this.element).addClass(this.options.classes.show).addClass(this.options.classes[status]).escape(message || "");
+      setTimeout(this.hide, 5000);
+      return this;
+    };
+
+    Notification.prototype.hide = function() {
+      $(this.element).removeClass(this.options.classes.show);
+      return this;
+    };
+
+    return Notification;
+
+  })(Delegator);
+
+  Annotator.Notification.INFO = 'show';
+
+  Annotator.Notification.SUCCESS = 'success';
+
+  Annotator.Notification.ERROR = 'error';
+
+  $(function() {
+    var notification;
+    notification = new Annotator.Notification;
+    Annotator.showNotification = notification.show;
+    return Annotator.hideNotification = notification.hide;
+  });
+
+  Annotator.Plugin.Unsupported = (function(_super) {
+
+    __extends(Unsupported, _super);
+
+    function Unsupported() {
+      return Unsupported.__super__.constructor.apply(this, arguments);
+    }
+
+    Unsupported.prototype.options = {
+      message: Annotator._t("Sorry your current browser does not support the Annotator")
+    };
+
+    Unsupported.prototype.pluginInit = function() {
+      var _this = this;
+      if (!Annotator.supported()) {
+        return $(function() {
+          Annotator.showNotification(_this.options.message);
+          if ((window.XMLHttpRequest === void 0) && (ActiveXObject !== void 0)) {
+            return $('html').addClass('ie6');
+          }
+        });
+      }
+    };
+
+    return Unsupported;
+
+  })(Annotator.Plugin);
+
+  createDateFromISO8601 = function(string) {
+    var d, date, offset, regexp, time, _ref2;
+    regexp = "([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})))?)?)?)?";
+    d = string.match(new RegExp(regexp));
+    offset = 0;
+    date = new Date(d[1], 0, 1);
+    if (d[3]) {
+      date.setMonth(d[3] - 1);
+    }
+    if (d[5]) {
+      date.setDate(d[5]);
+    }
+    if (d[7]) {
+      date.setHours(d[7]);
+    }
+    if (d[8]) {
+      date.setMinutes(d[8]);
+    }
+    if (d[10]) {
+      date.setSeconds(d[10]);
+    }
+    if (d[12]) {
+      date.setMilliseconds(Number("0." + d[12]) * 1000);
+    }
+    if (d[14]) {
+      offset = (Number(d[16]) * 60) + Number(d[17]);
+      offset *= (_ref2 = d[15] === '-') != null ? _ref2 : {
+        1: -1
+      };
+    }
+    offset -= date.getTimezoneOffset();
+    time = Number(date) + (offset * 60 * 1000);
+    date.setTime(Number(time));
+    return date;
+  };
+
+  base64Decode = function(data) {
+    var ac, b64, bits, dec, h1, h2, h3, h4, i, o1, o2, o3, tmp_arr;
+    if (typeof atob !== "undefined" && atob !== null) {
+      return atob(data);
+    } else {
+      b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+      i = 0;
+      ac = 0;
+      dec = "";
+      tmp_arr = [];
+      if (!data) {
+        return data;
+      }
+      data += '';
+      while (i < data.length) {
+        h1 = b64.indexOf(data.charAt(i++));
+        h2 = b64.indexOf(data.charAt(i++));
+        h3 = b64.indexOf(data.charAt(i++));
+        h4 = b64.indexOf(data.charAt(i++));
+        bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
+        o1 = bits >> 16 & 0xff;
+        o2 = bits >> 8 & 0xff;
+        o3 = bits & 0xff;
+        if (h3 === 64) {
+          tmp_arr[ac++] = String.fromCharCode(o1);
+        } else if (h4 === 64) {
+          tmp_arr[ac++] = String.fromCharCode(o1, o2);
+        } else {
+          tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
+        }
+      }
+      return tmp_arr.join('');
+    }
+  };
+
+  base64UrlDecode = function(data) {
+    var i, m, _k, _ref2;
+    m = data.length % 4;
+    if (m !== 0) {
+      for (i = _k = 0, _ref2 = 4 - m; 0 <= _ref2 ? _k < _ref2 : _k > _ref2; i = 0 <= _ref2 ? ++_k : --_k) {
+        data += '=';
+      }
+    }
+    data = data.replace(/-/g, '+');
+    data = data.replace(/_/g, '/');
+    return base64Decode(data);
+  };
+
+  parseToken = function(token) {
+    var head, payload, sig, _ref2;
+    _ref2 = token.split('.'), head = _ref2[0], payload = _ref2[1], sig = _ref2[2];
+    return JSON.parse(base64UrlDecode(payload));
+  };
+
+  Annotator.Plugin.Auth = (function(_super) {
+
+    __extends(Auth, _super);
+
+    Auth.prototype.options = {
+      token: null,
+      tokenUrl: '/auth/token',
+      autoFetch: true,
+      requestMethod: 'GET',
+      requestData: null,
+      unauthorizedCallback: null
+    };
+
+    function Auth(element, options) {
+      Auth.__super__.constructor.apply(this, arguments);
+      this.waitingForToken = [];
+      if (this.options.token) {
+        this.setToken(this.options.token);
+      } else {
+        this.requestToken();
+      }
+    }
+
+    Auth.prototype.requestToken = function() {
+      var _this = this;
+      this.requestInProgress = true;
+      return $.ajax({
+        url: this.options.tokenUrl,
+        dataType: 'text',
+        data: this.options.requestData,
+        type: this.options.requestMethod,
+        xhrFields: {
+          withCredentials: true
+        }
+      }).done(function(data, status, xhr) {
+        return _this.setToken(data);
+      }).fail(function(xhr, status, err) {
+        var callback, msg;
+        if (xhr.status === 401) {
+          callback = _this.options.unauthorizedCallback;
+          if ((callback != null) && callback(_this)) {
+            _this.retryTimeout = setTimeout((function() {
+              return _this.requestToken();
+            }), 1000);
+            return;
+          }
+        }
+        msg = Annotator._t("Couldn't get auth token:");
+        console.error("" + msg + " " + err, xhr);
+        return Annotator.showNotification("" + msg + " " + xhr.responseText, Annotator.Notification.ERROR);
+      }).always(function() {
+        return _this.requestInProgress = false;
+      });
+    };
+
+    Auth.prototype.setToken = function(token) {
+      var _results,
+        _this = this;
+      this.token = token;
+      this._unsafeToken = parseToken(token);
+      if (this.haveValidToken()) {
+        if (this.options.autoFetch) {
+          this.refreshTimeout = setTimeout((function() {
+            return _this.requestToken();
+          }), (this.timeToExpiry() - 2) * 1000);
+        }
+        this.updateHeaders();
+        _results = [];
+        while (this.waitingForToken.length > 0) {
+          _results.push(this.waitingForToken.pop()(this._unsafeToken));
+        }
+        return _results;
+      } else {
+        console.warn(Annotator._t("Didn't get a valid token."));
+        if (this.options.autoFetch) {
+          console.warn(Annotator._t("Getting a new token in 10s."));
+          return setTimeout((function() {
+            return _this.requestToken();
+          }), 10 * 1000);
+        }
+      }
+    };
+
+    Auth.prototype.haveValidToken = function() {
+      var allFields;
+      allFields = this._unsafeToken && this._unsafeToken.issuedAt && this._unsafeToken.ttl && this._unsafeToken.consumerKey;
+      return allFields && this.timeToExpiry() > 0;
+    };
+
+    Auth.prototype.timeToExpiry = function() {
+      var expiry, issue, now, timeToExpiry;
+      now = new Date().getTime() / 1000;
+      issue = createDateFromISO8601(this._unsafeToken.issuedAt).getTime() / 1000;
+      expiry = issue + this._unsafeToken.ttl;
+      timeToExpiry = expiry - now;
+      if (timeToExpiry > 0) {
+        return timeToExpiry;
+      } else {
+        return 0;
+      }
+    };
+
+    Auth.prototype.updateHeaders = function() {
+      var current;
+      current = this.element.data('annotator:headers');
+      return this.element.data('annotator:headers', $.extend(current, {
+        'x-annotator-auth-token': this.token
+      }));
+    };
+
+    Auth.prototype.withToken = function(callback) {
+      if (!(callback != null)) {
+        return;
+      }
+      if (this.haveValidToken()) {
+        return callback(this._unsafeToken);
+      } else {
+        this.waitingForToken.push(callback);
+        if (!this.requestInProgress) {
+          return this.requestToken();
+        }
+      }
+    };
+
+    return Auth;
+
+  })(Annotator.Plugin);
+
+  Annotator.Plugin.Store = (function(_super) {
+
+    __extends(Store, _super);
+
+    Store.prototype.events = {
+      'annotationCreated': 'annotationCreated',
+      'annotationDeleted': 'annotationDeleted',
+      'annotationUpdated': 'annotationUpdated'
+    };
+
+    Store.prototype.options = {
+      prefix: '/store',
+      autoFetch: true,
+      annotationData: {},
+      loadFromSearch: false,
+      urls: {
+        create: '/annotations',
+        read: '/annotations/:id',
+        update: '/annotations/:id',
+        destroy: '/annotations/:id',
+        search: '/search'
+      }
+    };
+
+    function Store(element, options) {
+      this._onError = __bind(this._onError, this);
+
+      this._onLoadAnnotationsFromSearch = __bind(this._onLoadAnnotationsFromSearch, this);
+
+      this._onLoadAnnotations = __bind(this._onLoadAnnotations, this);
+
+      this._getAnnotations = __bind(this._getAnnotations, this);
+      Store.__super__.constructor.apply(this, arguments);
+      this.annotations = [];
+    }
+
+    Store.prototype.pluginInit = function() {
+      if (!Annotator.supported()) {
+        return;
+      }
+      if (this.annotator.plugins.Auth) {
+        return this.annotator.plugins.Auth.withToken(this._getAnnotations);
+      } else {
+        return this._getAnnotations();
+      }
+    };
+
+    Store.prototype._getAnnotations = function() {
+      if (this.options.loadFromSearch) {
+        return this.loadAnnotationsFromSearch(this.options.loadFromSearch);
+      } else {
+        return this.loadAnnotations();
+      }
+    };
+
+    Store.prototype.annotationCreated = function(annotation) {
+      var _this = this;
+      if (__indexOf.call(this.annotations, annotation) < 0) {
+        this.registerAnnotation(annotation);
+        return this._apiRequest('create', annotation, function(data) {
+          if (!(data.id != null)) {
+            console.warn(Annotator._t("Warning: No ID returned from server for annotation "), annotation);
+          }
+          return _this.updateAnnotation(annotation, data);
+        });
+      } else {
+        return this.updateAnnotation(annotation, {});
+      }
+    };
+
+    Store.prototype.annotationUpdated = function(annotation) {
+      var _this = this;
+      if (__indexOf.call(this.annotations, annotation) >= 0) {
+        return this._apiRequest('update', annotation, (function(data) {
+          return _this.updateAnnotation(annotation, data);
+        }));
+      }
+    };
+
+    Store.prototype.annotationDeleted = function(annotation) {
+      var _this = this;
+      if (__indexOf.call(this.annotations, annotation) >= 0) {
+        return this._apiRequest('destroy', annotation, (function() {
+          return _this.unregisterAnnotation(annotation);
+        }));
+      }
+    };
+
+    Store.prototype.registerAnnotation = function(annotation) {
+      return this.annotations.push(annotation);
+    };
+
+    Store.prototype.unregisterAnnotation = function(annotation) {
+      return this.annotations.splice(this.annotations.indexOf(annotation), 1);
+    };
+
+    Store.prototype.updateAnnotation = function(annotation, data) {
+      if (__indexOf.call(this.annotations, annotation) < 0) {
+        console.error(Annotator._t("Trying to update unregistered annotation!"));
+      } else {
+        $.extend(annotation, data);
+      }
+      return $(annotation.highlights).data('annotation', annotation);
+    };
+
+    Store.prototype.loadAnnotations = function() {
+      return this._apiRequest('read', null, this._onLoadAnnotations);
+    };
+
+    Store.prototype._onLoadAnnotations = function(data) {
+      if (data == null) {
+        data = [];
+      }
+      this.annotations = data;
+      return this.annotator.loadAnnotations(data.slice());
+    };
+
+    Store.prototype.loadAnnotationsFromSearch = function(searchOptions) {
+      return this._apiRequest('search', searchOptions, this._onLoadAnnotationsFromSearch);
+    };
+
+    Store.prototype._onLoadAnnotationsFromSearch = function(data) {
+      if (data == null) {
+        data = {};
+      }
+      return this._onLoadAnnotations(data.rows || []);
+    };
+
+    Store.prototype.dumpAnnotations = function() {
+      var ann, _k, _len2, _ref2, _results;
+      _ref2 = this.annotations;
+      _results = [];
+      for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
+        ann = _ref2[_k];
+        _results.push(JSON.parse(this._dataFor(ann)));
+      }
+      return _results;
+    };
+
+    Store.prototype._apiRequest = function(action, obj, onSuccess) {
+      var id, options, request, url;
+      id = obj && obj.id;
+      url = this._urlFor(action, id);
+      options = this._apiRequestOptions(action, obj, onSuccess);
+      request = $.ajax(url, options);
+      request._id = id;
+      request._action = action;
+      return request;
+    };
+
+    Store.prototype._apiRequestOptions = function(action, obj, onSuccess) {
+      var opts;
+      opts = {
+        type: this._methodFor(action),
+        headers: this.element.data('annotator:headers'),
+        dataType: "json",
+        success: onSuccess || function() {},
+        error: this._onError
+      };
+      if (action === "search") {
+        opts = $.extend(opts, {
+          data: obj
+        });
+      } else {
+        opts = $.extend(opts, {
+          data: obj && this._dataFor(obj),
+          contentType: "application/json; charset=utf-8"
+        });
+      }
+      return opts;
+    };
+
+    Store.prototype._urlFor = function(action, id) {
+      var replaceWith, url;
+      replaceWith = id != null ? '/' + id : '';
+      url = this.options.prefix || '/';
+      url += this.options.urls[action];
+      url = url.replace(/\/:id/, replaceWith);
+      return url;
+    };
+
+    Store.prototype._methodFor = function(action) {
+      var table;
+      table = {
+        'create': 'POST',
+        'read': 'GET',
+        'update': 'PUT',
+        'destroy': 'DELETE',
+        'search': 'GET'
+      };
+      return table[action];
+    };
+
+    Store.prototype._dataFor = function(annotation) {
+      var data, highlights;
+      highlights = annotation.highlights;
+      delete annotation.highlights;
+      $.extend(annotation, this.options.annotationData);
+      data = JSON.stringify(annotation);
+      if (highlights) {
+        annotation.highlights = highlights;
+      }
+      return data;
+    };
+
+    Store.prototype._onError = function(xhr) {
+      var action, message;
+      action = xhr._action;
+      message = Annotator._t("Sorry we could not ") + action + Annotator._t(" this annotation");
+      if (xhr._action === 'search') {
+        message = Annotator._t("Sorry we could not search the store for annotations");
+      } else if (xhr._action === 'read' && !xhr._id) {
+        message = Annotator._t("Sorry we could not ") + action + Annotator._t(" the annotations from the store");
+      }
+      switch (xhr.status) {
+        case 401:
+          message = Annotator._t("Sorry you are not allowed to ") + action + Annotator._t(" this annotation");
+          break;
+        case 404:
+          message = Annotator._t("Sorry we could not connect to the annotations store");
+          break;
+        case 500:
+          message = Annotator._t("Sorry something went wrong with the annotation store");
+      }
+      Annotator.showNotification(message, Annotator.Notification.ERROR);
+      return console.error(Annotator._t("API request failed:") + (" '" + xhr.status + "'"));
+    };
+
+    return Store;
+
+  })(Annotator.Plugin);
+
+  Annotator.Plugin.Permissions = (function(_super) {
+
+    __extends(Permissions, _super);
+
+    Permissions.prototype.events = {
+      'beforeAnnotationCreated': 'addFieldsToAnnotation'
+    };
+
+    Permissions.prototype.options = {
+      showViewPermissionsCheckbox: true,
+      showEditPermissionsCheckbox: true,
+      userId: function(user) {
+        return user;
+      },
+      userString: function(user) {
+        return user;
+      },
+      userAuthorize: function(action, annotation, user) {
+        var token, tokens, _k, _len2;
+        if (annotation.permissions) {
+          tokens = annotation.permissions[action] || [];
+          if (tokens.length === 0) {
+            return true;
+          }
+          for (_k = 0, _len2 = tokens.length; _k < _len2; _k++) {
+            token = tokens[_k];
+            if (this.userId(user) === token) {
+              return true;
+            }
+          }
+          return false;
+        } else if (annotation.user) {
+          return user && this.userId(user) === this.userId(annotation.user);
+        }
+        return true;
+      },
+      user: '',
+      permissions: {
+        'read': [],
+        'update': [],
+        'delete': [],
+        'admin': []
+      }
+    };
+
+    function Permissions(element, options) {
+      this._setAuthFromToken = __bind(this._setAuthFromToken, this);
+
+      this.updateViewer = __bind(this.updateViewer, this);
+
+      this.updateAnnotationPermissions = __bind(this.updateAnnotationPermissions, this);
+
+      this.updatePermissionsField = __bind(this.updatePermissionsField, this);
+
+      this.addFieldsToAnnotation = __bind(this.addFieldsToAnnotation, this);
+      Permissions.__super__.constructor.apply(this, arguments);
+      if (this.options.user) {
+        this.setUser(this.options.user);
+        delete this.options.user;
+      }
+    }
+
+    Permissions.prototype.pluginInit = function() {
+      var createCallback, self,
+        _this = this;
+      if (!Annotator.supported()) {
+        return;
+      }
+      self = this;
+      createCallback = function(method, type) {
+        return function(field, annotation) {
+          return self[method].call(self, type, field, annotation);
+        };
+      };
+      if (!this.user && this.annotator.plugins.Auth) {
+        this.annotator.plugins.Auth.withToken(this._setAuthFromToken);
+      }
+      if (this.options.showViewPermissionsCheckbox === true) {
+        this.annotator.editor.addField({
+          type: 'checkbox',
+          label: Annotator._t('Allow anyone to <strong>view</strong> this annotation'),
+          load: createCallback('updatePermissionsField', 'read'),
+          submit: createCallback('updateAnnotationPermissions', 'read')
+        });
+      }
+      if (this.options.showEditPermissionsCheckbox === true) {
+        this.annotator.editor.addField({
+          type: 'checkbox',
+          label: Annotator._t('Allow anyone to <strong>edit</strong> this annotation'),
+          load: createCallback('updatePermissionsField', 'update'),
+          submit: createCallback('updateAnnotationPermissions', 'update')
+        });
+      }
+      this.annotator.viewer.addField({
+        load: this.updateViewer
+      });
+      if (this.annotator.plugins.Filter) {
+        return this.annotator.plugins.Filter.addFilter({
+          label: Annotator._t('User'),
+          property: 'user',
+          isFiltered: function(input, user) {
+            var keyword, _k, _len2, _ref2;
+            user = _this.options.userString(user);
+            if (!(input && user)) {
+              return false;
+            }
+            _ref2 = input.split(/\s*/);
+            for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
+              keyword = _ref2[_k];
+              if (user.indexOf(keyword) === -1) {
+                return false;
+              }
+            }
+            return true;
+          }
+        });
+      }
+    };
+
+    Permissions.prototype.setUser = function(user) {
+      return this.user = user;
+    };
+
+    Permissions.prototype.addFieldsToAnnotation = function(annotation) {
+      if (annotation) {
+        annotation.permissions = this.options.permissions;
+        if (this.user) {
+          return annotation.user = this.user;
+        }
+      }
+    };
+
+    Permissions.prototype.authorize = function(action, annotation, user) {
+      if (user === void 0) {
+        user = this.user;
+      }
+      if (this.options.userAuthorize) {
+        return this.options.userAuthorize.call(this.options, action, annotation, user);
+      } else {
+        return true;
+      }
+    };
+
+    Permissions.prototype.updatePermissionsField = function(action, field, annotation) {
+      var input;
+      field = $(field).show();
+      input = field.find('input').removeAttr('disabled');
+      if (!this.authorize('admin', annotation)) {
+        field.hide();
+      }
+      if (this.authorize(action, annotation || {}, null)) {
+        return input.attr('checked', 'checked');
+      } else {
+        return input.removeAttr('checked');
+      }
+    };
+
+    Permissions.prototype.updateAnnotationPermissions = function(type, field, annotation) {
+      var dataKey;
+      if (!annotation.permissions) {
+        annotation.permissions = this.options.permissions;
+      }
+      dataKey = type + '-permissions';
+      if ($(field).find('input').is(':checked')) {
+        return annotation.permissions[type] = [];
+      } else {
+        return annotation.permissions[type] = [this.user];
+      }
+    };
+
+    Permissions.prototype.updateViewer = function(field, annotation, controls) {
+      var user, username;
+      field = $(field);
+      username = this.options.userString(annotation.user);
+      if (annotation.user && username && typeof username === 'string') {
+        user = Annotator.$.escape(this.options.userString(annotation.user));
+        field.html(user).addClass('annotator-user');
+      } else {
+        field.remove();
+      }
+      if (controls) {
+        if (!this.authorize('update', annotation)) {
+          controls.hideEdit();
+        }
+        if (!this.authorize('delete', annotation)) {
+          return controls.hideDelete();
+        }
+      }
+    };
+
+    Permissions.prototype._setAuthFromToken = function(token) {
+      return this.setUser(token.userId);
+    };
+
+    return Permissions;
+
+  })(Annotator.Plugin);
+
+  Annotator.Plugin.Filter = (function(_super) {
+
+    __extends(Filter, _super);
+
+    Filter.prototype.events = {
+      ".annotator-filter-property input focus": "_onFilterFocus",
+      ".annotator-filter-property input blur": "_onFilterBlur",
+      ".annotator-filter-property input keyup": "_onFilterKeyup",
+      ".annotator-filter-previous click": "_onPreviousClick",
+      ".annotator-filter-next click": "_onNextClick",
+      ".annotator-filter-clear click": "_onClearClick"
+    };
+
+    Filter.prototype.classes = {
+      active: 'annotator-filter-active',
+      hl: {
+        hide: 'annotator-hl-filtered',
+        active: 'annotator-hl-active'
+      }
+    };
+
+    Filter.prototype.html = {
+      element: "<div class=\"annotator-filter\">\n  <strong>" + Annotator._t('Navigate:') + "</strong>\n<span class=\"annotator-filter-navigation\">\n  <button class=\"annotator-filter-previous\">" + Annotator._t('Previous') + "</button>\n<button class=\"annotator-filter-next\">" + Annotator._t('Next') + "</button>\n</span>\n<strong>" + Annotator._t('Filter by:') + "</strong>\n</div>",
+      filter: "<span class=\"annotator-filter-property\">\n  <label></label>\n  <input/>\n  <button class=\"annotator-filter-clear\">" + Annotator._t('Clear') + "</button>\n</span>"
+    };
+
+    Filter.prototype.options = {
+      appendTo: 'body',
+      filters: [],
+      addAnnotationFilter: true,
+      isFiltered: function(input, property) {
+        var keyword, _k, _len2, _ref2;
+        if (!(input && property)) {
+          return false;
+        }
+        _ref2 = input.split(/\s*/);
+        for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
+          keyword = _ref2[_k];
+          if (property.indexOf(keyword) === -1) {
+            return false;
+          }
+        }
+        return true;
+      }
+    };
+
+    function Filter(element, options) {
+      this._onPreviousClick = __bind(this._onPreviousClick, this);
+
+      this._onNextClick = __bind(this._onNextClick, this);
+
+      this._onFilterKeyup = __bind(this._onFilterKeyup, this);
+
+      this._onFilterBlur = __bind(this._onFilterBlur, this);
+
+      this._onFilterFocus = __bind(this._onFilterFocus, this);
+
+      this.updateHighlights = __bind(this.updateHighlights, this);
+
+      var _base;
+      element = $(this.html.element).appendTo((options != null ? options.appendTo : void 0) || this.options.appendTo);
+      Filter.__super__.constructor.call(this, element, options);
+      (_base = this.options).filters || (_base.filters = []);
+      this.filter = $(this.html.filter);
+      this.filters = [];
+      this.current = 0;
+    }
+
+    Filter.prototype.pluginInit = function() {
+      var filter, _k, _len2, _ref2;
+      _ref2 = this.options.filters;
+      for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
+        filter = _ref2[_k];
+        this.addFilter(filter);
+      }
+      this.updateHighlights();
+      this._setupListeners()._insertSpacer();
+      if (this.options.addAnnotationFilter === true) {
+        return this.addFilter({
+          label: Annotator._t('Annotation'),
+          property: 'text'
+        });
+      }
+    };
+
+    Filter.prototype._insertSpacer = function() {
+      var currentMargin, html;
+      html = $('html');
+      currentMargin = parseInt(html.css('padding-top'), 10) || 0;
+      html.css('padding-top', currentMargin + this.element.outerHeight());
+      return this;
+    };
+
+    Filter.prototype._setupListeners = function() {
+      var event, events, _k, _len2;
+      events = ['annotationsLoaded', 'annotationCreated', 'annotationUpdated', 'annotationDeleted'];
+      for (_k = 0, _len2 = events.length; _k < _len2; _k++) {
+        event = events[_k];
+        this.annotator.subscribe(event, this.updateHighlights);
+      }
+      return this;
+    };
+
+    Filter.prototype.addFilter = function(options) {
+      var f, filter;
+      filter = $.extend({
+        label: '',
+        property: '',
+        isFiltered: this.options.isFiltered
+      }, options);
+      if (!((function() {
+        var _k, _len2, _ref2, _results;
+        _ref2 = this.filters;
+        _results = [];
+        for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
+          f = _ref2[_k];
+          if (f.property === filter.property) {
+            _results.push(f);
+          }
+        }
+        return _results;
+      }).call(this)).length) {
+        filter.id = 'annotator-filter-' + filter.property;
+        filter.annotations = [];
+        filter.element = this.filter.clone().appendTo(this.element);
+        filter.element.find('label').html(filter.label).attr('for', filter.id);
+        filter.element.find('input').attr({
+          id: filter.id,
+          placeholder: Annotator._t('Filter by ') + filter.label + '\u2026'
+        });
+        filter.element.find('button').hide();
+        filter.element.data('filter', filter);
+        this.filters.push(filter);
+      }
+      return this;
+    };
+
+    Filter.prototype.updateFilter = function(filter) {
+      var annotation, annotations, input, property, _k, _len2, _ref2;
+      filter.annotations = [];
+      this.updateHighlights();
+      this.resetHighlights();
+      input = $.trim(filter.element.find('input').val());
+      if (input) {
+        annotations = this.highlights.map(function() {
+          return $(this).data('annotation');
+        });
+        _ref2 = $.makeArray(annotations);
+        for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
+          annotation = _ref2[_k];
+          property = annotation[filter.property];
+          if (filter.isFiltered(input, property)) {
+            filter.annotations.push(annotation);
+          }
+        }
+        return this.filterHighlights();
+      }
+    };
+
+    Filter.prototype.updateHighlights = function() {
+      this.highlights = this.annotator.element.find('.annotator-hl:visible');
+      return this.filtered = this.highlights.not(this.classes.hl.hide);
+    };
+
+    Filter.prototype.filterHighlights = function() {
+      var activeFilters, annotation, annotations, filtered, highlights, index, uniques, _k, _len2, _ref2;
+      activeFilters = $.grep(this.filters, function(filter) {
+        return !!filter.annotations.length;
+      });
+      filtered = ((_ref2 = activeFilters[0]) != null ? _ref2.annotations : void 0) || [];
+      if (activeFilters.length > 1) {
+        annotations = [];
+        $.each(activeFilters, function() {
+          return $.merge(annotations, this.annotations);
+        });
+        uniques = [];
+        filtered = [];
+        $.each(annotations, function() {
+          if ($.inArray(this, uniques) === -1) {
+            return uniques.push(this);
+          } else {
+            return filtered.push(this);
+          }
+        });
+      }
+      highlights = this.highlights;
+      for (index = _k = 0, _len2 = filtered.length; _k < _len2; index = ++_k) {
+        annotation = filtered[index];
+        highlights = highlights.not(annotation.highlights);
+      }
+      highlights.addClass(this.classes.hl.hide);
+      this.filtered = this.highlights.not(this.classes.hl.hide);
+      return this;
+    };
+
+    Filter.prototype.resetHighlights = function() {
+      this.highlights.removeClass(this.classes.hl.hide);
+      this.filtered = this.highlights;
+      return this;
+    };
+
+    Filter.prototype._onFilterFocus = function(event) {
+      var input;
+      input = $(event.target);
+      input.parent().addClass(this.classes.active);
+      return input.next('button').show();
+    };
+
+    Filter.prototype._onFilterBlur = function(event) {
+      var input;
+      if (!event.target.value) {
+        input = $(event.target);
+        input.parent().removeClass(this.classes.active);
+        return input.next('button').hide();
+      }
+    };
+
+    Filter.prototype._onFilterKeyup = function(event) {
+      var filter;
+      filter = $(event.target).parent().data('filter');
+      if (filter) {
+        return this.updateFilter(filter);
+      }
+    };
+
+    Filter.prototype._findNextHighlight = function(previous) {
+      var active, annotation, current, index, next, offset, operator, resetOffset;
+      if (!this.highlights.length) {
+        return this;
+      }
+      offset = previous ? 0 : -1;
+      resetOffset = previous ? -1 : 0;
+      operator = previous ? 'lt' : 'gt';
+      active = this.highlights.not('.' + this.classes.hl.hide);
+      current = active.filter('.' + this.classes.hl.active);
+      if (!current.length) {
+        current = active.eq(offset);
+      }
+      annotation = current.data('annotation');
+      index = active.index(current[0]);
+      next = active.filter(":" + operator + "(" + index + ")").not(annotation.highlights).eq(resetOffset);
+      if (!next.length) {
+        next = active.eq(resetOffset);
+      }
+      return this._scrollToHighlight(next.data('annotation').highlights);
+    };
+
+    Filter.prototype._onNextClick = function(event) {
+      return this._findNextHighlight();
+    };
+
+    Filter.prototype._onPreviousClick = function(event) {
+      return this._findNextHighlight(true);
+    };
+
+    Filter.prototype._scrollToHighlight = function(highlight) {
+      highlight = $(highlight);
+      this.highlights.removeClass(this.classes.hl.active);
+      highlight.addClass(this.classes.hl.active);
+      return $('html, body').animate({
+        scrollTop: highlight.offset().top - (this.element.height() + 20)
+      }, 150);
+    };
+
+    Filter.prototype._onClearClick = function(event) {
+      return $(event.target).prev('input').val('').keyup().blur();
+    };
+
+    return Filter;
+
+  })(Annotator.Plugin);
+
+  Annotator.Plugin.Markdown = (function(_super) {
+
+    __extends(Markdown, _super);
+
+    Markdown.prototype.events = {
+      'annotationViewerTextField': 'updateTextField'
+    };
+
+    function Markdown(element, options) {
+      this.updateTextField = __bind(this.updateTextField, this);
+      if ((typeof Showdown !== "undefined" && Showdown !== null ? Showdown.converter : void 0) != null) {
+        Markdown.__super__.constructor.apply(this, arguments);
+        this.converter = new Showdown.converter();
+      } else {
+        console.error(Annotator._t("To use the Markdown plugin, you must include Showdown into the page first."));
+      }
+    }
+
+    Markdown.prototype.updateTextField = function(field, annotation) {
+      var text;
+      text = Annotator.$.escape(annotation.text || '');
+      return $(field).html(this.convert(text));
+    };
+
+    Markdown.prototype.convert = function(text) {
+      return this.converter.makeHtml(text);
+    };
+
+    return Markdown;
+
+  })(Annotator.Plugin);
+
+  Annotator.Plugin.Tags = (function(_super) {
+
+    __extends(Tags, _super);
+
+    function Tags() {
+      this.setAnnotationTags = __bind(this.setAnnotationTags, this);
+
+      this.updateField = __bind(this.updateField, this);
+      return Tags.__super__.constructor.apply(this, arguments);
+    }
+
+    Tags.prototype.options = {
+      parseTags: function(string) {
+        var tags;
+        string = $.trim(string);
+        tags = [];
+        if (string) {
+          tags = string.split(/\s+/);
+        }
+        return tags;
+      },
+      stringifyTags: function(array) {
+        return array.join(" ");
+      }
+    };
+
+    Tags.prototype.field = null;
+
+    Tags.prototype.input = null;
+
+    Tags.prototype.pluginInit = function() {
+      if (!Annotator.supported()) {
+        return;
+      }
+      this.field = this.annotator.editor.addField({
+        label: Annotator._t('Add some tags here') + '\u2026',
+        load: this.updateField,
+        submit: this.setAnnotationTags
+      });
+      this.annotator.viewer.addField({
+        load: this.updateViewer
+      });
+      if (this.annotator.plugins.Filter) {
+        this.annotator.plugins.Filter.addFilter({
+          label: Annotator._t('Tag'),
+          property: 'tags',
+          isFiltered: Annotator.Plugin.Tags.filterCallback
+        });
+      }
+      return this.input = $(this.field).find(':input');
+    };
+
+    Tags.prototype.parseTags = function(string) {
+      return this.options.parseTags(string);
+    };
+
+    Tags.prototype.stringifyTags = function(array) {
+      return this.options.stringifyTags(array);
+    };
+
+    Tags.prototype.updateField = function(field, annotation) {
+      var value;
+      value = '';
+      if (annotation.tags) {
+        value = this.stringifyTags(annotation.tags);
+      }
+      return this.input.val(value);
+    };
+
+    Tags.prototype.setAnnotationTags = function(field, annotation) {
+      return annotation.tags = this.parseTags(this.input.val());
+    };
+
+    Tags.prototype.updateViewer = function(field, annotation) {
+      field = $(field);
+      if (annotation.tags && $.isArray(annotation.tags) && annotation.tags.length) {
+        return field.addClass('annotator-tags').html(function() {
+          var string;
+          return string = $.map(annotation.tags, function(tag) {
+            return '<span class="annotator-tag">' + Annotator.$.escape(tag) + '</span>';
+          }).join(' ');
+        });
+      } else {
+        return field.remove();
+      }
+    };
+
+    return Tags;
+
+  })(Annotator.Plugin);
+
+  Annotator.Plugin.Tags.filterCallback = function(input, tags) {
+    var keyword, keywords, matches, tag, _k, _l, _len2, _len3;
+    if (tags == null) {
+      tags = [];
+    }
+    matches = 0;
+    keywords = [];
+    if (input) {
+      keywords = input.split(/\s+/g);
+      for (_k = 0, _len2 = keywords.length; _k < _len2; _k++) {
+        keyword = keywords[_k];
+        if (tags.length) {
+          for (_l = 0, _len3 = tags.length; _l < _len3; _l++) {
+            tag = tags[_l];
+            if (tag.indexOf(keyword) !== -1) {
+              matches += 1;
+            }
+          }
+        }
+      }
+    }
+    return matches === keywords.length;
+  };
+
+  Annotator.Plugin.DigilibIntegrator = (function(_super) {
+
+    __extends(DigilibIntegrator, _super);
+
+    function DigilibIntegrator() {
+      return DigilibIntegrator.__super__.constructor.apply(this, arguments);
+    }
+
+    DigilibIntegrator.prototype.events = {
+      'annotationDeleted': 'annotationDeleted'
+    };
+
+    DigilibIntegrator.prototype.options = {
+      hooks: null
+    };
+
+    DigilibIntegrator.prototype.pluginInit = function() {
+      console.debug("DigilibIntegrator plugin init");
+      this.annotator.digilib = this.options.hooks;
+      this.annotator.setupRangeAnnotation = this.annotator.setupAnnotation;
+      this.annotator.setupAnnotation = this._setupAnnotation;
+      return this;
+    };
+
+    DigilibIntegrator.prototype._setupAnnotation = function(annotation, fireEvents) {
+      if (fireEvents == null) {
+        fireEvents = true;
+      }
+      if ((this.selectedAreas != null) || (annotation.areas != null)) {
+        console.debug("setupAnnotation for areas!");
+        annotation.areas || (annotation.areas = this.selectedAreas);
+        annotation.highlights = [];
+        annotation.ranges = [];
+        this.digilib.setupAnnotation(annotation);
+        if (fireEvents) {
+          this.publish('annotationCreated', [annotation]);
+        }
+        return annotation;
+      } else {
+        return this.setupRangeAnnotation.apply(this, arguments);
+      }
+    };
+
+    DigilibIntegrator.prototype.annotationDeleted = function(annotation) {
+      return this.options.hooks.annotationDeleted(annotation);
+    };
+
+    return DigilibIntegrator;
+
+  })(Annotator.Plugin);
+
+}).call(this);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webapp/src/main/webapp/jquery/annotator-dl.min.js	Fri Nov 09 11:28:44 2012 +0100
@@ -0,0 +1,11 @@
+/*
+** Annotator 1.2.5-dev-34a1d4e
+** https://github.com/okfn/annotator/
+**
+** Copyright 2012 Aron Carroll, Rufus Pollock, and Nick Stenning.
+** Dual licensed under the MIT and GPLv3 licenses.
+** https://github.com/okfn/annotator/blob/master/LICENSE
+**
+** Built at: 2012-11-08 19:26:45Z
+*/(function(){var e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x=[].slice,T={}.hasOwnProperty,N=function(e,t){function r(){this.constructor=e}for(var n in t)T.call(t,n)&&(e[n]=t[n]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e},C=function(e,t){return function(){return e.apply(t,arguments)}},k=[].indexOf||function(e){for(var t=0,n=this.length;t<n;t++)if(t in this&&this[t]===e)return t;return-1};c=null,typeof Gettext!="undefined"&&Gettext!==null?(v=new Gettext({domain:"annotator"}),c=function(e){return v.gettext(e)}):c=function(e){return e},S=function(e){return c(e)},(typeof jQuery!="undefined"&&jQuery!==null?(w=jQuery.fn)!=null?w.jquery:void 0:void 0)||console.error(S("Annotator requires jQuery: have you included lib/vendor/jquery.js?")),JSON&&JSON.parse&&JSON.stringify||console.error(S("Annotator requires a JSON implementation: have you included lib/vendor/json2.js?")),e=jQuery.sub(),e.flatten=function(t){var n;return n=function(t){var r,i,s,o;i=[];for(s=0,o=t.length;s<o;s++)r=t[s],i=i.concat(r&&e.isArray(r)?n(r):r);return i},n(t)},e.plugin=function(t,n){return jQuery.fn[t]=function(r){var i;return i=Array.prototype.slice.call(arguments,1),this.each(function(){var s;return s=e.data(this,t),s?r&&s[r].apply(s,i):(s=new n(this,r),e.data(this,t,s))})}},e.fn.textNodes=function(){var t;return t=function(e){var n;if(e&&e.nodeType!==3){n=[];if(e.nodeType!==8){e=e.lastChild;while(e)n.push(t(e)),e=e.previousSibling}return n.reverse()}return e},this.map(function(){return e.flatten(t(this))})},e.fn.xpath=function(t){var n;return n=this.map(function(){var n,r,i;i="",n=this;while(n&&n.nodeType===1&&n!==t)r=e(n.parentNode).children(n.tagName).index(n)+1,r="["+r+"]",i="/"+n.tagName.toLowerCase()+r+i,n=n.parentNode;return i}),n.get()},e.escape=function(e){return e.replace(/&(?!\w+;)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},e.fn.escape=function(t){return arguments.length?this.html(e.escape(t)):this.html()},e.fn.reverse=[]._reverse||[].reverse,f=["log","debug","info","warn","exception","assert","dir","dirxml","trace","group","groupEnd","groupCollapsed","time","timeEnd","profile","profileEnd","count","clear","table","error","notifyFirebug","firebug","userObjects"];if(typeof console!="undefined"&&console!==null){console.group==null&&(console.group=function(e){return console.log("GROUP: ",e)}),console.groupCollapsed==null&&(console.groupCollapsed=console.group);for(m=0,y=f.length;m<y;m++)a=f[m],console[a]==null&&(console[a]=function(){return console.log(S("Not implemented:")+(" console."+name))})}else{this.console={};for(g=0,b=f.length;g<b;g++)a=f[g],this.console[a]=function(){};this.console.error=function(){var e;return e=1<=arguments.length?x.call(arguments,0):[],alert("ERROR: "+e.join(", "))},this.console.warn=function(){var e;return e=1<=arguments.length?x.call(arguments,0):[],alert("WARNING: "+e.join(", "))}}n=function(){function t(t,n){this.options=e.extend(!0,{},this.options,n),this.element=e(t),this.on=this.subscribe,this.addEvents()}return t.prototype.events={},t.prototype.options={},t.prototype.element=null,t.prototype.addEvents=function(){var e,t,n,r,i,s,o,u;s=this.events,u=[];for(n in s)t=s[n],o=n.split(" "),r=2<=o.length?x.call(o,0,i=o.length-1):(i=0,[]),e=o[i++],u.push(this.addEvent(r.join(" "),e,t));return u},t.prototype.addEvent=function(t,n,r){var i,s,o=this;return i=function(){return o[r].apply(o,arguments)},s=typeof t=="string"&&t.replace(/\s+/g,"")==="",s&&(t=this.element),typeof t=="string"?this.element.delegate(t,n,i):this.isCustomEvent(n)?this.subscribe(n,i):e(t).bind(n,i),this},t.prototype.isCustomEvent=function(n){return n=n.split(".")[0],e.inArray(n,t.natives)===-1},t.prototype.publish=function(){return this.element.triggerHandler.apply(this.element,arguments),this},t.prototype.subscribe=function(t,n){var r;return r=function(){return n.apply(this,[].slice.call(arguments,1))},r.guid=n.guid=e.guid+=1,this.element.bind(t,r),this},t.prototype.unsubscribe=function(){return this.element.unbind.apply(this.element,arguments),this},t}(),n.natives=function(){var e,t,n;return t=function(){var t,r;t=jQuery.event.special,r=[];for(e in t){if(!T.call(t,e))continue;n=t[e],r.push(e)}return r}(),"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]+/).concat(t)}(),i={},i.sniff=function(e){return e.commonAncestorContainer!=null?new i.BrowserRange(e):typeof e.start=="string"?new i.SerializedRange(e):e.start&&typeof e.start=="object"?new i.NormalizedRange(e):(console.error(S("Could not sniff range type")),!1)},i.nodeFromXPath=function(t,n){var r,i,s,o,u;return n==null&&(n=document),i=function(e,t){return t==null&&(t=null),document.evaluate("."+e,n,t,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue},e.isXMLDoc(document.documentElement)?(r=document.createNSResolver(document.ownerDocument===null?document.documentElement:document.ownerDocument.documentElement),o=i(t,r),o||(t=function(){var e,n,r,i;r=t.split("/"),i=[];for(e=0,n=r.length;e<n;e++)u=r[e],u&&u.indexOf(":")===-1?i.push(u.replace(/^([a-z]+)/,"xhtml:$1")):i.push(u);return i}().join("/"),s=document.lookupNamespaceURI(null),r=function(e){return e==="xhtml"?s:document.documentElement.getAttribute("xmlns:"+e)},o=i(t,r)),o):i(t)},i.RangeError=function(e){function t(e,n,r){this.type=e,this.message=n,this.parent=r!=null?r:null,t.__super__.constructor.call(this,this.message)}return N(t,e),t}(Error),i.BrowserRange=function(){function e(e){this.commonAncestorContainer=e.commonAncestorContainer,this.startContainer=e.startContainer,this.startOffset=e.startOffset,this.endContainer=e.endContainer,this.endOffset=e.endOffset}return e.prototype.normalize=function(e){var t,n,r,s,o,u,a,f,l;if(this.tainted)return console.error(S("You may only call normalize() once on a BrowserRange!")),!1;this.tainted=!0,u={},r={},l=["start","end"];for(a=0,f=l.length;a<f;a++){o=l[a],n=this[o+"Container"],s=this[o+"Offset"];if(n==null||s==null)return!1;if(n.nodeType===1){t=n.childNodes[s],n=t||n.childNodes[s-1],n.nodeType===1&&!n.firstChild&&(t=null,n=n.previousSibling);while(n.nodeType!==3)n=n.firstChild;s=t?0:n.nodeValue.length}u[o]=n,u[o+"Offset"]=s}r.start=u.startOffset>0?u.start.splitText(u.startOffset):u.start,u.start===u.end?(u.endOffset-u.startOffset<r.start.nodeValue.length&&r.start.splitText(u.endOffset-u.startOffset),r.end=r.start):(u.endOffset<u.end.nodeValue.length&&u.end.splitText(u.endOffset),r.end=u.end),r.commonAncestor=this.commonAncestorContainer;while(r.commonAncestor.nodeType!==1)r.commonAncestor=r.commonAncestor.parentNode;return new i.NormalizedRange(r)},e.prototype.serialize=function(e,t){return this.normalize(e).serialize(e,t)},e}(),i.NormalizedRange=function(){function t(e){this.commonAncestor=e.commonAncestor,this.start=e.start,this.end=e.end}return t.prototype.normalize=function(e){return this},t.prototype.limit=function(t){var n,r,i,s,o,u;n=e.grep(this.textNodes(),function(n){return n.parentNode===t||e.contains(t,n.parentNode)});if(!n.length)return null;this.start=n[0],this.end=n[n.length-1],i=e(this.start).parents(),u=e(this.end).parents();for(s=0,o=u.length;s<o;s++){r=u[s];if(i.index(r)!==-1){this.commonAncestor=r;break}}return this},t.prototype.serialize=function(t,n){var r,s,o;return s=function(r,i){var s,o,u,a,f,l,c,h;n?a=e(r).parents(":not("+n+")").eq(0):a=e(r).parent(),l=a.xpath(t)[0],f=a.textNodes(),o=f.slice(0,f.index(r)),u=0;for(c=0,h=o.length;c<h;c++)s=o[c],u+=s.nodeValue.length;return i?[l,u+r.nodeValue.length]:[l,u]},o=s(this.start),r=s(this.end,!0),new i.SerializedRange({start:o[0],end:r[0],startOffset:o[1],endOffset:r[1]})},t.prototype.text=function(){var e;return function(){var t,n,r,i;r=this.textNodes(),i=[];for(t=0,n=r.length;t<n;t++)e=r[t],i.push(e.nodeValue);return i}.call(this).join("")},t.prototype.textNodes=function(){var t,n,r,i;return r=e(this.commonAncestor).textNodes(),i=[r.index(this.start),r.index(this.end)],n=i[0],t=i[1],e.makeArray(r.slice(n,t+1||9e9))},t.prototype.toRange=function(){var e;return e=document.createRange(),e.setStartBefore(this.start),e.setEndAfter(this.end),e},t}(),i.SerializedRange=function(){function t(e){this.start=e.start,this.startOffset=e.startOffset,this.end=e.end,this.endOffset=e.endOffset}return t.prototype.normalize=function(t){var n,r,s,o,u,a,f,l,c,h,p,d;u={},p=["start","end"];for(f=0,c=p.length;f<c;f++){o=p[f];try{s=i.nodeFromXPath(this[o],t)}catch(v){throw new i.RangeError(o,"Error while finding "+o+" node: "+this[o]+": "+v,v)}if(!s)throw new i.RangeError(o,"Couldn't find "+o+" node: "+this[o]);r=0,d=e(s).textNodes();for(l=0,h=d.length;l<h;l++){a=d[l];if(r+a.nodeValue.length>=this[o+"Offset"]){u[o+"Container"]=a,u[o+"Offset"]=this[o+"Offset"]-r;break}r+=a.nodeValue.length}if(u[o+"Offset"]==null)throw new i.RangeError(""+o+"offset","Couldn't find offset "+this[o+"Offset"]+" in element "+this[o])}return n=document.compareDocumentPosition==null?function(e,t){return e.contains(t)}:function(e,t){return e.compareDocumentPosition(t)&16},e(u.startContainer).parents().reverse().each(function(){if(n(this,u.endContainer))return u.commonAncestorContainer=this,!1}),(new i.BrowserRange(u)).normalize(t)},t.prototype.serialize=function(e,t){return this.normalize(e).serialize(e,t)},t.prototype.toObject=function(){return{start:this.start,startOffset:this.startOffset,end:this.end,endOffset:this.endOffset}},t}(),p={uuid:function(){var e;return e=0,function(){return e++}}(),getGlobal:function(){return function(){return this}()},maxZIndex:function(t){var n,r;return n=function(){var n,i,s;s=[];for(n=0,i=t.length;n<i;n++)r=t[n],e(r).css("position")==="static"?s.push(-1):s.push(parseInt(e(r).css("z-index"),10)||-1);return s}(),Math.max.apply(Math,n)},mousePosition:function(t,n){var r;return r=e(n).offset(),{top:t.pageY-r.top,left:t.pageX-r.left}},preventEventDefault:function(e){return e!=null?typeof e.preventDefault=="function"?e.preventDefault():void 0:void 0}},d=this.Annotator,t=function(t){function n(t,r){this.onDeleteAnnotation=C(this.onDeleteAnnotation,this),this.onEditAnnotation=C(this.onEditAnnotation,this),this.onAdderClick=C(this.onAdderClick,this),this.onAdderMousedown=C(this.onAdderMousedown,this),this.onHighlightMouseover=C(this.onHighlightMouseover,this),this.checkForEndSelection=C(this.checkForEndSelection,this),this.checkForStartSelection=C(this.checkForStartSelection,this),this.clearViewerHideTimer=C(this.clearViewerHideTimer,this),this.startViewerHideTimer=C(this.startViewerHideTimer,this),this.showViewer=C(this.showViewer,this),this.onEditorSubmit=C(this.onEditorSubmit,this),this.onEditorHide=C(this.onEditorHide,this),this.showEditor=C(this.showEditor,this),n.__super__.constructor.apply(this,arguments),this.plugins={};if(!n.supported())return this;this.options.readOnly||this._setupDocumentEvents(),this._setupWrapper()._setupViewer()._setupEditor(),this._setupDynamicStyle(),this.adder=e(this.html.adder).appendTo(this.wrapper).hide()}return N(n,t),n.prototype.events={".annotator-adder button click":"onAdderClick",".annotator-adder button mousedown":"onAdderMousedown",".annotator-hl mouseover":"onHighlightMouseover",".annotator-hl mouseout":"startViewerHideTimer"},n.prototype.html={adder:'<div class="annotator-adder"><button>'+S("Annotate")+"</button></div>",wrapper:'<div class="annotator-wrapper"></div>'},n.prototype.options={readOnly:!1},n.prototype.plugins={},n.prototype.editor=null,n.prototype.viewer=null,n.prototype.selectedRanges=null,n.prototype.mouseIsDown=!1,n.prototype.ignoreMouseup=!1,n.prototype.viewerHideTimer=null,n.prototype._setupWrapper=function(){return this.wrapper=e(this.html.wrapper),this.element.find("script").remove(),this.element.wrapInner(this.wrapper),this.wrapper=this.element.find(".annotator-wrapper"),this},n.prototype._setupViewer=function(){var t=this;return this.viewer=new n.Viewer({readOnly:this.options.readOnly}),this.viewer.hide().on("edit",this.onEditAnnotation).on("delete",this.onDeleteAnnotation).addField({load:function(n,r){return r.text?e(n).escape(r.text):e(n).html("<i>"+S("No Comment")+"</i>"),t.publish("annotationViewerTextField",[n,r])}}).element.appendTo(this.wrapper).bind({mouseover:this.clearViewerHideTimer,mouseout:this.startViewerHideTimer}),this},n.prototype._setupEditor=function(){return this.editor=new n.Editor,this.editor.hide().on("hide",this.onEditorHide).on("save",this.onEditorSubmit).addField({type:"textarea",label:S("Comments")+"…",load:function(t,n){return e(t).find("textarea").val(n.text||"")},submit:function(t,n){return n.text=e(t).find("textarea").val()}}),this.editor.element.appendTo(this.wrapper),this},n.prototype._setupDocumentEvents=function(){return e(document).bind({mouseup:this.checkForEndSelection,mousedown:this.checkForStartSelection}),this},n.prototype._setupDynamicStyle=function(){var t,n,r,i;return r=e("#annotator-dynamic-style"),r.length||(r=e('<style id="annotator-dynamic-style"></style>').appendTo(document.head)),n="*"+function(){var e,t,n,r;n=["adder","outer","notice","filter"],r=[];for(e=0,t=n.length;e<t;e++)i=n[e],r.push(":not(.annotator-"+i+")");return r}().join(""),t=p.maxZIndex(e(document.body).find(n)),t=Math.max(t,1e3),r.text([".annotator-adder, .annotator-outer, .annotator-notice {","  z-index: "+(t+20)+";","}",".annotator-filter {","  z-index: "+(t+10)+";","}"].join("\n")),this},n.prototype.getSelectedRanges=function(){var t,n,r,s,o,u,a,f,l;a=p.getGlobal().getSelection(),o=[],u=[],a.isCollapsed||(o=function(){var e,o,f;f=[];for(n=e=0,o=a.rangeCount;0<=o?e<o:e>o;n=0<=o?++e:--e)s=a.getRangeAt(n),t=new i.BrowserRange(s),r=t.normalize().limit(this.wrapper[0]),r===null&&u.push(s),f.push(r);return f}.call(this),a.removeAllRanges());for(f=0,l=u.length;f<l;f++)s=u[f],a.addRange(s);return e.grep(o,function(e){return e&&a.addRange(e.toRange()),e})},n.prototype.createAnnotation=function(){var e;return e={},this.publish("beforeAnnotationCreated",[e]),e},n.prototype.setupAnnotation=function(t,n){var r,s,o,u,a,f,l,c,h;n==null&&(n=!0),u=this.wrapper[0],t.ranges||(t.ranges=this.selectedRanges),s=[],h=t.ranges;for(a=0,l=h.length;a<l;a++){o=h[a];try{s.push(i.sniff(o).normalize(u))}catch(p){if(!(p instanceof i.RangeError))throw p;this.publish("rangeNormalizeFail",[t,o,p])}}t.quote=[],t.ranges=[],t.highlights=[];for(f=0,c=s.length;f<c;f++)r=s[f],t.quote.push(e.trim(r.text())),t.ranges.push(r.serialize(this.wrapper[0],".annotator-hl")),e.merge(t.highlights,this.highlightRange(r));return t.quote=t.quote.join(" / "),e(t.highlights).data("annotation",t),n&&this.publish("annotationCreated",[t]),t},n.prototype.updateAnnotation=function(e){return this.publish("beforeAnnotationUpdated",[e]),this.publish("annotationUpdated",[e]),e},n.prototype.deleteAnnotation=function(t){var n,r,i,s;s=t.highlights;for(r=0,i=s.length;r<i;r++)n=s[r],e(n).replaceWith(n.childNodes);return this.publish("annotationDeleted",[t]),t},n.prototype.loadAnnotations=function(e){var t,n,r=this;return e==null&&(e=[]),n=function(e){var i,s,o,u;e==null&&(e=[]),s=e.splice(0,10);for(o=0,u=s.length;o<u;o++)i=s[o],r.setupAnnotation(i,!1);return e.length>0?setTimeout(function(){return n(e)},10):r.publish("annotationsLoaded",[t])},t=e.slice(),e.length&&n(e),this},n.prototype.dumpAnnotations=function(){return this.plugins.Store?this.plugins.Store.dumpAnnotations():console.warn(S("Can't dump annotations without Store plugin."))},n.prototype.highlightRange=function(t,n){var r,i,s,o,u,a,f;n==null&&(n="annotator-hl"),s=/^\s*$/,r=e("<span class='"+n+"'></span>"),a=t.textNodes(),f=[];for(o=0,u=a.length;o<u;o++)i=a[o],s.test(i.nodeValue)||f.push(e(i).wrapAll(r).parent().show()[0]);return f},n.prototype.highlightRanges=function(t,n){var r,i,s,o;n==null&&(n="annotator-hl"),r=[];for(s=0,o=t.length;s<o;s++)i=t[s],e.merge(r,this.highlightRange(i,n));return r},n.prototype.addPlugin=function(e,t){var r,i;return this.plugins[e]?console.error(S("You cannot have more than one instance of any plugin.")):(r=n.Plugin[e],typeof r=="function"?(this.plugins[e]=new r(this.element[0],t),this.plugins[e].annotator=this,typeof (i=this.plugins[e]).pluginInit=="function"&&i.pluginInit()):console.error(S("Could not load ")+e+S(" plugin. Have you included the appropriate <script> tag?"))),this},n.prototype.showEditor=function(e,t){return this.editor.element.css(t),this.editor.load(e),this.publish("annotationEditorShown",[this.editor,e]),this},n.prototype.onEditorHide=function(){return this.publish("annotationEditorHidden",[this.editor]),this.ignoreMouseup=!1},n.prototype.onEditorSubmit=function(e){return this.publish("annotationEditorSubmit",[this.editor,e]),e.ranges===void 0?this.setupAnnotation(e):this.updateAnnotation(e)},n.prototype.showViewer=function(e,t){return this.viewer.element.css(t),this.viewer.load(e),this.publish("annotationViewerShown",[this.viewer,e])},n.prototype.startViewerHideTimer=function(){if(!this.viewerHideTimer)return this.viewerHideTimer=setTimeout(this.viewer.hide,250)},n.prototype.clearViewerHideTimer=function(){return clearTimeout(this.viewerHideTimer),this.viewerHideTimer=!1},n.prototype.checkForStartSelection=function(e){if(!e||!this.isAnnotator(e.target))return this.startViewerHideTimer(),this.mouseIsDown=!0},n.prototype.checkForEndSelection=function(t){var n,r,i,s,o;this.mouseIsDown=!1;if(this.ignoreMouseup)return;this.selectedRanges=this.getSelectedRanges(),o=this.selectedRanges;for(i=0,s=o.length;i<s;i++){r=o[i],n=r.commonAncestor,e(n).hasClass("annotator-hl")&&(n=e(n).parents("[class^=annotator-hl]")[0]);if(this.isAnnotator(n))return}return t&&this.selectedRanges.length?this.adder.css(p.mousePosition(t,this.wrapper[0])).show():this.adder.hide()},n.prototype.isAnnotator=function(t){return!!e(t).parents().andSelf().filter("[class^=annotator-]").not(this.wrapper).length},n.prototype.onHighlightMouseover=function(t){var n;return this.clearViewerHideTimer(),this.mouseIsDown||this.viewer.isShown()?!1:(n=e(t.target).parents(".annotator-hl").andSelf().map(function(){return e(this).data("annotation")}),this.showViewer(e.makeArray(n),p.mousePosition(t,this.wrapper[0])))},n.prototype.onAdderMousedown=function(e){return e!=null&&e.preventDefault(),this.ignoreMouseup=!0},n.prototype.onAdderClick=function(t){var n,r,s,o;return t!=null&&t.preventDefault(),r=this.adder.position(),this.adder.hide(),this.selectedRanges&&this.selectedRanges.length&&(o=function(){var e,t,n,r;n=this.selectedRanges,r=[];for(e=0,t=n.length;e<t;e++)s=n[e],r.push(i.sniff(s).normalize());return r}.call(this),n=this.highlightRanges(o,"annotator-hl annotator-hl-temporary"),this.editor.element.one("hide",function(){var t,r,i,s;s=[];for(r=0,i=n.length;r<i;r++)t=n[r],s.push(e(t).replaceWith(t.childNodes));return s})),this.showEditor(this.createAnnotation(),r)},n.prototype.onEditAnnotation=function(e){var t;return t=this.viewer.element.position(),this.viewer.hide(),this.showEditor(e,t)},n.prototype.onDeleteAnnotation=function(e){return this.viewer.hide(),this.deleteAnnotation(e)},n}(n),t.Plugin=function(e){function t(e,n){t.__super__.constructor.apply(this,arguments)}return N(t,e),t.prototype.pluginInit=function(){},t}(n),l=p.getGlobal(),((E=l.document)!=null?E.evaluate:void 0)==null&&e.getScript("http://assets.annotateit.org/vendor/xpath.min.js"),l.getSelection==null&&e.getScript("http://assets.annotateit.org/vendor/ierange.min.js"),l.JSON==null&&e.getScript("http://assets.annotateit.org/vendor/json2.min.js"),t.$=e,t.Delegator=n,t.Range=i,t._t=S,t.supported=function(){return function(){return!!this.getSelection}()},t.noConflict=function(){return p.getGlobal().Annotator=d,this},e.plugin("annotator",t),this.Annotator=t,t.Widget=function(n){function r(n,i){r.__super__.constructor.apply(this,arguments),this.classes=e.extend({},t.Widget.prototype.classes,this.classes)}return N(r,n),r.prototype.classes={hide:"annotator-hide",invert:{x:"annotator-invert-x",y:"annotator-invert-y"}},r.prototype.checkOrientation=function(){var t,n,r,i,s;return this.resetOrientation(),s=e(p.getGlobal()),i=this.element.children(":first"),n=i.offset(),r={top:s.scrollTop(),right:s.width()+s.scrollLeft()},t={top:n.top,right:n.left+i.width()},t.top-r.top<0&&this.invertY(),t.right-r.right>0&&this.invertX(),this},r.prototype.resetOrientation=function(){return this.element.removeClass(this.classes.invert.x).removeClass(this.classes.invert.y),this},r.prototype.invertX=function(){return this.element.addClass(this.classes.invert.x),this},r.prototype.invertY=function(){return this.element.addClass(this.classes.invert.y),this},r.prototype.isInvertedY=function(){return this.element.hasClass(this.classes.invert.y)},r.prototype.isInvertedX=function(){return this.element.hasClass(this.classes.invert.x)},r}(n),t.Editor=function(t){function n(t){this.onCancelButtonMouseover=C(this.onCancelButtonMouseover,this),this.processKeypress=C(this.processKeypress,this),this.submit=C(this.submit,this),this.load=C(this.load,this),this.hide=C(this.hide,this),this.show=C(this.show,this),n.__super__.constructor.call(this,e(this.html)[0],t),this.fields=[],this.annotation={}}return N(n,t),n.prototype.events={"form submit":"submit",".annotator-save click":"submit",".annotator-cancel click":"hide",".annotator-cancel mouseover":"onCancelButtonMouseover","textarea keydown":"processKeypress"},n.prototype.classes={hide:"annotator-hide",focus:"annotator-focus"},n.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">'+S("Cancel")+'</a>\n<a href="#save" class="annotator-save annotator-focus">'+S("Save")+"</a>\n    </div>\n  </form>\n</div>",n.prototype.options={},n.prototype.show=function(e){return p.preventEventDefault(e),this.element.removeClass(this.classes.hide),this.element.find(".annotator-save").addClass(this.classes.focus),this.checkOrientation(),this.element.find(":input:first").focus(),this.setupDraggables(),this.publish("show")},n.prototype.hide=function(e){return p.preventEventDefault(e),this.element.addClass(this.classes.hide),this.publish("hide")},n.prototype.load=function(e){var t,n,r,i;this.annotation=e,this.publish("load",[this.annotation]),i=this.fields;for(n=0,r=i.length;n<r;n++)t=i[n],t.load(t.element,this.annotation);return this.show()},n.prototype.submit=function(e){var t,n,r,i;p.preventEventDefault(e),i=this.fields;for(n=0,r=i.length;n<r;n++)t=i[n],t.submit(t.element,this.annotation);return this.publish("save",[this.annotation]),this.hide()},n.prototype.addField=function(t){var n,r,i;r=e.extend({id:"annotator-field-"+p.uuid(),type:"input",label:"",load:function(){},submit:function(){}},t),i=null,n=e('<li class="annotator-item" />'),r.element=n[0];switch(r.type){case"textarea":i=e("<textarea />");break;case"input":case"checkbox":i=e("<input />")}return n.append(i),i.attr({id:r.id,placeholder:r.label}),r.type==="checkbox"&&(i[0].type="checkbox",n.addClass("annotator-checkbox"),n.append(e("<label />",{"for":r.id,html:r.label}))),this.element.find("ul:first").append(n),this.fields.push(r),r.element},n.prototype.checkOrientation=function(){var e,t;return n.__super__.checkOrientation.apply(this,arguments),t=this.element.find("ul"),e=this.element.find(".annotator-controls"),this.element.hasClass(this.classes.invert.y)?e.insertBefore(t):e.is(":first-child")&&e.insertAfter(t),this},n.prototype.processKeypress=function(e){if(e.keyCode===27)return this.hide();if(e.keyCode===13&&!e.shiftKey)return this.submit()},n.prototype.onCancelButtonMouseover=function(){return this.element.find("."+this.classes.focus).removeClass(this.classes.focus)},n.prototype.setupDraggables=function(){var t,n,r,i,s,o,u,a,f,l,c,h=this;return this.element.find(".annotator-resize").remove(),this.element.hasClass(this.classes.invert.y)?r=this.element.find(".annotator-item:last"):r=this.element.find(".annotator-item:first"),r&&e('<span class="annotator-resize"></span>').appendTo(r),s=null,t=this.classes,i=this.element,l=null,f=i.find(".annotator-resize"),n=i.find(".annotator-controls"),c=!1,o=function(t){if(t.target===this)return s={element:this,top:t.pageY,left:t.pageX},l=i.find("textarea:first"),e(window).bind({"mouseup.annotator-editor-resize":a,"mousemove.annotator-editor-resize":u}),t.preventDefault()},a=function(){return s=null,e(window).unbind(".annotator-editor-resize")},u=function(e){var r,o,u,a,h;if(s&&c===!1)return r={top:e.pageY-s.top,left:e.pageX-s.left},s.element===f[0]?(a=l.outerHeight(),h=l.outerWidth(),o=i.hasClass(t.invert.x)?-1:1,u=i.hasClass(t.invert.y)?1:-1,l.height(a+r.top*u),l.width(h+r.left*o),l.outerHeight()!==a&&(s.top=e.pageY),l.outerWidth()!==h&&(s.left=e.pageX)):s.element===n[0]&&(i.css({top:parseInt(i.css("top"),10)+r.top,left:parseInt(i.css("left"),10)+r.left}),s.top=e.pageY,s.left=e.pageX),c=!0,setTimeout(function(){return c=!1},1e3/60)},f.bind("mousedown",o),n.bind("mousedown",o)},n}(t.Widget),t.Viewer=function(t){function n(t){this.onDeleteClick=C(this.onDeleteClick,this),this.onEditClick=C(this.onEditClick,this),this.load=C(this.load,this),this.hide=C(this.hide,this),this.show=C(this.show,this),n.__super__.constructor.call(this,e(this.html.element)[0],t),this.item=e(this.html.item)[0],this.fields=[],this.annotations=[]}return N(n,t),n.prototype.events={".annotator-edit click":"onEditClick",".annotator-delete click":"onDeleteClick"},n.prototype.classes={hide:"annotator-hide",showControls:"annotator-visible"},n.prototype.html={element:'<div class="annotator-outer annotator-viewer">\n  <ul class="annotator-widget annotator-listing"></ul>\n</div>',item:'<li class="annotator-annotation annotator-item">\n  <span class="annotator-controls">\n    <a href="#" title="View as webpage" class="annotator-link">View as webpage</a>\n    <button title="Edit" class="annotator-edit">Edit</button>\n    <button title="Delete" class="annotator-delete">Delete</button>\n  </span>\n</li>'},n.prototype.options={readOnly:!1},n.prototype.show=function(e){var t,n=this;return p.preventEventDefault(e),t=this.element.find(".annotator-controls").addClass(this.classes.showControls),setTimeout(function(){return t.removeClass(n.classes.showControls)},500),this.element.removeClass(this.classes.hide),this.checkOrientation().publish("show")},n.prototype.isShown=function(){return!this.element.hasClass(this.classes.hide)},n.prototype.hide=function(e){return p.preventEventDefault(e),this.element.addClass(this.classes.hide),this.publish("hide")},n.prototype.load=function(t){var n,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b;this.annotations=t||[],p=this.element.find("ul:first").empty(),y=this.annotations;for(d=0,m=y.length;d<m;d++){n=y[d],l=e(this.item).clone().appendTo(p).data("annotation",n),s=l.find(".annotator-controls"),c=s.find(".annotator-link"),u=s.find(".annotator-edit"),o=s.find(".annotator-delete"),h=(new r(n.links||[])).get("alternate",{type:"text/html"}),h.length===0||h[0].href==null?c.remove():c.attr("href",h[0].href),this.options.readOnly?(u.remove(),o.remove()):i={showEdit:function(){return u.removeAttr("disabled")},hideEdit:function(){return u.attr("disabled","disabled")},showDelete:function(){return o.removeAttr("disabled")},hideDelete:function(){return o.attr("disabled","disabled")}},b=this.fields;for(v=0,g=b.length;v<g;v++)f=b[v],a=e(f.element).clone().appendTo(l)[0],f.load(a,n,i)}return this.publish("load",[this.annotations]),this.show()},n.prototype.addField=function(t){var n;return n=e.extend({load:function(){}},t),n.element=e("<div />")[0],this.fields.push(n),n.element,this},n.prototype.onEditClick=function(e){return this.onButtonClick(e,"edit")},n.prototype.onDeleteClick=function(e){return this.onButtonClick(e,"delete")},n.prototype.onButtonClick=function(t,n){var r;return r=e(t.target).parents(".annotator-annotation"),this.publish(n,[r.data("annotation")])},n}(t.Widget),r=function(){function t(e){this.data=e}return t.prototype.get=function(t,n){var r,i,s,o,u,a,f,l,c;n==null&&(n={}),n=e.extend({},n,{rel:t}),s=function(){var e;e=[];for(i in n){if(!T.call(n,i))continue;u=n[i],e.push(i)}return e}(),l=this.data,c=[];for(a=0,f=l.length;a<f;a++){r=l[a],o=s.reduce(function(e,t){return e&&r[t]===n[t]},!0);if(!o)continue;c.push(r)}return c},t}(),t=t||{},t.Notification=function(n){function r(t){this.hide=C(this.hide,this),this.show=C(this.show,this),r.__super__.constructor.call(this,e(this.options.html).appendTo(document.body)[0],t)}return N(r,n),r.prototype.events={click:"hide"},r.prototype.options={html:"<div class='annotator-notice'></div>",classes:{show:"annotator-notice-show",info:"annotator-notice-info",success:"annotator-notice-success",error:"annotator-notice-error"}},r.prototype.show=function(n,r){return r==null&&(r=t.Notification.INFO),e(this.element).addClass(this.options.classes.show).addClass(this.options.classes[r]).escape(n||""),setTimeout(this.hide,5e3),this},r.prototype.hide=function(){return e(this.element).removeClass(this.options.classes.show),this},r}(n),t.Notification.INFO="show",t.Notification.SUCCESS="success",t.Notification.ERROR="error",e(function(){var e;return e=new t.Notification,t.showNotification=e.show,t.hideNotification=e.hide}),t.Plugin.Unsupported=function(n){function r(){return r.__super__.constructor.apply(this,arguments)}return N(r,n),r.prototype.options={message:t._t("Sorry your current browser does not support the Annotator")},r.prototype.pluginInit=function(){var n=this;if(!t.supported())return e(function(){t.showNotification(n.options.message);if(window.XMLHttpRequest===void 0&&ActiveXObject!==void 0)return e("html").addClass("ie6")})},r}(t.Plugin),u=function(e){var t,n,r,i,s,o;return i="([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})))?)?)?)?",t=e.match(new RegExp(i)),r=0,n=new Date(t[1],0,1),t[3]&&n.setMonth(t[3]-1),t[5]&&n.setDate(t[5]),t[7]&&n.setHours(t[7]),t[8]&&n.setMinutes(t[8]),t[10]&&n.setSeconds(t[10]),t[12]&&n.setMilliseconds(Number("0."+t[12])*1e3),t[14]&&(r=Number(t[16])*60+Number(t[17]),r*=(o=t[15]==="-")!=null?o:{1:-1}),r-=n.getTimezoneOffset(),s=Number(n)+r*60*1e3,n.setTime(Number(s)),n},s=function(e){var t,n,r,i,s,o,u,a,f,l,c,h,p;if(typeof atob!="undefined"&&atob!==null)return atob(e);n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f=0,t=0,i="",p=[];if(!e)return e;e+="";while(f<e.length)s=n.indexOf(e.charAt(f++)),o=n.indexOf(e.charAt(f++)),u=n.indexOf(e.charAt(f++)),a=n.indexOf(e.charAt(f++)),r=s<<18|o<<12|u<<6|a,l=r>>16&255,c=r>>8&255,h=r&255,u===64?p[t++]=String.fromCharCode(l):a===64?p[t++]=String.fromCharCode(l,c):p[t++]=String.fromCharCode(l,c,h);return p.join("")},o=function(e){var t,n,r,i;n=e.length%4;if(n!==0)for(t=r=0,i=4-n;0<=i?r<i:r>i;t=0<=i?++r:--r)e+="=";return e=e.replace(/-/g,"+"),e=e.replace(/_/g,"/"),s(e)},h=function(e){var t,n,r,i;return i=e.split("."),t=i[0],n=i[1],r=i[2],JSON.parse(o(n))},t.Plugin.Auth=function(n){function r(e,t){r.__super__.constructor.apply(this,arguments),this.waitingForToken=[],this.options.token?this.setToken(this.options.token):this.requestToken()}return N(r,n),r.prototype.options={token:null,tokenUrl:"/auth/token",autoFetch:!0,requestMethod:"GET",requestData:null,unauthorizedCallback:null},r.prototype.requestToken=function(){var n=this;return this.requestInProgress=!0,e.ajax({url:this.options.tokenUrl,dataType:"text",data:this.options.requestData,type:this.options.requestMethod,xhrFields:{withCredentials:!0}}).done(function(e,t,r){return n.setToken(e)}).fail(function(e,r,i){var s,o;if(e.status===401){s=n.options.unauthorizedCallback;if(s!=null&&s(n)){n.retryTimeout=setTimeout(function(){return n.requestToken()},1e3);return}}return o=t._t("Couldn't get auth token:"),console.error(""+o+" "+i,e),t.showNotification(""+o+" "+e.responseText,t.Notification.ERROR)}).always(function(){return n.requestInProgress=!1})},r.prototype.setToken=function(e){var n,r=this;this.token=e,this._unsafeToken=h(e);if(this.haveValidToken()){this.options.autoFetch&&(this.refreshTimeout=setTimeout(function(){return r.requestToken()},(this.timeToExpiry()-2)*1e3)),this.updateHeaders(),n=[];while(this.waitingForToken.length>0)n.push(this.waitingForToken.pop()(this._unsafeToken));return n}console.warn(t._t("Didn't get a valid token."));if(this.options.autoFetch)return console.warn(t._t("Getting a new token in 10s.")),setTimeout(function(){return r.requestToken()},1e4)},r.prototype.haveValidToken=function(){var e;return e=this._unsafeToken&&this.
+_unsafeToken.issuedAt&&this._unsafeToken.ttl&&this._unsafeToken.consumerKey,e&&this.timeToExpiry()>0},r.prototype.timeToExpiry=function(){var e,t,n,r;return n=(new Date).getTime()/1e3,t=u(this._unsafeToken.issuedAt).getTime()/1e3,e=t+this._unsafeToken.ttl,r=e-n,r>0?r:0},r.prototype.updateHeaders=function(){var t;return t=this.element.data("annotator:headers"),this.element.data("annotator:headers",e.extend(t,{"x-annotator-auth-token":this.token}))},r.prototype.withToken=function(e){if(e==null)return;if(this.haveValidToken())return e(this._unsafeToken);this.waitingForToken.push(e);if(!this.requestInProgress)return this.requestToken()},r}(t.Plugin),t.Plugin.Store=function(n){function r(e,t){this._onError=C(this._onError,this),this._onLoadAnnotationsFromSearch=C(this._onLoadAnnotationsFromSearch,this),this._onLoadAnnotations=C(this._onLoadAnnotations,this),this._getAnnotations=C(this._getAnnotations,this),r.__super__.constructor.apply(this,arguments),this.annotations=[]}return N(r,n),r.prototype.events={annotationCreated:"annotationCreated",annotationDeleted:"annotationDeleted",annotationUpdated:"annotationUpdated"},r.prototype.options={prefix:"/store",autoFetch:!0,annotationData:{},loadFromSearch:!1,urls:{create:"/annotations",read:"/annotations/:id",update:"/annotations/:id",destroy:"/annotations/:id",search:"/search"}},r.prototype.pluginInit=function(){if(!t.supported())return;return this.annotator.plugins.Auth?this.annotator.plugins.Auth.withToken(this._getAnnotations):this._getAnnotations()},r.prototype._getAnnotations=function(){return this.options.loadFromSearch?this.loadAnnotationsFromSearch(this.options.loadFromSearch):this.loadAnnotations()},r.prototype.annotationCreated=function(e){var n=this;return k.call(this.annotations,e)<0?(this.registerAnnotation(e),this._apiRequest("create",e,function(r){return r.id==null&&console.warn(t._t("Warning: No ID returned from server for annotation "),e),n.updateAnnotation(e,r)})):this.updateAnnotation(e,{})},r.prototype.annotationUpdated=function(e){var t=this;if(k.call(this.annotations,e)>=0)return this._apiRequest("update",e,function(n){return t.updateAnnotation(e,n)})},r.prototype.annotationDeleted=function(e){var t=this;if(k.call(this.annotations,e)>=0)return this._apiRequest("destroy",e,function(){return t.unregisterAnnotation(e)})},r.prototype.registerAnnotation=function(e){return this.annotations.push(e)},r.prototype.unregisterAnnotation=function(e){return this.annotations.splice(this.annotations.indexOf(e),1)},r.prototype.updateAnnotation=function(n,r){return k.call(this.annotations,n)<0?console.error(t._t("Trying to update unregistered annotation!")):e.extend(n,r),e(n.highlights).data("annotation",n)},r.prototype.loadAnnotations=function(){return this._apiRequest("read",null,this._onLoadAnnotations)},r.prototype._onLoadAnnotations=function(e){return e==null&&(e=[]),this.annotations=e,this.annotator.loadAnnotations(e.slice())},r.prototype.loadAnnotationsFromSearch=function(e){return this._apiRequest("search",e,this._onLoadAnnotationsFromSearch)},r.prototype._onLoadAnnotationsFromSearch=function(e){return e==null&&(e={}),this._onLoadAnnotations(e.rows||[])},r.prototype.dumpAnnotations=function(){var e,t,n,r,i;r=this.annotations,i=[];for(t=0,n=r.length;t<n;t++)e=r[t],i.push(JSON.parse(this._dataFor(e)));return i},r.prototype._apiRequest=function(t,n,r){var i,s,o,u;return i=n&&n.id,u=this._urlFor(t,i),s=this._apiRequestOptions(t,n,r),o=e.ajax(u,s),o._id=i,o._action=t,o},r.prototype._apiRequestOptions=function(t,n,r){var i;return i={type:this._methodFor(t),headers:this.element.data("annotator:headers"),dataType:"json",success:r||function(){},error:this._onError},t==="search"?i=e.extend(i,{data:n}):i=e.extend(i,{data:n&&this._dataFor(n),contentType:"application/json; charset=utf-8"}),i},r.prototype._urlFor=function(e,t){var n,r;return n=t!=null?"/"+t:"",r=this.options.prefix||"/",r+=this.options.urls[e],r=r.replace(/\/:id/,n),r},r.prototype._methodFor=function(e){var t;return t={create:"POST",read:"GET",update:"PUT",destroy:"DELETE",search:"GET"},t[e]},r.prototype._dataFor=function(t){var n,r;return r=t.highlights,delete t.highlights,e.extend(t,this.options.annotationData),n=JSON.stringify(t),r&&(t.highlights=r),n},r.prototype._onError=function(e){var n,r;n=e._action,r=t._t("Sorry we could not ")+n+t._t(" this annotation"),e._action==="search"?r=t._t("Sorry we could not search the store for annotations"):e._action==="read"&&!e._id&&(r=t._t("Sorry we could not ")+n+t._t(" the annotations from the store"));switch(e.status){case 401:r=t._t("Sorry you are not allowed to ")+n+t._t(" this annotation");break;case 404:r=t._t("Sorry we could not connect to the annotations store");break;case 500:r=t._t("Sorry something went wrong with the annotation store")}return t.showNotification(r,t.Notification.ERROR),console.error(t._t("API request failed:")+(" '"+e.status+"'"))},r}(t.Plugin),t.Plugin.Permissions=function(n){function r(e,t){this._setAuthFromToken=C(this._setAuthFromToken,this),this.updateViewer=C(this.updateViewer,this),this.updateAnnotationPermissions=C(this.updateAnnotationPermissions,this),this.updatePermissionsField=C(this.updatePermissionsField,this),this.addFieldsToAnnotation=C(this.addFieldsToAnnotation,this),r.__super__.constructor.apply(this,arguments),this.options.user&&(this.setUser(this.options.user),delete this.options.user)}return N(r,n),r.prototype.events={beforeAnnotationCreated:"addFieldsToAnnotation"},r.prototype.options={showViewPermissionsCheckbox:!0,showEditPermissionsCheckbox:!0,userId:function(e){return e},userString:function(e){return e},userAuthorize:function(e,t,n){var r,i,s,o;if(t.permissions){i=t.permissions[e]||[];if(i.length===0)return!0;for(s=0,o=i.length;s<o;s++){r=i[s];if(this.userId(n)===r)return!0}return!1}return t.user?n&&this.userId(n)===this.userId(t.user):!0},user:"",permissions:{read:[],update:[],"delete":[],admin:[]}},r.prototype.pluginInit=function(){var e,n,r=this;if(!t.supported())return;n=this,e=function(e,t){return function(r,i){return n[e].call(n,t,r,i)}},!this.user&&this.annotator.plugins.Auth&&this.annotator.plugins.Auth.withToken(this._setAuthFromToken),this.options.showViewPermissionsCheckbox===!0&&this.annotator.editor.addField({type:"checkbox",label:t._t("Allow anyone to <strong>view</strong> this annotation"),load:e("updatePermissionsField","read"),submit:e("updateAnnotationPermissions","read")}),this.options.showEditPermissionsCheckbox===!0&&this.annotator.editor.addField({type:"checkbox",label:t._t("Allow anyone to <strong>edit</strong> this annotation"),load:e("updatePermissionsField","update"),submit:e("updateAnnotationPermissions","update")}),this.annotator.viewer.addField({load:this.updateViewer});if(this.annotator.plugins.Filter)return this.annotator.plugins.Filter.addFilter({label:t._t("User"),property:"user",isFiltered:function(e,t){var n,i,s,o;t=r.options.userString(t);if(!e||!t)return!1;o=e.split(/\s*/);for(i=0,s=o.length;i<s;i++){n=o[i];if(t.indexOf(n)===-1)return!1}return!0}})},r.prototype.setUser=function(e){return this.user=e},r.prototype.addFieldsToAnnotation=function(e){if(e){e.permissions=this.options.permissions;if(this.user)return e.user=this.user}},r.prototype.authorize=function(e,t,n){return n===void 0&&(n=this.user),this.options.userAuthorize?this.options.userAuthorize.call(this.options,e,t,n):!0},r.prototype.updatePermissionsField=function(t,n,r){var i;return n=e(n).show(),i=n.find("input").removeAttr("disabled"),this.authorize("admin",r)||n.hide(),this.authorize(t,r||{},null)?i.attr("checked","checked"):i.removeAttr("checked")},r.prototype.updateAnnotationPermissions=function(t,n,r){var i;return r.permissions||(r.permissions=this.options.permissions),i=t+"-permissions",e(n).find("input").is(":checked")?r.permissions[t]=[]:r.permissions[t]=[this.user]},r.prototype.updateViewer=function(n,r,i){var s,o;n=e(n),o=this.options.userString(r.user),r.user&&o&&typeof o=="string"?(s=t.$.escape(this.options.userString(r.user)),n.html(s).addClass("annotator-user")):n.remove();if(i){this.authorize("update",r)||i.hideEdit();if(!this.authorize("delete",r))return i.hideDelete()}},r.prototype._setAuthFromToken=function(e){return this.setUser(e.userId)},r}(t.Plugin),t.Plugin.Filter=function(n){function r(t,n){this._onPreviousClick=C(this._onPreviousClick,this),this._onNextClick=C(this._onNextClick,this),this._onFilterKeyup=C(this._onFilterKeyup,this),this._onFilterBlur=C(this._onFilterBlur,this),this._onFilterFocus=C(this._onFilterFocus,this),this.updateHighlights=C(this.updateHighlights,this);var i;t=e(this.html.element).appendTo((n!=null?n.appendTo:void 0)||this.options.appendTo),r.__super__.constructor.call(this,t,n),(i=this.options).filters||(i.filters=[]),this.filter=e(this.html.filter),this.filters=[],this.current=0}return N(r,n),r.prototype.events={".annotator-filter-property input focus":"_onFilterFocus",".annotator-filter-property input blur":"_onFilterBlur",".annotator-filter-property input keyup":"_onFilterKeyup",".annotator-filter-previous click":"_onPreviousClick",".annotator-filter-next click":"_onNextClick",".annotator-filter-clear click":"_onClearClick"},r.prototype.classes={active:"annotator-filter-active",hl:{hide:"annotator-hl-filtered",active:"annotator-hl-active"}},r.prototype.html={element:'<div class="annotator-filter">\n  <strong>'+t._t("Navigate:")+'</strong>\n<span class="annotator-filter-navigation">\n  <button class="annotator-filter-previous">'+t._t("Previous")+'</button>\n<button class="annotator-filter-next">'+t._t("Next")+"</button>\n</span>\n<strong>"+t._t("Filter by:")+"</strong>\n</div>",filter:'<span class="annotator-filter-property">\n  <label></label>\n  <input/>\n  <button class="annotator-filter-clear">'+t._t("Clear")+"</button>\n</span>"},r.prototype.options={appendTo:"body",filters:[],addAnnotationFilter:!0,isFiltered:function(e,t){var n,r,i,s;if(!e||!t)return!1;s=e.split(/\s*/);for(r=0,i=s.length;r<i;r++){n=s[r];if(t.indexOf(n)===-1)return!1}return!0}},r.prototype.pluginInit=function(){var e,n,r,i;i=this.options.filters;for(n=0,r=i.length;n<r;n++)e=i[n],this.addFilter(e);this.updateHighlights(),this._setupListeners()._insertSpacer();if(this.options.addAnnotationFilter===!0)return this.addFilter({label:t._t("Annotation"),property:"text"})},r.prototype._insertSpacer=function(){var t,n;return n=e("html"),t=parseInt(n.css("padding-top"),10)||0,n.css("padding-top",t+this.element.outerHeight()),this},r.prototype._setupListeners=function(){var e,t,n,r;t=["annotationsLoaded","annotationCreated","annotationUpdated","annotationDeleted"];for(n=0,r=t.length;n<r;n++)e=t[n],this.annotator.subscribe(e,this.updateHighlights);return this},r.prototype.addFilter=function(n){var r,i;i=e.extend({label:"",property:"",isFiltered:this.options.isFiltered},n);if(!function(){var e,t,n,s;n=this.filters,s=[];for(e=0,t=n.length;e<t;e++)r=n[e],r.property===i.property&&s.push(r);return s}.call(this).length)i.id="annotator-filter-"+i.property,i.annotations=[],i.element=this.filter.clone().appendTo(this.element),i.element.find("label").html(i.label).attr("for",i.id),i.element.find("input").attr({id:i.id,placeholder:t._t("Filter by ")+i.label+"…"}),i.element.find("button").hide(),i.element.data("filter",i),this.filters.push(i);return this},r.prototype.updateFilter=function(t){var n,r,i,s,o,u,a;t.annotations=[],this.updateHighlights(),this.resetHighlights(),i=e.trim(t.element.find("input").val());if(i){r=this.highlights.map(function(){return e(this).data("annotation")}),a=e.makeArray(r);for(o=0,u=a.length;o<u;o++)n=a[o],s=n[t.property],t.isFiltered(i,s)&&t.annotations.push(n);return this.filterHighlights()}},r.prototype.updateHighlights=function(){return this.highlights=this.annotator.element.find(".annotator-hl:visible"),this.filtered=this.highlights.not(this.classes.hl.hide)},r.prototype.filterHighlights=function(){var t,n,r,i,s,o,u,a,f,l;t=e.grep(this.filters,function(e){return!!e.annotations.length}),i=((l=t[0])!=null?l.annotations:void 0)||[],t.length>1&&(r=[],e.each(t,function(){return e.merge(r,this.annotations)}),u=[],i=[],e.each(r,function(){return e.inArray(this,u)===-1?u.push(this):i.push(this)})),s=this.highlights;for(o=a=0,f=i.length;a<f;o=++a)n=i[o],s=s.not(n.highlights);return s.addClass(this.classes.hl.hide),this.filtered=this.highlights.not(this.classes.hl.hide),this},r.prototype.resetHighlights=function(){return this.highlights.removeClass(this.classes.hl.hide),this.filtered=this.highlights,this},r.prototype._onFilterFocus=function(t){var n;return n=e(t.target),n.parent().addClass(this.classes.active),n.next("button").show()},r.prototype._onFilterBlur=function(t){var n;if(!t.target.value)return n=e(t.target),n.parent().removeClass(this.classes.active),n.next("button").hide()},r.prototype._onFilterKeyup=function(t){var n;n=e(t.target).parent().data("filter");if(n)return this.updateFilter(n)},r.prototype._findNextHighlight=function(e){var t,n,r,i,s,o,u,a;return this.highlights.length?(o=e?0:-1,a=e?-1:0,u=e?"lt":"gt",t=this.highlights.not("."+this.classes.hl.hide),r=t.filter("."+this.classes.hl.active),r.length||(r=t.eq(o)),n=r.data("annotation"),i=t.index(r[0]),s=t.filter(":"+u+"("+i+")").not(n.highlights).eq(a),s.length||(s=t.eq(a)),this._scrollToHighlight(s.data("annotation").highlights)):this},r.prototype._onNextClick=function(e){return this._findNextHighlight()},r.prototype._onPreviousClick=function(e){return this._findNextHighlight(!0)},r.prototype._scrollToHighlight=function(t){return t=e(t),this.highlights.removeClass(this.classes.hl.active),t.addClass(this.classes.hl.active),e("html, body").animate({scrollTop:t.offset().top-(this.element.height()+20)},150)},r.prototype._onClearClick=function(t){return e(t.target).prev("input").val("").keyup().blur()},r}(t.Plugin),t.Plugin.Markdown=function(n){function r(e,n){this.updateTextField=C(this.updateTextField,this),(typeof Showdown!=="undefined"&&Showdown!==null?Showdown.converter:void 0)!=null?(r.__super__.constructor.apply(this,arguments),this.converter=new Showdown.converter):console.error(t._t("To use the Markdown plugin, you must include Showdown into the page first."))}return N(r,n),r.prototype.events={annotationViewerTextField:"updateTextField"},r.prototype.updateTextField=function(n,r){var i;return i=t.$.escape(r.text||""),e(n).html(this.convert(i))},r.prototype.convert=function(e){return this.converter.makeHtml(e)},r}(t.Plugin),t.Plugin.Tags=function(n){function r(){return this.setAnnotationTags=C(this.setAnnotationTags,this),this.updateField=C(this.updateField,this),r.__super__.constructor.apply(this,arguments)}return N(r,n),r.prototype.options={parseTags:function(t){var n;return t=e.trim(t),n=[],t&&(n=t.split(/\s+/)),n},stringifyTags:function(e){return e.join(" ")}},r.prototype.field=null,r.prototype.input=null,r.prototype.pluginInit=function(){if(!t.supported())return;return this.field=this.annotator.editor.addField({label:t._t("Add some tags here")+"…",load:this.updateField,submit:this.setAnnotationTags}),this.annotator.viewer.addField({load:this.updateViewer}),this.annotator.plugins.Filter&&this.annotator.plugins.Filter.addFilter({label:t._t("Tag"),property:"tags",isFiltered:t.Plugin.Tags.filterCallback}),this.input=e(this.field).find(":input")},r.prototype.parseTags=function(e){return this.options.parseTags(e)},r.prototype.stringifyTags=function(e){return this.options.stringifyTags(e)},r.prototype.updateField=function(e,t){var n;return n="",t.tags&&(n=this.stringifyTags(t.tags)),this.input.val(n)},r.prototype.setAnnotationTags=function(e,t){return t.tags=this.parseTags(this.input.val())},r.prototype.updateViewer=function(n,r){return n=e(n),r.tags&&e.isArray(r.tags)&&r.tags.length?n.addClass("annotator-tags").html(function(){var n;return n=e.map(r.tags,function(e){return'<span class="annotator-tag">'+t.$.escape(e)+"</span>"}).join(" ")}):n.remove()},r}(t.Plugin),t.Plugin.Tags.filterCallback=function(e,t){var n,r,i,s,o,u,a,f;t==null&&(t=[]),i=0,r=[];if(e){r=e.split(/\s+/g);for(o=0,a=r.length;o<a;o++){n=r[o];if(t.length)for(u=0,f=t.length;u<f;u++)s=t[u],s.indexOf(n)!==-1&&(i+=1)}}return i===r.length},t.Plugin.DigilibIntegrator=function(e){function t(){return t.__super__.constructor.apply(this,arguments)}return N(t,e),t.prototype.events={annotationDeleted:"annotationDeleted"},t.prototype.options={hooks:null},t.prototype.pluginInit=function(){return console.debug("DigilibIntegrator plugin init"),this.annotator.digilib=this.options.hooks,this.annotator.setupRangeAnnotation=this.annotator.setupAnnotation,this.annotator.setupAnnotation=this._setupAnnotation,this},t.prototype._setupAnnotation=function(e,t){return t==null&&(t=!0),this.selectedAreas!=null||e.areas!=null?(console.debug("setupAnnotation for areas!"),e.areas||(e.areas=this.selectedAreas),e.highlights=[],e.ranges=[],this.digilib.setupAnnotation(e),t&&this.publish("annotationCreated",[e]),e):this.setupRangeAnnotation.apply(this,arguments)},t.prototype.annotationDeleted=function(e){return this.options.hooks.annotationDeleted(e)},t}(t.Plugin)}).call(this);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webapp/src/main/webapp/jquery/annotator.min.css	Fri Nov 09 11:28:44 2012 +0100
@@ -0,0 +1,1 @@
+.annotator-notice,.annotator-filter *,.annotator-widget *{font-family:"Helvetica Neue",Arial,Helvetica,sans-serif;font-weight:normal;text-align:left;margin:0;padding:0;background:0;-webkit-transition:none;-moz-transition:none;-o-transition:none;transition:none;-moz-box-shadow:none;-webkit-box-shadow:none;-o-box-shadow:none;box-shadow:none;color:#909090}.annotator-adder{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJAAAAAwCAYAAAD+WvNWAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDowMzgwMTE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9OxNNhAvISEVFZDpevaJIHRTwKIvKb/0EQj4KI/Oa/U/F0qIA03JnS+wdKPD7cmSL/gyQeH+5Mkb8jxHOnWZiWiOTBLVH6/kEtbmHIglui9P2DWtzCWH3534r8HSUcd/l/AQYA7PGYKl3+RK0AAAAASUVORK5CYII=');background-repeat:no-repeat}.annotator-resize,.annotator-widget::after,.annotator-editor a::after,.annotator-viewer .annotator-controls button,.annotator-viewer .annotator-controls a,.annotator-filter .annotator-filter-navigation button::after,.annotator-filter .annotator-filter-property .annotator-filter-clear{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAEiCAYAAAD0w4JOAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmN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aK9KqjM3W1rZ62LBhVydMmDDdw8PjqMWNlJubewL5UWZiYmIo/WPTmgRCiJBLIc2tBdTHo/+3tMaS1IZnRknLX23qpNLBgwddk5OT93p5edG/nFtLtTTbIOPi4uif4TXl5eUFBw4cWOfo6EgfWTS1GiRa7vnzmjVrKD9qXyeQaAuzBCS37OxnyAykf3utCiPck9U8tEIzEpASa15qaHkHLfloY860UL3314Pk4pG7u4ex+7QYhT60bA6Jh2yAlGZkpBu1bOlGn6HtF52P4Z587duVk6xpM1a1cSLIEchJkYazzG0jWuxOCTstfKMv6OhLMlquF8vuDzcH1I5BaKO1o/tEk3jC0sUcUyD69RvckwWDHIuStIDSHjKE3actwlgYoRXj/2HH9GYkfGlInyreEZ3/jXuyoFlWIy8RRBgAxJ+WCRD6cPdfxgzyI3ZMHwPu4Z6sgKaPLO+z6ze5J0usPzMVIYWPKZ0YuJr1lPB91ihImjmhlj5bfI118SlIHkRIRqeYAxFchNZiX+EMP6ScImq7WpuSi5SwTHYyc4u7rFEvWuS09TH79wz6nwADANCoQA3w0fcjAAAAAElFTkSuQmCC');background-repeat:no-repeat}.annotator-hl{background:rgba(255,255,10,0.3)}.annotator-hl-temporary{background:rgba(0,124,255,0.3)}.annotator-wrapper{position:relative}.annotator-adder,.annotator-outer,.annotator-notice{z-index:1020}.annotator-filter{z-index:1010}.annotator-adder,.annotator-outer,.annotator-widget,.annotator-notice{position:absolute;font-size:10px;line-height:1}.annotator-hide{display:none;visibility:hidden}.annotator-adder{margin-top:-48px;margin-left:-24px;width:48px;height:48px;background-position:left top}.annotator-adder:hover{background-position:center top}.annotator-adder:active{background-position:center right}.annotator-adder button{display:block;width:36px;height:41px;margin:0 auto;border:0;background:0;text-indent:-999em;cursor:pointer}.annotator-outer{width:0;height:0}.annotator-widget{margin:0;padding:0;bottom:15px;left:-18px;min-width:265px;background-color:rgba(251,251,251,0.98);border:1px solid rgba(122,122,122,0.6);-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;-webkit-box-shadow:0 5px 15px rgba(0,0,0,0.2);-moz-box-shadow:0 5px 15px rgba(0,0,0,0.2);-o-box-shadow:0 5px 15px rgba(0,0,0,0.2);box-shadow:0 5px 15px rgba(0,0,0,0.2)}.annotator-invert-x .annotator-widget{left:auto;right:-18px}.annotator-invert-y .annotator-widget{bottom:auto;top:8px}.annotator-widget strong{font-weight:bold}.annotator-widget .annotator-listing,.annotator-widget .annotator-item{padding:0;margin:0;list-style:none}.annotator-widget::after{content:"";display:block;width:18px;height:10px;background-position:0 0;position:absolute;bottom:-10px;left:8px}.annotator-invert-x .annotator-widget::after{left:auto;right:8px}.annotator-invert-y .annotator-widget::after{background-position:0 -15px;bottom:auto;top:-9px}.annotator-widget .annotator-item,.annotator-editor .annotator-item input,.annotator-editor .annotator-item textarea{position:relative;font-size:12px}.annotator-viewer .annotator-item{border-top:2px solid rgba(122,122,122,0.2)}.annotator-widget .annotator-item:first-child{border-top:0}.annotator-editor .annotator-item,.annotator-viewer div{border-top:1px solid rgba(133,133,133,0.11)}.annotator-viewer div{padding:6px 6px}.annotator-viewer .annotator-item ol,.annotator-viewer .annotator-item ul{padding:4px 16px}.annotator-viewer div:first-of-type,.annotator-editor .annotator-item:first-child textarea{padding-top:12px;padding-bottom:12px;color:#3c3c3c;font-size:13px;font-style:italic;line-height:1.3;border-top:0}.annotator-viewer .annotator-controls{position:relative;top:5px;right:5px;padding-left:5px;opacity:0;-webkit-transition:opacity .2s ease-in;-moz-transition:opacity .2s ease-in;-o-transition:opacity .2s ease-in;transition:opacity .2s ease-in;float:right}.annotator-viewer li:hover .annotator-controls,.annotator-viewer li .annotator-controls.annotator-visible{opacity:1}.annotator-viewer .annotator-controls button,.annotator-viewer .annotator-controls a{cursor:pointer;display:inline-block;width:13px;height:13px;margin-left:2px;border:0;opacity:.2;text-indent:-900em;background-color:transparent;outline:0}.annotator-viewer .annotator-controls button:hover,.annotator-viewer .annotator-controls button:focus,.annotator-viewer .annotator-controls a:hover,.annotator-viewer .annotator-controls a:focus{opacity:.9}.annotator-viewer .annotator-controls button:active,.annotator-viewer .annotator-controls a:active{opacity:1}.annotator-viewer .annotator-controls button[disabled]{display:none}.annotator-viewer .annotator-controls .annotator-edit{background-position:0 -60px}.annotator-viewer .annotator-controls .annotator-delete{background-position:0 -75px}.annotator-viewer .annotator-controls .annotator-link{background-position:0 -270px}.annotator-editor .annotator-item{position:relative}.annotator-editor .annotator-item label{top:0;display:inline;cursor:pointer;font-size:12px}.annotator-editor .annotator-item input,.annotator-editor .annotator-item textarea{display:block;min-width:100%;padding:10px 8px;border:0;margin:0;color:#3c3c3c;background:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;resize:none}.annotator-editor .annotator-item textarea::-webkit-scrollbar{height:8px;width:8px}.annotator-editor .annotator-item textarea::-webkit-scrollbar-track-piece{margin:13px 0 3px;background-color:#e5e5e5;-webkit-border-radius:4px}.annotator-editor .annotator-item textarea::-webkit-scrollbar-thumb:vertical{height:25px;background-color:#ccc;-webkit-border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.1)}.annotator-editor .annotator-item textarea::-webkit-scrollbar-thumb:horizontal{width:25px;background-color:#ccc;-webkit-border-radius:4px}.annotator-editor .annotator-item:first-child textarea{min-height:5.5em;-webkit-border-radius:5px 5px 0 0;-moz-border-radius:5px 5px 0 0;-o-border-radius:5px 5px 0 0;border-radius:5px 5px 0 0}.annotator-editor .annotator-item input:focus,.annotator-editor .annotator-item textarea:focus{background-color:#f3f3f3;outline:0}.annotator-editor .annotator-item input[type=radio],.annotator-editor .annotator-item input[type=checkbox]{width:auto;min-width:0;padding:0;display:inline;margin:0 4px 0 0;cursor:pointer}.annotator-editor .annotator-checkbox{padding:8px 6px}.annotator-filter,.annotator-filter .annotator-filter-navigation button,.annotator-editor .annotator-controls{text-align:right;padding:3px;border-top:1px solid #d4d4d4;background-color:#d4d4d4;background-image:-webkit-gradient(linear,left top,left bottom,from(#f5f5f5),color-stop(0.6,#dcdcdc),to(#d2d2d2));background-image:-moz-linear-gradient(-90deg,#f5f5f5,#dcdcdc 60%,#d2d2d2);background-image:-webkit-linear-gradient(-90deg,#f5f5f5,#dcdcdc 60%,#d2d2d2);background-image:linear-gradient(-90deg,#f5f5f5,#dcdcdc 60%,#d2d2d2);-webkit-box-shadow:inset 1px 0 0 rgba(255,255,255,0.7),inset -1px 0 0 rgba(255,255,255,0.7),inset 0 1px 0 rgba(255,255,255,0.7);-moz-box-shadow:inset 1px 0 0 rgba(255,255,255,0.7),inset -1px 0 0 rgba(255,255,255,0.7),inset 0 1px 0 rgba(255,255,255,0.7);-o-box-shadow:inset 1px 0 0 rgba(255,255,255,0.7),inset -1px 0 0 rgba(255,255,255,0.7),inset 0 1px 0 rgba(255,255,255,0.7);box-shadow:inset 1px 0 0 rgba(255,255,255,0.7),inset -1px 0 0 rgba(255,255,255,0.7),inset 0 1px 0 rgba(255,255,255,0.7);-webkit-border-radius:0 0 5px 5px;-moz-border-radius:0 0 5px 5px;-o-border-radius:0 0 5px 5px;border-radius:0 0 5px 5px}.annotator-editor.annotator-invert-y .annotator-controls{border-top:0;border-bottom:1px solid #b4b4b4;-webkit-border-radius:5px 5px 0 0;-moz-border-radius:5px 5px 0 0;-o-border-radius:5px 5px 0 0;border-radius:5px 5px 0 0}.annotator-editor a,.annotator-filter .annotator-filter-property label{position:relative;display:inline-block;padding:0 6px 0 22px;color:#363636;text-shadow:0 1px 0 rgba(255,255,255,0.75);text-decoration:none;line-height:24px;font-size:12px;font-weight:bold;border:1px solid #a2a2a2;background-color:#d4d4d4;background-image:-webkit-gradient(linear,left top,left bottom,from(#f5f5f5),color-stop(0.5,#d2d2d2),color-stop(0.5,#bebebe),to(#d2d2d2));background-image:-moz-linear-gradient(-90deg,#f5f5f5,#d2d2d2 50%,#bebebe 50%,#d2d2d2);background-image:-webkit-linear-gradient(-90deg,#f5f5f5,#d2d2d2 50%,#bebebe 50%,#d2d2d2);background-image:linear-gradient(-90deg,#f5f5f5,#d2d2d2 50%,#bebebe 50%,#d2d2d2);-webkit-box-shadow:inset 0 0 5px rgba(255,255,255,0.2),inset 0 0 1px rgba(255,255,255,0.8);-moz-box-shadow:inset 0 0 5px rgba(255,255,255,0.2),inset 0 0 1px rgba(255,255,255,0.8);-o-box-shadow:inset 0 0 5px rgba(255,255,255,0.2),inset 0 0 1px rgba(255,255,255,0.8);box-shadow:inset 0 0 5px rgba(255,255,255,0.2),inset 0 0 1px rgba(255,255,255,0.8);-webkit-border-radius:5px;-moz-border-radius:5px;-o-border-radius:5px;border-radius:5px}.annotator-editor a::after{position:absolute;top:50%;left:5px;display:block;content:"";width:15px;height:15px;margin-top:-7px;background-position:0 -90px}.annotator-editor a:hover,.annotator-editor a:focus,.annotator-editor a.annotator-focus,.annotator-filter .annotator-filter-active label,.annotator-filter .annotator-filter-navigation button:hover{outline:0;border-color:#435aa0;background-color:#3865f9;background-image:-webkit-gradient(linear,left top,left bottom,from(#7691fb),color-stop(0.5,#5075fb),color-stop(0.5,#3865f9),to(#3665fa));background-image:-moz-linear-gradient(-90deg,#7691fb,#5075fb 50%,#3865f9 50%,#3665fa);background-image:-webkit-linear-gradient(-90deg,#7691fb,#5075fb 50%,#3865f9 50%,#3665fa);background-image:linear-gradient(-90deg,#7691fb,#5075fb 50%,#3865f9 50%,#3665fa);color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.42)}.annotator-editor a:hover::after,.annotator-editor a:focus::after{margin-top:-8px;background-position:0 -105px}.annotator-editor a:active,.annotator-filter .annotator-filter-navigation button:active{border-color:#700c49;background-color:#d12e8e;background-image:-webkit-gradient(linear,left top,left bottom,from(#fc7cca),color-stop(0.5,#e85db2),color-stop(0.5,#d12e8e),to(#ff009c));background-image:-moz-linear-gradient(-90deg,#fc7cca,#e85db2 50%,#d12e8e 50%,#ff009c);background-image:-webkit-linear-gradient(-90deg,#fc7cca,#e85db2 50%,#d12e8e 50%,#ff009c);background-image:linear-gradient(-90deg,#fc7cca,#e85db2 50%,#d12e8e 50%,#ff009c)}.annotator-editor a.annotator-save::after{background-position:0 -120px}.annotator-editor a.annotator-save:hover::after,.annotator-editor a.annotator-save:focus::after,.annotator-editor a.annotator-save.annotator-focus::after{margin-top:-8px;background-position:0 -135px}.annotator-editor .annotator-widget::after{background-position:0 -30px}.annotator-editor.annotator-invert-y .annotator-widget .annotator-controls{background-color:#f2f2f2}.annotator-editor.annotator-invert-y .annotator-widget::after{background-position:0 -45px;height:11px}.annotator-resize{position:absolute;top:0;right:0;width:12px;height:12px;background-position:2px -150px}.annotator-invert-x .annotator-resize{right:auto;left:0;background-position:0 -195px}.annotator-invert-y .annotator-resize{top:auto;bottom:0;background-position:2px -165px}.annotator-invert-y.annotator-invert-x .annotator-resize{background-position:0 -180px}.annotator-notice{color:#fff;position:absolute;position:fixed;top:-54px;left:0;width:100%;font-size:14px;line-height:50px;text-align:center;background:black;background:rgba(0,0,0,0.9);border-bottom:4px solid #d4d4d4;-webkit-transition:top .4s ease-out;-moz-transition:top .4s ease-out;-o-transition:top .4s ease-out;transition:top .4s ease-out}.ie6 .annotator-notice{position:absolute}.annotator-notice-success{border-color:#3665f9}.annotator-notice-error{border-color:#ff7e00}.annotator-notice p{margin:0}.annotator-notice a{color:#fff}.annotator-notice-show{top:0}.annotator-tags{margin-bottom:-2px}.annotator-tags .annotator-tag{display:inline-block;padding:0 8px;margin-bottom:2px;line-height:1.6;font-weight:bold;background-color:#e6e6e6;-webkit-border-radius:8px;-moz-border-radius:8px;-o-border-radius:8px;border-radius:8px}.annotator-filter{position:fixed;top:0;right:0;left:0;text-align:left;line-height:0;border:0;border-bottom:1px solid #878787;padding-left:10px;padding-right:10px;-webkit-border-radius:0;-moz-border-radius:0;-o-border-radius:0;border-radius:0;-webkit-box-shadow:inset 0 -1px 0 rgba(255,255,255,0.3);-moz-box-shadow:inset 0 -1px 0 rgba(255,255,255,0.3);-o-box-shadow:inset 0 -1px 0 rgba(255,255,255,0.3);box-shadow:inset 0 -1px 0 rgba(255,255,255,0.3)}.annotator-filter strong{font-size:12px;font-weight:bold;color:#3c3c3c;text-shadow:0 1px 0 rgba(255,255,255,0.7);position:relative;top:-9px}.annotator-filter .annotator-filter-property,.annotator-filter .annotator-filter-navigation{position:relative;display:inline-block;overflow:hidden;line-height:10px;padding:2px 0;margin-right:8px}.annotator-filter .annotator-filter-property label,.annotator-filter .annotator-filter-navigation button{text-align:left;display:block;float:left;line-height:20px;-webkit-border-radius:10px 0 0 10px;-moz-border-radius:10px 0 0 10px;-o-border-radius:10px 0 0 10px;border-radius:10px 0 0 10px}.annotator-filter .annotator-filter-property label{padding-left:8px}.annotator-filter .annotator-filter-property input{display:block;float:right;-webkit-appearance:none;background-color:#fff;border:1px solid #878787;border-left:none;padding:2px 4px;line-height:16px;min-height:16px;font-size:12px;width:150px;color:#333;background-color:#f8f8f8;-webkit-border-radius:0 10px 10px 0;-moz-border-radius:0 10px 10px 0;-o-border-radius:0 10px 10px 0;border-radius:0 10px 10px 0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.2);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.2);-o-box-shadow:inset 0 1px 1px rgba(0,0,0,0.2);box-shadow:inset 0 1px 1px rgba(0,0,0,0.2)}.annotator-filter .annotator-filter-property input:focus{outline:0;background-color:#fff}.annotator-filter .annotator-filter-clear{position:absolute;right:3px;top:6px;border:0;text-indent:-900em;width:15px;height:15px;background-position:0 -90px;opacity:.4}.annotator-filter .annotator-filter-clear:hover,.annotator-filter .annotator-filter-clear:focus{opacity:.8}.annotator-filter .annotator-filter-clear:active{opacity:1}.annotator-filter .annotator-filter-navigation button{border:1px solid #a2a2a2;padding:0;text-indent:-900px;width:20px;min-height:22px;-webkit-box-shadow:inset 0 0 5px rgba(255,255,255,0.2),inset 0 0 1px rgba(255,255,255,0.8);-moz-box-shadow:inset 0 0 5px rgba(255,255,255,0.2),inset 0 0 1px rgba(255,255,255,0.8);-o-box-shadow:inset 0 0 5px rgba(255,255,255,0.2),inset 0 0 1px rgba(255,255,255,0.8);box-shadow:inset 0 0 5px rgba(255,255,255,0.2),inset 0 0 1px rgba(255,255,255,0.8)}.annotator-filter .annotator-filter-navigation button,.annotator-filter .annotator-filter-navigation button:hover,.annotator-filter .annotator-filter-navigation button:focus{color:transparent}.annotator-filter .annotator-filter-navigation button::after{position:absolute;top:8px;left:8px;content:"";display:block;width:9px;height:9px;background-position:0 -210px}.annotator-filter .annotator-filter-navigation button:hover::after{background-position:0 -225px}.annotator-filter .annotator-filter-navigation .annotator-filter-next{-webkit-border-radius:0 10px 10px 0;-moz-border-radius:0 10px 10px 0;-o-border-radius:0 10px 10px 0;border-radius:0 10px 10px 0;border-left:none}.annotator-filter .annotator-filter-navigation .annotator-filter-next::after{left:auto;right:7px;background-position:0 -240px}.annotator-filter .annotator-filter-navigation .annotator-filter-next:hover::after{background-position:0 -255px}.annotator-hl-active{background:rgba(255,255,10,0.8)}.annotator-hl-filtered{background-color:transparent}
\ No newline at end of file
--- a/webapp/src/main/webapp/jquery/digilib-ann.html	Thu Nov 08 19:08:24 2012 +0100
+++ b/webapp/src/main/webapp/jquery/digilib-ann.html	Fri Nov 09 11:28:44 2012 +0100
@@ -12,7 +12,6 @@
         </style>
 
         <script type="text/javascript" src="jquery.js"></script>
-        <script type="text/javascript" src="jquery.tools.min.js"></script>
         <script type="text/javascript" src="jquery.cookie.js"></script>
         <script type="text/javascript" src="jquery.digilib.js"></script>
         <script type="text/javascript" src="jquery.digilib.geometry.js"></script>
@@ -25,7 +24,10 @@
         <script type="text/javascript" src="jquery.digilib.birdseye.js"></script>
         <script type="text/javascript" src="jquery.digilib.marks.js"></script>
         <script type="text/javascript" src="jquery.digilib.regions.js"></script>
-        <script type="text/javascript" src="jquery.digilib.annotations.js"></script>
+        <script type="text/javascript" src="showdown.js"></script>
+        <script type="text/javascript" src="annotator-dl.js"></script>
+        <link rel="stylesheet" type="text/css" href="annotator.min.css" />
+        <script type="text/javascript" src="jquery.digilib.annotator.js"></script>
         <link rel="stylesheet" type="text/css" href="jquery.digilib.css" />
 
         <script type="text/javascript">
@@ -34,11 +36,30 @@
                     interactionMode : 'fullscreen',
                     showRegionNumbers : true,
                     // URL of annotation server
+                    //'annotationServerUrl' : 'http://tuxserve03.mpiwg-berlin.mpg.de/AnnotationManager/annotator',
                     'annotationServerUrl' : 'http://localhost:18080/AnnotationManager/annotator',
                     //'annotationServerUrl' : 'http://tuxserve03.mpiwg-berlin.mpg.de/AnnotationManager/annotator',
                     // URL of authentication token server
-                    'annotationTokenUrl' : 'http://r583-1.mpiwg-berlin.mpg.de:8080/test/annotator/token/getLoginToken',
-                    };
+                    'annotationTokenUrl' : 'http://localhost:8080/test/docuviewa/template/token/getLoginToken',
+                    'annotatorPlugins' : {
+                		'Markdown' : {},
+                        'Permissions' : { 
+                        	//user: data.settings.annotationUser,
+                            userString : function(user) {
+                                if (user && user.name) {
+                                    return user.name;
+                                }
+                                return user;
+                            }, 
+                            userId: function (user) {
+                                if (user && user.id) {
+                                    return user.id;
+                                }
+                                return user;
+                            }
+                        }
+                    }
+                };
                 var $div = $('div#digilib');
                 $div.digilib(opts);
             });
--- a/webapp/src/main/webapp/jquery/jquery.digilib.annotator.js	Thu Nov 08 19:08:24 2012 +0100
+++ b/webapp/src/main/webapp/jquery/jquery.digilib.annotator.js	Fri Nov 09 11:28:44 2012 +0100
@@ -207,7 +207,7 @@
         // set params for Permissions plugin
         var perms = data.annotator.plugins.Permissions;
         if (perms != null) {
-        	perms.options.user = user;
+        	perms.setUser(user);
         }
    	};
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/webapp/src/main/webapp/jquery/showdown.js	Fri Nov 09 11:28:44 2012 +0100
@@ -0,0 +1,419 @@
+/*
+   A A L        Source code at:
+   T C A   <http://www.attacklab.net/>
+   T K B
+*/
+
+var Showdown={};
+Showdown.converter=function(){
+var _1;
+var _2;
+var _3;
+var _4=0;
+this.makeHtml=function(_5){
+_1=new Array();
+_2=new Array();
+_3=new Array();
+_5=_5.replace(/~/g,"~T");
+_5=_5.replace(/\$/g,"~D");
+_5=_5.replace(/\r\n/g,"\n");
+_5=_5.replace(/\r/g,"\n");
+_5="\n\n"+_5+"\n\n";
+_5=_6(_5);
+_5=_5.replace(/^[ \t]+$/mg,"");
+_5=_7(_5);
+_5=_8(_5);
+_5=_9(_5);
+_5=_a(_5);
+_5=_5.replace(/~D/g,"$$");
+_5=_5.replace(/~T/g,"~");
+return _5;
+};
+var _8=function(_b){
+var _b=_b.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,function(_c,m1,m2,m3,m4){
+m1=m1.toLowerCase();
+_1[m1]=_11(m2);
+if(m3){
+return m3+m4;
+}else{
+if(m4){
+_2[m1]=m4.replace(/"/g,"&quot;");
+}
+}
+return "";
+});
+return _b;
+};
+var _7=function(_12){
+_12=_12.replace(/\n/g,"\n\n");
+var _13="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del";
+var _14="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math";
+_12=_12.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,_15);
+_12=_12.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,_15);
+_12=_12.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,_15);
+_12=_12.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,_15);
+_12=_12.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,_15);
+_12=_12.replace(/\n\n/g,"\n");
+return _12;
+};
+var _15=function(_16,m1){
+var _18=m1;
+_18=_18.replace(/\n\n/g,"\n");
+_18=_18.replace(/^\n/,"");
+_18=_18.replace(/\n+$/g,"");
+_18="\n\n~K"+(_3.push(_18)-1)+"K\n\n";
+return _18;
+};
+var _9=function(_19){
+_19=_1a(_19);
+var key=_1c("<hr />");
+_19=_19.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,key);
+_19=_19.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,key);
+_19=_19.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key);
+_19=_1d(_19);
+_19=_1e(_19);
+_19=_1f(_19);
+_19=_7(_19);
+_19=_20(_19);
+return _19;
+};
+var _21=function(_22){
+_22=_23(_22);
+_22=_24(_22);
+_22=_25(_22);
+_22=_26(_22);
+_22=_27(_22);
+_22=_28(_22);
+_22=_11(_22);
+_22=_29(_22);
+_22=_22.replace(/  +\n/g," <br />\n");
+return _22;
+};
+var _24=function(_2a){
+var _2b=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;
+_2a=_2a.replace(_2b,function(_2c){
+var tag=_2c.replace(/(.)<\/?code>(?=.)/g,"$1`");
+tag=_2e(tag,"\\`*_");
+return tag;
+});
+return _2a;
+};
+var _27=function(_2f){
+_2f=_2f.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,_30);
+_2f=_2f.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,_30);
+_2f=_2f.replace(/(\[([^\[\]]+)\])()()()()()/g,_30);
+return _2f;
+};
+var _30=function(_31,m1,m2,m3,m4,m5,m6,m7){
+if(m7==undefined){
+m7="";
+}
+var _39=m1;
+var _3a=m2;
+var _3b=m3.toLowerCase();
+var url=m4;
+var _3d=m7;
+if(url==""){
+if(_3b==""){
+_3b=_3a.toLowerCase().replace(/ ?\n/g," ");
+}
+url="#"+_3b;
+if(_1[_3b]!=undefined){
+url=_1[_3b];
+if(_2[_3b]!=undefined){
+_3d=_2[_3b];
+}
+}else{
+if(_39.search(/\(\s*\)$/m)>-1){
+url="";
+}else{
+return _39;
+}
+}
+}
+url=_2e(url,"*_");
+var _3e="<a href=\""+url+"\"";
+if(_3d!=""){
+_3d=_3d.replace(/"/g,"&quot;");
+_3d=_2e(_3d,"*_");
+_3e+=" title=\""+_3d+"\"";
+}
+_3e+=">"+_3a+"</a>";
+return _3e;
+};
+var _26=function(_3f){
+_3f=_3f.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,_40);
+_3f=_3f.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,_40);
+return _3f;
+};
+var _40=function(_41,m1,m2,m3,m4,m5,m6,m7){
+var _49=m1;
+var _4a=m2;
+var _4b=m3.toLowerCase();
+var url=m4;
+var _4d=m7;
+if(!_4d){
+_4d="";
+}
+if(url==""){
+if(_4b==""){
+_4b=_4a.toLowerCase().replace(/ ?\n/g," ");
+}
+url="#"+_4b;
+if(_1[_4b]!=undefined){
+url=_1[_4b];
+if(_2[_4b]!=undefined){
+_4d=_2[_4b];
+}
+}else{
+return _49;
+}
+}
+_4a=_4a.replace(/"/g,"&quot;");
+url=_2e(url,"*_");
+var _4e="<img src=\""+url+"\" alt=\""+_4a+"\"";
+_4d=_4d.replace(/"/g,"&quot;");
+_4d=_2e(_4d,"*_");
+_4e+=" title=\""+_4d+"\"";
+_4e+=" />";
+return _4e;
+};
+var _1a=function(_4f){
+_4f=_4f.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,function(_50,m1){
+return _1c("<h1>"+_21(m1)+"</h1>");
+});
+_4f=_4f.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(_52,m1){
+return _1c("<h2>"+_21(m1)+"</h2>");
+});
+_4f=_4f.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(_54,m1,m2){
+var _57=m1.length;
+return _1c("<h"+_57+">"+_21(m2)+"</h"+_57+">");
+});
+return _4f;
+};
+var _58;
+var _1d=function(_59){
+_59+="~0";
+var _5a=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;
+if(_4){
+_59=_59.replace(_5a,function(_5b,m1,m2){
+var _5e=m1;
+var _5f=(m2.search(/[*+-]/g)>-1)?"ul":"ol";
+_5e=_5e.replace(/\n{2,}/g,"\n\n\n");
+var _60=_58(_5e);
+_60=_60.replace(/\s+$/,"");
+_60="<"+_5f+">"+_60+"</"+_5f+">\n";
+return _60;
+});
+}else{
+_5a=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g;
+_59=_59.replace(_5a,function(_61,m1,m2,m3){
+var _65=m1;
+var _66=m2;
+var _67=(m3.search(/[*+-]/g)>-1)?"ul":"ol";
+var _66=_66.replace(/\n{2,}/g,"\n\n\n");
+var _68=_58(_66);
+_68=_65+"<"+_67+">\n"+_68+"</"+_67+">\n";
+return _68;
+});
+}
+_59=_59.replace(/~0/,"");
+return _59;
+};
+_58=function(_69){
+_4++;
+_69=_69.replace(/\n{2,}$/,"\n");
+_69+="~0";
+_69=_69.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,function(_6a,m1,m2,m3,m4){
+var _6f=m4;
+var _70=m1;
+var _71=m2;
+if(_70||(_6f.search(/\n{2,}/)>-1)){
+_6f=_9(_72(_6f));
+}else{
+_6f=_1d(_72(_6f));
+_6f=_6f.replace(/\n$/,"");
+_6f=_21(_6f);
+}
+return "<li>"+_6f+"</li>\n";
+});
+_69=_69.replace(/~0/g,"");
+_4--;
+return _69;
+};
+var _1e=function(_73){
+_73+="~0";
+_73=_73.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(_74,m1,m2){
+var _77=m1;
+var _78=m2;
+_77=_79(_72(_77));
+_77=_6(_77);
+_77=_77.replace(/^\n+/g,"");
+_77=_77.replace(/\n+$/g,"");
+_77="<pre><code>"+_77+"\n</code></pre>";
+return _1c(_77)+_78;
+});
+_73=_73.replace(/~0/,"");
+return _73;
+};
+var _1c=function(_7a){
+_7a=_7a.replace(/(^\n+|\n+$)/g,"");
+return "\n\n~K"+(_3.push(_7a)-1)+"K\n\n";
+};
+var _23=function(_7b){
+_7b=_7b.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(_7c,m1,m2,m3,m4){
+var c=m3;
+c=c.replace(/^([ \t]*)/g,"");
+c=c.replace(/[ \t]*$/g,"");
+c=_79(c);
+return m1+"<code>"+c+"</code>";
+});
+return _7b;
+};
+var _79=function(_82){
+_82=_82.replace(/&/g,"&amp;");
+_82=_82.replace(/</g,"&lt;");
+_82=_82.replace(/>/g,"&gt;");
+_82=_2e(_82,"*_{}[]\\",false);
+return _82;
+};
+var _29=function(_83){
+_83=_83.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"<strong>$2</strong>");
+_83=_83.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"<em>$2</em>");
+return _83;
+};
+var _1f=function(_84){
+_84=_84.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(_85,m1){
+var bq=m1;
+bq=bq.replace(/^[ \t]*>[ \t]?/gm,"~0");
+bq=bq.replace(/~0/g,"");
+bq=bq.replace(/^[ \t]+$/gm,"");
+bq=_9(bq);
+bq=bq.replace(/(^|\n)/g,"$1  ");
+bq=bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm,function(_88,m1){
+var pre=m1;
+pre=pre.replace(/^  /mg,"~0");
+pre=pre.replace(/~0/g,"");
+return pre;
+});
+return _1c("<blockquote>\n"+bq+"\n</blockquote>");
+});
+return _84;
+};
+var _20=function(_8b){
+_8b=_8b.replace(/^\n+/g,"");
+_8b=_8b.replace(/\n+$/g,"");
+var _8c=_8b.split(/\n{2,}/g);
+var _8d=new Array();
+var end=_8c.length;
+for(var i=0;i<end;i++){
+var str=_8c[i];
+if(str.search(/~K(\d+)K/g)>=0){
+_8d.push(str);
+}else{
+if(str.search(/\S/)>=0){
+str=_21(str);
+str=str.replace(/^([ \t]*)/g,"<p>");
+str+="</p>";
+_8d.push(str);
+}
+}
+}
+end=_8d.length;
+for(var i=0;i<end;i++){
+while(_8d[i].search(/~K(\d+)K/)>=0){
+var _91=_3[RegExp.$1];
+_91=_91.replace(/\$/g,"$$$$");
+_8d[i]=_8d[i].replace(/~K\d+K/,_91);
+}
+}
+return _8d.join("\n\n");
+};
+var _11=function(_92){
+_92=_92.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&amp;");
+_92=_92.replace(/<(?![a-z\/?\$!])/gi,"&lt;");
+return _92;
+};
+var _25=function(_93){
+_93=_93.replace(/\\(\\)/g,_94);
+_93=_93.replace(/\\([`*_{}\[\]()>#+-.!])/g,_94);
+return _93;
+};
+var _28=function(_95){
+_95=_95.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,"<a href=\"$1\">$1</a>");
+_95=_95.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,function(_96,m1){
+return _98(_a(m1));
+});
+return _95;
+};
+var _98=function(_99){
+function char2hex(ch){
+var _9b="0123456789ABCDEF";
+var dec=ch.charCodeAt(0);
+return (_9b.charAt(dec>>4)+_9b.charAt(dec&15));
+}
+var _9d=[function(ch){
+return "&#"+ch.charCodeAt(0)+";";
+},function(ch){
+return "&#x"+char2hex(ch)+";";
+},function(ch){
+return ch;
+}];
+_99="mailto:"+_99;
+_99=_99.replace(/./g,function(ch){
+if(ch=="@"){
+ch=_9d[Math.floor(Math.random()*2)](ch);
+}else{
+if(ch!=":"){
+var r=Math.random();
+ch=(r>0.9?_9d[2](ch):r>0.45?_9d[1](ch):_9d[0](ch));
+}
+}
+return ch;
+});
+_99="<a href=\""+_99+"\">"+_99+"</a>";
+_99=_99.replace(/">.+:/g,"\">");
+return _99;
+};
+var _a=function(_a3){
+_a3=_a3.replace(/~E(\d+)E/g,function(_a4,m1){
+var _a6=parseInt(m1);
+return String.fromCharCode(_a6);
+});
+return _a3;
+};
+var _72=function(_a7){
+_a7=_a7.replace(/^(\t|[ ]{1,4})/gm,"~0");
+_a7=_a7.replace(/~0/g,"");
+return _a7;
+};
+var _6=function(_a8){
+_a8=_a8.replace(/\t(?=\t)/g,"    ");
+_a8=_a8.replace(/\t/g,"~A~B");
+_a8=_a8.replace(/~B(.+?)~A/g,function(_a9,m1,m2){
+var _ac=m1;
+var _ad=4-_ac.length%4;
+for(var i=0;i<_ad;i++){
+_ac+=" ";
+}
+return _ac;
+});
+_a8=_a8.replace(/~A/g,"    ");
+_a8=_a8.replace(/~B/g,"");
+return _a8;
+};
+var _2e=function(_af,_b0,_b1){
+var _b2="(["+_b0.replace(/([\[\]\\])/g,"\\$1")+"])";
+if(_b1){
+_b2="\\\\"+_b2;
+}
+var _b3=new RegExp(_b2,"g");
+_af=_af.replace(_b3,_94);
+return _af;
+};
+var _94=function(_b4,m1){
+var _b6=m1.charCodeAt(0);
+return "~E"+_b6+"E";
+};
+};
+