diff --git a/dist/1.2.0/css/ng-annotate-1.2.0.css b/dist/1.2.0/css/ng-annotate-1.2.0.css
new file mode 100644
index 0000000..4180f62
--- /dev/null
+++ b/dist/1.2.0/css/ng-annotate-1.2.0.css
@@ -0,0 +1,81 @@
+.text-center {
+ text-align: center; }
+
+.ng-annotation {
+ border-bottom: 1px solid #000;
+ cursor: pointer; }
+ .ng-annotation.red {
+ color: #000;
+ background: #fcbcbc;
+ border-color: #fcbcbc; }
+ .ng-annotation.green {
+ color: #000;
+ background: #c7fcbc;
+ border-color: #c7fcbc; }
+ .ng-annotation.blue {
+ color: #000;
+ background: #BCDFFC;
+ border-color: #BCDFFC; }
+ .ng-annotation.pink {
+ color: #000;
+ background: #fcbcfa;
+ border-color: #fcbcfa; }
+ .ng-annotation.yellow {
+ color: #000;
+ background: #fafcbc;
+ border-color: #fafcbc; }
+ .ng-annotation.teal {
+ color: #000;
+ background: #bcfcf7;
+ border-color: #bcfcf7; }
+ .ng-annotation.strike {
+ text-decoration: line-through; }
+
+.ng-annotation-popup {
+ width: 300px;
+ position: absolute;
+ z-index: 1000;
+ background: #fff;
+ box-shadow: 0 0 10px #777;
+ display: none;
+ padding: 10px; }
+
+.ng-annotation-popup label {
+ display: block; }
+
+.ng-annotation-popup:after {
+ content: "";
+ width: 10px;
+ height: 10px;
+ position: absolute;
+ background: #fff;
+ -webkit-transform: rotate(45deg);
+ right: -6px;
+ top: 50%;
+ margin-top: -5px;
+ z-index: 990;
+ border-top: 1px solid #ccc;
+ border-right: 1px solid #ccc; }
+
+.ng-annotation-tooltip {
+ width: 300px;
+ position: absolute;
+ z-index: 1000;
+ background: #fff;
+ box-shadow: 0 0 10px #777;
+ display: none;
+ padding: 10px; }
+
+.ng-annotation-tooltip:after {
+ content: "";
+ width: 10px;
+ height: 10px;
+ position: absolute;
+ background: #fff;
+ -webkit-transform: rotate(45deg);
+ right: -6px;
+ top: 50%;
+ margin-top: -5px;
+ z-index: 990;
+ border-top: 1px solid #ccc;
+ border-right: 1px solid #ccc; }
diff --git a/dist/1.2.0/css/ng-annotate-1.2.0.min.css b/dist/1.2.0/css/ng-annotate-1.2.0.min.css
new file mode 100644
index 0000000..f367b43
--- /dev/null
+++ b/dist/1.2.0/css/ng-annotate-1.2.0.min.css
@@ -0,0 +1 @@
+.text-center{text-align:center}.ng-annotation{border-bottom:1px solid #000;cursor:pointer}.ng-annotation.red{color:#000;background:#fcbcbc;border-color:#fcbcbc}.ng-annotation.green{color:#000;background:#c7fcbc;border-color:#c7fcbc}.ng-annotation.blue{color:#000;background:#BCDFFC;border-color:#BCDFFC}.ng-annotation.pink{color:#000;background:#fcbcfa;border-color:#fcbcfa}.ng-annotation.yellow{color:#000;background:#fafcbc;border-color:#fafcbc}.ng-annotation.teal{color:#000;background:#bcfcf7;border-color:#bcfcf7}.ng-annotation.strike{text-decoration:line-through}.ng-annotation-popup{width:300px;position:absolute;z-index:1000;background:#fff;box-shadow:0 0 10px #777;display:none;padding:10px}.ng-annotation-popup label{display:block}.ng-annotation-popup:after{content:"";width:10px;height:10px;position:absolute;background:#fff;-webkit-transform:rotate(45deg);right:-6px;top:50%;margin-top:-5px;z-index:990;border-top:1px solid #ccc;border-right:1px solid #ccc}.ng-annotation-tooltip{width:300px;position:absolute;z-index:1000;background:#fff;box-shadow:0 0 10px #777;display:none;padding:10px}.ng-annotation-tooltip:after{content:"";width:10px;height:10px;position:absolute;background:#fff;-webkit-transform:rotate(45deg);right:-6px;top:50%;margin-top:-5px;z-index:990;border-top:1px solid #ccc;border-right:1px solid #ccc}
\ No newline at end of file
diff --git a/dist/1.2.0/js/ng-annotate-1.2.0.js b/dist/1.2.0/js/ng-annotate-1.2.0.js
new file mode 100644
index 0000000..0a58370
--- /dev/null
+++ b/dist/1.2.0/js/ng-annotate-1.2.0.js
@@ -0,0 +1,489 @@
+(function() {
+ var getAnnotationById, insertAt, ngAnnotate, parseAnnotations, sortAnnotationsByEndIndex;
+
+ ngAnnotate = angular.module("ngAnnotate", []);
+
+ insertAt = function(text, index, string) {
+ return text.substr(0, index) + string + text.substr(index);
+ };
+
+ sortAnnotationsByEndIndex = function(annotations) {
+ return annotations.sort(function(a, b) {
+ if (a.endIndex < b.endIndex) {
+ return -1;
+ } else if (a.endIndex > b.endIndex) {
+ return 1;
+ }
+ return 0;
+ });
+ };
+
+ parseAnnotations = function(text, annotations, indexOffset) {
+ var annotation, i, _i, _ref;
+ if (annotations == null) {
+ annotations = [];
+ }
+ if (indexOffset == null) {
+ indexOffset = 0;
+ }
+ if (annotations.length === 0) {
+ return text;
+ }
+ annotations = sortAnnotationsByEndIndex(annotations);
+ for (i = _i = _ref = annotations.length - 1; _i >= 0; i = _i += -1) {
+ annotation = annotations[i];
+ text = insertAt(text, annotation.endIndex + indexOffset, "");
+ if (annotation.children.length) {
+ text = parseAnnotations(text, annotation.children, annotation.startIndex + indexOffset);
+ }
+ text = insertAt(text, annotation.startIndex + indexOffset, "");
+ }
+ return text;
+ };
+
+ getAnnotationById = function(annotations, aId) {
+ var a, an, _i, _len;
+ for (_i = 0, _len = annotations.length; _i < _len; _i++) {
+ a = annotations[_i];
+ if (aId === a.id) {
+ return a;
+ }
+ if (a.children.length > 0) {
+ an = getAnnotationById(a.children, aId);
+ if (an !== void 0) {
+ return an;
+ }
+ }
+ }
+ };
+
+ ngAnnotate.factory("NGAnnotatePopup", function() {
+ var NGAnnotatePopup;
+ NGAnnotatePopup = function(scope) {
+ return angular.extend(this, {
+ scope: scope,
+ $el: angular.element(""),
+ $anchor: null,
+ show: function(cb, speed) {
+ if (cb == null) {
+ cb = angular.noop;
+ }
+ if (speed == null) {
+ speed = "fast";
+ }
+ return this.$el.fadeIn(speed, cb);
+ },
+ hide: function(cb, speed) {
+ if (cb == null) {
+ cb = angular.noop;
+ }
+ if (speed == null) {
+ speed = "fast";
+ }
+ return this.$el.fadeOut(speed, cb);
+ },
+ isVisible: function() {
+ return this.$el.is(":visible");
+ },
+ positionTop: function() {
+ var anchorHeight, anchorOffsetTop, popupHeight;
+ if (this.$anchor == null) {
+ throw new Error("NG_ANNOTATE_NO_ANCHOR");
+ }
+ anchorOffsetTop = this.$anchor.offset().top;
+ anchorHeight = this.$anchor.innerHeight();
+ popupHeight = this.$el.innerHeight();
+ return this.$el.css({
+ top: anchorOffsetTop + (anchorHeight / 2) - (popupHeight / 2)
+ });
+ },
+ positionLeft: function(value) {
+ return this.$el.css({
+ left: value
+ });
+ },
+ destroy: function() {
+ var $el;
+ scope = this.scope;
+ $el = this.$el;
+ return this.hide(function() {
+ scope.$destroy();
+ return $el.remove();
+ });
+ }
+ });
+ };
+ return NGAnnotatePopup;
+ });
+
+ ngAnnotate.factory("NGAnnotateTooltip", function() {
+ var NGAnnotateTooltip;
+ return NGAnnotateTooltip = function(scope) {
+ return angular.extend(this, {
+ scope: scope,
+ $el: angular.element(""),
+ $anchor: null,
+ show: function(cb, speed) {
+ if (cb == null) {
+ cb = angular.noop;
+ }
+ if (speed == null) {
+ speed = "fast";
+ }
+ return this.$el.fadeIn(speed, cb);
+ },
+ hide: function(cb, speed) {
+ if (cb == null) {
+ cb = angular.noop;
+ }
+ if (speed == null) {
+ speed = "fast";
+ }
+ return this.$el.fadeOut(speed, cb);
+ },
+ isVisible: function() {
+ return this.$el.is(":visible");
+ },
+ positionTop: function() {
+ var anchorHeight, anchorOffsetTop, tooltipHeight;
+ if (this.$anchor == null) {
+ throw new Error("NG_ANNOTATE_NO_ANCHOR");
+ }
+ anchorOffsetTop = this.$anchor.offset().top;
+ anchorHeight = this.$anchor.innerHeight();
+ tooltipHeight = this.$el.innerHeight();
+ return this.$el.css({
+ top: anchorOffsetTop + (anchorHeight / 2) - (tooltipHeight / 2)
+ });
+ },
+ positionLeft: function(value) {
+ return this.$el.css({
+ left: value
+ });
+ },
+ destroy: function() {
+ var $el;
+ scope = this.scope;
+ $el = this.$el;
+ return this.hide(function() {
+ scope.$destroy();
+ return $el.remove();
+ });
+ }
+ });
+ };
+ });
+
+ ngAnnotate.factory("NGAnnotation", function() {
+ var Annotation;
+ Annotation = function(data) {
+ angular.extend(this, {
+ id: new Date().getTime(),
+ startIndex: null,
+ endIndex: null,
+ data: {},
+ type: "",
+ children: []
+ });
+ if (data != null) {
+ return angular.extend(this, data);
+ }
+ };
+ return Annotation;
+ });
+
+ ngAnnotate.directive("ngAnnotate", function($rootScope, $compile, $http, $q, NGAnnotation, NGAnnotatePopup, NGAnnotateTooltip) {
+ return {
+ restrict: "A",
+ scope: {
+ text: "=",
+ annotations: "=",
+ options: "=",
+ onAnnotate: "=",
+ onAnnotateDelete: "=",
+ onAnnotateError: "="
+ },
+ compile: function(tElement, tAttrs, transclude) {
+ return function($scope, element, attrs) {
+ var activePopups, activeTooltips, clearPopups, clearTooltips, createAnnotation, getPopupTemplate, getTooltipTemplate, onAnnotationsChange, onClick, onMouseEnter, onMouseLeave, onSelect, options, popupTemplateData, removeAnnotation, removeChildren, tooltipTemplateData;
+ activePopups = [];
+ activeTooltips = [];
+ popupTemplateData = "";
+ tooltipTemplateData = "";
+ onAnnotationsChange = function() {
+ var t;
+ if (($scope.text == null) || !$scope.text.length) {
+ return;
+ }
+ t = parseAnnotations($scope.text, $scope.annotations);
+ return tElement.html(t);
+ };
+ $scope.$watch("text", onAnnotationsChange);
+ $scope.$watch("annotations", onAnnotationsChange, true);
+ options = {
+ popupTemplateUrl: "",
+ tooltipTemplateUrl: ""
+ };
+ options = angular.extend(options, $scope.options);
+ clearPopups = function() {
+ var p, _i, _len;
+ for (_i = 0, _len = activePopups.length; _i < _len; _i++) {
+ p = activePopups[_i];
+ p.destroy();
+ }
+ return activePopups = [];
+ };
+ clearTooltips = function() {
+ var i, _i, _ref, _results;
+ _results = [];
+ for (i = _i = _ref = activeTooltips.length - 1; _i >= 0; i = _i += -1) {
+ activeTooltips[i].destroy();
+ _results.push(activeTooltips.splice(i, 1));
+ }
+ return _results;
+ };
+ $scope.$on("$destroy", function() {
+ clearPopups();
+ return clearTooltips();
+ });
+ getPopupTemplate = function(url) {
+ var deferred;
+ if (popupTemplateData.length) {
+ deferred = $q.defer();
+ deferred.resolve(popupTemplateData);
+ return deferred.promise;
+ }
+ return $http.get(url).then(function(response) {
+ popupTemplateData = response.data;
+ return response.data;
+ });
+ };
+ getTooltipTemplate = function(url) {
+ var deferred;
+ if (tooltipTemplateData.length) {
+ deferred = $q.defer();
+ deferred.resolve(tooltipTemplateData);
+ return deferred.promise;
+ }
+ return $http.get(url).then(function(response) {
+ tooltipTemplateData = response.data;
+ return response.data;
+ });
+ };
+ removeChildren = function(annotation) {
+ var a, i, _i, _ref, _results;
+ _results = [];
+ for (i = _i = _ref = annotation.children.length - 1; _i >= 0; i = _i += -1) {
+ a = annotation.children[i];
+ removeChildren(a);
+ _results.push(a.children.splice(i, 1));
+ }
+ return _results;
+ };
+ removeAnnotation = function(id, annotations) {
+ var a, i, _i, _len;
+ for (i = _i = 0, _len = annotations.length; _i < _len; i = ++_i) {
+ a = annotations[i];
+ removeAnnotation(id, a.children);
+ if (a.id === id) {
+ removeChildren(a);
+ annotations.splice(i, 1);
+ return;
+ }
+ }
+ };
+ createAnnotation = function() {
+ var annotation, annotationParentCollection, attrId, parentAnnotation, parentId, prevAnnotation, prevSiblingId, prevSiblingSpan, range, sel;
+ annotation = new NGAnnotation();
+ sel = window.getSelection();
+ if (sel.type !== "Range") {
+ throw new Error("NG_ANNOTATE_NO_TEXT_SELECTED");
+ }
+ range = sel.getRangeAt(0);
+ if (range.startContainer !== range.endContainer) {
+ throw new Error("NG_ANNOTATE_PARTIAL_NODE_SELECTED");
+ }
+ if (range.startContainer.parentElement.nodeName === "SPAN") {
+ parentId = (attrId = range.startContainer.parentElement.getAttribute("data-annotation-id")) != null ? parseInt(attrId, 10) : void 0;
+ if (parentId === void 0) {
+ throw new Error("NG_ANNOTATE_ILLEGAL_SELECTION");
+ }
+ parentAnnotation = getAnnotationById($scope.annotations, parentId);
+ annotationParentCollection = parentAnnotation.children;
+ } else {
+ annotationParentCollection = $scope.annotations;
+ }
+ if (annotationParentCollection.length) {
+ prevSiblingSpan = range.startContainer.previousSibling;
+ if (prevSiblingSpan != null) {
+ prevSiblingId = (attrId = prevSiblingSpan.getAttribute("data-annotation-id")) != null ? parseInt(attrId, 10) : void 0;
+ if (prevSiblingId == null) {
+ throw new Error("NG_ANNOTATE_ILLEGAL_SELECTION");
+ }
+ prevAnnotation = getAnnotationById($scope.annotations, prevSiblingId);
+ annotation.startIndex = prevAnnotation.endIndex + range.startOffset;
+ annotation.endIndex = prevAnnotation.endIndex + range.endOffset;
+ } else {
+ annotation.startIndex = range.startOffset;
+ annotation.endIndex = range.endOffset;
+ }
+ } else {
+ annotation.startIndex = range.startOffset;
+ annotation.endIndex = range.endOffset;
+ }
+ annotationParentCollection.push(annotation);
+ return annotation;
+ };
+ onSelect = function(event) {
+ var $span, annotation, ex, getTemplatePromise, popup;
+ try {
+ annotation = createAnnotation();
+ $scope.$apply();
+ $span = element.find(".ng-annotation-" + annotation.id);
+ } catch (_error) {
+ ex = _error;
+ if ($scope.onAnnotateError != null) {
+ $scope.onAnnotateError(ex);
+ }
+ return;
+ }
+ clearPopups();
+ clearTooltips();
+ popup = new NGAnnotatePopup($rootScope.$new());
+ popup.scope.$isNew = true;
+ popup.scope.$annotation = annotation;
+ popup.$anchor = $span;
+ popup.scope.$reject = function() {
+ removeAnnotation(annotation.id, $scope.annotations);
+ if ($scope.onAnnotateDelete != null) {
+ $scope.onAnnotateDelete(annotation);
+ }
+ clearPopups();
+ return popup.destroy();
+ };
+ popup.scope.$close = function() {
+ if ($scope.onAnnotate != null) {
+ $scope.onAnnotate(popup.scope.$annotation);
+ }
+ clearPopups();
+ return popup.destroy();
+ };
+ activePopups.push(popup);
+ getTemplatePromise = getPopupTemplate(options.popupTemplateUrl);
+ return getTemplatePromise.then(function(template) {
+ return $compile(angular.element(template))(popup.scope, function($content) {
+ popup.$el.html($content);
+ popup.$el.appendTo("body");
+ popup.positionTop();
+ popup.positionLeft(element.offset().left - popup.$el.innerWidth());
+ return popup.show();
+ });
+ });
+ };
+ onClick = function(event) {
+ var $target, annotation, attrId, getTemplatePromise, p, popup, targetId, _i, _len;
+ $target = angular.element(event.target);
+ targetId = (attrId = $target.attr("data-annotation-id")) != null ? parseInt(attrId, 10) : void 0;
+ if (targetId == null) {
+ return;
+ }
+ if (activePopups.length) {
+ for (_i = 0, _len = activePopups.length; _i < _len; _i++) {
+ p = activePopups[_i];
+ if ((p.scope != null) && p.scope.$annotation.id === targetId) {
+ clearPopups();
+ return;
+ }
+ }
+ }
+ clearPopups();
+ clearTooltips();
+ annotation = getAnnotationById($scope.annotations, targetId);
+ popup = new NGAnnotatePopup($rootScope.$new());
+ popup.scope.$isNew = false;
+ popup.scope.$annotation = annotation;
+ popup.$anchor = $target;
+ popup.scope.$reject = function() {
+ removeAnnotation(targetId, $scope.annotations);
+ if (typeof $scope.onAnnotateDelete === "function") {
+ $scope.onAnnotateDelete(annotation);
+ }
+ clearPopups();
+ return popup.destroy();
+ };
+ popup.scope.$close = function() {
+ if (typeof $scope.onAnnotate === "function") {
+ $scope.onAnnotate(popup.scope.$annotation);
+ }
+ clearPopups();
+ return popup.destroy();
+ };
+ activePopups.push(popup);
+ getTemplatePromise = getPopupTemplate(options.popupTemplateUrl);
+ return getTemplatePromise.then(function(template) {
+ return $compile(angular.element(template))(popup.scope, function($content) {
+ popup.$el.html($content);
+ popup.$el.appendTo("body");
+ popup.positionTop();
+ popup.positionLeft(element.offset().left - popup.$el.innerWidth());
+ return popup.show();
+ });
+ });
+ };
+ onMouseEnter = function(event) {
+ var $target, annotation, attrId, getTemplatePromise, targetId, tooltip;
+ event.stopPropagation();
+ $target = angular.element(event.target);
+ targetId = (attrId = $target.attr("data-annotation-id")) != null ? parseInt(attrId, 10) : void 0;
+ if (targetId == null) {
+ return;
+ }
+ annotation = getAnnotationById($scope.annotations, targetId);
+ if (activePopups.length) {
+ return;
+ }
+ tooltip = new NGAnnotateTooltip($rootScope.$new());
+ tooltip.scope.$annotation = annotation;
+ tooltip.$anchor = $target;
+ activeTooltips.push(tooltip);
+ getTemplatePromise = getTooltipTemplate(options.tooltipTemplateUrl);
+ return getTemplatePromise.then(function(template) {
+ return $compile(angular.element(template))(tooltip.scope, function($content) {
+ tooltip.$el.html($content);
+ tooltip.$el.appendTo("body");
+ tooltip.positionTop();
+ tooltip.positionLeft(element.offset().left - tooltip.$el.innerWidth());
+ return tooltip.show();
+ });
+ });
+ };
+ onMouseLeave = function(event) {
+ var $target, attrId, targetId;
+ event.stopPropagation();
+ $target = angular.element(event.target);
+ targetId = (attrId = $target.attr("data-annotation-id")) != null ? parseInt(attrId, 10) : void 0;
+ if (targetId == null) {
+ return;
+ }
+ return clearTooltips();
+ };
+ element.on("mouseover", "span", onMouseEnter);
+ element.on("mouseleave", "span", onMouseLeave);
+ return element.on("mouseup", function(event) {
+ var selection;
+ selection = window.getSelection();
+ if (selection.type === "Range") {
+ return onSelect(event);
+ } else if (selection.type === "Caret" && event.target.nodeName === "SPAN") {
+ return onClick(event);
+ } else if (selection.type === "Caret") {
+ clearTooltips();
+ return clearPopups();
+ }
+ });
+ };
+ }
+ };
+ });
+
+}).call(this);
diff --git a/dist/1.2.0/js/ng-annotate-1.2.0.min.js b/dist/1.2.0/js/ng-annotate-1.2.0.min.js
new file mode 100644
index 0000000..6aab888
--- /dev/null
+++ b/dist/1.2.0/js/ng-annotate-1.2.0.min.js
@@ -0,0 +1 @@
+(function(){var getAnnotationById,insertAt,ngAnnotate,parseAnnotations,sortAnnotationsByEndIndex;ngAnnotate=angular.module("ngAnnotate",[]),insertAt=function(text,index,string){return text.substr(0,index)+string+text.substr(index)},sortAnnotationsByEndIndex=function(annotations){return annotations.sort(function(a,b){return a.endIndexb.endIndex?1:0})},parseAnnotations=function(text,annotations,indexOffset){var annotation,i,_i,_ref;if(null==annotations&&(annotations=[]),null==indexOffset&&(indexOffset=0),0===annotations.length)return text;for(annotations=sortAnnotationsByEndIndex(annotations),i=_i=_ref=annotations.length-1;_i>=0;i=_i+=-1)annotation=annotations[i],text=insertAt(text,annotation.endIndex+indexOffset,""),annotation.children.length&&(text=parseAnnotations(text,annotation.children,annotation.startIndex+indexOffset)),text=insertAt(text,annotation.startIndex+indexOffset,'');return text},getAnnotationById=function(annotations,aId){var a,an,_i,_len;for(_i=0,_len=annotations.length;_len>_i;_i++){if(a=annotations[_i],aId===a.id)return a;if(a.children.length>0&&(an=getAnnotationById(a.children,aId),void 0!==an))return an}},ngAnnotate.factory("NGAnnotatePopup",function(){var NGAnnotatePopup;return NGAnnotatePopup=function(scope){return angular.extend(this,{scope:scope,$el:angular.element(''),$anchor:null,show:function(cb,speed){return null==cb&&(cb=angular.noop),null==speed&&(speed="fast"),this.$el.fadeIn(speed,cb)},hide:function(cb,speed){return null==cb&&(cb=angular.noop),null==speed&&(speed="fast"),this.$el.fadeOut(speed,cb)},isVisible:function(){return this.$el.is(":visible")},positionTop:function(){var anchorHeight,anchorOffsetTop,popupHeight;if(null==this.$anchor)throw new Error("NG_ANNOTATE_NO_ANCHOR");return anchorOffsetTop=this.$anchor.offset().top,anchorHeight=this.$anchor.innerHeight(),popupHeight=this.$el.innerHeight(),this.$el.css({top:anchorOffsetTop+anchorHeight/2-popupHeight/2})},positionLeft:function(value){return this.$el.css({left:value})},destroy:function(){var $el;return scope=this.scope,$el=this.$el,this.hide(function(){return scope.$destroy(),$el.remove()})}})}}),ngAnnotate.factory("NGAnnotateTooltip",function(){var NGAnnotateTooltip;return NGAnnotateTooltip=function(scope){return angular.extend(this,{scope:scope,$el:angular.element(''),$anchor:null,show:function(cb,speed){return null==cb&&(cb=angular.noop),null==speed&&(speed="fast"),this.$el.fadeIn(speed,cb)},hide:function(cb,speed){return null==cb&&(cb=angular.noop),null==speed&&(speed="fast"),this.$el.fadeOut(speed,cb)},isVisible:function(){return this.$el.is(":visible")},positionTop:function(){var anchorHeight,anchorOffsetTop,tooltipHeight;if(null==this.$anchor)throw new Error("NG_ANNOTATE_NO_ANCHOR");return anchorOffsetTop=this.$anchor.offset().top,anchorHeight=this.$anchor.innerHeight(),tooltipHeight=this.$el.innerHeight(),this.$el.css({top:anchorOffsetTop+anchorHeight/2-tooltipHeight/2})},positionLeft:function(value){return this.$el.css({left:value})},destroy:function(){var $el;return scope=this.scope,$el=this.$el,this.hide(function(){return scope.$destroy(),$el.remove()})}})}}),ngAnnotate.factory("NGAnnotation",function(){var Annotation;return Annotation=function(data){return angular.extend(this,{id:(new Date).getTime(),startIndex:null,endIndex:null,data:{},type:"",children:[]}),null!=data?angular.extend(this,data):void 0}}),ngAnnotate.directive("ngAnnotate",function($rootScope,$compile,$http,$q,NGAnnotation,NGAnnotatePopup,NGAnnotateTooltip){return{restrict:"A",scope:{text:"=",annotations:"=",options:"=",onAnnotate:"=",onAnnotateDelete:"=",onAnnotateError:"="},compile:function(tElement){return function($scope,element){var activePopups,activeTooltips,clearPopups,clearTooltips,createAnnotation,getPopupTemplate,getTooltipTemplate,onAnnotationsChange,onClick,onMouseEnter,onMouseLeave,onSelect,options,popupTemplateData,removeAnnotation,removeChildren,tooltipTemplateData;return activePopups=[],activeTooltips=[],popupTemplateData="",tooltipTemplateData="",onAnnotationsChange=function(){var t;if(null!=$scope.text&&$scope.text.length)return t=parseAnnotations($scope.text,$scope.annotations),tElement.html(t)},$scope.$watch("text",onAnnotationsChange),$scope.$watch("annotations",onAnnotationsChange,!0),options={popupTemplateUrl:"",tooltipTemplateUrl:""},options=angular.extend(options,$scope.options),clearPopups=function(){var p,_i,_len;for(_i=0,_len=activePopups.length;_len>_i;_i++)p=activePopups[_i],p.destroy();return activePopups=[]},clearTooltips=function(){var i,_i,_ref,_results;for(_results=[],i=_i=_ref=activeTooltips.length-1;_i>=0;i=_i+=-1)activeTooltips[i].destroy(),_results.push(activeTooltips.splice(i,1));return _results},$scope.$on("$destroy",function(){return clearPopups(),clearTooltips()}),getPopupTemplate=function(url){var deferred;return popupTemplateData.length?(deferred=$q.defer(),deferred.resolve(popupTemplateData),deferred.promise):$http.get(url).then(function(response){return popupTemplateData=response.data,response.data})},getTooltipTemplate=function(url){var deferred;return tooltipTemplateData.length?(deferred=$q.defer(),deferred.resolve(tooltipTemplateData),deferred.promise):$http.get(url).then(function(response){return tooltipTemplateData=response.data,response.data})},removeChildren=function(annotation){var a,i,_i,_ref,_results;for(_results=[],i=_i=_ref=annotation.children.length-1;_i>=0;i=_i+=-1)a=annotation.children[i],removeChildren(a),_results.push(a.children.splice(i,1));return _results},removeAnnotation=function(id,annotations){var a,i,_i,_len;for(i=_i=0,_len=annotations.length;_len>_i;i=++_i)if(a=annotations[i],removeAnnotation(id,a.children),a.id===id)return removeChildren(a),void annotations.splice(i,1)},createAnnotation=function(){var annotation,annotationParentCollection,attrId,parentAnnotation,parentId,prevAnnotation,prevSiblingId,prevSiblingSpan,range,sel;if(annotation=new NGAnnotation,sel=window.getSelection(),"Range"!==sel.type)throw new Error("NG_ANNOTATE_NO_TEXT_SELECTED");if(range=sel.getRangeAt(0),range.startContainer!==range.endContainer)throw new Error("NG_ANNOTATE_PARTIAL_NODE_SELECTED");if("SPAN"===range.startContainer.parentElement.nodeName){if(parentId=null!=(attrId=range.startContainer.parentElement.getAttribute("data-annotation-id"))?parseInt(attrId,10):void 0,void 0===parentId)throw new Error("NG_ANNOTATE_ILLEGAL_SELECTION");parentAnnotation=getAnnotationById($scope.annotations,parentId),annotationParentCollection=parentAnnotation.children}else annotationParentCollection=$scope.annotations;if(annotationParentCollection.length)if(prevSiblingSpan=range.startContainer.previousSibling,null!=prevSiblingSpan){if(prevSiblingId=null!=(attrId=prevSiblingSpan.getAttribute("data-annotation-id"))?parseInt(attrId,10):void 0,null==prevSiblingId)throw new Error("NG_ANNOTATE_ILLEGAL_SELECTION");prevAnnotation=getAnnotationById($scope.annotations,prevSiblingId),annotation.startIndex=prevAnnotation.endIndex+range.startOffset,annotation.endIndex=prevAnnotation.endIndex+range.endOffset}else annotation.startIndex=range.startOffset,annotation.endIndex=range.endOffset;else annotation.startIndex=range.startOffset,annotation.endIndex=range.endOffset;return annotationParentCollection.push(annotation),annotation},onSelect=function(){var $span,annotation,ex,getTemplatePromise,popup;try{annotation=createAnnotation(),$scope.$apply(),$span=element.find(".ng-annotation-"+annotation.id)}catch(_error){return ex=_error,void(null!=$scope.onAnnotateError&&$scope.onAnnotateError(ex))}return clearPopups(),clearTooltips(),popup=new NGAnnotatePopup($rootScope.$new()),popup.scope.$isNew=!0,popup.scope.$annotation=annotation,popup.$anchor=$span,popup.scope.$reject=function(){return removeAnnotation(annotation.id,$scope.annotations),null!=$scope.onAnnotateDelete&&$scope.onAnnotateDelete(annotation),clearPopups(),popup.destroy()},popup.scope.$close=function(){return null!=$scope.onAnnotate&&$scope.onAnnotate(popup.scope.$annotation),clearPopups(),popup.destroy()},activePopups.push(popup),getTemplatePromise=getPopupTemplate(options.popupTemplateUrl),getTemplatePromise.then(function(template){return $compile(angular.element(template))(popup.scope,function($content){return popup.$el.html($content),popup.$el.appendTo("body"),popup.positionTop(),popup.positionLeft(element.offset().left-popup.$el.innerWidth()),popup.show()})})},onClick=function(event){var $target,annotation,attrId,getTemplatePromise,p,popup,targetId,_i,_len;if($target=angular.element(event.target),targetId=null!=(attrId=$target.attr("data-annotation-id"))?parseInt(attrId,10):void 0,null!=targetId){if(activePopups.length)for(_i=0,_len=activePopups.length;_len>_i;_i++)if(p=activePopups[_i],null!=p.scope&&p.scope.$annotation.id===targetId)return void clearPopups();return clearPopups(),clearTooltips(),annotation=getAnnotationById($scope.annotations,targetId),popup=new NGAnnotatePopup($rootScope.$new()),popup.scope.$isNew=!1,popup.scope.$annotation=annotation,popup.$anchor=$target,popup.scope.$reject=function(){return removeAnnotation(targetId,$scope.annotations),"function"==typeof $scope.onAnnotateDelete&&$scope.onAnnotateDelete(annotation),clearPopups(),popup.destroy()},popup.scope.$close=function(){return"function"==typeof $scope.onAnnotate&&$scope.onAnnotate(popup.scope.$annotation),clearPopups(),popup.destroy()},activePopups.push(popup),getTemplatePromise=getPopupTemplate(options.popupTemplateUrl),getTemplatePromise.then(function(template){return $compile(angular.element(template))(popup.scope,function($content){return popup.$el.html($content),popup.$el.appendTo("body"),popup.positionTop(),popup.positionLeft(element.offset().left-popup.$el.innerWidth()),popup.show()})})}},onMouseEnter=function(event){var $target,annotation,attrId,getTemplatePromise,targetId,tooltip;return event.stopPropagation(),$target=angular.element(event.target),targetId=null!=(attrId=$target.attr("data-annotation-id"))?parseInt(attrId,10):void 0,null==targetId||(annotation=getAnnotationById($scope.annotations,targetId),activePopups.length)?void 0:(tooltip=new NGAnnotateTooltip($rootScope.$new()),tooltip.scope.$annotation=annotation,tooltip.$anchor=$target,activeTooltips.push(tooltip),getTemplatePromise=getTooltipTemplate(options.tooltipTemplateUrl),getTemplatePromise.then(function(template){return $compile(angular.element(template))(tooltip.scope,function($content){return tooltip.$el.html($content),tooltip.$el.appendTo("body"),tooltip.positionTop(),tooltip.positionLeft(element.offset().left-tooltip.$el.innerWidth()),tooltip.show()})}))},onMouseLeave=function(event){var $target,attrId,targetId;return event.stopPropagation(),$target=angular.element(event.target),targetId=null!=(attrId=$target.attr("data-annotation-id"))?parseInt(attrId,10):void 0,null!=targetId?clearTooltips():void 0},element.on("mouseover","span",onMouseEnter),element.on("mouseleave","span",onMouseLeave),element.on("mouseup",function(event){var selection;return selection=window.getSelection(),"Range"===selection.type?onSelect(event):"Caret"===selection.type&&"SPAN"===event.target.nodeName?onClick(event):"Caret"===selection.type?(clearTooltips(),clearPopups()):void 0})}}}})}).call(this);
\ No newline at end of file
diff --git a/package.json b/package.json
index cf6e076..2012492 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "ng-annotate",
- "version": "1.1.0",
+ "version": "1.2.0",
"description": "An AngularJS directive to assist with annotation of text",
"repository": {
"type": "git",