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

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mar10 committed May 20, 2013
2 parents cd6dcc8 + 30e9f72 commit 78c7f1e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = function (grunt) {
connect: {
demo: {
options: {
hostname: "*", // make accessible from everywhere
hostname: "*", // make accessible from everywhere
port: 8080,
base: "./",
keepalive: true
Expand Down
7 changes: 3 additions & 4 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
font-family: "Trebuchet MS", "Helvetica", "Arial", "Verdana", "sans-serif";
font-size: .8em;
/* Prevent tablets from selecting text on taphold, etc:
Note:
Note:
If only the potential menu trigger elements should be protected, simply
use the 'preventSelect: true' option.
But we disable it more globally for table pcs, because the whole line
or paragraph will still be selected otherwise.
or paragraph will still be selected otherwise.
*/
-webkit-user-select: none;
-khtml-user-select: none;
Expand Down Expand Up @@ -96,7 +95,7 @@
beforeOpen: function(event, ui) {
var $menu = ui.menu,
$target = $(event.relatedTarget);
console.log("beforeOpen", this, event, ui, "" + CLIPBOARD);
// console.log("beforeOpen", this, event, ui, "" + CLIPBOARD);
$(document)
// .contextmenu("replaceMenu", [{title: "aaa"}, {title: "bbb"}])
// .contextmenu("setEntry", "cut", {title: "Cuty", uiIcon: "ui-icon-heart", disabled: true})
Expand Down
30 changes: 8 additions & 22 deletions jquery.ui-contextmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,8 @@
/*
* TODO:
* - change namespace to 'moogle'
* - use _on / _off
* - move version to prototype
* - generally take more advantage off http://api.jqueryui.com/jQuery.widget/
* - open() programatically at a given positon
*/
(function ($) {
// function getMenuFromEvent(event){
// var menu = $(event.target).closest(":ui-menu"),
// $menu = $(menu);
// return $menu.data("ui-menu") || $menu.data("menu");
// }
var supportSelectstart = "onselectstart" in document.createElement("div");

/** Return command without leading '#' (default to ""). */
Expand Down Expand Up @@ -55,18 +46,18 @@
var eventNames, targetId,
opts = this.options;

console.log(this.element)
// console.log(this.element)

this.$headStyle = null;
this.orgMenu = null;
this.currentTarget = null;
this.ns = "." + this.widgetName;

if(opts.preventSelect){
// Create a global style for all potential menu targets
// If the contextmenu was bound to `document`, we apply the
// selector relative to the <body> tag instead
targetId = ($(this.element).is(document) ? $("body") : this.element).uniqueId().attr("id");
// If the contextmenu was bound to `document`, we apply the
// selector relative to the <body> tag instead
targetId = ($(this.element).is(document) ? $("body") : this.element).uniqueId().attr("id");
this.$headStyle = $("<style class='ui-contextmenu-style'>")
.prop("type", "text/css")
.html("#" + targetId + " " + opts.delegate + " { " +
Expand Down Expand Up @@ -210,9 +201,6 @@
_getMenu: function(){
// this.options.menu may be a string, jQuery or a function returning that.
var $menu = this.options.menu;
// if( $.isFunction($menu) ){
// $menu = $menu();
// }
return (typeof $menu === "string") ? $($menu) : $menu;
},
/** Open context menu on a specific target (must match options.delegate) */
Expand All @@ -233,7 +221,6 @@
},
/** Redefine the whole menu. */
replaceMenu: function(data){
// return this.element.contextmenu("option", "menu", menu);
var opts = this.options,
$menu = this._getMenu();

Expand Down Expand Up @@ -270,8 +257,7 @@
.first()
.replaceWith(titleOrData);
}else{
$parent = $entry.closest("li");
$parent.empty();
$parent = $entry.closest("li").empty();
$.ui.contextmenu.createEntryMarkup(titleOrData, $parent);
}
},
Expand Down Expand Up @@ -301,7 +287,7 @@ $.extend($.ui.contextmenu, {
$a.append($("<span class='ui-icon'>").addClass(entry.uiIcon));
}
if(entry.disabled){
$a.addClass("ui-state-disabled");
$parentLi.addClass("ui-state-disabled");
}
}
return $a;
Expand Down
4 changes: 2 additions & 2 deletions jquery.ui-contextmenu.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 78c7f1e

Please sign in to comment.