Skip to content

Commit dbd68ca

Browse files
authored
Merge pull request #150 from techlab/master
Latest fixes and corrections for v6.x
2 parents bd82649 + 942b428 commit dbd68ca

File tree

8 files changed

+120
-57
lines changed

8 files changed

+120
-57
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# These are supported funding model platforms
22

3-
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
3+
github: techlab
44
patreon: # Replace with a single Patreon username
55
open_collective: techlab
66
ko_fi: # Replace with a single Ko-fi username

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
CHANGELOG
22
=========
33

4+
5+
v6.0.5
6+
-----
7+
- **Fixed:** unDoneOnBackNavigation not working https://github.com/techlab/jquery-smartwizard/issues/146
8+
9+
v6.0.4
10+
-----
11+
- **Changed:** Code optimizations
12+
13+
v6.0.3
14+
-----
15+
- **Fixed:** Navigation not properly maintained when navigate fast
16+
- **Changed:** Code optimizations
17+
418
v6.0.1
519
-----
620
- **Added:** Support for jQuery Slim version

README.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,36 @@ Installation
7070
<script src="https://unpkg.com/smartwizard@6/dist/js/jquery.smartWizard.min.js" type="text/javascript"></script>
7171
```
7272

73+
### Common JS/Webpack
74+
```js
75+
var $ = require( "jquery" );
76+
require( "smartwizard/dist/css/smart_wizard_all.css");
77+
const smartWizard = require("smartwizard");
78+
79+
$(function() {
80+
$('#smartwizard').smartWizard();
81+
});
82+
```
83+
### ES6/Babel
84+
```js
85+
import $ from "jquery";
86+
import "smartwizard/dist/css/smart_wizard_all.css";
87+
import smartWizard from 'smartwizard';
88+
89+
$(function() {
90+
$('#smartwizard').smartWizard();
91+
});
92+
```
93+
94+
#### Note: you may have to install the required dependencies
95+
```bash
96+
npm i jquery
97+
npm i smartwizard
98+
99+
// If you are using Webpack, install
100+
npm i webpack webpack-cli style-loader css-loader --save-dev
101+
```
102+
73103
### Download
74104
#### [Download from GitHub](https://github.com/techlab/jquery-smartwizard/archive/master.zip)
75105

@@ -169,14 +199,10 @@ Include SmartWizard plugin JavaScript
169199
<script src="https://cdn.jsdelivr.net/npm/smartwizard@6/dist/js/jquery.smartWizard.min.js" type="text/javascript"></script>
170200
```
171201
Initialize the SmartWizard
172-
```html
173-
<script type="text/javascript">
174-
$(document).ready(function() {
175-
202+
```js
203+
$(function() {
176204
$('#smartwizard').smartWizard();
177-
178205
});
179-
</script>
180206
```
181207
That's it!
182208

dist/js/jquery.smartWizard.js

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
99
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1010

1111
/*!
12-
* jQuery SmartWizard v6.0.1
12+
* jQuery SmartWizard v6.0.5
1313
* The awesome step wizard plugin for jQuery
1414
* http://www.techlaboratory.net/jquery-smartwizard
1515
*
@@ -51,7 +51,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
5151
selected: 0,
5252
// Initial selected step, 0 = first step
5353
theme: 'basic',
54-
// theme for the wizard, related css need to include for other than default theme
54+
// Theme for the wizard, related css need to include for other than default theme
5555
justified: true,
5656
// Nav menu justification. true/false
5757
autoAdjustHeight: true,
@@ -282,12 +282,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
282282
value: function _setElements() {
283283
var _this2 = this;
284284

285-
// Set the main element
286-
this.main.addClass(this.options.style.mainCss); // Set theme option
287-
285+
// Set the main element classes including theme css
288286
this.main.removeClass(function (i, className) {
289-
return (className.match(/(^|\s)sw-theme-\S+/g) || []).join(' ');
290-
}).addClass(this.options.style.themePrefixCss + this.options.theme); // Set justify option
287+
return (className.match(new RegExp('(^|\\s)' + _this2.options.style.themePrefixCss + '\\S+', 'g')) || []).join(' ');
288+
}).addClass(this.options.style.mainCss + ' ' + this.options.style.themePrefixCss + this.options.theme); // Set justify option
291289

292290
this.main.toggleClass(this.options.style.justifiedCss, this.options.justified); // Set the anchor default style
293291

@@ -442,20 +440,20 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
442440

443441

444442
_this4._transit(selPage, curPage, stepDirection, function () {
445-
// Update the current index
446-
_this4.current_index = idx; // Fix height with content
443+
// Fix height with content
444+
_this4._fixHeight(idx); // Trigger "showStep" event
447445

448-
_this4._fixHeight(idx); // Set the buttons based on the step
449446

447+
_this4._triggerEvent("showStep", [selStep, idx, stepDirection, _this4._getStepPosition(idx)]);
448+
}); // Update the current index
450449

451-
_this4._setButtons(idx); // Set the progressbar based on the step
452450

451+
_this4.current_index = idx; // Set the buttons based on the step
453452

454-
_this4._setProgressbar(idx); // Trigger "showStep" event
453+
_this4._setButtons(idx); // Set the progressbar based on the step
455454

456455

457-
_this4._triggerEvent("showStep", [selStep, idx, stepDirection, _this4._getStepPosition(idx)]);
458-
});
456+
_this4._setProgressbar(idx);
459457
});
460458
}
461459
}, {
@@ -560,6 +558,8 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
560558
value: function _transit(elmToShow, elmToHide, stepDirection, callback) {
561559
var transitFn = $.fn.smartWizard.transitions[this.options.transition.animation];
562560

561+
this._stopAnimations();
562+
563563
if ($.isFunction(transitFn)) {
564564
transitFn(elmToShow, elmToHide, stepDirection, this, function (res) {
565565
if (res === false) {
@@ -575,6 +575,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
575575
callback();
576576
}
577577
}
578+
}, {
579+
key: "_stopAnimations",
580+
value: function _stopAnimations() {
581+
if ($.isFunction(this.container.finish)) {
582+
this.pages.finish();
583+
this.container.finish();
584+
}
585+
}
578586
}, {
579587
key: "_fixHeight",
580588
value: function _fixHeight(idx) {
@@ -596,19 +604,23 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
596604
key: "_setAnchor",
597605
value: function _setAnchor(idx) {
598606
// Current step anchor > Remove other classes and add done class
599-
this.steps.eq(this.current_index).removeClass(this.options.style.anchorActiveCss);
607+
if (this.current_index !== null && this.current_index >= 0) {
608+
var removeCss = this.options.style.anchorActiveCss;
609+
var addCss = '';
600610

601-
if (this.options.anchor.enableDoneState !== false && this.current_index !== null && this.current_index >= 0) {
602-
this.steps.eq(this.current_index).addClass(this.options.style.anchorDoneCss);
611+
if (this.options.anchor.enableDoneState !== false) {
612+
addCss += this.options.style.anchorDoneCss;
603613

604-
if (this.options.anchor.unDoneOnBackNavigation !== false && this._getStepDirection(idx) === 'backward') {
605-
this.steps.eq(this.current_index).removeClass(this.options.style.anchorDoneCss);
614+
if (this.options.anchor.unDoneOnBackNavigation !== false && this._getStepDirection(idx) === 'backward') {
615+
removeCss += ' ' + this.options.style.anchorDoneCss;
616+
}
606617
}
618+
619+
this.steps.eq(this.current_index).addClass(addCss).removeClass(removeCss);
607620
} // Next step anchor > Remove other classes and add active class
608621

609622

610-
this.steps.eq(idx).removeClass(this.options.style.anchorDoneCss);
611-
this.steps.eq(idx).addClass(this.options.style.anchorActiveCss);
623+
this.steps.eq(idx).removeClass(this.options.style.anchorDoneCss).addClass(this.options.style.anchorActiveCss);
612624
}
613625
}, {
614626
key: "_setButtons",

0 commit comments

Comments
 (0)