From 68fce1311d3691051828046e9cbc06ae0e049705 Mon Sep 17 00:00:00 2001 From: Robin Andersson Date: Tue, 24 Jun 2014 15:05:53 +0200 Subject: [PATCH] Adapted the structure better for bower, running grunt will now output latest files in dist --- Gruntfile.coffee | 10 +++++++++- bower.json | 3 ++- dist/ng-annotate-latest.min.css | 1 + dist/ng-annotate-latest.min.js | 1 + package.json | 3 ++- 5 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 dist/ng-annotate-latest.min.css create mode 100644 dist/ng-annotate-latest.min.js diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 7ce6078..314dd60 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -1,6 +1,6 @@ module.exports = (grunt) -> # Release - distTasks = ["coffee:release", "sass:release", "uglify", "cssmin"] + distTasks = ["coffee:release", "sass:release", "uglify", "cssmin", "copy:release"] # Development defaultTasks = ["coffee:development", "sass:development"] @@ -42,6 +42,13 @@ module.exports = (grunt) -> src: "<%= sass.release.dest %>" dest: "dist/<%= pkg.version %>/css/<%= pkg.name %>-<%= pkg.version %>.min.css" + copy: + release: + files: [ + { src: "<%= uglify.release.dest %>", dest: "dist/ng-annotate-latest.min.js" } + { src: "<%= cssmin.release.dest %>", dest: "dist/ng-annotate-latest.min.css" } + ] + watch: release: files: ["<%= coffee.release.src %>", "<%= sass.release.src %>"] @@ -61,6 +68,7 @@ module.exports = (grunt) -> grunt.loadNpmTasks "grunt-contrib-sass" grunt.loadNpmTasks "grunt-contrib-cssmin" grunt.loadNpmTasks "grunt-contrib-connect" + grunt.loadNpmTasks "grunt-contrib-copy" grunt.registerTask "default", defaultTasks grunt.registerTask "dist", distTasks diff --git a/bower.json b/bower.json index 0e58d03..267fbbd 100644 --- a/bower.json +++ b/bower.json @@ -25,7 +25,8 @@ "example-app", "dev", "/css/", - "/js/" + "/js/", + "/dist/**/" ], "dependencies": { "angular": "~1.2.6" diff --git a/dist/ng-annotate-latest.min.css b/dist/ng-annotate-latest.min.css new file mode 100644 index 0000000..e8ec77b --- /dev/null +++ b/dist/ng-annotate-latest.min.css @@ -0,0 +1 @@ +.text-center{text-align:center}.ng-annotation{border-bottom:1px solid #000;cursor:pointer}.ng-annotation.red{color:#000;background:#fcbcbc;border-color:#fcbcbc}.ng-annotation.green{color:#000;background:#c7fcbc;border-color:#c7fcbc}.ng-annotation.blue{color:#000;background:#BCDFFC;border-color:#BCDFFC}.ng-annotation.pink{color:#000;background:#fcbcfa;border-color:#fcbcfa}.ng-annotation.yellow{color:#000;background:#fafcbc;border-color:#fafcbc}.ng-annotation.aqua{color:#000;background:#bcfcf7;border-color:#bcfcf7}.ng-annotation.strike{text-decoration:line-through}.ng-annotation-popup{width:300px;position:absolute;z-index:1000;background:#fff;box-shadow:0 0 10px #777;display:none;padding:10px}.ng-annotation-popup label{display:block}.ng-annotation-popup:after{content:"";width:10px;height:10px;position:absolute;background:#fff;-webkit-transform:rotate(45deg);right:-6px;top:50%;margin-top:-5px;z-index:990;border-top:1px solid #ccc;border-right:1px solid #ccc}.ng-annotation-tooltip{width:300px;position:absolute;z-index:1000;background:#fff;box-shadow:0 0 10px #777;display:none;padding:10px}.ng-annotation-tooltip:after{content:"";width:10px;height:10px;position:absolute;background:#fff;-webkit-transform:rotate(45deg);right:-6px;top:50%;margin-top:-5px;z-index:990;border-top:1px solid #ccc;border-right:1px solid #ccc} \ No newline at end of file diff --git a/dist/ng-annotate-latest.min.js b/dist/ng-annotate-latest.min.js new file mode 100644 index 0000000..b1fb3f8 --- /dev/null +++ b/dist/ng-annotate-latest.min.js @@ -0,0 +1 @@ +(function(){var getAnnotationById,insertAt,ngAnnotate,parseAnnotations,sortAnnotationsByEndIndex;ngAnnotate=angular.module("ngAnnotate",[]),insertAt=function(text,index,string){return text.substr(0,index)+string+text.substr(index)},sortAnnotationsByEndIndex=function(annotations){return annotations.sort(function(a,b){return a.endIndexb.endIndex?1:0})},parseAnnotations=function(text,annotations,indexOffset){var annotation,i,_i,_ref;if(null==annotations&&(annotations=[]),null==indexOffset&&(indexOffset=0),0===annotations.length)return text;for(annotations=sortAnnotationsByEndIndex(annotations),i=_i=_ref=annotations.length-1;_i>=0;i=_i+=-1)annotation=annotations[i],text=insertAt(text,annotation.endIndex+indexOffset,""),annotation.children.length&&(text=parseAnnotations(text,annotation.children,annotation.startIndex+indexOffset)),text=insertAt(text,annotation.startIndex+indexOffset,'');return text},getAnnotationById=function(annotations,aId){var a,an,_i,_len;for(_i=0,_len=annotations.length;_len>_i;_i++){if(a=annotations[_i],aId===a.id)return a;if(a.children.length>0&&(an=getAnnotationById(a.children,aId),void 0!==an))return an}},ngAnnotate.factory("NGAnnotatePopup",function(){var NGAnnotatePopup;return NGAnnotatePopup=function(scope){return angular.extend(this,{scope:scope,$el:angular.element('
'),$anchor:null,show:function(cb,speed){return null==cb&&(cb=angular.noop),null==speed&&(speed="fast"),this.$el.fadeIn(speed,cb)},hide:function(cb,speed){return null==cb&&(cb=angular.noop),null==speed&&(speed="fast"),this.$el.fadeOut(speed,cb)},isVisible:function(){return this.$el.is(":visible")},positionTop:function(){var anchorHeight,anchorOffsetTop,popupHeight;if(null==this.$anchor)throw new Error("NG_ANNOTATE_NO_ANCHOR");return anchorOffsetTop=this.$anchor.offset().top,anchorHeight=this.$anchor.innerHeight(),popupHeight=this.$el.innerHeight(),this.$el.css({top:anchorOffsetTop+anchorHeight/2-popupHeight/2})},positionLeft:function(value){return this.$el.css({left:value})},destroy:function(cb){var $el;return null==cb&&(cb=angular.noop),scope=this.scope,$el=this.$el,this.hide(function(){return cb(),scope.$destroy(),$el.remove()})}})}}),ngAnnotate.factory("NGAnnotateTooltip",function(){var NGAnnotateTooltip;return NGAnnotateTooltip=function(scope){return angular.extend(this,{scope:scope,$el:angular.element('
'),$anchor:null,show:function(cb,speed){return null==cb&&(cb=angular.noop),null==speed&&(speed="fast"),this.$el.fadeIn(speed,cb)},hide:function(cb,speed){return null==cb&&(cb=angular.noop),null==speed&&(speed="fast"),this.$el.fadeOut(speed,cb)},isVisible:function(){return this.$el.is(":visible")},positionTop:function(){var anchorHeight,anchorOffsetTop,tooltipHeight;if(null==this.$anchor)throw new Error("NG_ANNOTATE_NO_ANCHOR");return anchorOffsetTop=this.$anchor.offset().top,anchorHeight=this.$anchor.innerHeight(),tooltipHeight=this.$el.innerHeight(),this.$el.css({top:anchorOffsetTop+anchorHeight/2-tooltipHeight/2})},positionLeft:function(value){return this.$el.css({left:value})},destroy:function(cb){var $el;return null==cb&&(cb=angular.noop),scope=this.scope,$el=this.$el,this.hide(function(){return cb(),scope.$destroy(),$el.remove()})},stopDestroy:function(){return this.$el.stop(!0).show("fast")}})}}),ngAnnotate.factory("NGAnnotation",function(){var Annotation;return Annotation=function(data){return angular.extend(this,{id:(new Date).getTime(),startIndex:null,endIndex:null,data:{},type:"",children:[]}),null!=data?angular.extend(this,data):void 0}}),ngAnnotate.directive("ngAnnotate",function($rootScope,$compile,$http,$q,$controller,$sce,NGAnnotation,NGAnnotatePopup,NGAnnotateTooltip){return{restrict:"E",scope:{text:"=",annotations:"=",options:"=",onAnnotate:"=",onAnnotateDelete:"=",onAnnotateError:"="},template:'

