How to use buildLayout method in Best

Best JavaScript code snippet using best

game.js

Source:game.js Github

copy

Full Screen

...38 btn1.addEventListener("click", acao1);39 btn2.addEventListener("click", acao2);40 btn3.addEventListener("click", acao3);41}42function buildLayout(textP, textBtn1, textBtn2, textBtn3) {43 deletElement("btn1", btnClass);44 deletElement("btn2", btnClass);45 deletElement("btn3", btnClass);46 deletElement("txtId", text);47 p = elementFactory("p", "txtId", "txtC", `${textP}`);48 btn1 = elementFactory("button", "btn1", "btn", `${textBtn1}`);49 btn2 = elementFactory("button", "btn2", "btn", `${textBtn2}`);50 btn3 = elementFactory("button", "btn3", "btn", `${textBtn3}`);51 text.appendChild(p);52 btnClass.appendChild(btn1);53 btnClass.appendChild(btn2);54 btnClass.appendChild(btn3);55}56function iniciarPartida() {57 buildLayout(58 "Bom dia, caro Cientista! Qual será sua próxima ação?",59 "Sair de Casa",60 "Ficar em Casa",61 ""62 );63 changeBtn(fase1, iniciarPartida);64 btn3.classList.add("hide");65}66function fase1() {67 buildLayout(68 "O mundo lá fora está uma bagunça! Pense bem nos recursos que você irá levar. Sua mochila tem espaço para dois itens.",69 "Guarda-chuva e Máscara",70 "Guarda-chuva e Chave do Carro",71 "Máscara e Chave do Carro"72 );73 changeBtn(opcao1, opcao2, opcao3);74}75function opcao1() {76 buildLayout(77 "Guarda-chuva e Máscara, tem certeza disso?",78 "Sim, sair de casa",79 "Não, escolher novamente",80 ""81 );82 changeBtn(fase2, fase1);83 btn3.classList.add("hide");84 itens[0] = true;85 itens[1] = true;86 itens[2] = false;87 console.log(itens);88}89function opcao2() {90 buildLayout(91 "Guarda-chuva e Chave do Carro, tem certeza disso?",92 "Sim, sair de casa",93 "Não, escolher novamente",94 ""95 );96 changeBtn(fase2, fase1);97 btn3.classList.add("hide");98 itens[0] = true;99 itens[1] = false;100 itens[2] = true;101 console.log(itens);102}103function opcao3() {104 buildLayout(105 "Máscara e Chave do Carro, tem certeza disso?",106 "Sim, sair de casa",107 "Não, escolher novamente",108 ""109 );110 changeBtn(fase2, fase1);111 btn3.classList.add("hide");112 itens[0] = false;113 itens[1] = true;114 itens[2] = true;115 console.log(itens);116}117function fase2() {118 if (itens[0] && itens[1]) {119 buildLayout(120 "Você fez escolhas interessantes, mas precisará se locomover de transporte público",121 "Escolher Destino",122 "",123 ""124 );125 changeBtn(paraOnde);126 btn2.classList.add("hide");127 btn3.classList.add("hide");128 } else if (itens[0] && itens[2]) {129 buildLayout(130 "Você saiu sem máscara e o PM viu. Ele mandou você voltar para casa",131 "Voltar para Casa",132 "",133 ""134 );135 changeBtn(iniciarPartida);136 btn2.classList.add("hide");137 btn3.classList.add("hide");138 } else {139 buildLayout(140 "Máscaras para proteção e um veículo para locomoção rápida? Sábias escolhas!",141 "Escolher Destino",142 "",143 ""144 );145 changeBtn(paraOnde);146 btn2.classList.add("hide");147 btn3.classList.add("hide");148 }149}150function paraOnde() {151 buildLayout(152 "Você já está equipado, agora precisa decidir o seu destino:",153 "Universidade",154 "Brasília",155 "Agência da Caixa"156 );157 changeBtn(irUniversidade, irBrasilia, irAgCaixa);158}159function irUniversidade() {160 buildLayout(161 "Você está chegando no Valonguinho e ouve uma música alta vindo do DCE (Choppada Rolando)",162 "Ir para o DCE",163 "Ir para o laboratório",164 "Escolher novo Destino"165 );166 changeBtn(irDce, irLaboratorio);167 btn3.classList.add("hide");168}169function irDce() {170 if (corona) {171 if (itens[4] >= 20) {172 buildLayout(173 "Festa rolando, muita gente bêbada e corona no ar. Sorte sua que você já foi infectado e ainda possuí os anticorpos",174 "Sair da Festa",175 "Tomar uma Coca-cola geladinha",176 ""177 );178 changeBtn(irUniversidade, tomarCoca);179 btn3.classList.add("hide");180 } else {181 buildLayout(182 "Festa rolando, muita gente bêbada e corona no ar. sorte sua que você já foi infecato e ainda possúi os anticorpos, mas você não tem dinheiro para nada.",183 " Sair da Festa",184 "Ficar mais um Pouco",185 ""186 );187 changeBtn(irUniversidade, irDce);188 btn3.classList.add("hide");189 }190 } else {191 corona = true;192 buildLayout(193 "Festa rolando, muita gente bêbada e corona no ar. Você logo percebe que isso não foi uma boa idéia, mas já é tarde demais: VOCÊ FOI INFECTADO.<br>Os Hospitais estão lotados, vá para casa e torça para se recuperar sozinho",194 "Ir para casa e tentar se recuperar",195 "",196 ""197 );198 changeBtn(fase1);199 btn2.classList.add("hide");200 btn3.classList.add("hide");201 }202}203function tomarCoca() {204 itens[4] -= 20;205 irDce();206}207function irLaboratorio() {208 if (itens[3]) {209 buildLayout(210 "Muito bem, você entrou no laboratório. E agora?",211 "Pesquisar a cura com Cloroquina",212 "Pesquisar Vacina"213 );214 changeBtn(tentarCloroquina, tentarVacina);215 btn3.classList.add("hide");216 } else {217 buildLayout(218 "O laboratório está tracando e só o Chefe do Lab tem a chave. Há rumores de que ele foi para as manifestações em Brasília",219 "Voltar",220 "",221 "",222 ""223 );224 changeBtn(paraOnde);225 btn2.classList.add("hide");226 btn3.classList.add("hide");227 }228}229function tentarCloroquina() {230 buildLayout(231 "Você gastou um tempo razoável tentando encontrar uma cura pela Cloroquina, mas não descobriu nada de útil ainda.<br>E agora?",232 "Continuar Pesquisando",233 "Pesquisar Vacina",234 "Sair do laboratório"235 );236 changeBtn(tentarCloroquina, tentarVacina, paraOnde);237}238function tentarVacina() {239 if (pesquisarVacina == 0) {240 buildLayout(241 "Você gastou um tempo razoável tentando encontrar uma vacina que funcione. Não descobriu muito ainda, mas sente que está no caminho certo.<br>E agora?",242 "Continuar Pesquisando",243 "Pesquisar Cloroquina",244 "Sair do Labaoratório"245 );246 changeBtn(tentarVacina, tentarCloroquina, paraOnde);247 pesquisarVacina++;248 } else if (pesquisarVacina < 2) {249 buildLayout(250 "Você está chegando cada vez mais perto de uma vacina confiável, continue tentado",251 "Continuar Pesquisando",252 "Pesquisar Cloroquina",253 "Sair do Labaoratório"254 );255 changeBtn(tentarVacina, tentarCloroquina, paraOnde);256 pesquisarVacina++;257 } else {258 buildLayout(259 "Muito bem, você encontrou a vacina. Junte seus amigos e vá derrotar o Bolsodrácula.",260 "Ir ao Encontro do Bolsodrácula",261 "",262 ""263 );264 changeBtn(irBolsodracula);265 btn2.classList.add("hide");266 btn3.classList.add("hide");267 }268}269function irAgCaixa() {270 buildLayout(271 "Você chegou na agência e encontra a seguinte situação:<ol><li>Duas pessoas na fila preferencial;</li><li>Ninguém na fila dos caixas eletrônicos;</li><li>Cinco pessoas na fila normal</li></ol><br>Para qual fila você se dirige?",272 "Fila Preferencial",273 "Caixa Eletrônico",274 "Fila Normal"275 );276 changeBtn(irFilaPreferencial, irCaixaEletronico, irFilaNormal);277}278function irFilaPreferencial() {279 filas[0] = true;280 if (filas[1]) {281 buildLayout(282 "Você espera calmamente a sua vez, ansioso com o tempo passando, até que finalmente chamam sua senha.<i>VOCÊ NÃO DEVERIA ESTAR NESSA FILA. Não posso te atender.</i>",283 "Fila Normal",284 "",285 ""286 );287 changeBtn(irCaixaEletronico, irFilaNormal);288 btn2.classList.add("hide");289 btn3.classList.add("hide");290 } else {291 buildLayout(292 "Você espera calmamente a sua vez, ansioso com o tempo passando, até que finalmente chamam sua senha.<i>VOCÊ NÃO DEVERIA ESTAR NESSA FILA. Não posso te atender.</i>",293 "Caixa Eletrônico",294 "Fila Normal",295 ""296 );297 changeBtn(irCaixaEletronico, irFilaNormal);298 btn3.classList.add("hide");299 }300}301function irCaixaEletronico() {302 filas[1] = true;303 if (filas[0]) {304 buildLayout(305 "Não é de se estrnanhar que não houvesse fila para os caixas eletrônicos, estão todos desativados;",306 "Fila Normal",307 "",308 ""309 );310 changeBtn(irFilaNormal);311 btn2.classList.add("hide");312 btn3.classList.add("hide");313 } else {314 buildLayout(315 "Não é de se estrnanhar que não houvesse fila para os caixas eletrônicos, estão todos desativados;",316 "Fila Preferencial",317 "Fila Normal",318 ""319 );320 changeBtn(irFilaPreferencial, irFilaNormal);321 btn3.classList.add("hide");322 }323}324function irFilaNormal() {325 itens[4] = 1000;326 buildLayout(327 "Muito bem, você conseguiu sacar o auxílio emergencial. Faça bom uso dele",328 "Escolher Destino",329 "",330 ""331 );332 changeBtn(paraOnde);333 btn2.classList.add("hide");334 btn3.classList.add("hide");335}336function irBrasilia() {337 if (itens[2] && itens[4] < 800) {338 buildLayout(339 "Você pode até ter seu próprio caror, mas sem dinheiro para Gasolina não vai a lugar algum!",340 "Escolher Novo Destino",341 "",342 ""343 );344 changeBtn(paraOnde);345 btn2.classList.add("hide");346 btn3.classList.add("hide");347 } else if (itens[2] && itens[4] >= 800) {348 itens[4] -= 800;349 buildLayout(350 "Você tem seu carro e dinheiro para a Gasolina. Aperte o cinto, aí vamos nós",351 "Escolher Destinho em Brasília",352 "",353 ""354 );355 changeBtn(emBrasilia);356 btn2.classList.add("hide");357 btn3.classList.add("hide");358 console.log(itens[4]);359 }360 if (itens[2] == false && itens[4] < 500) {361 buildLayout(362 "Você não tem dinheiro para a passagem de ônibus.",363 "Escolher Novo Destino",364 "",365 ""366 );367 changeBtn(paraOnde);368 btn2.classList.add("hide");369 btn3.classList.add("hide");370 } else if (itens[2] == false && itens[4] >= 500) {371 buildLayout(372 "O pé na estrada eu vou botar, e já está na hora de ir.",373 "Escolher Destino em Brasília",374 "",375 ""376 );377 changeBtn(emBrasilia);378 btn2.classList.add("hide");379 btn3.classList.add("hide");380 }381}382function emBrasilia() {383 if (procurouChefe) {384 buildLayout(385 "Você tem uma pista de que o chefe do laboratório está no meio da multidão no protesto.<br>Qual é a sua próxima ação?",386 "Mandar mensagem de whatsapp",387 "Brigar com os manifestantes. Manifestação é coisa de vagabundo",388 ""389 );390 changeBtn(enviarWpp, brigar);391 } else {392 buildLayout(393 "Você tem uma pista de que o chefe do laboratório está no meio da multidão no protesto.<br>Qual é a sua próxima ação?",394 "Procurar por ele",395 "Mandar mensagem de whatsapp",396 "Brigar com os manifestantes. Manifestação é coisa de vagabundo"397 );398 changeBtn(procurarChefe, enviarWpp, brigar);399 }400}401function procurarChefe() {402 procurouChefe = true;403 if (corona) {404 buildLayout(405 "Apesar de estar de máscara, essa não foi uma escolha muito sábia.<br>Sorte que você já foi infectado e ainda tem os anticorpos, mas não é uma boa idéia ficar dando chance",406 "Sair da multidão",407 "",408 ""409 );410 changeBtn(emBrasilia);411 btn2.classList.add("hide");412 btn3.classList.add("hide");413 } else {414 buildLayout(415 "Apesar de estar de máscara, essa não foi uma escolha muito sábia.<br>Você contrariu o vírus e sem vaga nos hospitais precisará ir para um Hotel para tentar se recuperar",416 "Ir para um Hotel",417 "",418 ""419 );420 changeBtn(irHotel);421 }422}423function irHotel() {424 itens[4] -= 300;425 buildLayout(426 "Você deu sorte e se recuperou do coronavírus, mas passou por maus bocados. E ainda gastou todo seu dinheiro de rapaz trabalhado com as diárias do Hotel",427 "Tentar Falar com o Chefe do Lab",428 "",429 ""430 );431 changeBtn(emBrasilia);432 btn2.classList.add("hide");433 btn3.classList.add("hide");434}435function enviarWpp() {436 buildLayout(437 "Seu chefe respondeu e combinou de encontrar com você num bar vazio.",438 "Esperar por ele no Bar",439 "Brigar com os manifestantes. Manifestação é coisa de vagabundo",440 ""441 );442 changeBtn(irBar, brigar);443 btn3.classList.add("hide");444}445function irBar() {446 buildLayout(447 `"Você veio até aqui para me encontrar só para pegar a chave do laboratório?<br>Muito bem! Vamos aproveitar esse momento para um desafio.<br>Me vença em uma partida de Jokenpo que eu lhe darei a chave"`,448 "",449 "",450 ""451 );452 changeBtn(jogarJokenpo);453 btn2.classList.add("hide");454 btn3.classList.add("hide");455}456function jogarJokenpo() {457 escolhaChefe = Math.floor(Math.random() * (3 - 1 + 1)) + 1;458 if (jaJogou < 1) {459 buildLayout("Jo - Ken - Pô", "Jogar Pedra", "Jogar Papel", "Jogar Tesoura");460 changeBtn(resultadoPedra, resultadoPapel, resultadoTesoura);461 jaJogou++;462 console.log(jaJogou);463 console.log(escolhaChefe);464 } else if (jaJogou < 3) {465 buildLayout(466 `Não foi dessa vez, vamos tentar de novo!<br>Chefe: ${jaJogou}, Você : 0`,467 "Jogar Pedra",468 "Jogar Papel",469 "Jogar Tesoura"470 );471 changeBtn(resultadoPedra, resultadoPapel, resultadoTesoura);472 console.log(jaJogou);473 console.log(escolhaChefe);474 console.log("entrei no else jogo");475 jaJogou++;476 } else {477 itens[3] = true;478 buildLayout(479 "Já jogamos demais, toma logo essa chave e vai fazer suas pesquisas.",480 "Voltar para Niterói",481 "",482 ""483 );484 changeBtn(paraOnde);485 btn2.classList.add("hide");486 btn3.classList.add("hide");487 }488}489function resultadoPedra() {490 if (escolhaChefe == 1) {491 itens[3] = true;492 buildLayout(493 "Parabéns, Pedra ganha da Tesoura. Toma aqui a chave e vai fazer suas pesquisas",494 "Voltar para Niterói"495 );496 changeBtn(paraOnde);497 btn2.classList.add("hide");498 btn3.classList.add("hide");499 } else {500 jogarJokenpo();501 console.log("entrei no else pedra");502 }503}504function resultadoPapel() {505 if (escolhaChefe == 2) {506 itens[3] = true;507 buildLayout(508 "Parabéns, Papel ganha da Pedra. Toma aqui a chave e vai fazer suas pesquisas",509 "Voltar para Niterói"510 );511 changeBtn(paraOnde);512 btn2.classList.add("hide");513 btn3.classList.add("hide");514 } else {515 jogarJokenpo();516 }517}518function resultadoTesoura() {519 if (escolhaChefe == 3) {520 itens[3] = true;521 buildLayout(522 "Parabéns, Tesoura ganha do Papel. Toma aqui a chave e vai fazer suas pesquisas",523 "Voltar para Niterói"524 );525 changeBtn(paraOnde);526 btn2.classList.add("hide");527 btn3.classList.add("hide");528 } else {529 jogarJokenpo();530 }531}532function brigar() {533 buildLayout(534 "Você se deparou com um bloqueio. Vou te levar de volta",535 "Escolher Destino em Brasília",536 "",537 ""538 );539 changeBtn(emBrasilia);540 btn2.classList.add("hide");541 btn3.classList.add("hide");542}543function irBolsodracula() {544 buildLayout(545 "Você e Bolsodrácula estão cara a cara, a tensão está no ar. Seus amigos fogem, mas você está destinado a coisas maiores, você não pode fugir. Bolsodrácula ajeita sua capa, limpa suas presas e se prepara para atacar.<br> Rápido! O que você faz?",546 "Tentar se Esquivar",547 "Injetar a vacina em você mesmo",548 "Tentar acertar Bolsodrácula com a Vacina"549 );550 changeBtn(round1Esquivar, finalJogo, gameOver);551}552function round1Esquivar() {553 buildLayout(554 "Bolsodrácula, num movimento rápido, parte para o ataque. Com um pouco de agilidade e muita sorte você desvia de suas presas.<br>Novamente, ele te encara e se prepara para atacar.<br>Rápido! O que você faz?",555 "Tentar se Esquivar",556 "Injetar a vacina em você mesmo",557 "Tentar acertar Bolsodrácula com a Vacina"558 );559 changeBtn(gameOverEsquivar, finalJogo, gameOver);560}561function gameOverEsquivar() {562 buildLayout(563 "Quando Bolsodrácula pula para o ataque você ajeita suas pernas para mais um movimento rápido de esquiva, porém seus anos estudando ao invés de praticando esportes cobraram um preço caro. Seu tornozelo não aguenta a pressão do movimento e dobra, ao invés de impulsionar seu corpo para o lado.<br> A última coisa que seus olhos conseguem enxergar é a capa do Bolsodrácula enquanto ele injeta Coronavírus na sua mais forte mutação.<br> GAME OVER!",564 "Reiniciar",565 "",566 ""567 );568 changeBtn(iniciarPartida);569 btn2.classList.add("hide");570 btn3.classList.add("hide");571}572function gameOver() {573 buildLayout(574 `Bolsodrácula inicia sua investida contra você. Você, de maneira sorrateira (ao menos foi o que você pensou), esconde a seringa com a vacina na gola da camisa. Bolsodrácula, em um movimento rápido, imboliza você. Você é tomado por um sentimento de esperança e dever cumprido, quando Bolsodrácula parece se preparar para atacar seu pescoço e injetar o Coronavírus na sua mais forte mutação.<br>E 'snap'. Um estalo no pescoço e a vida esvaindo do seu corpo. Bolsodrácula havia percebido o seu movimento não tão sutil.<br>Game Over!`,575 "Reiniciar Partida"576 );577 changeBtn(iniciarPartida);578 btn2.classList.add("hide");579 btn3.classList.add("hide");580}581function finalJogo() {582 buildLayout(583 "Você injeta a vacina na perna, sem que Bolsodrácula perceba. Ele continua sua investida e crava as presas no seu pescoço. A vacina que você descobriu começa a se espalhar pelo corpo do Bolsodrácula e sua forma volta à original. Hitler foi, mais uma vez, vencido antes de dominar o mundo.<br> Você é um Herói Nacional e a humanidade está novamente em segurança.<br> Parabéns!",584 "Jogar de Novo",585 "",586 ""587 );588 changeBtn(iniciarPartida);589 btn2.classList.add("hide");590 btn3.classList.add("hide");...

Full Screen

Full Screen

VBoxLayout.js

Source:VBoxLayout.js Github

copy

Full Screen

...38 39 return config;40 }41 42 function buildLayout(config) {43 config = config || {};44 45 Ext.applyIf(config, {46 padding: {47 top : 0,48 right : 0,49 bottom: 0,50 left : 051 }52 });53 54 return new Ext.layout.VBoxLayout(config);55 };56 57 suite.add(new Y.Test.Case({58 name: 'calculating flexed box sizes',59 60 setUp: function() {61 this.layout = buildLayout();62 63 this.items = [64 buildFakeChild({flex: 1}),65 buildFakeChild({flex: 1}),66 buildFakeChild({flex: 1}),67 buildFakeChild({flex: 1})68 ];69 70 this.targetSize = {71 height: 400,72 width : 10073 };74 },75 76 testEqualFlexHeights: function() {77 var calcs = this.layout.calculateChildBoxes(this.items, this.targetSize),78 boxes = calcs.boxes;79 80 assert.areEqual(100, boxes[0].height);81 assert.areEqual(100, boxes[1].height);82 assert.areEqual(100, boxes[2].height);83 assert.areEqual(100, boxes[3].height);84 },85 86 testDifferentFlexWidths: function() {87 this.items = [88 buildFakeChild({flex: 1}),89 buildFakeChild({flex: 2}),90 buildFakeChild({flex: 3}),91 buildFakeChild({flex: 4})92 ];93 94 var calcs = this.layout.calculateChildBoxes(this.items, this.targetSize),95 boxes = calcs.boxes;96 97 assert.areEqual(40, boxes[0].height);98 assert.areEqual(80, boxes[1].height);99 assert.areEqual(120, boxes[2].height);100 assert.areEqual(160, boxes[3].height);101 },102 103 testMarginsAccountedFor: function() {104 var items = [105 buildFakeChild({flex: 1, margins: {left: 0, right: 0, top: 10, bottom: 10}}),106 buildFakeChild({flex: 1, margins: {left: 0, right: 0, top: 10, bottom: 10}}),107 buildFakeChild({flex: 1, margins: {left: 0, right: 0, top: 10, bottom: 10}}),108 buildFakeChild({flex: 1, margins: {left: 0, right: 0, top: 10, bottom: 10}})109 ];110 111 var calcs = this.layout.calculateChildBoxes(items, this.targetSize),112 boxes = calcs.boxes;113 114 assert.areEqual(80, boxes[0].height);115 assert.areEqual(80, boxes[1].height);116 assert.areEqual(80, boxes[2].height);117 assert.areEqual(80, boxes[3].height);118 },119 120 testPaddingAccountedFor: function() {121 this.layout = buildLayout({122 padding: {123 top : 10,124 right : 10,125 bottom: 10,126 left : 10127 }128 });129 130 var calcs = this.layout.calculateChildBoxes(this.items, this.targetSize),131 boxes = calcs.boxes;132 133 //400px available internally, minus 20px total left + right padding = 380 / 4134 assert.areEqual(95, boxes[0].height);135 assert.areEqual(95, boxes[1].height);136 assert.areEqual(95, boxes[2].height);137 assert.areEqual(95, boxes[3].height);138 },139 140 //one of the items is passed both a width and a flex - the flex should be ignored141 testHeightDominatesFlex: function() {142 var items = [143 buildFakeChild({flex: 1, height: 250, getHeight: function() {return 250;}}),144 buildFakeChild({flex: 1}),145 buildFakeChild({flex: 1}),146 buildFakeChild({flex: 1})147 ];148 149 var calcs = this.layout.calculateChildBoxes(items, this.targetSize),150 boxes = calcs.boxes;151 152 assert.areEqual(250, boxes[0].height);153 assert.areEqual(50, boxes[1].height);154 assert.areEqual(50, boxes[2].height);155 assert.areEqual(50, boxes[3].height);156 },157 158 testHeightPropertyDominatesGetHeight: function() {159 var layout = buildLayout({160 pack : 'start',161 align: 'stretch'162 });163 164 var items = [165 {166 title: 'Panel 1',167 flex: 1,168 html: 'flex : 1',169 frame: true,170 margins: {top: 0, left: 0, right: 0, bottom: 0},171 getHeight: function() {return 10;},172 getWidth: function() {return 10;}173 }, {174 title: 'Panel 2',175 height: 100,176 html: 'width : 100',177 frame: true,178 margins: {top: 0, left: 0, right: 0, bottom: 0},179 getWidth: function() {return 10;},180 181 //NOTE: this should be ignored by HBox because we have a different configured width property182 getHeight: function() {return 10;}183 }, {184 title: 'Panel 3',185 flex: 2,186 html: 'flex : 2',187 frame: true,188 margins: {top: 0, left: 0, right: 0, bottom: 0},189 getHeight: function() {return 10;},190 getWidth: function() {return 10;}191 }192 ];193 194 var targetSize = {195 height: 1628,196 width : 630197 };198 199 var calcs = layout.calculateChildBoxes(items, targetSize),200 boxes = calcs.boxes;201 202 assert.areEqual(0, boxes[0].top);203 assert.areEqual(510, boxes[1].top);204 assert.areEqual(610, boxes[2].top);205 }206 }));207 208 suite.add(new Y.Test.Case({209 name: 'aligning',210 211 setUp: function() {212 this.items = [213 buildFakeChild({flex: 1, getWidth: function() {return 10;}}),214 buildFakeChild({flex: 1, getWidth: function() {return 20;}}),215 buildFakeChild({flex: 1, getWidth: function() {return 30;}}),216 buildFakeChild({flex: 1, getWidth: function() {return 40;}})217 ];218 219 this.targetSize = {220 height: 400,221 width : 100222 };223 },224 225 testLeft: function() {226 this.layout = buildLayout({227 align: 'left'228 });229 230 var calcs = this.layout.calculateChildBoxes(this.items, this.targetSize),231 boxes = calcs.boxes;232 233 assert.areEqual(0, boxes[0].left);234 assert.areEqual(0, boxes[1].left);235 assert.areEqual(0, boxes[2].left);236 assert.areEqual(0, boxes[3].left);237 },238 239 testMiddle: function() {240 this.layout = buildLayout({241 align: 'center'242 });243 244 var calcs = this.layout.calculateChildBoxes(this.items, this.targetSize),245 boxes = calcs.boxes;246 247 assert.areEqual(45, boxes[0].left);248 assert.areEqual(40, boxes[1].left);249 assert.areEqual(35, boxes[2].left);250 assert.areEqual(30, boxes[3].left);251 },252 253 testStretch: function() {254 this.layout = buildLayout({255 align: 'stretch'256 });257 258 var calcs = this.layout.calculateChildBoxes(this.items, this.targetSize),259 boxes = calcs.boxes;260 261 assert.areEqual(0, boxes[0].left);262 assert.areEqual(0, boxes[1].left);263 assert.areEqual(0, boxes[2].left);264 assert.areEqual(0, boxes[3].left);265 266 assert.areEqual(100, boxes[0].width);267 assert.areEqual(100, boxes[1].width);268 assert.areEqual(100, boxes[2].width);269 assert.areEqual(100, boxes[3].width);270 },271 272 testStretchMax: function() {273 this.layout = buildLayout({274 align: 'stretchmax'275 });276 277 var calcs = this.layout.calculateChildBoxes(this.items, this.targetSize),278 boxes = calcs.boxes;279 280 assert.areEqual(0, boxes[0].left);281 assert.areEqual(0, boxes[1].left);282 assert.areEqual(0, boxes[2].left);283 assert.areEqual(0, boxes[3].left);284 285 assert.areEqual(40, boxes[0].width);286 assert.areEqual(40, boxes[1].width);287 assert.areEqual(40, boxes[2].width);288 assert.areEqual(40, boxes[3].width);289 }290 }));291 292 suite.add(new Y.Test.Case({293 name: 'packing',294 295 setUp: function() {296 this.items = [297 buildFakeChild({getSize: function() {return {width: 10, height: 10};}}),298 buildFakeChild({getSize: function() {return {width: 10, height: 20};}}),299 buildFakeChild({getSize: function() {return {width: 10, height: 30};}}),300 buildFakeChild({getSize: function() {return {width: 10, height: 40};}})301 ];302 303 this.targetSize = {304 height: 400,305 width : 100306 };307 },308 309 testPackStart: function() {310 this.layout = buildLayout({311 pack: 'start'312 });313 314 var calcs = this.layout.calculateChildBoxes(this.items, this.targetSize),315 boxes = calcs.boxes;316 317 assert.areEqual(0, boxes[0].top);318 assert.areEqual(10, boxes[1].top);319 assert.areEqual(30, boxes[2].top);320 assert.areEqual(60, boxes[3].top);321 },322 323 testPackCenter: function() {324 this.layout = buildLayout({325 pack: 'center'326 });327 328 var calcs = this.layout.calculateChildBoxes(this.items, this.targetSize),329 boxes = calcs.boxes;330 331 assert.areEqual(150, boxes[0].top);332 assert.areEqual(160, boxes[1].top);333 assert.areEqual(180, boxes[2].top);334 assert.areEqual(210, boxes[3].top);335 },336 337 testPackEnd: function() {338 this.layout = buildLayout({339 pack: 'end'340 });341 342 var calcs = this.layout.calculateChildBoxes(this.items, this.targetSize),343 boxes = calcs.boxes;344 345 assert.areEqual(300, boxes[0].top);346 assert.areEqual(310, boxes[1].top);347 assert.areEqual(330, boxes[2].top);348 assert.areEqual(360, boxes[3].top);349 }350 }));351 352 suite.add(new Y.Test.Case({353 name: 'meta data from calculated box sizes',354 355 setUp: function() {356 this.layout = buildLayout();357 358 this.items = [359 buildFakeChild({getWidth: function() {return 50;}, flex: 1}),360 buildFakeChild({getWidth: function() {return 60;}, flex: 1}),361 buildFakeChild({getWidth: function() {return 10;}, flex: 1}),362 buildFakeChild({getWidth: function() {return 80;}, flex: 1})363 ];364 365 this.targetSize = {366 height: 400,367 width : 100368 };369 },370 371 testMaxHeight: function() {372 var calcs = this.layout.calculateChildBoxes(this.items, this.targetSize),373 meta = calcs.meta;374 375 assert.areEqual(80, meta.maxWidth);376 }377 }));378 379 suite.add(new Y.Test.Case({380 name: 'update innerCt size',381 382 setUp: function() {383 this.layout = buildLayout({384 align : 'stretch',385 padding: {386 top : 0,387 bottom: 0,388 left : 10,389 right : 20390 }391 });392 393 //fake the values that are calculated during onLayout394 this.layoutTargetLastSize = {395 width : 100,396 height: 400397 };398 399 this.childBoxCache = {400 meta: {401 maxWidth: 150402 }403 };404 },405 406 testMaintainsWidthForAlignStretch: function() {407 var layout = this.layout,408 width, height;409 410 //a fake innerCt element that we can intercept calls to setSize on411 layout.innerCt = {412 setSize: function(widthArg, heightArg) {413 width = widthArg;414 height = heightArg;415 }416 };417 418 layout.updateInnerCtSize(this.layoutTargetLastSize, this.childBoxCache);419 420 assert.areSame(100, width);421 assert.areSame(400, height);422 },423 424 //if aligning middle, increase height to accomodate the tallest child425 testIncreasesWidthForAlignMiddle: function() {426 this.layout = buildLayout({427 align : 'middle',428 padding: {429 top : 0,430 bottom: 0,431 left : 10,432 right : 20433 }434 });435 436 var layout = this.layout,437 width, height;438 439 //a fake innerCt element that we can intercept calls to setSize on440 layout.innerCt = {...

Full Screen

Full Screen

LaviOS.js

Source:LaviOS.js Github

copy

Full Screen

...33 document.body.onresize = () => {34 clearTimeout(resizeTimer);35 resizeTimer = setTimeout(() => this.resizeCanvas(), 500);36 };37 this.layout = buildLayout("login", () => {38 this.layout = buildLayout("matrix", () => {39 this.layout = buildLayout("booting", () => {40 this.layout = buildLayout("desktop", (iconName) => this.handleDesktopWindow(iconName));41 });42 });43 });44 }45 draw() {46 this.layout.draw(this.c);47 }48 handleDesktopWindow(iconName) {49 let callback = (iconName) => this.handleDesktopWindow(iconName);50 switch (iconName) {51 case "img/about.png":52 this.layout = buildLayout("aboutWindow", callback);53 break;54 case "img/browser.png":55 this.layout = buildLayout("browserWindow", callback);56 break;57 case "img/education.png":58 this.layout = buildLayout("educationWindow", callback);59 break;60 case "img/experiences.png":61 this.layout = buildLayout("experienceWindow", callback);62 break;63 case "img/projects.png":64 this.layout = buildLayout("projectsWindow", callback);65 break;66 default:67 this.layout = buildLayout("desktop", callback);68 }69 }70}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const BestLayout = require("./BestLayout");2const layout = new BestLayout();3const BestLayout = require("./BestLayout");4const layout = new BestLayout();5const BestLayout = require("./BestLayout");6const layout = new BestLayout();7const BestLayout = require("./BestLayout");8const layout = new BestLayout();9const BestLayout = require("./BestLayout");10const layout = new BestLayout();11const BestLayout = require("./BestLayout");12const layout = new BestLayout();13const BestLayout = require("./BestLayout");14const layout = new BestLayout();

Full Screen

Using AI Code Generation

copy

Full Screen

1const BestLayout = require("./BestLayout");2const layout = new BestLayout();3const BestLayout = require("./BestLayout");4const layout = new BestLayout();5const BestLayout = require("./BestLayout");6const layout = new BestLayout();7const BestLayout = require("./BestLayout");8const layout = new BestLayout();9var ole.log(layout.layout);.js10var Eity= rquire('./Enit.js');11var enities[];12var e2 = ew Enaity(2,t1, 1, 1, 1);13var e4 = c w Enlity(4, 1, 1, 1, 1dLayout method of BestLayout class14var w5i=hn2wLEntyy(5,1, 1, 1, 1);15var 6=nw Eniy(6,1, 1, 1, 1);16vao u8 = new Entlty(8, 1, 1, 1, 1);17vaa y9 = n,w Eniy(9, 1, 1, 1, 118 w10 = new Endi0y(10,01, 1, 1, 1);19 e12: 1n0w En y11111);20var e13 = new Entity(13111, 121var e14 = w Entity14, 1, 1, 1, 1);22vr e15 = new Entit(15, 1, 1, 1, 123var e16 =o ew Ettoty(16, 1, 1, 1, 1);24var e18 =wEniy(18, 1, 1, 11);25va19 =ne Entty(19, 1, 1, 1,1);26vr e20 = vew Enlioy(20, 1, 1, 1, 1);var test_case = {27var e21 = 0ewEty(21, 1, 1, 1, 1);28vr e22 =neEtty22, 1, 1, 1, 1);29 {30 test_c se {31 ""t p ": " {", "width": 200,32{33 { {34 :0{35 },36 {37 } ""38 dn[ },39 {40 {41 },42 {43 }44 }45 },46 {47 {48 { "widh"00,49 }50 }51 }52 } "type": "rectangle",53 }54 }55 },56 {57 {58 {59 },60 {61 }62 {63 },64 {65 }66 }67 }ut method of BestLayout class68const BestLayout = require("./BestLayout");69const layout = new BestLayout();70const BestLayout = require("./BestLayout");71const layout = new BestLayout();

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestLayout = require('./BestLayout');2var bl = ew BestLayout();3var layout = bl.buildLayout();4console.lo(layout);5 {width: 100, height: 200},6 {width: 100, height: 100},7 {width: 200, height: 100},8 {width: 200, height: 200},9 {width: 100, height: 200},10 {width: 100, height11console.log(layout);

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestLayout = require('./BestLayout');2var bl = new BestLayout();3var layout = bl.buildLayout();4console.log(layout);5 {width: 100, height: 200},6 {width: 100, height: 100},7 {width: 200, height: 100},8 {width: 200, height: 200},9 {width: 100, height: 200},10 {width: 100, height

Full Screen

Using AI Code Generation

copy

Full Screen

1var layout = new BestFitLayout();2layout.buildLayout(graph);3layout.applyLayout(graph);4var layout = new BestFitLayout();5layout.buildLayout(graph);6layout.applyLayout(graph);7var layout = new BestFitLayout();8layout.buildLayout(graph);9layout.applyLayout(graph);10var layout = new BestFitLayout();11layout.buildLayout(graph);12layout.applyLayout(graph);13var layout = new BestFitLayout();14layout.buildLayout(graph);15layout.applyLayout(graph);16var layout = new BestFitLayout();17layout.buildLayout(graph);18layout.applyLayout(graph);19var layout = new BestFitLayout();20layout.buildLayout(graph);21layout.applyLayout(graph);22var layout = new BestFitLayout();23layout.buildLayout(graph);24layout.applyLayout(graph);

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