diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..8b6f18f --- /dev/null +++ b/bower.json @@ -0,0 +1,28 @@ +{ + "name": "datatables-colresize", + "description": "A plugin for resizing columns in DataTables", + "version": "0.0.6", + "license": "MIT License", + "main": [ + "dataTables.colResize.js" + ], + "keywords": [ + "datatables", + "colresize", + "resize" + ], + "authors": [ + "dykstrad", + "tdillan", + "kylealonius" + ], + "homepage": "https://github.com/Silvacom/colResize", + "repository": { + "type": "git", + "url": "git://github.com/Silvacom/colResize.git" + }, + "dependencies": { + "jquery": ">=1.7.0", + "datatables": ">=1.10.2" + } +} diff --git a/dataTables.colResize.js b/dataTables.colResize.js index df04195..492f329 100644 --- a/dataTables.colResize.js +++ b/dataTables.colResize.js @@ -1,10 +1,10 @@ -/*! ColResize 0.0.6 +/*! ColResize 0.0.7 */ /** * @summary ColResize * @description Provide the ability to resize columns in a DataTable - * @version 0.0.6 + * @version 0.0.7 * @file dataTables.colResize.js * @author Silvacom Ltd. * @@ -13,6 +13,7 @@ * Special thank to everyone who has contributed to this plug in * - dykstrad * - tdillan (for 0.0.3 and 0.0.5 bug fixes) + * - kylealonius (for 0.0.7 bug fix) */ (function (window, document, undefined) { @@ -431,8 +432,8 @@ this.s.mouse.startY = e.pageY; //Store the indexes of the columns the mouse is down on - var idx = that.dom.resizeCol.data("column-index"); - var idxNeighbour = that.dom.resizeColNeighbour.data("column-index"); + var idx = that.dom.resizeCol[0].cellIndex; + var idxNeighbour = that.dom.resizeColNeighbour[0].cellIndex; if (idx === undefined) { return; @@ -765,7 +766,7 @@ * @type String * @default As code */ - ColResize.version = "0.0.6"; + ColResize.version = "0.0.7"; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * diff --git a/examples/js/dataTables.colResize.js b/examples/js/dataTables.colResize.js index b6afea4..492f329 100644 --- a/examples/js/dataTables.colResize.js +++ b/examples/js/dataTables.colResize.js @@ -1,10 +1,10 @@ -/*! ColResize 0.0.6 +/*! ColResize 0.0.7 */ /** * @summary ColResize * @description Provide the ability to resize columns in a DataTable - * @version 0.0.6 + * @version 0.0.7 * @file dataTables.colResize.js * @author Silvacom Ltd. * @@ -13,6 +13,7 @@ * Special thank to everyone who has contributed to this plug in * - dykstrad * - tdillan (for 0.0.3 and 0.0.5 bug fixes) + * - kylealonius (for 0.0.7 bug fix) */ (function (window, document, undefined) { @@ -258,9 +259,9 @@ * @private */ "_fnStateSave": function (oState) { - this.s.dt.aoColumns.forEach(function(col, index) { - oState.columns[index].width = col.sWidthOrig; - }); + this.s.dt.aoColumns.forEach(function(col, index) { + oState.columns[index].width = col.sWidthOrig; + }); }, /** @@ -269,22 +270,22 @@ * @private */ "_fnStateLoad": function() { - var that = this, - loadedState = this.s.dt.oLoadedState; - if (loadedState && loadedState.columns) { - var colStates = loadedState.columns, - currCols = this.s.dt.aoColumns; - // Only apply the saved widths if the number of columns is the same. - // Otherwise, we don't know if we're applying the width to the correct column. - if (colStates.length > 0 && colStates.length === currCols.length) { - colStates.forEach(function(state, index) { - var col = that.s.dt.aoColumns[index]; - if (state.width) { - col.sWidthOrig = col.sWidth = state.width; + var that = this, + loadedState = this.s.dt.oLoadedState; + if (loadedState && loadedState.columns) { + var colStates = loadedState.columns, + currCols = this.s.dt.aoColumns; + // Only apply the saved widths if the number of columns is the same. + // Otherwise, we don't know if we're applying the width to the correct column. + if (colStates.length > 0 && colStates.length === currCols.length) { + colStates.forEach(function(state, index) { + var col = that.s.dt.aoColumns[index]; + if (state.width) { + col.sWidthOrig = col.sWidth = state.width; + } + }); } - }); } - } }, /** @@ -391,11 +392,11 @@ "_fnMouseEnter": function (e, nTh) { var that = this; if(!that.s.isMousedown) { - //Once the mouse has entered the cell add mouse move event to see if the mouse is over resize handle - $(nTh).off('mousemove.ColResizeHandle').on('mousemove.ColResizeHandle', function (e) { - e.preventDefault(); - that._fnResizeHandleCheck.call(that, e, nTh); - }); + //Once the mouse has entered the cell add mouse move event to see if the mouse is over resize handle + $(nTh).off('mousemove.ColResizeHandle').on('mousemove.ColResizeHandle', function (e) { + e.preventDefault(); + that._fnResizeHandleCheck.call(that, e, nTh); + }); } }, @@ -431,8 +432,8 @@ this.s.mouse.startY = e.pageY; //Store the indexes of the columns the mouse is down on - var idx = that.dom.resizeCol.data("column-index"); - var idxNeighbour = that.dom.resizeColNeighbour.data("column-index"); + var idx = that.dom.resizeCol[0].cellIndex; + var idxNeighbour = that.dom.resizeColNeighbour[0].cellIndex; if (idx === undefined) { return; @@ -612,9 +613,9 @@ e.preventDefault(); that._fnMouseDown.call(that, e, nTh); }) - .off('click.ColResize').on('click.ColResize', function (e) { - that._fnClick.call(that, e); - }); + .off('click.ColResize').on('click.ColResize', function (e) { + that._fnClick.call(that, e); + }); } else { $(nTh).css("cursor", "pointer"); $(nTh).off('mousedown.ColResize click.ColResize'); @@ -765,7 +766,7 @@ * @type String * @default As code */ - ColResize.version = "0.0.6"; + ColResize.version = "0.0.7"; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *