Comparing version 0.6.3 to 0.6.4
@@ -0,0 +0,0 @@ # How to contribute |
@@ -0,0 +0,0 @@ 'use strict'; |
module.exports = require('./lib/Table'); |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -21,14 +21,22 @@ 'use strict'; | ||
var newElement; | ||
switch (type) { | ||
case 'row': | ||
newElement = document.createElement('tr'); | ||
break; | ||
case 'cell': | ||
// cells consist of a td element with a nested span which contains the content | ||
// cells consist of a td element with a nested span which contains the content | ||
newElement = document.createElement(element.row.useTH ? 'th' : 'td'); | ||
var contentContainer = document.createElement('span'); | ||
newElement.appendChild(contentContainer); | ||
break; | ||
} | ||
if (newElement && type === 'row') { | ||
if (element.next) { | ||
@@ -39,6 +47,9 @@ parent.insertBefore(newElement, this._elementRegistry.getGraphics(element.next)); | ||
} | ||
} else if (type === 'cell') { | ||
var neighboringCell = this._elementRegistry.filter(function(el) { | ||
return el.row === element.row && el.column === element.column.next; | ||
})[0]; | ||
if (neighboringCell) { | ||
@@ -49,2 +60,3 @@ parent.insertBefore(newElement, this._elementRegistry.getGraphics(neighboringCell)); | ||
} | ||
} | ||
@@ -62,2 +74,3 @@ return newElement || document.createElement('div'); | ||
} else { | ||
if (source.next) { | ||
@@ -69,2 +82,3 @@ gfxTarget = this._elementRegistry.getGraphics(source.next); | ||
} | ||
} | ||
@@ -107,3 +121,3 @@ }; | ||
// Do not update root element | ||
// do not update root element | ||
if (!element.parent) { | ||
@@ -114,4 +128,6 @@ return; | ||
var self = this; | ||
// redraw | ||
if (type === 'row') { | ||
this._renderer.drawRow(gfx, element); | ||
@@ -125,4 +141,5 @@ | ||
}); | ||
} else | ||
if (type === 'column') { | ||
} else if (type === 'column') { | ||
this._renderer.drawColumn(gfx, element); | ||
@@ -136,4 +153,4 @@ | ||
}); | ||
} else | ||
if (type === 'cell') { | ||
} else if (type === 'cell') { | ||
this._renderer.drawCell(gfx, element); | ||
@@ -140,0 +157,0 @@ } else { |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -237,4 +237,9 @@ 'use strict'; | ||
Sheet.prototype.setSibling = function(first, second) { | ||
if (first) first.next = second; | ||
if (second) second.previous = first; | ||
if (first) { | ||
first.next = second; | ||
} | ||
if (second) { | ||
second.previous = first; | ||
} | ||
}; | ||
@@ -244,15 +249,23 @@ | ||
var tmp, subType; | ||
if (type === 'row') { | ||
subType = element.isHead ? 'head' : element.isFoot ? 'foot' : 'body'; | ||
} | ||
if (!element.previous && !element.next) { | ||
if (type === 'column') { | ||
// add column to end of table per default | ||
element.next = null; | ||
this.setSibling(this.getLastColumn(), element); | ||
this.setLastColumn(element); | ||
} else if (type === 'row') { | ||
// add row to end of table per default | ||
element.next = null; | ||
this.setSibling(this.getLastRow(subType), element); | ||
this.setLastRow(element, subType); | ||
@@ -262,4 +275,6 @@ } | ||
tmp = element.previous.next; | ||
this.setSibling(element.previous, element); | ||
this.setSibling(element, tmp); | ||
if (!tmp) { | ||
@@ -274,2 +289,3 @@ if (type === 'row') { | ||
tmp = element.next.previous; | ||
this.setSibling(tmp, element); | ||
@@ -289,5 +305,7 @@ this.setSibling(element, element.next); | ||
var subType; | ||
if (type === 'row') { | ||
subType = element.isHead ? 'head' : element.isFoot ? 'foot' : 'body'; | ||
} | ||
if (type === 'column') { | ||
@@ -297,4 +315,3 @@ if (this.getLastColumn() === element) { | ||
} | ||
} else | ||
if (type === 'row') { | ||
} else if (type === 'row') { | ||
if (this.getLastRow(subType) === element) { | ||
@@ -304,8 +321,11 @@ this.setLastRow(element.previous, subType); | ||
} | ||
if (element.previous) { | ||
element.previous.next = element.next; | ||
} | ||
if (element.next) { | ||
element.next.previous = element.previous; | ||
} | ||
delete element.previous; | ||
@@ -362,8 +382,11 @@ delete element.next; | ||
} | ||
if (source.next) { | ||
source.next.previous = source.previous; | ||
} | ||
// re-wire the prev/next relations for the target | ||
if (above) { | ||
if (target.previous) { | ||
// (previous --> source --> target) | ||
@@ -376,2 +399,3 @@ target.previous.next = source; | ||
} else { | ||
// (null --> source --> target) | ||
@@ -385,2 +409,3 @@ source.previous = null; | ||
if (target.next) { | ||
// (target --> source --> next) | ||
@@ -393,2 +418,3 @@ target.next.previous = source; | ||
} else { | ||
// (target --> source --> null) | ||
@@ -399,2 +425,3 @@ source.next = null; | ||
target.next = source; | ||
this.setLastRow(source, 'body'); | ||
@@ -441,8 +468,12 @@ } | ||
} | ||
if (source.next) { | ||
source.next.previous = source.previous; | ||
} | ||
// re-wire the prev/next relations for the target | ||
if (left) { | ||
if (target.previous) { | ||
// (previous --> source --> target) | ||
@@ -455,2 +486,3 @@ target.previous.next = source; | ||
} else { | ||
// (null --> source --> target) | ||
@@ -462,4 +494,7 @@ source.previous = null; | ||
} | ||
} else { | ||
if (target.next) { | ||
// (target --> source --> next) | ||
@@ -472,2 +507,3 @@ target.next.previous = source; | ||
} else { | ||
// (target --> source --> null) | ||
@@ -481,2 +517,3 @@ source.next = null; | ||
} | ||
} | ||
@@ -515,4 +552,3 @@ | ||
if (!valid) { | ||
throw new Error( | ||
'must supply { ' + requiredAttrs.join(', ') + ' } with ' + type); | ||
throw new Error('must supply { ' + requiredAttrs.join(', ') + ' } with ' + type); | ||
} | ||
@@ -551,3 +587,2 @@ }; | ||
// create graphics | ||
element.parent = parent || this._rootNode; | ||
@@ -650,5 +685,7 @@ | ||
graphicsFactory.update('cell', | ||
graphicsFactory.update( | ||
'cell', | ||
elementRegistry.get('cell_' + config.column + '_' + config.row), | ||
elementRegistry.getGraphics('cell_' + config.column + '_' + config.row)); | ||
elementRegistry.getGraphics('cell_' + config.column + '_' + config.row) | ||
); | ||
}; | ||
@@ -675,2 +712,3 @@ | ||
if (!element) { | ||
// element was removed already | ||
@@ -704,2 +742,3 @@ return; | ||
var self = this; | ||
forEach(this._elementRegistry.filter(function(el) { | ||
@@ -727,2 +766,3 @@ return el.row === element; | ||
var self = this; | ||
forEach(this._elementRegistry.filter(function(el) { | ||
@@ -729,0 +769,0 @@ return el.column === element; |
module.exports = { | ||
renderer: [ 'type', require('./Renderer') ] | ||
}; |
'use strict'; | ||
var forEach = require('lodash/collection/forEach'), | ||
colDistance = function colDistance(from, to) { | ||
var i = 0, | ||
current = from.column; | ||
while (current && current !== to.column) { | ||
current = current.next; | ||
i++; | ||
} | ||
return !current ? -1 : i; | ||
}, | ||
rowDistance = function rowDistance(from, to) { | ||
var i = 0, | ||
current = from.row; | ||
while (current && current !== to.row) { | ||
current = current.next; | ||
i++; | ||
} | ||
return !current ? -1 : i; | ||
}; | ||
var forEach = require('lodash/collection/forEach'); | ||
function colDistance(from, to) { | ||
var i = 0, | ||
current = from.column; | ||
while (current && current !== to.column) { | ||
current = current.next; | ||
i++; | ||
} | ||
return !current ? -1 : i; | ||
} | ||
function rowDistance(from, to) { | ||
var i = 0, | ||
current = from.row; | ||
while (current && current !== to.row) { | ||
current = current.next; | ||
i++; | ||
} | ||
return !current ? -1 : i; | ||
} | ||
/** | ||
@@ -41,2 +43,3 @@ * The default renderer used for rows, columns and cells. | ||
}); | ||
return gfx; | ||
@@ -50,2 +53,3 @@ }; | ||
}); | ||
return gfx; | ||
@@ -71,2 +75,3 @@ }; | ||
var d = colDistance(cell, data); | ||
if (cell.colspan && d > 0 && d < cell.colspan) { | ||
@@ -84,2 +89,3 @@ gfx.setAttribute('style', 'display: none;'); | ||
var d = rowDistance(cell, data); | ||
if (cell.rowspan && d > 0 && d < cell.rowspan) { | ||
@@ -86,0 +92,0 @@ gfx.setAttribute('style', 'display: none;'); |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -87,4 +87,9 @@ 'use strict'; | ||
var update = function(evt) { | ||
self.setValue(evt.target.textContent); | ||
var value = evt.target.textContent; | ||
if (options.indexOf(value) !== -1) { | ||
self.setValue(evt.target.textContent); | ||
} | ||
}; | ||
this._dropdown.addEventListener('click', function(evt) { | ||
@@ -99,2 +104,3 @@ update(evt); | ||
}); | ||
this._dropdown.addEventListener('focus', update, true); | ||
@@ -101,0 +107,0 @@ |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
{ | ||
"name": "table-js", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"description": "A table editing framework for the web", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -0,0 +0,0 @@ > The project is in an early development stage. |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
'use strict'; | ||
module.exports = require('./helper'); |
@@ -0,0 +0,0 @@ 'use strict'; |
@@ -0,0 +0,0 @@ 'use strict'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
229855
5973
0