Skip to content

Commit

Permalink
grid.js: should not paste on readonly cells, fixed some minor bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed May 23, 2012
1 parent 31809f7 commit 0b3c80b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions public/javascripts/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ Grid.buildObj = function(grid, row) {
} else {
base[attr] = value
}
if (cell.innerHTML.strip() == '') cell.innerHTML = value || ''
if (cell.innerHTML.strip() == '') {
cell.innerHTML = value || ''
cell.orig_value = cell.innerHTML
}
}
}
grid.changes.push(base)
Expand Down Expand Up @@ -197,7 +200,7 @@ Grid.paste = function(event) {
}
if (i==0 && j==0) {
input.value = tabs[j]
} else {
} else if (!Grid.isReadOnly(cell)) {
Grid.changed(cell, tabs[j], tabs[j]);
}
}
Expand All @@ -207,7 +210,7 @@ Grid.paste = function(event) {
// single attribute table, serialize in input field
table.grid.input.value = Grid.serialize(table)
}
}, 100);
}, 0)
return true;
}

Expand Down Expand Up @@ -789,8 +792,8 @@ Grid.undo = function(grid_id) {
if (attr == 'id') continue
var cell = $(change.id).childElements()[grid.pos[attr]]
var value = state[attr] || cell.orig_value
cell.innerHTML = value
cell.prev_value = value
cell.innerHTML = value || ''
cell.prev_value = value || ''
if (value == cell.orig_value) {
cell.removeClassName('changed')
var row = cell.up()
Expand Down
2 changes: 1 addition & 1 deletion public/stylesheets/grid.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.grid tr.action td.action {border:0}
.grid td.input, .grid th.input { padding:0;}
.grid .input input, .grid .input textarea { margin:0; padding:0;font-size:inherit;}
.grid td.changed {background:#E5DDD7}
.grid td.changed, .grid .new td.changed {background:#E5DDD7}
.grid .new td {background:#B2DFEE}
.grid .new td.action {background:none}
.grid .saved { background:#A3FF4F}
Expand Down

0 comments on commit 0b3c80b

Please sign in to comment.