diff --git a/build/ng-grid.debug.js b/build/ng-grid.debug.js index 0ad80d364a..585501ef30 100644 --- a/build/ng-grid.debug.js +++ b/build/ng-grid.debug.js @@ -10,6 +10,7 @@ var EXCESS_ROWS = 6; var SCROLL_THRESHOLD = 4; var ASC = "asc"; + // constant for sorting direction var DESC = "desc"; // constant for sorting direction @@ -23,6 +24,7 @@ var DISPLAY_CELL_TEMPLATE = /DISPLAY_CELL_TEMPLATE/g; var EDITABLE_CELL_TEMPLATE = /EDITABLE_CELL_TEMPLATE/g; var CELL_EDITABLE_CONDITION = /CELL_EDITABLE_CONDITION/g; var TEMPLATE_REGEXP = /<.+>/; +var swipe; window.ngGrid = {}; window.ngGrid.i18n = {}; @@ -331,11 +333,17 @@ angular.module('ngGrid.services').factory('$domUtilityService',['$utilityService for (var i = 0; i < cols.length; i++) { var col = cols[i]; - if (col.visible !== false) { + if (col.visible !== false && i < cols.length-1) { css += "." + gridId + " .col" + i + " { width: " + col.width + "px; left: " + sumWidth + "px; height: " + rowHeight + "px }" + "." + gridId + " .colt" + i + " { width: " + col.width + "px; }"; sumWidth += col.width; } + // for removing horizontal scroll bar on grid during pin unpin + else if(col.visible !== false){ + css += "." + gridId + " .col" + i + " { width: " + (col.width-1) + "px; left: " + sumWidth + "px; height: " + rowHeight + "px }" + + "." + gridId + " .colt" + i + " { width: " + (col.width-1) + "px; }"; + sumWidth += col.width; + } } domUtilityService.setStyleText(grid, css); @@ -823,7 +831,8 @@ var ngColumn = function (config, $scope, grid, domUtilityService, $templateCache if (!self.sortable) { return true; // column sorting is disabled, do nothing } - var dir = self.sortDirection === ASC ? DESC : ASC; + //var dir = self.sortDirection === ASC ? DESC : ASC; + var dir = self.sortDirection === DESC ? ASC : DESC; // To make default sorting by descending order self.sortDirection = dir; config.sortCallback(self, evt); return false; @@ -842,6 +851,7 @@ var ngColumn = function (config, $scope, grid, domUtilityService, $templateCache } }; self.gripOnMouseDown = function(event) { + var ele = angular.element(event.target); $scope.isColumnResizing = true; if (event.ctrlKey && !self.pinned) { self.toggleVisible(); @@ -851,11 +861,17 @@ var ngColumn = function (config, $scope, grid, domUtilityService, $templateCache event.target.parentElement.style.cursor = 'col-resize'; self.startMousePosition = event.clientX; self.origWidth = self.width; + + ele.bind('touchstart', function(evt) { + self.onTouchMove(ele); + }); + $(document).mousemove(self.onMouseMove); $(document).mouseup(self.gripOnMouseUp); return false; }; self.onMouseMove = function(event) { + var diff = event.clientX - self.startMousePosition; var newWidth = diff + self.origWidth; self.width = (newWidth < self.minWidth ? self.minWidth : (newWidth > self.maxWidth ? self.maxWidth : newWidth)); @@ -863,8 +879,36 @@ var ngColumn = function (config, $scope, grid, domUtilityService, $templateCache domUtilityService.BuildStyles($scope, grid); return false; }; + self.onTouchMove = function(ele){ + var startElement,parent; + var $swipe = swipe; + $swipe.bind(ele, { + 'start' : function(coords) { + self.startMousePosition = coords.x; + }, + 'move' : function(coords) { + + var diff = coords.x - self.startMousePosition; + var newWidth = diff + self.origWidth; + self.width = (newWidth < self.minWidth ? self.minWidth : (newWidth > self.maxWidth ? self.maxWidth : newWidth)); + $scope.hasUserChangedGridColumnWidths = true; + domUtilityService.BuildStyles($scope, grid); + return false; + // ... + }, + 'end' : function(coords) { + // ... + + }, + 'cancel' : function(coords) { + // ... + } + }); + }; self.gripOnMouseUp = function (event) { - $(document).off('mousemove', self.onMouseMove); + + + $(document).off('mousemove', self.onMouseMove); $(document).off('mouseup', self.gripOnMouseUp); event.target.parentElement.style.cursor = 'default'; domUtilityService.digest($scope); @@ -2790,14 +2834,13 @@ var ngSelectionProvider = function (grid, $scope, $parse) { self.lastClickedRow = undefined; self.ignoreSelectedItemChanges = false; // flag to prevent circular event loops keeping single-select var in sync self.pKeyParser = $parse(grid.config.primaryKey); - // function to manage the selection action of a data item (entity) self.ChangeSelection = function (rowItem, evt) { // ctrl-click + shift-click multi-selections // up/down key navigation in multi-selections var charCode = evt.which || evt.keyCode; var isUpDownKeyPress = (charCode === 40 || charCode === 38); - + if (evt && evt.shiftKey && !evt.keyCode && self.multi && grid.config.enableRowSelection) { if (self.lastClickedRow) { var rowsArr; @@ -3202,7 +3245,7 @@ ngGridDirectives.directive('ngGridMenu', ['$compile', '$templateCache', function }; return ngGridMenu; }]); -ngGridDirectives.directive('ngGrid', ['$compile', '$filter', '$templateCache', '$sortService', '$domUtilityService', '$utilityService', '$timeout', '$parse', '$http', '$q', function ($compile, $filter, $templateCache, sortService, domUtilityService, $utils, $timeout, $parse, $http, $q) { +ngGridDirectives.directive('ngGrid', ['$compile', '$filter', '$templateCache', '$sortService', '$domUtilityService', '$utilityService', '$timeout', '$parse', '$http', '$q', 'GlobalState','$swipe', function ($compile, $filter, $templateCache, sortService, domUtilityService, $utils, $timeout, $parse, $http, $q,GlobalState,$swipe) { var ngGridDirective = { scope: true, compile: function() { @@ -3365,6 +3408,7 @@ ngGridDirectives.directive('ngGrid', ['$compile', '$filter', '$templateCache', ' // the grid Id, entity, scope for convenience options.gridId = grid.gridId; options.ngGrid = grid; + swipe = $swipe options.$gridScope = $scope; options.$gridServices = { SortService: sortService, DomUtilityService: domUtilityService, UtilityService: $utils };