Skip to content

Commit 3e6cace

Browse files
committed
Merge pull request joewalnes#26 from NoiseEee/master
Updated jQuery lib and methods / replaced .bind() with .on()
2 parents 2c09a51 + 2f84000 commit 3e6cace

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

demo/example.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
4+
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
55
<script src="../jquery.contextmenu.js"></script>
66
<link rel="stylesheet" href="../jquery.contextmenu.css">
77
<script>

jquery.contextmenu.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jQuery.fn.contextPopup = function(menuData) {
2626
// Define default settings
2727
var settings = {
2828
contextMenuClass: 'contextMenuPlugin',
29+
linkClickerClass: 'contextMenuLink',
2930
gutterLineClass: 'gutterLine',
3031
headerClass: 'header',
3132
seperatorClass: 'divider',
@@ -45,22 +46,22 @@ jQuery.fn.contextPopup = function(menuData) {
4546
}
4647
settings.items.forEach(function(item) {
4748
if (item) {
48-
var rowCode = '<li><a href="#"><span></span></a></li>';
49+
var rowCode = '<li><a href="#" class="'+settings.linkClickerClass+'"><span class="itemTitle"></span></a></li>';
4950
// if(item.icon)
5051
// rowCode += '<img>';
5152
// rowCode += '<span></span></a></li>';
5253
var row = $(rowCode).appendTo(menu);
5354
if(item.icon){
5455
var icon = $('<img>');
5556
icon.attr('src', item.icon);
56-
icon.insertBefore(row.find('span'));
57+
icon.insertBefore(row.find('.itemTitle'));
5758
}
58-
row.find('span').text(item.label);
59+
row.find('.itemTitle').text(item.label);
5960

6061
if (item.isEnabled != undefined && !item.isEnabled()) {
6162
row.addClass('disabled');
6263
} else if (item.action) {
63-
row.find('a').click(function () { item.action(e); });
64+
row.find('.'+settings.linkClickerClass).click(function () { item.action(e); });
6465
}
6566

6667
} else {
@@ -72,7 +73,7 @@ jQuery.fn.contextPopup = function(menuData) {
7273
}
7374

7475
// On contextmenu event (right click)
75-
this.bind('contextmenu', function(e) {
76+
this.on('contextmenu', function(e) {
7677
var menu = createMenu(e)
7778
.show();
7879

@@ -87,13 +88,13 @@ jQuery.fn.contextPopup = function(menuData) {
8788

8889
// Create and show menu
8990
menu.css({zIndex:1000001, left:left, top:top})
90-
.bind('contextmenu', function() { return false; });
91+
.on('contextmenu', function() { return false; });
9192

9293
// Cover rest of page with invisible div that when clicked will cancel the popup.
9394
var bg = $('<div></div>')
9495
.css({left:0, top:0, width:'100%', height:'100%', position:'absolute', zIndex:1000000})
9596
.appendTo(document.body)
96-
.bind('contextmenu click', function() {
97+
.on('contextmenu click', function() {
9798
// If click or right click anywhere else on page: remove clean up.
9899
bg.remove();
99100
menu.remove();

0 commit comments

Comments
 (0)