Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Drop jQuery requirement #734

Merged
merged 28 commits into from
Apr 29, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3df8a00
Drop jQuery requirement
MarkoBL Jan 25, 2023
054f05b
- removed jQuery from slick.groupitemmetadataprovider.js
MarkoBL Jan 25, 2023
7f56bdf
Rebase
MarkoBL Mar 6, 2023
897ae9f
- removed jQuery from slick.groupitemmetadataprovider.js
MarkoBL Jan 26, 2023
c10a9a1
fixed tests: example-checkbox-header-row.spec.js,
MarkoBL Jan 26, 2023
34cdfbc
fix test: example-composite-editor-modal-dialog.spec.js
MarkoBL Jan 27, 2023
79e8efc
fix test: example-composite-editor-modal-dialog.spec.js
MarkoBL Jan 27, 2023
29d9afa
moved slideUp/slideDown into Slick.Utils
MarkoBL Jan 28, 2023
afafcaa
Fixed Utils.position
MarkoBL Jan 28, 2023
5481602
Switched from mouseenter/mouseleave to mouseover/mouseout
MarkoBL Jan 28, 2023
4ce5e54
Use mouseenter/mouseleave on header and headerRow again, fixes test: …
MarkoBL Jan 31, 2023
b8436e9
Reworked EventData, fixed Drag and Drop, fixes test example-row-detai…
MarkoBL Jan 30, 2023
59ba584
fixed updateColumnHeader(), fixes test: example-draggable-grouping.sp…
MarkoBL Jan 31, 2023
0a8e2ab
fixed scrollTop/scrollLeft
MarkoBL Jan 31, 2023
cd517e3
Fixed Grid.ensureCellNodesInRowsCache, and other drag and drop relate…
MarkoBL Jan 31, 2023
a3b1603
fixed grid.getMaxSupportedCssHeight
MarkoBL Feb 1, 2023
a9e073b
some fixes
MarkoBL Feb 1, 2023
11ef8ae
Revert vscode tasks.json
MarkoBL Feb 1, 2023
6f7ba1c
fixing _footerRow exception
MarkoBL Feb 1, 2023
3451b55
Removed TreeColumns and unused variables
MarkoBL Feb 1, 2023
8fd7bd5
Revert "Removed TreeColumns and unused variables"
MarkoBL Feb 1, 2023
a899f70
Merge branch '6pac:master' into no-jquery
MarkoBL Mar 8, 2023
008ed88
PATCH: ensure frozen options are set before render. Fixes #727
6pac Mar 13, 2023
ae37d3c
Merge branch '6pac:master' into no-jquery
MarkoBL Mar 13, 2023
f711c24
Curly braces and other small changes requested by @ghiscoding
MarkoBL Mar 13, 2023
c5a8c25
Even more curly braces :)
MarkoBL Mar 13, 2023
def1727
fixed events
MarkoBL Mar 13, 2023
5367e73
ES5 syntax
MarkoBL Mar 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions controls/slick.gridmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@
// notify of the onBeforeMenuShow only works when it's a jQuery event (as per slick.core code)
// this mean that we cannot notify when the grid menu is attach to a button event
if (typeof e.isPropagationStopped === "function") {
if (_self.onBeforeMenuShow.notify(callbackArgs, e, _self) == false) {
if (_self.onBeforeMenuShow.notify(callbackArgs, e, _self).getReturnValue() == false) {
return;
}
}
Expand Down Expand Up @@ -490,7 +490,7 @@
_isMenuOpen = true;

if (typeof e.isPropagationStopped === "function") {
if (_self.onAfterMenuShow.notify(callbackArgs, e, _self) == false) {
if (_self.onAfterMenuShow.notify(callbackArgs, e, _self).getReturnValue() == false) {
return;
}
}
Expand Down Expand Up @@ -549,7 +549,7 @@
"allColumns": columns,
"visibleColumns": getVisibleColumns()
};
if (_self.onMenuClose.notify(callbackArgs, e, _self) == false) {
if (_self.onMenuClose.notify(callbackArgs, e, _self).getReturnValue() == false) {
return;
}
}
Expand Down
26 changes: 13 additions & 13 deletions cypress/integration/example-plugin-custom-tooltip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Example - Custom Tooltip', () => {
cy.get('@checkbox0-cell').trigger('mouseover');

cy.get('.slick-custom-tooltip').should('not.exist');
cy.get('@checkbox0-cell').trigger('mouseleave');
cy.get('@checkbox0-cell').trigger('mouseout');
});

