Created
June 17, 2019 08:28
-
-
Save Slinjez/7808c14ae69e03f5ecdf22f5af6b8c8d to your computer and use it in GitHub Desktop.
Wizard
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
<div class="wizard"> | |
<div data-title="Advert Basics" class="wizardPanel"> | |
<h1>Advert Basics</h1> | |
<div class="row"> | |
<div class="col-sm-3">Company</div> | |
<div class="col-sm-9"><input/></div> | |
</div> | |
<div class="row"> | |
<div class="col-sm-3">Manager(s)</div> | |
<div class="col-sm-9"><input/></div> | |
</div> | |
<div class="row"> | |
<div class="col-sm-3">Applicant Journey</div> | |
<div class="col-sm-9"><input/></div> | |
</div> | |
</div> | |
<div data-title="Posting Options" class="wizardPanel"> | |
<h1>Posting Options</h1> | |
</div> | |
<div data-title="Preview & Submit" class="wizardPanel"> | |
<h1>Advert Created</h1> | |
</div> | |
<div data-title="Complete" class="wizardPanel"> | |
<h1>Complete</h1> | |
</div> | |
</div> | |
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
$(".wizard").each(function() { | |
var index = 0; | |
var wizard = $(this); | |
$(wizard).prepend('<div class="wizardProgress"></div>'); | |
$(wizard).prepend('<div class="header"></div>'); | |
$(wizard).addClass("loadingparent"); | |
$(wizard).prepend('<div class="loading center"></div>'); | |
$(wizard) | |
.find(".wizardPanel") | |
.each(function() { | |
$(wizard) | |
.find(".wizardProgress") | |
.append("<div>" + $(this).data("title") + "</div>"); | |
}); | |
$(wizard) | |
.find(".wizardProgress div") | |
.click(function() { | |
selectPanel($(this).index()); | |
}); | |
$(wizard).append( | |
'<div class="footer"><button id="btnPrev" class="btn btn-default">Prev</button><button id="btnNext" class="btn btn-primary">Next</button></div>' | |
); | |
$(wizard) | |
.find("#btnPrev") | |
.click(function() { | |
selectPanel($(".wizardProgress .selected").index() - 1); | |
}); | |
$(wizard) | |
.find("#btnNext") | |
.click(function() { | |
selectPanel($(".wizardProgress .selected").index() + 1); | |
}); | |
selectPanel(0); | |
function selectPanel(index) { | |
$(wizard) | |
.find(".loading") | |
.fadeIn(); | |
setTimeout(function() { | |
$(wizard) | |
.find(".loading") | |
.fadeOut(); | |
if (index == 0) { | |
$(wizard) | |
.find("#btnPrev") | |
.fadeOut(); | |
} else { | |
$(wizard) | |
.find("#btnPrev") | |
.fadeIn(); | |
} | |
if (index == $(".wizardProgress div").length - 1) { | |
$(wizard) | |
.find("#btnNext") | |
.fadeOut(); | |
} else { | |
$(wizard) | |
.find("#btnNext") | |
.fadeIn(); | |
} | |
$(".wizardProgress .selected").removeClass("selected"); | |
var selectedTab = $(".wizardProgress div").get(index); | |
$(selectedTab).addClass("selected"); | |
$(".wizardPanel").slideUp(); | |
var selectedPanel = $(wizard) | |
.find(".wizardPanel") | |
.get(index); | |
$(selectedPanel).slideDown(); | |
}, 2000); | |
} | |
}); |
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
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> |
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
body { | |
margin: 20px; | |
} | |
.wizard { | |
border: 1px solid rgba(0, 0, 0, 0.2); | |
max-width: 700px; | |
margin: auto; | |
border-radius: 5px; | |
} | |
.wizard .wizardProgress { | |
border-bottom: 1px solid rgba(0, 0, 0, 0.2); | |
display: flex; | |
text-align: center; | |
} | |
.wizard .wizardProgress div { | |
width: 100%; | |
padding: 10px; | |
background: rgba(0, 0, 0, 0.05); | |
cursor: pointer; | |
counter-increment: tabs; | |
} | |
.wizard .wizardProgress div:hover { | |
background: rgba(0, 0, 0, 0.1); | |
vertical-align: middle; | |
} | |
.wizard .wizardProgress div:before { | |
content: counters(tabs, ".") " "; | |
display: inline-block; | |
padding: 0 10px; | |
margin-right: 5px; | |
background: rgba(0, 0, 0, 0.1); | |
border-radius: 10px; | |
} | |
.wizard .wizardProgress div:after { | |
content: ""; | |
height: 0; | |
border: 50% solid green; | |
display: block; | |
} | |
.wizard .wizardProgress div.selected { | |
background: rgba(0, 0, 0, 0.1); | |
} | |
.wizard .wizardPanel { | |
display: none; | |
} | |
.wizard .wizardPanel { | |
padding: 10px 0 20px 0; | |
} | |
.wizard .footer { | |
text-align: right; | |
padding: 10px; | |
border-top: 1px solid rgba(0, 0, 0, 0.2); | |
} | |
.wizard .row { | |
padding: 10px; | |
} | |
.wizard input { | |
width: 100%; | |
} | |
.wizard .btn { | |
margin-left: 10px; | |
} | |
.wizard h1 { | |
padding: 10px; | |
font-size: x-large; | |
font-weight: lighter; | |
} | |
.loadingparent { | |
position: relative; | |
} | |
.loadingparent .loading { | |
display: none; | |
background: #fff; | |
position: absolute; | |
top: 0; | |
bottom: 0; | |
left: 0; | |
right: 0; | |
z-index: 1000; | |
opacity: 0.5; | |
} | |
.loading:before { | |
content: " "; | |
position: absolute; | |
top: 50px; | |
left: calc(50% - 25px); | |
width: 50px; | |
height: 50px; | |
-webkit-border-radius: 50px; | |
-moz-border-radius: 50px; | |
border-radius: 50px; | |
border: 3px solid transparent; | |
border-top: 3px solid #999; | |
border-bottom: 3px solid #999; | |
-webkit-box-sizing: border-box; | |
-moz-box-sizing: border-box; | |
box-sizing: border-box; | |
-webkit-animation: spinner 1s infinite linear; | |
animation: spinner 1s infinite linear; | |
} | |
.loading.center:before { | |
top: calc(50% - 25px); | |
left: calc(50% - 25px); | |
} | |
@keyframes spinner { | |
to { | |
transform: rotate(360deg); | |
} | |
} | |
@-moz-keyframes spinner { | |
to { | |
-moz-transform: rotate(360deg); | |
} | |
} | |
@-webkit-keyframes spinner { | |
to { | |
-webkit-transform: rotate(360deg); | |
} | |
} |
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
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment