Skip to content

Commit

Permalink
Merge pull request #701 from fin-hypergrid/develop
Browse files Browse the repository at this point in the history
Merge v2.1.5 develop to master
  • Loading branch information
joneit authored Mar 9, 2018
2 parents 665cd35 + 420c747 commit 200b3bb
Show file tree
Hide file tree
Showing 13 changed files with 134 additions and 86 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ It also highlights a DOM-based custom external editor triggered via hypergrid ev
* [Roadmap](#roadmap)
* [Contributing](#contributors)

### Current Release (2.1.4 - 20 February 2018)
### Current Release (2.1.5 - 6 March 2018)

**Hypergrid 2.1.4** includes bug fixes and new properties and methods that offer new capabilities.
**Hypergrid 2.1.5** includes bug fixes.

_For a complete list of changes, see the [release notes](https://github.com/fin-hypergrid/core/releases)._

Expand Down
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

</head>
<body>
<h1 style="margin:.5em; color:lightgrey">Hypergrid 2.1.4 dev testbench</h1>
<h1 style="margin:.5em; color:lightgrey">Hypergrid 2.1.5 dev testbench</h1>

<div id="tabs">
<div id="tab-dashboard">Dashboard</div>
Expand Down
2 changes: 1 addition & 1 deletion demo/multiple-grids.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<style> body > div.hypergrid-container { width: 415px; margin-right: 10px; display: inline-block }</style>
</head>
<body>
<h1 style="margin:.5em; color:lightgrey">Hypergrid 2.1.4 multiple grids demo</h1>
<h1 style="margin:.5em; color:lightgrey">Hypergrid 2.1.5 multiple grids demo</h1>

<script src="build/fin-hypergrid.js"></script>

Expand Down
2 changes: 1 addition & 1 deletion demo/row-props.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</style>
</head>
<body>
<h1 style="margin:.5em; color:lightgrey">Hypergrid 2.1.4 performance workbench</h1>
<h1 style="margin:.5em; color:lightgrey">Hypergrid 2.1.5 performance workbench</h1>

<div id="controls" class="nowrap">
<label id="controller" title="Uncheck to hide other controls.">
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fin-hypergrid",
"version": "2.1.4",
"version": "2.1.5",
"description": "Canvas-based high-performance grid",
"repository": {
"type": "git",
Expand Down
27 changes: 23 additions & 4 deletions src/Hypergrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ var Hypergrid = Base.extend('Hypergrid', {
*/
this.cellEditors = new CellEditors({ grid: this });

this.initCanvas();

if (this.options.Behavior) {
this.setBehavior(this.options); // also sets this.options.pipeline and this.options.data
} else if (this.options.data) {
Expand Down Expand Up @@ -797,7 +799,6 @@ var Hypergrid = Base.extend('Hypergrid', {
// 2. Called from `setData` _and_ wasn't called explicitly since instantiation
var Behavior = options.Behavior || behaviorJSON;
this.behavior = new Behavior(this, options);
this.initCanvas();
this.initScrollbars();
this.refreshProperties();
this.behavior.reindex();
Expand Down Expand Up @@ -1029,14 +1030,16 @@ var Hypergrid = Base.extend('Hypergrid', {
/**
* @memberOf Hypergrid#
* @desc Switch the cursor for a grid instance.
* @param {string} cursorName - A well know cursor name.
* @param {string|string[]} cursorName - A well know cursor name.
* @see [cursor names](http://www.javascripter.net/faq/stylesc.htm)
*/
beCursor: function(cursorName) {
if (!cursorName) {
cursorName = 'default';
cursorName = ['default'];
} else if (!Array.isArray(cursorName)) {
cursorName = [cursorName];
}
this.div.style.cursor = cursorName;
cursorName.forEach(function(name) { this.cursor = name; }, this.div.style);
},

/**
Expand Down Expand Up @@ -1768,6 +1771,22 @@ var Hypergrid = Base.extend('Hypergrid', {
return this.behavior.getHeaderRowCount();
},

/**
* @returns {number} The total number of rows of all subgrids following the data subgrid.
* @memberOf Hypergrid#
*/
getFooterRowCount: function() {
return this.behavior.getFooterRowCount();
},

/**
* @returns {number} The total number of logical rows of all subgrids.
* @memberOf Hypergrid#
*/
getLogicalRowCount: function() {
return this.behavior.getLogicalRowCount();
},

isShowFilterRow: function() {
return this.deprecated('isShowFilterRow()', 'properties.showFilterRow', 'v1.2.10');
},
Expand Down
26 changes: 14 additions & 12 deletions src/behaviors/Behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,12 @@ var Behavior = Base.extend('Behavior', {
*/
getValue: function(xOrCellEvent, y, dataModel) {
if (typeof xOrCellEvent !== 'object') {
var x = xOrCellEvent;
xOrCellEvent = new this.CellEvent;
if (dataModel) {
xOrCellEvent.resetDataXY(xOrCellEvent, y, dataModel);
xOrCellEvent.resetDataXY(x, y, dataModel);
} else {
xOrCellEvent.resetGridCY(xOrCellEvent, y);
xOrCellEvent.resetGridCY(x, y);
}
}
return xOrCellEvent.value;
Expand Down Expand Up @@ -575,11 +576,12 @@ var Behavior = Base.extend('Behavior', {
if (typeof xOrCellEvent === 'object') {
value = y;
} else {
var x = xOrCellEvent;
xOrCellEvent = new this.CellEvent;
if (dataModel) {
xOrCellEvent.resetDataXY(xOrCellEvent, y, dataModel);
xOrCellEvent.resetDataXY(x, y, dataModel);
} else {
xOrCellEvent.resetGridCY(xOrCellEvent, y);
xOrCellEvent.resetGridCY(x, y);
}
}
xOrCellEvent.value = value;
Expand All @@ -605,7 +607,7 @@ var Behavior = Base.extend('Behavior', {
getCellOwnProperties: function(xOrCellEvent, y, dataModel) {
switch (arguments.length) {
case 1: // xOrCellEvent is cellEvent
return xOrCellEvent.column.getCellOwnProperties(xOrCellEvent.dataCell.y, xOrCellEvent.visibleRow.subgrid);
return xOrCellEvent.column.getCellOwnProperties(xOrCellEvent.dataCell.y, xOrCellEvent.subgrid);
case 2: case 3: // xOrCellEvent is x
return this.getColumn(xOrCellEvent).getCellOwnProperties(y, dataModel);
}
Expand Down Expand Up @@ -661,9 +663,9 @@ var Behavior = Base.extend('Behavior', {
setCellProperties: function(xOrCellEvent, y, properties, dataModel) {
if (typeof xOrCellEvent === 'object') {
properties = y;
xOrCellEvent.column.setCellProperties(xOrCellEvent.dataCell.y, properties, xOrCellEvent.visibleRow.subgrid);
return xOrCellEvent.column.setCellProperties(xOrCellEvent.dataCell.y, properties, xOrCellEvent.subgrid);
} else {
this.getColumn(xOrCellEvent).setCellProperties(y, properties, dataModel);
return this.getColumn(xOrCellEvent).setCellProperties(y, properties, dataModel);
}
},

Expand All @@ -678,9 +680,9 @@ var Behavior = Base.extend('Behavior', {
addCellProperties: function(xOrCellEvent, y, properties, dataModel) {
if (typeof xOrCellEvent === 'object') {
properties = y;
xOrCellEvent.column.addCellProperties(xOrCellEvent.dataCell.y, properties, xOrCellEvent.visibleRow.subgrid); // y omitted so y here is actually properties
return xOrCellEvent.column.addCellProperties(xOrCellEvent.dataCell.y, properties, xOrCellEvent.subgrid); // y omitted so y here is actually properties
} else {
this.getColumn(xOrCellEvent).addCellProperties(y, properties, dataModel);
return this.getColumn(xOrCellEvent).addCellProperties(y, properties, dataModel);
}
},

Expand Down Expand Up @@ -754,8 +756,8 @@ var Behavior = Base.extend('Behavior', {
*/
getRowProperties: function(yOrCellEvent, properties, dataModel) {
if (typeof yOrCellEvent === 'object') {
yOrCellEvent = yOrCellEvent.dataCell.y;
dataModel = yOrCellEvent.subgrid;
yOrCellEvent = yOrCellEvent.dataCell.y;
}

var metadata = (dataModel || this.dataModel).getRowMetadata(yOrCellEvent, properties && {});
Expand All @@ -771,8 +773,8 @@ var Behavior = Base.extend('Behavior', {
*/
setRowProperties: function(yOrCellEvent, properties, dataModel) {
if (typeof yOrCellEvent === 'object') {
yOrCellEvent = yOrCellEvent.dataCell.y;
dataModel = yOrCellEvent.subgrid;
yOrCellEvent = yOrCellEvent.dataCell.y;
}

(dataModel || this.dataModel).getRowMetadata(yOrCellEvent, {}, dataModel).__ROW = properties;
Expand Down Expand Up @@ -1186,7 +1188,7 @@ var Behavior = Base.extend('Behavior', {
*/
getFixedRowCount: function() {
return (
this.grid.getHeaderRowCount() +
this.getHeaderRowCount() +
this.grid.properties.fixedRowCount
);
},
Expand Down
30 changes: 29 additions & 1 deletion src/behaviors/subgrids.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ module.exports = {

/**
* @summary Gets the number of "header rows".
* @desc Defined as the sum of all rows of all subgrids before the (first) data subgrid.
* @desc Defined as the sum of all rows in all subgrids before the (first) data subgrid.
* @memberOf behaviors.JSON.prototype
*/
getHeaderRowCount: function() {
Expand All @@ -113,6 +113,34 @@ module.exports = {
});

return result;
},

/**
* @summary Gets the number of "footer rows".
* @desc Defined as the sum of all rows in all subgrids after the (last) data subgrid.
* @memberOf behaviors.JSON.prototype
*/
getFooterRowCount: function() {
var gotData;
return this.subgrids.reduce(function(rows, subgrid) {
if (gotData && !subgrid.isData) {
rows += subgrid.getRowCount();
} else {
gotData = subgrid.isData;
}
return rows;
}, 0);
},

/**
* @summary Gets the total number of logical rows.
* @desc Defined as the sum of all rows in all subgrids.
* @memberOf behaviors.JSON.prototype
*/
getLogicalRowCount: function() {
return this.subgrids.reduce(function(rows, subgrid) {
return (rows += subgrid.getRowCount());
}, 0);
}
};

Expand Down
15 changes: 8 additions & 7 deletions src/features/ColumnMoving.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

var Feature = require('./Feature');

var canDragCursorName = '-webkit-grab',
draggingCursorName = '-webkit-grabbing';
var GRAB = ['grab', '-moz-grab', '-webkit-grab'],
GRABBING = ['grabbing', '-moz-grabbing', '-webkit-grabbing'],
setName = function(name) { this.cursor = name; };

var columnAnimationTime = 150;
var dragger;
Expand Down Expand Up @@ -163,7 +164,7 @@ var ColumnMoving = Feature.extend('ColumnMoving', {
) {
if (event.isHeaderCell) {
this.dragArmed = true;
this.cursor = draggingCursorName;
this.cursor = GRABBING;
grid.clearSelections();
}
}
Expand Down Expand Up @@ -213,7 +214,7 @@ var ColumnMoving = Feature.extend('ColumnMoving', {
event.isHeaderCell &&
event.mousePoint.y < grid.properties.columnGrabMargin
) {
this.cursor = canDragCursorName;
this.cursor = GRAB;
} else {
this.cursor = null;
}
Expand All @@ -223,7 +224,7 @@ var ColumnMoving = Feature.extend('ColumnMoving', {
}

if (event.isHeaderCell && this.dragging) {
this.cursor = draggingCursorName; //move';
this.cursor = GRABBING;
}
},

Expand Down Expand Up @@ -386,7 +387,7 @@ var ColumnMoving = Feature.extend('ColumnMoving', {

style.zIndex = '4';
this.setCrossBrowserProperty(d, 'transform', 'translate(' + startX + 'px, ' + -2 + 'px)');
style.cursor = draggingCursorName;
GRABBING.forEach(setName, style);
grid.repaint();
},

Expand Down Expand Up @@ -472,7 +473,7 @@ var ColumnMoving = Feature.extend('ColumnMoving', {

this.setCrossBrowserProperty(d, 'transform', 'translate(' + x + 'px, -5px)');
style.zIndex = '5';
style.cursor = draggingCursorName;
GRABBING.forEach(setName, style);
grid.repaint();
},

Expand Down
2 changes: 1 addition & 1 deletion src/lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ module.exports = {
var self = this;

function handleMouseEvent(e, cb) {
if (self.getRowCount() === 0) {
if (self.getLogicalRowCount() === 0) {
return;
}

Expand Down
Loading

0 comments on commit 200b3bb

Please sign in to comment.