~michael-howden/sahana-eden/eden

« back to all changes in this revision

Viewing changes to static/scripts/S3/s3.msg.js

  • Committer: Michael Howden
  • Date: 2012-01-18 02:46:12 UTC
  • mfrom: (2653.1.486 eden)
  • Revision ID: michael@sahanafoundation.org-20120118024612-70bahuqx9rezd8w7
Merge Trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Used by the Compose function in Messaging (modules/s3msg.py)
 
3
 * This script is in Static to allow caching
 
4
 * Dynamic constants (e.g. Internationalised strings) are set in server-generated script
 
5
 */
 
6
 
 
7
/* Global vars */
 
8
//S3.msg = Object();
 
9
 
 
10
function s3_msg_ac_pe_input() {
 
11
    // Hide the real Input Field
 
12
    $('#msg_outbox_pe_id').hide();
 
13
    // Autocomplete-enable the Dummy Input
 
14
    $('#dummy').autocomplete({
 
15
        source: S3.msg_search_url,
 
16
        minLength: 2,
 
17
        focus: function( event, ui ) {
 
18
            $( '#dummy' ).val( ui.item.name );
 
19
            return false;
 
20
        },
 
21
        select: function( event, ui ) {
 
22
            $( '#dummy_input' ).val( ui.item.name );
 
23
            $( '#msg_outbox_pe_id' ).val( ui.item.id );
 
24
            return false;
 
25
        }
 
26
    })
 
27
    .data( 'autocomplete' )._renderItem = function( ul, item ) {
 
28
        return $( '<li></li>' )
 
29
            .data( 'item.autocomplete', item )
 
30
            .append( '<a>' + item.name + '</a>' )
 
31
            .appendTo( ul );
 
32
    };
 
33
}
 
34
 
 
35
$(document).ready(function() {
 
36
    if ($('#msg_outbox_pr_message_method').val() != 'EMAIL') {
 
37
        // SMS/Tweets don't have subjects
 
38
        $('#msg_log_subject__row').hide();
 
39
    }
 
40
    $('#msg_outbox_pr_message_method').change(function() {
 
41
        if ($(this).val() == 'EMAIL') {
 
42
            // Emails have a Subject
 
43
            $('#msg_log_subject__row').show();
 
44
        } else {
 
45
            $('#msg_log_subject__row').hide();
 
46
        }
 
47
    });
 
48
});
 
 
b'\\ No newline at end of file'