Skip to content

Commit

Permalink
-Fixed bug with ColReorder 1.1, Applied bug fix by kylealonius
Browse files Browse the repository at this point in the history
-Added bower file and registered plugin with bower repo, for all you bower lovers.
  • Loading branch information
dykstrad committed Apr 29, 2015
1 parent 00d6c56 commit 66e9970
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 35 deletions.
28 changes: 28 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
11 changes: 6 additions & 5 deletions dataTables.colResize.js
Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -765,7 +766,7 @@
* @type String
* @default As code
*/
ColResize.version = "0.0.6";
ColResize.version = "0.0.7";


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Expand Down
61 changes: 31 additions & 30 deletions examples/js/dataTables.colResize.js
Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
});
},

/**
Expand All @@ -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;
}
});
}
});
}
}
},

/**
Expand Down Expand Up @@ -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);
});
}
},

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -765,7 +766,7 @@
* @type String
* @default As code
*/
ColResize.version = "0.0.6";
ColResize.version = "0.0.7";


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Expand Down

0 comments on commit 66e9970

Please sign in to comment.