Project

General

Profile

1
$(function() {
2
    // copy notes list to sidebar
3
    altair_notes.copy_list_sidebar();
4
    // notes init functions
5
    altair_notes.init();
6
});
7

    
8
var $note_add_btn = $('#note_add'),
9
    $card_note = $('.md-card-single'),
10
    notes_list_class = '.notes_list', // main/sidebar list
11
    $notes_list = $('#notes_list');
12

    
13
altair_notes = {
14
    init: function () {
15
        altair_notes.add_new_note();
16
        altair_notes.open_note();
17
    },
18
    add_new_note: function() {
19
        if($note_add_btn) {
20
            var clear_inputs = function() {
21
                $card_note.find('#note_title,#note_content').val('');
22
                $notes_list.find('li').removeClass('md-list-item-active');
23
                $card_note.find('#note_title').focus();
24
            };
25
            $note_add_btn.on('click', function(e) {
26
                e.preventDefault();
27
                altair_md.card_show_hide($card_note,undefined,clear_inputs,undefined)
28
            })
29
        }
30
    },
31
    open_note: function() {
32
        // show note content
33
        var fill_inputs = function($this_note) {
34
            var note_content = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. A amet beatae eaque earum, eligendi error et iste iure iusto magni minus obcaecati quas qui quis quisquam, sit suscipit voluptas voluptatum.';
35
            $card_note.find('#note_title').val($this_note.children('.md-list-heading').text());
36
            $card_note.find('#note_content').val( "Note " + $this_note.attr('data-note-id') + " content \r\n" + note_content);
37
        };
38
        $(notes_list_class).find('a').on('click',function(e) {
39
            e.preventDefault();
40
            var $this_note = $(this);
41
            altair_md.card_show_hide($card_note,undefined,fill_inputs,$this_note);
42
            $(this).closest('li')
43
                .siblings('li').removeClass('md-list-item-active')
44
                .end()
45
                .addClass('md-list-item-active');
46
        });
47
    },
48
    copy_list_sidebar: function() {
49
        // hide secondary sidebar toggle btn for large screens
50
        $sidebar_secondary_toggle.addClass('uk-hidden-large');
51

    
52
        var notes_list_sidebar = $notes_list.clone();
53

    
54
        notes_list_sidebar.attr('id','notes_list_sidebar');
55

    
56
        $sidebar_secondary
57
            .find('.sidebar_secondary_wrapper').html(notes_list_sidebar);
58

    
59
    }
60
};
(55-55/114)