├── .gitignore ├── LICENSE.md ├── README.md ├── bower.json ├── dist ├── ng-annotate-text-latest.css ├── ng-annotate-text-latest.css.map ├── ng-annotate-text-latest.js ├── ng-annotate-text-latest.js.map ├── ng-annotate-text-latest.min.css ├── ng-annotate-text-latest.min.css.map ├── ng-annotate-text-latest.min.js └── ng-annotate-text-latest.min.js.map ├── gulpfile.js ├── package.json ├── screenshot.png └── src ├── ng-annotate-text.coffee └── ng-annotate-text.scss /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .sass-cache/ 3 | *.sublime-* 4 | node_modules/ 5 | bower_components/ 6 | .idea/ 7 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. 2 | 3 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. 4 | 5 | 1. Definitions 6 | 7 | "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License. "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License. "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership. "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License. "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast. "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work. "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images. "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium. 2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws. 8 | 9 | 3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: 10 | 11 | to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified."; to Distribute and Publicly Perform the Work including as incorporated in Collections; and, to Distribute and Publicly Perform Adaptations. The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved, including but not limited to the rights set forth in Section 4(d). 12 | 13 | 4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: 14 | 15 | You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(c), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(c), as requested. You may not exercise any of the rights granted to You in Section 3 above in any manner that is primarily intended for or directed toward commercial advantage or private monetary compensation. The exchange of the Work for other copyrighted works by means of digital file-sharing or otherwise shall not be considered to be intended for or directed toward commercial advantage or private monetary compensation, provided there is no payment of any monetary compensation in connection with the exchange of copyrighted works. If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and, (iv) consistent with Section 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4(c) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties. For the avoidance of doubt: 16 | 17 | Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License if Your exercise of such rights is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(b) and otherwise waives the right to collect royalties through any statutory or compulsory licensing scheme; and, Voluntary License Schemes. The Licensor reserves the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License that is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(c). Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise. 5. Representations, Warranties and Disclaimer 18 | 19 | UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 20 | 21 | 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 22 | 23 | 7. Termination 24 | 25 | This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. 8. Miscellaneous 26 | 27 | Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ng-annotate-text 2 | 3 | ng-annotate-text is a library to annotate texts in AngularJS. 4 | 5 | ![Screenshot](screenshot.png) 6 | 7 | ## Demo 8 | 9 | [Try a demo of ng-annotate.](http://digiexam.github.io/ng-annotate-text/) 10 | 11 | ## Attributes 12 | 13 | Attribute | Default value | Description 14 | --- | --- | --- 15 | text | | The text to be annotated 16 | annotations | | Annotations to load 17 | readonly | false | No new annotations can be made and existing annotations can't be edited 18 | popup-controller | | Controller to apply to the popup 19 | popup-template-url | | Url to the popup template 20 | tooltip-controller | | Controller to apply to the tooltip 21 | tooltip-template-url | | Url to the tooltip template 22 | on-annotate | | Function called when an annotation is saved, with the annotation passed as the first attribute 23 | on-annotate-delete | | Function called when an annotation is deleted, with the annotation passed as the first attribute 24 | on-annotate-error | | Function called when an error is caught, with the error passed as the first attribute 25 | on-popup-show | | Function called when the popup is shown 26 | on-popup-hide | | Function called when the popup is hidden 27 | popup-offset | 10 | Position the popup editor away form its annotation and the window edges by this many pixels 28 | 29 | ## Event listeners 30 | 31 | Event | Description 32 | --- | --- 33 | ngAnnotateText.clearPopups | Clears any open popup or tooltip 34 | 35 | ## Errors passed to the annotation error callback 36 | 37 | Error | Description 38 | --- | --- 39 | NG_ANNOTATE_TEXT_NO_TEXT_SELECTED | The user clicked the text but no text were selected 40 | NG_ANNOTATE_TEXT_PARTIAL_NODE_SELECTED | The selection did not start and end in the same element 41 | 42 | ## Getting started with development 43 | 44 | 1. Install NodeJS ([nodejs.org](http://nodejs.org/)) 45 | 2. Install Gulp globally: `npm install -g gulp` 46 | 3. Fork the repo and clone it. ([How to do it with GitHub.](https://help.github.com/articles/fork-a-repo)) 47 | 4. Go into the project folder: `cd ng-annotate-text` 48 | 5. Install the project dependencies: `npm install` 49 | 6. Build the project files: `gulp` 50 | * Build them whenever they change: `gulp watch` 51 | 52 | To make development of ng-annotate-text easier you can check out the `master` branch in one directory and the `gh-pages` branch in another, then symlink the dist files from `master` into the `lib` directory in `gh-pages`, and change the includes in `index.html` to use those versions. 53 | 54 | ## Browser compatability 55 | 56 | Chrome, Firefox, Safari and IE9+ 57 | 58 | Autoprefixer rule: last 2 versions, ie >= 9, Firefox ESR 59 | 60 | ## License 61 | 62 | Licensed under CC-BY-NC 63 | 64 | https://tldrlegal.com/license/creative-commons-attribution-noncommercial-(cc-nc) 65 | 66 | Copyright (C) 2014 DigiExam 67 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ng-annotate-text", 3 | "version": "2.5.1", 4 | "homepage": "https://github.com/DigiExam/ng-annotate-text", 5 | "authors": [ 6 | "(Rasmus Milesson )", 7 | "(Robin Andersson )", 8 | "(Kenneth Sundqvist )" 9 | ], 10 | "description": "An AngularJS directive to assist with annotation of text", 11 | "keywords": [ 12 | "angularjs", 13 | "annotation" 14 | ], 15 | "license": "CC-BY-NC", 16 | "private": true, 17 | "main": [ 18 | "./dist/ng-annotate-text-latest.min.css", 19 | "./dist/ng-annotate-text-latest.min.js" 20 | ], 21 | "ignore": [ 22 | "node_modules", 23 | "bower_components", 24 | "test", 25 | "tests", 26 | "example-app", 27 | "dev", 28 | "/css/", 29 | "/js/" 30 | ], 31 | "dependencies": { 32 | "angular": "~1.2.6" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /dist/ng-annotate-text-latest.css: -------------------------------------------------------------------------------- 1 | .ng-annotate-text-type- { 2 | border-bottom: 1px solid #000; } 3 | .ng-annotate-text-type-red { 4 | color: #000; 5 | background: #fcbcbc; 6 | border-color: #fcbcbc; } 7 | .ng-annotate-text-type-green { 8 | color: #000; 9 | background: #c7fcbc; 10 | border-color: #c7fcbc; } 11 | .ng-annotate-text-type-blue { 12 | color: #000; 13 | background: #bcdffc; 14 | border-color: #bcdffc; } 15 | .ng-annotate-text-type-pink { 16 | color: #000; 17 | background: #fcbcfa; 18 | border-color: #fcbcfa; } 19 | .ng-annotate-text-type-yellow { 20 | color: #000; 21 | background: #f8f89b; 22 | border-color: #f8f89b; } 23 | .ng-annotate-text-type-aqua { 24 | color: #000; 25 | background: #bcfcf7; 26 | border-color: #bcfcf7; } 27 | .ng-annotate-text-type-strike { 28 | text-decoration: line-through; } 29 | .ng-annotate-text-annotation { 30 | cursor: pointer; } 31 | .ng-annotate-text-popup { 32 | display: none; 33 | position: absolute; 34 | z-index: 990; 35 | width: 227px; 36 | padding: 10px; 37 | color: #333333; 38 | background: white; 39 | border: 1px solid rgba(0, 0, 0, 0.18); 40 | border-radius: 5px; 41 | box-shadow: 0 1px 10px rgba(0, 0, 0, 0.2); 42 | font: 13px/1.38462 "Helvetica Neue", Helvetica, Arial, sans-serif; 43 | text-rendering: optimizelegibility; } 44 | .ng-annotate-text-popup, .ng-annotate-text-popup * { 45 | -moz-box-sizing: border-box; 46 | box-sizing: border-box; } 47 | .ng-annotate-text-popup label { 48 | cursor: pointer; } 49 | .ng-annotate-text-popup-docked::after { 50 | content: ""; 51 | position: absolute; 52 | z-index: 1; 53 | width: 10px; 54 | height: 10px; 55 | background: white; 56 | border-top: 1px solid rgba(0, 0, 0, 0.18); 57 | border-right: 1px solid rgba(0, 0, 0, 0.18); 58 | box-shadow: 4px -3px 8px rgba(0, 0, 0, 0.07); } 59 | .ng-annotate-text-popup-docked-left::after, .ng-annotate-text-popup-docked-right::after { 60 | top: 50%; 61 | margin-top: -5px; } 62 | .ng-annotate-text-popup-docked-top::after, .ng-annotate-text-popup-docked-bottom::after { 63 | left: 50%; 64 | margin-left: -5px; } 65 | .ng-annotate-text-popup-docked-left::after { 66 | -webkit-transform: rotate(45deg); 67 | -ms-transform: rotate(45deg); 68 | transform: rotate(45deg); 69 | right: -6px; } 70 | .ng-annotate-text-popup-docked-right::after { 71 | -webkit-transform: rotate(-135deg); 72 | -ms-transform: rotate(-135deg); 73 | transform: rotate(-135deg); 74 | left: -6px; } 75 | .ng-annotate-text-popup-docked-top::after { 76 | -webkit-transform: rotate(135deg); 77 | -ms-transform: rotate(135deg); 78 | transform: rotate(135deg); 79 | bottom: -6px; } 80 | .ng-annotate-text-popup-docked-bottom::after { 81 | -webkit-transform: rotate(-45deg); 82 | -ms-transform: rotate(-45deg); 83 | transform: rotate(-45deg); 84 | top: -6px; } 85 | .ng-annotate-text-popup-group { 86 | margin-bottom: 10px; } 87 | .ng-annotate-text-popup-group::before, .ng-annotate-text-popup-group::after { 88 | content: " "; 89 | display: table; } 90 | .ng-annotate-text-popup-group::after { 91 | clear: both; } 92 | .ng-annotate-text-popup-group:last-child { 93 | margin-bottom: 0; } 94 | .ng-annotate-text-popup-actions { 95 | margin-top: 15px; } 96 | .ng-annotate-text-popup-label { 97 | display: block; 98 | font-weight: bold; 99 | margin-bottom: 5px; } 100 | .ng-annotate-text-popup-field { 101 | display: block; 102 | -moz-box-sizing: border-box; 103 | box-sizing: border-box; 104 | width: 100%; 105 | padding: 3px; 106 | color: #333333; 107 | background: white; 108 | border: 1px solid #cccccc; 109 | border-radius: 3px; 110 | font-size: inherit; } 111 | .ng-annotate-text-popup-points { 112 | display: table; 113 | width: 100%; } 114 | .ng-annotate-text-popup-points-label, .ng-annotate-text-popup-points-field { 115 | display: table-cell; } 116 | .ng-annotate-text-popup-points-label { 117 | padding-right: 10px; } 118 | .ng-annotate-text-popup-colors, .ng-annotate-text-popup-templates { 119 | list-style: none; 120 | margin: 0; 121 | padding: 0; } 122 | .ng-annotate-text-popup-colors li { 123 | float: left; } 124 | .ng-annotate-text-popup-colors li + li { 125 | margin-left: 5px; } 126 | .ng-annotate-text-popup-templates li + li { 127 | margin-top: 5px; } 128 | .ng-annotate-text-tooltip { 129 | pointer-events: none; 130 | display: none; 131 | position: absolute; 132 | z-index: 1000; 133 | max-width: 20em; 134 | padding: 5px 10px 4px; 135 | color: #f7f7f7; 136 | background: rgba(0, 0, 0, 0.85); 137 | border-radius: 5px; 138 | box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); 139 | font: 13px/1.38462 "Helvetica Neue", Helvetica, Arial, sans-serif; 140 | text-shadow: 0 0 2px #000; } 141 | .ng-annotate-text-tooltip-docked::after { 142 | content: ""; 143 | position: absolute; 144 | z-index: 1; 145 | border: 4px solid; 146 | border-color: rgba(0, 0, 0, 0.85) rgba(0, 0, 0, 0.85) transparent transparent; 147 | box-shadow: 4px -3px 8px rgba(0, 0, 0, 0.07); } 148 | .ng-annotate-text-tooltip-docked-left::after, .ng-annotate-text-tooltip-docked-right::after { 149 | top: 50%; 150 | margin-top: -4px; } 151 | .ng-annotate-text-tooltip-docked-top::after, .ng-annotate-text-tooltip-docked-bottom::after { 152 | left: 50%; 153 | margin-left: -4px; } 154 | .ng-annotate-text-tooltip-docked-left::after { 155 | -webkit-transform: rotate(45deg); 156 | -ms-transform: rotate(45deg); 157 | transform: rotate(45deg); 158 | right: -4px; } 159 | .ng-annotate-text-tooltip-docked-right::after { 160 | -webkit-transform: rotate(-135deg); 161 | -ms-transform: rotate(-135deg); 162 | transform: rotate(-135deg); 163 | left: -4px; } 164 | .ng-annotate-text-tooltip-docked-top::after { 165 | -webkit-transform: rotate(135deg); 166 | -ms-transform: rotate(135deg); 167 | transform: rotate(135deg); 168 | bottom: -4px; } 169 | .ng-annotate-text-tooltip-docked-bottom::after { 170 | -webkit-transform: rotate(-45deg); 171 | -ms-transform: rotate(-45deg); 172 | transform: rotate(-45deg); 173 | top: -4px; } 174 | .ng-annotate-text-tooltip-points { 175 | float: right; } 176 | .ng-annotate-text-tooltip-points, .ng-annotate-text-tooltip-comment { 177 | padding-bottom: 1px; } 178 | .ng-annotate-text-tooltip-points + .ng-annotate-text-tooltip-comment::before { 179 | content: ""; 180 | float: right; 181 | width: 20px; 182 | height: 1.38462em; 183 | margin-bottom: 1px; } 184 | .ng-annotate-text-btn { 185 | padding: 5px 10px; 186 | cursor: pointer; 187 | color: #444444; 188 | background: whitesmoke -webkit-linear-gradient(top, rgba(255, 255, 255, 0.15), rgba(0, 0, 0, 0.1)); 189 | background: whitesmoke linear-gradient(to bottom, rgba(255, 255, 255, 0.15), rgba(0, 0, 0, 0.1)); 190 | border: 1px solid rgba(0, 0, 0, 0.2); 191 | border-radius: 3px; 192 | box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 3px rgba(0, 0, 0, 0.1); 193 | font: inherit; 194 | text-shadow: 0 1px 1px #fff; } 195 | .ng-annotate-text-btn:active { 196 | background-image: -webkit-linear-gradient(bottom, rgba(255, 255, 255, 0), rgba(0, 0, 0, 0.1)); 197 | background-image: linear-gradient(to top, rgba(255, 255, 255, 0), rgba(0, 0, 0, 0.1)); 198 | box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); } 199 | .ng-annotate-text-btn-save, .ng-annotate-text-btn-delete { 200 | text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3); } 201 | .ng-annotate-text-btn-save { 202 | float: right; 203 | color: white; 204 | background-color: #1bb352; } 205 | .ng-annotate-text-btn-delete { 206 | color: white; 207 | background-color: #d94155; } 208 | .ng-annotate-text-swatch { 209 | -webkit-transition: border-color 0.15s; 210 | transition: border-color 0.15s; 211 | position: relative; 212 | display: block; 213 | width: 100%; 214 | cursor: pointer; 215 | border-radius: 3px; 216 | border: 1px solid rgba(0, 0, 0, 0.075); 217 | font: inherit; 218 | text-align: left; } 219 | .ng-annotate-text-swatch:hover { 220 | border-color: rgba(0, 0, 0, 0.3); } 221 | .ng-annotate-text-swatch-active::before { 222 | content: ""; 223 | position: absolute; 224 | top: -3px; 225 | bottom: -3px; 226 | left: -3px; 227 | right: -3px; 228 | border: 1px solid rgba(0, 0, 0, 0.3); 229 | border-radius: 4px; } 230 | .ng-annotate-text-swatch-color { 231 | width: 30px; 232 | height: 22.5px; 233 | padding: 0; 234 | text-indent: 9999px; } 235 | .ng-annotate-text-swatch-template { 236 | padding: 2.5px 5px; } 237 | .ng-annotate-text-swatch-template-name { 238 | float: left; } 239 | .ng-annotate-text-swatch-template-points { 240 | float: right; } 241 | 242 | /*# sourceMappingURL=ng-annotate-text-latest.css.map */ -------------------------------------------------------------------------------- /dist/ng-annotate-text-latest.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"ng-annotate-text-latest.css","names":[],"mappings":"","sources":["ng-annotate-text.css"],"sourcesContent":[".ng-annotate-text-type- {\n border-bottom: 1px solid #000; }\n.ng-annotate-text-type-red {\n color: #000;\n background: #fcbcbc;\n border-color: #fcbcbc; }\n.ng-annotate-text-type-green {\n color: #000;\n background: #c7fcbc;\n border-color: #c7fcbc; }\n.ng-annotate-text-type-blue {\n color: #000;\n background: #bcdffc;\n border-color: #bcdffc; }\n.ng-annotate-text-type-pink {\n color: #000;\n background: #fcbcfa;\n border-color: #fcbcfa; }\n.ng-annotate-text-type-yellow {\n color: #000;\n background: #f8f89b;\n border-color: #f8f89b; }\n.ng-annotate-text-type-aqua {\n color: #000;\n background: #bcfcf7;\n border-color: #bcfcf7; }\n.ng-annotate-text-type-strike {\n text-decoration: line-through; }\n.ng-annotate-text-annotation {\n cursor: pointer; }\n.ng-annotate-text-popup {\n display: none;\n position: absolute;\n z-index: 990;\n width: 227px;\n padding: 10px;\n color: #333333;\n background: white;\n border: 1px solid rgba(0, 0, 0, 0.18);\n border-radius: 5px;\n box-shadow: 0 1px 10px rgba(0, 0, 0, 0.2);\n font: 13px/1.38462 \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n text-rendering: optimizelegibility; }\n .ng-annotate-text-popup, .ng-annotate-text-popup * {\n box-sizing: border-box; }\n .ng-annotate-text-popup label {\n cursor: pointer; }\n .ng-annotate-text-popup-docked::after {\n content: \"\";\n position: absolute;\n z-index: 1;\n width: 10px;\n height: 10px;\n background: white;\n border-top: 1px solid rgba(0, 0, 0, 0.18);\n border-right: 1px solid rgba(0, 0, 0, 0.18);\n box-shadow: 4px -3px 8px rgba(0, 0, 0, 0.07); }\n .ng-annotate-text-popup-docked-left::after, .ng-annotate-text-popup-docked-right::after {\n top: 50%;\n margin-top: -5px; }\n .ng-annotate-text-popup-docked-top::after, .ng-annotate-text-popup-docked-bottom::after {\n left: 50%;\n margin-left: -5px; }\n .ng-annotate-text-popup-docked-left::after {\n transform: rotate(45deg);\n right: -6px; }\n .ng-annotate-text-popup-docked-right::after {\n transform: rotate(-135deg);\n left: -6px; }\n .ng-annotate-text-popup-docked-top::after {\n transform: rotate(135deg);\n bottom: -6px; }\n .ng-annotate-text-popup-docked-bottom::after {\n transform: rotate(-45deg);\n top: -6px; }\n .ng-annotate-text-popup-group {\n margin-bottom: 10px; }\n .ng-annotate-text-popup-group::before, .ng-annotate-text-popup-group::after {\n content: \" \";\n display: table; }\n .ng-annotate-text-popup-group::after {\n clear: both; }\n .ng-annotate-text-popup-group:last-child {\n margin-bottom: 0; }\n .ng-annotate-text-popup-actions {\n margin-top: 15px; }\n .ng-annotate-text-popup-label {\n display: block;\n font-weight: bold;\n margin-bottom: 5px; }\n .ng-annotate-text-popup-field {\n display: block;\n box-sizing: border-box;\n width: 100%;\n padding: 3px;\n color: #333333;\n background: white;\n border: 1px solid #cccccc;\n border-radius: 3px;\n font-size: inherit; }\n .ng-annotate-text-popup-points {\n display: table;\n width: 100%; }\n .ng-annotate-text-popup-points-label, .ng-annotate-text-popup-points-field {\n display: table-cell; }\n .ng-annotate-text-popup-points-label {\n padding-right: 10px; }\n .ng-annotate-text-popup-colors, .ng-annotate-text-popup-templates {\n list-style: none;\n margin: 0;\n padding: 0; }\n .ng-annotate-text-popup-colors li {\n float: left; }\n .ng-annotate-text-popup-colors li + li {\n margin-left: 5px; }\n .ng-annotate-text-popup-templates li + li {\n margin-top: 5px; }\n.ng-annotate-text-tooltip {\n pointer-events: none;\n display: none;\n position: absolute;\n z-index: 1000;\n max-width: 20em;\n padding: 5px 10px 4px;\n color: #f7f7f7;\n background: rgba(0, 0, 0, 0.85);\n border-radius: 5px;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);\n font: 13px/1.38462 \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n text-shadow: 0 0 2px #000; }\n .ng-annotate-text-tooltip-docked::after {\n content: \"\";\n position: absolute;\n z-index: 1;\n border: 4px solid;\n border-color: rgba(0, 0, 0, 0.85) rgba(0, 0, 0, 0.85) transparent transparent;\n box-shadow: 4px -3px 8px rgba(0, 0, 0, 0.07); }\n .ng-annotate-text-tooltip-docked-left::after, .ng-annotate-text-tooltip-docked-right::after {\n top: 50%;\n margin-top: -4px; }\n .ng-annotate-text-tooltip-docked-top::after, .ng-annotate-text-tooltip-docked-bottom::after {\n left: 50%;\n margin-left: -4px; }\n .ng-annotate-text-tooltip-docked-left::after {\n transform: rotate(45deg);\n right: -4px; }\n .ng-annotate-text-tooltip-docked-right::after {\n transform: rotate(-135deg);\n left: -4px; }\n .ng-annotate-text-tooltip-docked-top::after {\n transform: rotate(135deg);\n bottom: -4px; }\n .ng-annotate-text-tooltip-docked-bottom::after {\n transform: rotate(-45deg);\n top: -4px; }\n .ng-annotate-text-tooltip-points {\n float: right; }\n .ng-annotate-text-tooltip-points, .ng-annotate-text-tooltip-comment {\n padding-bottom: 1px; }\n .ng-annotate-text-tooltip-points + .ng-annotate-text-tooltip-comment::before {\n content: \"\";\n float: right;\n width: 20px;\n height: 1.38462em;\n margin-bottom: 1px; }\n.ng-annotate-text-btn {\n padding: 5px 10px;\n cursor: pointer;\n color: #444444;\n background: whitesmoke linear-gradient(to bottom, rgba(255, 255, 255, 0.15), rgba(0, 0, 0, 0.1));\n border: 1px solid rgba(0, 0, 0, 0.2);\n border-radius: 3px;\n box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 3px rgba(0, 0, 0, 0.1);\n font: inherit;\n text-shadow: 0 1px 1px #fff; }\n .ng-annotate-text-btn:active {\n background-image: linear-gradient(to top, rgba(255, 255, 255, 0), rgba(0, 0, 0, 0.1));\n box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); }\n .ng-annotate-text-btn-save, .ng-annotate-text-btn-delete {\n text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3); }\n .ng-annotate-text-btn-save {\n float: right;\n color: white;\n background-color: #1bb352; }\n .ng-annotate-text-btn-delete {\n color: white;\n background-color: #d94155; }\n.ng-annotate-text-swatch {\n transition: border-color 0.15s;\n position: relative;\n display: block;\n width: 100%;\n cursor: pointer;\n border-radius: 3px;\n border: 1px solid rgba(0, 0, 0, 0.075);\n font: inherit;\n text-align: left; }\n .ng-annotate-text-swatch:hover {\n border-color: rgba(0, 0, 0, 0.3); }\n .ng-annotate-text-swatch-active::before {\n content: \"\";\n position: absolute;\n top: -3px;\n bottom: -3px;\n left: -3px;\n right: -3px;\n border: 1px solid rgba(0, 0, 0, 0.3);\n border-radius: 4px; }\n .ng-annotate-text-swatch-color {\n width: 30px;\n height: 22.5px;\n padding: 0;\n text-indent: 9999px; }\n .ng-annotate-text-swatch-template {\n padding: 2.5px 5px; }\n .ng-annotate-text-swatch-template-name {\n float: left; }\n .ng-annotate-text-swatch-template-points {\n float: right; }\n"],"sourceRoot":"/source/"} -------------------------------------------------------------------------------- /dist/ng-annotate-text-latest.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var annotationIdCounter, getAnnotationById, insertAt, ngAnnotateText, parseAnnotations, sortAnnotationsByEndIndex; 3 | 4 | ngAnnotateText = angular.module("ngAnnotateText", []); 5 | 6 | annotationIdCounter = 0; 7 | 8 | insertAt = function(text, index, string) { 9 | return text.substr(0, index) + string + text.substr(index); 10 | }; 11 | 12 | sortAnnotationsByEndIndex = function(annotations) { 13 | return annotations.sort(function(a, b) { 14 | if (a.endIndex < b.endIndex) { 15 | return -1; 16 | } else if (a.endIndex > b.endIndex) { 17 | return 1; 18 | } 19 | return 0; 20 | }); 21 | }; 22 | 23 | parseAnnotations = function(text, annotations, indexOffset) { 24 | var annotation, i, _i, _ref; 25 | if (annotations == null) { 26 | annotations = []; 27 | } 28 | if (indexOffset == null) { 29 | indexOffset = 0; 30 | } 31 | if (annotations.length === 0) { 32 | return text; 33 | } 34 | annotations = sortAnnotationsByEndIndex(annotations); 35 | for (i = _i = _ref = annotations.length - 1; _i >= 0; i = _i += -1) { 36 | annotation = annotations[i]; 37 | text = insertAt(text, annotation.endIndex + indexOffset, ""); 38 | if (annotation.children.length) { 39 | text = parseAnnotations(text, annotation.children, annotation.startIndex + indexOffset); 40 | } 41 | text = insertAt(text, annotation.startIndex + indexOffset, ""); 42 | } 43 | return text; 44 | }; 45 | 46 | getAnnotationById = function(annotations, aId) { 47 | var a, an, _i, _len; 48 | for (_i = 0, _len = annotations.length; _i < _len; _i++) { 49 | a = annotations[_i]; 50 | if (aId === a.id) { 51 | return a; 52 | } 53 | if (a.children.length > 0) { 54 | an = getAnnotationById(a.children, aId); 55 | if (an !== void 0) { 56 | return an; 57 | } 58 | } 59 | } 60 | }; 61 | 62 | ngAnnotateText.factory("NGAnnotateTextPopup", function() { 63 | return function(args) { 64 | args = angular.extend({ 65 | scope: null, 66 | callbacks: {}, 67 | template: "
", 68 | $anchor: null, 69 | preferredAxis: 'x', 70 | offset: 0, 71 | positionClass: '{{position}}' 72 | }, args); 73 | return angular.extend(this, args, { 74 | $el: angular.element(args.template), 75 | show: function(speed) { 76 | if (speed == null) { 77 | speed = "fast"; 78 | } 79 | this.$el.fadeIn(speed); 80 | this.reposition(); 81 | if (typeof this.callbacks.show === "function") { 82 | return this.callbacks.show(this.$el); 83 | } 84 | }, 85 | hide: function(speed) { 86 | if (speed == null) { 87 | speed = "fast"; 88 | } 89 | this.$el.fadeOut(speed); 90 | if (typeof this.callbacks.hide === "function") { 91 | return this.callbacks.hide(this.$el); 92 | } 93 | }, 94 | isVisible: function() { 95 | return this.$el.is(":visible"); 96 | }, 97 | destroy: function(cb) { 98 | var $el, scope; 99 | if (cb == null) { 100 | cb = angular.noop; 101 | } 102 | scope = this.scope; 103 | $el = this.$el; 104 | return this.hide(function() { 105 | if (typeof cb === "function") { 106 | cb(); 107 | } 108 | scope.$destroy(); 109 | return $el.remove(); 110 | }); 111 | }, 112 | stopDestroy: function() { 113 | return this.$el.stop(true).show("fast"); 114 | }, 115 | reposition: function() { 116 | var anchorEl, pos, posX, posY, targetEl; 117 | targetEl = this.$el[0]; 118 | anchorEl = this.$anchor[0]; 119 | if (!(targetEl || anchorEl)) { 120 | return; 121 | } 122 | pos = { 123 | left: null, 124 | top: null, 125 | target: targetEl.getBoundingClientRect(), 126 | anchor: anchorEl.getBoundingClientRect(), 127 | viewport: { 128 | width: window.innerWidth, 129 | height: window.innerHeight 130 | }, 131 | scroll: { 132 | top: document.body.scrollTop, 133 | left: document.body.scrollLeft 134 | } 135 | }; 136 | if (!(pos.target.width > 0 && pos.target.height > 0)) { 137 | return; 138 | } 139 | posX = this.getNewPositionOnAxis(pos, 'x'); 140 | posY = this.getNewPositionOnAxis(pos, 'y'); 141 | if (this.preferredAxis === 'x') { 142 | if (posX && typeof posX.pos === 'number') { 143 | pos.left = posX.pos; 144 | pos.edge = posX.edge; 145 | } else if (posY) { 146 | pos.top = posY.pos; 147 | pos.edge = posY.edge; 148 | } 149 | } else { 150 | if (posY && typeof posY.pos === 'number') { 151 | pos.top = posY.pos; 152 | pos.edge = posY.edge; 153 | } else if (posX) { 154 | pos.left = posX.pos; 155 | pos.edge = posX.edge; 156 | } 157 | } 158 | if (pos.left === null && pos.top === null) { 159 | pos.left = pos.scroll.left + (pos.viewport.width / 2) - (pos.target.width / 2); 160 | pos.top = pos.scroll.top + (pos.viewport.height / 2) - (pos.target.height / 2); 161 | } else if (pos.left === null) { 162 | pos.left = this.getNewCenterPositionOnAxis(pos, 'x'); 163 | } else if (pos.top === null) { 164 | pos.top = this.getNewCenterPositionOnAxis(pos, 'y'); 165 | } 166 | this.$el.addClass(pos.edge && this.positionClass.replace("{{position}}", pos.edge)).css({ 167 | top: Math.round(pos.top) || 0, 168 | left: Math.round(pos.left) || 0 169 | }); 170 | }, 171 | getNewPositionOnAxis: function(pos, axis) { 172 | var axisPos, end, size, start; 173 | start = { 174 | x: 'left', 175 | y: 'top' 176 | }[axis]; 177 | end = { 178 | x: 'right', 179 | y: 'bottom' 180 | }[axis]; 181 | size = { 182 | x: 'width', 183 | y: 'height' 184 | }[axis]; 185 | if (pos.anchor[start] - this.offset >= pos.target[size]) { 186 | axisPos = { 187 | pos: pos.scroll[start] + pos.anchor[start] - this.offset - pos.target[size], 188 | edge: start 189 | }; 190 | } else if (pos.viewport[size] - pos.anchor[end] - this.offset >= pos.target[size]) { 191 | axisPos = { 192 | pos: pos.scroll[start] + pos.anchor[end] + this.offset, 193 | edge: end 194 | }; 195 | } 196 | return axisPos; 197 | }, 198 | getNewCenterPositionOnAxis: function(pos, axis) { 199 | var centerPos, size, start; 200 | start = { 201 | x: 'left', 202 | y: 'top' 203 | }[axis]; 204 | size = { 205 | x: 'width', 206 | y: 'height' 207 | }[axis]; 208 | centerPos = pos.scroll[start] + pos.anchor[start] + (pos.anchor[size] / 2) - (pos.target[size] / 2); 209 | return Math.max(pos.scroll[start] + this.offset, Math.min(centerPos, pos.scroll[start] + pos.viewport[size] - pos.target[size] - this.offset)); 210 | } 211 | }); 212 | }; 213 | }); 214 | 215 | ngAnnotateText.factory("NGAnnotation", function() { 216 | var Annotation; 217 | Annotation = function(data) { 218 | angular.extend(this, { 219 | id: annotationIdCounter++, 220 | startIndex: null, 221 | endIndex: null, 222 | data: { 223 | points: 0 224 | }, 225 | type: "", 226 | children: [] 227 | }); 228 | if (data != null) { 229 | return angular.extend(this, data); 230 | } 231 | }; 232 | return Annotation; 233 | }); 234 | 235 | ngAnnotateText.directive("ngAnnotateText", function($rootScope, $compile, $http, $q, $controller, $sce, NGAnnotation, NGAnnotateTextPopup) { 236 | return { 237 | restrict: "E", 238 | scope: { 239 | text: "=", 240 | annotations: "=", 241 | readonly: "=", 242 | popupController: "=", 243 | popupTemplateUrl: "=", 244 | tooltipController: "=", 245 | tooltipTemplateUrl: "=", 246 | onAnnotate: "=", 247 | onAnnotateDelete: "=", 248 | onAnnotateError: "=", 249 | onPopupShow: "=", 250 | onPopupHide: "=", 251 | popupOffset: "=" 252 | }, 253 | template: "

", 254 | replace: true, 255 | compile: function(el, attr) { 256 | if (attr.readonly == null) { 257 | attr.readonly = false; 258 | } 259 | return this.postLink; 260 | }, 261 | postLink: function($scope, element, attrs) { 262 | var POPUP_OFFSET, activePopup, activeTooltip, clearPopup, clearPopups, clearSelection, clearTooltip, createAnnotation, loadAnnotationPopup, onAnnotationsChange, onClick, onMouseEnter, onMouseLeave, onSelect, popupTemplateData, removeAnnotation, removeChildren, tooltipTemplateData, _ref; 263 | POPUP_OFFSET = (_ref = $scope.popupOffset) != null ? _ref : 10; 264 | activePopup = null; 265 | activeTooltip = null; 266 | popupTemplateData = ""; 267 | tooltipTemplateData = ""; 268 | onAnnotationsChange = function() { 269 | var t; 270 | if (($scope.text == null) || !$scope.text.length) { 271 | return; 272 | } 273 | t = parseAnnotations($scope.text, $scope.annotations); 274 | return $scope.content = $sce.trustAsHtml(t); 275 | }; 276 | $scope.$watch("text", onAnnotationsChange); 277 | $scope.$watch("annotations", onAnnotationsChange, true); 278 | clearPopup = function() { 279 | var tId; 280 | if (activePopup == null) { 281 | return; 282 | } 283 | tId = activePopup.scope.$annotation.id; 284 | return activePopup.destroy(function() { 285 | if (activePopup.scope.$annotation.id === tId) { 286 | return activePopup = null; 287 | } 288 | }); 289 | }; 290 | clearTooltip = function() { 291 | var tooltip; 292 | tooltip = activeTooltip; 293 | if (tooltip == null) { 294 | return; 295 | } 296 | return tooltip.destroy(function() { 297 | if (activeTooltip === tooltip) { 298 | return activeTooltip = null; 299 | } 300 | }); 301 | }; 302 | clearPopups = function() { 303 | clearPopup(); 304 | return clearTooltip(); 305 | }; 306 | $scope.$on("$destroy", clearPopups); 307 | $scope.$on("ngAnnotateText.clearPopups", clearPopups); 308 | if ($scope.popupTemplateUrl) { 309 | $http.get($scope.popupTemplateUrl).then(function(response) { 310 | return popupTemplateData = response.data; 311 | }); 312 | } 313 | if ($scope.tooltipTemplateUrl) { 314 | $http.get($scope.tooltipTemplateUrl).then(function(response) { 315 | return tooltipTemplateData = response.data; 316 | }); 317 | } 318 | removeChildren = function(annotation) { 319 | var a, i, _i, _ref1, _results; 320 | _results = []; 321 | for (i = _i = _ref1 = annotation.children.length - 1; _i >= 0; i = _i += -1) { 322 | a = annotation.children[i]; 323 | removeChildren(a); 324 | _results.push(a.children.splice(i, 1)); 325 | } 326 | return _results; 327 | }; 328 | removeAnnotation = function(id, annotations) { 329 | var a, i, _i, _len; 330 | for (i = _i = 0, _len = annotations.length; _i < _len; i = ++_i) { 331 | a = annotations[i]; 332 | removeAnnotation(id, a.children); 333 | if (a.id === id) { 334 | removeChildren(a); 335 | annotations.splice(i, 1); 336 | return; 337 | } 338 | } 339 | }; 340 | createAnnotation = function() { 341 | var annotation, annotationParentCollection, attrId, parentAnnotation, parentId, prevAnnotation, prevSiblingId, prevSiblingSpan, range, sel; 342 | annotation = new NGAnnotation(); 343 | sel = window.getSelection(); 344 | if (sel.isCollapsed) { 345 | throw new Error("NG_ANNOTATE_TEXT_NO_TEXT_SELECTED"); 346 | } 347 | range = sel.getRangeAt(0); 348 | if (range.startContainer !== range.endContainer) { 349 | throw new Error("NG_ANNOTATE_TEXT_PARTIAL_NODE_SELECTED"); 350 | } 351 | if (range.startContainer.parentNode.nodeName === "SPAN") { 352 | parentId = (attrId = range.startContainer.parentNode.getAttribute("data-annotation-id")) != null ? parseInt(attrId, 10) : void 0; 353 | if (parentId === void 0) { 354 | throw new Error("NG_ANNOTATE_TEXT_ILLEGAL_SELECTION"); 355 | } 356 | parentAnnotation = getAnnotationById($scope.annotations, parentId); 357 | annotationParentCollection = parentAnnotation.children; 358 | } else { 359 | annotationParentCollection = $scope.annotations; 360 | } 361 | if (annotationParentCollection.length) { 362 | prevSiblingSpan = range.startContainer.previousSibling; 363 | if (prevSiblingSpan != null) { 364 | prevSiblingId = (attrId = prevSiblingSpan.getAttribute("data-annotation-id")) != null ? parseInt(attrId, 10) : void 0; 365 | if (prevSiblingId == null) { 366 | throw new Error("NG_ANNOTATE_TEXT_ILLEGAL_SELECTION"); 367 | } 368 | prevAnnotation = getAnnotationById($scope.annotations, prevSiblingId); 369 | annotation.startIndex = prevAnnotation.endIndex + range.startOffset; 370 | annotation.endIndex = prevAnnotation.endIndex + range.endOffset; 371 | } else { 372 | annotation.startIndex = range.startOffset; 373 | annotation.endIndex = range.endOffset; 374 | } 375 | } else { 376 | annotation.startIndex = range.startOffset; 377 | annotation.endIndex = range.endOffset; 378 | } 379 | annotationParentCollection.push(annotation); 380 | clearSelection(); 381 | return annotation; 382 | }; 383 | clearSelection = function() { 384 | if (document.selection) { 385 | return document.selection.empty(); 386 | } else if (window.getSelection && window.getSelection().empty) { 387 | return window.getSelection().empty(); 388 | } else if (window.getSelection && window.getSelection().removeAllRanges) { 389 | return window.getSelection().removeAllRanges(); 390 | } 391 | }; 392 | onSelect = function(event) { 393 | var $span, annotation, ex; 394 | if (popupTemplateData.length === 0) { 395 | return; 396 | } 397 | try { 398 | annotation = createAnnotation(); 399 | $scope.$apply(); 400 | $span = element.find(".ng-annotate-text-" + annotation.id); 401 | } catch (_error) { 402 | ex = _error; 403 | if ($scope.onAnnotateError != null) { 404 | $scope.onAnnotateError(ex); 405 | } 406 | return; 407 | } 408 | clearPopups(); 409 | return loadAnnotationPopup(annotation, $span, true); 410 | }; 411 | onClick = function(event) { 412 | var $target, annotation, attrId, targetId; 413 | if (popupTemplateData.length === 0) { 414 | return; 415 | } 416 | $target = angular.element(event.target); 417 | targetId = (attrId = $target.attr("data-annotation-id")) != null ? parseInt(attrId, 10) : void 0; 418 | if (targetId == null) { 419 | return; 420 | } 421 | if ((activePopup != null) && activePopup.scope.$annotation.id === targetId) { 422 | clearPopup(); 423 | return; 424 | } 425 | annotation = getAnnotationById($scope.annotations, targetId); 426 | clearPopups(); 427 | return loadAnnotationPopup(annotation, $target, false); 428 | }; 429 | onMouseEnter = function(event) { 430 | var $target, annotation, attrId, controller, locals, targetId, tooltip; 431 | if (tooltipTemplateData.length === 0) { 432 | return; 433 | } 434 | event.stopPropagation(); 435 | $target = angular.element(event.target); 436 | targetId = (attrId = $target.attr("data-annotation-id")) != null ? parseInt(attrId, 10) : void 0; 437 | if ((activeTooltip != null) && activeTooltip.scope.$annotation.id === targetId) { 438 | activeTooltip.stopDestroy(); 439 | return; 440 | } else { 441 | clearTooltip(); 442 | } 443 | if (targetId == null) { 444 | return; 445 | } 446 | annotation = getAnnotationById($scope.annotations, targetId); 447 | if ((activePopup != null) || (!annotation.data.comment && !annotation.data.points)) { 448 | return; 449 | } 450 | tooltip = new NGAnnotateTextPopup({ 451 | scope: $rootScope.$new(), 452 | template: "
", 453 | positionClass: "ng-annotate-text-tooltip-docked ng-annotate-text-tooltip-docked-{{position}}", 454 | $anchor: $target, 455 | preferredAxis: 'y', 456 | offset: POPUP_OFFSET 457 | }); 458 | tooltip.scope.$annotation = annotation; 459 | activeTooltip = tooltip; 460 | locals = { 461 | $scope: tooltip.scope, 462 | $template: tooltipTemplateData 463 | }; 464 | tooltip.$el.html(locals.$template); 465 | tooltip.$el.appendTo("body"); 466 | if ($scope.tooltipController) { 467 | controller = $controller($scope.tooltipController, locals); 468 | tooltip.$el.data("$ngControllerController", controller); 469 | tooltip.$el.children().data("$ngControllerController", controller); 470 | } 471 | $compile(tooltip.$el)(tooltip.scope); 472 | tooltip.scope.$apply(); 473 | return tooltip.show(); 474 | }; 475 | onMouseLeave = function(event) { 476 | var $target, attrId, targetId; 477 | event.stopPropagation(); 478 | $target = angular.element(event.target); 479 | targetId = (attrId = $target.attr("data-annotation-id")) != null ? parseInt(attrId, 10) : void 0; 480 | if (targetId == null) { 481 | return; 482 | } 483 | return clearTooltip(); 484 | }; 485 | loadAnnotationPopup = function(annotation, anchor, isNew) { 486 | var controller, locals, popup; 487 | popup = new NGAnnotateTextPopup({ 488 | scope: $rootScope.$new(), 489 | callbacks: { 490 | show: $scope.onPopupShow, 491 | hide: $scope.onPopupHide 492 | }, 493 | template: "
", 494 | positionClass: "ng-annotate-text-popup-docked ng-annotate-text-popup-docked-{{position}}", 495 | $anchor: anchor, 496 | offset: POPUP_OFFSET 497 | }); 498 | popup.scope.$isNew = isNew; 499 | popup.scope.$annotation = annotation; 500 | popup.scope.$readonly = $scope.readonly; 501 | popup.scope.$reject = function() { 502 | removeAnnotation(annotation.id, $scope.annotations); 503 | if ($scope.onAnnotateDelete != null) { 504 | $scope.onAnnotateDelete(annotation); 505 | } 506 | clearPopup(); 507 | }; 508 | popup.scope.$close = function() { 509 | if ($scope.onAnnotate != null) { 510 | $scope.onAnnotate(popup.scope.$annotation); 511 | } 512 | clearPopup(); 513 | }; 514 | activePopup = popup; 515 | locals = { 516 | $scope: popup.scope, 517 | $template: popupTemplateData 518 | }; 519 | popup.$el.html(locals.$template); 520 | popup.$el.appendTo("body"); 521 | if ($scope.popupController) { 522 | controller = $controller($scope.popupController, locals); 523 | popup.$el.data("$ngControllerController", controller); 524 | popup.$el.children().data("$ngControllerController", controller); 525 | } 526 | $compile(popup.$el)(popup.scope); 527 | popup.scope.$apply(); 528 | return popup.show(); 529 | }; 530 | element.on("mouseenter", "span", onMouseEnter); 531 | element.on("mouseleave", "span", onMouseLeave); 532 | return element.on("mouseup", function(event) { 533 | var selection; 534 | selection = window.getSelection(); 535 | if (!selection.isCollapsed && !$scope.readonly) { 536 | return onSelect(event); 537 | } else if (selection.isCollapsed && event.target.nodeName === "SPAN") { 538 | return onClick(event); 539 | } else if (selection.isCollapsed) { 540 | return clearPopups(); 541 | } 542 | }); 543 | } 544 | }; 545 | }); 546 | 547 | }).call(this); 548 | 549 | //# sourceMappingURL=ng-annotate-text-latest.js.map -------------------------------------------------------------------------------- /dist/ng-annotate-text-latest.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["ng-annotate-text.coffee"],"names":[],"mappings":"AAAA;AAAA,MAAA,6GAAA;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CAAA,CAAoB,CAAC,IAArB,CAA0B,yBAA1B,EAAqD,UAArD,CAFA,CADD;WArCA;AAAA,UA0CA,QAAA,CAAS,KAAK,CAAC,GAAf,CAAA,CAAoB,KAAK,CAAC,KAA1B,CA1CA,CAAA;AAAA,UA2CA,KAAK,CAAC,KAAK,CAAC,MAAZ,CAAA,CA3CA,CAAA;iBA4CA,KAAK,CAAC,IAAN,CAAA,EA7CqB;QAAA,CA3NtB,CAAA;AAAA,QA0QA,OAAO,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"]} -------------------------------------------------------------------------------- /dist/ng-annotate-text-latest.min.css: -------------------------------------------------------------------------------- 1 | .ng-annotate-text-type-{border-bottom:1px solid #000}.ng-annotate-text-type-red{color:#000;background:#fcbcbc;border-color:#fcbcbc}.ng-annotate-text-type-green{color:#000;background:#c7fcbc;border-color:#c7fcbc}.ng-annotate-text-type-blue{color:#000;background:#bcdffc;border-color:#bcdffc}.ng-annotate-text-type-pink{color:#000;background:#fcbcfa;border-color:#fcbcfa}.ng-annotate-text-type-yellow{color:#000;background:#f8f89b;border-color:#f8f89b}.ng-annotate-text-type-aqua{color:#000;background:#bcfcf7;border-color:#bcfcf7}.ng-annotate-text-type-strike{text-decoration:line-through}.ng-annotate-text-annotation{cursor:pointer}.ng-annotate-text-popup{display:none;position:absolute;z-index:990;width:227px;padding:10px;color:#333;background:#fff;border:1px solid rgba(0,0,0,.18);border-radius:5px;box-shadow:0 1px 10px rgba(0,0,0,.2);font:13px/1.38462 "Helvetica Neue",Helvetica,Arial,sans-serif;text-rendering:optimizelegibility}.ng-annotate-text-popup,.ng-annotate-text-popup *{-moz-box-sizing:border-box;box-sizing:border-box}.ng-annotate-text-popup label{cursor:pointer}.ng-annotate-text-popup-docked::after{content:"";position:absolute;z-index:1;width:10px;height:10px;background:#fff;border-top:1px solid rgba(0,0,0,.18);border-right:1px solid rgba(0,0,0,.18);box-shadow:4px -3px 8px rgba(0,0,0,.07)}.ng-annotate-text-popup-docked-left::after,.ng-annotate-text-popup-docked-right::after{top:50%;margin-top:-5px}.ng-annotate-text-popup-docked-bottom::after,.ng-annotate-text-popup-docked-top::after{left:50%;margin-left:-5px}.ng-annotate-text-popup-docked-left::after{-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);right:-6px}.ng-annotate-text-popup-docked-right::after{-webkit-transform:rotate(-135deg);-ms-transform:rotate(-135deg);transform:rotate(-135deg);left:-6px}.ng-annotate-text-popup-docked-top::after{-webkit-transform:rotate(135deg);-ms-transform:rotate(135deg);transform:rotate(135deg);bottom:-6px}.ng-annotate-text-popup-docked-bottom::after{-webkit-transform:rotate(-45deg);-ms-transform:rotate(-45deg);transform:rotate(-45deg);top:-6px}.ng-annotate-text-popup-group{margin-bottom:10px}.ng-annotate-text-popup-group::after,.ng-annotate-text-popup-group::before{content:" ";display:table}.ng-annotate-text-popup-group::after{clear:both}.ng-annotate-text-popup-group:last-child{margin-bottom:0}.ng-annotate-text-popup-actions{margin-top:15px}.ng-annotate-text-popup-label{display:block;font-weight:700;margin-bottom:5px}.ng-annotate-text-popup-field{display:block;-moz-box-sizing:border-box;box-sizing:border-box;width:100%;padding:3px;color:#333;background:#fff;border:1px solid #ccc;border-radius:3px;font-size:inherit}.ng-annotate-text-popup-points{display:table;width:100%}.ng-annotate-text-popup-points-field,.ng-annotate-text-popup-points-label{display:table-cell}.ng-annotate-text-popup-points-label{padding-right:10px}.ng-annotate-text-popup-colors,.ng-annotate-text-popup-templates{list-style:none;margin:0;padding:0}.ng-annotate-text-popup-colors li{float:left}.ng-annotate-text-popup-colors li+li{margin-left:5px}.ng-annotate-text-popup-templates li+li{margin-top:5px}.ng-annotate-text-tooltip{pointer-events:none;display:none;position:absolute;z-index:1000;max-width:20em;padding:5px 10px 4px;color:#f7f7f7;background:rgba(0,0,0,.85);border-radius:5px;box-shadow:0 1px 3px rgba(0,0,0,.3);font:13px/1.38462 "Helvetica Neue",Helvetica,Arial,sans-serif;text-shadow:0 0 2px #000}.ng-annotate-text-tooltip-docked::after{content:"";position:absolute;z-index:1;border:4px solid;border-color:rgba(0,0,0,.85) rgba(0,0,0,.85) transparent transparent;box-shadow:4px -3px 8px rgba(0,0,0,.07)}.ng-annotate-text-tooltip-docked-left::after,.ng-annotate-text-tooltip-docked-right::after{top:50%;margin-top:-4px}.ng-annotate-text-tooltip-docked-bottom::after,.ng-annotate-text-tooltip-docked-top::after{left:50%;margin-left:-4px}.ng-annotate-text-tooltip-docked-left::after{-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);right:-4px}.ng-annotate-text-tooltip-docked-right::after{-webkit-transform:rotate(-135deg);-ms-transform:rotate(-135deg);transform:rotate(-135deg);left:-4px}.ng-annotate-text-tooltip-docked-top::after{-webkit-transform:rotate(135deg);-ms-transform:rotate(135deg);transform:rotate(135deg);bottom:-4px}.ng-annotate-text-tooltip-docked-bottom::after{-webkit-transform:rotate(-45deg);-ms-transform:rotate(-45deg);transform:rotate(-45deg);top:-4px}.ng-annotate-text-tooltip-points{float:right}.ng-annotate-text-tooltip-comment,.ng-annotate-text-tooltip-points{padding-bottom:1px}.ng-annotate-text-tooltip-points+.ng-annotate-text-tooltip-comment::before{content:"";float:right;width:20px;height:1.38462em;margin-bottom:1px}.ng-annotate-text-btn{padding:5px 10px;cursor:pointer;color:#444;background:-webkit-linear-gradient(top,rgba(255,255,255,.15),rgba(0,0,0,.1)) #f5f5f5;background:linear-gradient(to bottom,rgba(255,255,255,.15),rgba(0,0,0,.1)) #f5f5f5;border:1px solid rgba(0,0,0,.2);border-radius:3px;box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 1px 3px rgba(0,0,0,.1);font:inherit;text-shadow:0 1px 1px #fff}.ng-annotate-text-btn:active{background-image:-webkit-linear-gradient(bottom,rgba(255,255,255,0),rgba(0,0,0,.1));background-image:linear-gradient(to top,rgba(255,255,255,0),rgba(0,0,0,.1));box-shadow:inset 0 1px 2px rgba(0,0,0,.1)}.ng-annotate-text-btn-delete,.ng-annotate-text-btn-save{text-shadow:0 1px 1px rgba(0,0,0,.3)}.ng-annotate-text-btn-save{float:right;color:#fff;background-color:#1bb352}.ng-annotate-text-btn-delete{color:#fff;background-color:#d94155}.ng-annotate-text-swatch{-webkit-transition:border-color .15s;transition:border-color .15s;position:relative;display:block;width:100%;cursor:pointer;border-radius:3px;border:1px solid rgba(0,0,0,.075);font:inherit;text-align:left}.ng-annotate-text-swatch:hover{border-color:rgba(0,0,0,.3)}.ng-annotate-text-swatch-active::before{content:"";position:absolute;top:-3px;bottom:-3px;left:-3px;right:-3px;border:1px solid rgba(0,0,0,.3);border-radius:4px}.ng-annotate-text-swatch-color{width:30px;height:22.5px;padding:0;text-indent:9999px}.ng-annotate-text-swatch-template{padding:2.5px 5px}.ng-annotate-text-swatch-template-name{float:left}.ng-annotate-text-swatch-template-points{float:right} 2 | /*# sourceMappingURL=ng-annotate-text-latest.min.css.map */ -------------------------------------------------------------------------------- /dist/ng-annotate-text-latest.min.css.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"ng-annotate-text-latest.min.css","names":[],"mappings":"","sources":["ng-annotate-text.css"],"sourcesContent":[".ng-annotate-text-type- {\n border-bottom: 1px solid #000; }\n.ng-annotate-text-type-red {\n color: #000;\n background: #fcbcbc;\n border-color: #fcbcbc; }\n.ng-annotate-text-type-green {\n color: #000;\n background: #c7fcbc;\n border-color: #c7fcbc; }\n.ng-annotate-text-type-blue {\n color: #000;\n background: #bcdffc;\n border-color: #bcdffc; }\n.ng-annotate-text-type-pink {\n color: #000;\n background: #fcbcfa;\n border-color: #fcbcfa; }\n.ng-annotate-text-type-yellow {\n color: #000;\n background: #f8f89b;\n border-color: #f8f89b; }\n.ng-annotate-text-type-aqua {\n color: #000;\n background: #bcfcf7;\n border-color: #bcfcf7; }\n.ng-annotate-text-type-strike {\n text-decoration: line-through; }\n.ng-annotate-text-annotation {\n cursor: pointer; }\n.ng-annotate-text-popup {\n display: none;\n position: absolute;\n z-index: 990;\n width: 227px;\n padding: 10px;\n color: #333333;\n background: white;\n border: 1px solid rgba(0, 0, 0, 0.18);\n border-radius: 5px;\n box-shadow: 0 1px 10px rgba(0, 0, 0, 0.2);\n font: 13px/1.38462 \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n text-rendering: optimizelegibility; }\n .ng-annotate-text-popup, .ng-annotate-text-popup * {\n box-sizing: border-box; }\n .ng-annotate-text-popup label {\n cursor: pointer; }\n .ng-annotate-text-popup-docked::after {\n content: \"\";\n position: absolute;\n z-index: 1;\n width: 10px;\n height: 10px;\n background: white;\n border-top: 1px solid rgba(0, 0, 0, 0.18);\n border-right: 1px solid rgba(0, 0, 0, 0.18);\n box-shadow: 4px -3px 8px rgba(0, 0, 0, 0.07); }\n .ng-annotate-text-popup-docked-left::after, .ng-annotate-text-popup-docked-right::after {\n top: 50%;\n margin-top: -5px; }\n .ng-annotate-text-popup-docked-top::after, .ng-annotate-text-popup-docked-bottom::after {\n left: 50%;\n margin-left: -5px; }\n .ng-annotate-text-popup-docked-left::after {\n transform: rotate(45deg);\n right: -6px; }\n .ng-annotate-text-popup-docked-right::after {\n transform: rotate(-135deg);\n left: -6px; }\n .ng-annotate-text-popup-docked-top::after {\n transform: rotate(135deg);\n bottom: -6px; }\n .ng-annotate-text-popup-docked-bottom::after {\n transform: rotate(-45deg);\n top: -6px; }\n .ng-annotate-text-popup-group {\n margin-bottom: 10px; }\n .ng-annotate-text-popup-group::before, .ng-annotate-text-popup-group::after {\n content: \" \";\n display: table; }\n .ng-annotate-text-popup-group::after {\n clear: both; }\n .ng-annotate-text-popup-group:last-child {\n margin-bottom: 0; }\n .ng-annotate-text-popup-actions {\n margin-top: 15px; }\n .ng-annotate-text-popup-label {\n display: block;\n font-weight: bold;\n margin-bottom: 5px; }\n .ng-annotate-text-popup-field {\n display: block;\n box-sizing: border-box;\n width: 100%;\n padding: 3px;\n color: #333333;\n background: white;\n border: 1px solid #cccccc;\n border-radius: 3px;\n font-size: inherit; }\n .ng-annotate-text-popup-points {\n display: table;\n width: 100%; }\n .ng-annotate-text-popup-points-label, .ng-annotate-text-popup-points-field {\n display: table-cell; }\n .ng-annotate-text-popup-points-label {\n padding-right: 10px; }\n .ng-annotate-text-popup-colors, .ng-annotate-text-popup-templates {\n list-style: none;\n margin: 0;\n padding: 0; }\n .ng-annotate-text-popup-colors li {\n float: left; }\n .ng-annotate-text-popup-colors li + li {\n margin-left: 5px; }\n .ng-annotate-text-popup-templates li + li {\n margin-top: 5px; }\n.ng-annotate-text-tooltip {\n pointer-events: none;\n display: none;\n position: absolute;\n z-index: 1000;\n max-width: 20em;\n padding: 5px 10px 4px;\n color: #f7f7f7;\n background: rgba(0, 0, 0, 0.85);\n border-radius: 5px;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);\n font: 13px/1.38462 \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n text-shadow: 0 0 2px #000; }\n .ng-annotate-text-tooltip-docked::after {\n content: \"\";\n position: absolute;\n z-index: 1;\n border: 4px solid;\n border-color: rgba(0, 0, 0, 0.85) rgba(0, 0, 0, 0.85) transparent transparent;\n box-shadow: 4px -3px 8px rgba(0, 0, 0, 0.07); }\n .ng-annotate-text-tooltip-docked-left::after, .ng-annotate-text-tooltip-docked-right::after {\n top: 50%;\n margin-top: -4px; }\n .ng-annotate-text-tooltip-docked-top::after, .ng-annotate-text-tooltip-docked-bottom::after {\n left: 50%;\n margin-left: -4px; }\n .ng-annotate-text-tooltip-docked-left::after {\n transform: rotate(45deg);\n right: -4px; }\n .ng-annotate-text-tooltip-docked-right::after {\n transform: rotate(-135deg);\n left: -4px; }\n .ng-annotate-text-tooltip-docked-top::after {\n transform: rotate(135deg);\n bottom: -4px; }\n .ng-annotate-text-tooltip-docked-bottom::after {\n transform: rotate(-45deg);\n top: -4px; }\n .ng-annotate-text-tooltip-points {\n float: right; }\n .ng-annotate-text-tooltip-points, .ng-annotate-text-tooltip-comment {\n padding-bottom: 1px; }\n .ng-annotate-text-tooltip-points + .ng-annotate-text-tooltip-comment::before {\n content: \"\";\n float: right;\n width: 20px;\n height: 1.38462em;\n margin-bottom: 1px; }\n.ng-annotate-text-btn {\n padding: 5px 10px;\n cursor: pointer;\n color: #444444;\n background: whitesmoke linear-gradient(to bottom, rgba(255, 255, 255, 0.15), rgba(0, 0, 0, 0.1));\n border: 1px solid rgba(0, 0, 0, 0.2);\n border-radius: 3px;\n box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 3px rgba(0, 0, 0, 0.1);\n font: inherit;\n text-shadow: 0 1px 1px #fff; }\n .ng-annotate-text-btn:active {\n background-image: linear-gradient(to top, rgba(255, 255, 255, 0), rgba(0, 0, 0, 0.1));\n box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); }\n .ng-annotate-text-btn-save, .ng-annotate-text-btn-delete {\n text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3); }\n .ng-annotate-text-btn-save {\n float: right;\n color: white;\n background-color: #1bb352; }\n .ng-annotate-text-btn-delete {\n color: white;\n background-color: #d94155; }\n.ng-annotate-text-swatch {\n transition: border-color 0.15s;\n position: relative;\n display: block;\n width: 100%;\n cursor: pointer;\n border-radius: 3px;\n border: 1px solid rgba(0, 0, 0, 0.075);\n font: inherit;\n text-align: left; }\n .ng-annotate-text-swatch:hover {\n border-color: rgba(0, 0, 0, 0.3); }\n .ng-annotate-text-swatch-active::before {\n content: \"\";\n position: absolute;\n top: -3px;\n bottom: -3px;\n left: -3px;\n right: -3px;\n border: 1px solid rgba(0, 0, 0, 0.3);\n border-radius: 4px; }\n .ng-annotate-text-swatch-color {\n width: 30px;\n height: 22.5px;\n padding: 0;\n text-indent: 9999px; }\n .ng-annotate-text-swatch-template {\n padding: 2.5px 5px; }\n .ng-annotate-text-swatch-template-name {\n float: left; }\n .ng-annotate-text-swatch-template-points {\n float: right; }\n"],"sourceRoot":"/source/"} -------------------------------------------------------------------------------- /dist/ng-annotate-text-latest.min.js: -------------------------------------------------------------------------------- 1 | (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); 2 | //# sourceMappingURL=ng-annotate-text-latest.min.js.map -------------------------------------------------------------------------------- /dist/ng-annotate-text-latest.min.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"ng-annotate-text-latest.min.js","sources":["ng-annotate-text.coffee"],"names":[],"mappings":"CAAA,WA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AAW,mBAEZ,MAAM,IAAI,KAAK,OAAO,WACtB,MAAM,IAAI,SAAS,QAEhB,OAAO,kBACT,WAAa,YAAY,OAAO,gBAAiB,QACjD,MAAM,IAAI,KAAK,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","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/"} -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var gulp = require("gulp"); 4 | var r = require("gulp-load-plugins")(); 5 | 6 | var src = { 7 | js: "src/*.coffee", 8 | css: "src/*.scss" 9 | }; 10 | 11 | var dest = "dist"; 12 | 13 | gulp.task("default", function() { 14 | return gulp.start("js", "js-min", "css", "css-min"); 15 | }); 16 | 17 | gulp.task("watch", function() { 18 | gulp.watch(src.js, ["js", "js-min"]); 19 | gulp.watch(src.css, ["css", "css-min"]); 20 | return gulp.start("default"); 21 | }); 22 | 23 | gulp.task("js", function() { 24 | return gulp.src(src.js) 25 | .pipe(r.sourcemaps.init()) 26 | .pipe(r.coffee()) 27 | .pipe(r.rename({suffix: "-latest"})) 28 | .pipe(r.sourcemaps.write("./")) 29 | .pipe(gulp.dest(dest)); 30 | }); 31 | 32 | gulp.task("js-min", function() { 33 | return gulp.src(src.js) 34 | .pipe(r.sourcemaps.init()) 35 | .pipe(r.coffee()) 36 | // Mangle will shorten variable names which breaks the AngularJS dependency injection. 37 | // TODO: Use a build tool to preserve the important variables instead of disabling mangle. 38 | .pipe(r.uglify({mangle: false})) 39 | .pipe(r.rename({suffix: "-latest.min"})) 40 | .pipe(r.sourcemaps.write("./")) 41 | .pipe(gulp.dest(dest)); 42 | }); 43 | 44 | gulp.task("css", function() { 45 | return gulp.src(src.css) 46 | .pipe(r.rubySass()) 47 | .pipe(r.sourcemaps.init({loadMaps: true})) 48 | .pipe(r.autoprefixer("last 2 versions", "ie >= 9", "Firefox ESR")) 49 | .pipe(r.rename({suffix: "-latest"})) 50 | .pipe(r.sourcemaps.write("./")) 51 | .pipe(gulp.dest(dest)); 52 | }); 53 | 54 | gulp.task("css-min", function() { 55 | return gulp.src(src.css) 56 | .pipe(r.rubySass()) 57 | .pipe(r.sourcemaps.init({loadMaps: true})) 58 | .pipe(r.autoprefixer("last 2 versions", "ie >= 9", "Firefox ESR")) 59 | .pipe(r.minifyCss()) 60 | .pipe(r.rename({suffix: "-latest.min"})) 61 | .pipe(r.sourcemaps.write("./")) 62 | .pipe(gulp.dest(dest)); 63 | }); 64 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ng-annotate-text", 3 | "version": "2.5.1", 4 | "description": "An AngularJS directive to assist with annotation of text", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/DigiExam/ng-annotate-text.git" 8 | }, 9 | "author": "Rasmus Milesson", 10 | "bugs": { 11 | "url": "https://github.com/DigiExam/ng-annotate-text/issues" 12 | }, 13 | "homepage": "https://github.com/DigiExam/ng-annotate-text", 14 | "devDependencies": { 15 | "bower": "~1.3.8", 16 | "gulp": "~3.8.6", 17 | "gulp-load-plugins": "~0.5.3", 18 | "gulp-rename": "~1.2.0", 19 | "gulp-ruby-sass": "~0.6.0", 20 | "gulp-autoprefixer": "~0.0.8", 21 | "gulp-minify-css": "~0.3.7", 22 | "gulp-uglify": "~0.3.1", 23 | "gulp-coffee": "~2.1.1", 24 | "gulp-sourcemaps": "~1.1.0", 25 | "gulp-replace": "~0.4.0" 26 | }, 27 | "scripts": { 28 | "postinstall": "./node_modules/.bin/bower install" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DigiExam/ng-annotate-text/3602ff91cd86770f56ff9d1d6316dde02d45f7e4/screenshot.png -------------------------------------------------------------------------------- /src/ng-annotate-text.coffee: -------------------------------------------------------------------------------- 1 | ngAnnotateText = angular.module "ngAnnotateText", [] 2 | 3 | annotationIdCounter = 0 4 | 5 | insertAt = (text, index, string)-> 6 | return text.substr(0, index) + string + text.substr(index) 7 | 8 | sortAnnotationsByEndIndex = (annotations)-> 9 | return annotations.sort (a, b)-> 10 | if a.endIndex < b.endIndex 11 | return -1 12 | else if a.endIndex > b.endIndex 13 | return 1 14 | return 0 15 | 16 | parseAnnotations = (text, annotations = [], indexOffset = 0)-> 17 | if annotations.length is 0 18 | return text 19 | annotations = sortAnnotationsByEndIndex annotations 20 | 21 | for i in [annotations.length - 1..0] by -1 22 | annotation = annotations[i]; 23 | text = insertAt text, annotation.endIndex + indexOffset, "" 24 | if annotation.children.length 25 | text = parseAnnotations text, annotation.children, annotation.startIndex + indexOffset 26 | text = insertAt text, annotation.startIndex + indexOffset, "" 27 | return text 28 | 29 | getAnnotationById = (annotations, aId)-> 30 | for a in annotations 31 | if aId is a.id 32 | return a 33 | if a.children.length > 0 34 | an = getAnnotationById a.children, aId 35 | if an isnt undefined 36 | return an 37 | 38 | ngAnnotateText.factory "NGAnnotateTextPopup", -> 39 | (args) -> 40 | args = angular.extend { 41 | scope: null, 42 | callbacks: {}, 43 | template: "
" 44 | $anchor: null 45 | preferredAxis: 'x' 46 | offset: 0 47 | positionClass: '{{position}}' 48 | }, args 49 | 50 | angular.extend @, args, 51 | $el: angular.element args.template 52 | 53 | show: (speed = "fast") -> 54 | @$el.fadeIn speed 55 | @reposition() 56 | if typeof @callbacks.show is "function" 57 | @callbacks.show @$el 58 | 59 | hide: (speed = "fast")-> 60 | @$el.fadeOut speed 61 | if typeof @callbacks.hide is "function" 62 | @callbacks.hide @$el 63 | 64 | isVisible: -> 65 | return @$el.is ":visible" 66 | 67 | destroy: (cb = angular.noop)-> 68 | scope = @scope 69 | $el = @$el 70 | @hide -> 71 | if typeof cb is "function" 72 | cb() 73 | scope.$destroy() 74 | $el.remove() 75 | 76 | stopDestroy: -> 77 | @$el.stop(true).show("fast") 78 | 79 | reposition: -> 80 | targetEl = @$el[0] 81 | anchorEl = @$anchor[0] 82 | 83 | if not (targetEl or anchorEl) 84 | return 85 | 86 | pos = 87 | left: null 88 | top: null 89 | target: targetEl.getBoundingClientRect() 90 | anchor: anchorEl.getBoundingClientRect() 91 | viewport: 92 | width: window.innerWidth 93 | height: window.innerHeight 94 | scroll: 95 | top: document.body.scrollTop 96 | left: document.body.scrollLeft 97 | 98 | if not (pos.target.width > 0 and pos.target.height > 0) 99 | return 100 | 101 | # Find first axis position 102 | 103 | posX = @getNewPositionOnAxis pos, 'x' 104 | posY = @getNewPositionOnAxis pos, 'y' 105 | 106 | if @preferredAxis is 'x' 107 | if posX and typeof posX.pos is 'number' 108 | pos.left = posX.pos 109 | pos.edge = posX.edge 110 | else if posY 111 | pos.top = posY.pos 112 | pos.edge = posY.edge 113 | else 114 | if posY and typeof posY.pos is 'number' 115 | pos.top = posY.pos 116 | pos.edge = posY.edge 117 | else if posX 118 | pos.left = posX.pos 119 | pos.edge = posX.edge 120 | 121 | # Center on second axis 122 | 123 | if pos.left is null and pos.top is null 124 | # Center on X and Y axes 125 | pos.left = pos.scroll.left + (pos.viewport.width / 2) - (pos.target.width / 2) 126 | pos.top = pos.scroll.top + (pos.viewport.height / 2) - (pos.target.height / 2) 127 | else if pos.left is null 128 | # Center on X axis 129 | pos.left = @getNewCenterPositionOnAxis pos, 'x' 130 | else if pos.top is null 131 | # Center on Y axis 132 | pos.top = @getNewCenterPositionOnAxis pos, 'y' 133 | 134 | @$el 135 | .addClass pos.edge && @positionClass.replace "{{position}}", pos.edge 136 | .css 137 | top: Math.round(pos.top) || 0 138 | left: Math.round(pos.left) || 0 139 | 140 | return 141 | 142 | getNewPositionOnAxis: (pos, axis) -> 143 | start = {x: 'left', y: 'top'}[axis] 144 | end = {x: 'right', y: 'bottom'}[axis] 145 | size = {x: 'width', y: 'height'}[axis] 146 | if pos.anchor[start] - @offset >= pos.target[size] 147 | axisPos = 148 | pos: pos.scroll[start] + pos.anchor[start] - @offset - pos.target[size] 149 | edge: start 150 | else if pos.viewport[size] - pos.anchor[end] - @offset >= pos.target[size] 151 | axisPos = 152 | pos: pos.scroll[start] + pos.anchor[end] + @offset 153 | edge: end 154 | axisPos 155 | 156 | getNewCenterPositionOnAxis: (pos, axis) -> 157 | start = {x: 'left', y: 'top'}[axis] 158 | size = {x: 'width', y: 'height'}[axis] 159 | centerPos = pos.scroll[start] + pos.anchor[start] + (pos.anchor[size] / 2) - (pos.target[size] / 2) 160 | Math.max(pos.scroll[start] + @offset, Math.min(centerPos, pos.scroll[start] + pos.viewport[size] - pos.target[size] - @offset)) 161 | 162 | ngAnnotateText.factory "NGAnnotation", -> 163 | Annotation = (data)-> 164 | 165 | angular.extend @, 166 | id: annotationIdCounter++, 167 | startIndex: null 168 | endIndex: null 169 | data: {points: 0} 170 | type: "" 171 | children: [] 172 | 173 | if data? 174 | angular.extend @, data 175 | 176 | return Annotation 177 | 178 | ngAnnotateText.directive "ngAnnotateText", ($rootScope, $compile, $http, $q, $controller, $sce, NGAnnotation, NGAnnotateTextPopup)-> 179 | restrict: "E" 180 | scope: 181 | text: "=" 182 | annotations: "=" 183 | readonly: "=" 184 | popupController: "=" 185 | popupTemplateUrl: "=" 186 | tooltipController: "=" 187 | tooltipTemplateUrl: "=" 188 | onAnnotate: "=" 189 | onAnnotateDelete: "=" 190 | onAnnotateError: "=" 191 | onPopupShow: "=" 192 | onPopupHide: "=" 193 | popupOffset: "=" 194 | template: "

" 195 | replace: true 196 | 197 | compile: (el, attr) -> 198 | attr.readonly ?= false 199 | @postLink 200 | 201 | postLink: ($scope, element, attrs) -> 202 | POPUP_OFFSET = $scope.popupOffset ? 10 203 | 204 | activePopup = null 205 | activeTooltip = null 206 | 207 | # Cache the template when we fetch it 208 | popupTemplateData = "" 209 | tooltipTemplateData = "" 210 | 211 | onAnnotationsChange = -> 212 | if not $scope.text? or !$scope.text.length 213 | return 214 | t = parseAnnotations $scope.text, $scope.annotations 215 | $scope.content = $sce.trustAsHtml t 216 | 217 | # Annotation parsing 218 | $scope.$watch "text", onAnnotationsChange 219 | $scope.$watch "annotations", onAnnotationsChange, true 220 | 221 | clearPopup = -> 222 | if not activePopup? 223 | return 224 | tId = activePopup.scope.$annotation.id 225 | activePopup.destroy -> 226 | if activePopup.scope.$annotation.id is tId 227 | activePopup = null 228 | 229 | clearTooltip = -> 230 | tooltip = activeTooltip 231 | if not tooltip? 232 | return 233 | tooltip.destroy -> 234 | if activeTooltip is tooltip 235 | activeTooltip = null 236 | 237 | clearPopups = -> 238 | clearPopup() 239 | clearTooltip() 240 | 241 | $scope.$on "$destroy", clearPopups 242 | $scope.$on "ngAnnotateText.clearPopups", clearPopups 243 | 244 | if $scope.popupTemplateUrl 245 | $http.get($scope.popupTemplateUrl).then (response)-> 246 | popupTemplateData = response.data 247 | 248 | if $scope.tooltipTemplateUrl 249 | $http.get($scope.tooltipTemplateUrl).then (response)-> 250 | tooltipTemplateData = response.data 251 | 252 | removeChildren = (annotation)-> 253 | for i in [annotation.children.length - 1..0] by -1 254 | a = annotation.children[i] 255 | removeChildren a 256 | a.children.splice i, 1 257 | 258 | removeAnnotation = (id, annotations)-> 259 | for a, i in annotations 260 | removeAnnotation id, a.children 261 | 262 | if a.id is id 263 | removeChildren a 264 | annotations.splice i, 1 265 | return 266 | 267 | createAnnotation = -> 268 | annotation = new NGAnnotation() 269 | sel = window.getSelection() 270 | 271 | if sel.isCollapsed 272 | throw new Error "NG_ANNOTATE_TEXT_NO_TEXT_SELECTED" 273 | 274 | range = sel.getRangeAt 0 275 | 276 | if range.startContainer isnt range.endContainer 277 | throw new Error "NG_ANNOTATE_TEXT_PARTIAL_NODE_SELECTED" 278 | 279 | if range.startContainer.parentNode.nodeName is "SPAN" # Is a child annotation 280 | parentId = if (attrId = range.startContainer.parentNode.getAttribute("data-annotation-id"))? then parseInt(attrId, 10) 281 | if parentId is undefined 282 | throw new Error "NG_ANNOTATE_TEXT_ILLEGAL_SELECTION" 283 | parentAnnotation = getAnnotationById $scope.annotations, parentId 284 | 285 | annotationParentCollection = parentAnnotation.children 286 | else 287 | annotationParentCollection = $scope.annotations 288 | 289 | # Does this selection has any siblings? 290 | if annotationParentCollection.length 291 | # Yup, find the previous sibling 292 | prevSiblingSpan = range.startContainer.previousSibling 293 | if prevSiblingSpan? 294 | prevSiblingId = if (attrId = prevSiblingSpan.getAttribute("data-annotation-id"))? then parseInt(attrId, 10) 295 | if not prevSiblingId? 296 | throw new Error "NG_ANNOTATE_TEXT_ILLEGAL_SELECTION" 297 | 298 | prevAnnotation = getAnnotationById $scope.annotations, prevSiblingId 299 | annotation.startIndex = prevAnnotation.endIndex + range.startOffset 300 | annotation.endIndex = prevAnnotation.endIndex + range.endOffset 301 | else 302 | # Doesn't have a prev sibling, alrighty then 303 | annotation.startIndex = range.startOffset 304 | annotation.endIndex = range.endOffset 305 | else 306 | # Nope 307 | annotation.startIndex = range.startOffset 308 | annotation.endIndex = range.endOffset 309 | 310 | annotationParentCollection.push annotation 311 | clearSelection() 312 | return annotation 313 | 314 | clearSelection = -> 315 | if document.selection 316 | document.selection.empty() # Internet Explorer 317 | else if window.getSelection and window.getSelection().empty 318 | window.getSelection().empty() # Chrome 319 | else if window.getSelection and window.getSelection().removeAllRanges 320 | window.getSelection().removeAllRanges() # Firefox 321 | 322 | onSelect = (event)-> 323 | if popupTemplateData.length is 0 324 | return 325 | 326 | try 327 | annotation = createAnnotation() 328 | $scope.$apply() 329 | $span = element.find ".ng-annotate-text-" + annotation.id 330 | catch ex 331 | if $scope.onAnnotateError? 332 | $scope.onAnnotateError ex 333 | 334 | return 335 | 336 | clearPopups() 337 | 338 | loadAnnotationPopup annotation, $span, true 339 | 340 | onClick = (event)-> 341 | if popupTemplateData.length is 0 342 | return 343 | 344 | $target = angular.element event.target 345 | targetId = if (attrId = $target.attr("data-annotation-id"))? then parseInt(attrId, 10) 346 | 347 | if not targetId? 348 | return 349 | 350 | if activePopup? and activePopup.scope.$annotation.id is targetId 351 | clearPopup() 352 | return 353 | annotation = getAnnotationById $scope.annotations, targetId 354 | 355 | clearPopups() 356 | 357 | loadAnnotationPopup annotation, $target, false 358 | 359 | onMouseEnter = (event)-> 360 | if tooltipTemplateData.length is 0 361 | return 362 | 363 | event.stopPropagation() 364 | $target = angular.element event.target 365 | targetId = if (attrId = $target.attr("data-annotation-id"))? then parseInt(attrId, 10) 366 | 367 | if activeTooltip? and activeTooltip.scope.$annotation.id is targetId 368 | activeTooltip.stopDestroy() 369 | return 370 | else 371 | clearTooltip() 372 | 373 | if not targetId? 374 | return 375 | 376 | annotation = getAnnotationById $scope.annotations, targetId 377 | 378 | # We don't want to show the tooltip if a popup with the annotation is open, 379 | # or if the tooltip has both no comment and points 380 | if activePopup? or (not annotation.data.comment and not annotation.data.points) 381 | return 382 | 383 | tooltip = new NGAnnotateTextPopup 384 | scope: $rootScope.$new() 385 | template: "
" 386 | positionClass: "ng-annotate-text-tooltip-docked ng-annotate-text-tooltip-docked-{{position}}" 387 | $anchor: $target 388 | preferredAxis: 'y' 389 | offset: POPUP_OFFSET 390 | tooltip.scope.$annotation = annotation 391 | 392 | activeTooltip = tooltip 393 | 394 | locals = 395 | $scope: tooltip.scope 396 | $template: tooltipTemplateData 397 | 398 | tooltip.$el.html locals.$template 399 | tooltip.$el.appendTo "body" 400 | 401 | if $scope.tooltipController 402 | controller = $controller $scope.tooltipController, locals 403 | tooltip.$el.data "$ngControllerController", controller 404 | tooltip.$el.children().data "$ngControllerController", controller 405 | 406 | $compile(tooltip.$el) tooltip.scope 407 | tooltip.scope.$apply() 408 | tooltip.show() 409 | 410 | onMouseLeave = (event)-> 411 | event.stopPropagation() 412 | 413 | $target = angular.element event.target 414 | targetId = if (attrId = $target.attr("data-annotation-id"))? then parseInt(attrId, 10) 415 | 416 | if not targetId? 417 | return 418 | 419 | clearTooltip() 420 | 421 | loadAnnotationPopup = (annotation, anchor, isNew)-> 422 | popup = new NGAnnotateTextPopup 423 | scope: $rootScope.$new() 424 | callbacks: 425 | show: $scope.onPopupShow 426 | hide: $scope.onPopupHide 427 | template: "
" 428 | positionClass: "ng-annotate-text-popup-docked ng-annotate-text-popup-docked-{{position}}" 429 | $anchor: anchor 430 | offset: POPUP_OFFSET 431 | 432 | popup.scope.$isNew = isNew 433 | popup.scope.$annotation = annotation 434 | popup.scope.$readonly = $scope.readonly 435 | 436 | popup.scope.$reject = -> 437 | removeAnnotation annotation.id, $scope.annotations 438 | 439 | if $scope.onAnnotateDelete? 440 | $scope.onAnnotateDelete annotation 441 | clearPopup() 442 | return 443 | 444 | popup.scope.$close = -> 445 | if $scope.onAnnotate? 446 | $scope.onAnnotate popup.scope.$annotation 447 | clearPopup() 448 | return 449 | 450 | activePopup = popup 451 | 452 | locals = 453 | $scope: popup.scope 454 | $template: popupTemplateData 455 | 456 | popup.$el.html locals.$template 457 | popup.$el.appendTo "body" 458 | 459 | if $scope.popupController 460 | controller = $controller $scope.popupController, locals 461 | popup.$el.data "$ngControllerController", controller 462 | popup.$el.children().data "$ngControllerController", controller 463 | 464 | $compile(popup.$el) popup.scope 465 | popup.scope.$apply() 466 | popup.show() 467 | 468 | element.on "mouseenter", "span", onMouseEnter 469 | element.on "mouseleave", "span", onMouseLeave 470 | 471 | element.on "mouseup", (event)-> 472 | # We need to determine if the user actually selected something 473 | # or if he just clicked on an annotation 474 | selection = window.getSelection() 475 | if !selection.isCollapsed and !$scope.readonly 476 | # User has selected something 477 | onSelect event 478 | else if selection.isCollapsed and event.target.nodeName is "SPAN" 479 | onClick event 480 | else if selection.isCollapsed 481 | clearPopups() 482 | -------------------------------------------------------------------------------- /src/ng-annotate-text.scss: -------------------------------------------------------------------------------- 1 | // Variables 2 | 3 | $color-text: #333; 4 | $color-bg: #fff; 5 | $color-border: #ccc; 6 | 7 | $color-btn-text: #444; 8 | $color-btn-bg: #f5f5f5; 9 | $color-btn-border: hsla(0, 0%, 0%, 0.2); 10 | $color-btn-ok-text: #fff; 11 | $color-btn-ok-bg: #1bb352; 12 | $color-btn-delete-text: #fff; 13 | $color-btn-delete-bg: #d94155; 14 | 15 | $fontSize: 13px; 16 | $lineHeight: 18 / 13; 17 | $fontFamily: "Helvetica Neue", Helvetica, Arial, sans-serif; 18 | $font: $fontSize#{"/"}$lineHeight $fontFamily; 19 | 20 | $space: 10px; 21 | 22 | $zindex-popup: 990; 23 | $zindex-popup-arrow: 1; 24 | $zindex-tooltip: 1000; 25 | $zindex-tooltip-arrow: 1; 26 | 27 | $popup-width: 227px; 28 | $popup-border: 1px solid hsla(0, 0%, 0%, 0.18); 29 | 30 | $tooltip-text: #f7f7f7; 31 | $tooltip-bg: hsla(0, 0%, 0%, 0.85); 32 | $tooltip-shadow: 0 1px 3px hsla(0, 0%, 0%, 0.3); 33 | 34 | $swatch-color-width: ($popup-width - 2px - ($space * 2) - ($space / 2 * 5)) / 6; 35 | $swatch-color-height: $swatch-color-width * 0.75; 36 | 37 | $type-colors: ( 38 | 'red': #fcbcbc, 39 | 'green': #c7fcbc, 40 | 'blue': #bcdffc, 41 | 'pink': #fcbcfa, 42 | 'yellow': #f8f89b, 43 | 'aqua': #bcfcf7 44 | ); 45 | 46 | 47 | // Mixins 48 | 49 | @mixin clearfix() { 50 | &::before, 51 | &::after { 52 | content: " "; 53 | display: table; 54 | } 55 | 56 | &::after { 57 | clear: both; 58 | } 59 | } 60 | 61 | 62 | // Namespace 63 | 64 | .ng-annotate-text { 65 | 66 | 67 | // Type styles 68 | 69 | &-type { 70 | &- { // No type 71 | border-bottom: 1px solid #000; 72 | } 73 | 74 | @each $type, $color in $type-colors { 75 | &-#{$type} { color: #000; background: $color; border-color: $color; } 76 | } 77 | 78 | &-strike { text-decoration: line-through; } 79 | } 80 | 81 | 82 | // Annotation 83 | 84 | &-annotation { 85 | cursor: pointer; 86 | } 87 | 88 | 89 | // Popup 90 | 91 | &-popup { 92 | display: none; 93 | position: absolute; 94 | z-index: $zindex-popup; 95 | width: $popup-width; 96 | padding: $space; 97 | color: $color-text; 98 | background: $color-bg; 99 | border: $popup-border; 100 | border-radius: 5px; 101 | box-shadow: 0 1px 10px hsla(0, 0%, 0%, 0.2); 102 | font: $font; 103 | text-rendering: optimizelegibility; 104 | 105 | &, 106 | & * { 107 | box-sizing: border-box; 108 | } 109 | 110 | label { 111 | cursor: pointer; 112 | } 113 | 114 | &-docked::after { 115 | content: ""; 116 | position: absolute; 117 | z-index: $zindex-popup-arrow; 118 | width: 10px; 119 | height: 10px; 120 | background: $color-bg; 121 | border-top: $popup-border; 122 | border-right: $popup-border; 123 | box-shadow: 4px -3px 8px rgba(0, 0, 0, 0.07); 124 | } 125 | 126 | &-docked-left::after, 127 | &-docked-right::after { top: 50%; margin-top: -5px; } 128 | &-docked-top::after, 129 | &-docked-bottom::after { left: 50%; margin-left: -5px; } 130 | 131 | &-docked-left::after { transform: rotate(45deg); right: -6px; } 132 | &-docked-right::after { transform: rotate(-135deg); left: -6px; } 133 | &-docked-top::after { transform: rotate(135deg); bottom: -6px; } 134 | &-docked-bottom::after { transform: rotate(-45deg); top: -6px; } 135 | 136 | &-group { 137 | @include clearfix(); 138 | margin-bottom: $space; 139 | 140 | &:last-child { 141 | margin-bottom: 0; 142 | } 143 | } 144 | 145 | &-actions { 146 | margin-top: $space * 1.5; 147 | } 148 | 149 | &-label { 150 | display: block; 151 | font-weight: bold; 152 | margin-bottom: $space / 2; 153 | } 154 | 155 | &-field { 156 | display: block; 157 | box-sizing: border-box; 158 | width: 100%; 159 | padding: 3px; 160 | color: $color-text; 161 | background: $color-bg; 162 | border: 1px solid $color-border; 163 | border-radius: 3px; 164 | font-size: inherit; 165 | } 166 | 167 | &-points { 168 | display: table; 169 | width: 100%; 170 | } 171 | 172 | &-points { 173 | &-label, 174 | &-field { 175 | display: table-cell; 176 | } 177 | 178 | &-label { 179 | padding-right: $space; 180 | } 181 | } 182 | 183 | &-colors, 184 | &-templates { 185 | list-style: none; 186 | margin: 0; 187 | padding: 0; 188 | } 189 | 190 | &-colors li { 191 | float: left; 192 | 193 | & + li { 194 | margin-left: 5px; 195 | } 196 | } 197 | 198 | &-templates li + li { 199 | margin-top: 5px; 200 | } 201 | } 202 | 203 | 204 | // Tooltip 205 | 206 | &-tooltip { 207 | $comment-2nd-line-blocker: 1px; 208 | 209 | pointer-events: none; 210 | display: none; 211 | position: absolute; 212 | z-index: $zindex-tooltip; 213 | max-width: 20em; 214 | padding: ($space / 2) $space ($space / 2 - $comment-2nd-line-blocker); 215 | color: $tooltip-text; 216 | background: $tooltip-bg; 217 | border-radius: $space / 2; 218 | box-shadow: $tooltip-shadow; 219 | font: $font; 220 | text-shadow: 0 0 2px #000; 221 | 222 | &-docked::after { 223 | content: ""; 224 | position: absolute; 225 | z-index: $zindex-tooltip-arrow; 226 | border: 4px solid; 227 | border-color: $tooltip-bg $tooltip-bg transparent transparent; 228 | box-shadow: 4px -3px 8px rgba(0, 0, 0, 0.07); 229 | } 230 | 231 | &-docked-left::after, 232 | &-docked-right::after { top: 50%; margin-top: -4px; } 233 | &-docked-top::after, 234 | &-docked-bottom::after { left: 50%; margin-left: -4px; } 235 | 236 | &-docked-left::after { transform: rotate(45deg); right: -4px; } 237 | &-docked-right::after { transform: rotate(-135deg); left: -4px; } 238 | &-docked-top::after { transform: rotate(135deg); bottom: -4px; } 239 | &-docked-bottom::after { transform: rotate(-45deg); top: -4px; } 240 | 241 | &-points { 242 | float: right; 243 | } 244 | 245 | &-points, 246 | &-comment { 247 | padding-bottom: $comment-2nd-line-blocker; 248 | } 249 | 250 | &-points + &-comment::before { 251 | content: ""; 252 | float: right; 253 | width: $space * 2; 254 | height: $lineHeight * 1em; 255 | margin-bottom: $comment-2nd-line-blocker; 256 | } 257 | } 258 | 259 | 260 | // Btn 261 | 262 | &-btn { 263 | padding: ($space / 2) $space; 264 | cursor: pointer; 265 | color: $color-btn-text; 266 | background: $color-btn-bg linear-gradient(to bottom, hsla(0, 0%, 100%, 0.15), hsla(0, 0%, 0%, 0.1)); 267 | border: 1px solid $color-btn-border; 268 | border-radius: 3px; 269 | box-shadow: inset 0 1px 0 hsla(0, 0%, 100%, 0.2), 270 | 0 1px 3px hsla(0, 0%, 0%, 0.1); 271 | font: inherit; 272 | text-shadow: 0 1px 1px #fff; 273 | 274 | &:active { 275 | background-image: linear-gradient(to top, hsla(0, 0%, 100%, 0), hsla(0, 0%, 0%, 0.1)); 276 | box-shadow: inset 0 1px 2px hsla(0, 0%, 0%, 0.1); 277 | } 278 | 279 | &-save, 280 | &-delete { 281 | text-shadow: 0 1px 1px hsla(0, 0%, 0%, 0.3); 282 | } 283 | 284 | &-save { 285 | float: right; 286 | color: $color-btn-ok-text; 287 | background-color: $color-btn-ok-bg; 288 | } 289 | 290 | &-delete { 291 | color: $color-btn-delete-text; 292 | background-color: $color-btn-delete-bg; 293 | } 294 | } 295 | 296 | 297 | // Swatch 298 | 299 | &-swatch { 300 | transition: border-color 0.15s; 301 | position: relative; 302 | display: block; 303 | width: 100%; 304 | cursor: pointer; 305 | border-radius: 3px; 306 | border: 1px solid hsla(0, 0%, 0%, 0.075); 307 | font: inherit; 308 | text-align: left; 309 | 310 | &:hover { 311 | border-color: hsla(0, 0%, 0%, 0.3); 312 | } 313 | 314 | &-active::before { 315 | content: ""; 316 | position: absolute; 317 | top: -3px; 318 | bottom: -3px; 319 | left: -3px; 320 | right: -3px; 321 | border: 1px solid hsla(0, 0%, 0%, 0.3); 322 | border-radius: 4px; 323 | } 324 | 325 | &-color { 326 | width: $swatch-color-width; 327 | height: $swatch-color-height; 328 | padding: 0; 329 | text-indent: 9999px; 330 | } 331 | 332 | &-template { 333 | padding: ($space / 4) ($space / 2); 334 | 335 | &-name { 336 | float: left; 337 | } 338 | 339 | &-points { 340 | float: right; 341 | } 342 | } 343 | } 344 | 345 | } // End Namespace 346 | --------------------------------------------------------------------------------