From 18f62fecdb2d5a05fd3515825b3a602fd2a199b9 Mon Sep 17 00:00:00 2001 From: Mike Grill Date: Wed, 8 Nov 2017 12:24:47 -0500 Subject: [PATCH 1/5] added IntelliJ module file to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) 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 From 248f98cdbba51875edb855ff1301e0e3a35b3686 Mon Sep 17 00:00:00 2001 From: Mike Grill Date: Wed, 8 Nov 2017 12:25:30 -0500 Subject: [PATCH 2/5] fixed main export, bumped bower version to match npm --- bower.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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/package.json b/package.json index 8b0800d..822f31b 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" }, From eb44646f4a3a68e6d2d5b49d224401af6cdea4e3 Mon Sep 17 00:00:00 2001 From: Mike Grill Date: Wed, 8 Nov 2017 12:27:22 -0500 Subject: [PATCH 3/5] added options with ignoreRightClick --- js/custom-cell-select.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) 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(); From 31db29b828c5b6f90969133d7420191a4e9d1db1 Mon Sep 17 00:00:00 2001 From: Mike Grill Date: Wed, 8 Nov 2017 12:30:49 -0500 Subject: [PATCH 4/5] README update with settings --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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. From 8ac7483058f11f551a934fc7691b7d5482161a3f Mon Sep 17 00:00:00 2001 From: Mike Grill Date: Wed, 8 Nov 2017 12:36:01 -0500 Subject: [PATCH 5/5] appended myself as a contributor --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index 822f31b..769bed9 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,10 @@ { "name": "Jairo Alejandro Honorio Diaz", "email": "registrofx@gmail.com" + }, + { + "name": "Michael Grill", + "email": "mike@gogrillion.com" } ], "license": "MIT",