Project

General

Profile

1
$(function() {
2
    // mailbox init functions
3
    altair_mailbox_v2.init();
4
});
5

    
6
// variables
7
var $mailbox = $('#mailboxV2');
8

    
9
altair_mailbox_v2 = {
10
    init: function() {
11
        // select messages
12
        altair_mailbox_v2.select_messages();
13
        // go to messages
14
        //altair_mailbox_v2.goto_message();
15
        // compose message
16
        altair_mailbox_v2.create_message();
17
        // scrollbar
18
        altair_helpers.custom_scrollbar($('.page_aside_inner'));
19
    },
20
    // select messages
21
    select_messages: function () {
22
        $mailbox.on('ifChanged', '[data-md-icheck]', function() {
23
            $(this).is(':checked') ? $(this).closest('tr').addClass('row-selected') : $(this).closest('tr').removeClass('row-selected');
24
        });
25

    
26
        $('#mailboxV2_select_all').on('ifChanged',function() {
27
            var $this = $(this);
28
            $mailbox.find('[data-md-icheck]').each(function() {
29
                $this.is(':checked') ? $(this).iCheck('check') : $(this).iCheck('uncheck');
30
            })
31
        });
32
    },
33
    // go to single messages
34
    goto_message: function () {
35
        // in html data-link="page_single_message.html"
36
        $mailbox.on('click', 'tr[data-link]', function(e) {
37
            var link = $(this).attr('data-link');
38
            console.log(link);
39
        });
40
    },
41
    // compose message
42
    create_message: function() {
43

    
44
        // callback on modal show
45
        $('#mailbox_new_message').on('show.uk.modal',function() {});
46

    
47
        // file upload
48
        var progressbar = $("#mail_progressbar"),
49
            bar         = progressbar.find('.uk-progress-bar'),
50
            settings    = {
51
                action: './upload/', // upload url
52
                single: false,
53
                loadstart: function() {
54
                    bar.css("width", "0%").text("0%");
55
                    progressbar.removeClass("uk-hidden uk-progress-danger");
56
                },
57
                progress: function(percent) {
58
                    percent = Math.ceil(percent);
59
                    bar.css("width", percent+"%").text(percent+"%");
60
                    if(percent == '100') {
61
                        setTimeout(function(){
62
                            //progressbar.addClass("uk-hidden");
63
                        }, 1500);
64
                    }
65
                },
66
                error: function(event) {
67
                    progressbar.addClass("uk-progress-danger");
68
                    bar.css({'width':'100%'}).text('100%');
69
                },
70
                abort: function(event) {
71
                    console.log(event);
72
                },
73
                complete: function(response, xhr) {
74
                    console.log(response);
75
                }
76
            };
77

    
78
        var select = UIkit.uploadSelect($("#mail_upload-select"), settings),
79
            drop   = UIkit.uploadDrop($("#mail_upload-drop"), settings);
80

    
81
    }
82
};
(53-53/114)