Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2.0.10 hacken grid 1 #1

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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