Best JavaScript code snippet using playwright-internal
TitleBar.js
Source:TitleBar.js
1//==============================================================================2//3// TOBESOFT Co., Ltd.4// Copyright 2014 TOBESOFT Co., Ltd.5// All Rights Reserved.6//7// NOTICE: TOBESOFT permits you to use, modify, and distribute this file 8// in accordance with the terms of the license agreement accompanying it.9//10// Readme URL: http://www.nexacro.co.kr/legal/nexacro-public-license-readme-1.0.html 11//12//==============================================================================13if (!nexacro.TitleBar) {14 nexacro.TitleBar_Style = function (target) {15 this.icon = null;16 this._target = target || null;17 };18 var _pTitleBarStyle = nexacro._createPrototype(nexacro.Style, nexacro.TitleBar_Style);19 nexacro.TitleBar_Style.prototype = _pTitleBarStyle;20 eval(nexacro._createValueAttributeEvalStr("_pTitleBarStyle", "icon"));21 _pTitleBarStyle.__custom_emptyObject = function () {22 this.icon = null;23 };24 _pTitleBarStyle.__get_custom_style_value = function () {25 var val = "";26 if (this.icon && !this.icon._is_empty) {27 val += "icon:" + this.icon._value + "; ";28 }29 return val;30 };31 nexacro.TitleBar_CurrentStyle = function () {32 this.icon = null;33 };34 var _pTitleBarCurrentStyle = nexacro._createPrototype(nexacro.CurrentStyle, nexacro.TitleBar_CurrentStyle);35 nexacro.TitleBar_CurrentStyle.prototype = _pTitleBarCurrentStyle;36 _pTitleBarCurrentStyle.__custom_emptyObject = _pTitleBarStyle.__custom_emptyObject;37 _pTitleBarCurrentStyle.__get_custom_style_value = _pTitleBarStyle.__get_custom_style_value;38 delete _pTitleBarStyle;39 delete _pTitleBarCurrentStyle;40 nexacro.TitleBar = function (id, position, left, top, width, height, right, bottom, parent) {41 nexacro.Form.call(this, id, position, left, top, width, height, right, bottom, parent);42 this.minbutton = null;43 this.normalbutton = null;44 this.maxbutton = null;45 this.closebutton = null;46 this._state_openstatus = 0;47 if (parent && parent._is_frame && parent._is_window) {48 this._is_track = false;49 }50 else {51 this._is_track = true;52 }53 this._icon_elem = null;54 this._text_elem = null;55 this._titletext = "";56 this._is_verticalmin = false;57 this._absolute_style = 0;58 this._iconwidth = 0;59 this._iconheight = 0;60 this._is_scrollable = false;61 this._is_nc_control = true;62 this._is_focus_accept = false;63 };64 var _pTitleBar = nexacro._createPrototype(nexacro.Form, nexacro.TitleBar);65 nexacro.TitleBar.prototype = _pTitleBar;66 _pTitleBar._type_name = "TitleBar";67 nexacro.TitleBar._default_align = nexacro.Component._default_left_align;68 nexacro.TitleBar._default_icon = null;69 _pTitleBar.on_create_custom_style = function () {70 return new nexacro.TitleBar_Style(this);71 };72 _pTitleBar.on_create_custom_currentStyle = function () {73 return new nexacro.TitleBar_CurrentStyle();74 };75 _pTitleBar.on_apply_custom_pseudo = function (pseudo) {76 var curstyle = this.currentstyle;77 var font = this.on_find_CurrentStyle_font(pseudo);78 if (curstyle.font != font) {79 curstyle.font = font;80 this.on_apply_style_font(font);81 }82 var color = this.on_find_CurrentStyle_color(pseudo);83 if (curstyle.color != color) {84 curstyle.color = color;85 this.on_apply_style_color(color);86 }87 var icon = this.on_find_CurrentStyle_icon(pseudo);88 if (icon != curstyle.icon) {89 curstyle.icon = icon;90 this.on_apply_style_icon(icon);91 }92 var padding = this.on_find_CurrentStyle_padding(pseudo);93 if (curstyle.padding != padding) {94 curstyle.padding = padding;95 this.on_apply_style_padding(padding);96 }97 var rtlimagemirroring = this.on_find_CurrentStyle_rtlimagemirroring(pseudo);98 if (rtlimagemirroring != curstyle.rtlimagemirroring) {99 curstyle.rtlimagemirroring = rtlimagemirroring;100 this.on_apply_style_rtlimagemirroring(rtlimagemirroring);101 }102 };103 _pTitleBar.on_find_CurrentStyle_icon = function (pseudo) {104 var icon = this._find_pseudo_obj("icon", pseudo, "value");105 return icon ? icon : nexacro.TitleBar._default_icon;106 };107 _pTitleBar.on_update_style_icon = function () {108 this.on_apply_style_icon(this.currentstyle.icon = this.on_find_CurrentStyle_icon(this._pseudo));109 };110 _pTitleBar.on_update_style_padding = function () {111 var padding = this.currentstyle.padding = this.on_find_CurrentStyle_padding(this._pseudo);112 if (this._control_element) {113 this._control_element.setElementPadding(padding);114 this._updateClientSize(this._control_element);115 }116 };117 _pTitleBar.on_apply_style_padding = function (padding) {118 if (this._control_element) {119 this._control_element.setElementPadding(padding);120 }121 };122 _pTitleBar.on_apply_style_icon = function (icon) {123 if (this._icon_elem) {124 var ownerframe = this.getOwnerFrame();125 if (ownerframe && ownerframe.currentstyle.icon && !ownerframe.currentstyle.icon._is_empty) {126 icon = ownerframe.currentstyle.icon;127 }128 if (icon == null) {129 icon = this.currentstyle.icon;130 }131 var iconsize = nexacro._getImageSize(icon.value, this._on_loadicon, this, this._getRefFormBaseUrl());132 if (iconsize) {133 if ((iconsize.width > 0) && (iconsize.height > 0)) {134 this._iconwidth = iconsize.width;135 this._iconheight = iconsize.height;136 }137 }138 if (ownerframe.showtitleicon == false) {139 this._icon_elem.setElementImageUrl("");140 }141 else {142 this._icon_elem.setElementImageUrl(icon.value);143 }144 this._updateControlPosition();145 }146 };147 _pTitleBar.on_apply_style_font = function (font) {148 if (this._text_elem) {149 this._text_elem.setElementFont(font);150 }151 };152 _pTitleBar.on_apply_style_color = function (color) {153 if (this._text_elem) {154 this._text_elem.setElementColor(color);155 }156 };157 _pTitleBar.on_apply_style_align = function (align) {158 if (this._text_elem) {159 this._text_elem.setElementAlign(align);160 }161 };162 _pTitleBar.on_apply_style_rtlimagemirroring = function (rtlimagemirroring) {163 var control_elem = this._control_element;164 var img_elem = this._img_elem;165 if (this.minbutton) {166 this.minbutton.on_apply_style_rtlimagemirroring(rtlimagemirroring);167 }168 if (this.maxbutton) {169 this.maxbutton.on_apply_style_rtlimagemirroring(rtlimagemirroring);170 }171 if (this.normalbutton) {172 this.normalbutton.on_apply_style_rtlimagemirroring(rtlimagemirroring);173 }174 if (this.closebutton) {175 this.closebutton.on_apply_style_rtlimagemirroring(rtlimagemirroring);176 }177 };178 _pTitleBar.on_create_contents = function () {179 var control_elem = this.getElement();180 if (control_elem) {181 var ownerframe = this.getOwnerFrame();182 var curstyle = this.currentstyle;183 var iconElem = this._icon_elem = new nexacro.AlignImageElement(control_elem);184 iconElem.setElementAlignXY("center", "middle");185 var textElem = this._text_elem = new nexacro.TextBoxElement(control_elem);186 if (this._titletext) {187 textElem.setElementText(this._titletext);188 }189 textElem.setElementAlign(curstyle.align ? curstyle.align : nexacro.TitleBar._default_align);190 textElem.setElementFont(curstyle.font);191 textElem.setElementColor(curstyle.color);192 var minBtn = this.minbutton = new nexacro.ImageButtonCtrl("minbutton", "absolute", 0, 0, 0, 0, null, null, this);193 var maxBtn = this.maxbutton = new nexacro.ImageButtonCtrl("maxbutton", "absolute", 0, 0, 0, 0, null, null, this);194 var normalBtn = this.normalbutton = new nexacro.ImageButtonCtrl("normalbutton", "absolute", 0, 0, 0, 0, null, null, this);195 var closeBtn = this.closebutton = new nexacro.ImageButtonCtrl("closebutton", "absolute", 0, 0, 0, 0, null, null, this);196 normalBtn.set_visible(false);197 if (ownerframe) {198 minBtn._setEventHandler("onclick", ownerframe.on_minbutton_click, ownerframe);199 maxBtn._setEventHandler("onclick", ownerframe.on_maxbutton_click, ownerframe);200 normalBtn._setEventHandler("onclick", ownerframe.on_normalbutton_click, ownerframe);201 closeBtn._setEventHandler("onclick", ownerframe.on_closebutton_click, ownerframe);202 this._setEventHandler("ondblclick", ownerframe._on_titlebar_dblclick, ownerframe);203 }204 var icon;205 if (ownerframe && ownerframe.currentstyle.icon && !ownerframe.currentstyle.icon._is_empty) {206 icon = ownerframe.currentstyle.icon;207 }208 else {209 icon = this.currentstyle.icon;210 }211 if (icon) {212 var val = nexacro._getURIValue(icon._value);213 val = nexacro._getImageLocation(val, this._getRefFormBaseUrl());214 if (ownerframe.showtitleicon != false) {215 iconElem.setElementImageUrl(icon.value);216 }217 var iconsize = nexacro._getImageSize(val, this._on_loadicon, this, this._getRefFormBaseUrl());218 if (iconsize) {219 if ((iconsize.width > 0) && (iconsize.height > 0)) {220 this._iconwidth = iconsize.width;221 this._iconheight = iconsize.height;222 if (this._icon_elem) {223 this._updateControlPosition(this._client_width, this._client_height);224 }225 var frame = this.parent;226 if (frame && frame._is_window) {227 var _window = frame._getWindow();228 if (_window) {229 nexacro._setWindowHandleIcon(_window._handle, val);230 }231 }232 }233 }234 }235 this._updateControlPosition(this._client_width, this._client_height);236 minBtn.createComponent();237 maxBtn.createComponent();238 normalBtn.createComponent();239 closeBtn.createComponent();240 }241 };242 _pTitleBar.on_created_contents = function () {243 this._icon_elem.create();244 this._text_elem.create();245 this.minbutton.on_created();246 this.maxbutton.on_created();247 this.normalbutton.on_created();248 this.closebutton.on_created();249 if (this._pseudo) {250 var rtlimagemirroring = this.on_find_CurrentStyle_rtlimagemirroring(this._pseudo);251 this.on_apply_style_rtlimagemirroring(rtlimagemirroring);252 }253 };254 _pTitleBar.on_destroy_contents = function () {255 var iconElem = this._icon_elem;256 var textElem = this._text_elem;257 var minBtn = this.minbutton;258 var maxBtn = this.maxbutton;259 var normalBtn = this.normalbutton;260 var closeBtn = this.closebutton;261 if (iconElem) {262 iconElem.destroy();263 this._icon_elem = null;264 }265 if (textElem) {266 textElem.destroy();267 this._text_elem = null;268 }269 if (minBtn) {270 minBtn.destroy();271 this.minbutton = null;272 }273 if (maxBtn) {274 maxBtn.destroy();275 this.maxbutton = null;276 }277 if (normalBtn) {278 normalBtn.destroy();279 this.normalbutton = null;280 }281 if (closeBtn) {282 closeBtn.destroy();283 this.closebutton = null;284 }285 };286 _pTitleBar.on_change_containerRect = function (width, height) {287 this._updateControlPosition(width, height);288 };289 _pTitleBar.set_titletext = function (v) {290 this._titletext = v;291 if (this._text_elem) {292 this._text_elem.setElementText(v);293 }294 };295 _pTitleBar.on_minbutton_click = function (obj, e) {296 var ownerframe = this.getOwnerFrame();297 if (ownerframe) {298 ownerframe.on_minbutton_click(obj, e);299 }300 };301 _pTitleBar.on_maxbutton_click = function (obj, e) {302 var ownerframe = this.getOwnerFrame();303 if (ownerframe) {304 ownerframe.on_maxbutton_click(obj, e);305 }306 };307 _pTitleBar.on_normalbutton_click = function (obj, e) {308 var ownerframe = this.getOwnerFrame();309 if (ownerframe) {310 ownerframe.on_normalbutton_click(obj, e);311 }312 };313 _pTitleBar.on_closebutton_click = function (obj, e) {314 var ownerframe = this.getOwnerFrame();315 if (ownerframe) {316 ownerframe.on_closebutton_click(obj, e);317 }318 };319 _pTitleBar._on_starttrack = function () {320 if (!this._is_alive) {321 return;322 }323 var ownerframe = this.getOwnerFrame();324 if (ownerframe) {325 ownerframe._on_titlebar_starttrack();326 }327 };328 _pTitleBar._on_endtrack = function (x, y, dragdata) {329 if (!this._is_alive) {330 return;331 }332 var ownerframe = this.getOwnerFrame();333 if (ownerframe) {334 ownerframe._on_titlebar_endtrack(x, y, dragdata);335 }336 };337 _pTitleBar._on_movetrack = function (x, y, dragdata) {338 if (!this._is_alive) {339 return;340 }341 var ownerframe = this.getOwnerFrame();342 if (ownerframe) {343 ownerframe._on_titlebar_movetrack(x, y, dragdata);344 }345 };346 _pTitleBar._on_loadicon = function (url, w, h) {347 if ((w < 1) || (h < 1)) {348 return;349 }350 this._iconwidth = w;351 this._iconheight = h;352 if (this._icon_elem) {353 this._updateControlPosition(this._client_width, this._client_height);354 }355 var frame = this.parent;356 if (frame && frame._is_window) {357 var _window = frame._getWindow();358 if (_window) {359 nexacro._setWindowHandleIcon(_window._handle, url);360 }361 }362 };363 _pTitleBar._updateControlPosition = function (width, height) {364 if (!width || !height) {365 width = this._client_width;366 height = this._client_height;367 }368 var iconleftgap = 10;369 var iconrightgap = 6;370 var buttonwidth = 22;371 var buttonheight = 20;372 var buttongap = 1;373 var rightgap = 2;374 var display_as_minimize = ((this._state_openstatus == 2) || this._is_verticalmin);375 if (!this._is_verticalmin) {376 var itemsize = 24;377 var top = ((height - buttonheight) / 2) | 0;378 if (top < 0) {379 top = 0;380 }381 var curleft = width - (rightgap);382 curleft -= buttonwidth;383 this.closebutton.move(curleft, top, buttonwidth, buttonheight);384 curleft -= buttongap;385 curleft -= buttonwidth;386 this.maxbutton.move(curleft, top, buttonwidth, buttonheight);387 if (!display_as_minimize) {388 this.normalbutton.move(curleft, top, buttonwidth, buttonheight);389 }390 curleft -= buttongap;391 curleft -= buttonwidth;392 this.minbutton.move(curleft, top, buttonwidth, buttonheight);393 if (display_as_minimize) {394 this.normalbutton.move(curleft, top, buttonwidth, buttonheight);395 }396 var curright = curleft;397 curleft = iconleftgap;398 var iconElem = this._icon_elem;399 var iconwidth = this._iconwidth;400 var iconheight = this._iconheight;401 top = ((height - iconheight) / 2) | 0;402 var new_left = this._convertLeftForRtlLayout(curleft, iconwidth);403 iconElem.setElementPosition(new_left, top);404 iconElem.setElementSize(iconwidth, iconheight);405 curleft += iconwidth;406 curleft += iconrightgap;407 var textwidth = (curright - curleft);408 if (textwidth < 0) {409 textwidth = 0;410 }411 var textheight = itemsize;412 top = ((height - textheight) / 2) | 0;413 new_left = this._convertLeftForRtlLayout(curleft, textwidth);414 this._text_elem.setElementPosition(new_left, top);415 this._text_elem.setElementSize(textwidth, textheight);416 }417 else {418 var itemsize = 24;419 var left = ((width - buttonwidth) / 2) | 0;420 if (left < 0) {421 left = 0;422 }423 var curtop = height - (rightgap);424 curtop -= buttonwidth;425 this.closebutton.move(left, curtop, buttonwidth, buttonheight);426 curtop -= buttongap;427 curtop -= buttonwidth;428 this.maxbutton.move(left, curtop, buttonwidth, buttonheight);429 if (!display_as_minimize) {430 this.normalbutton.move(left, curtop, buttonwidth, buttonheight);431 }432 curtop -= buttongap;433 curtop -= buttonwidth;434 this.minbutton.move(left, curtop, buttonwidth, buttonheight);435 if (display_as_minimize) {436 this.normalbutton.move(left, curtop, buttonwidth, buttonheight);437 }438 var curbottom = curtop;439 curtop = iconleftgap;440 var iconElem = this._icon_elem;441 var iconwidth = this._iconwidth;442 var iconheight = this._iconheight;443 left = ((width - iconwidth) / 2) | 0;444 var new_left = this._convertLeftForRtlLayout(left, iconwidth);445 iconElem.setElementPosition(new_left, curtop);446 iconElem.setElementSize(iconwidth, iconheight);447 curtop += iconwidth;448 curtop += iconrightgap;449 var textwidth = (curbottom - curtop);450 if (textwidth < 0) {451 textwidth = 0;452 }453 var textheight = itemsize;454 left = ((width - textheight) / 2) | 0;455 new_left = this._convertLeftForRtlLayout(left, textwidth);456 this._text_elem.setElementPosition(new_left, curtop);457 this._text_elem.setElementSize(textwidth, textheight);458 }459 };460 _pTitleBar._change_state_OpenStatus = function (cur) {461 var pre = this._prestate_openstatus = this._state_openstatus;462 this._state_openstatus = cur;463 if (this._is_verticalmin) {464 cur = 2;465 }466 if (pre != cur) {467 switch (cur) {468 case 0:469 if ((this._absolute_style & 0x0001) == 0) {470 this.minbutton.set_visible(true);471 }472 if ((this._absolute_style & 0x0002) == 0) {473 this.maxbutton.set_visible(true);474 }475 if ((this._absolute_style & 0x0008) == 0) {476 this.closebutton.set_visible(true);477 }478 this.normalbutton.set_visible(false);479 break;480 case 1:481 break;482 case 2:483 this.minbutton.set_visible(false);484 if ((this._absolute_style & 0x0002) == 0) {485 this.maxbutton.set_visible(true);486 }487 if ((this._absolute_style & 0x0008) == 0) {488 this.closebutton.set_visible(true);489 }490 if ((this._absolute_style & 0x0004) == 0) {491 this.normalbutton.set_visible(true);492 }493 break;494 case 3:495 if ((this._absolute_style & 0x0001) == 0) {496 this.minbutton.set_visible(true);497 }498 this.maxbutton.set_visible(false);499 if ((this._absolute_style & 0x0008) == 0) {500 this.closebutton.set_visible(true);501 }502 if ((this._absolute_style & 0x0004) == 0) {503 this.normalbutton.set_visible(true);504 }505 break;506 }507 var control_elem = this.getElement();508 if (control_elem) {509 this.on_change_containerRect(control_elem.client_width, control_elem.client_height);510 }511 }512 };513 _pTitleBar._setVerticalMin = function (v) {514 if (this._is_verticalmin == v) {515 return;516 }517 var pre = -1;518 if (v == false) {519 pre = 2;520 }521 this._is_verticalmin = v;522 var real_openstatus = this._state_openstatus;523 if (pre != (-1)) {524 this._state_openstatus = pre;525 }526 this._change_state_OpenStatus(real_openstatus);527 if (this._control_element) {528 this._updateControlPosition();529 }530 };531 _pTitleBar._setDragMove = function (v, is_windowframe) {532 if (v && is_windowframe) {533 this._hittest_type = "caption";534 }535 else {536 this._hittest_type = "none";537 }538 if (this._control_element) {539 this._control_element.setElementHittestType(this._hittest_type);540 }541 };542 _pTitleBar._setAbsoluteStyle = function (_add, _remove, _apply) {543 this._absolute_style &= ~(_remove);544 this._absolute_style |= _add;545 if (_apply == undefined || _apply == true) {546 this._applyAbsoluteStyle();547 }548 };549 _pTitleBar.on_apply_prop_enable = function (v) {550 nexacro.Component.prototype.on_apply_prop_enable.call(this, v);551 if (this.minbutton && !((this._absolute_style & 0x0010) > 0)) {552 this.minbutton._setEnable(v);553 }554 };555 _pTitleBar._applyAbsoluteStyle = function () {556 if (this.minbutton) {557 if ((this._absolute_style & 0x0001) > 0) {558 this.minbutton.set_visible(false);559 }560 else if ((this._absolute_style & 0x0100) > 0) {561 this.minbutton.set_visible(true);562 }563 if ((this._absolute_style & 0x0010) > 0) {564 this.minbutton.set_enable(false);565 }566 else if ((this._absolute_style & 0x1000) > 0) {567 this.minbutton.set_enable(true);568 }569 }570 if (this.maxbutton) {571 if ((this._absolute_style & 0x0002) > 0) {572 this.maxbutton.set_visible(false);573 }574 else if ((this._absolute_style & 0x0200) > 0) {575 this.maxbutton.set_visible(true);576 }577 if ((this._absolute_style & 0x0020) > 0) {578 this.maxbutton.set_enable(false);579 }580 else if ((this._absolute_style & 0x2000) > 0) {581 this.maxbutton.set_enable(true);582 }583 }584 if (this.normalbutton) {585 if ((this._absolute_style & 0x0004) > 0) {586 this.normalbutton.set_visible(false);587 }588 else if ((this._absolute_style & 0x0400) > 0) {589 this.normalbutton.set_visible(true);590 }591 if ((this._absolute_style & 0x0040) > 0) {592 this.normalbutton.set_enable(false);593 }594 else if ((this._absolute_style & 0x4000) > 0) {595 this.normalbutton.set_enable(true);596 }597 }598 if (this.closebutton) {599 if ((this._absolute_style & 0x0008) > 0) {600 this.closebutton.set_visible(false);601 }602 else if ((this._absolute_style & 0x08) > 0) {603 this.closebutton.set_visible(true);604 }605 if ((this._absolute_style & 0x0080) > 0) {606 this.closebutton.set_enable(false);607 }608 else if ((this._absolute_style & 0x8000) > 0) {609 this.closebutton.set_enable(true);610 }611 }612 };613 _pTitleBar.on_apply_prop_rtldirection = function () {614 nexacro.Component.prototype.on_apply_prop_rtldirection.call(this);615 var _rtldirection = this._rtldirection;616 var control_element = this._control_element;617 if (control_element) {618 this._updateControlPosition(control_element.client_width, control_element.client_height);619 var pseudo = this._pseudo;620 var align = this.on_find_CurrentStyle_align(pseudo);621 this.on_apply_style_align(align);622 }623 if (this.minbutton) {624 this.minbutton._setRtlDirection(_rtldirection);625 }626 if (this.maxbutton) {627 this.maxbutton._setRtlDirection(_rtldirection);628 }629 if (this.normalbutton) {630 this.normalbutton._setRtlDirection(_rtldirection);631 }632 if (this.closebutton) {633 this.closebutton._setRtlDirection(_rtldirection);634 }635 };636 delete _pTitleBar;637 nexacro.TitleBarCtrl = function (id, position, left, top, width, height, right, bottom, parent) {638 nexacro.TitleBar.call(this, id, position, left, top, width, height, right, bottom, parent);639 this._is_subcontrol = true;640 };641 var _pTitleBarCtrl = nexacro._createPrototype(nexacro.TitleBar, nexacro.TitleBarCtrl);642 nexacro.TitleBarCtrl.prototype = _pTitleBarCtrl;643 _pTitleBarCtrl._type_name = "TitleBarControl";644 nexacro._setForTypedControlStyleFinder(_pTitleBarCtrl);645 delete _pTitleBarCtrl;...
StatusBar.js
Source:StatusBar.js
1//==============================================================================2//3// TOBESOFT Co., Ltd.4// Copyright 2017 TOBESOFT Co., Ltd.5// All Rights Reserved.6//7// NOTICE: TOBESOFT permits you to use, modify, and distribute this file 8// in accordance with the terms of the license agreement accompanying it.9//10// Readme URL: http://www.nexacro.co.kr/legal/nexacro17-public-license-readme-1.1.html11//12//==============================================================================13if (!nexacro.StatusBarControl) {14 nexacro.StatusBarControl = function (id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent) {15 nexacro.Form.call(this, id, left, top, width, height, right, bottom, minwidth, maxwidth, minheight, maxheight, parent);16 };17 var _pStatusBarControl = nexacro._createPrototype(nexacro.Form, nexacro.StatusBarControl);18 nexacro.StatusBarControl.prototype = _pStatusBarControl;19 _pStatusBarControl._type_name = "StatusBarControl";20 _pStatusBarControl.statustext = null;21 _pStatusBarControl.progressbar = null;22 _pStatusBarControl.resizegrip = null;23 _pStatusBarControl.resizable = false;24 _pStatusBarControl.progressbardirection = "forward";25 _pStatusBarControl.progressbargap = undefined;26 _pStatusBarControl.progressbarsize = undefined;27 _pStatusBarControl._progressbargap = 1;28 _pStatusBarControl._progressbarsize = 200;29 _pStatusBarControl.progressbarsmooth = false;30 _pStatusBarControl._is_nc_control = true;31 _pStatusBarControl._is_scrollable = false;32 _pStatusBarControl._is_subcontrol = true;33 nexacro.StatusBarControl._default_progressbarwidth = 200;34 nexacro.StatusBarControl._default_progressbarheight = 19;35 nexacro.StatusBarControl._default_progressbargap = 1;36 _pStatusBarControl.set_progressbarsize = function (val) {37 if (this.progressbarsize != val) {38 this.progressbarsize = val;39 this._progressbarsize = parseInt(val);40 if (this._progressbarsize < 0) {41 this._progressbarsize = 0;42 }43 this.on_apply_progressbar();44 }45 };46 _pStatusBarControl.set_progressbargap = function (val) {47 if (this.progressbargap != val) {48 this.progressbargap = val;49 this._progressbargap = parseInt(val);50 if (this._progressbargap < 0) {51 this._progressbargap = 0;52 }53 this.on_apply_progressbar();54 }55 };56 _pStatusBarControl.on_apply_progressbar = function () {57 var progressbar = this.progressbar;58 if (progressbar && progressbar.visible && this._is_created) {59 this._recalcLayout(this._getClientWidth(), this._getClientHeight());60 }61 };62 _pStatusBarControl.set_progressbardirection = function (val) {63 if (this.progressbardirection != val) {64 this.progressbardirection = val;65 this.on_apply_progressbardirection(val);66 }67 };68 _pStatusBarControl.on_apply_progressbardirection = function (v) {69 var progressbar = this.progressbar;70 if (progressbar) {71 progressbar.set_direction(v);72 }73 };74 _pStatusBarControl.set_progressbarsmooth = function (val) {75 if (this.progressbarsmooth != val) {76 this.progressbarsmooth = val;77 this.on_apply_progressbarsmooth(val);78 }79 };80 _pStatusBarControl.on_apply_progressbarsmooth = function (v) {81 var progressbar = this.progressbar;82 if (progressbar) {83 progressbar.set_smooth(v);84 }85 };86 _pStatusBarControl.set_resizable = function (val) {87 val = nexacro._toBoolean(val);88 if (this.resizable != val) {89 this.resizable = val;90 this.on_apply_resizable(val);91 }92 };93 _pStatusBarControl._createResizeGrip = function () {94 var resizegrip = this.resizegrip = new nexacro._Icon("resizegrip", 0, 0, 0, 0, null, null, null, null, null, null, this);95 resizegrip._on_starttrack = this._on_starttrack;96 resizegrip._on_movetrack = this._on_movetrack;97 resizegrip._on_endtrack = this._on_endtrack;98 resizegrip._setControl();99 resizegrip.createComponent();100 return resizegrip;101 };102 _pStatusBarControl.on_apply_resizable = function (resizable) {103 var resizegrip = this.resizegrip;104 var ownerframe = this.getOwnerFrame();105 if (this._is_created && resizable && !resizegrip) {106 resizegrip = this._createResizeGrip();107 resizegrip.on_created(this._getWindow());108 }109 if (ownerframe && resizegrip) {110 resizegrip._is_track = resizable;111 resizegrip.set_cursor(resizable ? "se-resize" : "arrow");112 var resizegrip_controlelem = resizegrip.getElement();113 if (resizegrip_controlelem) {114 resizegrip_controlelem.setElementHittestType(resizable && ownerframe._is_window ? "resizingborder_bottomright" : undefined);115 }116 }117 this._recalcLayout(this._getClientWidth(), this._getClientHeight());118 };119 _pStatusBarControl.on_create_contents = function () {120 var control_elem = this.getElement();121 if (control_elem) {122 var statustext = this.statustext = new nexacro.Static("statustext", 0, 0, 0, 0, null, null, null, null, null, null, this);123 statustext._setControl();124 if (this._displaytext) {125 statustext.set_text(this._displaytext);126 }127 statustext.createComponent();128 var progressbar = this.progressbar = new nexacro.ProgressBar("progressbar", 0, 0, 0, 0, null, null, null, null, null, null, this);129 progressbar._setControl();130 progressbar.createComponent();131 this._createResizeGrip();132 }133 };134 _pStatusBarControl.on_created_contents = function (win) {135 this.on_apply_resizable(this.resizable);136 this.statustext.on_created(win);137 this.progressbar.on_created(win);138 this.resizegrip.on_created(win);139 };140 _pStatusBarControl.on_destroy_contents = function (callremovechild) {141 var statustext = this.statustext;142 var progressbar = this.progressbar;143 var resizegrip = this.resizegrip;144 if (statustext) {145 statustext.destroy(callremovechild);146 this.statustext = null;147 }148 if (progressbar) {149 progressbar.destroy(callremovechild);150 this.progressbar = null;151 }152 if (resizegrip) {153 resizegrip.destroy(callremovechild);154 this.resizegrip = null;155 }156 };157 _pStatusBarControl.on_change_containerRect = function (width, height) {158 if (this._is_created_contents) {159 nexacro.Form.prototype.on_change_containerRect.call(this, width, height);160 this._recalcLayout(width, height);161 }162 };163 _pStatusBarControl.on_apply_text = function (text) {164 if (this.statustext) {165 this.statustext.set_text(text);166 }167 };168 _pStatusBarControl._on_load_resizegripicon = function () {169 };170 _pStatusBarControl._recalcLayout = function (width, height) {171 var left = width;172 var top = this._getClientTop();173 var resizegrip = this.resizegrip;174 if (resizegrip) {175 var resizegripwidth = 0;176 if (this.resizable) {177 var padding = resizegrip._getCurrentStylePadding();178 var border = resizegrip._getCurrentStyleBorder();179 var icon = resizegrip.icon ? resizegrip.icon : resizegrip._getCSSStyleValue("icon");180 if (border) {181 resizegripwidth = border._getBorderWidth();182 }183 if (padding) {184 resizegripwidth += padding.left + padding.right;185 }186 if (icon) {187 var iconsize = nexacro._getImageSize(icon.value, this._on_load_resizegripicon, this);188 if (iconsize) {189 resizegripwidth += iconsize.width;190 }191 }192 left = width - resizegripwidth;193 }194 resizegrip.move(left, top, resizegripwidth, height);195 }196 var progressbar = this.progressbar;197 if (progressbar) {198 var progressbarwidth = this._progressbarsize;199 left -= (this._progressbargap + progressbarwidth);200 progressbar.move(left, top, progressbarwidth, height);201 }202 var statustext = this.statustext;203 if (statustext) {204 statustext.move(this._getClientLeft(), top, left, height);205 }206 };207 _pStatusBarControl._on_starttrack = function () {208 var ownerframe = this.parent.getOwnerFrame();209 ownerframe._on_border_starttrack(this.cursor);210 };211 _pStatusBarControl._on_endtrack = function (x, y, dragdata) {212 var ownerframe = this.parent.getOwnerFrame();213 ownerframe._on_border_endtrack(x, y, dragdata);214 };215 _pStatusBarControl._on_movetrack = function (x, y, dragdata) {216 var ownerframe = this.parent.getOwnerFrame();217 ownerframe._on_border_movetrack(x, y, dragdata);218 };219 delete _pStatusBarControl;...
findRangeIterator.js
Source:findRangeIterator.js
1var EXPORTED_SYMBOLS = ['FindRangeIterator'];2var TEST = false;3var Cc = Components.classes;4var Ci = Components.interfaces;5var Cu = Components.utils;6Cu.import('resource://gre/modules/Services.jsm');7 8Cu.import('resource://xulmigemo-modules/constants.jsm');9Cu.import('resource://xulmigemo-modules/core/docUtils.js');10Cu.import('resource://xulmigemo-modules/log.jsm');11function log(...aArgs) { MigemoLog('findRangeIterator', ...aArgs); }12function FindRangeIterator(aRootDocShell, aStartPoint, aBackward, aTraverseFrames)13{14 log('new FindRangeIterator');15 this.backward = aBackward;16 this.traverseFrames = aTraverseFrames;17 this.mRootDocShell = aRootDocShell;18 if (aStartPoint) {19 this.mStartPoint = aStartPoint.cloneRange();20 this.mStartPoint.collapse(!this.backward);21 }22 else {23 let doc = MigemoDocumentUtils.getDocumentFromDocShell(aRootDocShell);24 this.mStartPoint = this.createAnchorInDocument(doc);25 }26 this.mAnchor = this.mStartPoint.cloneRange();27 log(' mStartPoint = '+this.mStartPoint.startContainer+'/'+this.mStartPoint.startOffset);28 this.wrappedCount = 0;29}30FindRangeIterator.prototype = {31 mRootDocShell : null,32 backward : false,33 wrapped : false,34 looped : false,35 36 get document()37 {38 return MigemoDocumentUtils.getOwnerDocumentFromRange(this.mAnchor);39 },40 get view()41 {42 return this.document.defaultView;43 },44 get docShell()45 {46 return MigemoDocumentUtils.getDocShellFromDocument(this.document);47 },48 get body() 49 {50 return MigemoDocumentUtils.getDocumentBody(this.document);51 },52 getWholeFindRangeFromRangeInEditable : function(aRange) 53 {54 var owner = MigemoDocumentUtils.getParentEditableFromRange(aRange);55 if (!owner)56 return null;57 var lastContainer = aRange.startContainer;58 while (lastContainer.parentNode != owner)59 {60 lastContainer = lastContainer.parentNode;61 }62 var range = lastContainer.ownerDocument.createRange();63 range.selectNodeContents(lastContainer);64 return range;65 },66 createAnchorInDocument : function(aDocument)67 {68 let point = aDocument.createRange();69 point.selectNodeContents(MigemoDocumentUtils.getDocumentBody(aDocument));70 point.collapse(!this.backward);71 return point;72 },73 74 iterateNext : function() 75 {76 log('iterateNext');77 if (this.looped)78 return {};79 this.wrapped = false;80 var doc = this.document;81 var editableRange = this.getWholeFindRangeFromRangeInEditable(this.mAnchor);82 if (this.backward) {83 if (this.mWillWrapBackward) {84 this.wrapped = true;85 this.wrappedCount++;86 this.mWillWrapBackward = false;87 log('backward: wrapped');88 }89 if (editableRange) {90 log('backward: move into editable range');91 editableRange.setEnd(this.mAnchor.startContainer, this.mAnchor.startOffset);92 let editable = MigemoDocumentUtils.getParentEditableFromRange(this.mAnchor);93 this.mAnchor = doc.createRange();94 this.mAnchor.selectNode(editable);95 this.mAnchor.collapse(true);96 this.checkLoop(editableRange);97 return this.createRangeSet(editableRange);98 }99 if (this.traverseFrames) {100 let previousFrame = MigemoDocumentUtils.getPreviousFrame(doc, this.mAnchor);101 log('backward: traverse frames, previousFrame = '+previousFrame);102 if (previousFrame) {103 let range = this.mAnchor.cloneRange();104 range.setStartBefore(previousFrame);105 this.mAnchor = this.createAnchorInDocument(previousFrame.contentDocument);106 this.checkLoop(range);107 return this.createRangeSet(range);108 }109 }110 let root = MigemoDocumentUtils.getDocumentBody(doc);111 let range = this.mAnchor.cloneRange();112 range.setStartBefore(root.firstChild || root);113 if (this.traverseFrames) {114 let ownerFrame = MigemoDocumentUtils.getOwnerFrameFromContentDocument(doc);115 log('backward: traverse frames, ownerFrame = '+ownerFrame);116 if (ownerFrame) {117 this.mAnchor = ownerFrame.ownerDocument.createRange();118 this.mAnchor.selectNode(ownerFrame);119 this.mAnchor.collapse(true);120 this.checkLoop(range);121 return this.createRangeSet(range);122 }123 }124 log('backward: select to first');125 doc = MigemoDocumentUtils.getDocumentFromDocShell(this.mRootDocShell);126 this.mAnchor = this.createAnchorInDocument(doc);127 this.mWillWrapBackward = true;128 this.checkLoop(range);129 return this.createRangeSet(range);130 }131 else {132 if (this.mWillWrapForward) {133 this.wrapped = true;134 this.wrappedCount++;135 this.mWillWrapForward = false;136 log('forward: wrapped');137 }138 if (editableRange) {139 log('forward: move into editable range');140 editableRange.setStart(this.mAnchor.endContainer, this.mAnchor.endOffset);141 let editable = MigemoDocumentUtils.getParentEditableFromRange(this.mAnchor);142 this.mAnchor = doc.createRange();143 this.mAnchor.selectNode(editable);144 this.mAnchor.collapse(false);145 this.checkLoop(editableRange);146 return this.createRangeSet(editableRange);147 }148 if (this.traverseFrames) {149 let nextFrame = MigemoDocumentUtils.getNextFrame(doc, this.mAnchor);150 log('forward: traverse frames, nextFrame = '+nextFrame);151 if (nextFrame) {152 let range = this.mAnchor.cloneRange();153 range.setEndBefore(nextFrame);154 log(' range => '+range.toString()+'('+range.toString().length+')');155 this.mAnchor = this.createAnchorInDocument(nextFrame.contentDocument);156 this.checkLoop(range);157 return this.createRangeSet(range);158 }159 }160 let root = MigemoDocumentUtils.getDocumentBody(doc);161 let range = this.mAnchor.cloneRange();162 range.setEndAfter(root.lastChild || root);163 if (this.traverseFrames) {164 let ownerFrame = MigemoDocumentUtils.getOwnerFrameFromContentDocument(doc);165 log('forward: traverse frames, ownerFrame = '+ownerFrame);166 if (ownerFrame) {167 this.mAnchor = ownerFrame.ownerDocument.createRange();168 this.mAnchor.selectNode(ownerFrame);169 this.mAnchor.collapse(false);170 this.checkLoop(range);171 return this.createRangeSet(range);172 }173 }174 log('forward: select to last');175 doc = MigemoDocumentUtils.getDocumentFromDocShell(this.mRootDocShell);176 this.mAnchor = this.createAnchorInDocument(doc);177 this.mWillWrapForward = true;178 this.checkLoop(range);179 return this.createRangeSet(range);180 }181 },182 createRangeSet : function(aFindRange)183 {184 var rangeSet = {185 range : aFindRange,186 start : aFindRange.cloneRange(),187 end : aFindRange.cloneRange()188 };189 rangeSet.start.collapse(!this.backward);190 rangeSet.end.collapse(this.backward);191 rangeSet.doc = MigemoDocumentUtils.getOwnerDocumentFromRange(aFindRange);192 if (Services.prefs.getBoolPref(MigemoConstants.BASE+'debug.findRangeIterator.markers'))193 MigemoDocumentUtils.insertMarkers('iteration', rangeSet);194 return rangeSet;195 },196 checkLoop : function(aNextFindRange)197 {198 if (this.looped ||199 this.wrappedCount === 0)200 return;201 var startDoc = MigemoDocumentUtils.getOwnerDocumentFromRange(this.mStartPoint);202 var anchorDoc = MigemoDocumentUtils.getOwnerDocumentFromRange(this.mAnchor);203 var anchorPassed = false;204 if (startDoc == anchorDoc) {205 if (this.backward) {206 anchorPassed = this.mAnchor.compareBoundaryPoints(this.mAnchor.START_TO_END, this.mStartPoint) <= 0;207 }208 else {209 anchorPassed = this.mAnchor.compareBoundaryPoints(this.mAnchor.END_TO_START, this.mStartPoint) >= 0;210 }211 }212 var findDoc = MigemoDocumentUtils.getOwnerDocumentFromRange(aNextFindRange);213 var findRangePassed = (214 (startDoc == findDoc) &&215 (216 aNextFindRange.compareBoundaryPoints(aNextFindRange.START_TO_START, this.mStartPoint) <= 0 &&217 aNextFindRange.compareBoundaryPoints(aNextFindRange.END_TO_END, this.mStartPoint) >= 0218 )219 );220 this.looped = anchorPassed || findRangePassed;221 },222 223 destroy : function() 224 {225 delete this.backward;226 delete this.mRootDocShell;227 delete this.mStartPoint;228 delete this.mAnchor;229 delete this.wrapped;230 }231 ...
Using AI Code Generation
1const ownerFrame = require('playwright/lib/internal/frames').ownerFrame;2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const frame = page.frames()[1];8 const frameElement = ownerFrame(frame)._elementHandle;9 await frameElement.click();10 await browser.close();11})();12const frameElement = frame._parentFrame._elementHandle;13const frameElement = page.frames()[0]._elementHandle;14const frameElement = page.mainFrame()._elementHandle;15const frameElement = page.mainFrame().childFrames()[0]._elementHandle;16const frameElement = page.mainFrame().childFrames()[0].childFrames()[0]._elementHandle;17const frameElement = page.mainFrame().childFrames()[0].childFrames()[0].childFrames()[0]._elementHandle;18const frameElement = page.mainFrame().childFrames()[0].childFrames()[0].childFrames()[0].childFrames()[0]._elementHandle;19const frameElement = page.mainFrame().childFrames()[0].child
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const element = await page.$('#search_input_react');7 const ownerFrame = await element.ownerFrame();8 console.log(ownerFrame);9 await page.screenshot({ path: `screenshot.png` });10 await browser.close();11})();12const { chromium } = require('playwright');13(async () => {14 const browser = await chromium.launch();15 const context = await browser.newContext();16 const page = await context.newPage();17 const element = await page.$('#search_input_react');18 const ownerFrame = await element.ownerFrame();19 console.log(ownerFrame);20 await page.screenshot({ path: `screenshot.png` });21 await browser.close();22})();
Using AI Code Generation
1const { ownerFrame } = require('@playwright/test/lib/server/frames');2const { test } = require('@playwright/test');3test('test', async ({ page }) => {4 const frame = await page.frames()[1];5 const owner = await ownerFrame(page, frame);6});
Using AI Code Generation
1const { ownerFrame } = require('playwright/lib/server/dom');2const { ownerFrame } = require('playwright/lib/server/dom');3const { chromium } = require('playwright');4(async () => {5 const browser = await chromium.launch({ headless: false });6 const page = await browser.newPage();7 const elementHandle = await page.$('a');8 const frame = ownerFrame(elementHandle);9 console.log(frame.url());10 await browser.close();11})();12const { ownerFrame } = require('playwright/lib/server/dom');13const { chromium } = require('playwright');14(async () => {15 const browser = await chromium.launch({ headless: false });16 const page = await browser.newPage();17 const frame = await page.evaluate((selector) => {18 const element = document.querySelector(selector);19 return ownerFrame(element);20 }, 'a');21 console.log(frame.url());22 await browser.close();23})();24const { ownerFrame } = require('playwright/lib/server/dom');25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch({ headless: false });28 const page = await browser.newPage();29 const frame = await page.frames()[0].evaluate((selector) => {30 const element = document.querySelector(selector);31 return ownerFrame(element);32 }, 'a');33 console.log(frame.url());34 await browser.close();35})();36const { ownerFrame } = require('playwright/lib/server/dom');37const { chromium } = require('playwright');38(async () => {39 const browser = await chromium.launch({ headless: false });
Using AI Code Generation
1const { ownerFrame } = require('playwright/lib/server/dom');2const { getFrameElement } = require('playwright/lib/server/dom');3const { getFrameElementHandle } = require('playwright/lib/server/dom');4const { chromium } = require('playwright');5(async () => {6 const browser = await chromium.launch();7 const context = await browser.newContext();8 const page = await context.newPage();9 const frame = page.frames()[1];10 const frameElement = ownerFrame(frame);11 console.log(frameElement);12 const frameElementHandle = await getFrameElementHandle(frame);13 console.log(frameElementHandle);14 const frameElement2 = await getFrameElement(frame);15 console.log(frameElement2);16 await browser.close();17})();
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!