Skip to content

Commit

Permalink
* #66. turn off events with active pop-up + build
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurkushman committed Nov 5, 2017
2 parents 6425995 + 6c861f3 commit c0e3380
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 115 deletions.
16 changes: 8 additions & 8 deletions build/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gigatables-react",
"version": "2.0.1",
"version": "2.0.2",
"description": "GigaTables is a ReactJS plug-in to help web-developers process table-data in applications and CMS, CRM, ERP or similar systems. It supports ajax data processing/editing (CRUD), pagination, cross-sorting, global search, shft/ctrl rows selection, 7 popular languages and more.",
"main": "./build/index.js",
"dependencies": {
Expand Down
214 changes: 109 additions & 105 deletions src/Reactables.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,122 +130,126 @@ class Reactables extends Main {

componentDidMount() {
let that = this;
// enabling keys
document.addEventListener('keydown', (e) => {
switch (e.which) {
case CommonConstants.CTRL_KEY:
that.setState({
ctrlDown: true
});
break;
case CommonConstants.CTRL_KEY_MAC_CHROME:
that.setState({
ctrlDown: true
});
break;
case CommonConstants.CTRL_KEY_MAC_FF:
that.setState({
ctrlDown: true
});
break;
case CommonConstants.SHIFT_KEY:
that.setState({
shiftDown: true
});
break;
case CommonConstants.ESCAPE_KEY:
that.hidePopup();
break;
case CommonConstants.ARROW_UP:
that.setState({
arrowUp: true
});
break;
case CommonConstants.ARROW_DOWN:
that.setState({
arrowDown: true
});
break;
case CommonConstants.ARROW_LEFT:
that.setState({
arrowLeft: true
});
break;
case CommonConstants.ARROW_RIGHT:
that.setState({
arrowRight: true
});
break;
case CommonConstants.A_KEY:
that.setState({
aDown: true
});
break;
}
that.addSelectedRows();
that.setPagination();
});

// turn on infinite scroll
if (this.settings.struct.infiniteScroll === true) {
window.addEventListener('scroll', (e) => {
this.handleScroll();
});
}

// turn on fixed headers
if (this.settings.struct.fixedHeader === true) {
this.fixHeaders();
}
// enabling keys
document.addEventListener('keydown', (e) => {
if (this.state.active === false) {// turn off events with active pop-up
switch (e.which) {
case CommonConstants.CTRL_KEY:
that.setState({
ctrlDown: true
});
break;
case CommonConstants.CTRL_KEY_MAC_CHROME:
that.setState({
ctrlDown: true
});
break;
case CommonConstants.CTRL_KEY_MAC_FF:
that.setState({
ctrlDown: true
});
break;
case CommonConstants.SHIFT_KEY:
that.setState({
shiftDown: true
});
break;
case CommonConstants.ESCAPE_KEY:
that.hidePopup();
break;
case CommonConstants.ARROW_UP:
that.setState({
arrowUp: true
});
break;
case CommonConstants.ARROW_DOWN:
that.setState({
arrowDown: true
});
break;
case CommonConstants.ARROW_LEFT:
that.setState({
arrowLeft: true
});
break;
case CommonConstants.ARROW_RIGHT:
that.setState({
arrowRight: true
});
break;
case CommonConstants.A_KEY:
that.setState({
aDown: true
});
break;
}
that.addSelectedRows();
that.setPagination();
}
});

// disabling keys
document.addEventListener('keyup', (e) => {
switch (e.which) {
case CommonConstants.CTRL_KEY:
that.setState({
ctrlDown: false
});
break;
case CommonConstants.CTRL_KEY_MAC_CHROME:
that.setState({
ctrlDown: false
});
break;
case CommonConstants.CTRL_KEY_MAC_FF:
that.setState({
ctrlDown: false
});
break;
case CommonConstants.SHIFT_KEY:
that.setState({
shiftDown: false
});
break;
case CommonConstants.ARROW_UP:
that.setState({
arrowUp: false
});
break;
case CommonConstants.ARROW_DOWN:
that.setState({
arrowDown: false
});
break;
case CommonConstants.ARROW_LEFT:
that.setState({
arrowLeft: false
});
break;
case CommonConstants.ARROW_RIGHT:
that.setState({
arrowRight: false
});
break;
case CommonConstants.A_KEY:
that.setState({
aDown: false
});
break;
if (this.state.active === false) {// turn off events with active pop-up
switch (e.which) {
case CommonConstants.CTRL_KEY:
that.setState({
ctrlDown: false
});
break;
case CommonConstants.CTRL_KEY_MAC_CHROME:
that.setState({
ctrlDown: false
});
break;
case CommonConstants.CTRL_KEY_MAC_FF:
that.setState({
ctrlDown: false
});
break;
case CommonConstants.SHIFT_KEY:
if (this.state.active === false) {// only if pop-up is closed
that.setState({
shiftDown: false
});
}
break;
case CommonConstants.ARROW_UP:
that.setState({
arrowUp: false
});
break;
case CommonConstants.ARROW_DOWN:
that.setState({
arrowDown: false
});
break;
case CommonConstants.ARROW_LEFT:
that.setState({
arrowLeft: false
});
break;
case CommonConstants.ARROW_RIGHT:
that.setState({
arrowRight: false
});
break;
case CommonConstants.A_KEY:
that.setState({
aDown: false
});
break;
}
}
});
}
Expand Down Expand Up @@ -402,15 +406,15 @@ class Reactables extends Main {
</div>
<table id="gigatable" className={styles.gigatable}>
<THead>
{sortedCols}
{sortedCols}
</THead>
<TBody
rerenderTable={this.rerenderTable.bind(this)}
struct={struct}>
{dataRows}
</TBody>
<TFoot>
{sortedCols}
{sortedCols}
</TFoot>
</table>
<div className={styles.gt_pagination}>
Expand Down
5 changes: 4 additions & 1 deletion src/components/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,10 @@ class Main extends Component {
popup_title: popup_title,
popup_button: popup_button,
opacity: 1,
fieldsEdit: fieldsEdit
fieldsEdit: fieldsEdit,
// turn off key selection
shiftDown: false,
ctrlDown: false,
});
}

Expand Down

0 comments on commit c0e3380

Please sign in to comment.