From 0379e427eedc91c58161162e32a7d7accd3f621c Mon Sep 17 00:00:00 2001 From: Gerrit Garbereder Date: Sun, 31 Aug 2014 14:03:26 +0200 Subject: [PATCH 1/3] moved button labels into settings --- jquery.multipage.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) mode change 100644 => 100755 jquery.multipage.js diff --git a/jquery.multipage.js b/jquery.multipage.js old mode 100644 new mode 100755 index 7be5bf8..c5f2ff6 --- a/jquery.multipage.js +++ b/jquery.multipage.js @@ -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; @@ -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) { @@ -87,9 +87,9 @@ $(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'); @@ -97,14 +97,14 @@ } 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(); @@ -180,8 +180,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); From 645303d691942292e7f578af3123ce74f21f9ded Mon Sep 17 00:00:00 2001 From: Gerrit Garbereder Date: Sun, 31 Aug 2014 14:14:20 +0200 Subject: [PATCH 2/3] recognize also buttons from type submit --- jquery.multipage.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jquery.multipage.js b/jquery.multipage.js index c5f2ff6..b92f0a0 100755 --- a/jquery.multipage.js +++ b/jquery.multipage.js @@ -195,11 +195,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(); From f10ac532e3e1dbf192f64b54ad72f3f775051027 Mon Sep 17 00:00:00 2001 From: Gerrit Garbereder Date: Tue, 30 Sep 2014 19:45:35 +0200 Subject: [PATCH 3/3] ADD: function to validate transition now configurabel by parameter --- README.md | 1 + jquery.multipage.js | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 54e8ab8..40a2bec 100644 --- a/README.md +++ b/README.md @@ -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 }); diff --git a/jquery.multipage.js b/jquery.multipage.js index b92f0a0..fc31ec6 100755 --- a/jquery.multipage.js +++ b/jquery.multipage.js @@ -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() {