(function ($, undefined) { var kendo = window.kendo, ui = kendo.ui, extend = $.extend, ContextMenu = ui.Menu.extend({/** @lends kendo.ui.ContextMenu.prototype */ /** * Creates a ContextMenu instance. * @constructs * @extends kendo.ui.Widget * @class ContextMenu UI widget * @param {Selector} element DOM element * @param {Object} options Configuration options. * @option {Object} [animation] A collection of Animation objects, used to change default animations. A value of false will disable all animations in the widget. *

Available animations for the ContextMenu are listed below. Each animation has a reverse options which is used for the close effect by default, but can be over-ridden * by setting the close animation. Each animation also has a direction which can be set off the animation (i.e. slideIn:Down).

*
*
*
slideIn
*
ContextMenu content slides in from the top
*
fadeIn
*
ContextMenu content fades in
*
expand
*
ContextMenu content expands from the top down. Similar to slideIn.
*
*
* _example * $("#menu").kendoContextMenu({ * animation: { open: { effects: "fadeIn" } } * }); * @option {Animation} [animation.open] The animation that will be used when opening sub menus. * @option {Animation} [animation.close] The animation that will be used when closing sub menus. * @option {Boolean} [closeOnClick] Specifies that sub menus should close after item selection (provided they won't navigate). * _example * $("#menu").kendoContextMenu({ * closeOnClick: false * }); * @option {Number} [hoverDelay] <100> Specifies the delay in ms before the menu is opened/closed - used to avoid accidental closure on leaving. * _example * $("#menu").kendoContextMenu({ * hoverDelay: 200 * }); * @option {String} [direction] <"default"> Specifies Menu opening direction. Can be "top", "bottom", "left", "right". * You can also specify different direction for root and sub menu items, separating them with space. The example below will initialize the root menu to open upwards and * its sub menus to the left. * _example * $("#menu").kendoContextMenu({ * direction: "top left" * }); */ init: function(element, options) { var that = this; ui.Menu.fn.init.call(that, element, options); element = that.element; options = that.options; var target = options.target; that.popup = element .wrap("
") .parent() .addClass("k-context-menu") .kendoPopup({ anchor: target || "body", collision: "fit flip" }).data("kendoPopup"); if (target) { $(target).on(options.event, function (e) { that.show(e.pageX, e.pageY); e.preventDefault(); }); } $(document.body).on(kendo.support.mouseup, function () { that.popup.close() }); }, options: { name: "ContextMenu", event: "contextmenu", orientation: "vertical", closeOnClick: true, target: null }, show: function(x, y) { var that = this; that.popup.wrapper.hide(); that.popup.open(x, y); } }); kendo.ui.plugin(ContextMenu); })(jQuery);