How to use getParent method in Testcafe

Best JavaScript code snippet using testcafe

Personage.js

Source:Personage.js Github

copy

Full Screen

...19cc.Personage = cc.AnimatedEntity.extend({20 init: function(transfer, parent, callback) {21 this._super(s_Personage, 4, 5, parent, function(){});22 this.m_BroadcastTransfer = transfer;23 this.m_EngineParticles = cc.EntityManager.create(5, cc.EngineParticle.create(), this.getParent(), 23);24 this.m_Shadow = cc.Entity.create(s_Shadow);25 this.m_Shockwave = cc.Entity.create(s_PersonageShockwave, this.getParent());26 this.m_Shockwave.setZOrder(22);27 this.m_Shockwave.m_Power = 1;28 this.setCollideable(true);29 this.setIgnoreSorting(false);30 callback(this);31 if(Connection.isEnabled()) {32 this.m_LoginName = cc.Text.create(Connection._login, 16, this);33 }34 if(Connection.isEnabled() && this.m_BroadcastTransfer) {35 var p = this;36 setInterval(function() {37 Connection.send("update", {38 id: 12,39 session: Connection._sessionId,40 x: p.getCenterX(),41 y: p.getCenterY(),42 i: p.getCurrentFrameIndex(),43 h: p.m_Health44 });45 }, 500);46 }47 },48 reset: function() {49 this.create();50 51 if(this.m_BroadcastTransfer) {52 Connection.send("update", {53 id: 18,54 session: Connection._sessionId55 });56 }57 },58 onCreate: function() {59 this._super();60 this.setCenterPosition(CAMERA_CENTER_X, CAMERA_CENTER_Y - 150);61 this.setMaxHealth(100);62 this.setZOrder(24);63 this.m_CommandMove = [false, false, false, false, false];64 this.m_Speed = 100;65 this.m_Flying = false;66 this.m_AnimationTime = 0.1;67 this.m_AnimationTimeElapsed = 0;68 this.m_AnimationFrameSide = 0;69 this.m_AnimationFrameSideLast = 0;70 this.m_EngineParticlesAnimationTime = 0.3;71 this.m_EngineParticlesAnimationTimeElapsed = 0;72 this.m_EngineParticlesAnimationTime = 0.3;73 this.m_EngineParticlesAnimationTimeElapsed = 0;74 this.m_JetPackPower = 100;75 this.m_JetPackPowerFull = 100;76 this.m_SpacebarLastPushTime = 0;77 this.m_ShockwaveScale = 1.5;78 this.m_IsShouldFire = false;79 this.m_FireVectorX = 0;80 this.m_FireVectorY = 0;81 this.m_FirePower = 20;82 this.m_FireSpeed = 500;83 this.m_FireCount = 1;84 this.m_FireFrame = 0;85 this.m_HealthRegenerationTime = 1.0;86 this.m_HealthRegenerationTimeElapsed = 0;87 this.m_FireTime = 0.45;88 this.m_FireTimeElapsed = 0;89 this.m_ShootPadding = 0;90 this.setCurrentFrameIndex(8);91 },92 onDestroy: function() {93 if(!this.isVisible()) return;94 this._super();95 this.m_Shockwave.destroy();96 this._parent.m_Explosions[1].create();97 this._parent.m_Explosions[1].last().setCenterPosition(this.getCenterX(), this.getCenterY() + this._parent.m_Explosions[1].last().getHeight() / 2 - 30);98 this._parent.shake(1.0, 10.0);99 cc.AudioEngine.getInstance().playEffect(s_PersonageDestroy);100 if(Connection.isEnabled()) {101 if(this.m_BroadcastTransfer) {102 cc.Director.getInstance().pushScene(cc.TransitionFade.create(3.0, cc.GameOver.create()));103 }104 } else {105 cc.Director.getInstance().pushScene(cc.TransitionFade.create(3.0, cc.GameOver.create()));106 }107 },108 setFireCoordinates: function(x, y) {109 this.m_FireVectorX = x;110 this.m_FireVectorY = y;111 },112 move: function(deltaTime) {113 var x = this.getCenterX();114 var y = this.getCenterY();115 for(var i = 0; i < 4; i++) {116 if(!this.m_CommandMove[i]) continue;117 switch(i) {118 case 0:119 y += this.m_Speed * deltaTime;120 break;121 case 1:122 y -= this.m_Speed * deltaTime;123 break;124 case 2:125 x -= this.m_Speed * deltaTime;126 break;127 case 3:128 x += this.m_Speed * deltaTime;129 break;130 }131 }132 133 var pontencialFrame = this.getCurrentFrameIndex() - this.m_AnimationFrameSideLast;134 if(this.m_IsShouldFire) {135 var padding1 = 0;136 var padding2 = 50;137 var padding3 = 100;138 var fcx = this.m_FireVectorX + (CAMERA_CENTER_X - this.getCenterX());139 var fcy = -this.m_FireVectorY - (CAMERA_CENTER_Y - this.getCenterY());140 if(fcy > padding1)141 {142 pontencialFrame = 8;143 pontencialFrame += 4;144 if(Math.abs(fcx) > Math.abs(fcy)*2) {145 pontencialFrame -= 4;146 } else if(Math.abs(fcx) > Math.abs(fcy) * 0.75) {147 } else {148 pontencialFrame += 4;149 }150 }151 else if(fcy < padding1)152 {153 pontencialFrame = 8;154 pontencialFrame -= 4;155 if(Math.abs(fcx) > Math.abs(fcy)*2) {156 pontencialFrame += 4;157 } else if(Math.abs(fcx) > Math.abs(fcy) * 0.75) {158 } else {159 pontencialFrame -= 4;160 }161 }162 if(fcx < 0)163 {164 this.setScaleX(1);165 }166 else167 {168 this.setScaleX(-1);169 }170 } else {171 if(this.m_CommandMove[0])172 {173 pontencialFrame = 8;174 pontencialFrame -= 8;175 if(this.m_CommandMove[2] || this.m_CommandMove[3])176 {177 pontencialFrame += 4;178 }179 }180 else if(this.m_CommandMove[1])181 {182 pontencialFrame = 8;183 pontencialFrame += 8;184 if(this.m_CommandMove[2] || this.m_CommandMove[3])185 {186 pontencialFrame -= 4;187 }188 }189 if((this.m_CommandMove[2] || this.m_CommandMove[3]) && !this.m_CommandMove[0] && !this.m_CommandMove[1]) {190 pontencialFrame = 8;191 }192 if(x < this.getCenterX())193 {194 this.setScaleX(1);195 }196 else if(x > this.getCenterX())197 {198 this.setScaleX(-1);199 }200 }201 pontencialFrame += this.m_AnimationFrameSide;202 this.setCurrentFrameIndex(pontencialFrame);203 this.setCenterPosition(x, y);204 this.m_Shockwave.setCenterPosition(x, y - 15);205 this.m_Shadow.setCenterPosition(x, y - 15 - this.getZ());206 if(Connection.isEnabled()) {207 this.m_LoginName.setPosition(this.getWidth() / 2, this.getHeight() / 2 + this.getHeight());208 this.m_LoginName.setScaleX(this.getScaleX());209 }210 this.m_AnimationFrameSideLast = this.m_AnimationFrameSide;211 },212 startFly: function() {213 if(this.m_JetPackPower <= 0) return;214 if(this.getZ() > MIN_Z) return;215 this.m_EngineParticlesAnimationTime = 0.1;216 this.m_FlyDownSpeed = 0;217 this.m_Flying = true;218 cc.AudioEngine.getInstance().playEffect(s_PersonageFlying);219 },220 endFly: function() {221 this.m_EngineParticlesAnimationTime = 0.3;222 this.m_Flying = false;223 },224 damage: function() {225 if(this.getZ() < 10) return;226 //if(!Utils::isOnPizza(this)) return;227 this.endFly();228 this.m_FlyDownSpeed = 20;229 this.getParent().shake(0.8, 4.0);230 cc.AudioEngine.getInstance().playEffect(s_PersonageFlyingDamage);231 },232 update: function(deltaTime) {233 this._super(deltaTime);234 this.m_AnimationTimeElapsed += deltaTime;235 this.m_EngineParticlesAnimationTimeElapsed += deltaTime;236 // Simple animation237 if(this.m_AnimationTimeElapsed >= this.m_AnimationTime)238 {239 this.m_AnimationTimeElapsed = 0;240 if(this.m_AnimationFrameSide == 3) {241 this.m_AnimationFrameSide = 0;242 } else {243 this.m_AnimationFrameSide++;244 }245 }246 // Engine particles animation247 if(this.m_EngineParticlesAnimationTimeElapsed >= this.m_EngineParticlesAnimationTime)248 {249 this.m_EngineParticlesAnimationTimeElapsed = 0;250 //if(!this.mIsOutOfTop && !this.mFall)251 {252 this.m_EngineParticles.create();253 this.m_EngineParticles.last().setCenterPosition(this.getCenterX(), this.getCenterY() - 15);254 }255 }256 // Flying257 if(this.m_Flying) {258 this.addZ(120.0 * deltaTime);259 this.m_JetPackPower = this.m_JetPackPower > 0 ? this.m_JetPackPower - 50 * deltaTime : 0;260 if(this.m_JetPackPower <= 0) {261 this.endFly();262 }263 } else {264 if(this.getZ() > MIN_Z) {265 this.m_EngineParticlesAnimationTime = 1000;266 this.m_FlyDownSpeed += 10 * deltaTime;267 this.removeZ((this.m_FlyDownSpeed * 60) * deltaTime);268 } else {269 this.m_EngineParticlesAnimationTime = 0.3;270 this.m_Flying = false;271 this.m_JetPackPower = this.m_JetPackPower >= this.m_JetPackPowerFull ? this.m_JetPackPowerFull : this.m_JetPackPower + 20 * deltaTime;272 if(this.m_FlyDownSpeed >= 10.0)273 {274 this.m_Shockwave.setScale(0);275 this.m_Shockwave.create();276 this.m_Shockwave.runAction(cc.ScaleTo.create(0.2, this.m_ShockwaveScale));277 this.m_FlyDownSpeed = 0;278 this.m_ShockwaveTimeElapsed = 0;279 }280 }281 }282 // Health Regeneration283 if(this.m_Health < this.m_HealthFull) {284 this.m_HealthRegenerationTimeElapsed += deltaTime;285 if(this.m_HealthRegenerationTimeElapsed >= this.m_HealthRegenerationTime) {286 this.m_HealthRegenerationTimeElapsed = 0287 this.m_Health += 1;288 }289 }290 // Shockwave291 this.m_ShockwaveTimeElapsed += deltaTime;292 if(this.m_ShockwaveTimeElapsed >= 0.2 && this.m_Shockwave.isVisible()) {293 this.m_Shockwave.destroy();294 }295 // Fire Time296 if(this.m_IsShouldFire) {297 this.m_FireTimeElapsed += deltaTime;298 if(this.m_FireTimeElapsed >= this.m_FireTime) {299 this.m_FireTimeElapsed = 0;300 this.fire();301 }302 }303 if(this.m_ShootPadding > 0) {304 var vector = vectorNormalize(this.m_VectorX, this.m_VectorY, this.m_ShootPaddingSpeed * deltaTime);305 this.setCenterPosition(this.getCenterX() + vector[0], this.getCenterY() + vector[1]);306 this.m_ShootPadding -= this.m_ShootPaddingSpeed * deltaTime;307 } else {308 this.move(deltaTime);309 }310 },311 draw: function() {312 this._super();313 if(this.m_JetPackPower < this.m_JetPackPowerFull) {314 var x1;315 var x2;316 var y1;317 var y2;318 var rectangleVerticles1 = [];319 var rectangleVerticles2 = [];320 x1 = (this.getWidth() - this.m_BarWidth) / 2;321 x2 = this.getWidth() - x1 + 1 * 2;322 y1 = -5;323 y2 = y1 - this.m_BarHeight;324 if(this.m_Health < this.m_HealthFull) {325 y1 -= 6;326 y2 -= 6;327 }328 rectangleVerticles1[0] = cc.p(x1, y1);329 rectangleVerticles1[1] = cc.p(x2, y1);330 rectangleVerticles1[2] = cc.p(x2, y2);331 rectangleVerticles1[3] = cc.p(x1, y2);332 x1 = x1 + 1;333 x2 = x1 + (((x2 - x1) - 1) * (this.m_JetPackPower) / this.m_JetPackPowerFull);334 y1 = y1 - 1;335 y2 = y1 - this.m_BarHeight + 1 * 2;336 if(this.getScaleX() < 0)337 {338 var padding = this.m_BarWidth - this.m_BarWidth * (this.m_JetPackPower / this.m_JetPackPowerFull);339 x1 += padding;340 x2 += padding;341 }342 rectangleVerticles2[0] = cc.p(x1, y1);343 rectangleVerticles2[1] = cc.p(x2, y1);344 rectangleVerticles2[2] = cc.p(x2, y2);345 rectangleVerticles2[3] = cc.p(x1, y2);346 cc.drawingUtil.drawSolidPoly(rectangleVerticles1, 4, new cc.Color4F(0, 0, 0, 1));347 cc.drawingUtil.drawSolidPoly(rectangleVerticles2, 4, new cc.Color4F(0/ 255, 200 / 255, 255 / 255, 1));348 }349 },350 onKeyUp: function(e) {351 switch(e) {352 case cc.KEY.up:353 case cc.KEY.w:354 this.m_CommandMove[0] = false;355 break;356 case cc.KEY.down:357 case cc.KEY.s:358 this.m_CommandMove[1] = false;359 break;360 case cc.KEY.left:361 case cc.KEY.a:362 this.m_CommandMove[2] = false;363 break;364 case cc.KEY.right:365 case cc.KEY.d:366 this.m_CommandMove[3] = false;367 break;368 case cc.KEY.space:369 this.m_CommandMove[4] = false;370 this.endFly();371 break;372 }373 if(Connection.isEnabled() && this.m_BroadcastTransfer) {374 Connection.send("update", {375 id: 11,376 session: Connection._sessionId,377 e: e378 });379 }380 },381 onKeyDown: function(e) {382 switch(e) {383 case cc.KEY.up:384 case cc.KEY.w:385 this.m_CommandMove[0] = true;386 break;387 case cc.KEY.down:388 case cc.KEY.s:389 this.m_CommandMove[1] = true;390 break;391 case cc.KEY.left:392 case cc.KEY.a:393 this.m_CommandMove[2] = true;394 break;395 case cc.KEY.right:396 case cc.KEY.d:397 this.m_CommandMove[3] = true;398 break;399 case cc.KEY.space:400 if(this.m_CommandMove[4]) return;401 this.m_CommandMove[4] = true;402 if(new Date().getTime() - this.m_SpacebarLastPushTime < 300) {403 this.damage();404 } else {405 this.startFly();406 }407 this.m_SpacebarLastPushTime = new Date().getTime();408 break;409 }410 if(Connection.isEnabled() && this.m_BroadcastTransfer) {411 Connection.send("update", {412 id: 10,413 session: Connection._sessionId,414 e: e415 });416 }417 },418 onMouseDown: function(e) {419 this.m_IsShouldFire = true;420 if(Connection.isEnabled() && this.m_BroadcastTransfer) {421 Connection.send("update", {422 id: 13,423 session: Connection._sessionId,424 e: e425 });426 }427 },428 onMouseUp: function(e) {429 this.m_IsShouldFire = false;430 if(Connection.isEnabled() && this.m_BroadcastTransfer) {431 Connection.send("update", {432 id: 14,433 session: Connection._sessionId,434 e: e435 });436 }437 },438 onMouseMoved: function(e) {439 if(this.m_BroadcastTransfer) {440 var location = this.getParent().convertToNodeSpace(cc.p(e._point.x, e._point.y));441 } else {442 var location = cc.p(e.location_custom.x, e.location_custom.y);443 }444 this.setFireCoordinates((location.x - CAMERA_CENTER_X), (location.y - CAMERA_CENTER_Y));445 this.m_MouseX = e._point.x + this.getCenterX() - CAMERA_CENTER_X;446 this.m_MouseY = e._point.y + this.getCenterY() - CAMERA_CENTER_Y;447 if(this.m_BroadcastTransfer) {448 e.location_custom = cc.p(location.x, location.y);449 }450 if(Connection.isEnabled() && this.m_BroadcastTransfer) {451 Connection.send("update", {452 id: 15,453 session: Connection._sessionId,454 e: e455 });456 }457 },458 onMouseDragged: function(e) {459 if(this.m_BroadcastTransfer) {460 var location = this.getParent().convertToNodeSpace(cc.p(e._point.x, e._point.y));461 } else {462 var location = cc.p(e.location_custom.x, e.location_custom.y);463 }464 this.setFireCoordinates((location.x - CAMERA_CENTER_X), (location.y - CAMERA_CENTER_Y));465 this.m_MouseX = e._point.x + this.getCenterX() - CAMERA_CENTER_X;466 this.m_MouseY = e._point.y + this.getCenterY() - CAMERA_CENTER_Y;467 if(this.m_BroadcastTransfer) {468 e.location_custom = cc.p(location.x, location.y);469 }470 if(Connection.isEnabled() && this.m_BroadcastTransfer) {471 Connection.send("update", {472 id: 16,473 session: Connection._sessionId,474 e: e475 });476 }477 },478 fire: function(data) {479 if(Connection.isEnabled() && this.m_BroadcastTransfer) {480 Connection.send("update", {481 id: 17,482 session: Connection._sessionId483 });484 }485 if(!this.m_BroadcastTransfer && !data) {486 return;487 }488 if(this.m_FireCount == 1) {489 var x = this.m_FireVectorX + (CAMERA_CENTER_X - this.getCenterX());490 var y = -this.m_FireVectorY - (CAMERA_CENTER_Y - this.getCenterY());491 this.getParent().m_Bullets.create();492 this.getParent().m_Bullets.last().setCurrentFrameIndex(this.m_FireFrame);493 this.getParent().m_Bullets.last().setCoordinates(x, y, this.m_MouseX, this.m_MouseY);494 this.getParent().m_Bullets.last().setCenterPosition(this.getCenterX(), this.getCenterY());495 this.getParent().m_Bullets.last().by = "personage";496 this.getParent().m_Bullets.last().m_Power = this.m_FirePower;497 this.getParent().m_Bullets.last().m_Speed = this.m_FireSpeed;498 this.getParent().m_Bullets.last()._sessionId = this._sessionId;499 } else if(this.m_FireCount == 2) {500 var x = this.m_FireVectorX + (CAMERA_CENTER_X - this.getCenterX());501 var y = -this.m_FireVectorY - (CAMERA_CENTER_Y - this.getCenterY());502 this.getParent().m_Bullets.create();503 this.getParent().m_Bullets.last().setCurrentFrameIndex(this.m_FireFrame);504 this.getParent().m_Bullets.last().setCoordinates(x, y, this.m_MouseX, this.m_MouseY);505 this.getParent().m_Bullets.last().setCenterPosition(this.getCenterX(), this.getCenterY());506 this.getParent().m_Bullets.last().setCoordinatesPadding(10, 10);507 this.getParent().m_Bullets.last().by = "personage";508 this.getParent().m_Bullets.last().m_Power = this.m_FirePower;509 this.getParent().m_Bullets.last().m_Speed = this.m_FireSpeed;510 this.getParent().m_Bullets.last()._sessionId = this._sessionId;511 x = this.m_FireVectorX + (CAMERA_CENTER_X - this.getCenterX());512 y = -this.m_FireVectorY - (CAMERA_CENTER_Y - this.getCenterY());513 this.getParent().m_Bullets.create();514 this.getParent().m_Bullets.last().setCurrentFrameIndex(this.m_FireFrame);515 this.getParent().m_Bullets.last().setCoordinates(x, y, this.m_MouseX, this.m_MouseY);516 this.getParent().m_Bullets.last().setCenterPosition(this.getCenterX(), this.getCenterY());517 this.getParent().m_Bullets.last().setCoordinatesPadding(-10, -10);518 this.getParent().m_Bullets.last().by = "personage";519 this.getParent().m_Bullets.last().m_Power = this.m_FirePower;520 this.getParent().m_Bullets.last().m_Speed = this.m_FireSpeed;521 this.getParent().m_Bullets.last()._sessionId = this._sessionId;522 } else if(this.m_FireCount == 3) {523 var x = this.m_FireVectorX + (CAMERA_CENTER_X - this.getCenterX());524 var y = -this.m_FireVectorY - (CAMERA_CENTER_Y - this.getCenterY());525 this.getParent().m_Bullets.create();526 this.getParent().m_Bullets.last().setCurrentFrameIndex(this.m_FireFrame);527 this.getParent().m_Bullets.last().setCoordinates(x, y, this.m_MouseX, this.m_MouseY);528 this.getParent().m_Bullets.last().setCenterPosition(this.getCenterX(), this.getCenterY());529 this.getParent().m_Bullets.last().setCoordinatesPadding(10, 10);530 this.getParent().m_Bullets.last().by = "personage";531 this.getParent().m_Bullets.last().m_Power = this.m_FirePower;532 this.getParent().m_Bullets.last().m_Speed = this.m_FireSpeed;533 this.getParent().m_Bullets.last()._sessionId = this._sessionId;534 x = this.m_FireVectorX + (CAMERA_CENTER_X - this.getCenterX());535 y = -this.m_FireVectorY - (CAMERA_CENTER_Y - this.getCenterY());536 this.getParent().m_Bullets.create();537 this.getParent().m_Bullets.last().setCurrentFrameIndex(this.m_FireFrame);538 this.getParent().m_Bullets.last().setCoordinates(x, y, this.m_MouseX, this.m_MouseY);539 this.getParent().m_Bullets.last().setCenterPosition(this.getCenterX(), this.getCenterY());540 this.getParent().m_Bullets.last().setCoordinatesPadding(-10, -10);541 this.getParent().m_Bullets.last().by = "personage";542 this.getParent().m_Bullets.last().m_Power = this.m_FirePower;543 this.getParent().m_Bullets.last().m_Speed = this.m_FireSpeed;544 this.getParent().m_Bullets.last()._sessionId = this._sessionId;545 x = this.m_FireVectorX + (CAMERA_CENTER_X - this.getCenterX());546 y = -this.m_FireVectorY - (CAMERA_CENTER_Y - this.getCenterY());547 this.getParent().m_Bullets.create();548 this.getParent().m_Bullets.last().setCurrentFrameIndex(this.m_FireFrame);549 this.getParent().m_Bullets.last().setCoordinates(x, y, this.m_MouseX, this.m_MouseY);550 this.getParent().m_Bullets.last().setCenterPosition(this.getCenterX(), this.getCenterY());551 this.getParent().m_Bullets.last().by = "personage";552 this.getParent().m_Bullets.last().m_Power = this.m_FirePower;553 this.getParent().m_Bullets.last().m_Speed = this.m_FireSpeed;554 this.getParent().m_Bullets.last()._sessionId = this._sessionId;555 } else if(this.m_FireCount == 4) {556 var x = this.m_FireVectorX + (CAMERA_CENTER_X - this.getCenterX());557 var y = -this.m_FireVectorY - (CAMERA_CENTER_Y - this.getCenterY());558 this.getParent().m_Bullets.create();559 this.getParent().m_Bullets.last().setCurrentFrameIndex(this.m_FireFrame);560 this.getParent().m_Bullets.last().setCoordinates(x, y, this.m_MouseX, this.m_MouseY);561 this.getParent().m_Bullets.last().setCenterPosition(this.getCenterX(), this.getCenterY());562 this.getParent().m_Bullets.last().setCoordinatesPadding(10, 10);563 this.getParent().m_Bullets.last().by = "personage";564 this.getParent().m_Bullets.last().m_Power = this.m_FirePower;565 this.getParent().m_Bullets.last().m_Speed = this.m_FireSpeed;566 this.getParent().m_Bullets.last()._sessionId = this._sessionId;567 x = this.m_FireVectorX + (CAMERA_CENTER_X - this.getCenterX());568 y = -this.m_FireVectorY - (CAMERA_CENTER_Y - this.getCenterY());569 this.getParent().m_Bullets.create();570 this.getParent().m_Bullets.last().setCurrentFrameIndex(this.m_FireFrame);571 this.getParent().m_Bullets.last().setCoordinates(x, y, this.m_MouseX, this.m_MouseY);572 this.getParent().m_Bullets.last().setCenterPosition(this.getCenterX(), this.getCenterY());573 this.getParent().m_Bullets.last().setCoordinatesPadding(-10, -10);574 this.getParent().m_Bullets.last().by = "personage";575 this.getParent().m_Bullets.last().m_Power = this.m_FirePower;576 this.getParent().m_Bullets.last().m_Speed = this.m_FireSpeed;577 this.getParent().m_Bullets.last()._sessionId = this._sessionId;578 x = this.m_FireVectorX + (CAMERA_CENTER_X - this.getCenterX());579 y = -this.m_FireVectorY - (CAMERA_CENTER_Y - this.getCenterY());580 this.getParent().m_Bullets.create();581 this.getParent().m_Bullets.last().setCurrentFrameIndex(this.m_FireFrame);582 this.getParent().m_Bullets.last().setCoordinates(x, y, this.m_MouseX, this.m_MouseY);583 this.getParent().m_Bullets.last().setCenterPosition(this.getCenterX(), this.getCenterY());584 this.getParent().m_Bullets.last().setCoordinatesPadding(30, 30);585 this.getParent().m_Bullets.last().by = "personage";586 this.getParent().m_Bullets.last().m_Power = this.m_FirePower;587 this.getParent().m_Bullets.last().m_Speed = this.m_FireSpeed;588 this.getParent().m_Bullets.last()._sessionId = this._sessionId;589 x = this.m_FireVectorX + (CAMERA_CENTER_X - this.getCenterX());590 y = -this.m_FireVectorY - (CAMERA_CENTER_Y - this.getCenterY());591 this.getParent().m_Bullets.create();592 this.getParent().m_Bullets.last().setCurrentFrameIndex(this.m_FireFrame);593 this.getParent().m_Bullets.last().setCoordinates(x, y, this.m_MouseX, this.m_MouseY);594 this.getParent().m_Bullets.last().setCenterPosition(this.getCenterX(), this.getCenterY());595 this.getParent().m_Bullets.last().setCoordinatesPadding(-30, -30);596 this.getParent().m_Bullets.last().by = "personage";597 this.getParent().m_Bullets.last().m_Power = this.m_FirePower;598 this.getParent().m_Bullets.last().m_Speed = this.m_FireSpeed;599 this.getParent().m_Bullets.last()._sessionId = this._sessionId;600 }601 cc.AudioEngine.getInstance().playEffect(s_PersonageShoot[this.m_FireFrame]);602 },603 onCollide: function(object, description) {604 switch(description) {605 case "pickup":606 break;607 case "enemy":608 this._super();609 this.m_Health -= 0.5;610 break;611 case "bullet":612 this._super();613 this.m_VectorX = object.m_VectorX;...

Full Screen

Full Screen

b-combo.js

Source:b-combo.js Github

copy

Full Screen

...3 $$( ".b-combo__input-text" ).addEvents({4 5 //focus на поле ввода6 focus: function (){7 this.getParent('.b-combo__input').addClass('b-combo__input_current');8 9 // ïðîâåðêà íàëè÷èÿ òðåáóåìûõ ýëåìåíòîâ íà ñòðàíèöå10 if (!this.getNext('.b-combo__label')) return;11 12 this.getNext('.b-combo__label').set('text',this.get('value'));13 //this.getParent('.b-combo__input').getChildren('.b-combo__input-text').set('value','')14 15 //длина блока .b-combo__input16 var input_width = this.getParent('.b-combo__input').getProperty('class').match(/b-combo__input_width_(\d+)/gi);17 input_width=input_width[0].match(/\d+/gi);18 19 //максимальная длина блока .b-combo__input20 var input_max_width = this.getParent('.b-combo__input').getProperty('class').match(/b-combo__input_max-width_(\d+)/gi);21 input_max_width = input_max_width[0].match(/\d+/gi);22 23 if((parseInt(this.getNext('.b-combo__label').getStyle('width')))>input_width){24 if((parseInt(this.getNext('.b-combo__label').getStyle('width')))>input_max_width){25 this.getParent('.b-combo__input').setStyle('width',input_max_width+"px");26 }27 else{28 this.getParent('.b-combo__input').setStyle('width',parseInt(this.getNext('.b-combo__label').getStyle('width'))+5);29 }30 }31 32 },33 34 //набор текста с клавиатуры35 keyup: function() {36 // ïðîâåðêà íàëè÷èÿ òðåáóåìûõ ýëåìåíòîâ íà ñòðàíèöå37 if (!this.getNext('.b-combo__label')) return;38 39 this.getNext('.b-combo__label').set('text',this.get('value'));40 41 //длина блока .b-combo__input42 var input_width = this.getParent('.b-combo__input').getProperty('class').match(/b-combo__input_width_(\d+)/gi);43 input_width = input_width[0].match(/\d+/gi);44 45 //максимальная длина блока .b-combo__input46 var input_max_width = this.getParent('.b-combo__input').getProperty('class').match(/b-combo__input_max-width_(\d+)/gi);47 input_max_width = input_max_width[0].match(/\d+/gi);48 49 50 if(51 // проверяем длину label, и если он шире блока b-combo__input то увеличиваем его52 input_width<=(parseInt(this.getNext('.b-combo__label').getStyle('width')))&&((this.getNext('.b-combo__label').getStyle('width')).toInt())<input_max_width53 ){54 this.getParent('.b-combo__input').setStyle('width',this.getNext('.b-combo__label').getStyle('width').toInt());55 }56 //иначе, если label короче блока .b-combo__input устанавливаем ему его начальную ширину57 else if((((this.getNext('.b-combo__label').getStyle('width')).toInt())<=input_width)){58 this.getParent('.b-combo__input').setStyle('width',input_width);59 }60 },61 62 63 //потеря фокуса после набора в поле ввода64 blur: function() {65 this.getParent('.b-combo__input').removeClass('b-combo__input_current');66 // ïðîâåðêà íàëè÷èÿ òðåáóåìûõ ýëåìåíòîâ íà ñòðàíèöå67 if (!this.getParent('.b-combo__input').getChildren('.b-combo__input-text') || !this.getNext('.b-combo__label')) return;68 69 this.getParent('.b-combo__input').getChildren('.b-combo__input-text').set('value',this.getNext('.b-combo__label').get('text'));70 this.getNext('.b-combo__label').set('text',this.get('value'));71 72 var input_width = this.getParent('.b-combo__input').getProperty('class').match(/b-combo__input_width_(\d+)/gi);73 input_width=input_width[0].match(/\d+/gi);74 75 if((parseInt(this.getNext('.b-combo__label').getStyle('width')))<input_width){76 this.getParent('.b-combo__input').setStyle('width',input_width+'px');77 }78 }79 })80 81var spec //создаем переменную, в которой будем хранить текст выбранный при клике по левой колонке. требуется для сохранения в инпуте только левого значения (с левой колонки) при изменении правого (из правой колонки).82 // тогглер выпадающего окна и оверлея83 $$('.b-combo__arrow', '.b-combo__arrow-date', '.b-combo__arrow-user').addEvent('click',function(){84 // проверка высоты выпадающего окна (первая колонка) и если оно больше 300пх, то добавляем к нему скролл85 if(parseInt(this.getParent('.b-combo__input').getNext('.b-shadow').getElement('.b-combo__body').getStyle('height'))>300){this.getParent('.b-combo__input').getNext('.b-shadow').getElement('.b-combo__body').addClass('b-combo__body_overflow-x_yes');}86 87 if(this.getParent('.b-combo__input').getNext('.b-shadow').hasClass('b-shadow_hide')){88 this.getParent('.b-combo__input').addClass('b-combo__input_current');89 this.getParent('.b-combo__input').getElement('.b-combo__input-text').addClass('b-combo__input-text_color_a7').focus();90 this.getParent('.b-combo__input').getNext('.b-shadow').removeClass('b-shadow_hide');91 92 //добавляем оверлей93 var overlay=document.createElement('div');94 overlay.className='b-combo__overlay';95 this.getParent('.b-combo').grab(overlay, 'top');96 $$('.b-combo__overlay').addEvent('click',function(){97 //подсветка шрифта98 if(this.getParent('.b-combo').getChildren('.b-combo__input-text_color_a7')){99 this.getParent('.b-combo').getElement('.b-combo__input-text').removeClass('b-combo__input-text_color_a7');100 }101 102 //сохранение данных выбраных пунктов в окошке, если они введены в инпут103 if((this.getParent('.b-combo').getElement('.b-combo__item_active')&&(this.getParent('.b-combo').getElement('.b-combo__label').get('text')==''))){104 this.getParent('.b-combo').getElement('.b-combo__item_active').removeClass('b-combo__item_active');105 this.getParent('.b-combo').getElement('.b-layout__right').addClass('b-layout__right_hide');106 }107 this.getParent('.b-combo').getElement('.b-shadow').addClass('b-shadow_hide');108 this.dispose();109 });110 111 112 113 // динамика внутри выпадающего окошка, клик по левой колонке114 $$('.b-layout__left .b-combo__item-inner').addEvent('click',function(){115 116 if(this.getParent('.b-combo').getElement('.b-combo__input-text').hasClass('b-combo__input-text_color_a7')){117 this.getParent('.b-combo').getElement('.b-combo__input-text').removeClass('b-combo__input-text_color_a7');118 }119 //меняем значение в поле ввода при клике по пунктам меню120 this.getParent('.b-combo').getElement('.b-combo__input-text').setProperty('value', this.get('text')+' →');121 this.getParent('.b-combo').getElement('.b-combo__label').set('text', this.get('text')+' →');122 123 //заносим текст в переменную124 spec = this.getParent('.b-combo').getElement('.b-combo__label').get('text');125 // меняем длину поля ввода126 var input_width = this.getParent('.b-combo').getElement('.b-combo__input').getProperty('class').match(/b-combo__input_width_(\d+)/gi);127 input_width=input_width[0].match(/\d+/gi);128 //максимальная длина блока .b-combo__input129 var input_max_width = this.getParent('.b-combo').getElement('.b-combo__input').getProperty('class').match(/b-combo__input_max-width_(\d+)/gi);130 input_max_width = input_max_width[0].match(/\d+/gi);131 132 133 //увеличиваем поле134 if((parseInt(this.getParent('.b-combo').getElement('.b-combo__label').getStyle('width')))>input_width){135 // если длина больше, чем максимально допустимая для этого блока, то ставим максимально допустимую136 if(parseInt(this.getParent('.b-combo').getElement('.b-combo__label').getStyle('width'))>input_max_width){137 this.getParent('.b-combo').getElement('.b-combo__input').setStyle('width',input_max_width +'px');138 }139 else{140 this.getParent('.b-combo').getElement('.b-combo__input').setStyle('width',parseInt(this.getParent('.b-combo').getElement('.b-combo__label').getStyle('width'))+5);141 }142 }143 else{144 this.getParent('.b-combo').getElement('.b-combo__input').setStyle('width',input_width+'px');145 }146 147 148 // сама динамика149 this.getParent('.b-combo__list').getChildren('.b-combo__item').removeClass('b-combo__item_active');150 this.getParent('.b-combo__item').addClass('b-combo__item_active');151 this.getParent('.b-layout__table').getElement('.b-layout__right').removeClass('b-layout__right_hide');152 // проверка высоты выпадающего окна (вторая колонка) и если оно больше 300пх, то добавляем к нему скролл153 if(parseInt(this.getParent('.b-shadow').getElement('.b-combo__body').getStyle('height'))>300){this.getParent('.b-shadow').getElement('.b-combo__body').addClass('b-combo__body_overflow-x_yes');}154 155 })156 157 //обрабатываем клик по элементам правой колонки158 $$('.b-layout__right .b-combo__item-inner').addEvent('click',function(){159 160 //меняем правое значения в инпуте и label 161 this.getParent('.b-combo').getElement('.b-combo__input-text').setProperty('value',spec+' '+this.get('text'))162 this.getParent('.b-combo').getElement('.b-combo__label').setProperty('text',spec+' '+this.get('text'))163 164 // меняем длину поля ввода165 var input_width = this.getParent('.b-combo').getElement('.b-combo__input').getProperty('class').match(/b-combo__input_width_(\d+)/gi);166 input_width=input_width[0].match(/\d+/gi);167 //максимальная длина блока .b-combo__input168 var input_max_width = this.getParent('.b-combo').getElement('.b-combo__input').getProperty('class').match(/b-combo__input_max-width_(\d+)/gi);169 input_max_width = input_max_width[0].match(/\d+/gi);170 171 //увеличиваем поле172 if((parseInt(this.getParent('.b-combo').getElement('.b-combo__label').getStyle('width')))>input_width){173 // если длина больше, чем максимально допустимая для этого блока, то ставим максимально допустимую174 if(parseInt(this.getParent('.b-combo').getElement('.b-combo__label').getStyle('width'))>input_max_width){175 this.getParent('.b-combo').getElement('.b-combo__input').setStyle('width',input_max_width +'px');176 }177 else{178 this.getParent('.b-combo').getElement('.b-combo__input').setStyle('width',parseInt(this.getParent('.b-combo').getElement('.b-combo__label').getStyle('width'))+5);179 }180 }181 else{182 this.getParent('.b-combo').getElement('.b-combo__input').setStyle('width',input_width+'px');183 }184 //сворачиваем окошко185 if(this.getParent('.b-combo').getElement('.b-combo__overlay')) {this.getParent('.b-combo').getElement('.b-combo__overlay').dispose();}186 this.getParent('.b-combo').getElement('.b-combo__input-text').removeClass('b-combo__input-text_color_a7');187 this.getParent('.b-combo').getElement('.b-shadow').addClass('b-shadow_hide');188 });189 190 191 //обрабатываем клик по элементам единственной колонки192 $$('.b-layout__one .b-combo__item-inner').addEvent('click',function(){193 194 //меняем значения в инпуте и label 195 this.getParent('.b-combo').getElement('.b-combo__input-text').setProperty('value',this.get('text'))196 this.getParent('.b-combo').getElement('.b-combo__label').setProperty('text',this.get('text'))197 198 // меняем длину поля ввода199 var input_width = this.getParent('.b-combo').getElement('.b-combo__input').getProperty('class').match(/b-combo__input_width_(\d+)/gi);200 input_width=input_width[0].match(/\d+/gi);201 //максимальная длина блока .b-combo__input202 var input_max_width = this.getParent('.b-combo').getElement('.b-combo__input').getProperty('class').match(/b-combo__input_max-width_(\d+)/gi);203 input_max_width = input_max_width[0].match(/\d+/gi);204 205 //увеличиваем поле206 if((parseInt(this.getParent('.b-combo').getElement('.b-combo__label').getStyle('width')))>input_width){207 // если длина больше, чем максимально допустимая для этого блока, то ставим максимально допустимую208 if(parseInt(this.getParent('.b-combo').getElement('.b-combo__label').getStyle('width'))>input_max_width){209 this.getParent('.b-combo').getElement('.b-combo__input').setStyle('width',input_max_width +'px');210 }211 else{212 this.getParent('.b-combo').getElement('.b-combo__input').setStyle('width',parseInt(this.getParent('.b-combo').getElement('.b-combo__label').getStyle('width'))+5);213 }214 }215 else{216 this.getParent('.b-combo').getElement('.b-combo__input').setStyle('width',input_width+'px');217 }218 //сворачиваем окошко219 if(this.getParent('.b-combo').getElement('.b-combo__overlay')) {this.getParent('.b-combo').getElement('.b-combo__overlay').dispose();}220 this.getParent('.b-combo').getElement('.b-combo__input-text').removeClass('b-combo__input-text_color_a7');221 this.getParent('.b-combo').getElement('.b-shadow').addClass('b-shadow_hide');222 });223 224 }225 else{226 this.getParent('.b-combo__input').getNext('.b-shadow').addClass('b-shadow_hide');227 if(this.getParent('.b-combo').getElement('.b-combo__overlay')) {this.getParent('.b-combo').getElement('.b-combo__overlay').dispose();}228 229 if((this.getParent('.b-combo').getElement('.b-combo__item_active')&&(this.getParent('.b-combo').getElement('.b-combo__label').get('text')==''))){230 this.getParent('.b-combo').getElement('.b-combo__item_active').removeClass('b-combo__item_active');231 this.getParent('.b-combo').getElement('.b-layout__right').addClass('b-layout__right_hide');232 }233 }234 })235 $$( ".b-combo__user" ).addEvents({236 237 //focus на поле ввода238 click: function (){239 this.getParent('.b-combo').getElement('.b-combo__label').set('html',this.get('html'));240 this.getParent('.b-combo').getElement('.b-combo__label').addClass('b-combo__label_show');241 this.getParent('.b-combo').getElement('.b-shadow').addClass('b-shadow_hide');242 this.getParent('.b-combo').getElement('.b-combo__overlay').dispose();243 244 //длина блока .b-combo__input245 var input_width = this.getParent('.b-combo').getElement('.b-combo__input').getProperty('class').match(/b-combo__input_width_(\d+)/gi);246 input_width=input_width[0].match(/\d+/gi);247 248 //максимальная длина блока .b-combo__input249 var input_max_width = this.getParent('.b-combo').getElement('.b-combo__input').getProperty('class').match(/b-combo__input_max-width_(\d+)/gi);250 input_max_width = input_max_width[0].match(/\d+/gi);251 252 if((parseInt(this.getParent('.b-combo').getElement('.b-combo__label').getStyle('width')))>input_width){253 if((parseInt(this.getParent('.b-combo').getElement('.b-combo__label').getStyle('width')))>input_max_width){254 this.getParent('.b-combo').getElement('.b-combo__input').setStyle('width',input_max_width+"px");255 }256 else{257 this.getParent('.b-combo').getElement('.b-combo__input').setStyle('width',parseInt(this.getParent('.b-combo').getElement('.b-combo__label').getStyle('width'))+5);258 }259 }260 261 return false;262 263 }264 265 266 })267 ...

Full Screen

Full Screen

script.js

Source:script.js Github

copy

Full Screen

...10 ];11 12 custom_module_id.each(function(el,j){13 if(el) {14 el.getParent().setStyle('display','none');15 }16 });17 18 if(document.id('jform_params_auto_module_id').value === '0') {19 document.id('jform_params_custom_module_id').getParent().setStyle('display','');20 }21 22 document.id('jform_params_auto_module_id').addEvent("change", function(){23 custom_module_id.each(function(el,j){24 el.getParent().setStyle('display','none');25 });26 if(document.id('jform_params_auto_module_id').value === '0') {27 document.id('jform_params_custom_module_id').getParent().setStyle('display','');28 }29 });30 31 document.id('jform_params_auto_module_id').addEvent("blur", function(){32 custom_module_id.each(function(el,j){33 el.getParent().setStyle('display','none');34 }); 35 if(document.id('jform_params_auto_module_id').value === '0') {36 document.id('jform_params_custom_module_id').getParent().setStyle('display','');37 }38 });39 40 // Toggle data_source fields41 var data_sources = [42 document.id('jform_params_catfilter'), 43 document.id('jformparamscategory_id'), 44 document.id('jform_params_getChildren'), 45 document.id('jform[params][add_k2_items]_name').getParent(), 46 document.id('itemsList'),47 document.id('jform_params_k2_tags'),48 document.id('jform_params_exclude_k2_items'),49 document.id('jform_params_FeaturedItems'),50 document.id('jform_params_popularityRange'),51 document.id('jform_params_videosOnly'),52 document.id('jform_params_items_order')53 ];54 55 data_sources.each(function(el,j){56 if(el) {57 el.getParent().setStyle('display','none');58 }59 })6061 if(document.id('jform_params_data_source').value === 'k2_categories') {62 document.id('jform_params_catfilter').getParent().setStyle('display','');63 document.id('jformparamscategory_id').getParent().setStyle('display','');64 document.id('jform_params_getChildren').getParent().setStyle('display','');65 document.id('jform_params_exclude_k2_items').getParent().setStyle('display','');66 document.id('jform_params_FeaturedItems').getParent().setStyle('display','');67 document.id('jform_params_popularityRange').getParent().setStyle('display','');68 document.id('jform_params_videosOnly').getParent().setStyle('display','');69 document.id('jform_params_items_order').getParent().setStyle('display','');70 }71 72 if(document.id('jform_params_data_source').value === 'k2_articles') {73 document.id('jform[params][add_k2_items]_name').getParent().getParent().setStyle('display','');74 document.id('itemsList').getParent().setStyle('display','');75 76 }77 78 if(document.id('jform_params_data_source').value === 'all_k2_articles') {79 document.id('jform_params_exclude_k2_items').getParent().setStyle('display','');80 document.id('jform_params_FeaturedItems').getParent().setStyle('display','');81 document.id('jform_params_popularityRange').getParent().setStyle('display','');82 document.id('jform_params_videosOnly').getParent().setStyle('display','');83 document.id('jform_params_items_order').getParent().setStyle('display','');84 }85 86 if(document.id('jform_params_data_source').value === 'k2_tags') {87 document.id('jform_params_k2_tags').getParent().setStyle('display','');88 document.id('jform_params_exclude_k2_items').getParent().setStyle('display','');89 document.id('jform_params_FeaturedItems').getParent().setStyle('display','');90 document.id('jform_params_popularityRange').getParent().setStyle('display','');91 document.id('jform_params_videosOnly').getParent().setStyle('display','');92 document.id('jform_params_items_order').getParent().setStyle('display','');93 }94 95 document.id('jform_params_data_source').addEvent("change", function(){96 data_sources.each(function(el,j){97 el.getParent().setStyle('display','none');98 });99100 if(document.id('jform_params_data_source').value === 'k2_categories') {101 document.id('jform_params_catfilter').getParent().setStyle('display','');102 document.id('jformparamscategory_id').getParent().setStyle('display','');103 document.id('jform_params_getChildren').getParent().setStyle('display','');104 document.id('jform_params_exclude_k2_items').getParent().setStyle('display','');105 document.id('jform_params_FeaturedItems').getParent().setStyle('display','');106 document.id('jform_params_popularityRange').getParent().setStyle('display','');107 document.id('jform_params_videosOnly').getParent().setStyle('display','');108 document.id('jform_params_items_order').getParent().setStyle('display','');109 }110 111 if(document.id('jform_params_data_source').value === 'k2_articles') {112 document.id('jform[params][add_k2_items]_name').getParent().getParent().setStyle('display','');113 document.id('itemsList').getParent().setStyle('display','');114 }115 116 if(document.id('jform_params_data_source').value === 'all_k2_articles') {117 document.id('jform_params_exclude_k2_items').getParent().setStyle('display','');118 document.id('jform_params_FeaturedItems').getParent().setStyle('display','');119 document.id('jform_params_popularityRange').getParent().setStyle('display','');120 document.id('jform_params_videosOnly').getParent().setStyle('display','');121 document.id('jform_params_items_order').getParent().setStyle('display','');122 }123 124 if(document.id('jform_params_data_source').value === 'k2_tags') {125 document.id('jform_params_k2_tags').getParent().setStyle('display','');126 document.id('jform_params_exclude_k2_items').getParent().setStyle('display','');127 document.id('jform_params_FeaturedItems').getParent().setStyle('display','');128 document.id('jform_params_popularityRange').getParent().setStyle('display','');129 document.id('jform_params_videosOnly').getParent().setStyle('display','');130 document.id('jform_params_items_order').getParent().setStyle('display','');131 }132 133 });134 135 document.id('jform_params_data_source').addEvent("blur", function(){136 data_sources.each(function(el,j){137 el.getParent().setStyle('display','none');138 });139 140 if(document.id('jform_params_data_source').value === 'k2_categories') {141 document.id('jform_params_catfilter').getParent().setStyle('display','');142 document.id('jformparamscategory_id').getParent().setStyle('display','');143 document.id('jform_params_getChildren').getParent().setStyle('display','');144 document.id('jform_params_exclude_k2_items').getParent().setStyle('display','');145 document.id('jform_params_FeaturedItems').getParent().setStyle('display','');146 document.id('jform_params_popularityRange').getParent().setStyle('display','');147 document.id('jform_params_videosOnly').getParent().setStyle('display','');148 document.id('jform_params_items_order').getParent().setStyle('display','');149 }150 151 if(document.id('jform_params_data_source').value === 'k2_articles') {152 document.id('jform[params][add_k2_items]_name').getParent().getParent().setStyle('display','');153 document.id('itemsList').getParent().setStyle('display','');154 }155 156 if(document.id('jform_params_data_source').value === 'all_k2_articles') {157 document.id('jform_params_exclude_k2_items').getParent().setStyle('display','');158 document.id('jform_params_FeaturedItems').getParent().setStyle('display','');159 document.id('jform_params_popularityRange').getParent().setStyle('display','');160 document.id('jform_params_videosOnly').getParent().setStyle('display','');161 document.id('jform_params_items_order').getParent().setStyle('display','');162 }163 164 if(document.id('jform_params_data_source').value === 'k2_tags') {165 document.id('jform_params_k2_tags').getParent().setStyle('display','');166 document.id('jform_params_exclude_k2_items').getParent().setStyle('display','');167 document.id('jform_params_FeaturedItems').getParent().setStyle('display','');168 document.id('jform_params_popularityRange').getParent().setStyle('display','');169 document.id('jform_params_videosOnly').getParent().setStyle('display','');170 document.id('jform_params_items_order').getParent().setStyle('display','');171 }172 173 });174 ...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

...14 var modblock = $$('div[id^="module-sliders"]')[0];15 var baseW = modblock.getSize().x;16 var minW = 640;17 18 modblock.getParent().setStyle('position','relative');19 20 if(baseW < minW) {21 modblock.setStyles({22 "position": "absolute",23 "background": "white",24 "width": baseW + "px",25 "padding": "5px",26 "border-radius": "3px",27 "-webkit-box-shadow": "-8px 0 15px #aaa",28 "-moz-box-shadow": "-8px 0 15px #aaa",29 "box-shadow": "-8px 0 15px #aaa",30 "-webkit-box-sizing": "border-box",31 "-moz-box-sizing": "border-box",32 "-ms-box-sizing": "border-box",33 "box-sizing": "border-box"34 });35 36 var WidthFX = new Fx.Morph(modblock, {duration: 150});37 var mouseOver = false;38 39 modblock.addEvent('mouseenter', function() {40 mouseOver = true;41 WidthFX.start({42 'width': minW,43 'margin-left': (-1 * (minW - baseW))44 });45 });46 modblock.addEvent('mouseleave', function() {47 mouseOver = false;48 (function() {49 if(!mouseOver) {50 WidthFX.start({51 'width': baseW,52 'margin-left': 053 });54 }55 }).delay(750);56 });57 }58 59 // fix the Joomla! behaviour60 $$('.panel h3.title').each(function(panel) {61 panel.addEvent('click', function(){62 if(panel.hasClass('pane-toggler')) {63 (function(){ 64 panel.getParent().getElement('.pane-slider').setStyle('height', 'auto'); 65 }).delay(750);66 (function() {67 var myFx = new Fx.Scroll(window, { duration: 150 }).toElement(panel);68 }).delay(250);69 }70 });71 });72 //73 //74 //75 if(document.id('jform_params_links_position').value == 'bottom') document.id('jform_params_links_width').getParent().setStyle('display','none');76 else document.id('jform_params_links_width').getParent().setStyle('display',''); 77 document.id('jform_params_links_position').addEvent('change', function(){78 if(document.id('jform_params_links_position').value == 'bottom') document.id('jform_params_links_width').getParent().setStyle('display','none');79 else document.id('jform_params_links_width').getParent().setStyle('display',''); 80 });81 document.id('jform_params_links_position').addEvent('blur', function(){82 if(document.id('jform_params_links_position').value == 'bottom') document.id('jform_params_links_width').getParent().setStyle('display','none');83 else document.id('jform_params_links_width').getParent().setStyle('display','');84 });85 86 $$('.input-pixels').each(function(el){el.getParent().innerHTML = el.getParent().innerHTML + "<span class=\"unit\">px</span>"});87 $$('.input-percents').each(function(el){el.getParent().innerHTML = el.getParent().innerHTML + "<span class=\"unit\">%</span>"});88 $$('.input-minutes').each(function(el){el.getParent().innerHTML = el.getParent().innerHTML + "<span class=\"unit\">minutes</span>"});89 $$('.input-ms').each(function(el){el.getParent().innerHTML = el.getParent().innerHTML + "<span class=\"unit\">ms</span>"});90 $$('.input-times').each(function(el){ el.getParent().innerHTML = el.getParent().innerHTML + "<span class=\"unit times\">&times;</span>"});91 92 $$('.text-limit').each(function(el){93 var name = el.get('id') + '_type';94 var parent = el.getParent();95 el.inject(document.id(name),'before'); 96 parent.dispose();97 });98 $$('.float').each(function(el){99 var destination = el.getParent().getPrevious().getElement('select');100 var parent = el.getParent();101 el.inject(destination, 'after');102 parent.dispose(); 103 });104 $$('.enabler').each(function(el){105 var destination = el.getParent().getPrevious().getElement('select');106 var parent = el.getParent();107 el.inject(destination, 'after');108 parent.dispose(); 109 });110 $$('.gk_switch').each(function(el){111 el.setStyle('display','none');112 var style = (el.value == 1) ? 'on' : 'off';113 var switcher = new Element('div',{'class' : 'switcher-'+style});114 switcher.inject(el, 'after');115 switcher.addEvent("click", function(){116 if(el.value == 1){117 switcher.setProperty('class','switcher-off');118 el.value = 0;119 } else {120 switcher.setProperty('class','switcher-on');121 el.value = 1;122 }123 });124 });125 126 var link = new Element('a', { 'class' : 'gkHelpLink', 'href' : 'http://www.gavick.com/news-show-pro-gk5.html', 'target' : '_blank' })127 link.inject($$('div.panel')[$$('div.panel').length-1].getElement('h3'), 'bottom');128 link.addEvent('click', function(e) { e.stopPropagation(); });129 //130 new DataSources();131 new PortalModes();132 new ImageCrop();133 new ArticleLayout();134 135 // option to hide article format related fields136 var article_format = document.id('jform_params_use_own_article_format').get('value');137 138 if(article_format == 1) {139 document.id('jform_params_article_format').getParent().setStyle('display', 'block');140 $$('.article-format-hide').each(function(el, i) {141 el.getParent().setStyle('display', 'none');142 });143 } else {144 document.id('jform_params_article_format').getParent().setStyle('display', 'none');145 $$('.article-format-hide').each(function(el, i) {146 el.getParent().setStyle('display', 'block');147 });148 }149 document.id('jform_params_use_own_article_format').getNext('div').addEvent('click', function() {150 var article_format = document.id('jform_params_use_own_article_format').get('value');151 152 if(article_format == 1) {153 document.id('jform_params_article_format').getParent().setStyle('display', 'block');154 $$('.article-format-hide').each(function(el, i) {155 el.getParent().setStyle('display', 'none');156 });157 } else {158 document.id('jform_params_article_format').getParent().setStyle('display', 'none');159 $$('.article-format-hide').each(function(el, i) {160 el.getParent().setStyle('display', 'block');161 });162 } 163 });164 165 // option to hide js engine related fiels166 var used_js_engine = document.id('jform_params_engine_mode').get('value');167 168 document.id('jform_params_animation_function').getParent().setStyle('display', (used_js_engine == 'mootools') ? 'block' : 'none');169 document.id('jform_params_engine_mode').addEvents({170 'change': function() {171 var used_js_engine = document.id('jform_params_engine_mode').get('value');172 document.id('jform_params_animation_function').getParent().setStyle('display', (used_js_engine == 'mootools') ? 'block' : 'none');173 },174 'blur': function() {175 var used_js_engine = document.id('jform_params_engine_mode').get('value');176 document.id('jform_params_animation_function').getParent().setStyle('display', (used_js_engine == 'mootools') ? 'block' : 'none');177 },178 'focus': function() {179 var used_js_engine = document.id('jform_params_engine_mode').get('value');180 document.id('jform_params_animation_function').getParent().setStyle('display', (used_js_engine == 'mootools') ? 'block' : 'none');181 }182 });183 184 // AMM fix185 document.getElements('#module-sliders .panel').each(function(el, i) {186 if(el.getParent().getProperty('id') == 'module-sliders' && el.getElement('h3').getProperty('id') != 'assignment-options' && el.getElement('h3').getProperty('id') != 'permissions') {187 el.addClass('nspgk5-panel');188 } else if(el.getParent().getProperty('id') == 'module-sliders'){189 el.addClass('non-nspgk5-panel');190 }191 });...

Full Screen

Full Screen

b-filter.js

Source:b-filter.js Github

copy

Full Screen

1window.addEvent('domready', 2function() {3 $$('.b-filter__body .b-filter__link').addEvent('click',function(){ 4 $$('.b-filter__toggle').addClass('b-filter__toggle_hide');5 this.getParent('.b-filter__body').getNext('.b-filter__toggle').removeClass('b-filter__toggle_hide');6 $$('.b-filter').setStyle('z-index','0')7 this.getParent('.b-filter').setStyle('z-index','10')8 var overlay=document.createElement('div');9 overlay.className='b-filter__overlay';10 $$('.overlay-cls').grab(overlay, 'top');11 $$('.b-filter__overlay').addEvent('click',function(){12 $$('.b-filter__toggle').addClass('b-filter__toggle_hide');13 $$('.b-filter__overlay').dispose();14 if (Browser.ie8){15 $$('.b-filter').setStyle('overflow','visible');16 if(this.getParent('.b-filter') != undefined) {17 this.getParent('.b-filter').setStyle('overflow','hidden');18 this.getParent('.b-filter').setStyle('overflow','visible');19 }20 } 21 });22 return false;23 })24 25 26 $$('.b-filter__item .b-filter__link').addEvent('click',function(){27 if((this.getParent('.b-filter__item').getChildren('.b-filter__marker').hasClass('b-filter__marker_hide'))){28 this.getParent('.b-filter__list').getChildren('.b-filter__item').getElement('.b-filter__marker').addClass('b-filter__marker_hide').getPrevious('.b-filter__link').removeClass('b-filter__link_no').addClass('b-filter__link_dot_0f71c8');29 this.getParent('.b-filter__item').getChildren('.b-filter__marker').removeClass('b-filter__marker_hide');30 this.removeClass('b-filter__link_dot_0f71c8').addClass('b-filter__link_no');31 this.getParent('.b-filter__toggle').getPrevious('.b-filter__body').getChildren('.b-filter__link').set('text',this.get('text'));32 $$('.b-filter__toggle').addClass('b-filter__toggle_hide');33 $$('.b-filter__overlay').dispose();34 if (Browser.ie8){35 $$('.b-filter').setStyle('overflow','visible');36 if(this.getParent('.b-filter') != undefined) {37 this.getParent('.b-filter').setStyle('overflow','hidden');38 this.getParent('.b-filter').setStyle('overflow','visible');39 }40 } 41 this.fireEvent('selected');42 return false;43 }44 });45 46 if($('calcForm') != undefined) sbr_calc($('calcForm'));47});48function setValueInput(name, val, act) {49 if(act == undefined) act = 'update';50 $(name).set('value', val);51 if(act == 'update') sbr_calc($('calcForm'), 'recalc');52}53function checkRole(val) {54 if(val == 1) {55 $('shadow_rez_type').removeClass('b-shadow_right_0');56 57 $('block_calc_emp_text').set('html', 'Ðàáîòîäàòåëü çàïëàòèò');58 $('block_calc_frl_text').set('html', 'Âû ïîëó÷èòå');59 60 var frl_html = $('freelancer_block');61 var emp_html = $('emp_block');62 63 $('first_block').empty()64 $('first_block').grab(frl_html);65 $('second_block').empty()66 $('second_block').grab(emp_html);67 68 $('case_word').set('html', 'ÿâëÿþùèéñÿ');69 $('calc_role').set('html', '&nbsp;õî÷ó çàêëþ÷èòü ñ ðàáîòîäàòåëåì');70 $('second_block_tooltip').grab($('calc_role'), 'after');71 $('link_role').set('html', 'ñ ðàáîòîäàòåëåì');72 }73 if(val == 2) {74 $('shadow_rez_type').addClass('b-shadow_right_0');75 76 $('block_calc_emp_text').set('html', 'Âû çàïëàòèòå');77 $('block_calc_frl_text').set('html', 'Èñïîëíèòåëü ïîëó÷èò');78 79 var frl_html = $('freelancer_block');80 var emp_html = $('emp_block');81 82 $('first_block').empty();83 $('first_block').grab(emp_html);84 $('second_block').empty();85 $('second_block').grab(frl_html);86 87 88 $('case_word').set('html', 'ÿâëÿþùèìñÿ');89 $('calc_role').set('html', '&nbsp;õî÷ó çàêëþ÷èòü ñ ôðè-ëàíñåðîì');90 $('first_block_tooltip').grab($('calc_role'), 'after');91 $('link_role').set('html', 'ñ ôðè-ëàíñåðîì');92 }93}94function setBlockScheme(act, u) {95 if(u == undefined) u= 0;96 if($('frl_type').get('value') == 2) {97 act = 1;98 }99 if(act == 1) {100 if(u == 0) $('bank_scheme').fireEvent('click');//click();101 $('bank_scheme').getParent().removeClass('b-filter__item_padbot_10');102 $('block_scheme').getElements('li a').each(function(elm) {103 if(elm.hasClass('b-filter__link_no') == false) {104 elm.getParent().hide();105 } 106 });107 } else if(act == 2) {108 var scheme = $('scheme_type').get('value'); 109 $('bank_scheme').getParent().addClass('b-filter__item_padbot_10');110 $('block_scheme').getElements('li a').each(function(elm) {111 if(elm.hasClass('b-filter__link_no') == false) {112 elm.getParent().show();113 } 114 115 if( (scheme == 1 || scheme == 4) && elm.hasClass('b-filter__pdrd') == true) {116 elm.getParent().hide();117 }118 119 if( (scheme == 2 || scheme == 5 ) && elm.hasClass('b-filter__pskb') == true) {120 elm.getParent().hide();121 }122 });123 } else if(act == 3) {124 $('bank_scheme').fireEvent('click');125 $('bank_scheme').getParent().addClass('b-filter__item_padbot_10');126 $('block_scheme').getElements('li a').each(function(elm) {127 if(elm.hasClass('b-filter__pskb') == true) {128 elm.getParent().hide();129 } else {130 elm.getParent().show();131 } 132 if(elm.hasClass('b-filter__pdrd') == true) {133 elm.getParent().show();134 } 135 });136 } else if(act == 4) {137 $('bank_scheme').fireEvent('click');138 $('bank_scheme').getParent().addClass('b-filter__item_padbot_10');139 $('block_scheme').getElements('li a').each(function(elm) {140 if(elm.hasClass('b-filter__pskb') == true) {141 elm.getParent().show();142 } 143 if(elm.hasClass('b-filter__pdrd') == true) {144 elm.getParent().hide();145 } 146 });147 }...

Full Screen

Full Screen

PounceAttack.js

Source:PounceAttack.js Github

copy

Full Screen

...15 constructor(parentUsername, time, angle) {16 super(parentUsername);17 this._startTime = time;18 this._angle = angle;19 if (this.getParent()) {20 this.getParent()._attackSprite = new PIXI.AnimatedSprite(PounceAttack.ATTACK_TEXTURES, true);21 this.getParent()._attackSprite.anchor.x = 0.5;22 this.getParent()._attackSprite.anchor.y = 0.8;23 this.getParent()._attackSprite.scale.x = 0.5;24 this.getParent()._attackSprite.scale.y = 0.5;25 this.getParent()._attackSprite.animationSpeed = 0.5;26 this.getParent()._attackSprite.loop = false;27 this.getParent()._attackSprite._pounce = true;28 this.getParent()._attackSprite.play();29 this.getParent()._attackSprite.onComplete = () => {30 if (!this.getParent() || !this.getParent()._attackSprite || !this.getParent()._attackSprite._pounce) {31 return;32 }33 this.getParent()._attackSprite.destroy();34 this.getParent()._attackSprite = null;35 };36 this.getParent()._container.addChild(this.getParent()._attackSprite);37 const position = this.getParent().getPosition(time);38 const howl = PounceAttack.AUDIO_CHOICES[Math.floor(Math.random() * PounceAttack.AUDIO_CHOICES.length)];39 AudioSystem.playSound(howl, position);40 }41 if (this._parentUsername === USERNAME) {42 if (this.getParent()) {43 this.getParent()._velocity[0] = Math.cos(this._angle) * 12;44 this.getParent()._velocity[1] = Math.sin(this._angle) * 12;45 this.getParent()._packetAppendString += this.getPacket();46 }47 }48 this._hit = false;49 }50 update(time) {51 if (this.getParent()) {52 if (time - this._startTime <= 600) {53 if (this._parentUsername === USERNAME) {54 this.getParent()._velocity[0] += Math.cos(this._angle) * Entity.ACCEL * 2;55 this.getParent()._velocity[1] += Math.sin(this._angle) * Entity.ACCEL * 2;56 }57 }58 if (Connection.isEddie() && Connection.getEddie()) {59 const dx = this.getParent()._velocity[0];60 const dy = this.getParent()._velocity[1];61 const eddiePosition = Connection.getEddie().getPosition(time);62 const eddiePolygon = Connection.getEddie().getPolygon([0, 0]).map(point => {63 return [point[0] * 1.8 + eddiePosition[0], point[1] * 1.6 + eddiePosition[1]];64 });65 if (PolygonMath.isPointInPolygon2D(this.getParent().getPosition(time - 500), eddiePolygon)) {66 this._hit = true;67 const d = Math.sqrt(dx * dx + dy * dy);68 const damage = Math.max((d - this.getParent().getMaxSpeed()) * 4, 24);69 console.log(damage);70 Connection.getEddie()._health -= damage * Connection._moonratDamageScale;71 AudioSystem.playEddiePainSound(eddiePosition);72 }73 }74 }75 }76 isActive(time) {77 return time - this._startTime <= 1200 && !this._hit;78 }79 shouldSlow(time) {80 return false;81 }82 getPacket() {...

Full Screen

Full Screen

HolyAttack.js

Source:HolyAttack.js Github

copy

Full Screen

...24 this._sprite.loop = false;25 this._sprite.play();26 Renderer._container.addChild(this._sprite);27 HolyAttack.AUDIO.play();28 if (this.getParent()) {29 if (this.getParent()._attackSprite) {30 this.getParent()._attackSprite.destroy();31 this.getParent()._attackSprite = null;32 }33 this.getParent()._attackSprite = new PIXI.AnimatedSprite(HolyAttack.ATTACK_TEXTURES, true);34 this.getParent()._attackSprite.anchor.x = 1133/1810;35 this.getParent()._attackSprite.anchor.y = 1118/1317;36 this.getParent()._attackSprite.scale.x = 0.8;37 this.getParent()._attackSprite.scale.y = 0.8;38 this.getParent()._attackSprite.animationSpeed = 0.2;39 this.getParent()._attackSprite.loop = false;40 this.getParent()._attackSprite._holy = true;41 this.getParent()._attackSprite.play();42 this.getParent()._attackSprite.onComplete = () => {43 if (!this.getParent() || !this.getParent()._attackSprite || !this.getParent()._attackSprite._holy) {44 return;45 }46 this.getParent()._attackSprite.destroy();47 this.getParent()._attackSprite = null;48 };49 this.getParent()._container.addChild(this.getParent()._attackSprite);50 }51 if (this._parentUsername === USERNAME) {52 if (this.getParent()) {53 this.getParent()._packetAppendString += this.getPacket();54 }55 }56 this._launched = false;57 }58 update(time) {59 const duration = Connection.isEddie() ? 3000 : 2000;60 if (time - this._startTime >= duration) {61 this._launched = true;62 const ability = new GroundHolyAttack(this._parentUsername, time, this._position);63 AbilityManager.addAbility(ability);64 }65 }66 isActive(time) {67 return !this._launched;...

Full Screen

Full Screen

getParent.test.js

Source:getParent.test.js Github

copy

Full Screen

...3 test('getParent using a single key returns the original value', () => {4 const value = {5 foo: 'bar',6 }7 expect(getParent('foo', value)).toBe(value)8 expect(getParent(['foo'], value)).toBe(value)9 expect(getParent('bim', value)).toBe(value)10 })11 test('getParent when access arrays directly returns array', () => {12 const value = ['foobar']13 expect(getParent('[0]', value)).toBe(value)14 expect(getParent([0], value)).toBe(value)15 })16 test('getParent using a undefined returns undefined', () => {17 expect(getParent(undefined, { a: 'b' })).toBe(undefined)18 expect(getParent(undefined, {})).toBe(undefined)19 expect(getParent(undefined, [])).toBe(undefined)20 expect(getParent(undefined, 'foo')).toBe(undefined)21 expect(getParent(undefined, 123)).toBe(undefined)22 expect(getParent(undefined, null)).toBe(undefined)23 expect(getParent(undefined, undefined)).toBe(undefined)24 })25 test('getParent using am empty array returns undefined', () => {26 expect(getParent([], { a: 'b' })).toBe(undefined)27 expect(getParent([], {})).toBe(undefined)28 expect(getParent([], [])).toBe(undefined)29 expect(getParent([], 'foo')).toBe(undefined)30 expect(getParent([], 123)).toBe(undefined)31 expect(getParent([], null)).toBe(undefined)32 expect(getParent([], undefined)).toBe(undefined)33 })34 test('select from a nested Map', () => {35 const value = {36 foo: new Map([37 [38 'bar',39 {40 bim: 'bop',41 },42 ],43 ]),44 }45 expect(getParent('foo.bar.bim', value)).toEqual({46 bim: 'bop',47 })48 })49 test('select from a nested object with getParent method', () => {50 const foo = {51 data: {52 bar: {53 bim: 'bop',54 },55 },56 get(prop) {57 return this.data[prop]58 },59 }60 const value = {61 foo,62 }63 expect(getParent('foo.bar.bim', value)).toBe(foo.data.bar)64 })65 test('converts dot props to paths and gets parent', () => {66 const value = {67 foo: {68 bar: 'foobar',69 },70 }71 expect(getParent('foo.bar', value)).toBe(value.foo)72 })73 test('works with props that have dots', () => {74 const value = {75 'foo.bar': 'foobar',76 }77 expect(getParent(['foo.bar'], value)).toBe(value)78 })79 test('supports array syntax', () => {80 const value = {81 foo: ['foobar'],82 }83 expect(getParent('foo[0]', value)).toBe(value.foo)84 })85 test('curries the getParent method', () => {86 const value = {87 foo: 'bar',88 }89 const getParentFoo = getParent('foo')90 expect(getParentFoo(value)).toBe(value)91 })92 test('dispatches to the getParent method of the last argument', () => {93 const value = {94 getParent(path) {95 return getParent(path, this.props)96 },97 props: {98 foo: 'bar',99 },100 }101 expect(getParent('foo', value)).toEqual({ foo: 'bar' })102 })103 test('dispatches to the getParent method of the last argument when curried', () => {104 const value = {105 getParent: jest.fn(function (path) {106 return getParent(path, this.props)107 }),108 props: {109 foo: {110 bar: 'baz',111 },112 },113 }114 const getParentFooBar = getParent('foo.bar')115 expect(getParentFooBar(value)).toBe(value.props.foo)116 expect(value.getParent).toHaveBeenCalledTimes(1)117 expect(value.getParent).toHaveBeenCalledWith('foo.bar', value)118 })...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My Test', async t => {3 const secondCheckBox = Selector('input').withAttribute('id', 'remote-testing');4 .click(secondCheckBox)5 .expect(secondCheckBox.checked).ok()6 .expect(secondCheckBox.parent().find('label').innerText).eql('Remote Testing');7});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 const button = Selector('button').withText('Click me');4 .click(button)5 .expect(Selector('#populate').value).eql('Clicked');6});7import org.openqa.selenium.By;8import org.openqa.selenium.WebDriver;9import org.openqa.selenium.WebElement;10import org.openqa.selenium.chrome.ChromeDriver;11public class Test {12public static void main(String[] args) throws InterruptedException {13 WebDriver driver = new ChromeDriver();14 driver.manage().window().maximize();15 button.click();16 System.out.println(text.getText());17 driver.quit();18}19}20const puppeteer = require('puppeteer');21(async () => {22 const browser = await puppeteer.launch({headless: false});23 const page = await browser.newPage();24 await page.click('button');25 await page.waitFor(3000);26 const text = await page.$eval('#populate', el => el.textContent);27 console.log(text);28 await browser.close();29})();30import { browser, by, element } from 'protractor';31describe('Protractor Demo App', function() {32 it('should add one and two', function() {33 element(by.buttonText('Click me')).click();34 expect(element(by.id('populate')).getText()).toEqual('Clicked');35 });36});37describe('My First Test', function() {38 it('Does not do much!', function() {39 cy.get('button').contains('Click me').click()40 cy.get('#populate').contains('Clicked')41 })42})43module.exports = {44 'Demo test Google' : function (browser)

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 const selectBasedOnText = Selector('label').withText('I have tried TestCafe');4 .click(selectBasedOnText)5 .expect(selectBasedOnText.checked).ok()6 .click(selectBasedOnText);7});8import { Selector } from 'testcafe';9test('My first test', async t => {10 const developerNameInput = Selector('#developer-name');11 .typeText(developerNameInput, 'Peter')12 .expect(developerNameInput.value).eql('Peter');13});14import { Selector } from 'testcafe';15test('My first test', async t => {16 const secondRemoteCheckbox = Selector('input[type=checkbox]').nth(1);17 .click(secondRemoteCheckbox)18 .expect(secondRemoteCheckbox.checked).ok();19});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My Test', async t => {3 const selectBasedOnText = Selector('label').withText('I have tried TestCafe');4 const label = await selectBasedOnText();5 const id = await label.getAttribute('id');6 const parent = await label.getParent('div');7 const parentId = await parent.getAttribute('id');8 console.log(id, parentId);9});10import { Selector } from 'testcafe';11test('My Test', async t => {12 const selectBasedOnText = Selector('label').withText('I have tried TestCafe');13 const label = await selectBasedOnText();14 const text = await label.getText();15 console.log(text);16});17import { Selector } from 'testcafe';18test('My Test', async t => {19 const selectBasedOnText = Selector('label').withText('I have tried TestCafe');20 const label = await selectBasedOnText();21 const value = await label.getValue();22 console.log(value);23});24import { Selector } from 'testcafe';25test('My Test', async t => {26 const selectBasedOnText = Selector('label').withText('I have tried TestCafe');27 const label = await selectBasedOnText();28 const childElementCount = await label.getChildElementCount();29 console.log(childElementCount);30});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My Test', async t => {3 .click(Selector('label').withText('I have tried TestCafe'))4 .expect(Selector('label').withText('I have tried TestCafe').checked).ok()5 .expect(Selector('label').withText('I have tried TestCafe').parent('div').child('input').checked).ok()6 .expect(Selector('label').withText('I have tried TestCafe').parent('div').child('input').parent('div').child('label').checked).ok()7 .expect(Selector('label').withText('I have tried TestCafe').parent('div').child('input').parent('div').child('label').parent('div').child('input').checked).ok()8 .expect(Selector('label').withText('I have tried TestCafe').parent('div').child('input').parent('div').child('label').parent('div').child('input').parent('div').child('label').checked).ok()9 .expect(Selector('label').withText('I have tried TestCafe').parent('div').child('input').parent('div').child('label').parent('div').child('input').parent('div').child('label').parent('div').child('input').checked).ok()10 .expect(Selector('label').withText('I have tried TestCafe').parent('div').child('input').parent('div').child('label').parent('div').child('input').parent('div').child('label').parent('div').child('input').parent('div').child('label').checked).ok()11 .expect(Selector('label').withText('I have tried TestCafe').parent('div').child('input').parent('div').child('label').parent('div').child('input').parent('div').child('label').parent('div').child('input').parent('div').child('label').parent('div').child('input').checked).ok()12 .expect(Selector('label').withText('I have tried TestCafe').parent('div').child('input').parent('div').child('label').parent

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My first test', async t => {3 const selectBasedOnText = Selector('label').withText('I have tried TestCafe');4 const parent = selectBasedOnText.parent();5 .click(parent);6});7import { Selector } from 'testcafe';8test('My first test', async t => {9 const selectBasedOnText = Selector('label').withText('I have tried TestCafe');10 const parent = selectBasedOnText.parent(1);11 .click(parent);12});13import { Selector } from 'testcafe';14test('My first test', async t => {15 const selectBasedOnText = Selector('label').withText('I have tried TestCafe');16 const sibling = selectBasedOnText.sibling();17 .click(sibling);18});19import { Selector } from 'testcafe';20test('My first test', async t => {21 const selectBasedOnText = Selector('label').withText('I have tried TestCafe');22 const sibling = selectBasedOnText.sibling(1);23 .click(sibling);24});25import { Selector } from 'testcafe';26test('My first test', async t => {27 const selectBasedOnText = Selector('label').withText('I have tried TestCafe');28 const nextSibling = selectBasedOnText.nextSibling();29 .click(nextSibling);30});31import { Selector } from 'testcafe

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('My test', async t => {3 const selectCountry = Selector('#preferred-interface');4 const option = selectCountry.find('option');5 .click(selectCountry)6 .click(option.withText('Both'));7});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { Selector } from 'testcafe';2test('test', async t => {3 const select = Selector('select');4 const option = select.find('option');5 .click(select)6 .click(option.withText('Option 1'))7 .expect(option.withText('Option 1').parent('select').value).eql('1');8});

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 Testcafe 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