idealsteps improvements

remove e.preventDefault, up to the user
This commit is contained in:
elclanrs 2013-10-14 01:28:09 -04:00
parent 4678908173
commit 5d98a7aa86
10 changed files with 46 additions and 33 deletions

View file

@ -142,13 +142,15 @@ Callback that runs after an input attempts to validate.
Callback that runs when the form is submitted. Callback that runs when the form is submitted.
- **invalid:** The number of invalid fields if any. - **invalid:** The number of invalid fields if any.
- **event:** The submit event (prevented by default). - **event:** The submit event.
For Example: Example:
```javascript ```javascript
$('form').idealforms({ $('form').idealforms({
onSubmit: function(invalid) { onSubmit: function(invalid, e) {
e.preventDefault();
if (invalid) { if (invalid) {
alert(invalid +' fields!'); alert(invalid +' fields!');
} else { } else {

View file

@ -54,7 +54,7 @@ form.idealforms.adaptive .error:after{top:2px;left:50%;margin-top:-1.4em;margin-
form.idealforms.adaptive .error.hidden{position:absolute;visibility:hidden} form.idealforms.adaptive .error.hidden{position:absolute;visibility:hidden}
form.idealforms.adaptive .idealforms-field-checkbox .error,form.idealforms.adaptive .idealforms-field-radio .error,form.idealforms.adaptive .idealforms-field-textarea .error{top:0} form.idealforms.adaptive .idealforms-field-checkbox .error,form.idealforms.adaptive .idealforms-field-radio .error,form.idealforms.adaptive .idealforms-field-textarea .error{top:0}
.idealsteps-container *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box} .idealsteps-container *{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}
.idealsteps-step{zoom:1} .idealsteps-step{display:none;zoom:1}
.idealsteps-step:before,.idealsteps-step:after{content:"";display:table} .idealsteps-step:before,.idealsteps-step:after{content:"";display:table}
.idealsteps-step:after{clear:both} .idealsteps-step:after{clear:both}
.idealsteps-nav{color:#444;background:#eee;background:-webkit-linear-gradient(#fff, #ddd);background:-moz-linear-gradient(#fff, #ddd);background:-o-linear-gradient(#fff, #ddd);background:-ms-linear-gradient(#fff, #ddd);background:linear-gradient(#fff, #ddd);border:1px solid #aaa;border-bottom-color:#919191;-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.15);box-shadow:0 1px 2px rgba(0,0,0,0.15);-webkit-border-radius:3.01px;border-radius:3.01px;overflow:hidden;margin-bottom:2em;} .idealsteps-nav{color:#444;background:#eee;background:-webkit-linear-gradient(#fff, #ddd);background:-moz-linear-gradient(#fff, #ddd);background:-o-linear-gradient(#fff, #ddd);background:-ms-linear-gradient(#fff, #ddd);background:linear-gradient(#fff, #ddd);border:1px solid #aaa;border-bottom-color:#919191;-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.15);box-shadow:0 1px 2px rgba(0,0,0,0.15);-webkit-border-radius:3.01px;border-radius:3.01px;overflow:hidden;margin-bottom:2em;}
@ -67,7 +67,7 @@ form.idealforms.adaptive .idealforms-field-checkbox .error,form.idealforms.adapt
.idealsteps-nav a:after,.idealsteps-nav a:before{content:"";position:absolute;z-index:1;top:0;right:-2em;margin-right:0;margin-top:-.125em;border-width:2em 1em;border-style:solid;border-color:transparent;border-left-color:#ddd} .idealsteps-nav a:after,.idealsteps-nav a:before{content:"";position:absolute;z-index:1;top:0;right:-2em;margin-right:0;margin-top:-.125em;border-width:2em 1em;border-style:solid;border-color:transparent;border-left-color:#ddd}
.idealsteps-nav a:before{margin-right:-1px;border-left-color:#aaa} .idealsteps-nav a:before{margin-right:-1px;border-left-color:#aaa}
.idealsteps-nav li:first-child a{padding-left:1.75em;-webkit-border-top-left-radius:3.01px;border-top-left-radius:3.01px;-webkit-border-bottom-left-radius:3.01px;border-bottom-left-radius:3.01px;} .idealsteps-nav li:first-child a{padding-left:1.75em;-webkit-border-top-left-radius:3.01px;border-top-left-radius:3.01px;-webkit-border-bottom-left-radius:3.01px;border-bottom-left-radius:3.01px;}
.idealsteps-nav li.idealsteps-step-active a{padding-right:3.5em;background:#fff;color:#3f9dcc;font-weight:bold;} .idealsteps-nav li.idealsteps-step-active a{padding-right:3.5em;background:#fff;color:#3f9dcc;font-weight:bold;cursor:default;}
.idealsteps-nav li.idealsteps-step-active a:after{border-left-color:#fff} .idealsteps-nav li.idealsteps-step-active a:after{border-left-color:#fff}
.idealsteps-nav li.idealsteps-step-active .counter{opacity:1;-ms-filter:none;filter:none} .idealsteps-nav li.idealsteps-step-active .counter{opacity:1;-ms-filter:none;filter:none}
.idealsteps-nav .counter{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);position:absolute;top:50%;right:1em;height:1.5em;width:1.5em;margin-top:-.75em;line-height:1.5 !important;text-align:center;color:#cc2a18;border:1px solid #cc2a18;-webkit-border-radius:10em;border-radius:10em;-webkit-transition:opacity 0.2s ease-in-out;-moz-transition:opacity 0.2s ease-in-out;-o-transition:opacity 0.2s ease-in-out;-ms-transition:opacity 0.2s ease-in-out;transition:opacity 0.2s ease-in-out;} .idealsteps-nav .counter{opacity:0;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);position:absolute;top:50%;right:1em;height:1.5em;width:1.5em;margin-top:-.75em;line-height:1.5 !important;text-align:center;color:#cc2a18;border:1px solid #cc2a18;-webkit-border-radius:10em;border-radius:10em;-webkit-transition:opacity 0.2s ease-in-out;-moz-transition:opacity 0.2s ease-in-out;-o-transition:opacity 0.2s ease-in-out;-ms-transition:opacity 0.2s ease-in-out;transition:opacity 0.2s ease-in-out;}

View file

@ -27,19 +27,19 @@
inkscape:pageopacity="0.0" inkscape:pageopacity="0.0"
inkscape:pageshadow="2" inkscape:pageshadow="2"
inkscape:zoom="1" inkscape:zoom="1"
inkscape:cx="27.048703" inkscape:cx="-12.009478"
inkscape:cy="2.9250227" inkscape:cy="68.328459"
inkscape:document-units="px" inkscape:document-units="px"
inkscape:current-layer="layer1" inkscape:current-layer="layer1"
showgrid="false" showgrid="true"
borderlayer="true" borderlayer="true"
inkscape:showpageshadow="false" inkscape:showpageshadow="false"
showguides="false" showguides="false"
inkscape:guide-bbox="true" inkscape:guide-bbox="true"
inkscape:window-width="1197" inkscape:window-width="1197"
inkscape:window-height="781" inkscape:window-height="781"
inkscape:window-x="3012" inkscape:window-x="2752"
inkscape:window-y="199" inkscape:window-y="196"
inkscape:window-maximized="0" inkscape:window-maximized="0"
showborder="true" showborder="true"
inkscape:object-nodes="false" inkscape:object-nodes="false"
@ -541,7 +541,7 @@
<dc:format>image/svg+xml</dc:format> <dc:format>image/svg+xml</dc:format>
<dc:type <dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title> <dc:title />
</cc:Work> </cc:Work>
</rdf:RDF> </rdf:RDF>
</metadata> </metadata>

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View file

@ -223,11 +223,18 @@
} }
}, },
onSubmit: function(invalid) { onSubmit: function(invalid, e) {
e.preventDefault();
$('#invalid').show().text(invalid ? (invalid +' invalid fields') : 'All good!'); $('#invalid').show().text(invalid ? (invalid +' invalid fields') : 'All good!');
},
steps: {
fadeSpeed: 300
} }
}); });
$('form.idealforms').find('input, select, textarea').on('change keyup', function() { $('form.idealforms').find('input, select, textarea').on('change keyup', function() {
$('#invalid').hide(); $('#invalid').hide();
}); });

View file

@ -14,8 +14,8 @@
wrap: '.idealsteps-wrap', wrap: '.idealsteps-wrap',
step: '.idealsteps-step', step: '.idealsteps-step',
activeClass: 'idealsteps-step-active', activeClass: 'idealsteps-step-active',
before: null, before: $.noop,
after: null, after: $.noop,
fadeSpeed: 0 fadeSpeed: 0
}; };
@ -41,7 +41,9 @@
this.$navItems.click(function(e) { this.$navItems.click(function(e) {
e.preventDefault(); e.preventDefault();
self.go(self.$navItems.index(this)); if (! $(this).is('.'+ self.opts.activeClass)) {
self.go(self.$navItems.index(this));
}
}); });
}, },
@ -75,12 +77,12 @@
if (idx >= this.$steps.length) idx = 0; if (idx >= this.$steps.length) idx = 0;
if (idx < 0) idx = this.$steps.length-1; if (idx < 0) idx = this.$steps.length-1;
if (this.opts.before) this.opts.before.call(this, idx); this.opts.before.call(this, idx);
this.$navItems.removeClass(active).eq(idx).addClass(active); this.$navItems.removeClass(active).eq(idx).addClass(active);
this.$steps.fadeOut(fadeSpeed).eq(idx).fadeIn(fadeSpeed); this.$steps.hide().eq(idx).fadeIn(fadeSpeed);
if (this.opts.after) this.opts.after.call(this, idx); this.opts.after.call(this, idx);
}, },
prev: function() { prev: function() {

View file

@ -17,8 +17,8 @@ module.exports = {
wrap: '.idealsteps-wrap', wrap: '.idealsteps-wrap',
step: '.idealsteps-step', step: '.idealsteps-step',
activeClass: 'idealsteps-step-active', activeClass: 'idealsteps-step-active',
before: null, before: $.noop,
after: null, after: $.noop,
fadeSpeed: 0, fadeSpeed: 0,
i18n: { i18n: {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -20,7 +20,6 @@ module.exports = {
this.addRules(this.opts.rules || {}); this.addRules(this.opts.rules || {});
this.$form.submit(function(e) { this.$form.submit(function(e) {
e.preventDefault();
self._validateAll(); self._validateAll();
self.focusFirstInvalid(); self.focusFirstInvalid();
self.opts.onSubmit.call(self, self.getInvalid().length, e); self.opts.onSubmit.call(self, self.getInvalid().length, e);

View file

@ -5,6 +5,7 @@
box-sizing: border-box box-sizing: border-box
.idealsteps-step .idealsteps-step
display: none
clearfix() clearfix()
.idealsteps-nav .idealsteps-nav
@ -66,6 +67,7 @@
background: white background: white
color: valid color: valid
font-weight: bold font-weight: bold
cursor: default
&:after &:after
border-left-color: white border-left-color: white