Skip to content
Browse files

Annotator release v1.0.0beta

  • Loading branch information...
1 parent d9a707c commit 66cdb88edd15499673bf182a28b3f240246e45d1 @nickstenning nickstenning committed
View
1 pkg/annotator.auth.min.js
@@ -0,0 +1 @@
+(function(){var d;var b=function(e,f){return function(){return e.apply(f,arguments)}},a=Object.prototype.hasOwnProperty,c=function(h,f){for(var e in f){if(a.call(f,e)){h[e]=f[e]}}function g(){this.constructor=h}g.prototype=f.prototype;h.prototype=new g;h.__super__=f.prototype;return h};d=jQuery;Date.prototype.setISO8601=function(f){var k,e,j,h,i,g;h="([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})))?)?)?)?";k=f.match(new RegExp(h));j=0;e=new Date(k[1],0,1);if(k[3]){e.setMonth(k[3]-1)}if(k[5]){e.setDate(k[5])}if(k[7]){e.setHours(k[7])}if(k[8]){e.setMinutes(k[8])}if(k[10]){e.setSeconds(k[10])}if(k[12]){e.setMilliseconds(Number("0."+k[12])*1000)}if(k[14]){j=(Number(k[16])*60)+Number(k[17]);j*=(g=k[15]==="-")!=null?g:{1:-1}}j-=e.getTimezoneOffset();i=Number(e)+(j*60*1000);this.setTime(Number(i));return this};Annotator.Plugins.Auth=(function(){c(e,Delegator);e.prototype.options={token:null,tokenUrl:"/auth/token",autoFetch:true};function e(g,f){this.haveValidToken=b(this.haveValidToken,this);e.__super__.constructor.apply(this,arguments);this.addEvents();d(this.element).data("annotator:auth",this);this.waitingForToken=[];if(this.options.token){this.setToken(this.options.token)}else{this.requestToken()}}e.prototype.requestToken=function(){this.requestInProgress=true;return d.getJSON(this.options.tokenUrl,b(function(g,f,h){if(f!=="success"){return console.error("Couldn't get auth token: "+f,h)}else{this.setToken(g);return this.requestInProgress=false}},this))};e.prototype.setToken=function(g){var f;this.token=g;if(this.haveValidToken()){if(this.options.autoFetch){this.refreshTimeout=setTimeout((b(function(){return this.requestToken()},this)),(this.timeToExpiry()-2)*1000)}this.updateHeaders();f=[];while(this.waitingForToken.length>0){f.push(this.waitingForToken.pop().apply())}return f}else{console.warn("Didn't get a valid token.");if(this.options.autoFetch){console.warn("Getting a new token in 10s.");return setTimeout((b(function(){return this.requestToken()},this)),10*1000)}}};e.prototype.haveValidToken=function(){var f;f=this.token&&this.token.authToken&&this.token.authTokenIssueTime&&this.token.authTokenTTL&&this.token.consumerKey&&this.token.userId;return f&&this.timeToExpiry()>0};e.prototype.timeToExpiry=function(){var h,f,g,i;g=new Date().getTime()/1000;f=new Date().setISO8601(this.token.authTokenIssueTime).getTime()/1000;h=f+this.token.authTokenTTL;i=h-g;if(i>0){return i}else{return 0}};e.prototype.updateHeaders=function(){var f;f=d(this.element).data("annotator:headers");return d(this.element).data("annotator:headers",d.extend(f,{"x-annotator-auth-token":this.token.authToken,"x-annotator-auth-token-issue-time":this.token.authTokenIssueTime,"x-annotator-auth-token-ttl":this.token.authTokenTTL,"x-annotator-consumer-key":this.token.consumerKey,"x-annotator-user-id":this.token.userId}))};e.prototype.withToken=function(f){if(!(f!=null)){return}if(this.haveValidToken()){return f()}else{this.waitingForToken.push(f);if(!this.requestInProgress){return this.requestToken()}}};return e})()}).call(this);
View
1 pkg/annotator.markdown.min.js
@@ -0,0 +1 @@
+(function(){var d;var b=function(e,f){return function(){return e.apply(f,arguments)}},a=Object.prototype.hasOwnProperty,c=function(h,f){for(var e in f){if(a.call(f,e)){h[e]=f[e]}}function g(){this.constructor=h}g.prototype=f.prototype;h.prototype=new g;h.__super__=f.prototype;return h};d=jQuery;Annotator.Plugins.Markdown=(function(){c(e,Delegator);e.prototype.events={annotationViewerShown:"updateViewer"};function e(g,f){this.updateViewer=b(this.updateViewer,this);if(typeof Showdown!="undefined"&&Showdown!==null){e.__super__.constructor.apply(this,arguments);this.addEvents();this.converter=new Showdown.converter()}else{console.error("To use the Markdown plugin, you must include Showdown into the page first.")}}e.prototype.updateViewer=function(k,n,j){var f,l,o,g,i,m,h;g=d(n).find(".annotator-ann-text");h=[];for(i=0,m=g.length;i<m;i++){o=g[i];f=d(o).parent().data("annotation");l=this.converter.makeHtml(f.text);h.push(d(o).html(l))}return h};return e})()}).call(this);
View
1 pkg/annotator.min.css
@@ -0,0 +1 @@
+.annotator-wrapper{position:relative;}.annotator-adder a{display:block;width:22px;height:22px;background:transparent url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH1gcFDBUEtI+i2QAAAJF0RVh0Q29tbWVudABUb29sYmFyLXNpemVkIGljb24KPT09PT09PT09PT09CgooYykgMjAwMyBKYWt1YiAnamltbWFjJyBTdGVpbmVyLCAKaHR0cDovL2ppbW1hYy5tdXNpY2hhbGwuY3oKCmNyZWF0ZWQgd2l0aCB0aGUgR0lNUCwKaHR0cDovL3d3dy5naW1wLm9yZxbzvxQAAALTSURBVDjLnZVLTBNBGMd/u1uCoBxaDzR7MBxIiCf0olcOoiacfMRED+CVgyYk3ognQ0JAQvCiMSoEDoTyiB7QkEh8UHpCRCwPU4QCCqXYh7SN3dDd8QBbFlkq8E8238xk85v/fDPzDVjk7UAcJeaUtwMhhBBHiXY82dpJLQ9vxeknh4oWSWbDAdDY1NA1+C0JXOBNoB6o3RM943d3xZ5Pd4BaXvrv0djkFPmf7wNQ121I2RkamxrEtSs3GB8fx+VyEY1GcTqdrKysoKoqsViM4uJigsEgqqqytraGqqqEw2EmJiZwLzVT0+ZlcaSX931t1HUbksO07na7qaioAMAwDBRFoby8HEmSEGIrjWVlZciyjGEYAAghcC81c/vRKMsfupicWdcBJZsKgMLCQjRNA0BRFNsNNscVRSEUCvH1+cUdaCBCdLpfMVORBcvyzj4Gg8GcJ2h9fZ3Zzipq2rwE33Uy5g+RDLzK5ncX2KqSkpJ9oaurqzvQt518mfu1B7oveD/HWaetW9DpxRjxmQG0sw+gu57/gu0cZ522elkY6WFqIUrE34fz0gtC4Z97/j+QY9NpdcsI34famfkRJ+Lvp7J+kvn5+YODrY6FEIy0nKP64UcCQ+3MLMWJzw5QWT8JQCQSsU1bTsdCCDweD5vyeaZ8PhZXfhOfHeB0zWvC4TBCCHRdPzjYdKzrOuqPFobXSunp66NUHuPU9V5SqRTJZJKioiLS6fS+YNnOsRACTdOo6zZovTnH6OZVTpZd5ozLBYDL5ULTtOwt3OYYVvAxO8dCCIQQ2SXf2l6BefskSSKTyeB2u5kPJtjm/IGtMuoACuyWIkkSkiTZXmlTeXl55Ofnm90CQAN0QHKYRSMWi+Hz+TisLJNbZxUOIJ3YSAw+ffa4iiMqsZEYBNJmGsx67ABOAEXAcctJkXOwzE3KACkgASS3+7ueEtnycQiw2Tb+GeMvnmKjxk6hepkAAAAASUVORK5CYII=') no-repeat left top;}.annotator-adder{position:absolute;display:none;margin:-25px 0 0 3px;}.annotator-hl{background:rgba(255,255,10,0.3);}.annotator-editor,.annotator-viewer{position:absolute;border-radius:.3em;-moz-border-radius:.3em;-webkit-border-radius:.3em;height:auto;width:15em;line-height:16px;background:rgba(253,245,216,0.95);border:1px solid #e1be94;margin:1px 0 0 0;padding:.2em;}.annotator-editor textarea{background:transparent;margin:1px 0 0 0;padding:0;border:none;width:100%;}.annotator-editor .annotator-editor-controls{float:right;}.annotator-editor .annotator-editor-controls button{opacity:.5;border:1px solid transparent;margin:0;line-height:16px;padding:0 0 0 18px;background:transparent none no-repeat top left;}.annotator-editor .annotator-editor-controls button:hover{opacity:1;cursor:pointer;}.annotator-editor .annotator-editor-controls button.annotator-editor-save{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAKfSURBVDjLpZPrS1NhHMf9O3bOdmwDCWREIYKEUHsVJBI7mg3FvCxL09290jZj2EyLMnJexkgpLbPUanNOberU5taUMnHZUULMvelCtWF0sW/n7MVMEiN64AsPD8/n83uucQDi/id/DBT4Dolypw/qsz0pTMbj/WHpiDgsdSUyUmeiPt2+V7SrIM+bSss8ySGdR4abQQv6lrui6VxsRonrGCS9VEjSQ9E7CtiqdOZ4UuTqnBHO1X7YXl6Daa4yGq7vWO1D40wVDtj4kWQbn94myPGkCDPdSesczE2sCZShwl8CzcwZ6NiUs6n2nYX99T1cnKqA2EKui6+TwphA5k4yqMayopU5mANV3lNQTBdCMVUA9VQh3GuDMHiVcLCS3J4jSLhCGmKCjBEx0xlshjXYhApfMZRP5CyYD+UkG08+xt+4wLVQZA1tzxthm2tEfD3JxARH7QkbD1ZuozaggdZbxK5kAIsf5qGaKMTY2lAU/rH5HW3PLsEwUYy+YCcERmIjJpDcpzb6l7th9KtQ69fi09ePUej9l7cx2DJbD7UrG3r3afQHOyCo+V3QQzE35pvQvnAZukk5zL5qRL59jsKbPzdheXoBZc4saFhBS6AO7V4zqCpiawuptwQG+UAa7Ct3UT0hh9p9EnXT5Vh6t4C22QaUDh6HwnECOmcO7K+6kW49DKqS2DrEZCtfuI+9GrNHg4fMHVSO5kE7nAPVkAxKBxcOzsajpS4Yh4ohUPPWKTUh3PaQEptIOr6BiJjcZXCwktaAGfrRIpwblqOV3YKdhfXOIvBLeREWpnd8ynsaSJoyESFphwTtfjN6X1jRO2+FxWtCWksqBApeiFIR9K6fiTpPiigDoadqCEag5YUFKl6Yrciw0VOlhOivv/Ff8wtn0KzlebrUYwAAAABJRU5ErkJggg==');}.annotator-editor .annotator-editor-controls button.annotator-editor-cancel{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHdSURBVDjLpZNraxpBFIb3a0ggISmmNISWXmOboKihxpgUNGWNSpvaS6RpKL3Ry//Mh1wgf6PElaCyzq67O09nVjdVlJbSDy8Lw77PmfecMwZg/I/GDw3DCo8HCkZl/RlgGA0e3Yfv7+DbAfLrW+SXOvLTG+SHV/gPbuMZRnsyIDL/OASziMxkkKkUQTJJsLaGn8/iHz6nd+8mQv87Ahg2H9Th/BxZqxEkEgSrq/iVCvLsDK9awtvfxb2zjD2ARID+lVVlbabTgWYTv1rFL5fBUtHbbeTJCb3EQ3ovCnRC6xAgzJtOE+ztheYIEkqbFaS3vY2zuIj77AmtYYDusPy8/zuvunJkDKXM7tYWTiyGWFjAqeQnAD6+7ueNx/FLpRGAru7mcoj5ebqzszil7DggeF/DX1nBN82rzPqrzbRayIsLhJqMPT2N83Sdy2GApwFqRN7jFPL0tF+10cDd3MTZ2AjNUkGCoyO6y9cRxfQowFUbpufr1ct4ZoHg+Dg067zduTmEbq4yi/UkYidDe+kaTcP4ObJIajksPd/eyx3c+N2rvPbMDPbUFPZSLKzcGjKPrbJaDsu+dQO3msfZzeGY2TCvKGYQhdSYeeJjUt21dIcjXQ7U7Kv599f4j/oF55W4g/2e3b8AAAAASUVORK5CYII=');}.annotator-editor input.annotator-editor-tags{font-size:.6em;width:24.8em;padding:0;margin-bottom:.4em;background:rgba(255,255,255,0.8);border:1px solid #ccc;}.annotator-viewer{padding:.2em .4em .4em .4em;}.annotator-viewer .annotator-ann{color:#333;font-family:helvetica;font-size:75%;margin:.25em 0 0 0;}.annotator-viewer .annotator-ann+.annotator-ann{border-top:1px solid #E1BE94;padding-top:.25em;}.annotator-ann .annotator-ann-controls{display:none;float:right;}.annotator-viewer:hover .annotator-ann .annotator-ann-controls{display:block;}.annotator-ann .annotator-ann-controls a{width:16px;height:16px;display:inline-block;text-indent:-9999em;}.annotator-ann .annotator-ann-controls a.edit{background:transparent url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFUSURBVDjLrZM/SAJxGIZdWwuDlnCplkAEm1zkaIiGFFpyMIwGK5KGoK2lphDKkMDg3LLUSIJsSKhIi+684CokOtTiMizCGuzEU5K3vOEgKvtBDe/2Pc8H3x8NAM1fQlx4H9M3pcOWp6TXWmM8A7j0629v1nraiAVC0IrrwATKIgs5xyG5QiE+Z4iQdoeU2oAsnqCSO1NSTu+D9VhqRLD8nIB8F0Q2MgmJDyipCzjvYJkIfpN2UBLG8MpP4dxvQ3ZzGuyyBQ2H+AnOOCBd9aL6soh81A5hyYSGWyCFvxUcerqI4S+CvYVOFPMHxLAq8I3qdHVY5LbBhJzEsCrwutpRFBlUHy6wO2tEYtWAzLELPN2P03kjfj3luqDycV2F8AgefWbEnVqEHa2IznSD6BdsVDNStB0lfh0FPoQjdx8RrAqGzC0YprSgxzsUMOY2bf37N/6Ud1Vc9yYcH50CAAAAAElFTkSuQmCC') no-repeat top left;}.annotator-ann .annotator-ann-controls a.del{background:transparent url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJdSURBVDjLpZP7S1NhGMf9W7YfogSJboSEUVCY8zJ31trcps6zTI9bLGJpjp1hmkGNxVz4Q6ildtXKXzJNbJRaRmrXoeWx8tJOTWptnrNryre5YCYuI3rh+8vL+/m8PA/PkwIg5X+y5mJWrxfOUBXm91QZM6UluUmthntHqplxUml2lciF6wrmdHriI0Wx3xw2hAediLwZRWRkCPzdDswaSvGqkGCfq8VEUsEyPF1O8Qu3O7A09RbRvjuIttsRbT6HHzebsDjcB4/JgFFlNv9MnkmsEszodIIY7Oaut2OJcSF68Qx8dgv8tmqEL1gQaaARtp5A+N4NzB0lMXxon/uxbI8gIYjB9HytGYuusfiPIQcN71kjgnW6VeFOkgh3XcHLvAwMSDPohOADdYQJdF1FtLMZPmslvhZJk2ahkgRvq4HHUoWHRDqTEDDl2mDkfheiDgt8pw340/EocuClCuFvboQzb0cwIZgki4KhzlaE6w0InipbVzBfqoK/qRH94i0rgokSFeO11iBkp8EdV8cfJo0yD75aE2ZNRvSJ0lZKcBXLaUYmQrCzDT6tDN5SyRqYlWeDLZAg0H4JQ+Jt6M3atNLE10VSwQsN4Z6r0CBwqzXesHmV+BeoyAUri8EyMfi2FowXS5dhd7doo2DVII0V5BAjigP89GEVAtda8b2ehodU4rNaAW+dGfzlFkyo89GTlcrHYCLpKD+V7yeeHNzLjkp24Uu1Ed6G8/F8qjqGRzlbl2H2dzjpMg1KdwsHxOlmJ7GTeZC/nesXbeZ6c9OYnuxUc3fmBuFft/Ff8xMd0s65SXIb/gAAAABJRU5ErkJggg==') no-repeat top left;}.annotator-ann .annotator-ann-text p{margin:0;}.annotator-ann .annotator-ann-text p+p{margin:0 0 .25em 0;}.annotator-ann .annotator-ann-user,.annotator-ann .annotator-ann-tags{opacity:.8;font-size:10px;line-height:11px;margin:3px 0 0 0;padding:1px 0 0 12px;background:transparent none no-repeat 0 0;display:block;}.annotator-ann .annotator-ann-user{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABtQTFRFubm50tLS6urq7u7u3d3d////MzMzZmZmAAAArXyMxAAAAAl0Uk5T//////////8AU094EgAAADpJREFUeNpkyzkSACAIBEEOcff/LxYQIyehiwIhiSyHpDRCcWkR9lPN5oAQeW8r6y286Gh2xT3xCDAAhGMCU84LE5UAAAAASUVORK5CYII=');}.annotator-ann .annotator-ann-tags{background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAMAAAC67D+PAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABhQTFRFMzMzAAAA3d3dlpaWZmZm7u7u////AAAAsSRAnQAAAAJ0Uk5T/wDltzBKAAAANElEQVR42jzIwREAIAgDwQsC/ZesgnKf7IR1UoVnpj+aWxsPszbiG43RGLWj32v0WLMFGAA0mQDaAXhvcwAAAABJRU5ErkJggg==');}
View
1 pkg/annotator.min.js
@@ -0,0 +1 @@
+(function(){var i,d,b,n,h,k,f,e,o,a,g;var j=Array.prototype.slice,l=function(p,q){return function(){return p.apply(q,arguments)}},m=Object.prototype.hasOwnProperty,c=function(s,q){for(var p in q){if(m.call(q,p)){s[p]=q[p]}}function r(){this.constructor=s}r.prototype=q.prototype;s.prototype=new r;s.__super__=q.prototype;return s};h=["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(p){return console.log("GROUP: ",p)}}if(!(console.groupCollapsed!=null)){console.groupCollapsed=console.group}for(f=0,o=h.length;f<o;f++){n=h[f];if(!(console[n]!=null)){console[n]=function(){return console.log("Not implemented: console."+name)}}}}else{this.console={};for(e=0,a=h.length;e<a;e++){n=h[e];this.console[n]=function(){}}this.console.error=function(){var p;p=1<=arguments.length?j.call(arguments,0):[];return alert("ERROR: "+(p.join(", ")))};this.console.warn=function(){var p;p=1<=arguments.length?j.call(arguments,0):[];return alert("WARNING: "+(p.join(", ")))}}if(!(typeof jQuery!="undefined"&&jQuery!==null?(g=jQuery.fn)!=null?g.jquery:void 0:void 0)){console.error("Annotator requires jQuery: have you included lib/vendor/jquery.js?")}if(!(JSON&&JSON.parse&&JSON.stringify)){console.error("Annotator requires a JSON implementation: have you included lib/vendor/json2.js?")}i=jQuery;b=(function(){p.prototype.events={};function p(r,q){this.options=i.extend(this.options,q);this.element=r}p.prototype.addEvents=function(){var s,w,v,q,u,t,x,r;t=this.events;r=[];for(v in t){w=t[v];x=v.split(" "),q=2<=x.length?j.call(x,0,u=x.length-1):(u=0,[]),s=x[u++];r.push(this.addEvent(q.join(" "),s,w))}return r};p.prototype.addEvent=function(q,s,t){var u,r;u=l(function(){return this[t].apply(this,arguments)},this);r=typeof q==="string"&&q.replace(/\s+/g,"")==="";if(r){q=this.element}if(typeof q==="string"){return i(this.element).delegate(q,s,u)}else{return i(q).bind(s,u)}};return p})();this.Delegator=b;i.plugin=function(q,p){return i.fn[q]=function(s){var r;r=Array.prototype.slice.call(arguments,1);return this.each(function(){var t;t=i.data(this,q);if(t){return s&&t[s].apply(t,r)}else{t=new p(this,s);return i.data(this,q,t)}})}};i=jQuery;Array.prototype.flatten=function(){var p;p=function(r){var s,u,t,q;u=[];for(t=0,q=r.length;t<q;t++){s=r[t];u=u.concat(s&&i.isArray(s)?p(s):s)}return u};return p(this)};i.fn.textNodes=function(){var p;p=function(s){var v,u,r,t,q;if(s&&s.nodeType!==3){t=i(s).contents().get();q=[];for(u=0,r=t.length;u<r;u++){v=t[u];q.push(p(v))}return q}else{return s}};return this.map(function(){return p(this).flatten()})};i.fn.xpath=function(p){var q;q=this.map(function(){var s,r,t;t="";s=this;while(s&&s.nodeType===1&&s!==p){r=i(s.parentNode).children(s.tagName).index(s)+1;r=r>1?"["+r+"]":"";t="/"+s.tagName.toLowerCase()+r+t;s=s.parentNode}return t});return q.get()};i=jQuery;this.Range={};Range.sniff=function(p){if(p.commonAncestorContainer!=null){return new Range.BrowserRange(p)}else{if(p.start&&typeof p.start==="string"){return new Range.SerializedRange(p)}else{if(p.start&&typeof p.start==="object"){return new Range.NormalizedRange(p)}else{console.error("Couldn't not sniff range type");return false}}}};Range.BrowserRange=(function(){function p(q){this.commonAncestorContainer=q.commonAncestorContainer;this.startContainer=q.startContainer;this.startOffset=q.startOffset;this.endContainer=q.endContainer;this.endOffset=q.endOffset}p.prototype.normalize=function(y){var x,t,A,u,s,q,v,z,w;if(this.tainted){console.error("You may only call normalize() once on a BrowserRange!");return false}else{this.tainted=true}q={};A={};w=["start","end"];for(v=0,z=w.length;v<z;v++){s=w[v];t=this[s+"Container"];u=this[s+"Offset"];if(t.nodeType===1){x=t.childNodes[u];t=x||t.childNodes[u-1];while(t.nodeType!==3){t=t.firstChild}u=x?0:t.nodeValue.length}q[s]=t;q[s+"Offset"]=u}A.start=q.startOffset>0?q.start.splitText(q.startOffset):q.start;if(q.start===q.end){if((q.endOffset-q.startOffset)<A.start.nodeValue.length){A.start.splitText(q.endOffset-q.startOffset)}A.end=A.start}else{if(q.endOffset<q.end.nodeValue.length){q.end.splitText(q.endOffset)}A.end=q.end}A.commonAncestor=this.commonAncestorContainer;while(A.commonAncestor.nodeType!==1){A.commonAncestor=A.commonAncestor.parentNode}return new Range.NormalizedRange(A)};p.prototype.serialize=function(q,r){return this.normalize(q).serialize(q,r)};return p})();Range.NormalizedRange=(function(){function p(q){this.commonAncestor=q.commonAncestor;this.start=q.start;this.end=q.end}p.prototype.normalize=function(q){return this};p.prototype.serialize=function(s,t){var r,q,u;q=function(y,x){var w,v,A,E,C,B,z,D;if(t){E=i(y).parents(":not("+t+")").eq(0)}else{E=i(y).parent()}B=E.xpath(s)[0];C=E.textNodes();v=C.slice(0,C.index(y));A=0;for(z=0,D=v.length;z<D;z++){w=v[z];A+=w.nodeValue.length}if(x){return[B,A+y.nodeValue.length]}else{return[B,A]}};u=q(this.start);r=q(this.end,true);return new Range.SerializedRange({start:u[0],end:r[0],startOffset:u[1],endOffset:r[1]})};return p})();Range.SerializedRange=(function(){function p(q){this.start=q.start;this.startOffset=q.startOffset;this.end=q.end;this.endOffset=q.endOffset}p.prototype.normalize=function(D){var G,z,x,F,v,B,C,E,A,w,u,s,q,H,I,y,t,r;B=function(J){return document.evaluate(J,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue};E=i(D).xpath()[0];w=this.start.split("/");x=this.end.split("/");z=[];A={};for(F=0,y=w.length;(0<=y?F<y:F>y);(0<=y?F+=1:F-=1)){if(w[F]===x[F]){z.push(w[F])}else{break}}G=E+z.join("/");A.commonAncestorContainer=B(G);if(!A.commonAncestorContainer){console.error("Error deserializing range: can't find XPath '"+G+"'. Is this the right document?")}t=["start","end"];for(s=0,H=t.length;s<H;s++){C=t[s];v=0;r=i(B(E+this[C])).textNodes();for(q=0,I=r.length;q<I;q++){u=r[q];if(v+u.nodeValue.length>=this[C+"Offset"]){A[C+"Container"]=u;A[C+"Offset"]=this[C+"Offset"]-v;break}else{v+=u.nodeValue.length}}}return new Range.BrowserRange(A).normalize(D)};p.prototype.serialize=function(q,r){return this.normalize(q).serialize(q,r)};p.prototype.toObject=function(){return{start:this.start,startOffset:this.startOffset,end:this.end,endOffset:this.endOffset}};return p})();i=jQuery;if(!(JSON&&JSON.parse&&JSON.stringify)){console.error("Annotator requires JSON support: have you included lib/vendor/json2.js?")}k={getGlobal:function(){return(function(){return this})()},mousePosition:function(p,r){var q;q=i(r).offset();return{top:p.pageY-q.top,left:p.pageX-q.left}}};d=(function(){c(p,b);p.prototype.events={".annotator-adder mousedown":"adderMousedown",".annotator-hl mouseover":"highlightMouseover",".annotator-hl mouseout":"startViewerHideTimer",".annotator-viewer mouseover":"clearViewerHideTimer",".annotator-viewer mouseout":"startViewerHideTimer",".annotator-editor textarea keydown":"processEditorKeypress",".annotator-editor form submit":"submitEditor",".annotator-editor button.annotator-editor-save click":"submitEditor",".annotator-editor button.annotator-editor-cancel click":"hideEditor",".annotator-ann-controls .edit click":"controlEditClick",".annotator-ann-controls .del click":"controlDeleteClick",mouseup:"checkForEndSelection",mousedown:"checkForStartSelection"};p.prototype.dom={adder:"<div class='annotator-adder'><a href='#'></a></div>",editor:"<div class='annotator-editor'>\n <form>\n <textarea></textarea>\n <div class='annotator-editor-controls'>\n <button type='submit' class='annotator-editor-save'>Save</button>\n <button type='submit' class='annotator-editor-cancel'>Cancel</button>\n </div>\n <form>\n</div>",hl:"<span class='annotator-hl'></span>",viewer:"<div class='annotator-viewer'></div>"};p.prototype.options={};function p(s,r){this.controlDeleteClick=l(this.controlDeleteClick,this);this.controlEditClick=l(this.controlEditClick,this);this.adderMousedown=l(this.adderMousedown,this);this.highlightMouseover=l(this.highlightMouseover,this);this.clearViewerHideTimer=l(this.clearViewerHideTimer,this);this.startViewerHideTimer=l(this.startViewerHideTimer,this);this.showViewer=l(this.showViewer,this);this.submitEditor=l(this.submitEditor,this);this.processEditorKeypress=l(this.processEditorKeypress,this);this.hideEditor=l(this.hideEditor,this);this.showEditor=l(this.showEditor,this);this.checkForEndSelection=l(this.checkForEndSelection,this);this.checkForStartSelection=l(this.checkForStartSelection,this);var q,u,t;p.__super__.constructor.apply(this,arguments);this.plugins={};this.wrapper=i("<div></div>").addClass("annotator-wrapper");i(this.element).wrapInner(this.wrapper);this.wrapper=i(this.element).contents().get(0);t=this.dom;for(q in t){u=t[q];this.dom[q]=i(u).hide().appendTo(this.wrapper)}this.addEvents()}p.prototype.checkForStartSelection=function(q){this.startViewerHideTimer();return this.mouseIsDown=true};p.prototype.checkForEndSelection=function(t){var r,q;this.mouseIsDown=false;if(this.ignoreMouseup){return}this.getSelection();r=this.selection;q=(r!=null?r.rangeCount:void 0)>0&&!r.isCollapsed;if(t&&q){return this.dom.adder.css(k.mousePosition(t,this.wrapper)).show()}else{return this.dom.adder.hide()}};p.prototype.getSelection=function(){var q;this.selection=k.getGlobal().getSelection();return this.selectedRanges=(function(){var s,r;r=[];for(q=0,s=this.selection.rangeCount;(0<=s?q<s:q>s);(0<=s?q+=1:q-=1)){r.push(this.selection.getRangeAt(q))}return r}).call(this)};p.prototype.createAnnotation=function(q,u){var s,t,w,x,v;if(u==null){u=true}s=q;s||(s={});s.ranges||(s.ranges=this.selectedRanges);s.highlights||(s.highlights=[]);s.ranges=(function(){var A,y,z,r;z=s.ranges;r=[];for(A=0,y=z.length;A<y;A++){w=z[A];v=Range.sniff(w);t=v.normalize(this.wrapper);r.push(x=t.serialize(this.wrapper,".annotator-hl"))}return r}).call(this);s.highlights=this.highlightRange(t);i(s.highlights).data("annotation",s);if(u){i(this.element).trigger("beforeAnnotationCreated",[s]);i(this.element).trigger("annotationCreated",[s])}return s};p.prototype.deleteAnnotation=function(q){var s,u,r,t;t=q.highlights;for(u=0,r=t.length;u<r;u++){s=t[u];i(s).replaceWith(i(s)[0].childNodes)}return i(this.element).trigger("annotationDeleted",[q])};p.prototype.updateAnnotation=function(q,r){i.extend(q,r);i(this.element).trigger("beforeAnnotationUpdated",[q]);return i(this.element).trigger("annotationUpdated",[q])};p.prototype.loadAnnotations=function(s){var q,r;r=[];q=l(function(v){var x,u,w,t;u=v.splice(0,10);for(w=0,t=u.length;w<t;w++){x=u[w];r.push(this.createAnnotation(x,false))}if(v.length>0){return setTimeout((function(){return q(v)}),100)}},this);return q(s)};p.prototype.dumpAnnotations=function(){if(this.plugins.Store){return this.plugins.Store.dumpAnnotations()}else{return console.warn("Can't dump annotations without Store plugin.")}};p.prototype.highlightRange=function(s){var q,r,u,x,t,w,v;t=i(s.commonAncestor).textNodes();v=[t.index(s.start),t.index(s.end)],x=v[0],r=v[1];t=t.slice(x,(r+1)||9000000000);return q=(function(){var A,z,y;y=[];for(A=0,z=t.length;A<z;A++){u=t[A];w=this.dom.hl.clone().show();y.push(i(u).wrap(w).parent().get(0))}return y}).call(this)};p.prototype.addPlugin=function(s,r){var q,t;if(this.plugins[s]){console.error("You cannot have more than one instance of any plugin.")}else{q=p.Plugins[s];if(typeof q==="function"){this.plugins[s]=new q(this.element,r);this.plugins[s].annotator=this;if(typeof(t=this.plugins[s]).pluginInit==="function"){t.pluginInit()}}else{console.error("Could not load "+s+" plugin. Have you included the appropriate <script> tag?")}}return this};p.prototype.showEditor=function(r,q){if(q){this.dom.editor.data("annotation",q);this.dom.editor.find("textarea").val(q.text)}this.dom.editor.css(k.mousePosition(r,this.wrapper)).show().find("textarea").focus();return i(this.element).trigger("annotationEditorShown",[this.dom.editor,q])};p.prototype.hideEditor=function(q){if(q!=null){q.preventDefault()}this.dom.editor.data("annotation",null).hide().find("textarea").val("");i(this.element).trigger("annotationEditorHidden",[this.dom.editor]);return this.ignoreMouseup=false};p.prototype.processEditorKeypress=function(q){if(q.keyCode===27){return this.hideEditor(q)}else{if(q.keyCode===13&&!q.shiftKey){return this.submitEditor(q)}}};p.prototype.submitEditor=function(t){var q,s,r;if(t!=null){t.preventDefault()}r=this.dom.editor.find("textarea");q=this.dom.editor.data("annotation");if(!q){s=true;q={}}i(this.element).trigger("annotationEditorSubmit",[this.dom.editor,q]);if(s){q.text=r.val();this.createAnnotation(q)}else{this.updateAnnotation(q,{text:r.val()})}return this.hideEditor()};p.prototype.showViewer=function(v,u){var s,r,w,t,q;r='<span class="annotator-ann-controls">\n <a href="#" class="edit" alt="Edit" title="Edit this annotation">Edit</a>\n <a href="#" class="del" alt="X" title="Delete this annotation">Delete</a>\n</span>';w=this.dom.viewer.clone().empty();for(t=0,q=u.length;t<q;t++){s=u[t];i("<div class='annotator-ann'>\n "+r+"\n <div class='annotator-ann-text'>\n <p>"+s.text+"</p>\n </div>\n</div>").appendTo(w).data("annotation",s)}w.css(k.mousePosition(v,this.wrapper)).replaceAll(this.dom.viewer).show();i(this.element).trigger("annotationViewerShown",[w.get(0),u]);return this.dom.viewer=w};p.prototype.startViewerHideTimer=function(q){if(!this.viewerHideTimer){return this.viewerHideTimer=setTimeout((function(r){return r.dom.viewer.hide()}),250,this)}};p.prototype.clearViewerHideTimer=function(){clearTimeout(this.viewerHideTimer);return this.viewerHideTimer=false};p.prototype.highlightMouseover=function(r){var q;this.clearViewerHideTimer();if(this.mouseIsDown){return false}q=i(r.target).parents(".annotator-hl").andSelf().map(function(){return i(this).data("annotation")});return this.showViewer(r,q)};p.prototype.adderMousedown=function(q){if(q!=null){q.preventDefault()}this.ignoreMouseup=true;this.dom.adder.hide();return this.showEditor(q)};p.prototype.controlEditClick=function(r){var q,s,t;q=i(r.target).parents(".annotator-ann");s=i(this.dom.viewer).offset();t={pageY:s.top,pageX:s.left};this.dom.viewer.hide();this.showEditor(t,q.data("annotation"));return false};p.prototype.controlDeleteClick=function(r){var q;q=i(r.target).parents(".annotator-ann");this.deleteAnnotation(q.data("annotation"));q.remove();if(!this.dom.viewer.is(":parent")){this.dom.viewer.hide()}return false};return p})();d.Plugins={};i.plugin("annotator",d);this.Annotator=d}).call(this);
View
1 pkg/annotator.store.min.js
@@ -0,0 +1 @@
+(function(){var e;var b=Object.prototype.hasOwnProperty,d=function(i,g){for(var f in g){if(b.call(g,f)){i[f]=g[f]}}function h(){this.constructor=i}h.prototype=g.prototype;i.prototype=new h;i.__super__=g.prototype;return i},a=function(f,g){return function(){return f.apply(g,arguments)}},c=Array.prototype.indexOf||function(h){for(var g=0,f=this.length;g<f;g++){if(this[g]===h){return g}}return -1};e=jQuery;Annotator.Plugins.Store=(function(){d(f,Delegator);f.prototype.events={annotationCreated:"annotationCreated",annotationDeleted:"annotationDeleted",annotationUpdated:"annotationUpdated"};f.prototype.options={prefix:"/store",autoFetch:true,annotationData:{},loadFromSearch:false,urls:{create:"/annotations",read:"/annotations/:id",update:"/annotations/:id",destroy:"/annotations/:id",search:"/search"}};function f(h,g){f.__super__.constructor.apply(this,arguments);this.addEvents();this.annotations=[]}f.prototype.pluginInit=function(){var g,h;h=a(function(){if(this.options.loadFromSearch){return this.loadAnnotationsFromSearch(this.options.loadFromSearch)}else{return this.loadAnnotations()}},this);g=e(this.element).data("annotator:auth");if(g){return g.withToken(h)}else{return h()}};f.prototype.annotationCreated=function(h,g){if(c.call(this.annotations,g)<0){this.registerAnnotation(g);return this._apiRequest("create",g,a(function(i){if(!(i.id!=null)){console.warn("Warning: No ID returned from server for annotation ",g)}return this.updateAnnotation(g,i)},this))}else{return this.updateAnnotation(g,{})}};f.prototype.annotationDeleted=function(h,g){if(c.call(this.annotations,g)>=0){return this._apiRequest("destroy",g,(a(function(){return this.unregisterAnnotation(g)},this)))}};f.prototype.annotationUpdated=function(h,g){if(c.call(this.annotations,g)>=0){return this._apiRequest("update",g,(a(function(){return this.updateAnnotation(g)},this)))}};f.prototype.registerAnnotation=function(g){return this.annotations.push(g)};f.prototype.unregisterAnnotation=function(g){return this.annotations.splice(this.annotations.indexOf(g),1)};f.prototype.updateAnnotation=function(g,h){if(c.call(this.annotations,g)<0){console.error("Trying to update unregistered annotation!")}else{e.extend(g,h)}return e(g.highlights).data("annotation",g)};f.prototype.loadAnnotations=function(){return this._apiRequest("read",null,a(function(g){this.annotations=g.slice();return this.annotator.loadAnnotations(g)},this))};f.prototype.loadAnnotationsFromSearch=function(g){return this._apiRequest("search",g,a(function(h){this.annotations=h.results.slice();return this.annotator.loadAnnotations(h.results)},this))};f.prototype.dumpAnnotations=function(){var k,j,h,i,g;i=this.annotations;g=[];for(j=0,h=i.length;j<h;j++){k=i[j];g.push(JSON.parse(this._dataFor(k)))}return g};f.prototype._apiRequest=function(i,j,l){var k,h,g;k=a(function(q){var p,n,o,m;p=e(this.element).data("annotator:headers");if(p){m=[];for(n in p){o=p[n];m.push(q.setRequestHeader(n,o))}return m}},this);h=function(o,m,n){return console.error("API request failed: '"+m+"'",o)};g={url:this._urlFor(i,j&&j.id),type:this._methodFor(i),beforeSend:k,dataType:"json",success:l||function(){},error:h};if(i==="search"){g=e.extend(g,{data:j})}else{g=e.extend(g,{data:j&&this._dataFor(j),contentType:"application/json; charset=utf-8"})}return e.ajax(g)};f.prototype._urlFor=function(i,j){var g,h;g=j!=null?"/"+j:"";h=this.options.prefix||"/";h+=this.options.urls[i];h=h.replace(/\/:id/,g);return h};f.prototype._methodFor=function(h){var g;g={create:"POST",read:"GET",update:"PUT",destroy:"DELETE",search:"GET"};return g[h]};f.prototype._dataFor=function(g){var h,i;i=g.highlights;delete g.highlights;e.extend(g,this.options.annotationData);h=JSON.stringify(g);g.highlights=i;return h};return f})()}).call(this);
View
1 pkg/annotator.tags.min.js
@@ -0,0 +1 @@
+(function(){var d;var b=function(e,f){return function(){return e.apply(f,arguments)}},a=Object.prototype.hasOwnProperty,c=function(h,f){for(var e in f){if(a.call(f,e)){h[e]=f[e]}}function g(){this.constructor=h}g.prototype=f.prototype;h.prototype=new g;h.__super__=f.prototype;return h};d=jQuery;Annotator.Plugins.Tags=(function(){c(e,Delegator);e.prototype.events={annotationViewerShown:"updateViewer",annotationEditorShown:"updateEditor",annotationEditorHidden:"clearEditor",annotationEditorSubmit:"setAnnotationTags"};function e(g,f){this.setAnnotationTags=b(this.setAnnotationTags,this);this.clearEditor=b(this.clearEditor,this);this.updateEditor=b(this.updateEditor,this);e.__super__.constructor.apply(this,arguments);this.addEvents();this.tagSrc="<input type='text' class='annotator-editor-tags' placeholder='tags&hellip;'>"}e.prototype.updateEditor=function(h,i,f){var g;if(!this.tags){g=d(i).find(".annotator-editor-controls");this.tags=d(this.tagSrc).insertBefore(g).get(0)}if((f!=null?f.tags:void 0)!=null){return d(this.tags).val(this.stringifyTags(f.tags))}};e.prototype.clearEditor=function(f,g){if(this.tags){return d(this.tags).val("")}};e.prototype.setAnnotationTags=function(g,h,f){if(this.tags){return f.tags=this.parseTags(d(this.tags).val())}};e.prototype.parseTags=function(f){return f.split(/\s+/)};e.prototype.stringifyTags=function(f){return f.join(" ")};e.prototype.updateViewer=function(m,n,k){var l,g,j,o,p,h,f;g=d(n).find(".annotator-ann");f=[];for(j=0,h=g.length;(0<=h?j<h:j>h);(0<=h?j+=1:j-=1)){p=k[j].tags;o=p!=null?p.join(", "):void 0;l=g.eq(j).find(".annotator-ann-text");f.push(o&&o!==""?d("<div class='annotator-ann-tags'>"+(p.join(", "))+"</div>").insertAfter(l):void 0)}return f};return e})()}).call(this);
View
1 pkg/annotator.user.min.js
@@ -0,0 +1 @@
+(function(){var e;var b=function(f,g){return function(){return f.apply(g,arguments)}},a=Object.prototype.hasOwnProperty,d=function(i,g){for(var f in g){if(a.call(g,f)){i[f]=g[f]}}function h(){this.constructor=i}h.prototype=g.prototype;i.prototype=new h;i.__super__=g.prototype;return i},c=Array.prototype.indexOf||function(h){for(var g=0,f=this.length;g<f;g++){if(this[g]===h){return g}}return -1};e=jQuery;Annotator.Plugins.User=(function(){d(f,Delegator);f.prototype.events={beforeAnnotationCreated:"addUserToAnnotation",annotationViewerShown:"updateViewer"};f.prototype.options={userId:function(g){return g},userString:function(g){return g},userGroups:function(g){return["public"]}};function f(h,g){this.updateViewer=b(this.updateViewer,this);this.addUserToAnnotation=b(this.addUserToAnnotation,this);f.__super__.constructor.apply(this,arguments);this.addEvents()}f.prototype.setUser=function(g){return this.user=g};f.prototype.addUserToAnnotation=function(h,g){if(this.user&&g){return g.user=this.user}};f.prototype.authorise=function(l,k){var o,i,h,r,m,q,n,j;if(h=k.permissions){if(!l||!h[l]){return true}else{if(n="user:"+(this.options.userId(this.user)),c.call(h[l],n)>=0){return true}else{if(i=this.options.userGroups(this.user)){for(m=0,q=i.length;m<q;m++){o=i[m];if(j="group:"+o,c.call(h[l],j)>=0){return true}}return false}}}}else{if(r=k.user){if(this.user&&this.options.userId(this.user)===r){return true}else{return false}}else{return true}}};f.prototype.updateViewer=function(o,s,l){var p,q,m,n,h,k,r,j,g;h=e(s).find(".annotator-ann");g=[];for(k=0,j=h.length;(0<=j?k<j:k>j);(0<=j?k+=1:k-=1)){p=h.eq(k).find(".annotator-ann-controls");m=h.eq(k).find(".annotator-ann-text");if(r=l[k].user){e("<div class='annotator-ann-user'>"+(this.options.userString(r))+"</div>").insertAfter(m)}g.push("permissions" in l[k]?(p.show(),n=p.find(".edit"),q=p.find(".delete"),this.authorise("update",l[k])?n.show():n.hide(),this.authorise("delete",l[k])?q.show():q.hide()):"user" in l[k]?this.authorise(null,l[k])?p.children().andSelf().show():p.hide():p.children().andSelf().show())}return g};return f})()}).call(this);

0 comments on commit 66cdb88

Please sign in to comment.
Something went wrong with that request. Please try again.