How to use CaretAnnotationElement method in wpt

Best JavaScript code snippet using wpt

annotation_layer.js

Source:annotation_layer.js Github

copy

Full Screen

...80 return new CircleAnnotationElement(parameters);81 case _util.AnnotationType.POLYLINE:82 return new PolylineAnnotationElement(parameters);83 case _util.AnnotationType.CARET:84 return new CaretAnnotationElement(parameters);85 case _util.AnnotationType.INK:86 return new InkAnnotationElement(parameters);87 case _util.AnnotationType.POLYGON:88 return new PolygonAnnotationElement(parameters);89 case _util.AnnotationType.HIGHLIGHT:90 return new HighlightAnnotationElement(parameters);91 case _util.AnnotationType.UNDERLINE:92 return new UnderlineAnnotationElement(parameters);93 case _util.AnnotationType.SQUIGGLY:94 return new SquigglyAnnotationElement(parameters);95 case _util.AnnotationType.STRIKEOUT:96 return new StrikeOutAnnotationElement(parameters);97 case _util.AnnotationType.STAMP:98 return new StampAnnotationElement(parameters);99 case _util.AnnotationType.FILEATTACHMENT:100 return new FileAttachmentAnnotationElement(parameters);101 default:102 return new AnnotationElement(parameters);103 }104 }105 }]);106 return AnnotationElementFactory;107}();108var AnnotationElement =109/*#__PURE__*/110function () {111 function AnnotationElement(parameters) {112 var isRenderable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;113 var ignoreBorder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;114 _classCallCheck(this, AnnotationElement);115 this.isRenderable = isRenderable;116 this.data = parameters.data;117 this.layer = parameters.layer;118 this.page = parameters.page;119 this.viewport = parameters.viewport;120 this.linkService = parameters.linkService;121 this.downloadManager = parameters.downloadManager;122 this.imageResourcesPath = parameters.imageResourcesPath;123 this.renderInteractiveForms = parameters.renderInteractiveForms;124 this.svgFactory = parameters.svgFactory;125 if (isRenderable) {126 this.container = this._createContainer(ignoreBorder);127 }128 }129 _createClass(AnnotationElement, [{130 key: "_createContainer",131 value: function _createContainer() {132 var ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;133 var data = this.data,134 page = this.page,135 viewport = this.viewport;136 var container = document.createElement('section');137 var width = data.rect[2] - data.rect[0];138 var height = data.rect[3] - data.rect[1];139 container.setAttribute('data-annotation-id', data.id);140 var rect = _util.Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]);141 container.style.transform = 'matrix(' + viewport.transform.join(',') + ')';142 container.style.transformOrigin = -rect[0] + 'px ' + -rect[1] + 'px';143 if (!ignoreBorder && data.borderStyle.width > 0) {144 container.style.borderWidth = data.borderStyle.width + 'px';145 if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) {146 width = width - 2 * data.borderStyle.width;147 height = height - 2 * data.borderStyle.width;148 }149 var horizontalRadius = data.borderStyle.horizontalCornerRadius;150 var verticalRadius = data.borderStyle.verticalCornerRadius;151 if (horizontalRadius > 0 || verticalRadius > 0) {152 var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';153 container.style.borderRadius = radius;154 }155 switch (data.borderStyle.style) {156 case _util.AnnotationBorderStyleType.SOLID:157 container.style.borderStyle = 'solid';158 break;159 case _util.AnnotationBorderStyleType.DASHED:160 container.style.borderStyle = 'dashed';161 break;162 case _util.AnnotationBorderStyleType.BEVELED:163 (0, _util.warn)('Unimplemented border style: beveled');164 break;165 case _util.AnnotationBorderStyleType.INSET:166 (0, _util.warn)('Unimplemented border style: inset');167 break;168 case _util.AnnotationBorderStyleType.UNDERLINE:169 container.style.borderBottomStyle = 'solid';170 break;171 default:172 break;173 }174 if (data.color) {175 container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);176 } else {177 container.style.borderWidth = 0;178 }179 }180 container.style.left = rect[0] + 'px';181 container.style.top = rect[1] + 'px';182 container.style.width = width + 'px';183 container.style.height = height + 'px';184 return container;185 }186 }, {187 key: "_createPopup",188 value: function _createPopup(container, trigger, data) {189 if (!trigger) {190 trigger = document.createElement('div');191 trigger.style.height = container.style.height;192 trigger.style.width = container.style.width;193 container.appendChild(trigger);194 }195 var popupElement = new PopupElement({196 container: container,197 trigger: trigger,198 color: data.color,199 title: data.title,200 modificationDate: data.modificationDate,201 contents: data.contents,202 hideWrapper: true203 });204 var popup = popupElement.render();205 popup.style.left = container.style.width;206 container.appendChild(popup);207 }208 }, {209 key: "render",210 value: function render() {211 (0, _util.unreachable)('Abstract method `AnnotationElement.render` called');212 }213 }]);214 return AnnotationElement;215}();216var LinkAnnotationElement =217/*#__PURE__*/218function (_AnnotationElement) {219 _inherits(LinkAnnotationElement, _AnnotationElement);220 function LinkAnnotationElement(parameters) {221 _classCallCheck(this, LinkAnnotationElement);222 var isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action);223 return _possibleConstructorReturn(this, _getPrototypeOf(LinkAnnotationElement).call(this, parameters, isRenderable));224 }225 _createClass(LinkAnnotationElement, [{226 key: "render",227 value: function render() {228 this.container.className = 'linkAnnotation';229 var data = this.data,230 linkService = this.linkService;231 var link = document.createElement('a');232 (0, _display_utils.addLinkAttributes)(link, {233 url: data.url,234 target: data.newWindow ? _display_utils.LinkTarget.BLANK : linkService.externalLinkTarget,235 rel: linkService.externalLinkRel236 });237 if (!data.url) {238 if (data.action) {239 this._bindNamedAction(link, data.action);240 } else {241 this._bindLink(link, data.dest);242 }243 }244 this.container.appendChild(link);245 return this.container;246 }247 }, {248 key: "_bindLink",249 value: function _bindLink(link, destination) {250 var _this = this;251 link.href = this.linkService.getDestinationHash(destination);252 link.onclick = function () {253 if (destination) {254 _this.linkService.navigateTo(destination);255 }256 return false;257 };258 if (destination) {259 link.className = 'internalLink';260 }261 }262 }, {263 key: "_bindNamedAction",264 value: function _bindNamedAction(link, action) {265 var _this2 = this;266 link.href = this.linkService.getAnchorUrl('');267 link.onclick = function () {268 _this2.linkService.executeNamedAction(action);269 return false;270 };271 link.className = 'internalLink';272 }273 }]);274 return LinkAnnotationElement;275}(AnnotationElement);276var TextAnnotationElement =277/*#__PURE__*/278function (_AnnotationElement2) {279 _inherits(TextAnnotationElement, _AnnotationElement2);280 function TextAnnotationElement(parameters) {281 _classCallCheck(this, TextAnnotationElement);282 var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);283 return _possibleConstructorReturn(this, _getPrototypeOf(TextAnnotationElement).call(this, parameters, isRenderable));284 }285 _createClass(TextAnnotationElement, [{286 key: "render",287 value: function render() {288 this.container.className = 'textAnnotation';289 var image = document.createElement('img');290 image.style.height = this.container.style.height;291 image.style.width = this.container.style.width;292 image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';293 image.alt = '[{{type}} Annotation]';294 image.dataset.l10nId = 'text_annotation_type';295 image.dataset.l10nArgs = JSON.stringify({296 type: this.data.name297 });298 if (!this.data.hasPopup) {299 this._createPopup(this.container, image, this.data);300 }301 this.container.appendChild(image);302 return this.container;303 }304 }]);305 return TextAnnotationElement;306}(AnnotationElement);307var WidgetAnnotationElement =308/*#__PURE__*/309function (_AnnotationElement3) {310 _inherits(WidgetAnnotationElement, _AnnotationElement3);311 function WidgetAnnotationElement() {312 _classCallCheck(this, WidgetAnnotationElement);313 return _possibleConstructorReturn(this, _getPrototypeOf(WidgetAnnotationElement).apply(this, arguments));314 }315 _createClass(WidgetAnnotationElement, [{316 key: "render",317 value: function render() {318 return this.container;319 }320 }]);321 return WidgetAnnotationElement;322}(AnnotationElement);323var TextWidgetAnnotationElement =324/*#__PURE__*/325function (_WidgetAnnotationElem) {326 _inherits(TextWidgetAnnotationElement, _WidgetAnnotationElem);327 function TextWidgetAnnotationElement(parameters) {328 _classCallCheck(this, TextWidgetAnnotationElement);329 var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;330 return _possibleConstructorReturn(this, _getPrototypeOf(TextWidgetAnnotationElement).call(this, parameters, isRenderable));331 }332 _createClass(TextWidgetAnnotationElement, [{333 key: "render",334 value: function render() {335 var TEXT_ALIGNMENT = ['left', 'center', 'right'];336 this.container.className = 'textWidgetAnnotation';337 var element = null;338 if (this.renderInteractiveForms) {339 if (this.data.multiLine) {340 element = document.createElement('textarea');341 element.textContent = this.data.fieldValue;342 } else {343 element = document.createElement('input');344 element.type = 'text';345 element.setAttribute('value', this.data.fieldValue);346 }347 element.disabled = this.data.readOnly;348 if (this.data.maxLen !== null) {349 element.maxLength = this.data.maxLen;350 }351 if (this.data.comb) {352 var fieldWidth = this.data.rect[2] - this.data.rect[0];353 var combWidth = fieldWidth / this.data.maxLen;354 element.classList.add('comb');355 element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';356 }357 } else {358 element = document.createElement('div');359 element.textContent = this.data.fieldValue;360 element.style.verticalAlign = 'middle';361 element.style.display = 'table-cell';362 var font = null;363 if (this.data.fontRefName && this.page.commonObjs.has(this.data.fontRefName)) {364 font = this.page.commonObjs.get(this.data.fontRefName);365 }366 this._setTextStyle(element, font);367 }368 if (this.data.textAlignment !== null) {369 element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];370 }371 this.container.appendChild(element);372 return this.container;373 }374 }, {375 key: "_setTextStyle",376 value: function _setTextStyle(element, font) {377 var style = element.style;378 style.fontSize = this.data.fontSize + 'px';379 style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';380 if (!font) {381 return;382 }383 style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';384 style.fontStyle = font.italic ? 'italic' : 'normal';385 var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';386 var fallbackName = font.fallbackName || 'Helvetica, sans-serif';387 style.fontFamily = fontFamily + fallbackName;388 }389 }]);390 return TextWidgetAnnotationElement;391}(WidgetAnnotationElement);392var CheckboxWidgetAnnotationElement =393/*#__PURE__*/394function (_WidgetAnnotationElem2) {395 _inherits(CheckboxWidgetAnnotationElement, _WidgetAnnotationElem2);396 function CheckboxWidgetAnnotationElement(parameters) {397 _classCallCheck(this, CheckboxWidgetAnnotationElement);398 return _possibleConstructorReturn(this, _getPrototypeOf(CheckboxWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));399 }400 _createClass(CheckboxWidgetAnnotationElement, [{401 key: "render",402 value: function render() {403 this.container.className = 'buttonWidgetAnnotation checkBox';404 var element = document.createElement('input');405 element.disabled = this.data.readOnly;406 element.type = 'checkbox';407 if (this.data.fieldValue && this.data.fieldValue !== 'Off') {408 element.setAttribute('checked', true);409 }410 this.container.appendChild(element);411 return this.container;412 }413 }]);414 return CheckboxWidgetAnnotationElement;415}(WidgetAnnotationElement);416var RadioButtonWidgetAnnotationElement =417/*#__PURE__*/418function (_WidgetAnnotationElem3) {419 _inherits(RadioButtonWidgetAnnotationElement, _WidgetAnnotationElem3);420 function RadioButtonWidgetAnnotationElement(parameters) {421 _classCallCheck(this, RadioButtonWidgetAnnotationElement);422 return _possibleConstructorReturn(this, _getPrototypeOf(RadioButtonWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));423 }424 _createClass(RadioButtonWidgetAnnotationElement, [{425 key: "render",426 value: function render() {427 this.container.className = 'buttonWidgetAnnotation radioButton';428 var element = document.createElement('input');429 element.disabled = this.data.readOnly;430 element.type = 'radio';431 element.name = this.data.fieldName;432 if (this.data.fieldValue === this.data.buttonValue) {433 element.setAttribute('checked', true);434 }435 this.container.appendChild(element);436 return this.container;437 }438 }]);439 return RadioButtonWidgetAnnotationElement;440}(WidgetAnnotationElement);441var PushButtonWidgetAnnotationElement =442/*#__PURE__*/443function (_LinkAnnotationElemen) {444 _inherits(PushButtonWidgetAnnotationElement, _LinkAnnotationElemen);445 function PushButtonWidgetAnnotationElement() {446 _classCallCheck(this, PushButtonWidgetAnnotationElement);447 return _possibleConstructorReturn(this, _getPrototypeOf(PushButtonWidgetAnnotationElement).apply(this, arguments));448 }449 _createClass(PushButtonWidgetAnnotationElement, [{450 key: "render",451 value: function render() {452 var container = _get(_getPrototypeOf(PushButtonWidgetAnnotationElement.prototype), "render", this).call(this);453 container.className = 'buttonWidgetAnnotation pushButton';454 return container;455 }456 }]);457 return PushButtonWidgetAnnotationElement;458}(LinkAnnotationElement);459var ChoiceWidgetAnnotationElement =460/*#__PURE__*/461function (_WidgetAnnotationElem4) {462 _inherits(ChoiceWidgetAnnotationElement, _WidgetAnnotationElem4);463 function ChoiceWidgetAnnotationElement(parameters) {464 _classCallCheck(this, ChoiceWidgetAnnotationElement);465 return _possibleConstructorReturn(this, _getPrototypeOf(ChoiceWidgetAnnotationElement).call(this, parameters, parameters.renderInteractiveForms));466 }467 _createClass(ChoiceWidgetAnnotationElement, [{468 key: "render",469 value: function render() {470 this.container.className = 'choiceWidgetAnnotation';471 var selectElement = document.createElement('select');472 selectElement.disabled = this.data.readOnly;473 if (!this.data.combo) {474 selectElement.size = this.data.options.length;475 if (this.data.multiSelect) {476 selectElement.multiple = true;477 }478 }479 for (var i = 0, ii = this.data.options.length; i < ii; i++) {480 var option = this.data.options[i];481 var optionElement = document.createElement('option');482 optionElement.textContent = option.displayValue;483 optionElement.value = option.exportValue;484 if (this.data.fieldValue.includes(option.displayValue)) {485 optionElement.setAttribute('selected', true);486 }487 selectElement.appendChild(optionElement);488 }489 this.container.appendChild(selectElement);490 return this.container;491 }492 }]);493 return ChoiceWidgetAnnotationElement;494}(WidgetAnnotationElement);495var PopupAnnotationElement =496/*#__PURE__*/497function (_AnnotationElement4) {498 _inherits(PopupAnnotationElement, _AnnotationElement4);499 function PopupAnnotationElement(parameters) {500 _classCallCheck(this, PopupAnnotationElement);501 var isRenderable = !!(parameters.data.title || parameters.data.contents);502 return _possibleConstructorReturn(this, _getPrototypeOf(PopupAnnotationElement).call(this, parameters, isRenderable));503 }504 _createClass(PopupAnnotationElement, [{505 key: "render",506 value: function render() {507 var IGNORE_TYPES = ['Line', 'Square', 'Circle', 'PolyLine', 'Polygon', 'Ink'];508 this.container.className = 'popupAnnotation';509 if (IGNORE_TYPES.includes(this.data.parentType)) {510 return this.container;511 }512 var selector = '[data-annotation-id="' + this.data.parentId + '"]';513 var parentElement = this.layer.querySelector(selector);514 if (!parentElement) {515 return this.container;516 }517 var popup = new PopupElement({518 container: this.container,519 trigger: parentElement,520 color: this.data.color,521 title: this.data.title,522 modificationDate: this.data.modificationDate,523 contents: this.data.contents524 });525 var parentLeft = parseFloat(parentElement.style.left);526 var parentWidth = parseFloat(parentElement.style.width);527 this.container.style.transformOrigin = -(parentLeft + parentWidth) + 'px -' + parentElement.style.top;528 this.container.style.left = parentLeft + parentWidth + 'px';529 this.container.appendChild(popup.render());530 return this.container;531 }532 }]);533 return PopupAnnotationElement;534}(AnnotationElement);535var PopupElement =536/*#__PURE__*/537function () {538 function PopupElement(parameters) {539 _classCallCheck(this, PopupElement);540 this.container = parameters.container;541 this.trigger = parameters.trigger;542 this.color = parameters.color;543 this.title = parameters.title;544 this.modificationDate = parameters.modificationDate;545 this.contents = parameters.contents;546 this.hideWrapper = parameters.hideWrapper || false;547 this.pinned = false;548 }549 _createClass(PopupElement, [{550 key: "render",551 value: function render() {552 var BACKGROUND_ENLIGHT = 0.7;553 var wrapper = document.createElement('div');554 wrapper.className = 'popupWrapper';555 this.hideElement = this.hideWrapper ? wrapper : this.container;556 this.hideElement.setAttribute('hidden', true);557 var popup = document.createElement('div');558 popup.className = 'popup';559 var color = this.color;560 if (color) {561 var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];562 var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];563 var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];564 popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0);565 }566 var title = document.createElement('h1');567 title.textContent = this.title;568 popup.appendChild(title);569 var dateObject = _display_utils.PDFDateString.toDateObject(this.modificationDate);570 if (dateObject) {571 var modificationDate = document.createElement('span');572 modificationDate.textContent = '{{date}}, {{time}}';573 modificationDate.dataset.l10nId = 'annotation_date_string';574 modificationDate.dataset.l10nArgs = JSON.stringify({575 date: dateObject.toLocaleDateString(),576 time: dateObject.toLocaleTimeString()577 });578 popup.appendChild(modificationDate);579 }580 var contents = this._formatContents(this.contents);581 popup.appendChild(contents);582 this.trigger.addEventListener('click', this._toggle.bind(this));583 this.trigger.addEventListener('mouseover', this._show.bind(this, false));584 this.trigger.addEventListener('mouseout', this._hide.bind(this, false));585 popup.addEventListener('click', this._hide.bind(this, true));586 wrapper.appendChild(popup);587 return wrapper;588 }589 }, {590 key: "_formatContents",591 value: function _formatContents(contents) {592 var p = document.createElement('p');593 var lines = contents.split(/(?:\r\n?|\n)/);594 for (var i = 0, ii = lines.length; i < ii; ++i) {595 var line = lines[i];596 p.appendChild(document.createTextNode(line));597 if (i < ii - 1) {598 p.appendChild(document.createElement('br'));599 }600 }601 return p;602 }603 }, {604 key: "_toggle",605 value: function _toggle() {606 if (this.pinned) {607 this._hide(true);608 } else {609 this._show(true);610 }611 }612 }, {613 key: "_show",614 value: function _show() {615 var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;616 if (pin) {617 this.pinned = true;618 }619 if (this.hideElement.hasAttribute('hidden')) {620 this.hideElement.removeAttribute('hidden');621 this.container.style.zIndex += 1;622 }623 }624 }, {625 key: "_hide",626 value: function _hide() {627 var unpin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;628 if (unpin) {629 this.pinned = false;630 }631 if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {632 this.hideElement.setAttribute('hidden', true);633 this.container.style.zIndex -= 1;634 }635 }636 }]);637 return PopupElement;638}();639var FreeTextAnnotationElement =640/*#__PURE__*/641function (_AnnotationElement5) {642 _inherits(FreeTextAnnotationElement, _AnnotationElement5);643 function FreeTextAnnotationElement(parameters) {644 _classCallCheck(this, FreeTextAnnotationElement);645 var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);646 return _possibleConstructorReturn(this, _getPrototypeOf(FreeTextAnnotationElement).call(this, parameters, isRenderable, true));647 }648 _createClass(FreeTextAnnotationElement, [{649 key: "render",650 value: function render() {651 this.container.className = 'freeTextAnnotation';652 if (!this.data.hasPopup) {653 this._createPopup(this.container, null, this.data);654 }655 return this.container;656 }657 }]);658 return FreeTextAnnotationElement;659}(AnnotationElement);660var LineAnnotationElement =661/*#__PURE__*/662function (_AnnotationElement6) {663 _inherits(LineAnnotationElement, _AnnotationElement6);664 function LineAnnotationElement(parameters) {665 _classCallCheck(this, LineAnnotationElement);666 var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);667 return _possibleConstructorReturn(this, _getPrototypeOf(LineAnnotationElement).call(this, parameters, isRenderable, true));668 }669 _createClass(LineAnnotationElement, [{670 key: "render",671 value: function render() {672 this.container.className = 'lineAnnotation';673 var data = this.data;674 var width = data.rect[2] - data.rect[0];675 var height = data.rect[3] - data.rect[1];676 var svg = this.svgFactory.create(width, height);677 var line = this.svgFactory.createElement('svg:line');678 line.setAttribute('x1', data.rect[2] - data.lineCoordinates[0]);679 line.setAttribute('y1', data.rect[3] - data.lineCoordinates[1]);680 line.setAttribute('x2', data.rect[2] - data.lineCoordinates[2]);681 line.setAttribute('y2', data.rect[3] - data.lineCoordinates[3]);682 line.setAttribute('stroke-width', data.borderStyle.width);683 line.setAttribute('stroke', 'transparent');684 svg.appendChild(line);685 this.container.append(svg);686 this._createPopup(this.container, line, data);687 return this.container;688 }689 }]);690 return LineAnnotationElement;691}(AnnotationElement);692var SquareAnnotationElement =693/*#__PURE__*/694function (_AnnotationElement7) {695 _inherits(SquareAnnotationElement, _AnnotationElement7);696 function SquareAnnotationElement(parameters) {697 _classCallCheck(this, SquareAnnotationElement);698 var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);699 return _possibleConstructorReturn(this, _getPrototypeOf(SquareAnnotationElement).call(this, parameters, isRenderable, true));700 }701 _createClass(SquareAnnotationElement, [{702 key: "render",703 value: function render() {704 this.container.className = 'squareAnnotation';705 var data = this.data;706 var width = data.rect[2] - data.rect[0];707 var height = data.rect[3] - data.rect[1];708 var svg = this.svgFactory.create(width, height);709 var borderWidth = data.borderStyle.width;710 var square = this.svgFactory.createElement('svg:rect');711 square.setAttribute('x', borderWidth / 2);712 square.setAttribute('y', borderWidth / 2);713 square.setAttribute('width', width - borderWidth);714 square.setAttribute('height', height - borderWidth);715 square.setAttribute('stroke-width', borderWidth);716 square.setAttribute('stroke', 'transparent');717 square.setAttribute('fill', 'none');718 svg.appendChild(square);719 this.container.append(svg);720 this._createPopup(this.container, square, data);721 return this.container;722 }723 }]);724 return SquareAnnotationElement;725}(AnnotationElement);726var CircleAnnotationElement =727/*#__PURE__*/728function (_AnnotationElement8) {729 _inherits(CircleAnnotationElement, _AnnotationElement8);730 function CircleAnnotationElement(parameters) {731 _classCallCheck(this, CircleAnnotationElement);732 var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);733 return _possibleConstructorReturn(this, _getPrototypeOf(CircleAnnotationElement).call(this, parameters, isRenderable, true));734 }735 _createClass(CircleAnnotationElement, [{736 key: "render",737 value: function render() {738 this.container.className = 'circleAnnotation';739 var data = this.data;740 var width = data.rect[2] - data.rect[0];741 var height = data.rect[3] - data.rect[1];742 var svg = this.svgFactory.create(width, height);743 var borderWidth = data.borderStyle.width;744 var circle = this.svgFactory.createElement('svg:ellipse');745 circle.setAttribute('cx', width / 2);746 circle.setAttribute('cy', height / 2);747 circle.setAttribute('rx', width / 2 - borderWidth / 2);748 circle.setAttribute('ry', height / 2 - borderWidth / 2);749 circle.setAttribute('stroke-width', borderWidth);750 circle.setAttribute('stroke', 'transparent');751 circle.setAttribute('fill', 'none');752 svg.appendChild(circle);753 this.container.append(svg);754 this._createPopup(this.container, circle, data);755 return this.container;756 }757 }]);758 return CircleAnnotationElement;759}(AnnotationElement);760var PolylineAnnotationElement =761/*#__PURE__*/762function (_AnnotationElement9) {763 _inherits(PolylineAnnotationElement, _AnnotationElement9);764 function PolylineAnnotationElement(parameters) {765 var _this3;766 _classCallCheck(this, PolylineAnnotationElement);767 var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);768 _this3 = _possibleConstructorReturn(this, _getPrototypeOf(PolylineAnnotationElement).call(this, parameters, isRenderable, true));769 _this3.containerClassName = 'polylineAnnotation';770 _this3.svgElementName = 'svg:polyline';771 return _this3;772 }773 _createClass(PolylineAnnotationElement, [{774 key: "render",775 value: function render() {776 this.container.className = this.containerClassName;777 var data = this.data;778 var width = data.rect[2] - data.rect[0];779 var height = data.rect[3] - data.rect[1];780 var svg = this.svgFactory.create(width, height);781 var vertices = data.vertices;782 var points = [];783 for (var i = 0, ii = vertices.length; i < ii; i++) {784 var x = vertices[i].x - data.rect[0];785 var y = data.rect[3] - vertices[i].y;786 points.push(x + ',' + y);787 }788 points = points.join(' ');789 var borderWidth = data.borderStyle.width;790 var polyline = this.svgFactory.createElement(this.svgElementName);791 polyline.setAttribute('points', points);792 polyline.setAttribute('stroke-width', borderWidth);793 polyline.setAttribute('stroke', 'transparent');794 polyline.setAttribute('fill', 'none');795 svg.appendChild(polyline);796 this.container.append(svg);797 this._createPopup(this.container, polyline, data);798 return this.container;799 }800 }]);801 return PolylineAnnotationElement;802}(AnnotationElement);803var PolygonAnnotationElement =804/*#__PURE__*/805function (_PolylineAnnotationEl) {806 _inherits(PolygonAnnotationElement, _PolylineAnnotationEl);807 function PolygonAnnotationElement(parameters) {808 var _this4;809 _classCallCheck(this, PolygonAnnotationElement);810 _this4 = _possibleConstructorReturn(this, _getPrototypeOf(PolygonAnnotationElement).call(this, parameters));811 _this4.containerClassName = 'polygonAnnotation';812 _this4.svgElementName = 'svg:polygon';813 return _this4;814 }815 return PolygonAnnotationElement;816}(PolylineAnnotationElement);817var CaretAnnotationElement =818/*#__PURE__*/819function (_AnnotationElement10) {820 _inherits(CaretAnnotationElement, _AnnotationElement10);821 function CaretAnnotationElement(parameters) {822 _classCallCheck(this, CaretAnnotationElement);823 var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);824 return _possibleConstructorReturn(this, _getPrototypeOf(CaretAnnotationElement).call(this, parameters, isRenderable, true));825 }826 _createClass(CaretAnnotationElement, [{827 key: "render",828 value: function render() {829 this.container.className = 'caretAnnotation';830 if (!this.data.hasPopup) {831 this._createPopup(this.container, null, this.data);832 }833 return this.container;834 }835 }]);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = new WebPageTest('www.webpagetest.org');2 if (err) {3 console.log(err);4 } else {5 console.log(data);6 }7});8{statusCode: 200, statusMessage: "OK", headers: Object, body: "Test not found"}9var wpt = new WebPageTest('www.webpagetest.org');10 if (err) {11 console.log(err);12 } else {13 console.log(data);14 }15});16I am trying to use the webpagetest API to run a test and get the results. I am using the nodejs module for the API. I am able to run the test but I am not able to get the results. The results are not available in the callback function. I am getting the following error: {statusCode: 200, statusMessage: "OK", headers: Object, body: "Test not found"} I am using the following code to run the test

