|
116 | 116 | break;
|
117 | 117 | case 'underline':
|
118 | 118 | var start = new ps.Point(event.point);
|
119 |
| - $rootScope.startRow = getStartRow($rootScope.docInfo,start,attrs); |
120 |
| - $rootScope.startText = $rootScope.startRow[0].characterCoordinates.filter(x=>Math.floor(x) > Math.floor(start.x)); |
121 |
| - if($rootScope.startText.length>1){ |
| 119 | + $rootScope.startRow = getStartRow($rootScope.docInfo, start, attrs); |
| 120 | + $rootScope.startText = $rootScope.startRow[0].characterCoordinates.filter(x = > Math.floor(x) > Math.floor(start.x) |
| 121 | + ) |
| 122 | + ; |
| 123 | + if ($rootScope.startText.length > 1) { |
122 | 124 | currentObject = new ps.Path.Line(new ps.Point($rootScope.startText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight), new ps.Point($rootScope.startText[1], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight));
|
123 | 125 | currentObject.strokeColor = 'black';
|
124 | 126 | currentObject.strokeWidth = 2;
|
125 | 127 | }
|
126 |
| - else if($rootScope.startText.length>1){ |
| 128 | + else if ($rootScope.startText.length > 1) { |
127 | 129 | currentObject = new ps.Path.Line(new ps.Point($rootScope.startText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight), new ps.Point($rootScope.startText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight));
|
128 | 130 | currentObject.strokeColor = 'black';
|
129 | 131 | currentObject.strokeWidth = 2;
|
130 | 132 | }
|
131 | 133 | break;
|
132 | 134 | case 'strikeout':
|
133 | 135 | var start = new ps.Point(event.point);
|
134 |
| - $rootScope.startRow = getStartRow($rootScope.docInfo,start,attrs); |
135 |
| - $rootScope.startText = $rootScope.startRow[0].characterCoordinates.filter(x=>Math.floor(x) > Math.floor(start.x)); |
136 |
| - if($rootScope.startText.length>1){ |
137 |
| - currentObject = new ps.Path.Line(new ps.Point($rootScope.startText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight/2), new ps.Point($rootScope.startText[1], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight/2)); |
| 136 | + $rootScope.startRow = getStartRow($rootScope.docInfo, start, attrs); |
| 137 | + $rootScope.startText = $rootScope.startRow[0].characterCoordinates.filter(x = > Math.floor(x) > Math.floor(start.x) |
| 138 | + ) |
| 139 | + ; |
| 140 | + if ($rootScope.startText.length > 1) { |
| 141 | + currentObject = new ps.Path.Line(new ps.Point($rootScope.startText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight / 2), new ps.Point($rootScope.startText[1], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight / 2)); |
138 | 142 | currentObject.strokeColor = 'black';
|
139 | 143 | currentObject.strokeWidth = 2;
|
140 | 144 | }
|
141 |
| - else if($rootScope.startText.length>1){ |
142 |
| - currentObject = new ps.Path.Line(new ps.Point($rootScope.startText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight/2), new ps.Point($rootScope.startText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight/2)); |
| 145 | + else if ($rootScope.startText.length > 1) { |
| 146 | + currentObject = new ps.Path.Line(new ps.Point($rootScope.startText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight / 2), new ps.Point($rootScope.startText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight / 2)); |
143 | 147 | currentObject.strokeColor = 'black';
|
144 | 148 | currentObject.strokeWidth = 2;
|
145 | 149 | }
|
|
172 | 176 | currentObject.position.y += event.delta.y;
|
173 | 177 | break;
|
174 | 178 | case 'underline':
|
175 |
| - if(currentObject){ |
| 179 | + if (currentObject) { |
176 | 180 | var end = new ps.Point(event.point);
|
177 |
| - var endText = $rootScope.startRow[0].characterCoordinates.filter(x=>Math.floor(x) > Math.floor(end.x)); |
178 |
| - if(endText.length>1){ |
| 181 | + var endText = $rootScope.startRow[0].characterCoordinates.filter(x = > Math.floor(x) > Math.floor(end.x) |
| 182 | + ) |
| 183 | + ; |
| 184 | + if (endText.length > 1) { |
179 | 185 | currentObject.add(new ps.Point(endText[1], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight));
|
180 | 186 | }
|
181 |
| - else if(endText.length>0){ |
| 187 | + else if (endText.length > 0) { |
182 | 188 | currentObject.add(new ps.Point(endText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight));
|
183 | 189 | }
|
184 | 190 | }
|
185 | 191 | break;
|
186 | 192 | case 'strikeout':
|
187 |
| - if(currentObject){ |
| 193 | + if (currentObject) { |
188 | 194 | var end = new ps.Point(event.point);
|
189 |
| - var endText = $rootScope.startRow[0].characterCoordinates.filter(x=>Math.floor(x) > Math.floor(end.x)); |
190 |
| - if(endText.length>1){ |
191 |
| - currentObject.add(new ps.Point(endText[1], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight/2)); |
| 195 | + var endText = $rootScope.startRow[0].characterCoordinates.filter(x = > Math.floor(x) > Math.floor(end.x) |
| 196 | + ) |
| 197 | + ; |
| 198 | + if (endText.length > 1) { |
| 199 | + currentObject.add(new ps.Point(endText[1], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight / 2)); |
192 | 200 | }
|
193 |
| - else if(endText.length>0){ |
194 |
| - currentObject.add(new ps.Point(endText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight/2)); |
| 201 | + else if (endText.length > 0) { |
| 202 | + currentObject.add(new ps.Point(endText[0], $rootScope.startRow[0].lineTop + $rootScope.startRow[0].lineHeight / 2)); |
195 | 203 | }
|
196 | 204 |
|
197 | 205 | }
|
|
219 | 227 | currentObject.strokeWidth = 2;
|
220 | 228 | break;
|
221 | 229 | case 'distance':
|
222 |
| - if(currentObject){ |
| 230 | + if (currentObject) { |
223 | 231 | currentObject.remove();
|
224 | 232 | }
|
225 | 233 | var start = new ps.Point(event.downPoint);
|
226 | 234 | var end = new ps.Point(event.point);
|
227 |
| - var textX = (start.x + end.x)/2; |
228 |
| - var textY = (start.y + end.y)/2; |
| 235 | + var textX = (start.x + end.x) / 2; |
| 236 | + var textY = (start.y + end.y) / 2; |
229 | 237 | var textPoint = new ps.Point(textX, textY);
|
230 | 238 | var tailLine = new ps.Path.Line(start, end);
|
231 | 239 | var textPosition = end.add(start);
|
|
305 | 313 | break;
|
306 | 314 | case 'distance':
|
307 | 315 | ant = {
|
308 |
| - type : 12, |
309 |
| - svgPath : currentObject.exportSVG().children[0].getAttribute('d')+ " " + currentObject.exportSVG().children[1].getAttribute('d') + " " + currentObject.exportSVG().children[2].getAttribute('d'), |
310 |
| - text : currentObject.children[3].content, |
311 |
| - box : { |
| 316 | + type: 12, |
| 317 | + svgPath: currentObject.exportSVG().children[0].getAttribute('d') + " " + currentObject.exportSVG().children[1].getAttribute('d') + " " + currentObject.exportSVG().children[2].getAttribute('d'), |
| 318 | + text: currentObject.children[3].content, |
| 319 | + box: { |
312 | 320 | x: currentObject.children[3].position.x,
|
313 | 321 | y: currentObject.children[3].position.y,
|
314 | 322 | width: 0,
|
|
318 | 326 | break;
|
319 | 327 | case 'underline':
|
320 | 328 | ant = {
|
321 |
| - type : 11, |
322 |
| - svgPath : currentObject.exportSVG().getAttribute('d'), |
| 329 | + type: 11, |
| 330 | + svgPath: currentObject.exportSVG().getAttribute('d'), |
323 | 331 | box: {
|
324 | 332 | x: currentObject.bounds.x,
|
325 | 333 | y: currentObject.bounds.y,
|
|
330 | 338 | break;
|
331 | 339 | case 'strikeout':
|
332 | 340 | ant = {
|
333 |
| - type : 11, |
334 |
| - svgPath : currentObject.exportSVG().getAttribute('d'), |
| 341 | + type: 11, |
| 342 | + svgPath: currentObject.exportSVG().getAttribute('d'), |
335 | 343 | box: {
|
336 | 344 | x: currentObject.bounds.x,
|
337 | 345 | y: currentObject.bounds.y,
|
|
345 | 353 | if (ant.type) {
|
346 | 354 | ant.pageNumber = attrs.number;
|
347 | 355 | var a = new AnnotationAddFactory(ant);
|
348 |
| - a.$save({ filename: $rootScope.selectedFile }, function (response) { |
| 356 | + a.$save({filename: $rootScope.selectedFile}, function (response) { |
349 | 357 | currentObject.name = response.guid;
|
350 | 358 | currentObject.selected = true;
|
351 | 359 | currentObject = null;
|
|
466 | 474 | }
|
467 | 475 | })
|
468 | 476 | }
|
469 |
| - function getStartRow(docInfo,start,attrs){ |
| 477 | + |
| 478 | + function getStartRow(docInfo, start, attrs) { |
470 | 479 | var startRow = [];
|
471 |
| - for(var i = 0; i<30; i++){ |
472 |
| - startRow = docInfo.pages[attrs.number-1].rows.filter(x => Math.floor(x.lineTop) == (Math.floor(start.y)-i )); |
473 |
| - if(startRow.length>0) |
| 480 | + for (var i = 0; i < 30; i++) { |
| 481 | + startRow = docInfo.pages[attrs.number].rows.filter(x = > Math.floor(x.lineTop) == (Math.floor(start.y) - i ) |
| 482 | + ) |
| 483 | + ; |
| 484 | + if (startRow.length > 0) |
474 | 485 | return startRow;
|
475 | 486 | }
|
476 |
| - if(startRow.length == 0) |
477 |
| - for(var i = 0; i<30; i++){ |
478 |
| - startRow = docInfo.pages[attrs.number-1].rows.filter(x => Math.floor(x.lineTop) == (Math.floor(start.y)+i )); |
479 |
| - if(startRow.length>0) |
| 487 | + if (startRow.length == 0) |
| 488 | + for (var i = 0; i < 30; i++) { |
| 489 | + startRow = docInfo.pages[attrs.number].rows.filter(x = > Math.floor(x.lineTop) == (Math.floor(start.y) + i ) |
| 490 | + ) |
| 491 | + ; |
| 492 | + if (startRow.length > 0) |
480 | 493 | return startRow;
|
481 | 494 | }
|
482 | 495 |
|
|
0 commit comments