summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/call_forward.js
blob: 13c5679a24fcba724d20f5821d00a96c9115d95e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
 $(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()) {

        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');
            }
        })
    }
  });