',replace:!0,compile:function(){return function($scope,element){var activePopup,activeTooltip,clearPopup,clearTooltip,createAnnotation,loadAnnotationPopup,onAnnotationsChange,onClick,onMouseEnter,onMouseLeave,onSelect,options,popupTemplateData,removeAnnotation,removeChildren,tooltipTemplateData;return 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),options={readonly:!1,popupController:"",popupTemplateUrl:"",tooltipController:"",tooltipTemplateUrl:""},options=angular.extend(options,$scope.options),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 tId;if(null!=activeTooltip)return tId=activeTooltip.scope.$annotation.id,activeTooltip.destroy(function(){return activeTooltip.scope.$annotation.id===tId?activeTooltip=null:void 0})},$scope.$on("$destroy",function(){return clearPopup(),clearTooltip()}),options.popupTemplateUrl&&$http.get(options.popupTemplateUrl).then(function(response){return popupTemplateData=response.data}),options.tooltipTemplateUrl&&$http.get(options.tooltipTemplateUrl).then(function(response){return tooltipTemplateData=response.data}),removeChildren=function(annotation){var a,i,_i,_ref,_results;for(_results=[],i=_i=_ref=annotation.children.length-1;_i>=0;i=_i+=-1)a=annotation.children[i],removeChildren(a),_results.push(a.children.splice(i,1));return _results},removeAnnotation=function(id,annotations){var a,i,_i,_len;for(i=_i=0,_len=annotations.length;_len>_i;i=++_i)if(a=annotations[i],removeAnnotation(id,a.children),a.id===id)return removeChildren(a),void annotations.splice(i,1)},createAnnotation=function(){var annotation,annotationParentCollection,attrId,parentAnnotation,parentId,prevAnnotation,prevSiblingId,prevSiblingSpan,range,sel;if(annotation=new NGAnnotation,sel=window.getSelection(),"Range"!==sel.type)throw new Error("NG_ANNOTATE_NO_TEXT_SELECTED");if(range=sel.getRangeAt(0),range.startContainer!==range.endContainer)throw new Error("NG_ANNOTATE_PARTIAL_NODE_SELECTED");if("SPAN"===range.startContainer.parentElement.nodeName){if(parentId=null!=(attrId=range.startContainer.parentElement.getAttribute("data-annotation-id"))?parseInt(attrId,10):void 0,void 0===parentId)throw new Error("NG_ANNOTATE_ILLEGAL_SELECTION");parentAnnotation=getAnnotationById($scope.annotations,parentId),annotationParentCollection=parentAnnotation.children}else annotationParentCollection=$scope.annotations;if(annotationParentCollection.length)if(prevSiblingSpan=range.startContainer.previousSibling,null!=prevSiblingSpan){if(prevSiblingId=null!=(attrId=prevSiblingSpan.getAttribute("data-annotation-id"))?parseInt(attrId,10):void 0,null==prevSiblingId)throw new Error("NG_ANNOTATE_ILLEGAL_SELECTION");prevAnnotation=getAnnotationById($scope.annotations,prevSiblingId),annotation.startIndex=prevAnnotation.endIndex+range.startOffset,annotation.endIndex=prevAnnotation.endIndex+range.endOffset}else annotation.startIndex=range.startOffset,annotation.endIndex=range.endOffset;else annotation.startIndex=range.startOffset,annotation.endIndex=range.endOffset;return annotationParentCollection.push(annotation),annotation},onSelect=function(){var $span,annotation,ex;if(0!==popupTemplateData.length){try{annotation=createAnnotation(),$scope.$apply(),$span=element.find(".ng-annotation-"+annotation.id)}catch(_error){return ex=_error,void(null!=$scope.onAnnotateError&&$scope.onAnnotateError(ex))}return clearPopup(),clearTooltip(),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),clearPopup(),clearTooltip(),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))return tooltip=new NGAnnotateTooltip($rootScope.$new()),tooltip.scope.$annotation=annotation,tooltip.$anchor=$target,tooltip.scope.$reposition=function(){tooltip.positionTop(),tooltip.positionLeft(element.offset().left-tooltip.$el.innerWidth())},activeTooltip=tooltip,locals={$scope:tooltip.scope,$template:tooltipTemplateData},tooltip.$el.html(locals.$template),tooltip.$el.appendTo("body"),options.tooltipController&&(controller=$controller(options.tooltipController,locals),tooltip.$el.data("$ngControllerController",controller),tooltip.$el.children().data("$ngControllerController",controller)),$compile(tooltip.$el)(tooltip.scope),tooltip.positionTop(),tooltip.positionLeft(element.offset().left-tooltip.$el.innerWidth()),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 NGAnnotatePopup($rootScope.$new()),popup.scope.$isNew=isNew,popup.scope.$annotation=annotation,popup.scope.$readonly=options.readonly,popup.$anchor=anchor,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()},popup.scope.$reposition=function(){popup.positionTop(),popup.positionLeft(element.offset().left-popup.$el.innerWidth())},activePopup=popup,locals={$scope:popup.scope,$template:popupTemplateData},popup.$el.html(locals.$template),popup.$el.appendTo("body"),options.popupController&&(controller=$controller(options.popupController,locals),popup.$el.data("$ngControllerController",controller),popup.$el.children().data("$ngControllerController",controller)),$compile(popup.$el)(popup.scope),popup.positionTop(),popup.positionLeft(element.offset().left-popup.$el.innerWidth()),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(),"Range"!==selection.type||options.readonly?"Caret"===selection.type&&"SPAN"===event.target.nodeName?onClick(event):"Caret"===selection.type?(clearTooltip(),clearPopup()):void 0:onSelect(event)})}}}})}).call(this); \ No newline at end of file diff --git a/package.json b/package.json index bd5a5c6..536074c 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "grunt-contrib-watch": "0.6.x", "grunt-contrib-sass": "0.7.x", "grunt-contrib-cssmin": "0.9.x", - "grunt-contrib-connect": "0.7.0" + "grunt-contrib-connect": "0.7.0", + "grunt-contrib-copy": "0.5.0" } }