From c02528dbe3a24d7d3f1c54befcece535d32c918e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eva=20Franc=C3=A9s?= Date: Wed, 13 Feb 2019 17:01:00 +0100 Subject: [PATCH 1/3] falta calcular precio final --- starter-code/index.html | 14 +++++---- starter-code/js/pizza.js | 68 ++++++++++++++++++++++++++++++++++++++++ starter-code/pizza.css | 22 ++++++++++--- starter-code/pizza.js | 1 - 4 files changed, 94 insertions(+), 11 deletions(-) create mode 100755 starter-code/js/pizza.js delete mode 100755 starter-code/pizza.js diff --git a/starter-code/index.html b/starter-code/index.html index 189a3311..d776755e 100755 --- a/starter-code/index.html +++ b/starter-code/index.html @@ -3,6 +3,8 @@ Pizza Builder + + @@ -41,11 +43,11 @@

Your pizza's price

$10 cheese pizza $21 @@ -290,6 +292,6 @@

Your pizza's price

- + diff --git a/starter-code/js/pizza.js b/starter-code/js/pizza.js new file mode 100755 index 00000000..d24f947d --- /dev/null +++ b/starter-code/js/pizza.js @@ -0,0 +1,68 @@ +// Write your Pizza Builder JavaScript in this file. +$(document).ready(function() { + //elegimos ingredientes, ingrediente-botón activo ||no ingrediente-no activo + $(".btn-pepperonni").click(function(event){ + if ($(".pep").hasClass("pep-index")) { + $(".pep").removeClass("pep-index") && $(".price li:nth-child(1)").removeClass("visible"); + $(".btn-pepperonni").removeClass("active") + + } else { + $(".pep").addClass("pep-index") && $(".price li:nth-child(1)").addClass("visible"); + $(".btn-pepperonni").addClass("active") + } + + }) + + $(".btn-mushrooms").click(function(event){ + if ($(".mushroom").hasClass("mushroom-index")) { + $(".mushroom").removeClass("mushroom-index") && $(".price li:nth-child(2)").removeClass("visible"); + $(".btn-mushrooms").removeClass("active") + } else { + $(".mushroom").addClass("mushroom-index") && $(".price li:nth-child(2)").addClass("visible"); + $(".btn-mushrooms").addClass("active") + } + }) + + $(".btn-green-peppers").click(function(event){ + if ($(".green-pepper").hasClass("green-pepper-index")) { + $(".green-pepper").removeClass("green-pepper-index") && $(".price li:nth-child(3)").removeClass("visible"); + $(".btn-green-peppers").removeClass("active") + } else { + $(".green-pepper").addClass("green-pepper-index") && $(".price li:nth-child(3)").addClass("visible"); + $(".btn-green-peppers").addClass("active") + } + }) + + $(".btn-crust").click(function(event){ + if ($(".crust").hasClass("crust-gluten-free")) { + $(".crust").removeClass("crust-gluten-free") && $(".price li:nth-child(4)").removeClass("visible"); + $(".btn-crust").removeClass("active") + } else { + $(".crust").addClass("crust-gluten-free") && $(".price li:nth-child(4)").addClass("visible"); + $(".btn-crust").addClass("active") + } + }) + + $(".btn-sauce").click(function(event){ + if ($(".sauce").hasClass("sauce-white")) { + $(".sauce").removeClass("sauce-white") && $(".price li:nth-child(5)").removeClass("visible"); + $(".btn-sauce").removeClass("active") + } else { + $(".sauce").addClass("sauce-white") && $(".price li:nth-child(5)").addClass("visible"); + $(".btn-sauce").addClass("active") + } + }) + + + // Total price + var sumPrice = document.getElementsByClassName('ingredients'); + var whatPrice = []; + var calculatePrice = 0; + for(i=0; i Date: Fri, 15 Feb 2019 14:27:48 +0100 Subject: [PATCH 2/3] terminado --- starter-code/index.html | 6 +++--- starter-code/js/pizza.js | 33 ++++++++++++++++++++++----------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/starter-code/index.html b/starter-code/index.html index d776755e..c401172e 100755 --- a/starter-code/index.html +++ b/starter-code/index.html @@ -49,7 +49,7 @@

