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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* ------------------------------------------------------------------------------
*
* # Context menu
*
* Specific JS code additions for extra_context_menu.html page
*
* Version: 1.0
* Latest update: Aug 1, 2015
*
* ---------------------------------------------------------------------------- */
$(function() {
// Basic setup
// ------------------------------
// Initialize using JS
$('.context-js').contextmenu({
target: '.context-js-menu'
});
// Exclude elements
$('.context-deactivate').contextmenu({
target: '.context-deactivate-menu',
before: function (e, element, target) {
e.preventDefault();
if (e.target.tagName == 'CODE') {
e.preventDefault();
this.closemenu();
return false;
}
return true;
}
});
// Dynamic replacement
$('.context-dynamic').contextmenu({
target: '.context-dynamic-menu',
before: function(e) {
this.getMenu().find('li').eq(2).find('a').html('<i class="icon-stack"></i> Item has been changed');
return true;
}
});
// Name on selection
$('.context-selection').contextmenu({
target: '.context-selection-menu',
onItem: function(context, e) {
alert($(e.target).text());
}
});
// Callbacks
// ------------------------------
// onShow callback
$('.context-show-menu').on('show.bs.context',function () {
alert('onShow event fired');
});
// onShown callback
$('.context-shown-menu').on('shown.bs.context',function () {
alert('onShown event fired');
});
// onHide callback
$('.context-hide-menu').on('hide.bs.context',function () {
alert('onHide event fired');
});
// onHidden callback
$('.context-hidden-menu').on('hidden.bs.context',function () {
alert('onHidden event fired');
});
});