-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[AMS] Merle Jansen #727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jurlem
wants to merge
1
commit into
ironhack-labs:master
Choose a base branch
from
jurlem:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[AMS] Merle Jansen #727
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,78 @@ | ||
| // Write your Pizza Builder JavaScript in this file. | ||
|
|
||
| // to make a tomato sauce as default, toggle it first to OFF: | ||
| //to make crust to be dafault | ||
| $('.sauce').toggleClass('sauce-white'); | ||
| $('.crust').toggleClass('crust-gluten-free'); | ||
| $('.price-wsauce').toggle(); | ||
| $('.price-glut').toggle(); | ||
|
|
||
| //price of a plain pizza, displayed in #sum: | ||
| var sum = 13; | ||
| $('#sum').html(sum); | ||
|
|
||
| //pepperoni toggel | ||
| //$(".selector").toggleClass(className) | ||
| $('.btn-pepperonni').click(function(){ | ||
| $('.pep').toggle(); | ||
| $(this).toggleClass("active"); | ||
| $('.price-pep').toggle(); | ||
| if ($('.btn-pepperonni').hasClass('active')) { | ||
| sum += 1; | ||
| } else { | ||
| sum -=1; | ||
| } | ||
| }) | ||
|
|
||
| //mushroom toggel | ||
| $('.btn-mushrooms').click(function(){ | ||
| $('.mushroom').toggle(); | ||
| $(this).toggleClass("active"); | ||
| $('.price-mush').toggle(); | ||
| if ($('.btn-mushrooms').hasClass('active')) { | ||
| sum += 1; | ||
| } else { | ||
| sum -=1; | ||
| } | ||
| }) | ||
|
|
||
| //green-pepper toggel | ||
| $('.btn-green-peppers').click(function(){ | ||
| $('.green-pepper').toggle(); | ||
| $(this).toggleClass("active"); | ||
| $('.price-green').toggle(); | ||
|
|
||
| if ($('.btn-green-peppers').hasClass('active')) { | ||
| sum += 1; | ||
| } else { | ||
| sum -=1; | ||
| } | ||
| }) | ||
|
|
||
| // choose white sauce | ||
| $('.btn-sauce ').click(function(){ | ||
| $('.sauce').toggleClass('sauce-white'); | ||
| $(this).toggleClass("active"); | ||
| $('.price-wsauce').toggle(); | ||
| if ($('.btn-sauce ').hasClass('active')) { | ||
| sum += 3; | ||
| } else { | ||
| sum -=3; | ||
| } | ||
| }) | ||
|
|
||
| // choose gluten-free | ||
| $('.btn-crust').click(function(){ | ||
| $('.crust').toggleClass('crust-gluten-free'); | ||
| $(this).toggleClass("active"); | ||
| $('.price-glut').toggle(); | ||
| if ($('.btn-crust').hasClass('active')) { | ||
| sum += 5; | ||
| } else { | ||
| sum -=5; | ||
| } | ||
| }) | ||
| //funtion to calc total sum, on each btn pressing | ||
| $('.btn').click(function(){ | ||
| $('#sum').html(sum); | ||
| }) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it might be useful here to create two functions that could help you avoid duplicate code:
e.g.
calculatePrice()andtoggleIngredient()for example. A function likesetupDefaultToppings()might also be handy in terms of readability. Then the challenge is, how can you define and organize your classes to be able to do these things for every ingredient with one function?