Skip to content

Commit

Permalink
take away options parameter from Capytable initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
cadamsmith committed Oct 2, 2024
1 parent b4c6682 commit 4263a41
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
25 changes: 5 additions & 20 deletions src/capytable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import { initialize } from './core/init';
import { adjustSortingClasses } from './core/sort';
import { logError } from './core/support';
import { ISettings } from './models/interfaces';
import { IOptions } from './models/options';
import { Settings } from './models/settings';

class Capytable {
settings: ISettings;

constructor(id: string, options?: IOptions) {
constructor(id: string) {
var element = document.getElementById(id);
if (!element) {
console.error('Element with id ' + id + ' not found');
Expand All @@ -27,29 +26,15 @@ class Capytable {
return;
}

if (!options) {
options = {
searching: true,
paging: true,
ordering: true,
};
}

// make col group element
const colGroupElement = document.createElement('colgroup');
element.prepend(colGroupElement);

/* Create the settings object for this table and set some of the default parameters */
var oSettings: ISettings = new Settings(
options.searching,
options.paging,
options.ordering,
id,
{
table: element,
colgroup: colGroupElement,
},
);
var oSettings: ISettings = new Settings(id, {
table: element,
colgroup: colGroupElement,
});

// Need to add the instance after the instance after the settings object has been added
// to the settings array, so we can self reference the table instance if more than one
Expand Down
14 changes: 4 additions & 10 deletions src/models/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,11 @@ export class Settings implements ISettings {

_reszEvt: boolean = false;

constructor(
searching: boolean,
paging: boolean,
ordering: boolean,
tableId: string,
elementRefs: { [id: string]: HTMLElement },
) {
constructor(tableId: string, elementRefs: { [id: string]: HTMLElement }) {
this.features = {
searching: searching,
paging: paging,
ordering: ordering,
searching: true,
paging: true,
ordering: true,
};

this.tableId = tableId;
Expand Down

0 comments on commit 4263a41

Please sign in to comment.