Created
January 24, 2013 07:52
-
-
Save maisaengineering/4618524 to your computer and use it in GitHub Desktop.
form_data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.dashContainer | |
%h1 Form: Permission for Screening | |
.standardForm | |
.standardForm | |
= form_tag update_form_res_profiles_path, :method => 'post', :name =>"form_data", :id =>"form_data", :onSubmit => "return validate_form_fields(this);", :html=>{:'data_type' => 'json'} do | |
=hidden_field_tag :form_id, value = params[:form_id] | |
=hidden_field_tag :org_id, value = params[:org_id] | |
=hidden_field_tag :season, value = params[:season] | |
=hidden_field_tag :child, value = params[:child] | |
=hidden_field_tag :email, value = params[:email] | |
//=JSON.parse(@form.content)['form'] | |
%br | |
%br | |
=JSON.parse(@form.content)['form']['name'].html_safe unless JSON.parse(@form.content)['form']['name'].blank? | |
=JSON.parse(@form.content)['form']['description'].html_safe unless JSON.parse(@form.content)['form']['description'].blank? | |
-JSON.parse(@form.content)['form']['panel'].each do |each_panel| | |
.formBox | |
.formSection #{each_panel['name']} | |
= each_panel['description'].html_safe unless each_panel['description'].blank? | |
%br | |
-unless each_panel['field'].nil? | |
- each_panel['field'].each do |each_field| | |
-if each_field['type'] == 'select' | |
%label #{each_field['id']} : | |
= select_tag :"#{each_field['name']}", options_for_select(each_field['selection_list']) | |
-elsif each_field['type'] == 'textarea' | |
%label | |
#{each_field['id']} : | |
.formErrorText{:id => "loading#{each_field['id']}"} | |
= text_area_tag :"#{each_field['name']}",'',:maxlength=>'40',:onblur =>"activate('#{each_field['id']}','#{each_field['type']}', '#{each_field['required']}' )" | |
-elsif each_field['type'] == 'date' | |
%label #{each_field['id']} : | |
= text_field_tag :"#{each_field['name']}", '',:class=>"hasDatepicker" | |
-elsif each_field['type'] == 'radio_button' | |
%label #{each_field['id']} : | |
-each_field['items'].each do |each_checkbox| | |
= each_checkbox['boxLabel'] | |
= radio_button_tag :"#{each_checkbox['boxLabel']}",name ="each_checkbox['boxLabel']",checked = false | |
//= radio_button_tag :"#{each_checkbox['boxLabel']}",name ="each_checkbox['boxLabel']",checked = each_checkbox['checked'] | |
-elsif each_field['type'] == 'check_box' | |
= check_box_tag :"#{each_field['name']}",name ="each_field['name']",checked = false, :onclick => "displaying(checked);",:onblur =>"activate('#{each_field['id']}','#{each_field['type']}', '#{each_field['required']}' )" | |
%label #{each_field['id']} | |
%br | |
-elsif each_field['type'] == 'password' | |
.styles{:style => "display:#{each_field['display']}"} | |
%label | |
#{each_field['type']} : | |
.formErrorText{:id => "loading#{each_field['id']}"} | |
= password_field_tag :"#{each_field['id']}",'', :onblur =>"activate('#{each_field['id']}','#{each_field['type']}', '#{each_field['required']}')" | |
-else | |
%label | |
#{each_field['id']} : | |
.formErrorText{:id => "loading#{each_field['id']}"} | |
= text_field_tag :"#{each_field['id']}" ,"#{each_field['value']}", :onblur =>"activate('#{each_field['id']}','#{each_field['type']}', '#{each_field['required']}')" | |
%br | |
%br | |
.standardForm | |
= submit_tag "Submit changes", :onclick =>"onsubmission()" | |
%input.btnCancel{:type => "reset", :value => "Cancel", :id => "reset"} | |
.childDashLeft | |
.cdlHome | |
= link_to "kidslink home", "#" | |
%ul.cdlOrgList | |
%li | |
= link_to "#{@kid_profile.kids_type.nickname} overview", child_dashboard_profiles_path(:child => params[:child], :email =>params[:email]) | |
- prv_org = [] | |
- @orgnization_season.each do |org| | |
- org_id = org.split(',')[3] | |
- if !prv_org.include?(org_id) | |
-season_acc=org.split(',')[2] | |
-if(season_acc!="applied") | |
-if(params[:org]==org.split(',')[3]) | |
%li.selected | |
= link_to "#{(org.split(',')[12])}", child_org_dashboard_profiles_path(:child => params[:child], :org =>org.split(',')[3], :email =>params[:email]) | |
-else | |
%li | |
= link_to "#{(org.split(',')[12])}", child_org_dashboard_profiles_path(:child => params[:child], :org =>org.split(',')[3], :email =>params[:email]) | |
- prv_org.push(org_id) | |
- prv_org1 = [] | |
- @orgnization_season.each do |org| | |
- org_id = org.split(',')[3] | |
- if !prv_org1.include?(org_id) | |
-season_acc=org.split(',')[2] | |
-if(season_acc=="applied") | |
-if(params[:org]==org.split(',')[3]) | |
%li.selected | |
= link_to "#{(org.split(',')[12])}", child_org_dashboard_profiles_path(:child => params[:child], :org =>org.split(',')[3], :email =>params[:email]) | |
-else | |
%li.atApp | |
= link_to "#{(org.split(',')[12])}<span> (@appl) </span>".html_safe, child_org_dashboard_profiles_path(:child => params[:child], :org =>org.split(',')[3], :email =>params[:email]) | |
- prv_org1.push(org_id) | |
.cdlApplyAnotherBox | |
= link_to "Apply", "#", :class => 'cdlApplyLink' | |
for another KidsLink affiliated organization | |
:javascript | |
function activate(field_id, field_type, field_required) | |
{ | |
if($("form:not(.filter) :input:visible:enabled:first").val()=="") | |
{ | |
$("form:not(.filter) :input:visible:enabled:first").focus(); | |
$('html, body').animate({ scrollTop: 0 }, 'slow'); | |
} | |
var field_name = field_id; | |
var field_val = $('#'+field_id).val(); | |
$.ajax({ | |
url: "/profiles/validate_form", | |
data: { field_val : field_val, field_name: field_name, field_type: field_type, field_required: field_required }, | |
cache: false, | |
beforeSend: function( ) { | |
$('#loading'+field_name).append("loading..."); | |
}, | |
success: function(html){ | |
$('#loading'+field_name).empty(); | |
$('#loading'+field_name).append(html); | |
}, | |
error: function( ) { | |
$('#loading'+field_name).empty(); | |
$('#loading'+field_name).append("...error loading..."); | |
} | |
}); | |
} | |
function validate_form_fields(str) | |
{ | |
$('#form_data input').blur(function() | |
{ | |
if( !$(this).val() ) { | |
$('html, body').animate({ scrollTop: 0 }, 'slow'); | |
return false; | |
} | |
}); | |
if($("form:not(.filter) :input:visible:enabled:first").val()=="") | |
{ | |
$("form:not(.filter) :input:visible:enabled:first").focus(); | |
$('html, body').animate({ scrollTop: 0 }, 'slow'); | |
return false; | |
} | |
} | |
$('#form_data1').submit(function() { | |
var values = {}; | |
$.each($('#form_data1').serializeArray(), function(i, field) { | |
//alert(values[field.name) | |
values[field.name] = field.name; | |
values[field.val] = field.value; | |
if(field.value=="") | |
{ | |
field_name = '#'+field.name | |
alert(field_name) | |
return false; | |
} | |
return false; | |
}); | |
}); | |
$('#reset').live('click',function() { | |
$('html, body').animate({ scrollTop: 0 }, 'slow'); | |
$('#form')[0].reset(); | |
}); | |
function displaying(checked) | |
{ | |
if(checked== true) | |
$(".styles").css("display", "block"); | |
else | |
$(".styles").css("display", "none"); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment