Skip to content
This repository was archived by the owner on Aug 14, 2021. It is now read-only.

Sample patch to enable hyphens as title #137

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions demo/index-1-12.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@
loadTheme: "Base"
});
*/
/* SAMPLE for issue #136: globally disable hyphen detection. */
$.ui.menu.prototype._isDivider = function(item) {
console.log("_isDivider", this, arguments);
// Match hyphen, em dash, en dash
// return !/[^\-\u2014\u2013\s]/.test( item.text() );
// return false;
return item.text() === "----";
};
/* Menu 1: init by passing an array of entries. */

$(document).contextmenu({
Expand All @@ -93,6 +101,8 @@
{title: "Cut <kbd>Ctrl+X</kbd>", cmd: "cut", uiIcon: "ui-icon-scissors"},
{title: "Copy <kbd>Ctrl+C</kbd>", cmd: "copy", uiIcon: "ui-icon-copy"},
{title: "Paste <kbd>Ctrl+V</kbd>", cmd: "paste", uiIcon: "ui-icon-clipboard", disabled: true },
{title: "-", cmd: "hyphen"},
{title: " - -", cmd: "hyphen2"},
{title: "----"},
{title: "More", children: [
{title: "Sub 1 (callback)", action: function(event, ui) { alert("action callback sub1");} },
Expand Down
3 changes: 2 additions & 1 deletion jquery.ui-contextmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ $.extend($.moogle.contextmenu, {

$parentLi.attr("data-command", entry.cmd);

if ( !/[^\-\u2014\u2013\s]/.test( entry.title ) ) {
if ( entry.title === "----" ) {
// if ( !/[^\-\u2014\u2013\s]/.test( entry.title ) ) {
// hyphen, em dash, en dash: separator as defined by UI Menu 1.10
$parentLi.text(entry.title);
} else {
Expand Down