jquery-bootstrap-modal-steps

WebJar for jquery-bootstrap-modal-steps

License

License

MIT
Categories

Categories

Github Development Tools Version Controls
GroupId

GroupId

org.webjars.bower
ArtifactId

ArtifactId

github-com-orige-jquery-bootstrap-modal-steps
Last Version

Last Version

0.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

jquery-bootstrap-modal-steps
WebJar for jquery-bootstrap-modal-steps
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/orige/jquery-bootstrap-modal-steps

Download github-com-orige-jquery-bootstrap-modal-steps

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bower/github-com-orige-jquery-bootstrap-modal-steps/ -->
<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>github-com-orige-jquery-bootstrap-modal-steps</artifactId>
    <version>0.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bower/github-com-orige-jquery-bootstrap-modal-steps/
implementation 'org.webjars.bower:github-com-orige-jquery-bootstrap-modal-steps:0.0.3'
// https://jarcasting.com/artifacts/org.webjars.bower/github-com-orige-jquery-bootstrap-modal-steps/
implementation ("org.webjars.bower:github-com-orige-jquery-bootstrap-modal-steps:0.0.3")
'org.webjars.bower:github-com-orige-jquery-bootstrap-modal-steps:jar:0.0.3'
<dependency org="org.webjars.bower" name="github-com-orige-jquery-bootstrap-modal-steps" rev="0.0.3">
  <artifact name="github-com-orige-jquery-bootstrap-modal-steps" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bower', module='github-com-orige-jquery-bootstrap-modal-steps', version='0.0.3')
)
libraryDependencies += "org.webjars.bower" % "github-com-orige-jquery-bootstrap-modal-steps" % "0.0.3"
[org.webjars.bower/github-com-orige-jquery-bootstrap-modal-steps "0.0.3"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.bower : jquery jar [2.1.1,2.2)
org.webjars.bower : bootstrap jar [3.3.0,3.4)

Project Modules

There are no modules declared in this project.

jquery-bootstrap-modal-steps

Lightweight step by step modal for bootstrap

What is this?

Sometimes you need break complex things in many parts. Forms, manuals, ideas. I like to thing that like steps. For example, if you need create a payment page. The first step is get the personal information from the client, then you need the payment information and after that you'll need the address for the shipment. This is not the correct order but works.

You can develop a big HTML form with all this stuff or ask to client in step by step.

What I need?

You'll need to know about bootstrap, html and a little bit of javascript. jQuery and Bootstrap must be installed in your project.

How to install

Using Bower:
$ bower install jquery-bootstrap-modal-steps

jQuery and Bootstrap are required so you need import them in your Html file before jquery-bootstrap-modal-steps:

<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/js/bootstrap.min.js"></script>

<script src="../dist/jquery-bootstrap-modal-steps.min.js"></script>

Configuring the Modal

Is pretty simple to work with Bootstrap modals. You can see more details here.

<div class="modal-header">
   <h4 class="js-title-step"></h4>
</div>

In your .modal-header you'll need use any Html tag with js-title-step class. I decide for H4 for estetic purposes. Don't put nothing inside this tag, the Javascript will do this.

After that, at the .modal-body you'll set the modal steps. Use a div tag with row and hide class. Set the step order using data-step and step title with data-title.

<div class="modal-body">
    <div class="row hide" data-step="1" data-title="This is the first step!">
        <div class="jumbotron">As you can see, this is the first step!</div>
    </div>
    <div class="row hide" data-step="2" data-title="This is the second and last step!">
        <div class="jumbotron">As you can see, this is the second and last step!</div>
    </div>
</div>

Now, you'll set the action buttons. All you need is use js-btn-step and data-orientation attribute. Use data-orientation="previous" for previous buttons, data-orientation="next" for next buttons, and data-orientation="cancel" for cancel buttons.

<div class="modal-footer">
    <button type="button" class="btn btn-default js-btn-step pull-left" data-orientation="cancel" data-dismiss="modal"></button>
    <button type="button" class="btn btn-warning js-btn-step" data-orientation="previous"></button>
    <button type="button" class="btn btn-success js-btn-step" data-orientation="next"></button>
</div>

Note you don't need set nothing inside the .js-btn-step.

Activate modals

You already have the modal, now you'll need activate it.

$('#modal-sample').modalSteps();

With this you can use steps with Bootstrap modals.

Don't forget that you need use a button to launch the Bootstrap modal. You can see more of this here

It's jQuery

You can use jQuery functions after modalSteps because this is a jQuery plugin (haha):

$('#modal-sample').modalSteps().find('#someDiv');

Callbacks

Using a callback when user complete modal's steps

You can set a callback when the user completes the modal steps.

var callback = function (){
    console.log('Congratulations!');
}
$('#modal-sample').modalSteps({
    completeCallback: callback
});

Callback for each step

When you need valid forms in each modal step, it's cool a callback for this

var callback = function (){
    console.log('Each step Callback!');
}
$('#modal-sample').modalSteps({
    callbacks: {
        '*': callback
    }
});

Callback for a specific step

Generally, you'll have a step pretty different of others and you must treat that. Use an specific callback for this. The key of the callback dictionary must be the step:

var callback1 = function (){
    console.log('A specific callback for step 1!');
};

var callback2 = function (){
    console.log('A specific callback for step 2!');
};

$('#modal-sample').modalSteps({
    callbacks: {
        '1': callback1,
        '2': callback2
    }
});

Customize buttons

The default values for buttons is:

Button Orientation Value
previous Previous
next Next
cancel Cancel
last Complete

How to replace?

$('#modal-sample').modalSteps({
    btnCancelHtml: 'Quit',
    btnPreviousHtml: 'Back',
    btnNextHtml: 'Go',
    btnLastStepHtml: 'Finish'
});

Disabling next buttons

For validations purposes, you can need block the next buttons:

$('#modal-sample').modalSteps({
    disableNextButton: true
});

You can see more examples in samples directory

Sorry for my bad english :D

Versions

Version
0.0.3