Created
April 17, 2012 07:49
-
-
Save aslam/2404258 to your computer and use it in GitHub Desktop.
Banyan
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
<% if @home_visit.errors.any? %> | |
/* Hide the flash notice div */ | |
$("#flash_notice").addClass('hidden') | |
/* Update the html of the div phone-call-errors with the new one */ | |
$("#home_visit_errors").html("<%= escape_javascript(errors_for(@home_visit).html_safe) %>"); | |
/* show the div phone-call-errors */ | |
$("#home_visit_errors").removeClass('hidden'); | |
<% else %> | |
/* Hide the div phone-call-errors */ | |
$("#flash_notice").hide(300); | |
/* Update the html of the div flash_notice with the new one */ | |
$("#flash_notice #message").html("<%= escape_javascript(flash[:notice]) %>"); | |
/* Show the flash_notice div */ | |
$("#flash_notice").show(300); | |
/* Close the form and show list-header */ | |
Followup.Controller.clearForm(); | |
/* Replace the html of the div phone-call-lists with the updated new one */ | |
$("div#home_visits").html("<%= escape_javascript( render(:partial => 'home_visits') ) %>"); | |
$("table.listing > tbody tr:nth-child(<%= @home_visits.index(@home_visit) + 1 %>)").effect("highlight", {}, 3000); | |
<% end %> |
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
var Followup = {}; | |
Followup.Controller = {}; | |
// Controller | |
(function() { | |
function init () { } | |
function showForm(input) { | |
$('div#follow_up_form').addClass('hidden'); | |
$('#spinner').show(); | |
var ele = $(input).val(); | |
var splits = ele.split('_'); | |
var control = splits.shift(); | |
resource = splits.join('_'); | |
switch(control){ | |
case "new": | |
$.ajax({ | |
url: '/' + resource + '/new', | |
success: function(data) { | |
}, | |
error: function(data) { | |
var notice = $('#flash_notice'); | |
notice.text('Something went wrong. Please try again later!'); | |
notice.removeClass('hidden'); | |
}, | |
complete: function() { | |
$('#spinner').hide(); | |
$('#search').addClass('hidden'); | |
} | |
}); | |
break; | |
} | |
} | |
function clearForm() { | |
$('div#follow_up_select').addClass('hidden'); | |
$('a#nb').removeClass('disabled'); | |
$('div#follow_up_form').addClass('hidden'); | |
} | |
var followup = Followup.Controller; | |
followup.init = init; | |
followup.showForm = showForm; | |
followup.clearForm = clearForm; | |
})(); // end Controller |
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
<%= content_for :scripts do %> | |
<%= javascript_include_tag 'nested_form', 'followups' %> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
$("#nav a#aftercare").trigger('click'); | |
}); | |
</script> | |
<% end %> | |
<%= content_tag :div, :id => "flash_notice", :class => 'hidden grid_13' do %> | |
<span id="message"></span> | |
<%= content_tag :span, :class => "controls" do %> | |
( click on this box to dismiss ) | |
<%= image_tag('icons/cancel.png') %> | |
<% end %> | |
<% end %> | |
<div id="simple-form" class="grid_14 append-bottom box omega"> | |
<div id="list-header"> | |
<span class="upcase"> Follow Up </span> | |
<span class="right"> | |
<%= image_tag 'ajax.gif', :id => 'spinner', :class => 'hidden' %> | |
<%= link_to 'Register New', "javascript:void(0);", :class => 'button red', | |
:onclick => "$('div#follow_up_select').removeClass('hidden'); $(this).addClass('disabled');", :id => 'nb' %> | |
</span> | |
</div> | |
<div id="follow_up_select" class="simple_form hidden"> | |
<div class="grid_13 append-bottom"> | |
<div class="grid_4"> | |
<input type="radio" value="new_home_visits" name="type" onclick="Followup.Controller.showForm(this);"> | |
<span class="upcase strong"> Home Visit </span> | |
</div> | |
<div class="grid_4"> | |
<input type="radio" value="new_telephone_follow_ups" name="type" onclick="Followup.Controller.showForm(this);"> | |
<span class="upcase strong"> Thelephone Follow Up </span> | |
</div> | |
</div> | |
</div> | |
<div id="follow_up_form" class="hidden"> | |
<div id="simple-form"> </div> | |
</div> | |
<div id="follow_up" class="hidden"> </div> | |
<div id="follow_ups" class="prepend-top_0"> <%= render 'follow_ups' %></div> | |
</div> |
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
.. | |
$('div#follow_up_form').removeClass('hidden'); | |
$("div#follow_up_form > #simple-form").html("<%= escape_javascript(render "form") %>"); | |
.. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment