[Movecommons-commits] r584 - trunk/src
Mario Gallegos
mgallegos at ourproject.org
Wed Nov 7 17:57:58 CET 2012
Author: mgallegos
Date: 2012-11-07 17:57:57 +0100 (Wed, 07 Nov 2012)
New Revision: 584
Modified:
trunk/src/mc-dia-form2.js
Log:
Modified: trunk/src/mc-dia-form2.js
===================================================================
--- trunk/src/mc-dia-form2.js 2012-11-06 15:09:59 UTC (rev 583)
+++ trunk/src/mc-dia-form2.js 2012-11-07 16:57:57 UTC (rev 584)
@@ -128,57 +128,211 @@
$j('#sixthStepProgressLine').html('<img src="/mc/0.1/images/progressTransparentLine.png" usemap="#step6_image_map" class="map" style="border: 0px;float: left;"><div class="complete" style="width: 478px;margin-top: 0"><div class="marker" style="background-position: -130px 0;"></div></div>');
}
- function onClickImageMap(e){
- $j(current_step).slideUp();
- $j(e.key).slideDown();
- if (e.key=='#first_step'){
- $j('#progress_text').html('0% Complete');
- $j('#progress').css('width','0');
- current_step='#first_step';
- }
- else if (e.key=='#second_step'){
- $j('#progress_text').html('20% Complete');
- $j('#progress').css('width','68px');
- current_step='#second_step';
- if($j('#np-checkbox').val()=='S')
- $j('label[for*="step2-yes"]').addClass('ui-state-active');
- else if ($j('#np-checkbox').val()=='N')
- $j('label[for*="step2-no"]').addClass('ui-state-active');
+ function validations_step1(){
+ var error = false;
+
+ //remove classes
+ $j('#first_step input').removeClass('error').removeClass('valid');
+
+ //ckeck if inputs aren't empty
+ var fields = $j('#first_step input[type=text], #first_step input[type=password]');
+
+ fields.each(function(){
+ var value = $j.trim($j(this).val());
+ if( value=="" || value==field_values[$j(this).attr('id')] ) {
+ $j(this).addClass('error');
+ $j(this).effect("shake", { times:3 }, 50);
+ error=true;
+ } else {
+ /*if($j(this).attr('id')=='url'){
+ if(!(/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]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((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value))){
+ $j(this).addClass('error');
+ $j(this).effect("shake", { times:3 }, 50);
+ error++;
+ }
+ }
+ else*/
+ $j(this).addClass('valid');
+ }
+ });
+
+ return error;
+ }
+
+ function validations_step2(){
+ var error=false;
+
+ if($j('#np-checkbox').val()=='A'){
+ $j('#step2question').effect("shake", { times:3 }, 50);
+ return true;
}
- else if (e.key=='#third_step'){
- $j('#progress_text').html('40% Complete');
- $j('#progress').css('width','136px');
- current_step='#third_step';
- if($j('#rp-checkbox').val()=='S')
- $j('label[for*="step3-yes"]').addClass('ui-state-active');
- else if ($j('#rp-checkbox').val()=='N')
- $j('label[for*="step3-no"]').addClass('ui-state-active');
- }
- else if (e.key=='#fourth_step'){
- $j('#progress_text').html('60% Complete');
- $j('#progress').css('width','204px');
- current_step='#fourth_step';
- if($j('#rc-checkbox').val()=='S')
- $j('label[for*="step4-yes"]').addClass('ui-state-active');
- else if ($j('#rc-checkbox').val()=='N')
- $j('label[for*="step4-no"]').addClass('ui-state-active');
+
+ if($j("#registered-non-profit").attr("checked"))
+ if($j.trim($j('#non-profit-website').val())==""){
+ $j('#non-profit-website').addClass('error');
+ $j('#non-profit-website').effect("shake", { times:3 }, 50);
+ error=true;
+ }
+ else
+ $j('#non-profit-website').addClass('valid');
+
+ if($j("#open-accounting").attr("checked"))
+ if($j.trim($j('#open-accounting-website').val())==""){
+ $j('#open-accounting-website').addClass('error');
+ $j('#open-accounting-website').effect("shake", { times:3 }, 50);
+ error=true;
+ }
+ else
+ $j('#open-accounting-website').addClass('valid');
+
+ if($j("#accept-donations").attr("checked"))
+ if($j.trim($j('#donation-website').val())==""){
+ $j('#donation-website').addClass('error');
+ $j('#donation-website').effect("shake", { times:3 }, 50);
+ error=true;
+ }
+ else
+ $j('#accept-donations').addClass('valid');
+
+ return error;
+ }
+
+ function validations_step3(){
+ var error=false;
+
+ if($j('#rp-checkbox').val()=='A'){
+ $j('#step3question').effect("shake", { times:3 }, 50);
+ return true;
}
- else if (e.key=='#fifth_step'){
- $j('#progress_text').html('60% Complete');
- $j('#progress').css('width','204px');
- current_step='#fifth_step';
- if($j('#gr-checkbox').val()=='S')
- $j('label[for*="step5-yes"]').addClass('ui-state-active');
- else if ($j('#gr-checkbox').val()=='N')
- $j('label[for*="step5-no"]').addClass('ui-state-active');
+
+ if($j("#terms-of-use").attr("checked"))
+ if($j.trim($j('#terms-of-use-website').val())==""){
+ $j('#terms-of-use-website').addClass('error');
+ $j('#terms-of-use-website').effect("shake", { times:3 }, 50);
+ error=true;
+ }
+ else
+ $j('#terms-of-use-website').addClass('valid');
+
+ if($j("#creative-commons").attr("checked"))
+ if($j.trim($j('#creative-commons-website').val())==""){
+ $j('#creative-commons-website').addClass('error');
+ $j('#creative-commons-website').effect("shake", { times:3 }, 50);
+ error=true;
+ }
+ else
+ $j('#creative-commons-website').addClass('valid');
+
+ if($j("#other-license").attr("checked"))
+ if($j.trim($j('#other-license-website').val())==""){
+ $j('#other-license-website').addClass('error');
+ $j('#other-license-website').effect("shake", { times:3 }, 50);
+ error=true;
+ }
+ else
+ $j('#other-license-website').addClass('valid');
+
+ return error;
+ }
+
+ function validations_step4(){
+ if($j('#rc-checkbox').val()=='A'){
+ $j('#step4question').effect("shake", { times:3 }, 50);
+ return true;
}
- else if (e.key=='#sixth_step'){
- $j('#progress_text').html('100% Complete');
- $j('#progress').css('width','339px');
- current_step='#sixth_step';
- }
+
+ if($j('#mc-form-icon-rc').attr('src')=='/mc/0.1/images/rc60.png' && $j('#rc-checkbox').val()=='S'){
+ $j('#mc-form-optional-reinforcing').effect("shake", { times:3 }, 50);
+ return true;
+ }
+
+ return false;
}
+ function validations_step5(){
+
+ if($j('#gr-checkbox').val()=='A'){
+ $j('#step5question').effect("shake", { times:3 }, 50);
+ return true;
+ }
+
+ return false;
+ }
+
+ function onClickImageMap(e){
+ switch (current_step) {
+ case '#first_step':
+ if(validations_step1())
+ return;
+ break;
+ case '#second_step':
+ if(validations_step2())
+ return;
+ break;
+ case '#third_step':
+ if(validations_step3())
+ return;
+ break;
+ case '#fourth_step':
+ if(validations_step4())
+ return;
+ break;
+ case '#fifth_step':
+ if(validations_step5())
+ return;
+ break;
+ default:
+ break;
+ }
+ $j(current_step).slideUp();
+ $j(e.key).slideDown();
+ current_step=e.key;
+ switch (e.key) {
+ case '#first_step':
+ $j('#progress_text').html('0% Complete');
+ $j('#progress').css('width','0');
+ break;
+ case '#second_step':
+ $j('#progress_text').html('20% Complete');
+ $j('#progress').css('width','68px');
+ if($j('#np-checkbox').val()=='S')
+ $j('label[for*="step2-yes"]').addClass('ui-state-active');
+ else if ($j('#np-checkbox').val()=='N')
+ $j('label[for*="step2-no"]').addClass('ui-state-active');
+ break;
+ case '#third_step':
+ $j('#progress_text').html('40% Complete');
+ $j('#progress').css('width','136px');
+ if($j('#rp-checkbox').val()=='S')
+ $j('label[for*="step3-yes"]').addClass('ui-state-active');
+ else if ($j('#rp-checkbox').val()=='N')
+ $j('label[for*="step3-no"]').addClass('ui-state-active');
+ break;
+ case '#fourth_step':
+ $j('#progress_text').html('60% Complete');
+ $j('#progress').css('width','204px');
+ if($j('#rc-checkbox').val()=='S')
+ $j('label[for*="step4-yes"]').addClass('ui-state-active');
+ else if ($j('#rc-checkbox').val()=='N')
+ $j('label[for*="step4-no"]').addClass('ui-state-active');
+ break;
+ case '#fifth_step':
+ $j('#progress_text').html('60% Complete');
+ $j('#progress').css('width','204px');
+ if($j('#gr-checkbox').val()=='S')
+ $j('label[for*="step5-yes"]').addClass('ui-state-active');
+ else if ($j('#gr-checkbox').val()=='N')
+ $j('label[for*="step5-no"]').addClass('ui-state-active');
+ break;
+ case '#sixth_step':
+ $j('#progress_text').html('100% Complete');
+ $j('#progress').css('width','339px');
+ break;
+ default:
+ break;
+ }
+ }
+
function select_cat($id, $id2) {
var cat_id = "#mc-form-" + $id;
$j(cat_id + ",#mc-form-icon-" + $id).click(
@@ -441,6 +595,8 @@
}
+
+ /*
// http://remysharp.com/2007/03/19/a-few-more-jquery-plugins-crop-labelover-and-pluck/#labelOver
$.fn.labelOver = function(overClass) {
return this.each(function()
@@ -467,62 +623,43 @@
}
});
};
+ */
- $j('#submit_first').click(function(){
- //remove classes
- $j('#first_step input').removeClass('error').removeClass('valid');
-
- //ckeck if inputs aren't empty
- var fields = $j('#first_step input[type=text], #first_step input[type=password]');
- var error = 0;
- fields.each(function(){
- var value = $j.trim($j(this).val());
- if( value=="" || value==field_values[$j(this).attr('id')] ) {
- $j(this).addClass('error');
- $j(this).effect("shake", { times:3 }, 50);
- error++;
- } else {
- /*if($j(this).attr('id')=='url'){
- if(!(/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value))){
- $j(this).addClass('error');
- $j(this).effect("shake", { times:3 }, 50);
- error++;
- }
- }
- else*/
- $j(this).addClass('valid');
- }
- });
-
- if(!error) {
+ $j('#submit_first').click(function(){
+
+ if(validations_step1())
+ return;
- current_step='#second_step';
-
- if(!step_two_reached){
- $j('#step1_image_map').append('<area href="#" step="#second_step" shape="circle" coords="122,12,12"><!--2-->');
- imageMapUnBind();
- imageMapInit();
- step_two_reached=true;
- }
-
- //update progress bar
- $j('#progress_text').html('20% Complete');
- $j('#progress').css('width','68px');
-
- //slide steps
- $j('#first_step').slideUp();
- $j('#second_step').slideDown();
-
- if($j('#np-checkbox').val()=='S')
- $j('label[for*="step2-yes"]').addClass('ui-state-active');
- else if ($j('#np-checkbox').val()=='N')
- $j('label[for*="step2-no"]').addClass('ui-state-active');
- } else return false;
+ current_step='#second_step';
+
+ if(!step_two_reached){
+ $j('#step1_image_map').append('<area href="#" step="#second_step" shape="circle" coords="122,12,12"><!--2-->');
+ imageMapUnBind();
+ imageMapInit();
+ step_two_reached=true;
+ }
+
+ //update progress bar
+ $j('#progress_text').html('20% Complete');
+ $j('#progress').css('width','68px');
+
+ //slide steps
+ $j('#first_step').slideUp();
+ $j('#second_step').slideDown();
+
+ if($j('#np-checkbox').val()=='S')
+ $j('label[for*="step2-yes"]').addClass('ui-state-active');
+ else if ($j('#np-checkbox').val()=='N')
+ $j('label[for*="step2-no"]').addClass('ui-state-active');
+
});
$j('#p_submit_second').click(function(){
+ if(validations_step2())
+ return;
+
current_step='#first_step';
//update progress bar
@@ -535,45 +672,11 @@
});
- $j('#submit_second').click(function(){
+ $j('#submit_second').click(function(){
- var error=false;
-
- if($j('#np-checkbox').val()=='A'){
- $j('#step2question').effect("shake", { times:3 }, 50);
+ if(validations_step2())
return;
- }
- if($j("#registered-non-profit").attr("checked"))
- if($j.trim($j('#non-profit-website').val())==""){
- $j('#non-profit-website').addClass('error');
- $j('#non-profit-website').effect("shake", { times:3 }, 50);
- error=true;
- }
- else
- $j('#non-profit-website').addClass('valid');
-
- if($j("#open-accounting").attr("checked"))
- if($j.trim($j('#open-accounting-website').val())==""){
- $j('#open-accounting-website').addClass('error');
- $j('#open-accounting-website').effect("shake", { times:3 }, 50);
- error=true;
- }
- else
- $j('#open-accounting-website').addClass('valid');
-
- if($j("#accept-donations").attr("checked"))
- if($j.trim($j('#donation-website').val())==""){
- $j('#donation-website').addClass('error');
- $j('#donation-website').effect("shake", { times:3 }, 50);
- error=true;
- }
- else
- $j('#accept-donations').addClass('valid');
-
- if(error)
- return;
-
current_step='#third_step';
if(!step_three_reached){
@@ -596,11 +699,15 @@
//slide steps
$j('#second_step').slideUp();
$j('#third_step').slideDown();
+
});
$j('#p_submit_third').click(function(){
+ if(validations_step3())
+ return;
+
current_step='#second_step';
//update progress bar
@@ -619,44 +726,10 @@
$j('#submit_third').click(function(){
-
- var error=false;
-
- if($j('#rp-checkbox').val()=='A'){
- $j('#step3question').effect("shake", { times:3 }, 50);
+
+ if(validations_step3())
return;
- }
- if($j("#terms-of-use").attr("checked"))
- if($j.trim($j('#terms-of-use-website').val())==""){
- $j('#terms-of-use-website').addClass('error');
- $j('#terms-of-use-website').effect("shake", { times:3 }, 50);
- error=true;
- }
- else
- $j('#terms-of-use-website').addClass('valid');
-
- if($j("#creative-commons").attr("checked"))
- if($j.trim($j('#creative-commons-website').val())==""){
- $j('#creative-commons-website').addClass('error');
- $j('#creative-commons-website').effect("shake", { times:3 }, 50);
- error=true;
- }
- else
- $j('#creative-commons-website').addClass('valid');
-
- if($j("#other-license").attr("checked"))
- if($j.trim($j('#other-license-website').val())==""){
- $j('#other-license-website').addClass('error');
- $j('#other-license-website').effect("shake", { times:3 }, 50);
- error=true;
- }
- else
- $j('#other-license-website').addClass('valid');
-
- if(error)
- return;
-
current_step='#fourth_step';
if(!step_four_reached){
@@ -682,8 +755,11 @@
$j('#fourth_step').slideDown();
});
- $j('#p_submit_fourth').click(function(){
+ $j('#p_submit_fourth').click(function(){
+ if(validations_step4())
+ return;
+
current_step='#third_step';
//update progress bar
@@ -702,17 +778,9 @@
$j('#submit_fourth').click(function(){
- if($j('#rc-checkbox').val()=='A'){
- $j('#step4question').effect("shake", { times:3 }, 50);
+ if(validations_step4())
return;
- }
-
- if($j('#mc-form-icon-rc').attr('src')=='/mc/0.1/images/rc60.png' && $j('#rc-checkbox').val()=='S'){
- $j('#mc-form-optional-reinforcing').effect("shake", { times:3 }, 50);
- return;
- }
-
current_step='#fifth_step';
if(!step_five_reached){
@@ -742,6 +810,9 @@
$j('#p_submit_fifth').click(function(){
+ if(validations_step5())
+ return;
+
current_step='#fourth_step';
//update progress bar
@@ -759,12 +830,10 @@
});
$j('#submit_fifth').click(function(){
-
- if($j('#gr-checkbox').val()=='A'){
- $j('#step5question').effect("shake", { times:3 }, 50);
- return;
- }
+ if(validations_step5())
+ return;
+
current_step='#sixth_step';
if(!step_six_reached){
@@ -897,6 +966,11 @@
if($j("#creative-commons").attr("checked")){
$j('#creative-commons-website').show();
$j('#infield-creative-commons-website').show();
+ if($j("#other-license").attr("checked")){
+ $j('#other-license-website').hide();
+ $j('#infield-other-license-website').hide();
+ $j('#other-license').removeAttr('checked');
+ }
}
else{
$j('#creative-commons-website').hide();
@@ -905,9 +979,14 @@
});
$j("#other-license").click(function(){
- if($j("#other-license").attr("checked")){
+ if($j("#other-license").attr("checked")){
$j('#other-license-website').show();
$j('#infield-other-license-website').show();
+ if($j("#creative-commons").attr("checked")){
+ $j('#other-license-website').hide();
+ $j('#infield-other-license-website').hide();
+ $j('#creative-commons').removeAttr('checked');
+ }
}
else{
$j('#other-license-website').hide();
More information about the Movecommons-commits
mailing list