diff --git a/bower.json b/bower.json
index 3a36ebc..3ca53d0 100644
--- a/bower.json
+++ b/bower.json
@@ -6,7 +6,7 @@
"name": "Sudhanshu Yadav",
"email": "sudhanshuyadav2@gmail.com"
},
- "version": "1.2.3",
+ "version": "1.3.0",
"repository": {
"type": "git",
"url": "https://github.com/s-yadav/contextMenu.js"
diff --git a/contextMenu.js b/contextMenu.js
index 06aec96..0ccb3c1 100644
--- a/contextMenu.js
+++ b/contextMenu.js
@@ -1,5 +1,5 @@
/*
- *contextMenu.js v 1.2.3
+ *contextMenu.js v 1.3.0
*Author: Sudhanshu Yadav
*s-yadav.github.com
*Copyright (c) 2013 Sudhanshu Yadav.
@@ -157,6 +157,15 @@
menuData.option.baseTrigger = this;
iMethods.contextMenuBind.call(newElm, menuData.menuSelector, menuData.option);
},
+ open: function(sel,data){
+ data = data || {};
+ var e = data.event || new Event('click');
+ if(data.top) e.clientY = data.top;
+ if(data.left) e.clientX = data.left;
+ this.each(function(){
+ iMethods.eventHandler.call(this,e);
+ });
+ },
//to force context menu to close
close: function () {
var menuData = this.data('iw-menuData');
diff --git a/contextMenu.js.jquery.json b/contextMenu.js.jquery.json
index 5da1749..7dd52de 100644
--- a/contextMenu.js.jquery.json
+++ b/contextMenu.js.jquery.json
@@ -1,6 +1,6 @@
{
"name": "contextMenu.js",
- "version": "1.2.3",
+ "version": "1.3.0",
"title": "A light weight multi functional context menu plugin",
"author": {
"name": "Sudhanshu Yadav",
diff --git a/contextMenu.min.js b/contextMenu.min.js
index 991a201..c101135 100644
--- a/contextMenu.min.js
+++ b/contextMenu.min.js
@@ -1,8 +1,8 @@
/*
- *contextMenu.js v 1.2.3
+ *contextMenu.js v 1.3.0
*Author: Sudhanshu Yadav
*s-yadav.github.com
*Copyright (c) 2013 Sudhanshu Yadav.
*Dual licensed under the MIT and GPL licenses
*/
-;(function(e,t,n,r){"use strict";e.fn.contextMenu=function(t,n,r){if(!i[t]){r=n;n=t;t="popup"}else if(n){if(!(n instanceof Array||typeof n==="string"||n.nodeType||n.jquery)){r=n;n=null}}if(n instanceof Array&&t!="update"){t="menu"}var o=r;if(t!="update"){r=s.optionOtimizer(t,r);o=e.extend({},e.fn.contextMenu.defaults,r);if(!o.baseTrigger){o.baseTrigger=this}}i[t].call(this,n,o);return this};e.fn.contextMenu.defaults={triggerOn:"click",displayAround:"cursor",mouseClick:"left",verAdjust:0,horAdjust:0,top:"auto",left:"auto",closeOther:true,containment:t,winEventClose:true,sizeStyle:"auto",position:"auto",closeOnClick:true,onOpen:function(e,t){},afterOpen:function(e,t){},onClose:function(e,t){}};var i={menu:function(t,n){var r=e(this);t=s.createMenuList(r,t,n);s.contextMenuBind.call(this,t,n,"menu")},popup:function(t,n){e(t).addClass("iw-contextMenu");s.contextMenuBind.call(this,t,n,"popup")},update:function(t,n){var i=this;this.each(function(){var o=e(this),u=o.data("iw-menuData");if(!u){i.contextMenu("refresh");u=o.data("iw-menuData")}var a=u.menu;if(typeof t==="object"){for(var f=0;f')}}if(g){m.contextMenu("update",g)}}}s.onOff(a);u.option=e.extend({},u.option,n);o.data("iw-menuData",u);var b=u.option.triggerOn;if(n){if(b!=n.triggerOn){o.unbind(".contextMenu");o.bind(b+".contextMenu",s.eventHandler)}}})},refresh:function(){var t=this.filter(function(){return!!e(this).data("iw-menuData")}).data("iw-menuData"),n=this.filter(function(){return!e(this).data("iw-menuData")});t.option.baseTrigger=this;s.contextMenuBind.call(n,t.menuSelector,t.option)},close:function(){var e=this.data("iw-menuData");if(e){s.closeContextMenu(e.option,this,e.menu,null)}},value:function(e){var t=this.data("iw-menuData");if(t[e]){return t[e]}else if(t.option){return t.option[e]}return null},destroy:function(){this.each(function(){var t=e(this),n=t.data("iw-menuData").menuId,r=e(".iw-contextMenu[menuId="+n+"]"),i=r.data("iw-menuData");if(!i)return;if(i.noTrigger==1){if(r.hasClass("iw-created")){r.remove()}else{r.removeClass("iw-contextMenu "+n).removeAttr("menuId").removeData("iw-menuData");r.find("li.iw-mTrigger").contextMenu("destroy")}}else{i.noTrigger--;r.data("iw-menuData",i)}t.unbind(".contextMenu").removeClass("iw-mTrigger").removeData("iw-menuData")})}};var s={contextMenuBind:function(t,n,r){var i=this,o=e(t),u=o.data("iw-menuData");if(o.length==0){o=i.find(t);if(o.length==0){return}}if(r=="menu"){s.menuHover(o)}var a=n.baseTrigger;if(!u){var f;if(!a.data("iw-menuData")){f=Math.ceil(Math.random()*1e5);a.data("iw-menuData",{menuId:f})}else{f=a.data("iw-menuData").menuId}var l=o.clone();l.appendTo("body");u={menuId:f,menuWidth:l.outerWidth(true),menuHeight:l.outerHeight(true),noTrigger:1,trigger:i};o.data("iw-menuData",u).attr("menuId",f);l.remove()}else{u.noTrigger++;o.data("iw-menuData",u)}i.addClass("iw-mTrigger").data("iw-menuData",{menuId:u.menuId,option:n,menu:o,menuSelector:t,method:r});var c;if(n.triggerOn=="hover"){c="mouseenter";if(a.index(i)!=-1){a.add(o).bind("mouseleave.contextMenu",function(t){if(e(t.relatedTarget).closest(".iw-contextMenu").length==0){e('.iw-contextMenu[menuId="'+u.menuId+'"]').hide(100)}})}}else{c=n.triggerOn}i.delegate("input,a,.needs-click","click",function(e){e.stopImmediatePropagation()});i.bind(c+".contextMenu",s.eventHandler);o.bind("click mouseenter",function(e){e.stopPropagation()});o.delegate("li","click",function(e){if(n.closeOnClick)s.closeContextMenu(n,i,o,e)})},eventHandler:function(r){r.preventDefault();var i=e(this),o=i.data("iw-menuData"),u=o.menu,a=u.data("iw-menuData"),f=o.option,l=f.containment,c={trigger:i,menu:u},h=l==t,p=f.baseTrigger.index(i)==-1;if(!p&&f.closeOther){e(".iw-contextMenu").css("display","none")}u.find(".iw-mSelected").removeClass("iw-mSelected");f.onOpen.call(this,c,r);var d=e(l),v=d.innerHeight(),m=d.innerWidth(),g=0,y=0,b=a.menuHeight,w=a.menuWidth,E,S,x=0,T=0,N,C,k=E=parseInt(f.verAdjust),L=S=parseInt(f.horAdjust);if(!h){g=d.offset().top;y=d.offset().left;if(d.css("position")=="static"){d.css("position","relative")}}if(f.sizeStyle=="auto"){b=Math.min(b,v);w=Math.min(w,m);w=w+20}if(f.displayAround=="cursor"){x=h?r.clientX:r.clientX+e(t).scrollLeft()-y;T=h?r.clientY:r.clientY+e(t).scrollTop()-g;N=T+b;C=x+w;if(N>v){if(T-b<0){if(N-vm){if(x-w<0){if(C-mv){if(T-b<0){if(N-vm){if(x-w<0){if(C-m