Project

General

Profile

1
$(function() {
2
    // context menu
3
    altair_context_menu.cm_text();
4
    altair_context_menu.cm_image();
5
});
6

    
7
altair_context_menu = {
8
    cm_text: function() {
9
        // text
10
        var items = {
11
            'undo': {
12
                name: "Undo",
13
                icon: function(opt, $itemElement, itemKey, item){
14
                    console.log(item);
15
                    // Set the content to the menu trigger selector and add an bootstrap icon to the item.
16
                    $itemElement.html('<i class="material-icons">&#xE166;</i> ' + item.name);
17

    
18
                    // Add the context-menu-icon-updated class to the item
19
                    return 'context-menu-material';
20
                },
21
                disabled: function(key, opt){
22
                    return true;
23
                }
24
            },
25
            'redo': {
26
                name: "Redo",
27
                icon: function(opt, $itemElement, itemKey, item){
28
                    console.log(item);
29
                    // Set the content to the menu trigger selector and add an bootstrap icon to the item.
30
                    $itemElement.html('<i class="material-icons">&#xE15A;</i> ' + item.name);
31

    
32
                    // Add the context-menu-icon-updated class to the item
33
                    return 'context-menu-material';
34
                }
35
            },
36
            "sep1": "---------",
37
            'edit': {
38
                name: "Edit",
39
                icon: function(opt, $itemElement, itemKey, item){
40
                    console.log(item);
41
                    // Set the content to the menu trigger selector and add an bootstrap icon to the item.
42
                    $itemElement.html('<i class="material-icons">&#xE254;</i> ' + item.name);
43

    
44
                    // Add the context-menu-icon-updated class to the item
45
                    return 'context-menu-material';
46
                }
47
            },
48
            'cut': {
49
                name: "Cut",
50
                icon: function(opt, $itemElement, itemKey, item){
51
                    // Set the content to the menu trigger selector and add an bootstrap icon to the item.
52
                    $itemElement.html('<i class="material-icons">&#xE14E;</i> ' + item.name);
53

    
54
                    // Add the context-menu-icon-updated class to the item
55
                    return 'context-menu-material';
56
                }
57
            },
58
            'copy': {
59
                name: "Copy",
60
                icon: function(opt, $itemElement, itemKey, item){
61
                    // Set the content to the menu trigger selector and add an bootstrap icon to the item.
62
                    $itemElement.html('<i class="material-icons">&#xE14D;</i> ' + item.name);
63

    
64
                    // Add the context-menu-icon-updated class to the item
65
                    return 'context-menu-material';
66
                }
67
            },
68
            'paste': {
69
                name: "Paste",
70
                icon: function(opt, $itemElement, itemKey, item){
71
                    // Set the content to the menu trigger selector and add an bootstrap icon to the item.
72
                    $itemElement.html('<i class="material-icons">&#xE14F;</i> ' + item.name);
73

    
74
                    // Add the context-menu-icon-updated class to the item
75
                    return 'context-menu-material';
76
                },
77
                disabled: function(key, opt){
78
                    return true;
79
                }
80
            },
81
            'delete': {
82
                name: "Delete",
83
                icon: function(opt, $itemElement, itemKey, item){
84
                    // Set the content to the menu trigger selector and add an bootstrap icon to the item.
85
                    $itemElement.html('<i class="material-icons">&#xE872;</i> ' + item.name);
86

    
87
                    // Add the context-menu-icon-updated class to the item
88
                    return 'context-menu-material md-color-red-600';
89
                }
90
            }
91
        };
92
        $.contextMenu({
93
            selector: '#context-text',
94
            callback: function(key, options) {
95
                var m = "clicked: " + key;
96
                window.console && console.log(m) || alert(m);
97
            },
98
            items: items
99
        });
100
    },
101
    cm_image: function() {
102
        var items = {
103
            'edit': {
104
                name: "Edit",
105
                icon: function(opt, $itemElement, itemKey, item){
106
                    console.log(item);
107
                    // Set the content to the menu trigger selector and add an bootstrap icon to the item.
108
                    $itemElement.html('<i class="material-icons">&#xE254;</i> ' + item.name);
109

    
110
                    // Add the context-menu-icon-updated class to the item
111
                    return 'context-menu-material';
112
                }
113
            },
114
            'replace': {
115
                name: "Replace",
116
                icon: function(opt, $itemElement, itemKey, item){
117
                    // Set the content to the menu trigger selector and add an bootstrap icon to the item.
118
                    $itemElement.html('<i class="material-icons">&#xE042;</i> ' + item.name);
119

    
120
                    // Add the context-menu-icon-updated class to the item
121
                    return 'context-menu-material';
122
                }
123
            },
124
            'archive': {
125
                name: "Archive",
126
                icon: function(opt, $itemElement, itemKey, item){
127
                    // Set the content to the menu trigger selector and add an bootstrap icon to the item.
128
                    $itemElement.html('<i class="material-icons">&#xE149;</i> ' + item.name);
129

    
130
                    // Add the context-menu-icon-updated class to the item
131
                    return 'context-menu-material';
132
                }
133
            },
134
            'delete': {
135
                name: "Delete",
136
                icon: function(opt, $itemElement, itemKey, item){
137
                    // Set the content to the menu trigger selector and add an bootstrap icon to the item.
138
                    $itemElement.html('<i class="material-icons">&#xE872;</i> ' + item.name);
139

    
140
                    // Add the context-menu-icon-updated class to the item
141
                    return 'context-menu-material md-color-red-600';
142
                }
143
            }
144
        };
145

    
146
        $.contextMenu({
147
            selector: '#context-image',
148
            callback: function(key, options) {
149
                var m = "clicked: " + key;
150
                window.console && console.log(m) || alert(m);
151
            },
152
            items: items
153
        });
154

    
155
    }
156
};
(81-81/114)