From 8bd6a396c891b3f0cc7e4d63f7b00e2c9d61a9b6 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 24 May 2013 16:44:02 +0200 Subject: broken javascript on non call_forwarding views fixed --- app/assets/javascripts/call_forward.js | 53 ++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 25 deletions(-) (limited to 'app/assets/javascripts/call_forward.js') diff --git a/app/assets/javascripts/call_forward.js b/app/assets/javascripts/call_forward.js index 744fae0..13c5679 100644 --- a/app/assets/javascripts/call_forward.js +++ b/app/assets/javascripts/call_forward.js @@ -16,43 +16,46 @@ 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'); + if($('#call_forward_call_forwarding_destination').val()) { - } - 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"){ + 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{ + } + 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