Your pizza's price

  • $3 white sauce
  • $5 gluten-free crust
  • - $21 + $21 @@ -270,9 +270,9 @@

    Your pizza's price

    31
    33
    -
    +
    -
    +
    diff --git a/starter-code/js/pizza.js b/starter-code/js/pizza.js index d24f947d..cf742051 100755 --- a/starter-code/js/pizza.js +++ b/starter-code/js/pizza.js @@ -1,14 +1,24 @@ // Write your Pizza Builder JavaScript in this file. $(document).ready(function() { + + + var sumPrice = document.getElementsByClassName('ingredients'); + var totalPrice = document.querySelector('.totalPrice'); + var calculatePrice = 0; + //elegimos ingredientes, ingrediente-botón activo ||no ingrediente-no activo + $(".btn").removeClass("active") + $(".btn-pepperonni").click(function(event){ if ($(".pep").hasClass("pep-index")) { $(".pep").removeClass("pep-index") && $(".price li:nth-child(1)").removeClass("visible"); $(".btn-pepperonni").removeClass("active") + totalPrice.innerHTML = calculatePrice -= 1; } else { $(".pep").addClass("pep-index") && $(".price li:nth-child(1)").addClass("visible"); $(".btn-pepperonni").addClass("active") + totalPrice.innerHTML = calculatePrice += 1; } }) @@ -17,9 +27,12 @@ $(document).ready(function() { if ($(".mushroom").hasClass("mushroom-index")) { $(".mushroom").removeClass("mushroom-index") && $(".price li:nth-child(2)").removeClass("visible"); $(".btn-mushrooms").removeClass("active") + totalPrice.innerHTML = calculatePrice -= 1; + } else { $(".mushroom").addClass("mushroom-index") && $(".price li:nth-child(2)").addClass("visible"); $(".btn-mushrooms").addClass("active") + totalPrice.innerHTML = calculatePrice += 1; } }) @@ -27,9 +40,12 @@ $(document).ready(function() { if ($(".green-pepper").hasClass("green-pepper-index")) { $(".green-pepper").removeClass("green-pepper-index") && $(".price li:nth-child(3)").removeClass("visible"); $(".btn-green-peppers").removeClass("active") + totalPrice.innerHTML = calculatePrice -= 1; + } else { $(".green-pepper").addClass("green-pepper-index") && $(".price li:nth-child(3)").addClass("visible"); $(".btn-green-peppers").addClass("active") + totalPrice.innerHTML = calculatePrice += 1; } }) @@ -37,9 +53,12 @@ $(document).ready(function() { if ($(".crust").hasClass("crust-gluten-free")) { $(".crust").removeClass("crust-gluten-free") && $(".price li:nth-child(4)").removeClass("visible"); $(".btn-crust").removeClass("active") + totalPrice.innerHTML = calculatePrice -= 5; + } else { $(".crust").addClass("crust-gluten-free") && $(".price li:nth-child(4)").addClass("visible"); $(".btn-crust").addClass("active") + totalPrice.innerHTML = calculatePrice += 5; } }) @@ -47,22 +66,14 @@ $(document).ready(function() { if ($(".sauce").hasClass("sauce-white")) { $(".sauce").removeClass("sauce-white") && $(".price li:nth-child(5)").removeClass("visible"); $(".btn-sauce").removeClass("active") + totalPrice.innerHTML = calculatePrice -= 3; + } else { $(".sauce").addClass("sauce-white") && $(".price li:nth-child(5)").addClass("visible"); $(".btn-sauce").addClass("active") + totalPrice.innerHTML = calculatePrice += 3; } }) - - // Total price - var sumPrice = document.getElementsByClassName('ingredients'); - var whatPrice = []; - var calculatePrice = 0; - for(i=0; i Date: Fri, 15 Feb 2019 14:49:06 +0100 Subject: [PATCH 3/3] este terminado --- starter-code/index.html | 7 ++++--- starter-code/js/pizza.js | 26 ++++++++++++++------------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/starter-code/index.html b/starter-code/index.html index c401172e..0f5e729b 100755 --- a/starter-code/index.html +++ b/starter-code/index.html @@ -28,11 +28,12 @@

    Pizza Builder

  • - +
  • - +
  • + @@ -46,8 +47,8 @@

    Your pizza's price

  • $1 pepperonni
  • $1 mushrooms
  • $1 green peppers
  • -
  • $3 white sauce
  • $5 gluten-free crust
  • +
  • $3 white sauce
  • $21 diff --git a/starter-code/js/pizza.js b/starter-code/js/pizza.js index cf742051..9c72af00 100755 --- a/starter-code/js/pizza.js +++ b/starter-code/js/pizza.js @@ -49,6 +49,19 @@ $(document).ready(function() { } }) + $(".btn-sauce").click(function(event){ + if ($(".sauce").hasClass("sauce-white")) { + $(".sauce").removeClass("sauce-white") && $(".price li:nth-child(5)").removeClass("visible"); + $(".btn-sauce").removeClass("active") + totalPrice.innerHTML = calculatePrice -= 3; + + } else { + $(".sauce").addClass("sauce-white") && $(".price li:nth-child(5)").addClass("visible"); + $(".btn-sauce").addClass("active") + totalPrice.innerHTML = calculatePrice += 3; + } + }) + $(".btn-crust").click(function(event){ if ($(".crust").hasClass("crust-gluten-free")) { $(".crust").removeClass("crust-gluten-free") && $(".price li:nth-child(4)").removeClass("visible"); @@ -62,18 +75,7 @@ $(document).ready(function() { } }) - $(".btn-sauce").click(function(event){ - if ($(".sauce").hasClass("sauce-white")) { - $(".sauce").removeClass("sauce-white") && $(".price li:nth-child(5)").removeClass("visible"); - $(".btn-sauce").removeClass("active") - totalPrice.innerHTML = calculatePrice -= 3; - - } else { - $(".sauce").addClass("sauce-white") && $(".price li:nth-child(5)").addClass("visible"); - $(".btn-sauce").addClass("active") - totalPrice.innerHTML = calculatePrice += 3; - } - }) + });