Skip to content

Commit

Permalink
Merge pull request #32 from jonataswalker/v2.1.0
Browse files Browse the repository at this point in the history
Release v2.1.0
  • Loading branch information
jonataswalker committed May 23, 2016
2 parents 5abad41 + e654241 commit 66b055f
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 27 deletions.
68 changes: 49 additions & 19 deletions build/ol3-contextmenu-debug.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -287,6 +287,10 @@
};

var eventType = {
/**
* Triggered before context menu is openned.
*/
BEFOREOPEN: 'beforeopen',
/**
* Triggered when context menu is openned.
*/
Expand Down Expand Up @@ -465,7 +469,7 @@
this.Base.dispatchEvent({
type: eventType.OPEN,
pixel: pixel,
coordinate: coordinate,
coordinate: coordinate
});
};

Expand All @@ -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
Expand Down Expand Up @@ -655,6 +670,7 @@
);

this.options = utils.mergeOptions(defaultOptions, opt_options);
this.disabled = false;

Base.Internal = new Internal(this);
Base.Html = new Html(this);
Expand All @@ -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.
Expand All @@ -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.
*/
Expand All @@ -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());
};

/**
Expand Down
4 changes: 2 additions & 2 deletions build/ol3-contextmenu.css
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Loading

0 comments on commit 66b055f

Please sign in to comment.