diff --git a/build/ol3-contextmenu-debug.js b/build/ol3-contextmenu-debug.js
index 48c1882..7aabf37 100644
--- a/build/ol3-contextmenu-debug.js
+++ b/build/ol3-contextmenu-debug.js
@@ -1,8 +1,8 @@
/**
* Custom Context Menu for Openlayers 3
* https://github.com/jonataswalker/ol3-contextmenu
- * Version: v2.0.1
- * Built: 2016-05-23T11:41:14-0300
+ * Version: v2.1.0
+ * Built: 2016-05-23T15:06:24-0300
*/
(function (global, factory) {
@@ -287,6 +287,10 @@
};
var eventType = {
+ /**
+ * Triggered before context menu is openned.
+ */
+ BEFOREOPEN: 'beforeopen',
/**
* Triggered when context menu is openned.
*/
@@ -465,7 +469,7 @@
this.Base.dispatchEvent({
type: eventType.OPEN,
pixel: pixel,
- coordinate: coordinate,
+ coordinate: coordinate
});
};
@@ -484,11 +488,22 @@
var this_ = this,
map = this.map,
canvas = map.getTargetElement(),
- menu = function(evt){
- evt.stopPropagation();
- evt.preventDefault();
+ menu = function(evt) {
this_.coordinate_clicked = map.getEventCoordinate(evt);
this_.pixel_clicked = map.getEventPixel(evt);
+
+ this_.Base.dispatchEvent({
+ type: eventType.BEFOREOPEN,
+ pixel: this_.pixel_clicked,
+ coordinate: this_.coordinate_clicked
+ });
+
+ if (this_.Base.disabled) {
+ return;
+ }
+
+ evt.stopPropagation();
+ evt.preventDefault();
this_.openMenu(this_.pixel_clicked, this_.coordinate_clicked);
//one-time fire
@@ -655,6 +670,7 @@
);
this.options = utils.mergeOptions(defaultOptions, opt_options);
+ this.disabled = false;
Base.Internal = new Internal(this);
Base.Html = new Html(this);
@@ -677,6 +693,27 @@
utils.removeAllChildren(this.container);
};
+ /**
+ * Enable menu
+ */
+ Base.prototype.enable = function enable() {
+ this.disabled = false;
+ };
+
+ /**
+ * Disable menu
+ */
+ Base.prototype.disable = function disable() {
+ this.disabled = true;
+ };
+
+ /**
+ * @return {Array} Returns default items
+ */
+ Base.prototype.getDefaultItems = function getDefaultItems() {
+ return defaultItems;
+ };
+
/**
* Add items to the menu. This pushes each item in the provided array
* to the end of the menu.
@@ -687,16 +724,6 @@
arr.forEach(this.push, this);
};
- /**
- * Insert the provided item at the end of the menu.
- * @param {Object|String} item Item.
- */
- Base.prototype.push = function push(item) {
- utils.assert(utils.isDefAndNotNull(item), '@param `item` must be informed.');
- Base.Html.addMenuEntry(item, Base.Internal.getNextItemIndex());
- Base.Internal.positionContainer(Base.Internal.getPixelClicked());
- };
-
/**
* Remove the last item of the menu.
*/
@@ -708,10 +735,13 @@
};
/**
- * @return {Array} Returns default items
+ * Insert the provided item at the end of the menu.
+ * @param {Object|String} item Item.
*/
- Base.prototype.getDefaultItems = function getDefaultItems() {
- return defaultItems;
+ Base.prototype.push = function push(item) {
+ utils.assert(utils.isDefAndNotNull(item), '@param `item` must be informed.');
+ Base.Html.addMenuEntry(item, Base.Internal.getNextItemIndex());
+ Base.Internal.positionContainer(Base.Internal.getPixelClicked());
};
/**
diff --git a/build/ol3-contextmenu.css b/build/ol3-contextmenu.css
index 20ce60c..342baba 100644
--- a/build/ol3-contextmenu.css
+++ b/build/ol3-contextmenu.css
@@ -1,8 +1,8 @@
/**
* Custom Context Menu for Openlayers 3
* https://github.com/jonataswalker/ol3-contextmenu
- * Version: v2.0.1
- * Built: 2016-05-23T11:41:14-0300
+ * Version: v2.1.0
+ * Built: 2016-05-23T15:06:24-0300
*/
.ol-ctx-menu-container {
diff --git a/build/ol3-contextmenu.js b/build/ol3-contextmenu.js
index 6c0ef9f..95274b6 100644
--- a/build/ol3-contextmenu.js
+++ b/build/ol3-contextmenu.js
@@ -1,8 +1,8 @@
/**
* Custom Context Menu for Openlayers 3
* https://github.com/jonataswalker/ol3-contextmenu
- * Version: v2.0.1
- * Built: 2016-05-23T11:41:14-0300
+ * Version: v2.1.0
+ * Built: 2016-05-23T15:06:24-0300
*/
-!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.ContextMenu=e()}(this,function(){"use strict";var t="ol-ctx-menu",e="-container",n="-separator",s="-submenu",i="-hidden",o="-icon",a="-zoom-in",r="-zoom-out",l="ol-unselectable",c={isNumeric:function(t){return/^\d+$/.test(t)},classRegex:function(t){return new RegExp("(^|\\s+) "+t+" (\\s+|$)")},addClass:function(t,e,n){var s=this;if(Array.isArray(t))return void t.forEach(function(t){s.addClass(t,e)});for(var i=Array.isArray(e)?e:e.split(/\s+/),o=i.length;o--;)s.hasClass(t,i[o])||s._addClass(t,i[o],n)},_addClass:function(t,e,n){var s=this;t.classList?t.classList.add(e):t.className=(t.className+" "+e).trim(),n&&this.isNumeric(n)&&window.setTimeout(function(){s._removeClass(t,e)},n)},removeClass:function(t,e,n){var s=this;if(Array.isArray(t))return void t.forEach(function(t){s.removeClass(t,e,n)});for(var i=Array.isArray(e)?e:e.split(/\s+/),o=i.length;o--;)s.hasClass(t,i[o])&&s._removeClass(t,i[o],n)},_removeClass:function(t,e,n){var s=this;t.classList?t.classList.remove(e):t.className=t.className.replace(this.classRegex(e)," ").trim(),n&&this.isNumeric(n)&&window.setTimeout(function(){s._addClass(t,e)},n)},hasClass:function(t,e){return t.classList?t.classList.contains(e):this.classRegex(e).test(t.className)},toggleClass:function(t,e){var n=this;return Array.isArray(t)?void t.forEach(function(t){n.toggleClass(t,e)}):void(t.classList?t.classList.toggle(e):this.hasClass(t,e)?this._removeClass(t,e):this._addClass(t,e))},$:function(t){return t="#"===t[0]?t.substr(1,t.length):t,document.getElementById(t)},isElement:function(t){return"HTMLElement"in window?!!t&&t instanceof HTMLElement:!!t&&"object"==typeof t&&1===t.nodeType&&!!t.nodeName},find:function(t,e,n){void 0===e&&(e=window.document);var s=/^(#?[\w-]+|\.[\w-.]+)$/,i=/\./g,o=Array.prototype.slice,a=[];if(s.test(t))switch(t[0]){case"#":a=[this.$(t.substr(1))];break;case".":a=o.call(e.getElementsByClassName(t.substr(1).replace(i," ")));break;default:a=o.call(e.getElementsByTagName(t))}else a=o.call(e.querySelectorAll(t));return n?a:a[0]},getAllChildren:function(t,e){return[].slice.call(t.getElementsByTagName(e))},isEmpty:function(t){return!t||0===t.length},emptyArray:function(t){for(;t.length;)t.pop()},removeAllChildren:function(t){for(;t.firstChild;)t.removeChild(t.firstChild)},mergeOptions:function(t,e){var n={};for(var s in t)n[s]=t[s];for(var i in e)n[i]=e[i];return n},createFragment:function(t){var e=document.createDocumentFragment(),n=document.createElement("div");for(n.innerHTML=t;n.firstChild;)e.appendChild(n.firstChild);return e},contains:function(t,e){return!!~e.indexOf(t)},isDefAndNotNull:function(t){return null!=t},assertEqual:function(t,e,n){if(t!=e)throw new Error(n+" mismatch: "+t+" != "+e)},assert:function(t,e){if(void 0===e&&(e="Assertion failed"),!t){if("undefined"!=typeof Error)throw new Error(e);throw e}},events:function(){var t={},e=t.hasOwnProperty;return{subscribe:function(n,s){e.call(t,n)||(t[n]=[]);var i=t[n].push(s)-1;return{remove:function(){delete t[n][i]}}},publish:function(n,s){e.call(t,n)&&t[n].forEach(function(t){t(void 0!==s?s:{})})}}}},u={OPEN:"open",CLOSE:"close",ADD_MENU_ENTRY:"add-menu-entry"},d={width:150,default_items:!0},h=c.events(),m=[{text:"Zoom In",classname:[t+a,t+o].join(" "),callback:function(t,e){var n=e.getView(),s=ol.animation.pan({duration:1e3,source:n.getCenter()}),i=ol.animation.zoom({duration:1e3,resolution:n.getResolution()});e.beforeRender(s,i),n.setCenter(t.coordinate),n.setZoom(+n.getZoom()+1)}},{text:"Zoom Out",classname:[t+r,t+o].join(" "),callback:function(t,e){var n=e.getView(),s=ol.animation.pan({duration:1e3,source:n.getCenter()}),i=ol.animation.zoom({duration:1e3,resolution:n.getResolution()});e.beforeRender(s,i),n.setCenter(t.coordinate),n.setZoom(+n.getZoom()-1)}}],f=function(t){return this.Base=t,this.map=void 0,this.coordinate_clicked=void 0,this.pixel_clicked=void 0,this.counter=0,this.lineHeight=0,this.items={},this.submenu={left:this.Base.options.width-15+"px",last_left:""},this};f.prototype.init=function(t){this.map=t,this.setListeners(),this.Base.constructor.Html.createMenu(),this.lineHeight=this.Base.container.offsetHeight/this.getItemsLength()},f.prototype.getItemsLength=function(){var t=this,e=0;return Object.keys(this.items).forEach(function(n){t.items[n].submenu||t.items[n].separator||e++}),e},f.prototype.getPixelClicked=function(){return this.pixel_clicked},f.prototype.getCoordinateClicked=function(){return this.coordinate_clicked},f.prototype.positionContainer=function(e){var n=this,o=this.map.getSize(),a=o[0],r=o[1],l=r-e[1],u=a-e[0],d={w:this.Base.container.offsetWidth,h:Math.round(this.lineHeight*this.getItemsLength())},h=c.find("li."+t+s+">ul",this.Base.container,!0);u>=d.w?(this.Base.container.style.right="auto",this.Base.container.style.left=e[0]+5+"px"):(this.Base.container.style.left="auto",this.Base.container.style.right="15px"),l>=d.h?(this.Base.container.style.bottom="auto",this.Base.container.style.top=e[1]-10+"px"):(this.Base.container.style.top="auto",this.Base.container.style.bottom=0),c.removeClass(this.Base.container,t+i),h.length&&(u<2*d.w?this.submenu.last_left="-"+d.w+"px":this.submenu.last_left=this.submenu.left,h.forEach(function(t){t.style.left=n.submenu.last_left}))},f.prototype.openMenu=function(t,e){this.positionContainer(t),this.Base.dispatchEvent({type:u.OPEN,pixel:t,coordinate:e})},f.prototype.closeMenu=function(){c.addClass(this.Base.container,t+i),this.Base.dispatchEvent({type:u.CLOSE})},f.prototype.getNextItemIndex=function(){return++this.counter},f.prototype.setListeners=function(){var t=this,e=this.map,n=e.getTargetElement(),s=function(s){s.stopPropagation(),s.preventDefault(),t.coordinate_clicked=e.getEventCoordinate(s),t.pixel_clicked=e.getEventPixel(s),t.openMenu(t.pixel_clicked,t.coordinate_clicked),n.addEventListener("mousedown",{handleEvent:function(e){t.closeMenu(),n.removeEventListener(e.type,this,!1)}},!1)};n.addEventListener("contextmenu",s,!1),h.subscribe(u.ADD_MENU_ENTRY,function(e){t.setItemListener(e.element,e.index)})},f.prototype.setItemListener=function(t,e){var n=this;t&&"function"==typeof this.items[e].callback&&!function(s){t.addEventListener("click",function(t){t.preventDefault();var i={coordinate:n.getCoordinateClicked(),data:n.items[e].data||null};n.closeMenu(),s.call(void 0,i,n.map)},!1)}(this.items[e].callback)};var p=function(t){return this.Base=t,this.Base.container=this.container=this.createContainer(),this};p.prototype.createContainer=function(){var n=document.createElement("ul");return n.className=[t+e,t+i,l].join(" "),n.style.width=parseInt(this.Base.options.width,10)+"px",n},p.prototype.createMenu=function(){var t=this.Base.options,e=[];return"items"in t?e=t.default_items?t.items.concat(m):t.items:t.default_items&&(e=m),0===e.length?!1:void e.forEach(this.addMenuEntry,this)},p.prototype.addMenuEntry=function(n){var i=this,o=this.Base.constructor.Internal,a=o.getNextItemIndex(),r=t+s;if(n.items&&Array.isArray(n.items)){n.classname=n.classname||"",c.contains(r,n.classname)||(n.classname+=" "+r);var l=this.generateHtmlAndPublish(this.container,n,a),u=document.createElement("ul");u.className=t+e,u.style.left=o.submenu.last_left||o.submenu.left,u.style.width=this.Base.options.width+"px",l.appendChild(u),n.items.forEach(function(t){i.generateHtmlAndPublish(u,t,o.getNextItemIndex(),!0)})}else this.generateHtmlAndPublish(this.container,n,a)},p.prototype.generateHtmlAndPublish=function(e,s,i,a){var r,l,d,m=!1,f=this.Base.constructor.Internal;return"string"==typeof s&&"-"==s.trim()?(r='
',l=c.createFragment(r),d=[].slice.call(l.childNodes,0)[0],e.appendChild(l),m=!0):(s.classname=s.classname||"",r=""+s.text+"",l=c.createFragment(r),d=document.createElement("li"),s.icon&&(""===s.classname?s.classname=t+o:-1===s.classname.indexOf(t+o)&&(s.classname+=" "+t+o),d.setAttribute("style","background-image:url("+s.icon+")")),d.id="index"+i,d.className=s.classname,d.appendChild(l),e.appendChild(d)),f.items[i]={id:i,submenu:a||0,separator:m,callback:s.callback,data:s.data||null},h.publish(u.ADD_MENU_ENTRY,{index:i,element:d}),d};var y=function(t){function e(n){void 0===n&&(n={}),c.assert("object"==typeof n,"@param `opt_options` should be object type!"),this.options=c.mergeOptions(d,n),e.Internal=new f(this),e.Html=new p(this),t.call(this,{element:this.container})}return e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.clear=function(){Object.keys(e.Internal.items).forEach(function(t){delete e.Internal.items[t]}),c.removeAllChildren(this.container)},e.prototype.extend=function(t){c.assert(Array.isArray(t),"@param `arr` should be an Array."),t.forEach(this.push,this)},e.prototype.push=function(t){c.assert(c.isDefAndNotNull(t),"@param `item` must be informed."),e.Html.addMenuEntry(t,e.Internal.getNextItemIndex()),e.Internal.positionContainer(e.Internal.getPixelClicked())},e.prototype.pop=function(){var t=this.container.lastChild;t&&this.container.removeChild(t)},e.prototype.getDefaultItems=function(){return m},e.prototype.setMap=function(t){ol.control.Control.prototype.setMap.call(this,t),e.Internal.init(t)},e}(ol.control.Control);return y});
+!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.ContextMenu=e()}(this,function(){"use strict";var t="ol-ctx-menu",e="-container",n="-separator",i="-submenu",s="-hidden",o="-icon",a="-zoom-in",r="-zoom-out",l="ol-unselectable",c={isNumeric:function(t){return/^\d+$/.test(t)},classRegex:function(t){return new RegExp("(^|\\s+) "+t+" (\\s+|$)")},addClass:function(t,e,n){var i=this;if(Array.isArray(t))return void t.forEach(function(t){i.addClass(t,e)});for(var s=Array.isArray(e)?e:e.split(/\s+/),o=s.length;o--;)i.hasClass(t,s[o])||i._addClass(t,s[o],n)},_addClass:function(t,e,n){var i=this;t.classList?t.classList.add(e):t.className=(t.className+" "+e).trim(),n&&this.isNumeric(n)&&window.setTimeout(function(){i._removeClass(t,e)},n)},removeClass:function(t,e,n){var i=this;if(Array.isArray(t))return void t.forEach(function(t){i.removeClass(t,e,n)});for(var s=Array.isArray(e)?e:e.split(/\s+/),o=s.length;o--;)i.hasClass(t,s[o])&&i._removeClass(t,s[o],n)},_removeClass:function(t,e,n){var i=this;t.classList?t.classList.remove(e):t.className=t.className.replace(this.classRegex(e)," ").trim(),n&&this.isNumeric(n)&&window.setTimeout(function(){i._addClass(t,e)},n)},hasClass:function(t,e){return t.classList?t.classList.contains(e):this.classRegex(e).test(t.className)},toggleClass:function(t,e){var n=this;return Array.isArray(t)?void t.forEach(function(t){n.toggleClass(t,e)}):void(t.classList?t.classList.toggle(e):this.hasClass(t,e)?this._removeClass(t,e):this._addClass(t,e))},$:function(t){return t="#"===t[0]?t.substr(1,t.length):t,document.getElementById(t)},isElement:function(t){return"HTMLElement"in window?!!t&&t instanceof HTMLElement:!!t&&"object"==typeof t&&1===t.nodeType&&!!t.nodeName},find:function(t,e,n){void 0===e&&(e=window.document);var i=/^(#?[\w-]+|\.[\w-.]+)$/,s=/\./g,o=Array.prototype.slice,a=[];if(i.test(t))switch(t[0]){case"#":a=[this.$(t.substr(1))];break;case".":a=o.call(e.getElementsByClassName(t.substr(1).replace(s," ")));break;default:a=o.call(e.getElementsByTagName(t))}else a=o.call(e.querySelectorAll(t));return n?a:a[0]},getAllChildren:function(t,e){return[].slice.call(t.getElementsByTagName(e))},isEmpty:function(t){return!t||0===t.length},emptyArray:function(t){for(;t.length;)t.pop()},removeAllChildren:function(t){for(;t.firstChild;)t.removeChild(t.firstChild)},mergeOptions:function(t,e){var n={};for(var i in t)n[i]=t[i];for(var s in e)n[s]=e[s];return n},createFragment:function(t){var e=document.createDocumentFragment(),n=document.createElement("div");for(n.innerHTML=t;n.firstChild;)e.appendChild(n.firstChild);return e},contains:function(t,e){return!!~e.indexOf(t)},isDefAndNotNull:function(t){return null!=t},assertEqual:function(t,e,n){if(t!=e)throw new Error(n+" mismatch: "+t+" != "+e)},assert:function(t,e){if(void 0===e&&(e="Assertion failed"),!t){if("undefined"!=typeof Error)throw new Error(e);throw e}},events:function(){var t={},e=t.hasOwnProperty;return{subscribe:function(n,i){e.call(t,n)||(t[n]=[]);var s=t[n].push(i)-1;return{remove:function(){delete t[n][s]}}},publish:function(n,i){e.call(t,n)&&t[n].forEach(function(t){t(void 0!==i?i:{})})}}}},u={BEFOREOPEN:"beforeopen",OPEN:"open",CLOSE:"close",ADD_MENU_ENTRY:"add-menu-entry"},d={width:150,default_items:!0},h=c.events(),m=[{text:"Zoom In",classname:[t+a,t+o].join(" "),callback:function(t,e){var n=e.getView(),i=ol.animation.pan({duration:1e3,source:n.getCenter()}),s=ol.animation.zoom({duration:1e3,resolution:n.getResolution()});e.beforeRender(i,s),n.setCenter(t.coordinate),n.setZoom(+n.getZoom()+1)}},{text:"Zoom Out",classname:[t+r,t+o].join(" "),callback:function(t,e){var n=e.getView(),i=ol.animation.pan({duration:1e3,source:n.getCenter()}),s=ol.animation.zoom({duration:1e3,resolution:n.getResolution()});e.beforeRender(i,s),n.setCenter(t.coordinate),n.setZoom(+n.getZoom()-1)}}],p=function(t){return this.Base=t,this.map=void 0,this.coordinate_clicked=void 0,this.pixel_clicked=void 0,this.counter=0,this.lineHeight=0,this.items={},this.submenu={left:this.Base.options.width-15+"px",last_left:""},this};p.prototype.init=function(t){this.map=t,this.setListeners(),this.Base.constructor.Html.createMenu(),this.lineHeight=this.Base.container.offsetHeight/this.getItemsLength()},p.prototype.getItemsLength=function(){var t=this,e=0;return Object.keys(this.items).forEach(function(n){t.items[n].submenu||t.items[n].separator||e++}),e},p.prototype.getPixelClicked=function(){return this.pixel_clicked},p.prototype.getCoordinateClicked=function(){return this.coordinate_clicked},p.prototype.positionContainer=function(e){var n=this,o=this.map.getSize(),a=o[0],r=o[1],l=r-e[1],u=a-e[0],d={w:this.Base.container.offsetWidth,h:Math.round(this.lineHeight*this.getItemsLength())},h=c.find("li."+t+i+">ul",this.Base.container,!0);u>=d.w?(this.Base.container.style.right="auto",this.Base.container.style.left=e[0]+5+"px"):(this.Base.container.style.left="auto",this.Base.container.style.right="15px"),l>=d.h?(this.Base.container.style.bottom="auto",this.Base.container.style.top=e[1]-10+"px"):(this.Base.container.style.top="auto",this.Base.container.style.bottom=0),c.removeClass(this.Base.container,t+s),h.length&&(u<2*d.w?this.submenu.last_left="-"+d.w+"px":this.submenu.last_left=this.submenu.left,h.forEach(function(t){t.style.left=n.submenu.last_left}))},p.prototype.openMenu=function(t,e){this.positionContainer(t),this.Base.dispatchEvent({type:u.OPEN,pixel:t,coordinate:e})},p.prototype.closeMenu=function(){c.addClass(this.Base.container,t+s),this.Base.dispatchEvent({type:u.CLOSE})},p.prototype.getNextItemIndex=function(){return++this.counter},p.prototype.setListeners=function(){var t=this,e=this.map,n=e.getTargetElement(),i=function(i){t.coordinate_clicked=e.getEventCoordinate(i),t.pixel_clicked=e.getEventPixel(i),t.Base.dispatchEvent({type:u.BEFOREOPEN,pixel:t.pixel_clicked,coordinate:t.coordinate_clicked}),t.Base.disabled||(i.stopPropagation(),i.preventDefault(),t.openMenu(t.pixel_clicked,t.coordinate_clicked),n.addEventListener("mousedown",{handleEvent:function(e){t.closeMenu(),n.removeEventListener(e.type,this,!1)}},!1))};n.addEventListener("contextmenu",i,!1),h.subscribe(u.ADD_MENU_ENTRY,function(e){t.setItemListener(e.element,e.index)})},p.prototype.setItemListener=function(t,e){var n=this;t&&"function"==typeof this.items[e].callback&&!function(i){t.addEventListener("click",function(t){t.preventDefault();var s={coordinate:n.getCoordinateClicked(),data:n.items[e].data||null};n.closeMenu(),i.call(void 0,s,n.map)},!1)}(this.items[e].callback)};var f=function(t){return this.Base=t,this.Base.container=this.container=this.createContainer(),this};f.prototype.createContainer=function(){var n=document.createElement("ul");return n.className=[t+e,t+s,l].join(" "),n.style.width=parseInt(this.Base.options.width,10)+"px",n},f.prototype.createMenu=function(){var t=this.Base.options,e=[];return"items"in t?e=t.default_items?t.items.concat(m):t.items:t.default_items&&(e=m),0===e.length?!1:void e.forEach(this.addMenuEntry,this)},f.prototype.addMenuEntry=function(n){var s=this,o=this.Base.constructor.Internal,a=o.getNextItemIndex(),r=t+i;if(n.items&&Array.isArray(n.items)){n.classname=n.classname||"",c.contains(r,n.classname)||(n.classname+=" "+r);var l=this.generateHtmlAndPublish(this.container,n,a),u=document.createElement("ul");u.className=t+e,u.style.left=o.submenu.last_left||o.submenu.left,u.style.width=this.Base.options.width+"px",l.appendChild(u),n.items.forEach(function(t){s.generateHtmlAndPublish(u,t,o.getNextItemIndex(),!0)})}else this.generateHtmlAndPublish(this.container,n,a)},f.prototype.generateHtmlAndPublish=function(e,i,s,a){var r,l,d,m=!1,p=this.Base.constructor.Internal;return"string"==typeof i&&"-"==i.trim()?(r='
',l=c.createFragment(r),d=[].slice.call(l.childNodes,0)[0],e.appendChild(l),m=!0):(i.classname=i.classname||"",r=""+i.text+"",l=c.createFragment(r),d=document.createElement("li"),i.icon&&(""===i.classname?i.classname=t+o:-1===i.classname.indexOf(t+o)&&(i.classname+=" "+t+o),d.setAttribute("style","background-image:url("+i.icon+")")),d.id="index"+s,d.className=i.classname,d.appendChild(l),e.appendChild(d)),p.items[s]={id:s,submenu:a||0,separator:m,callback:i.callback,data:i.data||null},h.publish(u.ADD_MENU_ENTRY,{index:s,element:d}),d};var y=function(t){function e(n){void 0===n&&(n={}),c.assert("object"==typeof n,"@param `opt_options` should be object type!"),this.options=c.mergeOptions(d,n),this.disabled=!1,e.Internal=new p(this),e.Html=new f(this),t.call(this,{element:this.container})}return e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.clear=function(){Object.keys(e.Internal.items).forEach(function(t){delete e.Internal.items[t]}),c.removeAllChildren(this.container)},e.prototype.enable=function(){this.disabled=!1},e.prototype.disable=function(){this.disabled=!0},e.prototype.getDefaultItems=function(){return m},e.prototype.extend=function(t){c.assert(Array.isArray(t),"@param `arr` should be an Array."),t.forEach(this.push,this)},e.prototype.pop=function(){var t=this.container.lastChild;t&&this.container.removeChild(t)},e.prototype.push=function(t){c.assert(c.isDefAndNotNull(t),"@param `item` must be informed."),e.Html.addMenuEntry(t,e.Internal.getNextItemIndex()),e.Internal.positionContainer(e.Internal.getPixelClicked())},e.prototype.setMap=function(t){ol.control.Control.prototype.setMap.call(this,t),e.Internal.init(t)},e}(ol.control.Control);return y});
diff --git a/build/ol3-contextmenu.min.css b/build/ol3-contextmenu.min.css
index 5b72bea..530febd 100644
--- a/build/ol3-contextmenu.min.css
+++ b/build/ol3-contextmenu.min.css
@@ -1,8 +1,8 @@
/**
* Custom Context Menu for Openlayers 3
* https://github.com/jonataswalker/ol3-contextmenu
- * Version: v2.0.1
- * Built: 2016-05-23T11:41:14-0300
+ * Version: v2.1.0
+ * Built: 2016-05-23T15:06:24-0300
*/
.ol-ctx-menu-container{position:absolute;padding:10px;list-style:none;background:#fff;color:#222;font-size:13px;border-radius:5px;box-shadow:rgba(0,0,0,.2) 3px 3px 5px;box-sizing:border-box}.ol-ctx-menu-container a,.ol-ctx-menu-container abbr,.ol-ctx-menu-container acronym,.ol-ctx-menu-container address,.ol-ctx-menu-container applet,.ol-ctx-menu-container article,.ol-ctx-menu-container aside,.ol-ctx-menu-container audio,.ol-ctx-menu-container b,.ol-ctx-menu-container big,.ol-ctx-menu-container blockquote,.ol-ctx-menu-container canvas,.ol-ctx-menu-container caption,.ol-ctx-menu-container center,.ol-ctx-menu-container cite,.ol-ctx-menu-container code,.ol-ctx-menu-container dd,.ol-ctx-menu-container del,.ol-ctx-menu-container details,.ol-ctx-menu-container dfn,.ol-ctx-menu-container div,.ol-ctx-menu-container dl,.ol-ctx-menu-container dt,.ol-ctx-menu-container em,.ol-ctx-menu-container embed,.ol-ctx-menu-container fieldset,.ol-ctx-menu-container figcaption,.ol-ctx-menu-container figure,.ol-ctx-menu-container footer,.ol-ctx-menu-container form,.ol-ctx-menu-container h1,.ol-ctx-menu-container h2,.ol-ctx-menu-container h3,.ol-ctx-menu-container h4,.ol-ctx-menu-container h5,.ol-ctx-menu-container h6,.ol-ctx-menu-container header,.ol-ctx-menu-container hgroup,.ol-ctx-menu-container i,.ol-ctx-menu-container iframe,.ol-ctx-menu-container img,.ol-ctx-menu-container ins,.ol-ctx-menu-container kbd,.ol-ctx-menu-container label,.ol-ctx-menu-container legend,.ol-ctx-menu-container li,.ol-ctx-menu-container mark,.ol-ctx-menu-container menu,.ol-ctx-menu-container nav,.ol-ctx-menu-container object,.ol-ctx-menu-container ol,.ol-ctx-menu-container output,.ol-ctx-menu-container p,.ol-ctx-menu-container pre,.ol-ctx-menu-container q,.ol-ctx-menu-container ruby,.ol-ctx-menu-container s,.ol-ctx-menu-container samp,.ol-ctx-menu-container section,.ol-ctx-menu-container small,.ol-ctx-menu-container span,.ol-ctx-menu-container strike,.ol-ctx-menu-container strong,.ol-ctx-menu-container sub,.ol-ctx-menu-container summary,.ol-ctx-menu-container sup,.ol-ctx-menu-container table,.ol-ctx-menu-container tbody,.ol-ctx-menu-container td,.ol-ctx-menu-container tfoot,.ol-ctx-menu-container th,.ol-ctx-menu-container thead,.ol-ctx-menu-container time,.ol-ctx-menu-container tr,.ol-ctx-menu-container tt,.ol-ctx-menu-container u,.ol-ctx-menu-container ul,.ol-ctx-menu-container var,.ol-ctx-menu-container video{margin:0;padding:0;border:0;font:inherit;font-size:100%;vertical-align:baseline}.ol-ctx-menu-container table{border-collapse:collapse;border-spacing:0}.ol-ctx-menu-container caption,.ol-ctx-menu-container td,.ol-ctx-menu-container th{text-align:left;font-weight:400;vertical-align:middle}.ol-ctx-menu-container blockquote,.ol-ctx-menu-container q{quotes:none}.ol-ctx-menu-container blockquote:after,.ol-ctx-menu-container blockquote:before,.ol-ctx-menu-container q:after,.ol-ctx-menu-container q:before{content:"";content:none}.ol-ctx-menu-container a img{border:none}.ol-ctx-menu-container *,.ol-ctx-menu-container ::after,.ol-ctx-menu-container ::before{box-sizing:inherit}.ol-ctx-menu-container.ol-ctx-menu-hidden{opacity:0;visibility:hidden;-webkit-transition:visibility 0s linear .3s,opacity .3s;transition:visibility 0s linear .3s,opacity .3s}.ol-ctx-menu-container li{position:relative;line-height:20px;padding:2px 5px}.ol-ctx-menu-container li:not(.ol-ctx-menu-separator):hover{cursor:pointer;background-color:#333;color:#eee}.ol-ctx-menu-container li.ol-ctx-menu-submenu ul{border:1px solid #eee;top:0;opacity:0;visibility:hidden;-webkit-transition:visibility 0s linear .3s,opacity .3s;transition:visibility 0s linear .3s,opacity .3s}.ol-ctx-menu-container li.ol-ctx-menu-submenu:hover ul{opacity:1;visibility:visible;-webkit-transition-delay:0s;transition-delay:0s}.ol-ctx-menu-container li.ol-ctx-menu-submenu::after{position:absolute;top:7px;right:10px;content:"";display:inline-block;width:.6em;height:.6em;border-right:.3em solid #222;border-top:.3em solid #222;-webkit-transform:rotate(45deg);transform:rotate(45deg)}.ol-ctx-menu-container li.ol-ctx-menu-submenu:hover::after{border-color:#eee}.ol-ctx-menu-container li.ol-ctx-menu-separator{padding:0}.ol-ctx-menu-container li.ol-ctx-menu-separator hr{border:0;height:1px;background-image:-webkit-linear-gradient(right,transparent,rgba(0,0,0,.75),transparent);background-image:linear-gradient(to left,transparent,rgba(0,0,0,.75),transparent)}.ol-ctx-menu-icon{text-indent:20px;background-size:20px auto;background-repeat:no-repeat;background-position:left center}.ol-ctx-menu-zoom-in{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABaUlEQVQ4T72U7VHCQBCGn90GtAMuNGCswFiBWIFQgWMFxg6wArECsQKhArEBiB1Qwa1zgQn5IAYcxv13k71n3919L8KJQ07M47+BzgG9TRfZ/JBuWhS6BJFHRJICYrZGZIz3z5Ct2+B7gG6I6kt+wewdkQVwjtkAkR5mC8yu26A1oItR/cTsOweQBdgutD8G7jGm2PJ2n8oqUKIpIjd4HxTM8gvaT/F+AlmWnyWaIXKF95eNguFzTYFhNsdWu9kFgFlaFMANUH3D8wDLoLgSTSD2il8NCe2ZXQBxWDGwxmyUzzOMBZ7wy7Qb2K0wQfXjMOBuhlFpZtNty5sFaTQBuTusZdymeqs1SpYKcO9HkE3KbTd9WFijMHJQ5hBNEAYNq5Qd0dhyke0GiE4QzjqfW23mHT8Hl4DG4Lce3FPE7AtbBSdsbNqpoJLgYkRnNeUV+xwJDHTnUEkxHGbhBXUs5TjJjew/KPy94g+NRaIVRYmMXwAAAABJRU5ErkJggg==)}.ol-ctx-menu-container li:hover.ol-ctx-menu-zoom-in{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABc0lEQVQ4T71U21ECQRDsJgGdvQDECMQIxAjECMQILCPwzAAjECIQI0AiEDPQAPaWCBhrcKHuCUcV5f7dY3v6tUscefHIePhfwBBCF8CZqRCReRs1tQxDCH1VfQLQz4EsSY4AvIjIsgm8AhhCGKrqa9zwrqoLAKckB5HtguR1E2gBMITQU9VPAD8GICIGtl3e+xHJBwBT59xtHcsCYJZlUwA3kcGHbfDep51OZywi3/acZZm9vyJ5WR5o38uACmDunNt6ZwAkUxFZDwghDFT1jeSjiJinhVUBVNVJkiTDKO8CQA+AsbNQ7s1Ps0VVn5MkSfcCtmBoDZi1Bdx4eJ7zbBolrwPy3o9J3rWSHPs3A1BbjVKlYBaIyDgvu9LDXDU2RTZmXVW1oKyLxRD+OrkOrJLy5mVM0iaftDhuhVbsvBzMglzKUNW6IV/OOWtCM8MmVvEkmbwt83LaB19fdgOtVquUZJeknaDdobTwbOcvBzPcN/AXH1DFFWP7u9oAAAAASUVORK5CYII=)}.ol-ctx-menu-zoom-out{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABU0lEQVQ4T72U7VECMRRFz3sNaAdkacC1AtcKxApcKnCsQOwAK3CtQKxAqEBsANYOqCDPyTIC+8WCw5jfybn33dxEOPGSE/P4b6BzQG89RT47ZJoWhy5B5BGRZAMxWyEyxvtnyFdt8AagS1F9KQ6YvSMyB84xGyDSw2yO2XUbtAJ0MaqfmH0XAPIA2y7tj4F7jAm2uG1yWQZKNEHkBu+Dg2njWBJNEbnC+8uaIFRuWfuG2QxbbrOrUd0A1Tc8D7AIjkur7DAAsVf8MiWMZ3ZR2m02LPIMscATfjHqBnY7TFD9OAy4zTCCPG/MUKMM5O6wkXFr9dZq7FQqqHk/hDzbFa73cFONTZFDdRyiCcKg5rrSiLaXkiI6RjjrfG6VzDs+B5eAxuDXeYpmNRGzL2wZ/wof+du4GNFpBVqqz5HA4MM5VEYYDrOs+1I6Q9u/4Q8O9wN/AGgWjBVqQjjgAAAAAElFTkSuQmCC)}.ol-ctx-menu-container li:hover.ol-ctx-menu-zoom-out{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABYklEQVQ4T72U4VHCQBCF36tA91KAWIFYgViBWIFYgWMFYgdYgVCBWAFSgdiBFpAsFWSdxcDkQoBkhnF/ZjbfvX377ogjF4/Mw/8CVbUD4MynEJF5k2lqFapqz8yeAPRKkCXJEYAXEVnugm8BVXVgZq/FD+9mtgBwSrJfqF2QvN4FjYCq2jWzTwA/DhARh20qTdMRyQcA0xDCbZ3KCJhl2RTATaHgo+6HLMv8+xXJy+qB3l8FGoB5CKHsXcRV1b6ZvZF8FBH3NKotoJlNkiQZFONdlLtJ3rufbouZPSdJMjwIbKDQEzBrClx7eC4i33Uepmk6JnnXaOQifzMAtdGoRApugYiMI1uqKkrRWAfZo9MxM1+UZzFewl8mN4nYdVM83L7BkwbXLUrF3sfBLQDQBbDy08x8vOohXyEE71lVq9emuEk+3gZa3XYroCvwFyjP8yHJDsnxwaU08GxvS2uFhw78BbzWrxXgMbsHAAAAAElFTkSuQmCC)}
\ No newline at end of file
diff --git a/package.json b/package.json
index ac0cccd..955aa9a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "ol3-contextmenu",
- "version": "2.0.1",
+ "version": "2.1.0",
"description": "Custom Context Menu for Openlayers 3",
"main": "build/ol3-contextmenu.js",
"author": "Jonatas Walker",