From cdf91b1fb239659a4193cfde4ec17a15677b2d4c Mon Sep 17 00:00:00 2001 From: jonricaurte Date: Wed, 26 Jun 2013 08:06:52 -0700 Subject: [PATCH] Fixed cell navigation Cell navigation broke due to there being an extra element in the cell. Also changed the color of the focused cell to be different than selected rows to be easier to identify. Fixed issue #510. Now when mouse clicking within cell, rows won't keep being selected and deselected. --- build/ng-grid.debug.js | 12 ++++++++++-- build/ng-grid.js | 11 +++++++++-- build/ng-grid.min.js | 4 ++-- ng-grid-2.0.7.debug.js | 12 ++++++++++-- ng-grid-2.0.7.min.js | 4 ++-- ng-grid.css | 2 +- ng-grid.min.css | 2 +- src/classes/domAccessProvider.js | 2 +- src/directives/ng-input.js | 8 ++++++++ src/less/colors.less | 5 ++++- src/less/selection.less | 2 +- workbench/main2.js | 3 ++- 12 files changed, 51 insertions(+), 16 deletions(-) diff --git a/build/ng-grid.debug.js b/build/ng-grid.debug.js index 52ffe9bb35..0bf03ac04b 100644 --- a/build/ng-grid.debug.js +++ b/build/ng-grid.debug.js @@ -2,7 +2,7 @@ * ng-grid JavaScript Library * Authors: https://github.com/angular-ui/ng-grid/blob/master/README.md * License: MIT (http://www.opensource.org/licenses/mit-license.php) -* Compiled At: 06/25/2013 22:47 +* Compiled At: 06/26/2013 08:00 ***********************************************/ (function(window, $) { 'use strict'; @@ -919,7 +919,7 @@ ngDomAccessProvider.prototype.focusCellElement = function ($scope, index) { i = 1; //don't want to focus on checkbox } if (columns[i]) { - columns[i].children[0].focus(); + columns[i].children[1].children[0].focus(); } this.previousColumn = columnIndex; } @@ -3215,6 +3215,14 @@ ngGridDirectives.directive('ngInput', [function() { return true; }); + + elm.bind('click', function(evt) { + evt.stopPropagation(); + }); + + elm.bind('mousedown', function(evt) { + evt.stopPropagation(); + }); } }; }]); diff --git a/build/ng-grid.js b/build/ng-grid.js index 9519cf86fa..b5a3f167ca 100644 --- a/build/ng-grid.js +++ b/build/ng-grid.js @@ -2,7 +2,7 @@ * ng-grid JavaScript Library * Authors: https://github.com/angular-ui/ng-grid/blob/master/README.md * License: MIT (http://www.opensource.org/licenses/mit-license.php) -* Compiled At: 06/25/2013 22:47 +* Compiled At: 06/26/2013 08:00 ***********************************************/ (function(window, $) { 'use strict'; @@ -862,7 +862,7 @@ ngDomAccessProvider.prototype.focusCellElement = function ($scope, index) { i = 1; } if (columns[i]) { - columns[i].children[0].focus(); + columns[i].children[1].children[0].focus(); } this.previousColumn = columnIndex; } @@ -2860,6 +2860,13 @@ ngGridDirectives.directive('ngInput', [function() { return true; }); + + elm.bind('click', function(evt) { + evt.stopPropagation(); + }); + elm.bind('mousedown', function(evt) { + evt.stopPropagation(); + }); } }; }]); diff --git a/build/ng-grid.min.js b/build/ng-grid.min.js index 5b841a3ea8..a6861f4609 100644 --- a/build/ng-grid.min.js +++ b/build/ng-grid.min.js @@ -1,2 +1,2 @@ -(function(e,t){"use strict";var n=6,o=4,i="asc",r="desc",l="_ng_field_",a="_ng_depth_",s="_ng_hidden_",c="_ng_column_",g=/CUSTOM_FILTERS/g,d=/COL_FIELD/g,u=/DISPLAY_CELL_TEMPLATE/g,f=/EDITABLE_CELL_TEMPLATE/g,h=/<.+>/;e.ngGrid={},e.ngGrid.i18n={},angular.module("ngGrid.services",[]);var p=angular.module("ngGrid.directives",[]),m=angular.module("ngGrid.filters",[]);angular.module("ngGrid",["ngGrid.services","ngGrid.directives","ngGrid.filters"]);var v=function(e,t,o,i){if(void 0===e.selectionProvider.selectedItems)return!0;var r,l=o.which||o.keyCode,a=!1,s=!1,c=e.selectionProvider.lastClickedRow.rowIndex,g=e.columns.filter(function(e){return e.visible}),d=e.columns.filter(function(e){return e.pinned});if(e.col&&(r=g.indexOf(e.col)),37!==l&&38!==l&&39!==l&&40!==l&&9!==l&&13!==l)return!0;if(e.enableCellSelection){9===l&&o.preventDefault();var u=e.showSelectionCheckbox?1===e.col.index:0===e.col.index,f=1===e.$index||0===e.$index,h=e.$index===e.renderedColumns.length-1||e.$index===e.renderedColumns.length-2,p=g.indexOf(e.col)===g.length-1,m=d.indexOf(e.col)===d.length-1;if(37===l||9===l&&o.shiftKey){var v=0;u||(r-=1),f?u&&9===l&&o.shiftKey?(v=i.$canvas.width(),r=g.length-1,s=!0):v=i.$viewport.scrollLeft()-e.col.width:d.length>0&&(v=i.$viewport.scrollLeft()-g[r].width),i.$viewport.scrollLeft(v)}else(39===l||9===l&&!o.shiftKey)&&(h?p&&9===l&&!o.shiftKey?(i.$viewport.scrollLeft(0),r=e.showSelectionCheckbox?1:0,a=!0):i.$viewport.scrollLeft(i.$viewport.scrollLeft()+e.col.width):m&&i.$viewport.scrollLeft(0),p||(r+=1))}var w;w=e.configGroups.length>0?i.rowFactory.parsedData.filter(function(e){return!e.isAggRow}):i.filteredRows;var C=0;if(0!==c&&(38===l||13===l&&o.shiftKey||9===l&&o.shiftKey&&s)?C=-1:c!==w.length-1&&(40===l||13===l&&!o.shiftKey||9===l&&a)&&(C=1),C){var b=w[c+C];b.beforeSelectionChange(b,o)&&(b.continueSelection(o),e.$emit("ngGridEventDigestGridParent"),e.selectionProvider.lastClickedRow.renderedRowIndex>=e.renderedRows.length-n-2?i.$viewport.scrollTop(i.$viewport.scrollTop()+e.rowHeight):n+2>=e.selectionProvider.lastClickedRow.renderedRowIndex&&i.$viewport.scrollTop(i.$viewport.scrollTop()-e.rowHeight))}return e.enableCellSelection&&setTimeout(function(){e.domAccessProvider.focusCellElement(e,e.renderedColumns.indexOf(g[r]))},3),!1};String.prototype.trim||(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),Array.prototype.indexOf||(Array.prototype.indexOf=function(e){var t=this.length>>>0,n=Number(arguments[1])||0;for(n=0>n?Math.ceil(n):Math.floor(n),0>n&&(n+=t);t>n;n++)if(n in this&&this[n]===e)return n;return-1}),Array.prototype.filter||(Array.prototype.filter=function(e){var t=Object(this),n=t.length>>>0;if("function"!=typeof e)throw new TypeError;for(var o=[],i=arguments[1],r=0;n>r;r++)if(r in t){var l=t[r];e.call(i,l,r,t)&&o.push(l)}return o}),m.filter("checkmark",function(){return function(e){return e?"✔":"✘"}}),m.filter("ngColumns",function(){return function(e){return e.filter(function(e){return!e.isAggCol})}}),angular.module("ngGrid.services").factory("$domUtilityService",["$utilityService",function(e){var n={},o={},i=function(){var e=t("
");e.appendTo("body"),e.height(100).width(100).css("position","absolute").css("overflow","scroll"),e.append('
'),n.ScrollH=e.height()-e[0].clientHeight,n.ScrollW=e.width()-e[0].clientWidth,e.empty(),e.attr("style",""),e.append('M'),n.LetterW=e.children().first().width(),e.remove()};return n.eventStorage={},n.AssignGridContainers=function(e,o,i){i.$root=t(o),i.$topPanel=i.$root.find(".ngTopPanel"),i.$groupPanel=i.$root.find(".ngGroupPanel"),i.$headerContainer=i.$topPanel.find(".ngHeaderContainer"),e.$headerContainer=i.$headerContainer,i.$headerScroller=i.$topPanel.find(".ngHeaderScroller"),i.$headers=i.$headerScroller.children(),i.$viewport=i.$root.find(".ngViewport"),i.$canvas=i.$viewport.find(".ngCanvas"),i.$footerPanel=i.$root.find(".ngFooterPanel"),e.$watch(function(){return i.$viewport.scrollLeft()},function(e){return i.$headerContainer.scrollLeft(e)}),n.UpdateGridLayout(e,i)},n.getRealWidth=function(e){var n=0,o={visibility:"hidden",display:"block"},i=e.parents().andSelf().not(":visible");return t.swap(i[0],o,function(){n=e.outerWidth()}),n},n.UpdateGridLayout=function(e,t){var o=t.$viewport.scrollTop();t.elementDims.rootMaxW=t.$root.width(),t.$root.is(":hidden")&&(t.elementDims.rootMaxW=n.getRealWidth(t.$root)),t.elementDims.rootMaxH=t.$root.height(),t.refreshDomSizes(),e.adjustScrollTop(o,!0)},n.numberOfGrids=0,n.BuildStyles=function(o,i,r){var l,a=i.config.rowHeight,s=i.$styleSheet,c=i.gridId,g=o.columns,d=0;s||(s=t("#"+c),s[0]||(s=t("