Skip to content

Commit 2f84000

Browse files
author
Joshua Linux Work
committed
Addition of classes to some items, to allow for more accurate styling/targeting
- Class 'linkClicker' given to the clickable item, and associated handler(s) now identify by class rather than relying on a particular tag, should one change the markup structure in the future - title of item now classed with .itemTitle for similar reasons
1 parent 7361b5a commit 2f84000

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

jquery.contextmenu.js

Lines changed: 5 additions & 4 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 {

0 commit comments

Comments
 (0)