How to use PopupAnnotationElement method in wpt

Best JavaScript code snippet using wpt

annotation_layer.js

Source:annotation_layer.js Github

copy

Full Screen

...59 return new TextAnnotationElement(parameters);60 case AnnotationType.WIDGET:61 return new WidgetAnnotationElement(parameters);62 case AnnotationType.POPUP:63 return new PopupAnnotationElement(parameters);64 case AnnotationType.HIGHLIGHT:65 return new HighlightAnnotationElement(parameters);66 case AnnotationType.UNDERLINE:67 return new UnderlineAnnotationElement(parameters);68 case AnnotationType.SQUIGGLY:69 return new SquigglyAnnotationElement(parameters);70 case AnnotationType.STRIKEOUT:71 return new StrikeOutAnnotationElement(parameters);72 default:73 throw new Error('Unimplemented annotation type "' + subtype + '"');74 }75 }76};77/**78 * @class79 * @alias AnnotationElement80 */81var AnnotationElement = (function AnnotationElementClosure() {82 function AnnotationElement(parameters) {83 this.data = parameters.data;84 this.layer = parameters.layer;85 this.page = parameters.page;86 this.viewport = parameters.viewport;87 this.linkService = parameters.linkService;88 this.container = this._createContainer();89 }90 AnnotationElement.prototype = /** @lends AnnotationElement.prototype */ {91 /**92 * Create an empty container for the annotation's HTML element.93 *94 * @private95 * @memberof AnnotationElement96 * @returns {HTMLSectionElement}97 */98 _createContainer: function AnnotationElement_createContainer() {99 var data = this.data, page = this.page, viewport = this.viewport;100 var container = document.createElement('section');101 var width = data.rect[2] - data.rect[0];102 var height = data.rect[3] - data.rect[1];103 container.setAttribute('data-annotation-id', data.id);104 // Do *not* modify `data.rect`, since that will corrupt the annotation105 // position on subsequent calls to `_createContainer` (see issue 6804).106 var rect = Util.normalizeRect([107 data.rect[0],108 page.view[3] - data.rect[1] + page.view[1],109 data.rect[2],110 page.view[3] - data.rect[3] + page.view[1]111 ]);112 CustomStyle.setProp('transform', container,113 'matrix(' + viewport.transform.join(',') + ')');114 CustomStyle.setProp('transformOrigin', container,115 -rect[0] + 'px ' + -rect[1] + 'px');116 if (data.borderStyle.width > 0) {117 container.style.borderWidth = data.borderStyle.width + 'px';118 if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {119 // Underline styles only have a bottom border, so we do not need120 // to adjust for all borders. This yields a similar result as121 // Adobe Acrobat/Reader.122 width = width - 2 * data.borderStyle.width;123 height = height - 2 * data.borderStyle.width;124 }125 var horizontalRadius = data.borderStyle.horizontalCornerRadius;126 var verticalRadius = data.borderStyle.verticalCornerRadius;127 if (horizontalRadius > 0 || verticalRadius > 0) {128 var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';129 CustomStyle.setProp('borderRadius', container, radius);130 }131 switch (data.borderStyle.style) {132 case AnnotationBorderStyleType.SOLID:133 container.style.borderStyle = 'solid';134 break;135 case AnnotationBorderStyleType.DASHED:136 container.style.borderStyle = 'dashed';137 break;138 case AnnotationBorderStyleType.BEVELED:139 warn('Unimplemented border style: beveled');140 break;141 case AnnotationBorderStyleType.INSET:142 warn('Unimplemented border style: inset');143 break;144 case AnnotationBorderStyleType.UNDERLINE:145 container.style.borderBottomStyle = 'solid';146 break;147 default:148 break;149 }150 if (data.color) {151 container.style.borderColor =152 Util.makeCssRgb(data.color[0] | 0,153 data.color[1] | 0,154 data.color[2] | 0);155 } else {156 // Transparent (invisible) border, so do not draw it at all.157 container.style.borderWidth = 0;158 }159 }160 container.style.left = rect[0] + 'px';161 container.style.top = rect[1] + 'px';162 container.style.width = width + 'px';163 container.style.height = height + 'px';164 return container;165 },166 /**167 * Render the annotation's HTML element in the empty container.168 *169 * @public170 * @memberof AnnotationElement171 */172 render: function AnnotationElement_render() {173 throw new Error('Abstract method AnnotationElement.render called');174 }175 };176 return AnnotationElement;177})();178/**179 * @class180 * @alias LinkAnnotationElement181 */182var LinkAnnotationElement = (function LinkAnnotationElementClosure() {183 function LinkAnnotationElement(parameters) {184 AnnotationElement.call(this, parameters);185 }186 Util.inherit(LinkAnnotationElement, AnnotationElement, {187 /**188 * Render the link annotation's HTML element in the empty container.189 *190 * @public191 * @memberof LinkAnnotationElement192 * @returns {HTMLSectionElement}193 */194 render: function LinkAnnotationElement_render() {195 this.container.className = 'linkAnnotation';196 var link = document.createElement('a');197 addLinkAttributes(link, { url: this.data.url });198 if (!this.data.url) {199 if (this.data.action) {200 this._bindNamedAction(link, this.data.action);201 } else {202 this._bindLink(link, ('dest' in this.data) ? this.data.dest : null);203 }204 }205 this.container.appendChild(link);206 return this.container;207 },208 /**209 * Bind internal links to the link element.210 *211 * @private212 * @param {Object} link213 * @param {Object} destination214 * @memberof LinkAnnotationElement215 */216 _bindLink: function LinkAnnotationElement_bindLink(link, destination) {217 var self = this;218 link.href = this.linkService.getDestinationHash(destination);219 link.onclick = function() {220 if (destination) {221 self.linkService.navigateTo(destination);222 }223 return false;224 };225 if (destination) {226 link.className = 'internalLink';227 }228 },229 /**230 * Bind named actions to the link element.231 *232 * @private233 * @param {Object} link234 * @param {Object} action235 * @memberof LinkAnnotationElement236 */237 _bindNamedAction:238 function LinkAnnotationElement_bindNamedAction(link, action) {239 var self = this;240 link.href = this.linkService.getAnchorUrl('');241 link.onclick = function() {242 self.linkService.executeNamedAction(action);243 return false;244 };245 link.className = 'internalLink';246 }247 });248 return LinkAnnotationElement;249})();250/**251 * @class252 * @alias TextAnnotationElement253 */254var TextAnnotationElement = (function TextAnnotationElementClosure() {255 function TextAnnotationElement(parameters) {256 AnnotationElement.call(this, parameters);257 }258 Util.inherit(TextAnnotationElement, AnnotationElement, {259 /**260 * Render the text annotation's HTML element in the empty container.261 *262 * @public263 * @memberof TextAnnotationElement264 * @returns {HTMLSectionElement}265 */266 render: function TextAnnotationElement_render() {267 this.container.className = 'textAnnotation';268 var image = document.createElement('img');269 image.style.height = this.container.style.height;270 image.style.width = this.container.style.width;271 image.src = PDFJS.imageResourcesPath + 'annotation-' +272 this.data.name.toLowerCase() + '.svg';273 image.alt = '[{{type}} Annotation]';274 image.dataset.l10nId = 'text_annotation_type';275 image.dataset.l10nArgs = JSON.stringify({type: this.data.name});276 if (!this.data.hasPopup) {277 var popupElement = new PopupElement({278 container: this.container,279 trigger: image,280 color: this.data.color,281 title: this.data.title,282 contents: this.data.contents,283 hideWrapper: true284 });285 var popup = popupElement.render();286 // Position the popup next to the Text annotation's container.287 popup.style.left = image.style.width;288 this.container.appendChild(popup);289 }290 this.container.appendChild(image);291 return this.container;292 }293 });294 return TextAnnotationElement;295})();296/**297 * @class298 * @alias WidgetAnnotationElement299 */300var WidgetAnnotationElement = (function WidgetAnnotationElementClosure() {301 function WidgetAnnotationElement(parameters) {302 AnnotationElement.call(this, parameters);303 }304 Util.inherit(WidgetAnnotationElement, AnnotationElement, {305 /**306 * Render the widget annotation's HTML element in the empty container.307 *308 * @public309 * @memberof WidgetAnnotationElement310 * @returns {HTMLSectionElement}311 */312 render: function WidgetAnnotationElement_render() {313 var content = document.createElement('div');314 content.textContent = this.data.fieldValue;315 var textAlignment = this.data.textAlignment;316 content.style.textAlign = ['left', 'center', 'right'][textAlignment];317 content.style.verticalAlign = 'middle';318 content.style.display = 'table-cell';319 var font = (this.data.fontRefName ?320 this.page.commonObjs.getData(this.data.fontRefName) : null);321 this._setTextStyle(content, font);322 this.container.appendChild(content);323 return this.container;324 },325 /**326 * Apply text styles to the text in the element.327 *328 * @private329 * @param {HTMLDivElement} element330 * @param {Object} font331 * @memberof WidgetAnnotationElement332 */333 _setTextStyle:334 function WidgetAnnotationElement_setTextStyle(element, font) {335 // TODO: This duplicates some of the logic in CanvasGraphics.setFont().336 var style = element.style;337 style.fontSize = this.data.fontSize + 'px';338 style.direction = (this.data.fontDirection < 0 ? 'rtl': 'ltr');339 if (!font) {340 return;341 }342 style.fontWeight = (font.black ?343 (font.bold ? '900' : 'bold') :344 (font.bold ? 'bold' : 'normal'));345 style.fontStyle = (font.italic ? 'italic' : 'normal');346 // Use a reasonable default font if the font doesn't specify a fallback.347 var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';348 var fallbackName = font.fallbackName || 'Helvetica, sans-serif';349 style.fontFamily = fontFamily + fallbackName;350 }351 });352 return WidgetAnnotationElement;353})();354/**355 * @class356 * @alias PopupAnnotationElement357 */358var PopupAnnotationElement = (function PopupAnnotationElementClosure() {359 function PopupAnnotationElement(parameters) {360 AnnotationElement.call(this, parameters);361 }362 Util.inherit(PopupAnnotationElement, AnnotationElement, {363 /**364 * Render the popup annotation's HTML element in the empty container.365 *366 * @public367 * @memberof PopupAnnotationElement368 * @returns {HTMLSectionElement}369 */370 render: function PopupAnnotationElement_render() {371 this.container.className = 'popupAnnotation';372 var selector = '[data-annotation-id="' + this.data.parentId + '"]';373 var parentElement = this.layer.querySelector(selector);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var popup = new wptools.PopupAnnotationElement();3popup.show('Hello world', 100, 100);4var popup = new PopupAnnotationElement();5popup.show('Hello world', 100, 100);6new PopupAnnotationElement()7show(message, x, y)8hide()

Full Screen

Using AI Code Generation

copy

Full Screen

1function test() {2 var editor = document.getElementById("editor");3 var popup = document.getElementById("popup");4 editor.setPopupAnnotationElement(popup);5 editor.popupAnnotationElement(0, 0, 0, 0, "test message");6}7> var gWPTimer = null;8> var gWPTimerID = 0;9>+var gWPAnnotationElement = null;10> var gWPAnnotationElementID = 0;11> var gWPAnnotationElementTimer = null;12> var gWPAnnotationElementTimerID = 0;13>+var gWPPopupAnnotationElement = null;14> function PopupAnnotationElement(aElement, aX, aY)15> {16> if (gWPTimer)17> gWPTimer.cancel();18> gWPTimer = null;19> }20>+ gWPPopupAnnotationElement = null;21> if (gWPAnnotationElement)22> {23> gWPAnnotationElement.hidePopup();24> gWPAnnotationElement = null;25> }26> if (gWPAnnotationElementTimer)27>+ gWPPopupAnnotationElement = null;28> {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var driver = new wpt.Driver();3var popupAnnotationElement = driver.createPopupAnnotationElement();4if (popupAnnotationElement != null) {5 console.log("Successfully created a popup annotation element");6}7if (popupAnnotationElement != null) {8 console.log("Successfully verified the popup annotation element");9}10var wpt = require('wpt');11var driver = new wpt.Driver();12var popupAnnotationElement = driver.createPopupAnnotationElement();13if (popupAnnotationElement != null) {14 console.log("Successfully created a popup annotation element");15}16if (popupAnnotationElement != null) {17 console.log("Successfully verified the popup annotation element");18}

Full Screen

Using AI Code Generation

copy

Full Screen

1var popup = new PopupAnnotationElement();2popup.PopupAnnotationElement();3popup.setPopupText("This is a test popup");4popup.setPopupPosition("top");5popup.setPopupColor("red");6popup.setPopupTextColor("white");7popup.setPopupSize(300, 200);8popup.setPopupTextSize(12);9popup.setPopupTextFont("Arial");10popup.setPopupTextFontStyle("italic");11popup.setPopupTextFontWeight("bold");12popup.setPopupTextAlign("center");13popup.setPopupTextPadding(10);14popup.setPopupTextVerticalAlign("middle");15popup.setPopupTextLineHeight(1.5);16popup.setPopupTextLetterSpacing(2);17popup.setPopupTextWordSpacing(5);18popup.setPopupTextDecoration("underline");19popup.setPopupTextTransform("uppercase");20popup.setPopupTextIndent(10);21popup.setPopupTextShadow("5px 5px 5px black");22popup.setPopupTextBorder("1px solid black");23popup.setPopupTextBorderRadius(10);24popup.setPopupTextBackgroundColor("blue");25popup.setPopupTextBackgroundRepeat("no-repeat");26popup.setPopupTextBackgroundSize("cover");27popup.setPopupTextBackgroundPosition("center");28popup.setPopupTextBackgroundAttachment("fixed");

Full Screen

Using AI Code Generation

copy

Full Screen

1var test = new PDFTest();2var pdf = test.open("test.pdf");3var popup = pdf.PopupAnnotationElement();4popup.setPopupAnnotation(100, 100, 200, 200);5popup.verifyPopupAnnotation(100, 100, 200, 200);6test.close();7var test = new PDFTest();8var pdf = test.open("test.pdf");9var popup = pdf.PopupAnnotationElement();10popup.setPopupAnnotation(100, 100, 200, 200);11popup.verifyPopupAnnotation(100, 100, 200, 200);12test.close();13var test = new PDFTest();14var pdf = test.open("test.pdf");15var popup = pdf.PopupAnnotationElement();16popup.setPopupAnnotation(100, 100, 200, 200);17popup.verifyPopupAnnotation(100, 100, 200, 200);18test.close();19var test = new PDFTest();

Full Screen

Using AI Code Generation

copy

Full Screen

1var popup = new PopupAnnotationElement();2popup.setPopupText("This is a test popup annotation element");3popup.setPopupLocation(100,100);4popup.setPopupSize(100,100);5popup.setPopupColor(255,255,255);6popup.setPopupOpacity(1);7popup.setPopupBorderColor(0,0,0);8popup.setPopupBorderWidth(1);9popup.setPopupBorderRadius(1);10popup.setPopupFont("Arial", "normal", "normal");11popup.setPopupFontSize(16);12popup.setPopupFontColor(0,0,0);

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