Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

plugin system updates

updating to closer match spec in issue #79
  • Loading branch information...
commit 27028c81c37427d8f02b60c7ec4c93dab01acdc3 1 parent 3ca0479
@timothyswt timothyswt authored
View
33 KoGrid-1.2.4.debug.js
@@ -2,7 +2,7 @@
* koGrid JavaScript Library
* Authors: https://github.com/ericmbarnard/KoGrid/blob/master/README.md
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
-* Compiled At: 11/05/2012 19:40:39
+* Compiled At: 11/05/2012 21:34:40
***********************************************/
@@ -667,7 +667,7 @@ kg.Row = function (entity, config, selectionManager) {
var element = event.target;
//check and make sure its not the bubbling up of our checked 'click' event
- if (element.type == "checkbox" && element.parentElement.className.indexOf("kgSelectionCell" !== -1)) {
+ if (element.type == "checkbox" && $(element).parent().attr('class').indexOf("kgSelectionCell" !== -1)) {
return true;
}
if (config.selectWithCheckboxOnly && element.type != "checkbox"){
@@ -827,7 +827,8 @@ kg.HeaderCell = function (col, rightHeaderGroup, grid) {
}, DELAY);
} else {
clearTimeout(timer); //prevent single-click action
- grid.resizeOnDataCallback(self.column); //perform double-click action
+ grid.resizeOnData(self.column); //perform double-click action
+ kg.cssBuilder.buildStyles(grid);
clicks = 0; //after action performed, reset counter
}
};
@@ -976,7 +977,9 @@ kg.RowManager = function (grid) {
//null the row pointer for next iteration
row = null;
});
-
+ kg.utils.forEach(grid.config.plugins, function (p) {
+ p.onRowsChanged(grid, rowArr);
+ });
self.rows(rowArr);
});
@@ -2406,14 +2409,14 @@ kg.KoGrid = function (options, gridWidth) {
columnDefs.splice(targetCol, 0, { field: '__kg_selected__', width: self.elementDims.rowSelectedCellW });
}
}
-
- var createColumnSortClosure = function (col) {
- return function (dir) {
+
+ var createColumnSortClosure = function(col) {
+ return function(dir) {
if (dir) {
self.sortData(col, dir);
}
- }
- }
+ };
+ };
if (columnDefs.length > 0) {
@@ -2467,7 +2470,9 @@ kg.KoGrid = function (options, gridWidth) {
self.rows = self.rowManager.rows; // dependent observable
kg.cssBuilder.buildStyles(self);
-
+ kg.utils.forEach(self.config.plugins, function (p) {
+ p.onGridInit(self);
+ });
self.initPhase = 1;
};
@@ -2490,6 +2495,9 @@ kg.KoGrid = function (options, gridWidth) {
} else {
h_updateTimeout = setTimeout(updater, 0);
}
+ kg.utils.forEach(self.config.plugins, function(p) {
+ p.onGridUpdate(self);
+ });
};
this.showFilter_Click = function () {
@@ -2868,7 +2876,7 @@ ko.bindingHandlers['koGrid'] = (function () {
$element.addClass("kgGrid")
.addClass("ui-widget")
.addClass(grid.gridId.toString());
-
+
//make sure the templates are generated for the Grid
return ko.bindingHandlers['template'].init(element, makeNewValueAccessor(grid), allBindingsAccessor, grid, bindingContext);
@@ -2892,9 +2900,6 @@ ko.bindingHandlers['koGrid'] = (function () {
//now use the manager to assign the event handlers
kg.gridManager.assignGridEventHandlers(grid);
- kg.utils.forEach(grid.config.plugins, function(p) {
- p.init(grid);
- });
//call update on the grid, which will refresh the dome measurements asynchronously
grid.update();
View
33 build/KoGrid.debug.js
@@ -2,7 +2,7 @@
* koGrid JavaScript Library
* Authors: https://github.com/ericmbarnard/KoGrid/blob/master/README.md
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
-* Compiled At: 11/05/2012 19:40:39
+* Compiled At: 11/05/2012 21:34:40
***********************************************/
@@ -667,7 +667,7 @@ kg.Row = function (entity, config, selectionManager) {
var element = event.target;
//check and make sure its not the bubbling up of our checked 'click' event
- if (element.type == "checkbox" && element.parentElement.className.indexOf("kgSelectionCell" !== -1)) {
+ if (element.type == "checkbox" && $(element).parent().attr('class').indexOf("kgSelectionCell" !== -1)) {
return true;
}
if (config.selectWithCheckboxOnly && element.type != "checkbox"){
@@ -827,7 +827,8 @@ kg.HeaderCell = function (col, rightHeaderGroup, grid) {
}, DELAY);
} else {
clearTimeout(timer); //prevent single-click action
- grid.resizeOnDataCallback(self.column); //perform double-click action
+ grid.resizeOnData(self.column); //perform double-click action
+ kg.cssBuilder.buildStyles(grid);
clicks = 0; //after action performed, reset counter
}
};
@@ -976,7 +977,9 @@ kg.RowManager = function (grid) {
//null the row pointer for next iteration
row = null;
});
-
+ kg.utils.forEach(grid.config.plugins, function (p) {
+ p.onRowsChanged(grid, rowArr);
+ });
self.rows(rowArr);
});
@@ -2406,14 +2409,14 @@ kg.KoGrid = function (options, gridWidth) {
columnDefs.splice(targetCol, 0, { field: '__kg_selected__', width: self.elementDims.rowSelectedCellW });
}
}
-
- var createColumnSortClosure = function (col) {
- return function (dir) {
+
+ var createColumnSortClosure = function(col) {
+ return function(dir) {
if (dir) {
self.sortData(col, dir);
}
- }
- }
+ };
+ };
if (columnDefs.length > 0) {
@@ -2467,7 +2470,9 @@ kg.KoGrid = function (options, gridWidth) {
self.rows = self.rowManager.rows; // dependent observable
kg.cssBuilder.buildStyles(self);
-
+ kg.utils.forEach(self.config.plugins, function (p) {
+ p.onGridInit(self);
+ });
self.initPhase = 1;
};
@@ -2490,6 +2495,9 @@ kg.KoGrid = function (options, gridWidth) {
} else {
h_updateTimeout = setTimeout(updater, 0);
}
+ kg.utils.forEach(self.config.plugins, function(p) {
+ p.onGridUpdate(self);
+ });
};
this.showFilter_Click = function () {
@@ -2868,7 +2876,7 @@ ko.bindingHandlers['koGrid'] = (function () {
$element.addClass("kgGrid")
.addClass("ui-widget")
.addClass(grid.gridId.toString());
-
+
//make sure the templates are generated for the Grid
return ko.bindingHandlers['template'].init(element, makeNewValueAccessor(grid), allBindingsAccessor, grid, bindingContext);
@@ -2892,9 +2900,6 @@ ko.bindingHandlers['koGrid'] = (function () {
//now use the manager to assign the event handlers
kg.gridManager.assignGridEventHandlers(grid);
- kg.utils.forEach(grid.config.plugins, function(p) {
- p.init(grid);
- });
//call update on the grid, which will refresh the dome measurements asynchronously
grid.update();
View
14 plugins/koGrid-reorderable.js
@@ -7,13 +7,23 @@
self.config = $.extend(defaults, options);
self.myGrid = null;
- // The init method gets called during the ng-grid directive execution.
- self.init = function (grid) {
+ // The init method gets called during the koGrid binding handler execution.
+ self.onGridInit = function (grid) {
+ /* logic */
+
+ };
+ self.onGridUpdate = function (grid) {
+ /* logic */
// The directive passes in the grid scope and the grid object which we will want to save for manipulation later.
self.myGrid = grid;
// In this example we want to assign grid events.
self.assignEvents();
};
+ self.onRowsChanged = function (grid, rowCollection) {
+ /* logic */
+ };
+
+ //internal funcs
self.colToMove = undefined;
self.rowToMove = undefined;
self.assignEvents = function () {
View
5 src/BindingHandlers/koGrid.js
@@ -64,7 +64,7 @@ ko.bindingHandlers['koGrid'] = (function () {
$element.addClass("kgGrid")
.addClass("ui-widget")
.addClass(grid.gridId.toString());
-
+
//make sure the templates are generated for the Grid
return ko.bindingHandlers['template'].init(element, makeNewValueAccessor(grid), allBindingsAccessor, grid, bindingContext);
@@ -88,9 +88,6 @@ ko.bindingHandlers['koGrid'] = (function () {
//now use the manager to assign the event handlers
kg.gridManager.assignGridEventHandlers(grid);
- kg.utils.forEach(grid.config.plugins, function(p) {
- p.init(grid);
- });
//call update on the grid, which will refresh the dome measurements asynchronously
grid.update();
View
17 src/Grid.js
@@ -483,14 +483,14 @@ kg.KoGrid = function (options, gridWidth) {
columnDefs.splice(targetCol, 0, { field: '__kg_selected__', width: self.elementDims.rowSelectedCellW });
}
}
-
- var createColumnSortClosure = function (col) {
- return function (dir) {
+
+ var createColumnSortClosure = function(col) {
+ return function(dir) {
if (dir) {
self.sortData(col, dir);
}
- }
- }
+ };
+ };
if (columnDefs.length > 0) {
@@ -544,7 +544,9 @@ kg.KoGrid = function (options, gridWidth) {
self.rows = self.rowManager.rows; // dependent observable
kg.cssBuilder.buildStyles(self);
-
+ kg.utils.forEach(self.config.plugins, function (p) {
+ p.onGridInit(self);
+ });
self.initPhase = 1;
};
@@ -567,6 +569,9 @@ kg.KoGrid = function (options, gridWidth) {
} else {
h_updateTimeout = setTimeout(updater, 0);
}
+ kg.utils.forEach(self.config.plugins, function(p) {
+ p.onGridUpdate(self);
+ });
};
this.showFilter_Click = function () {
View
3  src/GridClasses/HeaderCell.js
@@ -77,7 +77,8 @@
}, DELAY);
} else {
clearTimeout(timer); //prevent single-click action
- grid.resizeOnDataCallback(self.column); //perform double-click action
+ grid.resizeOnData(self.column); //perform double-click action
+ kg.cssBuilder.buildStyles(grid);
clicks = 0; //after action performed, reset counter
}
};
View
2  src/GridClasses/Row.js
@@ -41,7 +41,7 @@ kg.Row = function (entity, config, selectionManager) {
var element = event.target;
//check and make sure its not the bubbling up of our checked 'click' event
- if (element.type == "checkbox" && element.parentElement.className.indexOf("kgSelectionCell" !== -1)) {
+ if (element.type == "checkbox" && $(element).parent().attr('class').indexOf("kgSelectionCell" !== -1)) {
return true;
}
if (config.selectWithCheckboxOnly && element.type != "checkbox"){
View
4 src/GridClasses/RowManager.js
@@ -89,7 +89,9 @@
//null the row pointer for next iteration
row = null;
});
-
+ kg.utils.forEach(grid.config.plugins, function (p) {
+ p.onRowsChanged(grid, rowArr);
+ });
self.rows(rowArr);
});
View
3  tests/RowManager_Tests.js
@@ -60,7 +60,8 @@ kg.getTestGrid = function () {
config: {
rowHeight: 30,
currentPage: ko.observable(1),
- pageSize: ko.observable(100)
+ pageSize: ko.observable(100),
+ plugins: []
},
changeSelectedItem: function (handler) {
Please sign in to comment.
Something went wrong with that request. Please try again.