first commit
This commit is contained in:
50
asset/sliderform/jquery.slideto.v1.1.js
Normal file
50
asset/sliderform/jquery.slideto.v1.1.js
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* jQuery SlideTo Plugin (version 1.0)
|
||||
*
|
||||
* @copyright Jesse Price <jesseprice.com>
|
||||
* @description Animate slide scroll to effects to specific elements in the document
|
||||
*
|
||||
* @license Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
// Create closure
|
||||
(function($) {
|
||||
$.fn.slideto = function(options) {
|
||||
var opts = $.extend({}, $.fn.slideto.defaults, options);
|
||||
var elem = (this.length > 0) ? this : 'a';
|
||||
// Element instance specific actions
|
||||
$(elem).each(function() {
|
||||
var e = $(this);
|
||||
var o = $.meta ? $.extend({}, opts, e.data()) : opts;
|
||||
var url = $(e).attr("href");
|
||||
var anchor = '';
|
||||
if(url && url.indexOf("#") != -1 && url.indexOf("#") == 0) {
|
||||
var pieces = url.split("#",2);
|
||||
anchor = $("a[name='"+pieces[1]+"']");
|
||||
$(this).attr('href', 'javascript:void(0);');
|
||||
} else
|
||||
anchor = $(o.target);
|
||||
|
||||
$(e).bind('click', function(){
|
||||
$('html, body').animate({
|
||||
scrollTop: anchor.offset().top,
|
||||
scrollLeft: anchor.offset().left
|
||||
}, o.speed);
|
||||
});
|
||||
});
|
||||
|
||||
// Allow jQuery chaining
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Plugin Options
|
||||
* ---------------------------------------------------------------------
|
||||
* Overwrite the default options? Go for it!
|
||||
*/
|
||||
$.fn.slideto.defaults = {
|
||||
target : false, // Where to scroll? If it's false, we use the "scroll attribute"
|
||||
speed : 1500 // slow, medium, fast, numeric microseconds
|
||||
}
|
||||
})(jQuery);
|
154
asset/sliderform/sliding.form.js
Normal file
154
asset/sliderform/sliding.form.js
Normal file
@ -0,0 +1,154 @@
|
||||
$(function() {
|
||||
/*
|
||||
number of fieldsets
|
||||
*/
|
||||
var fieldsetCount = $('#formElem').children().length;
|
||||
|
||||
/*
|
||||
current position of fieldset / navigation link
|
||||
*/
|
||||
var current = 1;
|
||||
|
||||
/*
|
||||
sum and save the widths of each one of the fieldsets
|
||||
set the final sum as the total width of the steps element
|
||||
*/
|
||||
var stepsWidth = 0;
|
||||
var widths = new Array();
|
||||
$('#steps .step').each(function(i){
|
||||
var $step = $(this);
|
||||
widths[i] = stepsWidth;
|
||||
stepsWidth += $step.width();
|
||||
});
|
||||
$('#steps').width(stepsWidth);
|
||||
|
||||
/*
|
||||
to avoid problems in IE, focus the first input of the form
|
||||
*/
|
||||
$('#formElem').children(':first').find(':input:first').focus();
|
||||
|
||||
/*
|
||||
show the navigation bar
|
||||
*/
|
||||
$('#navigation').show();
|
||||
|
||||
/*
|
||||
when clicking on a navigation link
|
||||
the form slides to the corresponding fieldset
|
||||
*/
|
||||
$('#navigation a').bind('click',function(e){
|
||||
var $this = $(this);
|
||||
var prev = current;
|
||||
$this.closest('ul').find('li').removeClass('selected');
|
||||
$this.parent().addClass('selected');
|
||||
/*
|
||||
we store the position of the link
|
||||
in the current variable
|
||||
*/
|
||||
current = $this.parent().index() + 1;
|
||||
/*
|
||||
animate / slide to the next or to the corresponding
|
||||
fieldset. The order of the links in the navigation
|
||||
is the order of the fieldsets.
|
||||
Also, after sliding, we trigger the focus on the first
|
||||
input element of the new fieldset
|
||||
If we clicked on the last link (confirmation), then we validate
|
||||
all the fieldsets, otherwise we validate the previous one
|
||||
before the form slided
|
||||
*/
|
||||
$('#steps').stop().animate({
|
||||
marginLeft: '-' + widths[current-1] + 'px'
|
||||
},500,function(){
|
||||
if(current == fieldsetCount)
|
||||
validateSteps();
|
||||
else
|
||||
validateStep(prev);
|
||||
$('#formElem').children(':nth-child('+ parseInt(current) +')').find(':input:first').focus();
|
||||
});
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
/*
|
||||
clicking on the tab (on the last input of each fieldset), makes the form
|
||||
slide to the next step
|
||||
*/
|
||||
$('#formElem > fieldset').each(function(){
|
||||
var $fieldset = $(this);
|
||||
$fieldset.children(':last').find(':input').keydown(function(e){
|
||||
if (e.which == 9){
|
||||
$('#navigation li:nth-child(' + (parseInt(current)+1) + ') a').click();
|
||||
/* force the blur for validation */
|
||||
$(this).blur();
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
var $fieldset = $(this);
|
||||
$fieldset.children(':last').find('#nextb').keydown(function(e){
|
||||
if (e.which == 9){
|
||||
$('#navigation li:nth-child(' + (parseInt(current)+1) + ') a').click();
|
||||
/* force the blur for validation */
|
||||
$(this).blur();
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
validates errors on all the fieldsets
|
||||
records if the Form has errors in $('#formElem').data()
|
||||
*/
|
||||
function validateSteps(){
|
||||
var FormErrors = false;
|
||||
for(var i = 1; i < fieldsetCount; ++i){
|
||||
var error = validateStep(i);
|
||||
if(error == -1)
|
||||
FormErrors = true;
|
||||
}
|
||||
$('#formElem').data('errors',FormErrors);
|
||||
}
|
||||
|
||||
/*
|
||||
validates one fieldset
|
||||
and returns -1 if errors found, or 1 if not
|
||||
*/
|
||||
function validateStep(step){
|
||||
if(step == fieldsetCount) return;
|
||||
|
||||
var error = 1;
|
||||
var hasError = false;
|
||||
$('#formElem').children(':nth-child('+ parseInt(step) +')').find(':input:not(button)').each(function(){
|
||||
var $this = $(this);
|
||||
var valueLength = jQuery.trim($this.val()).length;
|
||||
|
||||
if(valueLength == ''){
|
||||
hasError = true;
|
||||
$this.css('background-color','#FFEDEF');
|
||||
}
|
||||
else
|
||||
$this.css('background-color','#FFFFFF');
|
||||
});
|
||||
var $link = $('#navigation li:nth-child(' + parseInt(step) + ') a');
|
||||
$link.parent().find('.error,.checked').remove();
|
||||
|
||||
var valclass = 'checked';
|
||||
if(hasError){
|
||||
error = -1;
|
||||
valclass = 'error';
|
||||
}
|
||||
$('<span class="'+valclass+'"></span>').insertAfter($link);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
if there are errors don't allow the user to submit
|
||||
*/
|
||||
$('#registerButton').bind('click',function(){
|
||||
if($('#formElem').data('errors')){
|
||||
alert('Please correct the errors in the Form');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
152
asset/sliderform/style.css
Normal file
152
asset/sliderform/style.css
Normal file
@ -0,0 +1,152 @@
|
||||
|
||||
body{
|
||||
font-size:10px;
|
||||
background: #fff;
|
||||
font-family:"Century Gothic", Helvetica, sans-serif;
|
||||
}
|
||||
|
||||
#wrapper{
|
||||
-moz-box-shadow:0px 0px 3px #aaa;
|
||||
-webkit-box-shadow:0px 0px 3px #aaa;
|
||||
box-shadow:0px 0px 3px #aaa;
|
||||
-moz-border-radius:10px;
|
||||
-webkit-border-radius:10px;
|
||||
border-radius:10px;
|
||||
border:2px solid #fff;
|
||||
background-color:#f9f9f9;
|
||||
width:700px;
|
||||
overflow:hidden;
|
||||
padding:20px;
|
||||
padding-left:5px;
|
||||
}
|
||||
|
||||
.step{
|
||||
float:left;
|
||||
width:720px;
|
||||
height:800px;
|
||||
max-height:auto;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#steps form fieldset{
|
||||
border:none;
|
||||
padding-bottom:20px;
|
||||
}
|
||||
|
||||
#steps{
|
||||
width:720px;
|
||||
height:auto;
|
||||
overflow:hidden;
|
||||
}
|
||||
|
||||
#steps form legend{
|
||||
text-align:left;
|
||||
background-color:#f0f0f0;
|
||||
color:#666;
|
||||
font-size:24px;
|
||||
text-shadow:1px 1px 1px #fff;
|
||||
font-weight:bold;
|
||||
float:left;
|
||||
width:700px;
|
||||
padding:5px 0px 5px 10px;
|
||||
margin:10px 0px;
|
||||
border-bottom:1px solid #fff;
|
||||
border-top:1px solid #d9d9d9;
|
||||
}
|
||||
#steps form p{
|
||||
float:left;
|
||||
clear:both;
|
||||
margin:5px 0px;
|
||||
background-color:#f4f4f4;
|
||||
border:1px solid #fff;
|
||||
padding:10px;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
-moz-box-shadow:0px 0px 3px #aaa;
|
||||
-webkit-box-shadow:0px 0px 3px #aaa;
|
||||
box-shadow:0px 0px 3px #aaa;
|
||||
}
|
||||
#steps form p label{
|
||||
float:left;
|
||||
line-height:26px;
|
||||
color:#666;
|
||||
text-shadow:1px 1px 1px #fff;
|
||||
font-weight:bold;
|
||||
}
|
||||
form input{
|
||||
margin-right:10px;
|
||||
margin-bottom:10px;
|
||||
}
|
||||
#steps form input:not([type=radio]),
|
||||
#steps form textarea,
|
||||
#steps form select{
|
||||
background: #ffffff;
|
||||
border: 1px solid #ddd;
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
outline: none;
|
||||
padding: 5px;
|
||||
}
|
||||
#steps form input:focus{
|
||||
-moz-box-shadow:0px 0px 3px #aaa;
|
||||
-webkit-box-shadow:0px 0px 3px #aaa;
|
||||
box-shadow:0px 0px 3px #aaa;
|
||||
background-color:#FFFEEF;
|
||||
}
|
||||
#steps form p.submit{
|
||||
background:none;
|
||||
border:none;
|
||||
-moz-box-shadow:none;
|
||||
-webkit-box-shadow:none;
|
||||
box-shadow:none;
|
||||
}
|
||||
|
||||
|
||||
/* navigation*/
|
||||
|
||||
#navigation ul{
|
||||
list-style:none;
|
||||
position:fixed;
|
||||
width:280px;
|
||||
border:1px solid #ccc;
|
||||
border-radius:5px;
|
||||
}
|
||||
|
||||
#navigation ul li{
|
||||
/*border-top:1px solid #ccc;*/
|
||||
border-bottom:1px solid #ccc;
|
||||
position:relative;
|
||||
}
|
||||
#navigation ul li a{
|
||||
display:block;
|
||||
/*background-color:#444;*/
|
||||
width:85%;
|
||||
color:#777;
|
||||
outline:none;
|
||||
font-weight:bold;
|
||||
text-decoration:none;
|
||||
line-height:45px;
|
||||
padding:0px 20px;
|
||||
border-right:1px solid #fff;
|
||||
border-left:1px solid #fff;
|
||||
}
|
||||
#navigation ul li a:hover,
|
||||
#navigation ul li.selected a{
|
||||
background:#66CCCC;
|
||||
color:#fff;
|
||||
}
|
||||
#navigation ul li a:hover{
|
||||
background:#CDFFFF;
|
||||
color:#000;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.test #navigation ul{
|
||||
position: static;
|
||||
width: auto;
|
||||
top: 0;
|
||||
padding:0;
|
||||
margin-bottom:10px;
|
||||
}
|
Reference in New Issue
Block a user