Skip to content

Commit

Permalink
Merge branch 'master' into gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyGermaneri committed Aug 17, 2017
2 parents 2757fc9 + 033db35 commit c47d2a7
Show file tree
Hide file tree
Showing 11 changed files with 413 additions and 118 deletions.
2 changes: 1 addition & 1 deletion build.txt
@@ -1 +1 @@
1428
1439
60 changes: 12 additions & 48 deletions dist/canvas-datagrid.debug.js

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

2 changes: 1 addition & 1 deletion dist/canvas-datagrid.debug.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/canvas-datagrid.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/canvas-datagrid.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion lib/contextMenu.js
Expand Up @@ -427,7 +427,9 @@ define([], function () {
document.removeEventListener('click', self.disposeContextMenu);
zIndexTop = 2;
self.disposeAutocomplete();
self.contextMenu.dispose();
if (self.contextMenu) {
self.contextMenu.dispose();
}
self.contextMenu = undefined;
};
self.contextmenuEvent = function (e, overridePos) {
Expand Down
2 changes: 1 addition & 1 deletion lib/draw.js
Expand Up @@ -894,7 +894,7 @@ define([], function () {
fillRect(0, a[1], self.canvas.width, 1);
fillRect(a[0], 0, 1, self.canvas.height);
self.ctx.fillStyle = 'dodgerblue';
fillRect(a[0] - 2, a[1] - 2, 5, 5);
fillRect(a[0] - 1, a[1] - 1, 3, 3);
});
}
}
Expand Down
13 changes: 8 additions & 5 deletions lib/events.js
Expand Up @@ -492,11 +492,16 @@ define([], function () {
if (self.dispatchEvent('beforebeginedit', {cell: cell})) { return false; }
self.scrollIntoView(x, y);
self.setActiveCell(x, y);
if (cell.header.enum) {
self.input = document.createElement('select');
} else {
self.input = document.createElement(self.attributes.multiLine
? 'textarea' : 'input');
}
function postDraw() {
var mEv, option, valueInEnum;
var option, valueInEnum;
cell = self.getVisibleCellByIndex(x, y);
if (cell.header.enum) {
self.input = document.createElement('select');
// add enums
if (typeof cell.header.enum === 'function') {
enumItems = cell.header.enum.apply(self.intf, [{cell: cell}]);
Expand Down Expand Up @@ -529,8 +534,6 @@ define([], function () {
self.endEdit();
self.draw(true);
});
} else {
self.input = document.createElement(self.attributes.multiLine ? 'textarea' : 'input');
}
document.body.appendChild(self.input);
self.createInlineStyle(self.input, 'canvas-datagrid-edit-input');
Expand Down Expand Up @@ -585,7 +588,7 @@ define([], function () {
}
});
}
requestAnimationFrame(postDraw);
postDraw();
self.dispatchEvent('beginedit', {cell: cell, input: self.input});
};
self.click = function (e, overridePos) {
Expand Down
41 changes: 0 additions & 41 deletions lib/intf.js
Expand Up @@ -371,47 +371,6 @@ define([], function () {
self.getFontHeight = function (fontStyle) {
return parseFloat(fontStyle, 10);
};
self.getFontHeightLong = function (fontStyle) {
var pixels,
start,
end,
row,
column,
index,
canvas = document.createElement('canvas'),
ctx = canvas.getContext('2d');
canvas.height = 5000;
canvas.width = 5000;
ctx.save();
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.textBaseline = 'top';
ctx.fillStyle = 'white';
ctx.font = fontStyle;
ctx.fillText('gM', 0, 0);
pixels = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
start = -1;
end = -1;
for (row = 0; row < canvas.height; row += 1) {
for (column = 0; column < canvas.width; column += 1) {
index = (row * canvas.width + column) * 4;
if (pixels[index] === 0) {
if (column === canvas.width - 1 && start !== -1) {
end = row;
row = canvas.height;
break;
}
} else {
if (start === -1) {
start = row;
}
break;
}
}
}
ctx.restore();
console.log(end - start);
return end - start;
};
self.parseFont = function (key) {
if (/Font/.test(key)) {
self.style[key + 'Height'] = self.getFontHeight(self.style[key]);
Expand Down
16 changes: 13 additions & 3 deletions test/tests.html
Expand Up @@ -33,31 +33,41 @@
html, body {
height: 100%;
min-height: 100%;
background: #CCC;
}
#mocha, #grid {
width: 40%;
display: inline-block;
vertical-align: top;
border: solid 1px #DDD;
background: #EEE;
box-shadow: 5px 5px 12px #777;
padding: 15px;
height: 80%;
overflow-y: auto;
}
#grid {
height: 80%;
margin-top: 70px;
margin-top: 60px;
width: 420px;
}
.grid-test-title {
font: 14px "Helvetica Neue", Helvetica, Arial, sans-serif;
padding: 3px;
background: lightgray;
}
.test-container {
border: solid 1px #CCC;
border: solid 1px #AAA;
width: 400px;
margin-bottom: 30px;
padding: 3px;
background: #BBB;
box-shadow: 5px 5px 12px #888;
}
.grid-container {
height: 120px;
width: 400px;
display: inline-block;
background: black;
}
.grid-test-failed {
background: darkred;
Expand Down

0 comments on commit c47d2a7

Please sign in to comment.