1DV.Annotation = function(argHash){ 2 this.position = { top: argHash.top, left: argHash.left }; 3 this.dimensions = { width: argHash.width, height: argHash.height }; 4 this.page = argHash.page; 5 this.pageEl = argHash.pageEl; 6 this.annotationContainerEl = argHash.annotationContainerEl; 7 this.viewer = this.page.set.viewer; 8 this.annotationEl = null; 9 this.renderedHTML = argHash.renderedHTML; 10 this.type = argHash.type; 11 this.id = argHash.id; 12 this.model = this.viewer.models.annotations.getAnnotation(this.id); 13 this.state = 'collapsed'; 14 this.active = false; 15 this.remove(); 16 this.add(); 17 18 if(argHash.active){ 19 this.viewer.helpers.setActiveAnnotationLimits(this); 20 this.viewer.events.resetTracker(); 21 this.active = null; 22 // this.viewer.elements.window[0].scrollTop += this.annotationEl.offset().top; 23 this.show(); 24 if (argHash.showEdit) this.showEdit(); 25 } 26}; 27 28// Add annotation to page 29DV.Annotation.prototype.add = function(){ 30 if(this.type === 'page'){ 31 this.annotationEl = this.renderedHTML.insertBefore(this.annotationContainerEl); 32 }else{ 33 if(this.page.annotations.length > 0){ 34 for(var i = 0,len = this.page.annotations.length;i<len;i++){ 35 if(this.page.annotations[i].id === this.id){ 36 37 return false; 38 }else{ 39 40 this.annotationEl = this.renderedHTML.appendTo(this.annotationContainerEl); 41 } 42 } 43 }else{ 44 45 this.annotationEl = this.renderedHTML.appendTo(this.annotationContainerEl); 46 } 47 } 48}; 49 50// Jump to next annotation 51DV.Annotation.prototype.next = function(){ 52 this.hide.preventRemovalOfCoverClass = true; 53 54 var annotation = this.viewer.models.annotations.getNextAnnotation(this.id); 55 if(!annotation){ 56 return; 57 } 58 59 this.page.set.showAnnotation({ index: annotation.index, id: annotation.id, top: annotation.top }); 60}; 61 62// Jump to previous annotation 63DV.Annotation.prototype.previous = function(){ 64 this.hide.preventRemovalOfCoverClass = true; 65 var annotation = this.viewer.models.annotations.getPreviousAnnotation(this.id); 66 if(!annotation) { 67 return; 68 } 69 this.page.set.showAnnotation({ index: annotation.index, id: annotation.id, top: annotation.top }); 70}; 71 72// Show annotation 73DV.Annotation.prototype.show = function(argHash) { 74 75 if (this.viewer.activeAnnotation && this.viewer.activeAnnotation.id != this.id) { 76 this.viewer.activeAnnotation.hide(); 77 } 78 this.viewer.annotationToLoadId = null; 79 this.viewer.elements.window.addClass('DV-coverVisible'); 80 81 this.annotationEl.find('div.DV-annotationBG').css({ display: 'block', opacity: 1 }); 82 this.annotationEl.addClass('DV-activeAnnotation'); 83 this.viewer.activeAnnotation = this; 84 85 // Enable annotation tracking to ensure the active state hides on scroll 86 this.viewer.helpers.addObserver('trackAnnotation'); 87 this.viewer.helpers.setActiveAnnotationInNav(this.id); 88 this.active = true; 89 this.pageEl.parent('.DV-set').addClass('DV-activePage'); 90 // this.viewer.history.save('document/p'+(parseInt(this.page.index,10)+1)+'/a'+this.id); 91 92 if (argHash && argHash.edit) { 93 this.showEdit(); 94 } 95}; 96 97// Hide annotation 98DV.Annotation.prototype.hide = function(forceOverlayHide){ 99 var pageNumber = parseInt(this.viewer.elements.currentPage.text(),10); 100 101 if(this.type !== 'page'){ 102 this.annotationEl.find('div.DV-annotationBG').css({ opacity: 0, display: 'none' }); 103 } 104 105 var isEditing = this.annotationEl.hasClass('DV-editing'); 106 107 this.annotationEl.removeClass('DV-editing DV-activeAnnotation'); 108 if(forceOverlayHide === true){ 109 this.viewer.elements.window.removeClass('DV-coverVisible'); 110 } 111 if(this.hide.preventRemovalOfCoverClass === false || !this.hide.preventRemovalOfCoverClass){ 112 this.viewer.elements.window.removeClass('DV-coverVisible'); 113 this.hide.preventRemovalOfCoverClass = false; 114 } 115 116 // stop tracking this annotation 117 this.viewer.activeAnnotation = null; 118 this.viewer.events.trackAnnotation.h = null; 119 this.viewer.events.trackAnnotation.id = null; 120 this.viewer.events.trackAnnotation.combined = null; 121 this.active = false;
122 this.viewer.pageSet.setActiveAnnotation(null); 123 this.viewer.helpers.removeObserver('trackAnnotation'); 124 this.viewer.helpers.setActiveAnnotationInNav(); 125 this.pageEl.parent('.DV-set').removeClass('DV-activePage'); 126 this.removeConnector(true); 127 128 if (isEditing) { 129 this.viewer.helpers.saveAnnotation({target : this.annotationEl}, 'onlyIfText'); 130 } 131}; 132 133// Toggle annotation 134DV.Annotation.prototype.toggle = function(argHash){ 135 if (this.viewer.activeAnnotation && (this.viewer.activeAnnotation != this)){ 136 this.viewer.activeAnnotation.hide(); 137 } 138 139 if (this.type === 'page') return; 140 141 this.annotationEl.toggleClass('DV-activeAnnotation'); 142 if(this.active == true){ 143 this.hide(true); 144 }else{ 145 this.show(); 146 } 147}; 148 149// Show hover annotation state 150DV.Annotation.prototype.drawConnector = function(){ 151 if(this.active != true){ 152 this.viewer.elements.window.addClass('DV-annotationActivated'); 153 this.annotationEl.addClass('DV-annotationHover'); 154 } 155}; 156 157// Remove hover annotation state 158DV.Annotation.prototype.removeConnector = function(force){ 159 if(this.active != true){ 160 this.viewer.elements.window.removeClass('DV-annotationActivated'); 161 this.annotationEl.removeClass('DV-annotationHover'); 162 } 163}; 164 165// Show edit controls 166DV.Annotation.prototype.showEdit = function() { 167 this.annotationEl.addClass('DV-editing'); 168 this.viewer.$('.DV-annotationTitleInput', this.annotationEl).focus(); 169}; 170 171// Remove the annotation from the page 172DV.Annotation.prototype.remove = function(){ 173 DV.jQuery('#DV-annotation-'+this.id).remove(); 174};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.