/* ** Annotator v1.2.5 ** 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-06-22 12:25:24Z */((function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x=Array.prototype.slice,y=Object.prototype.hasOwnProperty,z=function(a,b){function d(){this.constructor=a}for(var c in b)y.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a},A=function(a,b){return function(){return a.apply(b,arguments)}},B=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;b/g,">").replace(/"/g,""")},a.fn.escape=function(b){return arguments.length?this.html(a.escape(b)):this.html()},a.fn.reverse=[].reverse,j=["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(a){return console.log("GROUP: ",a)}),console.groupCollapsed==null&&(console.groupCollapsed=console.group);for(q=0,s=j.length;q0?h.start.splitText(h.startOffset):h.start,h.start===h.end?(h.endOffset-h.startOffset=this[g+"Offset"]){h[g+"Container"]=i,h[g+"Offset"]=this[g+"Offset"]-d;break}d+=i.nodeValue.length}if(h[g+"Offset"]==null)throw new e.RangeError(""+g+"offset","Couldn't find offset "+this[g+"Offset"]+" in element "+this[g])}return c=document.compareDocumentPosition==null?function(a,b){return a.contains(b)}:function(a,b){return a.compareDocumentPosition(b)&16},a(h.startContainer).parents().reverse().each(function(){if(c(this,h.endContainer))return h.commonAncestorContainer=this,!1}),(new e.BrowserRange(h)).normalize(b)},b.prototype.serialize=function(a,b){return this.normalize(a).serialize(a,b)},b.prototype.toObject=function(){return{start:this.start,startOffset:this.startOffset,end:this.end,endOffset:this.endOffset}},b}(),n={uuid:function(){var a;return a=0,function(){return a++}}(),getGlobal:function(){return function(){return this}()},maxZIndex:function(b){var c,d;return c=function(){var c,e,f;f=[];for(c=0,e=b.length;c",wrapper:'
'},c.prototype.options={readOnly:!1},c.prototype.plugins={},c.prototype.editor=null,c.prototype.viewer=null,c.prototype.selectedRanges=null,c.prototype.mouseIsDown=!1,c.prototype.ignoreMouseup=!1,c.prototype.viewerHideTimer=null,c.prototype._setupWrapper=function(){return this.wrapper=a(this.html.wrapper),this.element.find("script").remove(),this.element.wrapInner(this.wrapper),this.wrapper=this.element.find(".annotator-wrapper"),this},c.prototype._setupViewer=function(){var b=this;return this.viewer=new c.Viewer({readOnly:this.options.readOnly}),this.viewer.hide().on("edit",this.onEditAnnotation).on("delete",this.onDeleteAnnotation).addField({load:function(c,d){return d.text?a(c).escape(d.text):a(c).html(""+w("No Comment")+""),b.publish("annotationViewerTextField",[c,d])}}).element.appendTo(this.wrapper).bind({mouseover:this.clearViewerHideTimer,mouseout:this.startViewerHideTimer}),this},c.prototype._setupEditor=function(){return this.editor=new c.Editor,this.editor.hide().on("hide",this.onEditorHide).on("save",this.onEditorSubmit).addField({type:"textarea",label:w("Comments")+"…",load:function(b,c){return a(b).find("textarea").val(c.text||"")},submit:function(b,c){return c.text=a(b).find("textarea").val()}}),this.editor.element.appendTo(this.wrapper),this},c.prototype._setupDocumentEvents=function(){return a(document).bind({mouseup:this.checkForEndSelection,mousedown:this.checkForStartSelection}),this},c.prototype._setupDynamicStyle=function(){var b,c,d,e;return d=a("#annotator-dynamic-style"),d.length||(d=a('').appendTo(document.head)),c="*"+function(){var a,b,c,d;c=["adder","outer","notice","filter"],d=[];for(a=0,b=c.length;aa;0<=a?c++:c--)f=i.getRangeAt(c),b=new e.BrowserRange(f),d=b.normalize().limit(this.wrapper[0]),d===null&&h.push(f),g.push(d);return g}.call(this),i.removeAllRanges());for(j=0,k=h.length;j0?setTimeout(function(){return c(a)},10):d.publish("annotationsLoaded",[b])},b=a.slice(),a.length&&c(a),this},c.prototype.dumpAnnotations=function(){return this.plugins.Store?this.plugins.Store.dumpAnnotations():console.warn(w("Can't dump annotations without Store plugin."))},c.prototype.highlightRange=function(b,c){var d,e,f,g,h,i,j;c==null&&(c="annotator-hl"),f=/^\s*$/,d=a(""),i=b.textNodes(),j=[];for(g=0,h=i.length;g tag?"))),this},c.prototype.showEditor=function(a,b){return this.editor.element.css(b),this.editor.load(a),this.publish("annotationEditorShown",[this.editor,a]),this},c.prototype.onEditorHide=function(){return this.publish("annotationEditorHidden",[this.editor]),this.ignoreMouseup=!1},c.prototype.onEditorSubmit=function(a){return this.publish("annotationEditorSubmit",[this.editor,a]),a.ranges===void 0?this.setupAnnotation(a):this.updateAnnotation(a)},c.prototype.showViewer=function(a,b){return this.viewer.element.css(b),this.viewer.load(a),this.publish("annotationViewerShown",[this.viewer,a])},c.prototype.startViewerHideTimer=function(){if(!this.viewerHideTimer)return this.viewerHideTimer=setTimeout(this.viewer.hide,250)},c.prototype.clearViewerHideTimer=function(){return clearTimeout(this.viewerHideTimer),this.viewerHideTimer=!1},c.prototype.checkForStartSelection=function(a){if(!a||!this.isAnnotator(a.target))return this.startViewerHideTimer(),this.mouseIsDown=!0},c.prototype.checkForEndSelection=function(b){var c,d,e,f,g;this.mouseIsDown=!1;if(this.ignoreMouseup)return;this.selectedRanges=this.getSelectedRanges(),g=this.selectedRanges;for(e=0,f=g.length;e0&&this.invertX(),this},d.prototype.resetOrientation=function(){return this.element.removeClass(this.classes.invert.x).removeClass(this.classes.invert.y),this},d.prototype.invertX=function(){return this.element.addClass(this.classes.invert.x),this},d.prototype.invertY=function(){return this.element.addClass(this.classes.invert.y),this},d.prototype.isInvertedY=function(){return this.element.hasClass(this.classes.invert.y)},d.prototype.isInvertedX=function(){return this.element.hasClass(this.classes.invert.x)},d}(c),b.Editor=function(b){function c(b){this.onCancelButtonMouseover=A(this.onCancelButtonMouseover,this),this.processKeypress=A(this.processKeypress,this),this.submit=A(this.submit,this),this.load=A(this.load,this),this.hide=A(this.hide,this),this.show=A(this.show,this),c.__super__.constructor.call(this,a(this.html)[0],b),this.fields=[],this.annotation={}}return z(c,b),c.prototype.events={"form submit":"submit",".annotator-save click":"submit",".annotator-cancel click":"hide",".annotator-cancel mouseover":"onCancelButtonMouseover","textarea keydown":"processKeypress"},c.prototype.classes={hide:"annotator-hide",focus:"annotator-focus"},c.prototype.html='
\n
\n
    \n \n
    \n
    ",c.prototype.options={},c.prototype.show=function(a){return n.preventEventDefault(a),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")},c.prototype.hide=function(a){return n.preventEventDefault(a),this.element.addClass(this.classes.hide),this.publish("hide")},c.prototype.load=function(a){var b,c,d,e;this.annotation=a,this.publish("load",[this.annotation]),e=this.fields;for(c=0,d=e.length;c'),d.element=c[0];switch(d.type){case"textarea":e=a("