diff --git a/dist/ng-annotate-text-latest.js b/dist/ng-annotate-text-latest.js index c0cdcad..ff2606b 100644 --- a/dist/ng-annotate-text-latest.js +++ b/dist/ng-annotate-text-latest.js @@ -1,5 +1,5 @@ (function() { - var annotationIdCounter, getAnnotationById, insertAt, ngAnnotateText, parseAnnotations, sortAnnotationsByEndIndex; + var annotationIdCounter, getAnnotationById, insertAt, isEmptyObject, ngAnnotateText, parseAnnotations, sortAnnotationsByEndIndex; ngAnnotateText = angular.module("ngAnnotateText", []); @@ -59,6 +59,16 @@ } }; + isEmptyObject = function(obj) { + var prop; + for (prop in obj) { + if (Object.prototype.hasOwnProperty.call(obj, prop)) { + return false; + } + } + return true; + }; + ngAnnotateText.factory("NGAnnotateTextPopup", function() { return function(args) { args = angular.extend({ @@ -219,9 +229,7 @@ id: annotationIdCounter++, startIndex: null, endIndex: null, - data: { - points: 0 - }, + data: {}, type: "", children: [] }); @@ -444,7 +452,7 @@ return; } annotation = getAnnotationById($scope.annotations, targetId); - if ((activePopup != null) || (!annotation.data.comment && !annotation.data.points)) { + if ((activePopup != null) || isEmptyObject(annotation.data)) { return; } tooltip = new NGAnnotateTextPopup({ diff --git a/dist/ng-annotate-text-latest.js.map b/dist/ng-annotate-text-latest.js.map index 5989471..d704be0 100755 --- a/dist/ng-annotate-text-latest.js.map +++ b/dist/ng-annotate-text-latest.js.map @@ -1 +1 @@ -{"version":3,"sources":["ng-annotate-text.coffee"],"names":[],"mappings":"AAAA;AAAA,MAAA,6GAAA;;AAAA,EAAA,cAAA,GAAiB,OAAO,CAAC,MAAR,CAAe,gBAAf,EAAiC,EAAjC,CAAjB,CAAA;;AAAA,EAEA,mBAAA,GAAsB,CAFtB,CAAA;;AAAA,EAIA,QAAA,GAAW,SAAC,IAAD,EAAO,KAAP,EAAc,MAAd,GAAA;AACV,WAAO,IAAI,CAAC,MAAL,CAAY,CAAZ,EAAe,KAAf,CAAA,GAAwB,MAAxB,GAAiC,IAAI,CAAC,MAAL,CAAY,KAAZ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CAAC,EAAR,CAAW,YAAX,EAAyB,MAAzB,EAAiC,YAAjC,CA1QA,CAAA;AAAA,QA2QA,OAAO,CAAC,EAAR,CAAW,YAAX,EAAyB,MAAzB,EAAiC,YAAjC,CA3QA,CAAA;eA6QA,OAAO,CAAC,EAAR,CAAW,SAAX,EAAsB,SAAC,KAAD,GAAA;AAGrB,cAAA,SAAA;AAAA,UAAA,SAAA,GAAY,MAAM,CAAC,YAAP,CAAA,CAAZ,CAAA;AACA,UAAA,IAAG,CAAA,SAAU,CAAC,WAAX,IAA2B,CAAA,MAAO,CAAC,QAAtC;mBAEC,QAAA,CAAS,KAAT,EAFD;WAAA,MAGK,IAAG,SAAS,CAAC,WAAV,IAA0B,KAAK,CAAC,MAAM,CAAC,QAAb,KAAyB,MAAtD;mBACJ,OAAA,CAAQ,KAAR,EADI;WAAA,MAEA,IAAG,SAAS,CAAC,WAAb;mBACJ,WAAA,CAAA,EADI;WATgB;QAAA,CAAtB,EA9QS;MAAA,CAtBV;MAD0C;EAAA,CAA3C,CAjLA,CAAA;AAAA","file":"ng-annotate-text-latest.js","sourceRoot":"/source/","sourcesContent":["ngAnnotateText = angular.module \"ngAnnotateText\", []\n\nannotationIdCounter = 0\n\ninsertAt = (text, index, string)->\n\treturn text.substr(0, index) + string + text.substr(index)\n\nsortAnnotationsByEndIndex = (annotations)->\n\treturn annotations.sort (a, b)->\n\t\tif a.endIndex < b.endIndex\n\t\t\treturn -1\n\t\telse if a.endIndex > b.endIndex\n\t\t\treturn 1\n\t\treturn 0\n\nparseAnnotations = (text, annotations = [], indexOffset = 0)->\n\tif annotations.length is 0\n\t\treturn text\n\tannotations = sortAnnotationsByEndIndex annotations\n\n\tfor i in [annotations.length - 1..0] by -1\n\t\tannotation = annotations[i];\n\t\ttext = insertAt text, annotation.endIndex + indexOffset, \"\"\n\t\tif annotation.children.length\n\t\t\ttext = parseAnnotations text, annotation.children, annotation.startIndex + indexOffset\n\t\ttext = insertAt text, annotation.startIndex + indexOffset, \"\"\n\treturn text\n\ngetAnnotationById = (annotations, aId)->\n\tfor a in annotations\n\t\tif aId is a.id\n\t\t\treturn a\n\t\tif a.children.length > 0\n\t\t\tan = getAnnotationById a.children, aId\n\t\t\tif an isnt undefined\n\t\t\t\treturn an\n\nngAnnotateText.factory \"NGAnnotateTextPopup\", ->\n\t(args) ->\n\t\targs = angular.extend {\n\t\t\tscope: null,\n\t\t\tcallbacks: {},\n\t\t\ttemplate: \"
\"\n\t\t\t$anchor: null\n\t\t\tpreferredAxis: 'x'\n\t\t\toffset: 0\n\t\t\tpositionClass: '{{position}}'\n\t\t}, args\n\n\t\tangular.extend @, args,\n\t\t\t$el: angular.element args.template\n\n\t\t\tshow: (speed = \"fast\") ->\n\t\t\t\t@$el.fadeIn speed\n\t\t\t\t@reposition()\n\t\t\t\tif typeof @callbacks.show is \"function\"\n\t\t\t\t\t@callbacks.show @$el\n\n\t\t\thide: (speed = \"fast\")->\n\t\t\t\t@$el.fadeOut speed\n\t\t\t\tif typeof @callbacks.hide is \"function\"\n\t\t\t\t\t@callbacks.hide @$el\n\n\t\t\tisVisible: ->\n\t\t\t\treturn @$el.is \":visible\"\n\n\t\t\tdestroy: (cb = angular.noop)->\n\t\t\t\tscope = @scope\n\t\t\t\t$el = @$el\n\t\t\t\t@hide ->\n\t\t\t\t\tif typeof cb is \"function\"\n\t\t\t\t\t\tcb()\n\t\t\t\t\tscope.$destroy()\n\t\t\t\t\t$el.remove()\n\n\t\t\tstopDestroy: ->\n\t\t\t\t@$el.stop(true).show(\"fast\")\n\n\t\t\treposition: ->\n\t\t\t\ttargetEl = @$el[0]\n\t\t\t\tanchorEl = @$anchor[0]\n\n\t\t\t\tif not (targetEl or anchorEl)\n\t\t\t\t\treturn\n\n\t\t\t\tpos =\n\t\t\t\t\tleft: null\n\t\t\t\t\ttop: null\n\t\t\t\t\ttarget: targetEl.getBoundingClientRect()\n\t\t\t\t\tanchor: anchorEl.getBoundingClientRect()\n\t\t\t\t\tviewport:\n\t\t\t\t\t\twidth: window.innerWidth\n\t\t\t\t\t\theight: window.innerHeight\n\t\t\t\t\tscroll:\n\t\t\t\t\t\ttop: document.body.scrollTop\n\t\t\t\t\t\tleft: document.body.scrollLeft\n\n\t\t\t\tif not (pos.target.width > 0 and pos.target.height > 0)\n\t\t\t\t\treturn\n\n\t\t\t\t# Find first axis position\n\n\t\t\t\tposX = @getNewPositionOnAxis pos, 'x'\n\t\t\t\tposY = @getNewPositionOnAxis pos, 'y'\n\n\t\t\t\tif @preferredAxis is 'x'\n\t\t\t\t\tif posX and typeof posX.pos is 'number'\n\t\t\t\t\t\tpos.left = posX.pos\n\t\t\t\t\t\tpos.edge = posX.edge\n\t\t\t\t\telse if posY\n\t\t\t\t\t\tpos.top = posY.pos\n\t\t\t\t\t\tpos.edge = posY.edge\n\t\t\t\telse\n\t\t\t\t\tif posY and typeof posY.pos is 'number'\n\t\t\t\t\t\tpos.top = posY.pos\n\t\t\t\t\t\tpos.edge = posY.edge\n\t\t\t\t\telse if posX\n\t\t\t\t\t\tpos.left = posX.pos\n\t\t\t\t\t\tpos.edge = posX.edge\n\n\t\t\t\t# Center on second axis\n\n\t\t\t\tif pos.left is null and pos.top is null\n\t\t\t\t\t# Center on X and Y axes\n\t\t\t\t\tpos.left = pos.scroll.left + (pos.viewport.width / 2) - (pos.target.width / 2)\n\t\t\t\t\tpos.top = pos.scroll.top + (pos.viewport.height / 2) - (pos.target.height / 2)\n\t\t\t\telse if pos.left is null\n\t\t\t\t\t# Center on X axis\n\t\t\t\t\tpos.left = @getNewCenterPositionOnAxis pos, 'x'\n\t\t\t\telse if pos.top is null\n\t\t\t\t\t# Center on Y axis\n\t\t\t\t\tpos.top = @getNewCenterPositionOnAxis pos, 'y'\n\n\t\t\t\t@$el\n\t\t\t\t\t.addClass pos.edge && @positionClass.replace \"{{position}}\", pos.edge\n\t\t\t\t\t.css\n\t\t\t\t\t\ttop: Math.round(pos.top) || 0\n\t\t\t\t\t\tleft: Math.round(pos.left) || 0\n\n\t\t\t\treturn\n\n\t\t\tgetNewPositionOnAxis: (pos, axis) ->\n\t\t\t\tstart = {x: 'left', y: 'top'}[axis]\n\t\t\t\tend = {x: 'right', y: 'bottom'}[axis]\n\t\t\t\tsize = {x: 'width', y: 'height'}[axis]\n\t\t\t\tif pos.anchor[start] - @offset >= pos.target[size]\n\t\t\t\t\taxisPos =\n\t\t\t\t\t\tpos: pos.scroll[start] + pos.anchor[start] - @offset - pos.target[size]\n\t\t\t\t\t\tedge: start\n\t\t\t\telse if pos.viewport[size] - pos.anchor[end] - @offset >= pos.target[size]\n\t\t\t\t\taxisPos =\n\t\t\t\t\t\tpos: pos.scroll[start] + pos.anchor[end] + @offset\n\t\t\t\t\t\tedge: end\n\t\t\t\taxisPos\n\n\t\t\tgetNewCenterPositionOnAxis: (pos, axis) ->\n\t\t\t\tstart = {x: 'left', y: 'top'}[axis]\n\t\t\t\tsize = {x: 'width', y: 'height'}[axis]\n\t\t\t\tcenterPos = pos.scroll[start] + pos.anchor[start] + (pos.anchor[size] / 2) - (pos.target[size] / 2)\n\t\t\t\tMath.max(pos.scroll[start] + @offset, Math.min(centerPos, pos.scroll[start] + pos.viewport[size] - pos.target[size] - @offset))\n\nngAnnotateText.factory \"NGAnnotation\", ->\n\tAnnotation = (data)->\n\n\t\tangular.extend @,\n\t\t\tid: annotationIdCounter++,\n\t\t\tstartIndex: null\n\t\t\tendIndex: null\n\t\t\tdata: {points: 0}\n\t\t\ttype: \"\"\n\t\t\tchildren: []\n\n\t\tif data?\n\t\t\tangular.extend @, data\n\n\treturn Annotation\n\nngAnnotateText.directive \"ngAnnotateText\", ($rootScope, $compile, $http, $q, $controller, $sce, NGAnnotation, NGAnnotateTextPopup)->\n\trestrict: \"E\"\n\tscope:\n\t\ttext: \"=\"\n\t\tannotations: \"=\"\n\t\treadonly: \"=\"\n\t\tpopupController: \"=\"\n\t\tpopupTemplateUrl: \"=\"\n\t\ttooltipController: \"=\"\n\t\ttooltipTemplateUrl: \"=\"\n\t\tonAnnotate: \"=\"\n\t\tonAnnotateDelete: \"=\"\n\t\tonAnnotateError: \"=\"\n\t\tonPopupShow: \"=\"\n\t\tonPopupHide: \"=\"\n\t\tpopupOffset: \"=\"\n\ttemplate: \"

\"\n\treplace: true\n\n\tcompile: (el, attr) ->\n\t\tattr.readonly ?= false\n\t\t@postLink\n\n\tpostLink: ($scope, element, attrs) ->\n\t\tPOPUP_OFFSET = $scope.popupOffset ? 10\n\n\t\tactivePopup = null\n\t\tactiveTooltip = null\n\n\t\t# Cache the template when we fetch it\n\t\tpopupTemplateData = \"\"\n\t\ttooltipTemplateData = \"\"\n\n\t\tonAnnotationsChange = ->\n\t\t\tif not $scope.text? or !$scope.text.length\n\t\t\t\treturn\n\t\t\tt = parseAnnotations $scope.text, $scope.annotations\n\t\t\t$scope.content = $sce.trustAsHtml t\n\n\t\t# Annotation parsing\n\t\t$scope.$watch \"text\", onAnnotationsChange\n\t\t$scope.$watch \"annotations\", onAnnotationsChange, true\n\n\t\tclearPopup = ->\n\t\t\tif not activePopup?\n\t\t\t\treturn\n\t\t\ttId = activePopup.scope.$annotation.id\n\t\t\tactivePopup.destroy ->\n\t\t\t\tif activePopup.scope.$annotation.id is tId\n\t\t\t\t\tactivePopup = null\n\n\t\tclearTooltip = ->\n\t\t\ttooltip = activeTooltip\n\t\t\tif not tooltip?\n\t\t\t\treturn\n\t\t\ttooltip.destroy ->\n\t\t\t\tif activeTooltip is tooltip\n\t\t\t\t\tactiveTooltip = null\n\n\t\tclearPopups = ->\n\t\t\tclearPopup()\n\t\t\tclearTooltip()\n\n\t\t$scope.$on \"$destroy\", clearPopups\n\t\t$scope.$on \"ngAnnotateText.clearPopups\", clearPopups\n\n\t\tif $scope.popupTemplateUrl\n\t\t\t$http.get($scope.popupTemplateUrl).then (response)->\n\t\t\t\tpopupTemplateData = response.data\n\n\t\tif $scope.tooltipTemplateUrl\n\t\t\t$http.get($scope.tooltipTemplateUrl).then (response)->\n\t\t\t\ttooltipTemplateData = response.data\n\n\t\tremoveChildren = (annotation)->\n\t\t\tfor i in [annotation.children.length - 1..0] by -1\n\t\t\t\ta = annotation.children[i]\n\t\t\t\tremoveChildren a\n\t\t\t\ta.children.splice i, 1\n\n\t\tremoveAnnotation = (id, annotations)->\n\t\t\tfor a, i in annotations\n\t\t\t\tremoveAnnotation id, a.children\n\n\t\t\t\tif a.id is id\n\t\t\t\t\tremoveChildren a\n\t\t\t\t\tannotations.splice i, 1\n\t\t\t\t\treturn\n\n\t\tcreateAnnotation = ->\n\t\t\tannotation = new NGAnnotation()\n\t\t\tsel = window.getSelection()\n\n\t\t\tif sel.isCollapsed\n\t\t\t\tthrow new Error \"NG_ANNOTATE_TEXT_NO_TEXT_SELECTED\"\n\n\t\t\trange = sel.getRangeAt 0\n\n\t\t\tif range.startContainer isnt range.endContainer\n\t\t\t\tthrow new Error \"NG_ANNOTATE_TEXT_PARTIAL_NODE_SELECTED\"\n\n\t\t\tif range.startContainer.parentNode.nodeName is \"SPAN\" # Is a child annotation\n\t\t\t\tparentId = if (attrId = range.startContainer.parentNode.getAttribute(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\t\t\t\tif parentId is undefined\n\t\t\t\t\tthrow new Error \"NG_ANNOTATE_TEXT_ILLEGAL_SELECTION\"\n\t\t\t\tparentAnnotation = getAnnotationById $scope.annotations, parentId\n\n\t\t\t\tannotationParentCollection = parentAnnotation.children\n\t\t\telse\n\t\t\t\tannotationParentCollection = $scope.annotations\n\n\t\t\t# Does this selection has any siblings?\n\t\t\tif annotationParentCollection.length\n\t\t\t\t# Yup, find the previous sibling\n\t\t\t\tprevSiblingSpan = range.startContainer.previousSibling\n\t\t\t\tif prevSiblingSpan?\n\t\t\t\t\tprevSiblingId = if (attrId = prevSiblingSpan.getAttribute(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\t\t\t\t\tif not prevSiblingId?\n\t\t\t\t\t\tthrow new Error \"NG_ANNOTATE_TEXT_ILLEGAL_SELECTION\"\n\n\t\t\t\t\tprevAnnotation = getAnnotationById $scope.annotations, prevSiblingId\n\t\t\t\t\tannotation.startIndex = prevAnnotation.endIndex + range.startOffset\n\t\t\t\t\tannotation.endIndex = prevAnnotation.endIndex + range.endOffset\n\t\t\t\telse\n\t\t\t\t\t# Doesn't have a prev sibling, alrighty then\n\t\t\t\t\tannotation.startIndex = range.startOffset\n\t\t\t\t\tannotation.endIndex = range.endOffset\n\t\t\telse\n\t\t\t\t# Nope\n\t\t\t\tannotation.startIndex = range.startOffset\n\t\t\t\tannotation.endIndex = range.endOffset\n\n\t\t\tannotationParentCollection.push annotation\n\t\t\tclearSelection()\n\t\t\treturn annotation\n\n\t\tclearSelection = ->\n\t\t\tif document.selection\n\t\t\t\tdocument.selection.empty() # Internet Explorer\n\t\t\telse if window.getSelection and window.getSelection().empty\n\t\t\t\twindow.getSelection().empty() # Chrome\n\t\t\telse if window.getSelection and window.getSelection().removeAllRanges\n\t\t\t\twindow.getSelection().removeAllRanges() # Firefox\n\n\t\tonSelect = (event)->\n\t\t\tif popupTemplateData.length is 0\n\t\t\t\treturn\n\n\t\t\ttry\n\t\t\t\tannotation = createAnnotation()\n\t\t\t\t$scope.$apply()\n\t\t\t\t$span = element.find \".ng-annotate-text-\" + annotation.id\n\t\t\tcatch ex\n\t\t\t\tif $scope.onAnnotateError?\n\t\t\t\t\t$scope.onAnnotateError ex\n\n\t\t\t\treturn\n\n\t\t\tclearPopups()\n\n\t\t\tloadAnnotationPopup annotation, $span, true\n\n\t\tonClick = (event)->\n\t\t\tif popupTemplateData.length is 0\n\t\t\t\treturn\n\n\t\t\t$target = angular.element event.target\n\t\t\ttargetId = if (attrId = $target.attr(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\n\t\t\tif not targetId?\n\t\t\t\treturn\n\n\t\t\tif activePopup? and activePopup.scope.$annotation.id is targetId\n\t\t\t\tclearPopup()\n\t\t\t\treturn\n\t\t\tannotation = getAnnotationById $scope.annotations, targetId\n\n\t\t\tclearPopups()\n\n\t\t\tloadAnnotationPopup annotation, $target, false\n\n\t\tonMouseEnter = (event)->\n\t\t\tif tooltipTemplateData.length is 0\n\t\t\t\treturn\n\n\t\t\tevent.stopPropagation()\n\t\t\t$target = angular.element event.target\n\t\t\ttargetId = if (attrId = $target.attr(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\n\t\t\tif activeTooltip? and activeTooltip.scope.$annotation.id is targetId\n\t\t\t\tactiveTooltip.stopDestroy()\n\t\t\t\treturn\n\t\t\telse\n\t\t\t\tclearTooltip()\n\n\t\t\tif not targetId?\n\t\t\t\treturn\n\n\t\t\tannotation = getAnnotationById $scope.annotations, targetId\n\n\t\t\t# We don't want to show the tooltip if a popup with the annotation is open,\n\t\t\t# or if the tooltip has both no comment and points\n\t\t\tif activePopup? or (not annotation.data.comment and not annotation.data.points)\n\t\t\t\treturn\n\n\t\t\ttooltip = new NGAnnotateTextPopup\n\t\t\t\tscope: $rootScope.$new()\n\t\t\t\ttemplate: \"
\"\n\t\t\t\tpositionClass: \"ng-annotate-text-tooltip-docked ng-annotate-text-tooltip-docked-{{position}}\"\n\t\t\t\t$anchor: $target\n\t\t\t\tpreferredAxis: 'y'\n\t\t\t\toffset: POPUP_OFFSET\n\t\t\ttooltip.scope.$annotation = annotation\n\n\t\t\tactiveTooltip = tooltip\n\n\t\t\tlocals =\n\t\t\t\t$scope: tooltip.scope\n\t\t\t\t$template: tooltipTemplateData\n\n\t\t\ttooltip.$el.html locals.$template\n\t\t\ttooltip.$el.appendTo \"body\"\n\n\t\t\tif $scope.tooltipController\n\t\t\t\tcontroller = $controller $scope.tooltipController, locals\n\t\t\t\ttooltip.$el.data \"$ngControllerController\", controller\n\t\t\t\ttooltip.$el.children().data \"$ngControllerController\", controller\n\n\t\t\t$compile(tooltip.$el) tooltip.scope\n\t\t\ttooltip.scope.$apply()\n\t\t\ttooltip.show()\n\n\t\tonMouseLeave = (event)->\n\t\t\tevent.stopPropagation()\n\n\t\t\t$target = angular.element event.target\n\t\t\ttargetId = if (attrId = $target.attr(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\n\t\t\tif not targetId?\n\t\t\t\treturn\n\n\t\t\tclearTooltip()\n\n\t\tloadAnnotationPopup = (annotation, anchor, isNew)->\n\t\t\tpopup = new NGAnnotateTextPopup\n\t\t\t\tscope: $rootScope.$new()\n\t\t\t\tcallbacks:\n\t\t\t\t\tshow: $scope.onPopupShow\n\t\t\t\t\thide: $scope.onPopupHide\n\t\t\t\ttemplate: \"
\"\n\t\t\t\tpositionClass: \"ng-annotate-text-popup-docked ng-annotate-text-popup-docked-{{position}}\"\n\t\t\t\t$anchor: anchor\n\t\t\t\toffset: POPUP_OFFSET\n\n\t\t\tpopup.scope.$isNew = isNew\n\t\t\tpopup.scope.$annotation = annotation\n\t\t\tpopup.scope.$readonly = $scope.readonly\n\n\t\t\tpopup.scope.$reject = ->\n\t\t\t\tremoveAnnotation annotation.id, $scope.annotations\n\n\t\t\t\tif $scope.onAnnotateDelete?\n\t\t\t\t\t$scope.onAnnotateDelete annotation\n\t\t\t\tclearPopup()\n\t\t\t\treturn\n\n\t\t\tpopup.scope.$close = ->\n\t\t\t\tif $scope.onAnnotate?\n\t\t\t\t\t$scope.onAnnotate popup.scope.$annotation\n\t\t\t\tclearPopup()\n\t\t\t\treturn\n\n\t\t\tactivePopup = popup\n\n\t\t\tlocals =\n\t\t\t\t$scope: popup.scope\n\t\t\t\t$template: popupTemplateData\n\n\t\t\tpopup.$el.html locals.$template\n\t\t\tpopup.$el.appendTo \"body\"\n\n\t\t\tif $scope.popupController\n\t\t\t\tcontroller = $controller $scope.popupController, locals\n\t\t\t\tpopup.$el.data \"$ngControllerController\", controller\n\t\t\t\tpopup.$el.children().data \"$ngControllerController\", controller\n\n\t\t\t$compile(popup.$el) popup.scope\n\t\t\tpopup.scope.$apply()\n\t\t\tpopup.show()\n\n\t\telement.on \"mouseenter\", \"span\", onMouseEnter\n\t\telement.on \"mouseleave\", \"span\", onMouseLeave\n\n\t\telement.on \"mouseup\", (event)->\n\t\t\t# We need to determine if the user actually selected something\n\t\t\t# or if he just clicked on an annotation\n\t\t\tselection = window.getSelection()\n\t\t\tif !selection.isCollapsed and !$scope.readonly\n\t\t\t\t# User has selected something\n\t\t\t\tonSelect event\n\t\t\telse if selection.isCollapsed and event.target.nodeName is \"SPAN\"\n\t\t\t\tonClick event\n\t\t\telse if selection.isCollapsed\n\t\t\t\tclearPopups()\n"]} \ No newline at end of file +{"version":3,"sources":["ng-annotate-text.coffee"],"names":[],"mappings":"AAAA;AAAA,MAAA,4HAAA;;AAAA,EAAA,cAAA,GAAiB,OAAO,CAAC,MAAR,CAAe,gBAAf,EAAiC,EAAjC,CAAjB,CAAA;;AAAA,EAEA,mBAAA,GAAsB,CAFtB,CAAA;;AAAA,EAIA,QAAA,GAAW,SAAC,IAAD,EAAO,KAAP,EAAc,MAAd,GAAA;AACV,WAAO,IAAI,CAAC,MAAL,CAAY,CAAZ,EAAe,KAAf,CAAA,GAAwB,MAAxB,GAAiC,IAAI,CAAC,MAAL,CAAY,KAAZ,CAAxC,CADU;EAAA,CAJX,CAAA;;AAAA,EAOA,yBAAA,GAA4B,SAAC,WAAD,GAAA;AAC3B,WAAO,WAAW,CAAC,IAAZ,CAAiB,SAAC,CAAD,EAAI,CAAJ,GAAA;AACvB,MAAA,IAAG,CAAC,CAAC,QAAF,GAAa,CAAC,CAAC,QAAlB;AACC,eAAO,CAAA,CAAP,CADD;OAAA,MAEK,IAAG,CAAC,CAAC,QAAF,GAAa,CAAC,CAAC,QAAlB;AACJ,eAAO,CAAP,CADI;OAFL;AAIA,aAAO,CAAP,CALuB;IAAA,CAAjB,CAAP,CAD2B;EAAA,CAP5B,CAAA;;AAAA,EAeA,gBAAA,GAAmB,SAAC,IAAD,EAAO,WAAP,EAAyB,WAAzB,GAAA;AAClB,QAAA,uBAAA;;MADyB,cAAc;KACvC;;MAD2C,cAAc;KACzD;AAAA,IAAA,IAAG,WAAW,CAAC,MAAZ,KAAsB,CAAzB;AACC,aA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AGK,IAAG,SAAS,CAAC,WAAV,IAA0B,KAAK,CAAC,MAAM,CAAC,QAAb,KAAyB,MAAtD;mBACJ,OAAA,CAAQ,KAAR,EADI;WAAA,MAEA,IAAG,SAAS,CAAC,WAAb;mBACJ,WAAA,CAAA,EADI;WATgB;QAAA,CAAtB,EA9QS;MAAA,CAtBV;MAD0C;EAAA,CAA3C,CAxLA,CAAA;AAAA","file":"ng-annotate-text-latest.js","sourceRoot":"/source/","sourcesContent":["ngAnnotateText = angular.module \"ngAnnotateText\", []\n\nannotationIdCounter = 0\n\ninsertAt = (text, index, string)->\n\treturn text.substr(0, index) + string + text.substr(index)\n\nsortAnnotationsByEndIndex = (annotations)->\n\treturn annotations.sort (a, b)->\n\t\tif a.endIndex < b.endIndex\n\t\t\treturn -1\n\t\telse if a.endIndex > b.endIndex\n\t\t\treturn 1\n\t\treturn 0\n\nparseAnnotations = (text, annotations = [], indexOffset = 0)->\n\tif annotations.length is 0\n\t\treturn text\n\tannotations = sortAnnotationsByEndIndex annotations\n\n\tfor i in [annotations.length - 1..0] by -1\n\t\tannotation = annotations[i];\n\t\ttext = insertAt text, annotation.endIndex + indexOffset, \"\"\n\t\tif annotation.children.length\n\t\t\ttext = parseAnnotations text, annotation.children, annotation.startIndex + indexOffset\n\t\ttext = insertAt text, annotation.startIndex + indexOffset, \"\"\n\treturn text\n\ngetAnnotationById = (annotations, aId)->\n\tfor a in annotations\n\t\tif aId is a.id\n\t\t\treturn a\n\t\tif a.children.length > 0\n\t\t\tan = getAnnotationById a.children, aId\n\t\t\tif an isnt undefined\n\t\t\t\treturn an\n\n\nisEmptyObject = (obj) ->\n for prop of obj\n if Object.prototype.hasOwnProperty.call(obj, prop)\n return false;\n return true;\n\nngAnnotateText.factory \"NGAnnotateTextPopup\", ->\n\t(args) ->\n\t\targs = angular.extend {\n\t\t\tscope: null,\n\t\t\tcallbacks: {},\n\t\t\ttemplate: \"
\"\n\t\t\t$anchor: null\n\t\t\tpreferredAxis: 'x'\n\t\t\toffset: 0\n\t\t\tpositionClass: '{{position}}'\n\t\t}, args\n\n\t\tangular.extend @, args,\n\t\t\t$el: angular.element args.template\n\n\t\t\tshow: (speed = \"fast\") ->\n\t\t\t\t@$el.fadeIn speed\n\t\t\t\t@reposition()\n\t\t\t\tif typeof @callbacks.show is \"function\"\n\t\t\t\t\t@callbacks.show @$el\n\n\t\t\thide: (speed = \"fast\")->\n\t\t\t\t@$el.fadeOut speed\n\t\t\t\tif typeof @callbacks.hide is \"function\"\n\t\t\t\t\t@callbacks.hide @$el\n\n\t\t\tisVisible: ->\n\t\t\t\treturn @$el.is \":visible\"\n\n\t\t\tdestroy: (cb = angular.noop)->\n\t\t\t\tscope = @scope\n\t\t\t\t$el = @$el\n\t\t\t\t@hide ->\n\t\t\t\t\tif typeof cb is \"function\"\n\t\t\t\t\t\tcb()\n\t\t\t\t\tscope.$destroy()\n\t\t\t\t\t$el.remove()\n\n\t\t\tstopDestroy: ->\n\t\t\t\t@$el.stop(true).show(\"fast\")\n\n\t\t\treposition: ->\n\t\t\t\ttargetEl = @$el[0]\n\t\t\t\tanchorEl = @$anchor[0]\n\n\t\t\t\tif not (targetEl or anchorEl)\n\t\t\t\t\treturn\n\n\t\t\t\tpos =\n\t\t\t\t\tleft: null\n\t\t\t\t\ttop: null\n\t\t\t\t\ttarget: targetEl.getBoundingClientRect()\n\t\t\t\t\tanchor: anchorEl.getBoundingClientRect()\n\t\t\t\t\tviewport:\n\t\t\t\t\t\twidth: window.innerWidth\n\t\t\t\t\t\theight: window.innerHeight\n\t\t\t\t\tscroll:\n\t\t\t\t\t\ttop: document.body.scrollTop\n\t\t\t\t\t\tleft: document.body.scrollLeft\n\n\t\t\t\tif not (pos.target.width > 0 and pos.target.height > 0)\n\t\t\t\t\treturn\n\n\t\t\t\t# Find first axis position\n\n\t\t\t\tposX = @getNewPositionOnAxis pos, 'x'\n\t\t\t\tposY = @getNewPositionOnAxis pos, 'y'\n\n\t\t\t\tif @preferredAxis is 'x'\n\t\t\t\t\tif posX and typeof posX.pos is 'number'\n\t\t\t\t\t\tpos.left = posX.pos\n\t\t\t\t\t\tpos.edge = posX.edge\n\t\t\t\t\telse if posY\n\t\t\t\t\t\tpos.top = posY.pos\n\t\t\t\t\t\tpos.edge = posY.edge\n\t\t\t\telse\n\t\t\t\t\tif posY and typeof posY.pos is 'number'\n\t\t\t\t\t\tpos.top = posY.pos\n\t\t\t\t\t\tpos.edge = posY.edge\n\t\t\t\t\telse if posX\n\t\t\t\t\t\tpos.left = posX.pos\n\t\t\t\t\t\tpos.edge = posX.edge\n\n\t\t\t\t# Center on second axis\n\n\t\t\t\tif pos.left is null and pos.top is null\n\t\t\t\t\t# Center on X and Y axes\n\t\t\t\t\tpos.left = pos.scroll.left + (pos.viewport.width / 2) - (pos.target.width / 2)\n\t\t\t\t\tpos.top = pos.scroll.top + (pos.viewport.height / 2) - (pos.target.height / 2)\n\t\t\t\telse if pos.left is null\n\t\t\t\t\t# Center on X axis\n\t\t\t\t\tpos.left = @getNewCenterPositionOnAxis pos, 'x'\n\t\t\t\telse if pos.top is null\n\t\t\t\t\t# Center on Y axis\n\t\t\t\t\tpos.top = @getNewCenterPositionOnAxis pos, 'y'\n\n\t\t\t\t@$el\n\t\t\t\t\t.addClass pos.edge && @positionClass.replace \"{{position}}\", pos.edge\n\t\t\t\t\t.css\n\t\t\t\t\t\ttop: Math.round(pos.top) || 0\n\t\t\t\t\t\tleft: Math.round(pos.left) || 0\n\n\t\t\t\treturn\n\n\t\t\tgetNewPositionOnAxis: (pos, axis) ->\n\t\t\t\tstart = {x: 'left', y: 'top'}[axis]\n\t\t\t\tend = {x: 'right', y: 'bottom'}[axis]\n\t\t\t\tsize = {x: 'width', y: 'height'}[axis]\n\t\t\t\tif pos.anchor[start] - @offset >= pos.target[size]\n\t\t\t\t\taxisPos =\n\t\t\t\t\t\tpos: pos.scroll[start] + pos.anchor[start] - @offset - pos.target[size]\n\t\t\t\t\t\tedge: start\n\t\t\t\telse if pos.viewport[size] - pos.anchor[end] - @offset >= pos.target[size]\n\t\t\t\t\taxisPos =\n\t\t\t\t\t\tpos: pos.scroll[start] + pos.anchor[end] + @offset\n\t\t\t\t\t\tedge: end\n\t\t\t\taxisPos\n\n\t\t\tgetNewCenterPositionOnAxis: (pos, axis) ->\n\t\t\t\tstart = {x: 'left', y: 'top'}[axis]\n\t\t\t\tsize = {x: 'width', y: 'height'}[axis]\n\t\t\t\tcenterPos = pos.scroll[start] + pos.anchor[start] + (pos.anchor[size] / 2) - (pos.target[size] / 2)\n\t\t\t\tMath.max(pos.scroll[start] + @offset, Math.min(centerPos, pos.scroll[start] + pos.viewport[size] - pos.target[size] - @offset))\n \nngAnnotateText.factory \"NGAnnotation\", ->\n\tAnnotation = (data)->\n\n\t\tangular.extend @,\n\t\t\tid: annotationIdCounter++,\n\t\t\tstartIndex: null\n\t\t\tendIndex: null\n\t\t\tdata: {}\n\t\t\ttype: \"\"\n\t\t\tchildren: []\n\n\t\tif data?\n\t\t\tangular.extend @, data\n\n\treturn Annotation\n\nngAnnotateText.directive \"ngAnnotateText\", ($rootScope, $compile, $http, $q, $controller, $sce, NGAnnotation, NGAnnotateTextPopup)->\n\trestrict: \"E\"\n\tscope:\n\t\ttext: \"=\"\n\t\tannotations: \"=\"\n\t\treadonly: \"=\"\n\t\tpopupController: \"=\"\n\t\tpopupTemplateUrl: \"=\"\n\t\ttooltipController: \"=\"\n\t\ttooltipTemplateUrl: \"=\"\n\t\tonAnnotate: \"=\"\n\t\tonAnnotateDelete: \"=\"\n\t\tonAnnotateError: \"=\"\n\t\tonPopupShow: \"=\"\n\t\tonPopupHide: \"=\"\n\t\tpopupOffset: \"=\"\n\ttemplate: \"

\"\n\treplace: true\n\n\tcompile: (el, attr) ->\n\t\tattr.readonly ?= false\n\t\t@postLink\n\n\tpostLink: ($scope, element, attrs) ->\n\t\tPOPUP_OFFSET = $scope.popupOffset ? 10\n\n\t\tactivePopup = null\n\t\tactiveTooltip = null\n\n\t\t# Cache the template when we fetch it\n\t\tpopupTemplateData = \"\"\n\t\ttooltipTemplateData = \"\"\n\n\t\tonAnnotationsChange = ->\n\t\t\tif not $scope.text? or !$scope.text.length\n\t\t\t\treturn\n\t\t\tt = parseAnnotations $scope.text, $scope.annotations\n\t\t\t$scope.content = $sce.trustAsHtml t\n\n\t\t# Annotation parsing\n\t\t$scope.$watch \"text\", onAnnotationsChange\n\t\t$scope.$watch \"annotations\", onAnnotationsChange, true\n\n\t\tclearPopup = ->\n\t\t\tif not activePopup?\n\t\t\t\treturn\n\t\t\ttId = activePopup.scope.$annotation.id\n\t\t\tactivePopup.destroy ->\n\t\t\t\tif activePopup.scope.$annotation.id is tId\n\t\t\t\t\tactivePopup = null\n\n\t\tclearTooltip = ->\n\t\t\ttooltip = activeTooltip\n\t\t\tif not tooltip?\n\t\t\t\treturn\n\t\t\ttooltip.destroy ->\n\t\t\t\tif activeTooltip is tooltip\n\t\t\t\t\tactiveTooltip = null\n\n\t\tclearPopups = ->\n\t\t\tclearPopup()\n\t\t\tclearTooltip()\n\n\t\t$scope.$on \"$destroy\", clearPopups\n\t\t$scope.$on \"ngAnnotateText.clearPopups\", clearPopups\n\n\t\tif $scope.popupTemplateUrl\n\t\t\t$http.get($scope.popupTemplateUrl).then (response)->\n\t\t\t\tpopupTemplateData = response.data\n\n\t\tif $scope.tooltipTemplateUrl\n\t\t\t$http.get($scope.tooltipTemplateUrl).then (response)->\n\t\t\t\ttooltipTemplateData = response.data\n\n\t\tremoveChildren = (annotation)->\n\t\t\tfor i in [annotation.children.length - 1..0] by -1\n\t\t\t\ta = annotation.children[i]\n\t\t\t\tremoveChildren a\n\t\t\t\ta.children.splice i, 1\n\n\t\tremoveAnnotation = (id, annotations)->\n\t\t\tfor a, i in annotations\n\t\t\t\tremoveAnnotation id, a.children\n\n\t\t\t\tif a.id is id\n\t\t\t\t\tremoveChildren a\n\t\t\t\t\tannotations.splice i, 1\n\t\t\t\t\treturn\n\n\t\tcreateAnnotation = ->\n\t\t\tannotation = new NGAnnotation()\n\t\t\tsel = window.getSelection()\n\n\t\t\tif sel.isCollapsed\n\t\t\t\tthrow new Error \"NG_ANNOTATE_TEXT_NO_TEXT_SELECTED\"\n\n\t\t\trange = sel.getRangeAt 0\n\n\t\t\tif range.startContainer isnt range.endContainer\n\t\t\t\tthrow new Error \"NG_ANNOTATE_TEXT_PARTIAL_NODE_SELECTED\"\n\n\t\t\tif range.startContainer.parentNode.nodeName is \"SPAN\" # Is a child annotation\n\t\t\t\tparentId = if (attrId = range.startContainer.parentNode.getAttribute(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\t\t\t\tif parentId is undefined\n\t\t\t\t\tthrow new Error \"NG_ANNOTATE_TEXT_ILLEGAL_SELECTION\"\n\t\t\t\tparentAnnotation = getAnnotationById $scope.annotations, parentId\n\n\t\t\t\tannotationParentCollection = parentAnnotation.children\n\t\t\telse\n\t\t\t\tannotationParentCollection = $scope.annotations\n\n\t\t\t# Does this selection has any siblings?\n\t\t\tif annotationParentCollection.length\n\t\t\t\t# Yup, find the previous sibling\n\t\t\t\tprevSiblingSpan = range.startContainer.previousSibling\n\t\t\t\tif prevSiblingSpan?\n\t\t\t\t\tprevSiblingId = if (attrId = prevSiblingSpan.getAttribute(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\t\t\t\t\tif not prevSiblingId?\n\t\t\t\t\t\tthrow new Error \"NG_ANNOTATE_TEXT_ILLEGAL_SELECTION\"\n\n\t\t\t\t\tprevAnnotation = getAnnotationById $scope.annotations, prevSiblingId\n\t\t\t\t\tannotation.startIndex = prevAnnotation.endIndex + range.startOffset\n\t\t\t\t\tannotation.endIndex = prevAnnotation.endIndex + range.endOffset\n\t\t\t\telse\n\t\t\t\t\t# Doesn't have a prev sibling, alrighty then\n\t\t\t\t\tannotation.startIndex = range.startOffset\n\t\t\t\t\tannotation.endIndex = range.endOffset\n\t\t\telse\n\t\t\t\t# Nope\n\t\t\t\tannotation.startIndex = range.startOffset\n\t\t\t\tannotation.endIndex = range.endOffset\n\n\t\t\tannotationParentCollection.push annotation\n\t\t\tclearSelection()\n\t\t\treturn annotation\n\n\t\tclearSelection = ->\n\t\t\tif document.selection\n\t\t\t\tdocument.selection.empty() # Internet Explorer\n\t\t\telse if window.getSelection and window.getSelection().empty\n\t\t\t\twindow.getSelection().empty() # Chrome\n\t\t\telse if window.getSelection and window.getSelection().removeAllRanges\n\t\t\t\twindow.getSelection().removeAllRanges() # Firefox\n\n\t\tonSelect = (event)->\n\t\t\tif popupTemplateData.length is 0\n\t\t\t\treturn\n\n\t\t\ttry\n\t\t\t\tannotation = createAnnotation()\n\t\t\t\t$scope.$apply()\n\t\t\t\t$span = element.find \".ng-annotate-text-\" + annotation.id\n\t\t\tcatch ex\n\t\t\t\tif $scope.onAnnotateError?\n\t\t\t\t\t$scope.onAnnotateError ex\n\n\t\t\t\treturn\n\n\t\t\tclearPopups()\n\n\t\t\tloadAnnotationPopup annotation, $span, true\n\n\t\tonClick = (event)->\n\t\t\tif popupTemplateData.length is 0\n\t\t\t\treturn\n\n\t\t\t$target = angular.element event.target\n\t\t\ttargetId = if (attrId = $target.attr(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\n\t\t\tif not targetId?\n\t\t\t\treturn\n\n\t\t\tif activePopup? and activePopup.scope.$annotation.id is targetId\n\t\t\t\tclearPopup()\n\t\t\t\treturn\n\t\t\tannotation = getAnnotationById $scope.annotations, targetId\n\n\t\t\tclearPopups()\n\n\t\t\tloadAnnotationPopup annotation, $target, false\n\n\t\tonMouseEnter = (event)->\n\t\t\tif tooltipTemplateData.length is 0\n\t\t\t\treturn\n\n\t\t\tevent.stopPropagation()\n\t\t\t$target = angular.element event.target\n\t\t\ttargetId = if (attrId = $target.attr(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\n\t\t\tif activeTooltip? and activeTooltip.scope.$annotation.id is targetId\n\t\t\t\tactiveTooltip.stopDestroy()\n\t\t\t\treturn\n\t\t\telse\n\t\t\t\tclearTooltip()\n\n\t\t\tif not targetId?\n\t\t\t\treturn\n\n\t\t\tannotation = getAnnotationById $scope.annotations, targetId\n\n\t\t\t# We don't want to show the tooltip if a popup with the annotation is open,\n\t\t\t# or if the tooltip has both no comment and points\n\t\t\tif activePopup? or isEmptyObject(annotation.data)\n\t\t\t\treturn\n\n\t\t\ttooltip = new NGAnnotateTextPopup\n\t\t\t\tscope: $rootScope.$new()\n\t\t\t\ttemplate: \"
\"\n\t\t\t\tpositionClass: \"ng-annotate-text-tooltip-docked ng-annotate-text-tooltip-docked-{{position}}\"\n\t\t\t\t$anchor: $target\n\t\t\t\tpreferredAxis: 'y'\n\t\t\t\toffset: POPUP_OFFSET\n\t\t\ttooltip.scope.$annotation = annotation\n\n\t\t\tactiveTooltip = tooltip\n\n\t\t\tlocals =\n\t\t\t\t$scope: tooltip.scope\n\t\t\t\t$template: tooltipTemplateData\n\n\t\t\ttooltip.$el.html locals.$template\n\t\t\ttooltip.$el.appendTo \"body\"\n\n\t\t\tif $scope.tooltipController\n\t\t\t\tcontroller = $controller $scope.tooltipController, locals\n\t\t\t\ttooltip.$el.data \"$ngControllerController\", controller\n\t\t\t\ttooltip.$el.children().data \"$ngControllerController\", controller\n\n\t\t\t$compile(tooltip.$el) tooltip.scope\n\t\t\ttooltip.scope.$apply()\n\t\t\ttooltip.show()\n\n\t\tonMouseLeave = (event)->\n\t\t\tevent.stopPropagation()\n\n\t\t\t$target = angular.element event.target\n\t\t\ttargetId = if (attrId = $target.attr(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\n\t\t\tif not targetId?\n\t\t\t\treturn\n\n\t\t\tclearTooltip()\n\n\t\tloadAnnotationPopup = (annotation, anchor, isNew)->\n\t\t\tpopup = new NGAnnotateTextPopup\n\t\t\t\tscope: $rootScope.$new()\n\t\t\t\tcallbacks:\n\t\t\t\t\tshow: $scope.onPopupShow\n\t\t\t\t\thide: $scope.onPopupHide\n\t\t\t\ttemplate: \"
\"\n\t\t\t\tpositionClass: \"ng-annotate-text-popup-docked ng-annotate-text-popup-docked-{{position}}\"\n\t\t\t\t$anchor: anchor\n\t\t\t\toffset: POPUP_OFFSET\n\n\t\t\tpopup.scope.$isNew = isNew\n\t\t\tpopup.scope.$annotation = annotation\n\t\t\tpopup.scope.$readonly = $scope.readonly\n\n\t\t\tpopup.scope.$reject = ->\n\t\t\t\tremoveAnnotation annotation.id, $scope.annotations\n\n\t\t\t\tif $scope.onAnnotateDelete?\n\t\t\t\t\t$scope.onAnnotateDelete annotation\n\t\t\t\tclearPopup()\n\t\t\t\treturn\n\n\t\t\tpopup.scope.$close = ->\n\t\t\t\tif $scope.onAnnotate?\n\t\t\t\t\t$scope.onAnnotate popup.scope.$annotation\n\t\t\t\tclearPopup()\n\t\t\t\treturn\n\n\t\t\tactivePopup = popup\n\n\t\t\tlocals =\n\t\t\t\t$scope: popup.scope\n\t\t\t\t$template: popupTemplateData\n\n\t\t\tpopup.$el.html locals.$template\n\t\t\tpopup.$el.appendTo \"body\"\n\n\t\t\tif $scope.popupController\n\t\t\t\tcontroller = $controller $scope.popupController, locals\n\t\t\t\tpopup.$el.data \"$ngControllerController\", controller\n\t\t\t\tpopup.$el.children().data \"$ngControllerController\", controller\n\n\t\t\t$compile(popup.$el) popup.scope\n\t\t\tpopup.scope.$apply()\n\t\t\tpopup.show()\n\n\t\telement.on \"mouseenter\", \"span\", onMouseEnter\n\t\telement.on \"mouseleave\", \"span\", onMouseLeave\n\n\t\telement.on \"mouseup\", (event)->\n\t\t\t# We need to determine if the user actually selected something\n\t\t\t# or if he just clicked on an annotation\n\t\t\tselection = window.getSelection()\n\t\t\tif !selection.isCollapsed and !$scope.readonly\n\t\t\t\t# User has selected something\n\t\t\t\tonSelect event\n\t\t\telse if selection.isCollapsed and event.target.nodeName is \"SPAN\"\n\t\t\t\tonClick event\n\t\t\telse if selection.isCollapsed\n\t\t\t\tclearPopups()\n"]} \ No newline at end of file diff --git a/dist/ng-annotate-text-latest.min.js b/dist/ng-annotate-text-latest.min.js index 8790b17..8d42860 100644 --- a/dist/ng-annotate-text-latest.min.js +++ b/dist/ng-annotate-text-latest.min.js @@ -1,2 +1,2 @@ -(function(){var annotationIdCounter,getAnnotationById,insertAt,ngAnnotateText,parseAnnotations,sortAnnotationsByEndIndex;ngAnnotateText=angular.module("ngAnnotateText",[]),annotationIdCounter=0,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}},ngAnnotateText.factory("NGAnnotateTextPopup",function(){return function(args){return args=angular.extend({scope:null,callbacks:{},template:"
",$anchor:null,preferredAxis:"x",offset:0,positionClass:"{{position}}"},args),angular.extend(this,args,{$el:angular.element(args.template),show:function(speed){return null==speed&&(speed="fast"),this.$el.fadeIn(speed),this.reposition(),"function"==typeof this.callbacks.show?this.callbacks.show(this.$el):void 0},hide:function(speed){return null==speed&&(speed="fast"),this.$el.fadeOut(speed),"function"==typeof this.callbacks.hide?this.callbacks.hide(this.$el):void 0},isVisible:function(){return this.$el.is(":visible")},destroy:function(cb){var $el,scope;return null==cb&&(cb=angular.noop),scope=this.scope,$el=this.$el,this.hide(function(){return"function"==typeof cb&&cb(),scope.$destroy(),$el.remove()})},stopDestroy:function(){return this.$el.stop(!0).show("fast")},reposition:function(){var anchorEl,pos,posX,posY,targetEl;targetEl=this.$el[0],anchorEl=this.$anchor[0],(targetEl||anchorEl)&&(pos={left:null,top:null,target:targetEl.getBoundingClientRect(),anchor:anchorEl.getBoundingClientRect(),viewport:{width:window.innerWidth,height:window.innerHeight},scroll:{top:document.body.scrollTop,left:document.body.scrollLeft}},pos.target.width>0&&pos.target.height>0&&(posX=this.getNewPositionOnAxis(pos,"x"),posY=this.getNewPositionOnAxis(pos,"y"),"x"===this.preferredAxis?posX&&"number"==typeof posX.pos?(pos.left=posX.pos,pos.edge=posX.edge):posY&&(pos.top=posY.pos,pos.edge=posY.edge):posY&&"number"==typeof posY.pos?(pos.top=posY.pos,pos.edge=posY.edge):posX&&(pos.left=posX.pos,pos.edge=posX.edge),null===pos.left&&null===pos.top?(pos.left=pos.scroll.left+pos.viewport.width/2-pos.target.width/2,pos.top=pos.scroll.top+pos.viewport.height/2-pos.target.height/2):null===pos.left?pos.left=this.getNewCenterPositionOnAxis(pos,"x"):null===pos.top&&(pos.top=this.getNewCenterPositionOnAxis(pos,"y")),this.$el.addClass(pos.edge&&this.positionClass.replace("{{position}}",pos.edge)).css({top:Math.round(pos.top)||0,left:Math.round(pos.left)||0})))},getNewPositionOnAxis:function(pos,axis){var axisPos,end,size,start;return start={x:"left",y:"top"}[axis],end={x:"right",y:"bottom"}[axis],size={x:"width",y:"height"}[axis],pos.anchor[start]-this.offset>=pos.target[size]?axisPos={pos:pos.scroll[start]+pos.anchor[start]-this.offset-pos.target[size],edge:start}:pos.viewport[size]-pos.anchor[end]-this.offset>=pos.target[size]&&(axisPos={pos:pos.scroll[start]+pos.anchor[end]+this.offset,edge:end}),axisPos},getNewCenterPositionOnAxis:function(pos,axis){var centerPos,size,start;return start={x:"left",y:"top"}[axis],size={x:"width",y:"height"}[axis],centerPos=pos.scroll[start]+pos.anchor[start]+pos.anchor[size]/2-pos.target[size]/2,Math.max(pos.scroll[start]+this.offset,Math.min(centerPos,pos.scroll[start]+pos.viewport[size]-pos.target[size]-this.offset))}})}}),ngAnnotateText.factory("NGAnnotation",function(){var Annotation;return Annotation=function(data){return angular.extend(this,{id:annotationIdCounter++,startIndex:null,endIndex:null,data:{points:0},type:"",children:[]}),null!=data?angular.extend(this,data):void 0}}),ngAnnotateText.directive("ngAnnotateText",function($rootScope,$compile,$http,$q,$controller,$sce,NGAnnotation,NGAnnotateTextPopup){return{restrict:"E",scope:{text:"=",annotations:"=",readonly:"=",popupController:"=",popupTemplateUrl:"=",tooltipController:"=",tooltipTemplateUrl:"=",onAnnotate:"=",onAnnotateDelete:"=",onAnnotateError:"=",onPopupShow:"=",onPopupHide:"=",popupOffset:"="},template:'

',replace:!0,compile:function(el,attr){return null==attr.readonly&&(attr.readonly=!1),this.postLink},postLink:function($scope,element){var POPUP_OFFSET,activePopup,activeTooltip,clearPopup,clearPopups,clearSelection,clearTooltip,createAnnotation,loadAnnotationPopup,onAnnotationsChange,onClick,onMouseEnter,onMouseLeave,onSelect,popupTemplateData,removeAnnotation,removeChildren,tooltipTemplateData,_ref;return POPUP_OFFSET=null!=(_ref=$scope.popupOffset)?_ref:10,activePopup=null,activeTooltip=null,popupTemplateData="",tooltipTemplateData="",onAnnotationsChange=function(){var t;if(null!=$scope.text&&$scope.text.length)return t=parseAnnotations($scope.text,$scope.annotations),$scope.content=$sce.trustAsHtml(t)},$scope.$watch("text",onAnnotationsChange),$scope.$watch("annotations",onAnnotationsChange,!0),clearPopup=function(){var tId;if(null!=activePopup)return tId=activePopup.scope.$annotation.id,activePopup.destroy(function(){return activePopup.scope.$annotation.id===tId?activePopup=null:void 0})},clearTooltip=function(){var tooltip;return tooltip=activeTooltip,null!=tooltip?tooltip.destroy(function(){return activeTooltip===tooltip?activeTooltip=null:void 0}):void 0},clearPopups=function(){return clearPopup(),clearTooltip()},$scope.$on("$destroy",clearPopups),$scope.$on("ngAnnotateText.clearPopups",clearPopups),$scope.popupTemplateUrl&&$http.get($scope.popupTemplateUrl).then(function(response){return popupTemplateData=response.data}),$scope.tooltipTemplateUrl&&$http.get($scope.tooltipTemplateUrl).then(function(response){return tooltipTemplateData=response.data}),removeChildren=function(annotation){var a,i,_i,_ref1,_results;for(_results=[],i=_i=_ref1=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(),sel.isCollapsed)throw new Error("NG_ANNOTATE_TEXT_NO_TEXT_SELECTED");if(range=sel.getRangeAt(0),range.startContainer!==range.endContainer)throw new Error("NG_ANNOTATE_TEXT_PARTIAL_NODE_SELECTED");if("SPAN"===range.startContainer.parentNode.nodeName){if(parentId=null!=(attrId=range.startContainer.parentNode.getAttribute("data-annotation-id"))?parseInt(attrId,10):void 0,void 0===parentId)throw new Error("NG_ANNOTATE_TEXT_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_TEXT_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),clearSelection(),annotation},clearSelection=function(){return document.selection?document.selection.empty():window.getSelection&&window.getSelection().empty?window.getSelection().empty():window.getSelection&&window.getSelection().removeAllRanges?window.getSelection().removeAllRanges():void 0},onSelect=function(){var $span,annotation,ex;if(0!==popupTemplateData.length){try{annotation=createAnnotation(),$scope.$apply(),$span=element.find(".ng-annotate-text-"+annotation.id)}catch(_error){return ex=_error,void(null!=$scope.onAnnotateError&&$scope.onAnnotateError(ex))}return clearPopups(),loadAnnotationPopup(annotation,$span,!0)}},onClick=function(event){var $target,annotation,attrId,targetId;if(0!==popupTemplateData.length&&($target=angular.element(event.target),targetId=null!=(attrId=$target.attr("data-annotation-id"))?parseInt(attrId,10):void 0,null!=targetId))return null!=activePopup&&activePopup.scope.$annotation.id===targetId?void clearPopup():(annotation=getAnnotationById($scope.annotations,targetId),clearPopups(),loadAnnotationPopup(annotation,$target,!1))},onMouseEnter=function(event){var $target,annotation,attrId,controller,locals,targetId,tooltip;if(0!==tooltipTemplateData.length){if(event.stopPropagation(),$target=angular.element(event.target),targetId=null!=(attrId=$target.attr("data-annotation-id"))?parseInt(attrId,10):void 0,null!=activeTooltip&&activeTooltip.scope.$annotation.id===targetId)return void activeTooltip.stopDestroy();if(clearTooltip(),null!=targetId&&(annotation=getAnnotationById($scope.annotations,targetId),null==activePopup&&(annotation.data.comment||annotation.data.points)))return tooltip=new NGAnnotateTextPopup({scope:$rootScope.$new(),template:"
",positionClass:"ng-annotate-text-tooltip-docked ng-annotate-text-tooltip-docked-{{position}}",$anchor:$target,preferredAxis:"y",offset:POPUP_OFFSET}),tooltip.scope.$annotation=annotation,activeTooltip=tooltip,locals={$scope:tooltip.scope,$template:tooltipTemplateData},tooltip.$el.html(locals.$template),tooltip.$el.appendTo("body"),$scope.tooltipController&&(controller=$controller($scope.tooltipController,locals),tooltip.$el.data("$ngControllerController",controller),tooltip.$el.children().data("$ngControllerController",controller)),$compile(tooltip.$el)(tooltip.scope),tooltip.scope.$apply(),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?clearTooltip():void 0},loadAnnotationPopup=function(annotation,anchor,isNew){var controller,locals,popup;return popup=new NGAnnotateTextPopup({scope:$rootScope.$new(),callbacks:{show:$scope.onPopupShow,hide:$scope.onPopupHide},template:"
",positionClass:"ng-annotate-text-popup-docked ng-annotate-text-popup-docked-{{position}}",$anchor:anchor,offset:POPUP_OFFSET}),popup.scope.$isNew=isNew,popup.scope.$annotation=annotation,popup.scope.$readonly=$scope.readonly,popup.scope.$reject=function(){removeAnnotation(annotation.id,$scope.annotations),null!=$scope.onAnnotateDelete&&$scope.onAnnotateDelete(annotation),clearPopup()},popup.scope.$close=function(){null!=$scope.onAnnotate&&$scope.onAnnotate(popup.scope.$annotation),clearPopup()},activePopup=popup,locals={$scope:popup.scope,$template:popupTemplateData},popup.$el.html(locals.$template),popup.$el.appendTo("body"),$scope.popupController&&(controller=$controller($scope.popupController,locals),popup.$el.data("$ngControllerController",controller),popup.$el.children().data("$ngControllerController",controller)),$compile(popup.$el)(popup.scope),popup.scope.$apply(),popup.show()},element.on("mouseenter","span",onMouseEnter),element.on("mouseleave","span",onMouseLeave),element.on("mouseup",function(event){var selection;return selection=window.getSelection(),selection.isCollapsed||$scope.readonly?selection.isCollapsed&&"SPAN"===event.target.nodeName?onClick(event):selection.isCollapsed?clearPopups():void 0:onSelect(event)})}}})}).call(this); +(function(){var annotationIdCounter,getAnnotationById,insertAt,isEmptyObject,ngAnnotateText,parseAnnotations,sortAnnotationsByEndIndex;ngAnnotateText=angular.module("ngAnnotateText",[]),annotationIdCounter=0,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}},isEmptyObject=function(obj){var prop;for(prop in obj)if(Object.prototype.hasOwnProperty.call(obj,prop))return!1;return!0},ngAnnotateText.factory("NGAnnotateTextPopup",function(){return function(args){return args=angular.extend({scope:null,callbacks:{},template:"
",$anchor:null,preferredAxis:"x",offset:0,positionClass:"{{position}}"},args),angular.extend(this,args,{$el:angular.element(args.template),show:function(speed){return null==speed&&(speed="fast"),this.$el.fadeIn(speed),this.reposition(),"function"==typeof this.callbacks.show?this.callbacks.show(this.$el):void 0},hide:function(speed){return null==speed&&(speed="fast"),this.$el.fadeOut(speed),"function"==typeof this.callbacks.hide?this.callbacks.hide(this.$el):void 0},isVisible:function(){return this.$el.is(":visible")},destroy:function(cb){var $el,scope;return null==cb&&(cb=angular.noop),scope=this.scope,$el=this.$el,this.hide(function(){return"function"==typeof cb&&cb(),scope.$destroy(),$el.remove()})},stopDestroy:function(){return this.$el.stop(!0).show("fast")},reposition:function(){var anchorEl,pos,posX,posY,targetEl;targetEl=this.$el[0],anchorEl=this.$anchor[0],(targetEl||anchorEl)&&(pos={left:null,top:null,target:targetEl.getBoundingClientRect(),anchor:anchorEl.getBoundingClientRect(),viewport:{width:window.innerWidth,height:window.innerHeight},scroll:{top:document.body.scrollTop,left:document.body.scrollLeft}},pos.target.width>0&&pos.target.height>0&&(posX=this.getNewPositionOnAxis(pos,"x"),posY=this.getNewPositionOnAxis(pos,"y"),"x"===this.preferredAxis?posX&&"number"==typeof posX.pos?(pos.left=posX.pos,pos.edge=posX.edge):posY&&(pos.top=posY.pos,pos.edge=posY.edge):posY&&"number"==typeof posY.pos?(pos.top=posY.pos,pos.edge=posY.edge):posX&&(pos.left=posX.pos,pos.edge=posX.edge),null===pos.left&&null===pos.top?(pos.left=pos.scroll.left+pos.viewport.width/2-pos.target.width/2,pos.top=pos.scroll.top+pos.viewport.height/2-pos.target.height/2):null===pos.left?pos.left=this.getNewCenterPositionOnAxis(pos,"x"):null===pos.top&&(pos.top=this.getNewCenterPositionOnAxis(pos,"y")),this.$el.addClass(pos.edge&&this.positionClass.replace("{{position}}",pos.edge)).css({top:Math.round(pos.top)||0,left:Math.round(pos.left)||0})))},getNewPositionOnAxis:function(pos,axis){var axisPos,end,size,start;return start={x:"left",y:"top"}[axis],end={x:"right",y:"bottom"}[axis],size={x:"width",y:"height"}[axis],pos.anchor[start]-this.offset>=pos.target[size]?axisPos={pos:pos.scroll[start]+pos.anchor[start]-this.offset-pos.target[size],edge:start}:pos.viewport[size]-pos.anchor[end]-this.offset>=pos.target[size]&&(axisPos={pos:pos.scroll[start]+pos.anchor[end]+this.offset,edge:end}),axisPos},getNewCenterPositionOnAxis:function(pos,axis){var centerPos,size,start;return start={x:"left",y:"top"}[axis],size={x:"width",y:"height"}[axis],centerPos=pos.scroll[start]+pos.anchor[start]+pos.anchor[size]/2-pos.target[size]/2,Math.max(pos.scroll[start]+this.offset,Math.min(centerPos,pos.scroll[start]+pos.viewport[size]-pos.target[size]-this.offset))}})}}),ngAnnotateText.factory("NGAnnotation",function(){var Annotation;return Annotation=function(data){return angular.extend(this,{id:annotationIdCounter++,startIndex:null,endIndex:null,data:{},type:"",children:[]}),null!=data?angular.extend(this,data):void 0}}),ngAnnotateText.directive("ngAnnotateText",function($rootScope,$compile,$http,$q,$controller,$sce,NGAnnotation,NGAnnotateTextPopup){return{restrict:"E",scope:{text:"=",annotations:"=",readonly:"=",popupController:"=",popupTemplateUrl:"=",tooltipController:"=",tooltipTemplateUrl:"=",onAnnotate:"=",onAnnotateDelete:"=",onAnnotateError:"=",onPopupShow:"=",onPopupHide:"=",popupOffset:"="},template:'

',replace:!0,compile:function(el,attr){return null==attr.readonly&&(attr.readonly=!1),this.postLink},postLink:function($scope,element){var POPUP_OFFSET,activePopup,activeTooltip,clearPopup,clearPopups,clearSelection,clearTooltip,createAnnotation,loadAnnotationPopup,onAnnotationsChange,onClick,onMouseEnter,onMouseLeave,onSelect,popupTemplateData,removeAnnotation,removeChildren,tooltipTemplateData,_ref;return POPUP_OFFSET=null!=(_ref=$scope.popupOffset)?_ref:10,activePopup=null,activeTooltip=null,popupTemplateData="",tooltipTemplateData="",onAnnotationsChange=function(){var t;if(null!=$scope.text&&$scope.text.length)return t=parseAnnotations($scope.text,$scope.annotations),$scope.content=$sce.trustAsHtml(t)},$scope.$watch("text",onAnnotationsChange),$scope.$watch("annotations",onAnnotationsChange,!0),clearPopup=function(){var tId;if(null!=activePopup)return tId=activePopup.scope.$annotation.id,activePopup.destroy(function(){return activePopup.scope.$annotation.id===tId?activePopup=null:void 0})},clearTooltip=function(){var tooltip;return tooltip=activeTooltip,null!=tooltip?tooltip.destroy(function(){return activeTooltip===tooltip?activeTooltip=null:void 0}):void 0},clearPopups=function(){return clearPopup(),clearTooltip()},$scope.$on("$destroy",clearPopups),$scope.$on("ngAnnotateText.clearPopups",clearPopups),$scope.popupTemplateUrl&&$http.get($scope.popupTemplateUrl).then(function(response){return popupTemplateData=response.data}),$scope.tooltipTemplateUrl&&$http.get($scope.tooltipTemplateUrl).then(function(response){return tooltipTemplateData=response.data}),removeChildren=function(annotation){var a,i,_i,_ref1,_results;for(_results=[],i=_i=_ref1=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),annotations.splice(i,1),void 0},createAnnotation=function(){var annotation,annotationParentCollection,attrId,parentAnnotation,parentId,prevAnnotation,prevSiblingId,prevSiblingSpan,range,sel;if(annotation=new NGAnnotation,sel=window.getSelection(),sel.isCollapsed)throw new Error("NG_ANNOTATE_TEXT_NO_TEXT_SELECTED");if(range=sel.getRangeAt(0),range.startContainer!==range.endContainer)throw new Error("NG_ANNOTATE_TEXT_PARTIAL_NODE_SELECTED");if("SPAN"===range.startContainer.parentNode.nodeName){if(parentId=null!=(attrId=range.startContainer.parentNode.getAttribute("data-annotation-id"))?parseInt(attrId,10):void 0,void 0===parentId)throw new Error("NG_ANNOTATE_TEXT_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_TEXT_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),clearSelection(),annotation},clearSelection=function(){return document.selection?document.selection.empty():window.getSelection&&window.getSelection().empty?window.getSelection().empty():window.getSelection&&window.getSelection().removeAllRanges?window.getSelection().removeAllRanges():void 0},onSelect=function(){var $span,annotation,ex;if(0!==popupTemplateData.length){try{annotation=createAnnotation(),$scope.$apply(),$span=element.find(".ng-annotate-text-"+annotation.id)}catch(_error){return ex=_error,null!=$scope.onAnnotateError&&$scope.onAnnotateError(ex),void 0}return clearPopups(),loadAnnotationPopup(annotation,$span,!0)}},onClick=function(event){var $target,annotation,attrId,targetId;if(0!==popupTemplateData.length&&($target=angular.element(event.target),targetId=null!=(attrId=$target.attr("data-annotation-id"))?parseInt(attrId,10):void 0,null!=targetId))return null!=activePopup&&activePopup.scope.$annotation.id===targetId?(clearPopup(),void 0):(annotation=getAnnotationById($scope.annotations,targetId),clearPopups(),loadAnnotationPopup(annotation,$target,!1))},onMouseEnter=function(event){var $target,annotation,attrId,controller,locals,targetId,tooltip;if(0!==tooltipTemplateData.length){if(event.stopPropagation(),$target=angular.element(event.target),targetId=null!=(attrId=$target.attr("data-annotation-id"))?parseInt(attrId,10):void 0,null!=activeTooltip&&activeTooltip.scope.$annotation.id===targetId)return activeTooltip.stopDestroy(),void 0;if(clearTooltip(),null!=targetId&&(annotation=getAnnotationById($scope.annotations,targetId),null==activePopup&&!isEmptyObject(annotation.data)))return tooltip=new NGAnnotateTextPopup({scope:$rootScope.$new(),template:"
",positionClass:"ng-annotate-text-tooltip-docked ng-annotate-text-tooltip-docked-{{position}}",$anchor:$target,preferredAxis:"y",offset:POPUP_OFFSET}),tooltip.scope.$annotation=annotation,activeTooltip=tooltip,locals={$scope:tooltip.scope,$template:tooltipTemplateData},tooltip.$el.html(locals.$template),tooltip.$el.appendTo("body"),$scope.tooltipController&&(controller=$controller($scope.tooltipController,locals),tooltip.$el.data("$ngControllerController",controller),tooltip.$el.children().data("$ngControllerController",controller)),$compile(tooltip.$el)(tooltip.scope),tooltip.scope.$apply(),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?clearTooltip():void 0},loadAnnotationPopup=function(annotation,anchor,isNew){var controller,locals,popup;return popup=new NGAnnotateTextPopup({scope:$rootScope.$new(),callbacks:{show:$scope.onPopupShow,hide:$scope.onPopupHide},template:"
",positionClass:"ng-annotate-text-popup-docked ng-annotate-text-popup-docked-{{position}}",$anchor:anchor,offset:POPUP_OFFSET}),popup.scope.$isNew=isNew,popup.scope.$annotation=annotation,popup.scope.$readonly=$scope.readonly,popup.scope.$reject=function(){removeAnnotation(annotation.id,$scope.annotations),null!=$scope.onAnnotateDelete&&$scope.onAnnotateDelete(annotation),clearPopup()},popup.scope.$close=function(){null!=$scope.onAnnotate&&$scope.onAnnotate(popup.scope.$annotation),clearPopup()},activePopup=popup,locals={$scope:popup.scope,$template:popupTemplateData},popup.$el.html(locals.$template),popup.$el.appendTo("body"),$scope.popupController&&(controller=$controller($scope.popupController,locals),popup.$el.data("$ngControllerController",controller),popup.$el.children().data("$ngControllerController",controller)),$compile(popup.$el)(popup.scope),popup.scope.$apply(),popup.show()},element.on("mouseenter","span",onMouseEnter),element.on("mouseleave","span",onMouseLeave),element.on("mouseup",function(event){var selection;return selection=window.getSelection(),selection.isCollapsed||$scope.readonly?selection.isCollapsed&&"SPAN"===event.target.nodeName?onClick(event):selection.isCollapsed?clearPopups():void 0:onSelect(event)})}}})}).call(this); //# sourceMappingURL=ng-annotate-text-latest.min.js.map \ No newline at end of file diff --git a/dist/ng-annotate-text-latest.min.js.map b/dist/ng-annotate-text-latest.min.js.map index 1762333..9143dbe 100644 --- a/dist/ng-annotate-text-latest.min.js.map +++ b/dist/ng-annotate-text-latest.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ng-annotate-text-latest.min.js","sources":["ng-annotate-text.coffee"],"names":[],"mappings":"CAAA,WAAA,GAAA,qBAAA,kBAAA,SAAA,eAAA,iBAAA,yBAAA,gBAAiB,QAAQ,OAAO,qBAEhC,oBAAsB,EAEtB,SAAW,SAAC,KAAM,MAAO,QACxB,MAAO,MAAK,OAAO,EAAG,OAAS,OAAS,KAAK,OAAO,QAErD,0BAA4B,SAAC,aAC5B,MAAO,aAAY,KAAK,SAAC,EAAG,GAC3B,MAAG,GAAE,SAAW,EAAE,SACV,GACA,EAAE,SAAW,EAAE,SACf,EACD,KAET,iBAAmB,SAAC,KAAM,YAAkB,aAC3C,GAAA,YAAA,EAAA,GAAA,IAA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OAAO,eAChB,UAAW,aAAgB,OAAQ,SAG9B,UAAU,aAAyC,SAAzB,MAAM,OAAO,SAC9C,QAAQ,OACD,UAAU,YACjB,cADI,OAHJ,SAAS","sourcesContent":["ngAnnotateText = angular.module \"ngAnnotateText\", []\n\nannotationIdCounter = 0\n\ninsertAt = (text, index, string)->\n\treturn text.substr(0, index) + string + text.substr(index)\n\nsortAnnotationsByEndIndex = (annotations)->\n\treturn annotations.sort (a, b)->\n\t\tif a.endIndex < b.endIndex\n\t\t\treturn -1\n\t\telse if a.endIndex > b.endIndex\n\t\t\treturn 1\n\t\treturn 0\n\nparseAnnotations = (text, annotations = [], indexOffset = 0)->\n\tif annotations.length is 0\n\t\treturn text\n\tannotations = sortAnnotationsByEndIndex annotations\n\n\tfor i in [annotations.length - 1..0] by -1\n\t\tannotation = annotations[i];\n\t\ttext = insertAt text, annotation.endIndex + indexOffset, \"\"\n\t\tif annotation.children.length\n\t\t\ttext = parseAnnotations text, annotation.children, annotation.startIndex + indexOffset\n\t\ttext = insertAt text, annotation.startIndex + indexOffset, \"\"\n\treturn text\n\ngetAnnotationById = (annotations, aId)->\n\tfor a in annotations\n\t\tif aId is a.id\n\t\t\treturn a\n\t\tif a.children.length > 0\n\t\t\tan = getAnnotationById a.children, aId\n\t\t\tif an isnt undefined\n\t\t\t\treturn an\n\nngAnnotateText.factory \"NGAnnotateTextPopup\", ->\n\t(args) ->\n\t\targs = angular.extend {\n\t\t\tscope: null,\n\t\t\tcallbacks: {},\n\t\t\ttemplate: \"
\"\n\t\t\t$anchor: null\n\t\t\tpreferredAxis: 'x'\n\t\t\toffset: 0\n\t\t\tpositionClass: '{{position}}'\n\t\t}, args\n\n\t\tangular.extend @, args,\n\t\t\t$el: angular.element args.template\n\n\t\t\tshow: (speed = \"fast\") ->\n\t\t\t\t@$el.fadeIn speed\n\t\t\t\t@reposition()\n\t\t\t\tif typeof @callbacks.show is \"function\"\n\t\t\t\t\t@callbacks.show @$el\n\n\t\t\thide: (speed = \"fast\")->\n\t\t\t\t@$el.fadeOut speed\n\t\t\t\tif typeof @callbacks.hide is \"function\"\n\t\t\t\t\t@callbacks.hide @$el\n\n\t\t\tisVisible: ->\n\t\t\t\treturn @$el.is \":visible\"\n\n\t\t\tdestroy: (cb = angular.noop)->\n\t\t\t\tscope = @scope\n\t\t\t\t$el = @$el\n\t\t\t\t@hide ->\n\t\t\t\t\tif typeof cb is \"function\"\n\t\t\t\t\t\tcb()\n\t\t\t\t\tscope.$destroy()\n\t\t\t\t\t$el.remove()\n\n\t\t\tstopDestroy: ->\n\t\t\t\t@$el.stop(true).show(\"fast\")\n\n\t\t\treposition: ->\n\t\t\t\ttargetEl = @$el[0]\n\t\t\t\tanchorEl = @$anchor[0]\n\n\t\t\t\tif not (targetEl or anchorEl)\n\t\t\t\t\treturn\n\n\t\t\t\tpos =\n\t\t\t\t\tleft: null\n\t\t\t\t\ttop: null\n\t\t\t\t\ttarget: targetEl.getBoundingClientRect()\n\t\t\t\t\tanchor: anchorEl.getBoundingClientRect()\n\t\t\t\t\tviewport:\n\t\t\t\t\t\twidth: window.innerWidth\n\t\t\t\t\t\theight: window.innerHeight\n\t\t\t\t\tscroll:\n\t\t\t\t\t\ttop: document.body.scrollTop\n\t\t\t\t\t\tleft: document.body.scrollLeft\n\n\t\t\t\tif not (pos.target.width > 0 and pos.target.height > 0)\n\t\t\t\t\treturn\n\n\t\t\t\t# Find first axis position\n\n\t\t\t\tposX = @getNewPositionOnAxis pos, 'x'\n\t\t\t\tposY = @getNewPositionOnAxis pos, 'y'\n\n\t\t\t\tif @preferredAxis is 'x'\n\t\t\t\t\tif posX and typeof posX.pos is 'number'\n\t\t\t\t\t\tpos.left = posX.pos\n\t\t\t\t\t\tpos.edge = posX.edge\n\t\t\t\t\telse if posY\n\t\t\t\t\t\tpos.top = posY.pos\n\t\t\t\t\t\tpos.edge = posY.edge\n\t\t\t\telse\n\t\t\t\t\tif posY and typeof posY.pos is 'number'\n\t\t\t\t\t\tpos.top = posY.pos\n\t\t\t\t\t\tpos.edge = posY.edge\n\t\t\t\t\telse if posX\n\t\t\t\t\t\tpos.left = posX.pos\n\t\t\t\t\t\tpos.edge = posX.edge\n\n\t\t\t\t# Center on second axis\n\n\t\t\t\tif pos.left is null and pos.top is null\n\t\t\t\t\t# Center on X and Y axes\n\t\t\t\t\tpos.left = pos.scroll.left + (pos.viewport.width / 2) - (pos.target.width / 2)\n\t\t\t\t\tpos.top = pos.scroll.top + (pos.viewport.height / 2) - (pos.target.height / 2)\n\t\t\t\telse if pos.left is null\n\t\t\t\t\t# Center on X axis\n\t\t\t\t\tpos.left = @getNewCenterPositionOnAxis pos, 'x'\n\t\t\t\telse if pos.top is null\n\t\t\t\t\t# Center on Y axis\n\t\t\t\t\tpos.top = @getNewCenterPositionOnAxis pos, 'y'\n\n\t\t\t\t@$el\n\t\t\t\t\t.addClass pos.edge && @positionClass.replace \"{{position}}\", pos.edge\n\t\t\t\t\t.css\n\t\t\t\t\t\ttop: Math.round(pos.top) || 0\n\t\t\t\t\t\tleft: Math.round(pos.left) || 0\n\n\t\t\t\treturn\n\n\t\t\tgetNewPositionOnAxis: (pos, axis) ->\n\t\t\t\tstart = {x: 'left', y: 'top'}[axis]\n\t\t\t\tend = {x: 'right', y: 'bottom'}[axis]\n\t\t\t\tsize = {x: 'width', y: 'height'}[axis]\n\t\t\t\tif pos.anchor[start] - @offset >= pos.target[size]\n\t\t\t\t\taxisPos =\n\t\t\t\t\t\tpos: pos.scroll[start] + pos.anchor[start] - @offset - pos.target[size]\n\t\t\t\t\t\tedge: start\n\t\t\t\telse if pos.viewport[size] - pos.anchor[end] - @offset >= pos.target[size]\n\t\t\t\t\taxisPos =\n\t\t\t\t\t\tpos: pos.scroll[start] + pos.anchor[end] + @offset\n\t\t\t\t\t\tedge: end\n\t\t\t\taxisPos\n\n\t\t\tgetNewCenterPositionOnAxis: (pos, axis) ->\n\t\t\t\tstart = {x: 'left', y: 'top'}[axis]\n\t\t\t\tsize = {x: 'width', y: 'height'}[axis]\n\t\t\t\tcenterPos = pos.scroll[start] + pos.anchor[start] + (pos.anchor[size] / 2) - (pos.target[size] / 2)\n\t\t\t\tMath.max(pos.scroll[start] + @offset, Math.min(centerPos, pos.scroll[start] + pos.viewport[size] - pos.target[size] - @offset))\n\nngAnnotateText.factory \"NGAnnotation\", ->\n\tAnnotation = (data)->\n\n\t\tangular.extend @,\n\t\t\tid: annotationIdCounter++,\n\t\t\tstartIndex: null\n\t\t\tendIndex: null\n\t\t\tdata: {points: 0}\n\t\t\ttype: \"\"\n\t\t\tchildren: []\n\n\t\tif data?\n\t\t\tangular.extend @, data\n\n\treturn Annotation\n\nngAnnotateText.directive \"ngAnnotateText\", ($rootScope, $compile, $http, $q, $controller, $sce, NGAnnotation, NGAnnotateTextPopup)->\n\trestrict: \"E\"\n\tscope:\n\t\ttext: \"=\"\n\t\tannotations: \"=\"\n\t\treadonly: \"=\"\n\t\tpopupController: \"=\"\n\t\tpopupTemplateUrl: \"=\"\n\t\ttooltipController: \"=\"\n\t\ttooltipTemplateUrl: \"=\"\n\t\tonAnnotate: \"=\"\n\t\tonAnnotateDelete: \"=\"\n\t\tonAnnotateError: \"=\"\n\t\tonPopupShow: \"=\"\n\t\tonPopupHide: \"=\"\n\t\tpopupOffset: \"=\"\n\ttemplate: \"

\"\n\treplace: true\n\n\tcompile: (el, attr) ->\n\t\tattr.readonly ?= false\n\t\t@postLink\n\n\tpostLink: ($scope, element, attrs) ->\n\t\tPOPUP_OFFSET = $scope.popupOffset ? 10\n\n\t\tactivePopup = null\n\t\tactiveTooltip = null\n\n\t\t# Cache the template when we fetch it\n\t\tpopupTemplateData = \"\"\n\t\ttooltipTemplateData = \"\"\n\n\t\tonAnnotationsChange = ->\n\t\t\tif not $scope.text? or !$scope.text.length\n\t\t\t\treturn\n\t\t\tt = parseAnnotations $scope.text, $scope.annotations\n\t\t\t$scope.content = $sce.trustAsHtml t\n\n\t\t# Annotation parsing\n\t\t$scope.$watch \"text\", onAnnotationsChange\n\t\t$scope.$watch \"annotations\", onAnnotationsChange, true\n\n\t\tclearPopup = ->\n\t\t\tif not activePopup?\n\t\t\t\treturn\n\t\t\ttId = activePopup.scope.$annotation.id\n\t\t\tactivePopup.destroy ->\n\t\t\t\tif activePopup.scope.$annotation.id is tId\n\t\t\t\t\tactivePopup = null\n\n\t\tclearTooltip = ->\n\t\t\ttooltip = activeTooltip\n\t\t\tif not tooltip?\n\t\t\t\treturn\n\t\t\ttooltip.destroy ->\n\t\t\t\tif activeTooltip is tooltip\n\t\t\t\t\tactiveTooltip = null\n\n\t\tclearPopups = ->\n\t\t\tclearPopup()\n\t\t\tclearTooltip()\n\n\t\t$scope.$on \"$destroy\", clearPopups\n\t\t$scope.$on \"ngAnnotateText.clearPopups\", clearPopups\n\n\t\tif $scope.popupTemplateUrl\n\t\t\t$http.get($scope.popupTemplateUrl).then (response)->\n\t\t\t\tpopupTemplateData = response.data\n\n\t\tif $scope.tooltipTemplateUrl\n\t\t\t$http.get($scope.tooltipTemplateUrl).then (response)->\n\t\t\t\ttooltipTemplateData = response.data\n\n\t\tremoveChildren = (annotation)->\n\t\t\tfor i in [annotation.children.length - 1..0] by -1\n\t\t\t\ta = annotation.children[i]\n\t\t\t\tremoveChildren a\n\t\t\t\ta.children.splice i, 1\n\n\t\tremoveAnnotation = (id, annotations)->\n\t\t\tfor a, i in annotations\n\t\t\t\tremoveAnnotation id, a.children\n\n\t\t\t\tif a.id is id\n\t\t\t\t\tremoveChildren a\n\t\t\t\t\tannotations.splice i, 1\n\t\t\t\t\treturn\n\n\t\tcreateAnnotation = ->\n\t\t\tannotation = new NGAnnotation()\n\t\t\tsel = window.getSelection()\n\n\t\t\tif sel.isCollapsed\n\t\t\t\tthrow new Error \"NG_ANNOTATE_TEXT_NO_TEXT_SELECTED\"\n\n\t\t\trange = sel.getRangeAt 0\n\n\t\t\tif range.startContainer isnt range.endContainer\n\t\t\t\tthrow new Error \"NG_ANNOTATE_TEXT_PARTIAL_NODE_SELECTED\"\n\n\t\t\tif range.startContainer.parentNode.nodeName is \"SPAN\" # Is a child annotation\n\t\t\t\tparentId = if (attrId = range.startContainer.parentNode.getAttribute(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\t\t\t\tif parentId is undefined\n\t\t\t\t\tthrow new Error \"NG_ANNOTATE_TEXT_ILLEGAL_SELECTION\"\n\t\t\t\tparentAnnotation = getAnnotationById $scope.annotations, parentId\n\n\t\t\t\tannotationParentCollection = parentAnnotation.children\n\t\t\telse\n\t\t\t\tannotationParentCollection = $scope.annotations\n\n\t\t\t# Does this selection has any siblings?\n\t\t\tif annotationParentCollection.length\n\t\t\t\t# Yup, find the previous sibling\n\t\t\t\tprevSiblingSpan = range.startContainer.previousSibling\n\t\t\t\tif prevSiblingSpan?\n\t\t\t\t\tprevSiblingId = if (attrId = prevSiblingSpan.getAttribute(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\t\t\t\t\tif not prevSiblingId?\n\t\t\t\t\t\tthrow new Error \"NG_ANNOTATE_TEXT_ILLEGAL_SELECTION\"\n\n\t\t\t\t\tprevAnnotation = getAnnotationById $scope.annotations, prevSiblingId\n\t\t\t\t\tannotation.startIndex = prevAnnotation.endIndex + range.startOffset\n\t\t\t\t\tannotation.endIndex = prevAnnotation.endIndex + range.endOffset\n\t\t\t\telse\n\t\t\t\t\t# Doesn't have a prev sibling, alrighty then\n\t\t\t\t\tannotation.startIndex = range.startOffset\n\t\t\t\t\tannotation.endIndex = range.endOffset\n\t\t\telse\n\t\t\t\t# Nope\n\t\t\t\tannotation.startIndex = range.startOffset\n\t\t\t\tannotation.endIndex = range.endOffset\n\n\t\t\tannotationParentCollection.push annotation\n\t\t\tclearSelection()\n\t\t\treturn annotation\n\n\t\tclearSelection = ->\n\t\t\tif document.selection\n\t\t\t\tdocument.selection.empty() # Internet Explorer\n\t\t\telse if window.getSelection and window.getSelection().empty\n\t\t\t\twindow.getSelection().empty() # Chrome\n\t\t\telse if window.getSelection and window.getSelection().removeAllRanges\n\t\t\t\twindow.getSelection().removeAllRanges() # Firefox\n\n\t\tonSelect = (event)->\n\t\t\tif popupTemplateData.length is 0\n\t\t\t\treturn\n\n\t\t\ttry\n\t\t\t\tannotation = createAnnotation()\n\t\t\t\t$scope.$apply()\n\t\t\t\t$span = element.find \".ng-annotate-text-\" + annotation.id\n\t\t\tcatch ex\n\t\t\t\tif $scope.onAnnotateError?\n\t\t\t\t\t$scope.onAnnotateError ex\n\n\t\t\t\treturn\n\n\t\t\tclearPopups()\n\n\t\t\tloadAnnotationPopup annotation, $span, true\n\n\t\tonClick = (event)->\n\t\t\tif popupTemplateData.length is 0\n\t\t\t\treturn\n\n\t\t\t$target = angular.element event.target\n\t\t\ttargetId = if (attrId = $target.attr(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\n\t\t\tif not targetId?\n\t\t\t\treturn\n\n\t\t\tif activePopup? and activePopup.scope.$annotation.id is targetId\n\t\t\t\tclearPopup()\n\t\t\t\treturn\n\t\t\tannotation = getAnnotationById $scope.annotations, targetId\n\n\t\t\tclearPopups()\n\n\t\t\tloadAnnotationPopup annotation, $target, false\n\n\t\tonMouseEnter = (event)->\n\t\t\tif tooltipTemplateData.length is 0\n\t\t\t\treturn\n\n\t\t\tevent.stopPropagation()\n\t\t\t$target = angular.element event.target\n\t\t\ttargetId = if (attrId = $target.attr(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\n\t\t\tif activeTooltip? and activeTooltip.scope.$annotation.id is targetId\n\t\t\t\tactiveTooltip.stopDestroy()\n\t\t\t\treturn\n\t\t\telse\n\t\t\t\tclearTooltip()\n\n\t\t\tif not targetId?\n\t\t\t\treturn\n\n\t\t\tannotation = getAnnotationById $scope.annotations, targetId\n\n\t\t\t# We don't want to show the tooltip if a popup with the annotation is open,\n\t\t\t# or if the tooltip has both no comment and points\n\t\t\tif activePopup? or (not annotation.data.comment and not annotation.data.points)\n\t\t\t\treturn\n\n\t\t\ttooltip = new NGAnnotateTextPopup\n\t\t\t\tscope: $rootScope.$new()\n\t\t\t\ttemplate: \"
\"\n\t\t\t\tpositionClass: \"ng-annotate-text-tooltip-docked ng-annotate-text-tooltip-docked-{{position}}\"\n\t\t\t\t$anchor: $target\n\t\t\t\tpreferredAxis: 'y'\n\t\t\t\toffset: POPUP_OFFSET\n\t\t\ttooltip.scope.$annotation = annotation\n\n\t\t\tactiveTooltip = tooltip\n\n\t\t\tlocals =\n\t\t\t\t$scope: tooltip.scope\n\t\t\t\t$template: tooltipTemplateData\n\n\t\t\ttooltip.$el.html locals.$template\n\t\t\ttooltip.$el.appendTo \"body\"\n\n\t\t\tif $scope.tooltipController\n\t\t\t\tcontroller = $controller $scope.tooltipController, locals\n\t\t\t\ttooltip.$el.data \"$ngControllerController\", controller\n\t\t\t\ttooltip.$el.children().data \"$ngControllerController\", controller\n\n\t\t\t$compile(tooltip.$el) tooltip.scope\n\t\t\ttooltip.scope.$apply()\n\t\t\ttooltip.show()\n\n\t\tonMouseLeave = (event)->\n\t\t\tevent.stopPropagation()\n\n\t\t\t$target = angular.element event.target\n\t\t\ttargetId = if (attrId = $target.attr(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\n\t\t\tif not targetId?\n\t\t\t\treturn\n\n\t\t\tclearTooltip()\n\n\t\tloadAnnotationPopup = (annotation, anchor, isNew)->\n\t\t\tpopup = new NGAnnotateTextPopup\n\t\t\t\tscope: $rootScope.$new()\n\t\t\t\tcallbacks:\n\t\t\t\t\tshow: $scope.onPopupShow\n\t\t\t\t\thide: $scope.onPopupHide\n\t\t\t\ttemplate: \"
\"\n\t\t\t\tpositionClass: \"ng-annotate-text-popup-docked ng-annotate-text-popup-docked-{{position}}\"\n\t\t\t\t$anchor: anchor\n\t\t\t\toffset: POPUP_OFFSET\n\n\t\t\tpopup.scope.$isNew = isNew\n\t\t\tpopup.scope.$annotation = annotation\n\t\t\tpopup.scope.$readonly = $scope.readonly\n\n\t\t\tpopup.scope.$reject = ->\n\t\t\t\tremoveAnnotation annotation.id, $scope.annotations\n\n\t\t\t\tif $scope.onAnnotateDelete?\n\t\t\t\t\t$scope.onAnnotateDelete annotation\n\t\t\t\tclearPopup()\n\t\t\t\treturn\n\n\t\t\tpopup.scope.$close = ->\n\t\t\t\tif $scope.onAnnotate?\n\t\t\t\t\t$scope.onAnnotate popup.scope.$annotation\n\t\t\t\tclearPopup()\n\t\t\t\treturn\n\n\t\t\tactivePopup = popup\n\n\t\t\tlocals =\n\t\t\t\t$scope: popup.scope\n\t\t\t\t$template: popupTemplateData\n\n\t\t\tpopup.$el.html locals.$template\n\t\t\tpopup.$el.appendTo \"body\"\n\n\t\t\tif $scope.popupController\n\t\t\t\tcontroller = $controller $scope.popupController, locals\n\t\t\t\tpopup.$el.data \"$ngControllerController\", controller\n\t\t\t\tpopup.$el.children().data \"$ngControllerController\", controller\n\n\t\t\t$compile(popup.$el) popup.scope\n\t\t\tpopup.scope.$apply()\n\t\t\tpopup.show()\n\n\t\telement.on \"mouseenter\", \"span\", onMouseEnter\n\t\telement.on \"mouseleave\", \"span\", onMouseLeave\n\n\t\telement.on \"mouseup\", (event)->\n\t\t\t# We need to determine if the user actually selected something\n\t\t\t# or if he just clicked on an annotation\n\t\t\tselection = window.getSelection()\n\t\t\tif !selection.isCollapsed and !$scope.readonly\n\t\t\t\t# User has selected something\n\t\t\t\tonSelect event\n\t\t\telse if selection.isCollapsed and event.target.nodeName is \"SPAN\"\n\t\t\t\tonClick event\n\t\t\telse if selection.isCollapsed\n\t\t\t\tclearPopups()\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["ng-annotate-text.coffee"],"names":[],"mappings":"CAAA,WAAA,GAAA,qBAAA,kBAAA,SAAA,cAAA,eAAA,iBAAA,yBAAA,gBAAiB,QAAQ,OAAO,qBAEhC,oBAAsB,EAEtB,SAAW,SAAC,KAAM,MAAO,QACxB,MAAO,MAAK,OAAO,EAAG,OAAS,OAAS,KAAK,OAAO,QAErD,0BAA4B,SAAC,aAC5B,MAAO,aAAY,KAAK,SAAC,E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,0BAA2B,YAC1C,MAAM,IAAI,WAAW,KAAK,0BAA2B,aAEtD,SAAS,MAAM,KAAK,MAAM,OAC1B,MAAM,MAAM,SACZ,MAAM,QAEP,QAAQ,GAAG,aAAc,OAAQ,cACjC,QAAQ,GAAG,aAAc,OAAQ,cAEjC,QAAQ,GAAG,UAAW,SAAC,OAGtB,GAAA,UACA,OADA,WAAY,OAAO,eAChB,UAAW,aAAgB,OAAQ,SAG9B,UAAU,aAAyC,SAAzB,MAAM,OAAO,SAC9C,QAAQ,OACD,UAAU,YACjB,cADI,OAHJ,SAAS","file":"ng-annotate-text-latest.min.js","sourcesContent":["ngAnnotateText = angular.module \"ngAnnotateText\", []\n\nannotationIdCounter = 0\n\ninsertAt = (text, index, string)->\n\treturn text.substr(0, index) + string + text.substr(index)\n\nsortAnnotationsByEndIndex = (annotations)->\n\treturn annotations.sort (a, b)->\n\t\tif a.endIndex < b.endIndex\n\t\t\treturn -1\n\t\telse if a.endIndex > b.endIndex\n\t\t\treturn 1\n\t\treturn 0\n\nparseAnnotations = (text, annotations = [], indexOffset = 0)->\n\tif annotations.length is 0\n\t\treturn text\n\tannotations = sortAnnotationsByEndIndex annotations\n\n\tfor i in [annotations.length - 1..0] by -1\n\t\tannotation = annotations[i];\n\t\ttext = insertAt text, annotation.endIndex + indexOffset, \"\"\n\t\tif annotation.children.length\n\t\t\ttext = parseAnnotations text, annotation.children, annotation.startIndex + indexOffset\n\t\ttext = insertAt text, annotation.startIndex + indexOffset, \"\"\n\treturn text\n\ngetAnnotationById = (annotations, aId)->\n\tfor a in annotations\n\t\tif aId is a.id\n\t\t\treturn a\n\t\tif a.children.length > 0\n\t\t\tan = getAnnotationById a.children, aId\n\t\t\tif an isnt undefined\n\t\t\t\treturn an\n\n\nisEmptyObject = (obj) ->\n for prop of obj\n if Object.prototype.hasOwnProperty.call(obj, prop)\n return false;\n return true;\n\nngAnnotateText.factory \"NGAnnotateTextPopup\", ->\n\t(args) ->\n\t\targs = angular.extend {\n\t\t\tscope: null,\n\t\t\tcallbacks: {},\n\t\t\ttemplate: \"
\"\n\t\t\t$anchor: null\n\t\t\tpreferredAxis: 'x'\n\t\t\toffset: 0\n\t\t\tpositionClass: '{{position}}'\n\t\t}, args\n\n\t\tangular.extend @, args,\n\t\t\t$el: angular.element args.template\n\n\t\t\tshow: (speed = \"fast\") ->\n\t\t\t\t@$el.fadeIn speed\n\t\t\t\t@reposition()\n\t\t\t\tif typeof @callbacks.show is \"function\"\n\t\t\t\t\t@callbacks.show @$el\n\n\t\t\thide: (speed = \"fast\")->\n\t\t\t\t@$el.fadeOut speed\n\t\t\t\tif typeof @callbacks.hide is \"function\"\n\t\t\t\t\t@callbacks.hide @$el\n\n\t\t\tisVisible: ->\n\t\t\t\treturn @$el.is \":visible\"\n\n\t\t\tdestroy: (cb = angular.noop)->\n\t\t\t\tscope = @scope\n\t\t\t\t$el = @$el\n\t\t\t\t@hide ->\n\t\t\t\t\tif typeof cb is \"function\"\n\t\t\t\t\t\tcb()\n\t\t\t\t\tscope.$destroy()\n\t\t\t\t\t$el.remove()\n\n\t\t\tstopDestroy: ->\n\t\t\t\t@$el.stop(true).show(\"fast\")\n\n\t\t\treposition: ->\n\t\t\t\ttargetEl = @$el[0]\n\t\t\t\tanchorEl = @$anchor[0]\n\n\t\t\t\tif not (targetEl or anchorEl)\n\t\t\t\t\treturn\n\n\t\t\t\tpos =\n\t\t\t\t\tleft: null\n\t\t\t\t\ttop: null\n\t\t\t\t\ttarget: targetEl.getBoundingClientRect()\n\t\t\t\t\tanchor: anchorEl.getBoundingClientRect()\n\t\t\t\t\tviewport:\n\t\t\t\t\t\twidth: window.innerWidth\n\t\t\t\t\t\theight: window.innerHeight\n\t\t\t\t\tscroll:\n\t\t\t\t\t\ttop: document.body.scrollTop\n\t\t\t\t\t\tleft: document.body.scrollLeft\n\n\t\t\t\tif not (pos.target.width > 0 and pos.target.height > 0)\n\t\t\t\t\treturn\n\n\t\t\t\t# Find first axis position\n\n\t\t\t\tposX = @getNewPositionOnAxis pos, 'x'\n\t\t\t\tposY = @getNewPositionOnAxis pos, 'y'\n\n\t\t\t\tif @preferredAxis is 'x'\n\t\t\t\t\tif posX and typeof posX.pos is 'number'\n\t\t\t\t\t\tpos.left = posX.pos\n\t\t\t\t\t\tpos.edge = posX.edge\n\t\t\t\t\telse if posY\n\t\t\t\t\t\tpos.top = posY.pos\n\t\t\t\t\t\tpos.edge = posY.edge\n\t\t\t\telse\n\t\t\t\t\tif posY and typeof posY.pos is 'number'\n\t\t\t\t\t\tpos.top = posY.pos\n\t\t\t\t\t\tpos.edge = posY.edge\n\t\t\t\t\telse if posX\n\t\t\t\t\t\tpos.left = posX.pos\n\t\t\t\t\t\tpos.edge = posX.edge\n\n\t\t\t\t# Center on second axis\n\n\t\t\t\tif pos.left is null and pos.top is null\n\t\t\t\t\t# Center on X and Y axes\n\t\t\t\t\tpos.left = pos.scroll.left + (pos.viewport.width / 2) - (pos.target.width / 2)\n\t\t\t\t\tpos.top = pos.scroll.top + (pos.viewport.height / 2) - (pos.target.height / 2)\n\t\t\t\telse if pos.left is null\n\t\t\t\t\t# Center on X axis\n\t\t\t\t\tpos.left = @getNewCenterPositionOnAxis pos, 'x'\n\t\t\t\telse if pos.top is null\n\t\t\t\t\t# Center on Y axis\n\t\t\t\t\tpos.top = @getNewCenterPositionOnAxis pos, 'y'\n\n\t\t\t\t@$el\n\t\t\t\t\t.addClass pos.edge && @positionClass.replace \"{{position}}\", pos.edge\n\t\t\t\t\t.css\n\t\t\t\t\t\ttop: Math.round(pos.top) || 0\n\t\t\t\t\t\tleft: Math.round(pos.left) || 0\n\n\t\t\t\treturn\n\n\t\t\tgetNewPositionOnAxis: (pos, axis) ->\n\t\t\t\tstart = {x: 'left', y: 'top'}[axis]\n\t\t\t\tend = {x: 'right', y: 'bottom'}[axis]\n\t\t\t\tsize = {x: 'width', y: 'height'}[axis]\n\t\t\t\tif pos.anchor[start] - @offset >= pos.target[size]\n\t\t\t\t\taxisPos =\n\t\t\t\t\t\tpos: pos.scroll[start] + pos.anchor[start] - @offset - pos.target[size]\n\t\t\t\t\t\tedge: start\n\t\t\t\telse if pos.viewport[size] - pos.anchor[end] - @offset >= pos.target[size]\n\t\t\t\t\taxisPos =\n\t\t\t\t\t\tpos: pos.scroll[start] + pos.anchor[end] + @offset\n\t\t\t\t\t\tedge: end\n\t\t\t\taxisPos\n\n\t\t\tgetNewCenterPositionOnAxis: (pos, axis) ->\n\t\t\t\tstart = {x: 'left', y: 'top'}[axis]\n\t\t\t\tsize = {x: 'width', y: 'height'}[axis]\n\t\t\t\tcenterPos = pos.scroll[start] + pos.anchor[start] + (pos.anchor[size] / 2) - (pos.target[size] / 2)\n\t\t\t\tMath.max(pos.scroll[start] + @offset, Math.min(centerPos, pos.scroll[start] + pos.viewport[size] - pos.target[size] - @offset))\n \nngAnnotateText.factory \"NGAnnotation\", ->\n\tAnnotation = (data)->\n\n\t\tangular.extend @,\n\t\t\tid: annotationIdCounter++,\n\t\t\tstartIndex: null\n\t\t\tendIndex: null\n\t\t\tdata: {}\n\t\t\ttype: \"\"\n\t\t\tchildren: []\n\n\t\tif data?\n\t\t\tangular.extend @, data\n\n\treturn Annotation\n\nngAnnotateText.directive \"ngAnnotateText\", ($rootScope, $compile, $http, $q, $controller, $sce, NGAnnotation, NGAnnotateTextPopup)->\n\trestrict: \"E\"\n\tscope:\n\t\ttext: \"=\"\n\t\tannotations: \"=\"\n\t\treadonly: \"=\"\n\t\tpopupController: \"=\"\n\t\tpopupTemplateUrl: \"=\"\n\t\ttooltipController: \"=\"\n\t\ttooltipTemplateUrl: \"=\"\n\t\tonAnnotate: \"=\"\n\t\tonAnnotateDelete: \"=\"\n\t\tonAnnotateError: \"=\"\n\t\tonPopupShow: \"=\"\n\t\tonPopupHide: \"=\"\n\t\tpopupOffset: \"=\"\n\ttemplate: \"

\"\n\treplace: true\n\n\tcompile: (el, attr) ->\n\t\tattr.readonly ?= false\n\t\t@postLink\n\n\tpostLink: ($scope, element, attrs) ->\n\t\tPOPUP_OFFSET = $scope.popupOffset ? 10\n\n\t\tactivePopup = null\n\t\tactiveTooltip = null\n\n\t\t# Cache the template when we fetch it\n\t\tpopupTemplateData = \"\"\n\t\ttooltipTemplateData = \"\"\n\n\t\tonAnnotationsChange = ->\n\t\t\tif not $scope.text? or !$scope.text.length\n\t\t\t\treturn\n\t\t\tt = parseAnnotations $scope.text, $scope.annotations\n\t\t\t$scope.content = $sce.trustAsHtml t\n\n\t\t# Annotation parsing\n\t\t$scope.$watch \"text\", onAnnotationsChange\n\t\t$scope.$watch \"annotations\", onAnnotationsChange, true\n\n\t\tclearPopup = ->\n\t\t\tif not activePopup?\n\t\t\t\treturn\n\t\t\ttId = activePopup.scope.$annotation.id\n\t\t\tactivePopup.destroy ->\n\t\t\t\tif activePopup.scope.$annotation.id is tId\n\t\t\t\t\tactivePopup = null\n\n\t\tclearTooltip = ->\n\t\t\ttooltip = activeTooltip\n\t\t\tif not tooltip?\n\t\t\t\treturn\n\t\t\ttooltip.destroy ->\n\t\t\t\tif activeTooltip is tooltip\n\t\t\t\t\tactiveTooltip = null\n\n\t\tclearPopups = ->\n\t\t\tclearPopup()\n\t\t\tclearTooltip()\n\n\t\t$scope.$on \"$destroy\", clearPopups\n\t\t$scope.$on \"ngAnnotateText.clearPopups\", clearPopups\n\n\t\tif $scope.popupTemplateUrl\n\t\t\t$http.get($scope.popupTemplateUrl).then (response)->\n\t\t\t\tpopupTemplateData = response.data\n\n\t\tif $scope.tooltipTemplateUrl\n\t\t\t$http.get($scope.tooltipTemplateUrl).then (response)->\n\t\t\t\ttooltipTemplateData = response.data\n\n\t\tremoveChildren = (annotation)->\n\t\t\tfor i in [annotation.children.length - 1..0] by -1\n\t\t\t\ta = annotation.children[i]\n\t\t\t\tremoveChildren a\n\t\t\t\ta.children.splice i, 1\n\n\t\tremoveAnnotation = (id, annotations)->\n\t\t\tfor a, i in annotations\n\t\t\t\tremoveAnnotation id, a.children\n\n\t\t\t\tif a.id is id\n\t\t\t\t\tremoveChildren a\n\t\t\t\t\tannotations.splice i, 1\n\t\t\t\t\treturn\n\n\t\tcreateAnnotation = ->\n\t\t\tannotation = new NGAnnotation()\n\t\t\tsel = window.getSelection()\n\n\t\t\tif sel.isCollapsed\n\t\t\t\tthrow new Error \"NG_ANNOTATE_TEXT_NO_TEXT_SELECTED\"\n\n\t\t\trange = sel.getRangeAt 0\n\n\t\t\tif range.startContainer isnt range.endContainer\n\t\t\t\tthrow new Error \"NG_ANNOTATE_TEXT_PARTIAL_NODE_SELECTED\"\n\n\t\t\tif range.startContainer.parentNode.nodeName is \"SPAN\" # Is a child annotation\n\t\t\t\tparentId = if (attrId = range.startContainer.parentNode.getAttribute(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\t\t\t\tif parentId is undefined\n\t\t\t\t\tthrow new Error \"NG_ANNOTATE_TEXT_ILLEGAL_SELECTION\"\n\t\t\t\tparentAnnotation = getAnnotationById $scope.annotations, parentId\n\n\t\t\t\tannotationParentCollection = parentAnnotation.children\n\t\t\telse\n\t\t\t\tannotationParentCollection = $scope.annotations\n\n\t\t\t# Does this selection has any siblings?\n\t\t\tif annotationParentCollection.length\n\t\t\t\t# Yup, find the previous sibling\n\t\t\t\tprevSiblingSpan = range.startContainer.previousSibling\n\t\t\t\tif prevSiblingSpan?\n\t\t\t\t\tprevSiblingId = if (attrId = prevSiblingSpan.getAttribute(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\t\t\t\t\tif not prevSiblingId?\n\t\t\t\t\t\tthrow new Error \"NG_ANNOTATE_TEXT_ILLEGAL_SELECTION\"\n\n\t\t\t\t\tprevAnnotation = getAnnotationById $scope.annotations, prevSiblingId\n\t\t\t\t\tannotation.startIndex = prevAnnotation.endIndex + range.startOffset\n\t\t\t\t\tannotation.endIndex = prevAnnotation.endIndex + range.endOffset\n\t\t\t\telse\n\t\t\t\t\t# Doesn't have a prev sibling, alrighty then\n\t\t\t\t\tannotation.startIndex = range.startOffset\n\t\t\t\t\tannotation.endIndex = range.endOffset\n\t\t\telse\n\t\t\t\t# Nope\n\t\t\t\tannotation.startIndex = range.startOffset\n\t\t\t\tannotation.endIndex = range.endOffset\n\n\t\t\tannotationParentCollection.push annotation\n\t\t\tclearSelection()\n\t\t\treturn annotation\n\n\t\tclearSelection = ->\n\t\t\tif document.selection\n\t\t\t\tdocument.selection.empty() # Internet Explorer\n\t\t\telse if window.getSelection and window.getSelection().empty\n\t\t\t\twindow.getSelection().empty() # Chrome\n\t\t\telse if window.getSelection and window.getSelection().removeAllRanges\n\t\t\t\twindow.getSelection().removeAllRanges() # Firefox\n\n\t\tonSelect = (event)->\n\t\t\tif popupTemplateData.length is 0\n\t\t\t\treturn\n\n\t\t\ttry\n\t\t\t\tannotation = createAnnotation()\n\t\t\t\t$scope.$apply()\n\t\t\t\t$span = element.find \".ng-annotate-text-\" + annotation.id\n\t\t\tcatch ex\n\t\t\t\tif $scope.onAnnotateError?\n\t\t\t\t\t$scope.onAnnotateError ex\n\n\t\t\t\treturn\n\n\t\t\tclearPopups()\n\n\t\t\tloadAnnotationPopup annotation, $span, true\n\n\t\tonClick = (event)->\n\t\t\tif popupTemplateData.length is 0\n\t\t\t\treturn\n\n\t\t\t$target = angular.element event.target\n\t\t\ttargetId = if (attrId = $target.attr(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\n\t\t\tif not targetId?\n\t\t\t\treturn\n\n\t\t\tif activePopup? and activePopup.scope.$annotation.id is targetId\n\t\t\t\tclearPopup()\n\t\t\t\treturn\n\t\t\tannotation = getAnnotationById $scope.annotations, targetId\n\n\t\t\tclearPopups()\n\n\t\t\tloadAnnotationPopup annotation, $target, false\n\n\t\tonMouseEnter = (event)->\n\t\t\tif tooltipTemplateData.length is 0\n\t\t\t\treturn\n\n\t\t\tevent.stopPropagation()\n\t\t\t$target = angular.element event.target\n\t\t\ttargetId = if (attrId = $target.attr(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\n\t\t\tif activeTooltip? and activeTooltip.scope.$annotation.id is targetId\n\t\t\t\tactiveTooltip.stopDestroy()\n\t\t\t\treturn\n\t\t\telse\n\t\t\t\tclearTooltip()\n\n\t\t\tif not targetId?\n\t\t\t\treturn\n\n\t\t\tannotation = getAnnotationById $scope.annotations, targetId\n\n\t\t\t# We don't want to show the tooltip if a popup with the annotation is open,\n\t\t\t# or if the tooltip has both no comment and points\n\t\t\tif activePopup? or isEmptyObject(annotation.data)\n\t\t\t\treturn\n\n\t\t\ttooltip = new NGAnnotateTextPopup\n\t\t\t\tscope: $rootScope.$new()\n\t\t\t\ttemplate: \"
\"\n\t\t\t\tpositionClass: \"ng-annotate-text-tooltip-docked ng-annotate-text-tooltip-docked-{{position}}\"\n\t\t\t\t$anchor: $target\n\t\t\t\tpreferredAxis: 'y'\n\t\t\t\toffset: POPUP_OFFSET\n\t\t\ttooltip.scope.$annotation = annotation\n\n\t\t\tactiveTooltip = tooltip\n\n\t\t\tlocals =\n\t\t\t\t$scope: tooltip.scope\n\t\t\t\t$template: tooltipTemplateData\n\n\t\t\ttooltip.$el.html locals.$template\n\t\t\ttooltip.$el.appendTo \"body\"\n\n\t\t\tif $scope.tooltipController\n\t\t\t\tcontroller = $controller $scope.tooltipController, locals\n\t\t\t\ttooltip.$el.data \"$ngControllerController\", controller\n\t\t\t\ttooltip.$el.children().data \"$ngControllerController\", controller\n\n\t\t\t$compile(tooltip.$el) tooltip.scope\n\t\t\ttooltip.scope.$apply()\n\t\t\ttooltip.show()\n\n\t\tonMouseLeave = (event)->\n\t\t\tevent.stopPropagation()\n\n\t\t\t$target = angular.element event.target\n\t\t\ttargetId = if (attrId = $target.attr(\"data-annotation-id\"))? then parseInt(attrId, 10)\n\n\t\t\tif not targetId?\n\t\t\t\treturn\n\n\t\t\tclearTooltip()\n\n\t\tloadAnnotationPopup = (annotation, anchor, isNew)->\n\t\t\tpopup = new NGAnnotateTextPopup\n\t\t\t\tscope: $rootScope.$new()\n\t\t\t\tcallbacks:\n\t\t\t\t\tshow: $scope.onPopupShow\n\t\t\t\t\thide: $scope.onPopupHide\n\t\t\t\ttemplate: \"
\"\n\t\t\t\tpositionClass: \"ng-annotate-text-popup-docked ng-annotate-text-popup-docked-{{position}}\"\n\t\t\t\t$anchor: anchor\n\t\t\t\toffset: POPUP_OFFSET\n\n\t\t\tpopup.scope.$isNew = isNew\n\t\t\tpopup.scope.$annotation = annotation\n\t\t\tpopup.scope.$readonly = $scope.readonly\n\n\t\t\tpopup.scope.$reject = ->\n\t\t\t\tremoveAnnotation annotation.id, $scope.annotations\n\n\t\t\t\tif $scope.onAnnotateDelete?\n\t\t\t\t\t$scope.onAnnotateDelete annotation\n\t\t\t\tclearPopup()\n\t\t\t\treturn\n\n\t\t\tpopup.scope.$close = ->\n\t\t\t\tif $scope.onAnnotate?\n\t\t\t\t\t$scope.onAnnotate popup.scope.$annotation\n\t\t\t\tclearPopup()\n\t\t\t\treturn\n\n\t\t\tactivePopup = popup\n\n\t\t\tlocals =\n\t\t\t\t$scope: popup.scope\n\t\t\t\t$template: popupTemplateData\n\n\t\t\tpopup.$el.html locals.$template\n\t\t\tpopup.$el.appendTo \"body\"\n\n\t\t\tif $scope.popupController\n\t\t\t\tcontroller = $controller $scope.popupController, locals\n\t\t\t\tpopup.$el.data \"$ngControllerController\", controller\n\t\t\t\tpopup.$el.children().data \"$ngControllerController\", controller\n\n\t\t\t$compile(popup.$el) popup.scope\n\t\t\tpopup.scope.$apply()\n\t\t\tpopup.show()\n\n\t\telement.on \"mouseenter\", \"span\", onMouseEnter\n\t\telement.on \"mouseleave\", \"span\", onMouseLeave\n\n\t\telement.on \"mouseup\", (event)->\n\t\t\t# We need to determine if the user actually selected something\n\t\t\t# or if he just clicked on an annotation\n\t\t\tselection = window.getSelection()\n\t\t\tif !selection.isCollapsed and !$scope.readonly\n\t\t\t\t# User has selected something\n\t\t\t\tonSelect event\n\t\t\telse if selection.isCollapsed and event.target.nodeName is \"SPAN\"\n\t\t\t\tonClick event\n\t\t\telse if selection.isCollapsed\n\t\t\t\tclearPopups()\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/src/ng-annotate-text.coffee b/src/ng-annotate-text.coffee index d72ab51..38b0ed1 100644 --- a/src/ng-annotate-text.coffee +++ b/src/ng-annotate-text.coffee @@ -35,6 +35,13 @@ getAnnotationById = (annotations, aId)-> if an isnt undefined return an + +isEmptyObject = (obj) -> + for prop of obj + if Object.prototype.hasOwnProperty.call(obj, prop) + return false; + return true; + ngAnnotateText.factory "NGAnnotateTextPopup", -> (args) -> args = angular.extend { @@ -158,7 +165,7 @@ ngAnnotateText.factory "NGAnnotateTextPopup", -> size = {x: 'width', y: 'height'}[axis] centerPos = pos.scroll[start] + pos.anchor[start] + (pos.anchor[size] / 2) - (pos.target[size] / 2) Math.max(pos.scroll[start] + @offset, Math.min(centerPos, pos.scroll[start] + pos.viewport[size] - pos.target[size] - @offset)) - + ngAnnotateText.factory "NGAnnotation", -> Annotation = (data)-> @@ -166,7 +173,7 @@ ngAnnotateText.factory "NGAnnotation", -> id: annotationIdCounter++, startIndex: null endIndex: null - data: {points: 0} + data: {} type: "" children: [] @@ -377,7 +384,7 @@ ngAnnotateText.directive "ngAnnotateText", ($rootScope, $compile, $http, $q, $co # We don't want to show the tooltip if a popup with the annotation is open, # or if the tooltip has both no comment and points - if activePopup? or (not annotation.data.comment and not annotation.data.points) + if activePopup? or isEmptyObject(annotation.data) return tooltip = new NGAnnotateTextPopup