Skip to content

Commit

Permalink
upd wizard, add startPage property
Browse files Browse the repository at this point in the history
  • Loading branch information
olton committed Jan 8, 2015
1 parent 99bc898 commit 0bbeb87
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 23 deletions.
2 changes: 1 addition & 1 deletion docs/js/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ $(window).scroll(function(){
headerPosition();
});

METRO_AUTO_REINIT = true;
//METRO_AUTO_REINIT = true;
17 changes: 9 additions & 8 deletions docs/js/metro.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions docs/js/metro/metro-stepper.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
});
},

stepTo: function(step){
this._stepTo(step);
},

first: function(){
var o = this.options;
o.start = 1;
Expand Down
39 changes: 36 additions & 3 deletions docs/js/metro/metro-wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
options: {
stepper: true,
stepperType: 'default',
startPage: 'default',
locale: $.Metro.currentLocale,
finishStep: 'default',
buttons: {
Expand Down Expand Up @@ -36,13 +37,20 @@
this._steps = steps;

if (o.stepper) {
this._stepper = this._createStepper(steps.length).insertBefore(element.find('.steps'));
this._stepper = this._createStepper(steps.length).insertBefore(element.find('.steps')).stepper();
}

if (element.data('locale') != undefined) o.locale = element.data('locale');

this._createEvents();

if (o.startPage != 'default' && parseInt(o.startPage) > 1) {
//if (this._stepper != undefined) this._stepper.stepper('stepTo', o.startPage);
this.stepTo(o.startPage);
}

this.options.onPage(this._currentStep + 1, element);

},

_createStepper: function(steps){
Expand Down Expand Up @@ -104,7 +112,7 @@
$(this._steps[new_step]).show();

this.options.onPage(this._currentStep + 1, this.element);
this._stepper.stepper('next');
this._stepper.stepper('stepTo', this._currentStep + 1);

var finish = parseInt(this.options.finishStep == 'default' ? this._steps.length - 1 : this.options.finishStep);
if (new_step == finish) {
Expand All @@ -125,7 +133,28 @@
$(this._steps[new_step]).show();

this.options.onPage(this._currentStep + 1, this.element);
this._stepper.stepper('prior');
this._stepper.stepper('stepTo', this._currentStep + 1);

var finish = parseInt(this.options.finishStep == 'default' ? this._steps.length - 1 : this.options.finishStep);
if (new_step == finish) {
this.element.find('.btn-finish').attr('disabled', false);
} else {
this.element.find('.btn-finish').attr('disabled', true);
}

return true;
},

stepTo: function(step){
var new_step = step - 1;

if (new_step < 0) return false;
this._currentStep = new_step;
this._steps.hide();
$(this._steps[new_step]).show();

this.options.onPage(this._currentStep + 1, this.element);
if (this._stepper != undefined) this._stepper.stepper('stepTo', step);

var finish = parseInt(this.options.finishStep == 'default' ? this._steps.length - 1 : this.options.finishStep);
if (new_step == finish) {
Expand All @@ -137,6 +166,10 @@
return true;
},

stepper: function(){
return this._stepper;
},

_destroy: function(){
},

Expand Down
2 changes: 2 additions & 0 deletions docs/wizard.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ <h1>
$(function(){
$('#wizard').wizard({
locale: 'en',
startPage: 2,
onCancel: function(){
$.Dialog({
title: 'Wizard',
Expand Down Expand Up @@ -96,6 +97,7 @@ <h3>JavaScript</h3>
$('#wizard').wizard({
stepper: true, // show stepper, see http://metroui.org.ua/stepper.html
stepperType: 'default', // stepper type, see http://metroui.org.ua/stepper.html
startPage: 'default', // if this value ne 'default' wizard started from this page
locale: $.Metro.currentLocale, //'en', 'ua', 'ru', ... more languages defined in metro-locale.js
finishStep: 'default', // 'default' - last page or int - number of page
buttons: { //show or hide buttons
Expand Down
4 changes: 4 additions & 0 deletions js/metro-stepper.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
});
},

stepTo: function(step){
this._stepTo(step);
},

first: function(){
var o = this.options;
o.start = 1;
Expand Down
Loading

0 comments on commit 0bbeb87

Please sign in to comment.