diff --git a/.gitignore b/.gitignore
index 04e28fc..783d317 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
*.log
.idea/
+*.iml
\ No newline at end of file
diff --git a/README.md b/README.md
index de67f10..8821dff 100644
--- a/README.md
+++ b/README.md
@@ -28,9 +28,15 @@ angular.module("app", ["ui.grid", "ui.grid.custom-cell-select"]);
To add custom cell selection functionality you have to insert `ui-grid-custom-cell-select` directive to your table.
```html
-
+
```
+## Settings
+
+An object may be provided to the `ui-grid-custom-cell-select` attribute.
+
+- `ignoreRightClick` - (Default: false) Will not begin dragging when right mouse is used. Useful for context menus.
+
## Additional styling
When you select grid cells ann additional css class (`ui-grid-draggable-row-over`) is applied to them. This plugin has default styling for these elements. If you are using __less__ you could import styles into your application.
diff --git a/bower.json b/bower.json
index 8259c9b..bb71bae 100644
--- a/bower.json
+++ b/bower.json
@@ -1,11 +1,11 @@
{
"name": "ui-grid-custom-cell-select",
- "version": "0.1.2",
+ "version": "0.2.0",
"authors": [
"Brenden Peterson "
],
"description": "Custom Cell Selection Plugin for UI Grid",
- "main": "js/draggable-rows.js",
+ "main": "js/custom-cell-select.js",
"moduleType": [
"globals"
],
diff --git a/js/custom-cell-select.js b/js/custom-cell-select.js
index d504e57..dae68a0 100644
--- a/js/custom-cell-select.js
+++ b/js/custom-cell-select.js
@@ -1,8 +1,29 @@
// Custom multi-cell selection directive for UI-Grid
// Created by brendenjpeterson@gmail.com
+/**
+ * @typedef {Object} SelectionOptions
+ * @property {Boolean} ignoreRightClick=false Set to true to ignore right click events
+ */
+
angular.module('ui.grid')
.directive('uiGridCustomCellSelect', ['$timeout', '$document', '$filter', 'rowSearcher', 'uiGridConstants', function ($timeout, $document, $filter, rowSearcher, uiGridConstants) {
+
+ // Adapted From https://www.quirksmode.org/js/events_properties.html
+ // Quick test to check mouse events for right click
+ function isRightMouse(evt) {
+ if (evt.which) { return (evt.which === 3); }
+ else if (evt.button) { return (evt.button === 2); }
+ return false;
+ }
+
+ /**
+ * @type {SelectionOptions}
+ */
+ var defaultOptions = {
+ ignoreRightClick: false
+ };
+
return {
replace: true,
require: '^uiGrid',
@@ -15,6 +36,10 @@ angular.module('ui.grid')
var _scope = $scope;
var grid = uiGridCtrl.grid;
+ /**
+ * @type {SelectionOptions}
+ */
+ var selectionOptions = angular.extend({}, defaultOptions, $scope.$eval( $attrs.uiGridCustomCellSelect ));
// Data setup
_scope.ugCustomSelect = {
@@ -55,6 +80,10 @@ angular.module('ui.grid')
// Events
function dragStart(evt) {
+
+ // Ignore right mouse if specified in options
+ if( selectionOptions.ignoreRightClick && isRightMouse(evt) ){ return; }
+
if (angular.element(evt.target).hasClass('ui-grid-cell-contents')) {
var cellData = $(this).data().$scope;
clearDragData();
diff --git a/package.json b/package.json
index 8b0800d..769bed9 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "ui-grid-custom-cell-select",
"version": "0.2.0",
"description": "Custom Cell Selection Plugin for UI Grid",
- "main": "js/draggable-rows.js",
+ "main": "js/custom-cell-select.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
@@ -23,6 +23,10 @@
{
"name": "Jairo Alejandro Honorio Diaz",
"email": "registrofx@gmail.com"
+ },
+ {
+ "name": "Michael Grill",
+ "email": "mike@gogrillion.com"
}
],
"license": "MIT",