Full Screen

Using AI Code Generation

copy

Full Screen

1var caretAnnotationElement = new CaretAnnotationElement();2caretAnnotationElement.setCaretAnnotationElement("test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test");3caretAnnotationElement.getCaretAnnotationElement();4caretAnnotationElement.getAnnotationElement();5caretAnnotationElement.setAnnotationElement("test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test");6caretAnnotationElement.getAnnotationElement();7caretAnnotationElement.setAnnotationElement("test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test");8caretAnnotationElement.getAnnotationElement();9caretAnnotationElement.setAnnotationElement("test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test");10caretAnnotationElement.getAnnotationElement();11caretAnnotationElement.setAnnotationElement("test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test");12caretAnnotationElement.getAnnotationElement();13caretAnnotationElement.setAnnotationElement("test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test");14caretAnnotationElement.getAnnotationElement();15caretAnnotationElement.setAnnotationElement("test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test");16caretAnnotationElement.getAnnotationElement();17caretAnnotationElement.setAnnotationElement("test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test");18caretAnnotationElement.getAnnotationElement();19caretAnnotationElement.setAnnotationElement("test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test");20caretAnnotationElement.getAnnotationElement();21caretAnnotationElement.setAnnotationElement("test", "test", "test", "test", "test", "test", "test", "test", "test", "test", "test");22caretAnnotationElement.getAnnotationElement();23caretAnnotationElement.setAnnotationElement("test", "test", "test",

Full Screen

Using AI Code Generation

copy

Full Screen

1var caret = new CaretAnnotationElement();2caret.setCaretPosition(0, 0);3var CaretAnnotationElement = function() {4 this.setCaretPosition = function(x, y) {5 }6}7function test() {8 var a = 1;9 var b = 2;10 var c = 3;11 var d = 4;12 var e = 5;13 var f = 6;14 var g = 7;15 var h = 8;16 var i = 9;17 var j = 10;18 var k = 11;19 var l = 12;20 var m = 13;21 var n = 14;22 var o = 15;23 var p = 16;24 var q = 17;25 var r = 18;26 var s = 19;27 var t = 20;28 var u = 21;29 var v = 22;30 var w = 23;31 var x = 24;32 var y = 25;33 var z = 26;34 var aa = 27;35 var bb = 28;36 var cc = 29;37 var dd = 30;38 var ee = 31;39 var ff = 32;40 var gg = 33;41 var hh = 34;42 var ii = 35;43 var jj = 36;44 var kk = 37;45 var ll = 38;46 var mm = 39;47 var nn = 40;48 var oo = 41;49 var pp = 42;50 var qq = 43;51 var rr = 44;52 var ss = 45;53 var tt = 46;54 var uu = 47;55 var vv = 48;56 var ww = 49;57 var xx = 50;58 var yy = 51;59 var zz = 52;

Full Screen

Using AI Code Generation

copy

Full Screen

1const CaretAnnotationElement = wp.blocks.RichText.CaretAnnotationElement;2const Range = wp.blocks.RichText.Range;3const caretAnnotationElement = new CaretAnnotationElement( {4 "range": new Range( 0, 0 ),5 "annotation": {6 "attributes": {7 },8 },9} );10const newCaretAnnotationElement = wp.blocks.RichText.insert( this.state.text, [ caretAnnotationElement ] );11### `wp.blocks.RichText.applyFormat( value, format, start, end )`12### `wp.blocks.RichText.removeFormat( value, formatTypes, start, end )`13### `wp.blocks.RichText.toggleFormat( value, format, start, end )`14### `wp.blocks.RichText.getFormatType( name )`

Full Screen

Using AI Code Generation

copy

Full Screen

1function test()2{3 var cae = new CaretAnnotationElement();4 cae.setCaretAnnotationElement("test");5}6test();7function CaretAnnotationElement()8{9 this.setCaretAnnotationElement = function (value)10 {11 console.log(value);12 }13}

Full Screen

Using AI Code Generation

copy

Full Screen

1var editor = document.getElementById('editor');2editor.insertElement(new CaretAnnotationElement('span', {'class': 'test'}));3function CaretAnnotationElement(tag, attributes) {4 this.tag = tag;5 this.attributes = attributes;6}7CaretAnnotationElement.prototype = {8 insert: function (editor) {9 var doc = editor.getDoc();10 var range = editor.getRange();11 var element = doc.createElement(this.tag);12 for (var name in this.attributes) {13 element.setAttribute(name, this.attributes[name]);14 }15 range.insertNode(element);16 }17};18WpTextEditor.prototype.insertElement = function (element) {19 element.insert(this);20};

Full Screen

Using AI Code Generation

copy

Full Screen

1(function() {2 var CaretAnnotationElement = function() {3 var caret = document.createElement("span");4 caret.id = "caret";5 return caret;6 };7 CaretAnnotationElement.prototype = {8 get caretAnnotationElement() {9 return document.getElementById("caret");10 }11 };12 window.CaretAnnotationElement = CaretAnnotationElement;13})();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful