From 5a89a4dca6b51154611dbdfc6c7619ae4c68976d Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 23 May 2013 11:47:42 +0200 Subject: JavaSctipt added to CallForward view --- app/assets/javascripts/call_forward.js | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 app/assets/javascripts/call_forward.js (limited to 'app/assets') diff --git a/app/assets/javascripts/call_forward.js b/app/assets/javascripts/call_forward.js new file mode 100644 index 0000000..744fae0 --- /dev/null +++ b/app/assets/javascripts/call_forward.js @@ -0,0 +1,58 @@ + $(document).ready(function(){ + if($('#call_forward_call_forward_case_id').val() != "3"){ + $("#timeout_div").css('display','none'); + } + else{ + $("#timeout_div").css('display','block'); + } + $('#call_forward_call_forward_case_id').change(function(){ + if($(this).val() != "3"){ + $("#timeout_div").css('display','none'); + } + else{ + $("#timeout_div").css('display','block'); + } + }) + + var voicemail_pattern = /VoicemailAccount$/; + + if($('#call_forward_call_forwarding_destination').val() == ":PhoneNumber"){ + $("#destination_phone_number").attr('name', 'call_forward[destination]'); + $("#destination_greeting").attr('name', 'disabled'); + $("#destination_phone_number_div").css('display','block'); + $("#destination_greeting_div").css('display','none'); + + } + else if ($('#call_forward_call_forwarding_destination').val().match(voicemail_pattern)){ + $("#destination_phone_number").attr('name', 'disabled'); + $("#destination_greeting").attr('name', 'call_forward[destination]'); + $("#destination_phone_number_div").css('display','none'); + $("#destination_greeting_div").css('display','block'); + } + else { + $("#destination_phone_number").attr('name', 'disabled'); + $("#destination_greeting").attr('name', 'disabled'); + $("#destination_phone_number_div").css('display','none'); + $("#destination_greeting_div").css('display','none'); + } + $('#call_forward_call_forwarding_destination').change(function(){ + if($(this).val() == ":PhoneNumber"){ + $("#destination_phone_number").attr('name', 'call_forward[destination]'); + $("#destination_greeting").attr('name', 'disabled'); + $("#destination_phone_number_div").css('display','block'); + $("#destination_greeting_div").css('display','none'); + } + else if ($('#call_forward_call_forwarding_destination').val().match(voicemail_pattern)){ + $("#destination_phone_number").attr('name', 'disabled'); + $("#destination_greeting").attr('name', 'call_forward[destination]'); + $("#destination_phone_number_div").css('display','none'); + $("#destination_greeting_div").css('display','block'); + } + else{ + $("#destination_phone_number").attr('name', 'disabled'); + $("#destination_greeting").attr('name', 'disabled'); + $("#destination_phone_number_div").css('display','none'); + $("#destination_greeting_div").css('display','none'); + } + }) + }); -- cgit v1.2.3