Skip to content

Commit

Permalink
Merge pull request #1 from siosTomBeckenhauer/v2.0.10-hackenGrid-1
Browse files Browse the repository at this point in the history
V2.0.10 hacken grid 1
  • Loading branch information
siosTomBeckenhauer committed Jan 22, 2016
2 parents c50e29d + b1f9506 commit c0e0d99
Showing 1 changed file with 50 additions and 6 deletions.
56 changes: 50 additions & 6 deletions build/ng-grid.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = {};

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -851,20 +861,54 @@ 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));
$scope.hasUserChangedGridColumnWidths = true;
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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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 };

Expand Down

0 comments on commit c0e0d99

Please sign in to comment.