it('should mouse over Task 1 cell and expect async tooltip to show', () => {
Expand All @@ -52,7 +52,7 @@ describe('Example - Custom Tooltip', () => {
cy.get('.tooltip-2cols-row:nth(2)').find('div:nth(0)').contains('Ratio:');
cy.get('.tooltip-2cols-row:nth(2)').find('div:nth(1)').contains(/\d+$/); // use regexp to make sure it's a number

cy.get('@task1-cell').trigger('mouseleave');
cy.get('@task1-cell').trigger('mouseout');
});

it('should mouse over Task 5 cell and expect async tooltip to show', () => {
Expand All @@ -71,7 +71,7 @@ describe('Example - Custom Tooltip', () => {
cy.get('.tooltip-2cols-row:nth(2)').find('div:nth(0)').contains('Ratio:');
cy.get('.tooltip-2cols-row:nth(2)').find('div:nth(1)').contains(/\d+$/); // use regexp to make sure it's a number

cy.get('@task5-cell').trigger('mouseleave');
cy.get('@task5-cell').trigger('mouseout');
});

it('should mouse over 6th row Description and expect full cell content to show in a tooltip because cell has ellipsis and is too long for the cell itself', () => {
Expand All @@ -83,7 +83,7 @@ describe('Example - Custom Tooltip', () => {
cy.get('.slick-custom-tooltip').should('not.contain', `regular tooltip (from title attribute)\nTask 5 cell value:\nThis is a sample task description.\nIt can be multiline\n\nAnother line...`);
cy.get('.slick-custom-tooltip').should('contain', `This is a sample task description.\nIt can be multiline\n\nAnother line...`);

cy.get('@desc5-cell').trigger('mouseleave');
cy.get('@desc5-cell').trigger('mouseout');
});

it('should mouse over 6th row Description 2 and expect regular tooltip title + concatenated full cell content when using "useRegularTooltipFromFormatterOnly: true"', () => {
Expand All @@ -94,7 +94,7 @@ describe('Example - Custom Tooltip', () => {
cy.get('.slick-custom-tooltip').should('be.visible');
cy.get('.slick-custom-tooltip').should('contain', `regular tooltip (from title attribute)\nTask 5 cell value:\nThis is a sample task description.\nIt can be multiline\n\nAnother line...`);

cy.get('@desc2-5-cell').trigger('mouseleave');
cy.get('@desc2-5-cell').trigger('mouseout');
});

it('should mouse over 6th row Duration and expect a custom tooltip shown with 4 label/value pairs displayed', () => {
Expand All @@ -118,7 +118,7 @@ describe('Example - Custom Tooltip', () => {
cy.get('.tooltip-2cols-row:nth(3)').find('div:nth(1)')
.find('img').invoke('attr', 'src').then(src => expect(src).to.contain('tick.png'));

cy.get('@duration5-cell').trigger('mouseleave');
cy.get('@duration5-cell').trigger('mouseout');
});

it('should mouse over % Complete cell of Task 5 and expect regular tooltip to show with content "x %" where x is a number', () => {
Expand All @@ -129,20 +129,20 @@ describe('Example - Custom Tooltip', () => {
cy.get('.slick-custom-tooltip').should('be.visible');
cy.get('.slick-custom-tooltip').contains(/\d+\%$/);

cy.get('@percentage-cell').trigger('mouseleave');
cy.get('@percentage-cell').trigger('mouseout');
});

it('should mouse over header-row (filter) 1st column checkbox and NOT expect any tooltip to show since it is disabled on that column', () => {
cy.get(`.slick-headerrow-columns .slick-headerrow-column:nth(0)`).as('checkbox0-filter')
cy.get('@checkbox0-filter').trigger('mouseover');
cy.get('@checkbox0-filter').trigger('mouseenter');

cy.get('.slick-custom-tooltip').should('not.exist');
cy.get('@checkbox0-filter').trigger('mouseleave');
});

it('should mouse over header-row (filter) 2nd column Title and expect a tooltip to show rendered from an headerRowFormatter', () => {
cy.get(`.slick-headerrow-columns .slick-headerrow-column:nth(1)`).as('checkbox0-filter')
cy.get('@checkbox0-filter').trigger('mouseover');
cy.get('@checkbox0-filter').trigger('mouseenter');

cy.get('.slick-custom-tooltip').should('be.visible');
cy.get('.slick-custom-tooltip').contains('Custom Tooltip - Header Row (filter)');
Expand All @@ -155,23 +155,23 @@ describe('Example - Custom Tooltip', () => {

it('should mouse over header-row (filter) Finish column and NOT expect any tooltip to show since it is disabled on that column', () => {
cy.get(`.slick-headerrow-columns .slick-headerrow-column:nth(7)`).as('finish-filter')
cy.get('@finish-filter').trigger('mouseover');
cy.get('@finish-filter').trigger('mouseenter');

cy.get('.slick-custom-tooltip').should('not.exist');
cy.get('@finish-filter').trigger('mouseleave');
});

it('should mouse over header title on 1st column with checkbox and NOT expect any tooltip to show since it is disabled on that column', () => {
cy.get(`.slick-header-columns .slick-header-column:nth(0)`).as('checkbox-header')
cy.get('@checkbox-header').trigger('mouseover');
cy.get('@checkbox-header').trigger('mouseenter');

cy.get('.slick-custom-tooltip').should('not.exist');
cy.get('@checkbox-header').trigger('mouseleave');
});

it('should mouse over header title on 2nd column with Title name and expect a tooltip to show rendered from an headerFormatter', () => {
cy.get(`.slick-header-columns .slick-header-column:nth(1)`).as('checkbox0-header')
cy.get('@checkbox0-header').trigger('mouseover');
cy.get('@checkbox0-header').trigger('mouseenter');

cy.get('.slick-custom-tooltip').should('be.visible');
cy.get('.slick-custom-tooltip').contains('Custom Tooltip - Header');
Expand All @@ -184,7 +184,7 @@ describe('Example - Custom Tooltip', () => {

it('should mouse over header title on 2nd column with Finish name and NOT expect any tooltip to show since it is disabled on that column', () => {
cy.get(`.slick-header-columns .slick-header-column:nth(7)`).as('finish-header')
cy.get('@finish-header').trigger('mouseover');
cy.get('@finish-header').trigger('mouseenter');

cy.get('.slick-custom-tooltip').should('not.exist');
cy.get('@finish-header').trigger('mouseleave');
Expand Down
2 changes: 1 addition & 1 deletion examples/example-checkbox-header-row.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ <h3>Selected Ids (<span id="idsCount">0</span>) with index/id offset=<span id="i
<script src="../lib/jquery-3.1.0.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sortablejs/Sortable.min.js"></script>

<script src="../slick.core.js"></script>
<script src="../plugins/slick.checkboxselectcolumn.js"></script>
<script src="../plugins/slick.rowselectionmodel.js"></script>
<script src="../controls/slick.pager.js"></script>
<script src="../controls/slick.columnpicker.js"></script>

<script src="../slick.core.js"></script>
<script src="../slick.dataview.js"></script>
<script src="../slick.interactions.js"></script>
<script src="../slick.grid.js"></script>
Expand Down
64 changes: 31 additions & 33 deletions examples/example-column-group.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,46 +94,44 @@ <h2>View Source:</h2>
{id: "effort-driven", name: "Effort Driven", width: 80, minWidth: 20, maxWidth: 80, field: "effortDriven", columnGroup:"Analysis"}
];

$(function () {
for (var i = 0; i < 50000; i++) {
var d = (data[i] = {});
for (var i = 0; i < 50000; i++) {
var d = (data[i] = {});

d["id"] = "id_" + i;
d["num"] = i;
d["title"] = "Task " + i;
d["duration"] = "5 days";
d["start"] = "01/01/2009";
d["finish"] = "01/05/2009";
d["percentComplete"] = Math.round(Math.random() * 100);
d["effortDriven"] = (i % 5 == 0);
}
d["id"] = "id_" + i;
d["num"] = i;
d["title"] = "Task " + i;
d["duration"] = "5 days";
d["start"] = "01/01/2009";
d["finish"] = "01/05/2009";
d["percentComplete"] = Math.round(Math.random() * 100);
d["effortDriven"] = (i % 5 == 0);
}

dataView = new Slick.Data.DataView();
grid = new Slick.Grid("#myGrid", dataView, columns, options);
dataView = new Slick.Data.DataView();
grid = new Slick.Grid("#myGrid", dataView, columns, options);

dataView.onRowCountChanged.subscribe(function (e, args) {
grid.updateRowCount();
grid.render();
});
dataView.onRowCountChanged.subscribe(function (e, args) {
grid.updateRowCount();
grid.render();
});

dataView.onRowsChanged.subscribe(function (e, args) {
grid.invalidateRows(args.rows);
grid.render();
});
dataView.onRowsChanged.subscribe(function (e, args) {
grid.invalidateRows(args.rows);
grid.render();
});

grid.init();
grid.init();

grid.onColumnsResized.subscribe(function (e, args) {
CreateAddlHeaderRow();
});

grid.onColumnsResized.subscribe(function (e, args) {
CreateAddlHeaderRow();

// Initialise data
dataView.beginUpdate();
dataView.setItems(data);
dataView.endUpdate();
})
});

CreateAddlHeaderRow();

// Initialise data
dataView.beginUpdate();
dataView.setItems(data);
dataView.endUpdate();
</script>
</body>
</html>
6 changes: 3 additions & 3 deletions examples/example-composite-editor-item-details.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ <h2>View Source:</h2>
.appendTo("body");

$modal.keydown(function (e) {
if (e.which == $.ui.keyCode.ENTER) {
if (e.which == Slick.keyCode.ENTER) {
grid.getEditController().commitCurrentEdit();
e.stopPropagation();
e.preventDefault();
} else if (e.which == $.ui.keyCode.ESCAPE) {
} else if (e.which == Slick.keyCode.ESCAPE) {
grid.getEditController().cancelCurrentEdit();
e.stopPropagation();
e.preventDefault();
Expand All @@ -178,7 +178,7 @@ <h2>View Source:</h2>


var containers = $.map(columns, function (c) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$.map is a jQuery function, I know it's just an Example but if we're expecting to remove jQuery everywhere then...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's not prohibited to use SlickGrid and jQuery together :) There are 77 examples included, and I don't see the use to modify every example. Maybe some important ones, but not all. And the plugins still make use of jQuery.

My goal was to remove jQuery from the core library (all the js files in the root directory) and make the vanilla version usable without jQuery.

return $modal.find("[data-editorid=" + c.id + "]");
return $modal.find("[data-editorid=" + c.id + "]")[0];
});

var compositeEditor = new Slick.CompositeEditor(
Expand Down
2 changes: 1 addition & 1 deletion examples/example-composite-editor-modal-dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ <h2>View Source:</h2>
});

var containers = $.map(modalColumns, function (c) {
return $modal.find("[data-editorid=" + c.id + "]");
return $modal.find("[data-editorid=" + c.id + "]")[0];
});

var compositeEditor = new Slick.CompositeEditor(
Expand Down
2 changes: 1 addition & 1 deletion examples/example-explicit-initialization.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ <h2>View Source:</h2>

// create a detached container element
var myGrid = $("<div id='myGrid' style='width:600px;height:500px;position:relative;'></div>");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we keeping jQuery in some Examples? $("div...") is what I'm referring to

grid = new Slick.Grid(myGrid, data, columns, options);
grid = new Slick.Grid(myGrid[0], data, columns, options);


// ... later on, append the container to the DOM and initialize SlickGrid
Expand Down
28 changes: 12 additions & 16 deletions examples/example1-simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ <h2>View Source:</h2>
</tr>
</table>

<script src="../lib/jquery-3.1.0.js"></script>
<script src="../slick.interactions.js"></script>
MarkoBL marked this conversation as resolved.
Show resolved Hide resolved
<script src="https://cdn.jsdelivr.net/npm/sortablejs/Sortable.min.js"></script>

<script src="../slick.core.js"></script>
Expand All @@ -50,21 +48,19 @@ <h2>View Source:</h2>
enableColumnReorder: false
};

$(function () {
var data = [];
for (var i = 0; i < 500; i++) {
data[i] = {
title: "Task " + i,
duration: "5 days",
percentComplete: Math.round(Math.random() * 100),
start: "01/01/2009",
finish: "01/05/2009",
effortDriven: (i % 5 == 0)
};
}
var data = [];
for (var i = 0; i < 500; i++) {
data[i] = {
title: "Task " + i,
duration: "5 days",
percentComplete: Math.round(Math.random() * 100),
start: "01/01/2009",
finish: "01/05/2009",
effortDriven: (i % 5 == 0)
};
}

grid = new Slick.Grid("#myGrid", data, columns, options);
})
grid = new Slick.Grid("#myGrid", data, columns, options);
</script>
</body>
</html>
6 changes: 2 additions & 4 deletions examples/example2-formatters.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ <h2>View Source:</h2>

<script src="../lib/firebugx.js"></script>

<script src="../lib/jquery-3.1.0.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sortablejs/Sortable.min.js"></script>

<script src="../slick.core.js"></script>
Expand Down Expand Up @@ -99,10 +98,10 @@ <h2>View Source:</h2>
var options = {
editable: true,
enableAddRow: false,
enableCellNavigation: true
enableCellNavigation: true,
createPreHeaderPanel: true
};

$(function () {
for (var i = 0; i < 5; i++) {
var d = (data[i] = {});

Expand All @@ -115,7 +114,6 @@ <h2>View Source:</h2>
}

grid = new Slick.Grid("#myGrid", data, columns, options);
})
</script>
</body>
</html>
6 changes: 3 additions & 3 deletions examples/example3-editing.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ <h2>View Source:</h2>

<script src="../lib/firebugx.js"></script>

<script src="../lib/jquery-3.1.0.js"></script>
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script src="https://cdn.jsdelivr.net/npm/sortablejs/Sortable.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script src="https://cdn.jsdelivr.net/npm/sortablejs/Sortable.min.js"></script>

<script src="../lib/jquery-3.1.0.js"></script>
<script src="../slick.core.js"></script>
<script src="../plugins/slick.cellrangedecorator.js"></script>
<script src="../plugins/slick.cellrangeselector.js"></script>
Expand Down
3 changes: 0 additions & 3 deletions examples/example3b-editing-with-undo.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ <h2>View Source:</h2>

<script src="../lib/firebugx.js"></script>

<script src="../lib/jquery-3.1.0.js"></script>
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script src="https://cdn.jsdelivr.net/npm/sortablejs/Sortable.min.js"></script>

Expand Down Expand Up @@ -96,7 +95,6 @@ <h2>View Source:</h2>
}
}

$(function () {
for (var i = 0; i < 500; i++) {
var d = (data[i] = {});

Expand All @@ -110,7 +108,6 @@ <h2>View Source:</h2>
}

grid = new Slick.Grid("#myGrid", data, columns, options);
})
</script>
</body>
</html>
Loading