Skip to content
This repository has been archived by the owner on Aug 15, 2019. It is now read-only.

moved button labels into settings #12

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ The full set of options is as follows:
'navigationFunction': function(pages){}, // a function that generates the nav, receives array of pages
'stateFunction': function(page){}, // a function that shows what page the user is viewing, receives current page #
'transitionFunction': function(from,to){} // a function that transitions from one page $(from) to another $(to)
'validatePageFunction': function(page){} // a function that can prevent transition by returning false
});


Expand Down
37 changes: 20 additions & 17 deletions jquery.multipage.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@


jQuery.fn.gotopage = function(page) {
$(id + '_nav .multipage_next').html('Next');
$(id + '_nav .multipage_next').html(settings.nextLabel);

if (isNaN(page)) {
q = page;
Expand Down Expand Up @@ -76,9 +76,9 @@
$(id + '_nav .multipage_back').hide();
$(id + '_nav .multipage_next').show();
if (settings.pages[page].title) {
$(id + '_nav .multipage_next').html('Next: ' + settings.pages[page].title);
$(id + '_nav .multipage_next').html(settings.nextLabel + ': ' + settings.pages[page].title);
} else {
$(id + '_nav .multipage_next').html('Next');
$(id + '_nav .multipage_next').html(settings.nextLabel);
}

} else if (page==settings.pages.length) {
Expand All @@ -87,24 +87,24 @@
$(id + '_nav .multipage_next').show();

if (settings.pages[page-2].title) {
$(id + '_nav .multipage_back').html('Back: ' + settings.pages[page-2].title);
$(id + '_nav .multipage_back').html(settings.backLabel + ': ' + settings.pages[page-2].title);
} else {
$(id + '_nav .multipage_back').html('Back');
$(id + '_nav .multipage_back').html(settings.backLabel);
}

$(id + '_nav .multipage_next').addClass('submit');
$(id + '_nav .multipage_next').html(settings.submitLabel);

} else {
if (settings.pages[page-2].title) {
$(id + '_nav .multipage_back').html('Back: ' + settings.pages[page-2].title);
$(id + '_nav .multipage_back').html(settings.backLabel + ': ' + settings.pages[page-2].title);
} else {
$(id + '_nav .multipage_back').html('Back');
$(id + '_nav .multipage_back').html(settings.backLabel);
}
if (settings.pages[page].title) {
$(id + '_nav .multipage_next').html('Next: ' + settings.pages[page].title);
$(id + '_nav .multipage_next').html(settings.nextLabel + ': ' + settings.pages[page].title);
} else {
$(id + '_nav .multipage_next').html('Next');
$(id + '_nav .multipage_next').html(settings.nextLabel);
}

$(id + '_nav .multipage_back').show();
Expand All @@ -118,9 +118,13 @@

}

jQuery.fn.validatePage = function(page) {
return true;
}
jQuery.fn.validatePage = function(page) {
if (settings.validatePageFunction) {
return settings.validatePageFunction(page);
} else {
return true;
}
}


jQuery.fn.validateAll = function() {
Expand Down Expand Up @@ -180,8 +184,7 @@


jQuery.fn.multipage = function(options) {

settings = jQuery.extend({stayLinkable:false,submitLabel:'Submit',hideLegend:false,hideSubmit:true,generateNavigation:true,activeDot:' ●',inactiveDot:' ·'},options);
settings = jQuery.extend({stayLinkable:false,submitLabel:'Submit',nextLabel:'Next',backLabel:'Back',hideLegend:false,hideSubmit:true,generateNavigation:true,activeDot:' ●',inactiveDot:' ·'},options);
id = '#' + $(this).attr('id');
var form = $(this);

Expand All @@ -196,11 +199,11 @@
// hide all the pages
$(id +' fieldset').hide();
if (settings.hideSubmit) {
$(id+' input[type="submit"]').hide();
$(id+' *[type="submit"]').hide();
}

if ($(id+' input[type="submit"]').val()!='') {
settings.submitLabel = $(id+' input[type="submit"]').val();
if ($(id+' *[type="submit"]').val()!='') {
settings.submitLabel = $(id+' *[type="submit"]').val();
}

settings.pages = new Array();
Expand Down