From 1b3e30146a914f65e0755ad3098a5785aadc3f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Van=20Canneyt?= Date: Mon, 27 Nov 2023 22:11:08 +0100 Subject: [PATCH] * Bootstrap namespaced --- .../bootstrap/namespaced/Api.Bootstrap.pas | 3 ++ .../namespaced/Api.BootstrapTable.pas | 3 ++ .../bootstrap/namespaced/Widget.Bootstrap.pas | 3 ++ .../namespaced/Widget.BootstrapTable.pas | 3 ++ .../{ => src}/bootstraptablewidget.pp | 28 ++++++++++- .../bootstrap/{ => src}/bootstrapwidgets.pp | 9 +++- packages/bootstrap/{ => src}/libbootstrap.pp | 8 +++- .../bootstrap/{ => src}/libbootstraptable.pp | 46 ++++++++++++------- 8 files changed, 83 insertions(+), 20 deletions(-) create mode 100644 packages/bootstrap/namespaced/Api.Bootstrap.pas create mode 100644 packages/bootstrap/namespaced/Api.BootstrapTable.pas create mode 100644 packages/bootstrap/namespaced/Widget.Bootstrap.pas create mode 100644 packages/bootstrap/namespaced/Widget.BootstrapTable.pas rename packages/bootstrap/{ => src}/bootstraptablewidget.pp (98%) rename packages/bootstrap/{ => src}/bootstrapwidgets.pp (99%) rename packages/bootstrap/{ => src}/libbootstrap.pp (98%) rename packages/bootstrap/{ => src}/libbootstraptable.pp (94%) diff --git a/packages/bootstrap/namespaced/Api.Bootstrap.pas b/packages/bootstrap/namespaced/Api.Bootstrap.pas new file mode 100644 index 0000000..44c0e22 --- /dev/null +++ b/packages/bootstrap/namespaced/Api.Bootstrap.pas @@ -0,0 +1,3 @@ +{$DEFINE FPC_DOTTEDUNITS} +unit Api.Bootstrap; +{$include ../src/libbootstrap.pp} diff --git a/packages/bootstrap/namespaced/Api.BootstrapTable.pas b/packages/bootstrap/namespaced/Api.BootstrapTable.pas new file mode 100644 index 0000000..05025a8 --- /dev/null +++ b/packages/bootstrap/namespaced/Api.BootstrapTable.pas @@ -0,0 +1,3 @@ +{$DEFINE FPC_DOTTEDUNITS} +unit Api.BootstrapTable; +{$include ../src/libbootstraptable.pp} diff --git a/packages/bootstrap/namespaced/Widget.Bootstrap.pas b/packages/bootstrap/namespaced/Widget.Bootstrap.pas new file mode 100644 index 0000000..2c849ab --- /dev/null +++ b/packages/bootstrap/namespaced/Widget.Bootstrap.pas @@ -0,0 +1,3 @@ +{$DEFINE FPC_DOTTEDUNITS} +unit Widget.Bootstrap; +{$include ../src/bootstrapwidgets.pp} diff --git a/packages/bootstrap/namespaced/Widget.BootstrapTable.pas b/packages/bootstrap/namespaced/Widget.BootstrapTable.pas new file mode 100644 index 0000000..d9dd035 --- /dev/null +++ b/packages/bootstrap/namespaced/Widget.BootstrapTable.pas @@ -0,0 +1,3 @@ +{$DEFINE FPC_DOTTEDUNITS} +unit Widget.BootstrapTable; +{$include ../src/bootstraptablewidget.pp} diff --git a/packages/bootstrap/bootstraptablewidget.pp b/packages/bootstrap/src/bootstraptablewidget.pp similarity index 98% rename from packages/bootstrap/bootstraptablewidget.pp rename to packages/bootstrap/src/bootstraptablewidget.pp index 5fdd7a5..89acef7 100644 --- a/packages/bootstrap/bootstraptablewidget.pp +++ b/packages/bootstrap/src/bootstraptablewidget.pp @@ -1,9 +1,30 @@ +{ + This file is part of the Pas2JS run time library. + Copyright (C) 2019 Michael Van Canneyt + + BootstrapTable widget + + See the file COPYING.FPC, included in this distribution, + for details about the copyright. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + **********************************************************************} +{$IFNDEF FPC_DOTTEDUNITS} unit bootstraptablewidget; +{$ENDIF} interface uses +{$IFDEF FPC_DOTTEDUNITS} + Api.JQuery, Api.BootstrapTable, Widget.Web, System.SysUtils, System.Classes, Data.DB, + JSApi.JS, BrowserApi.Web, System.StrUtils; +{$ELSE} libjquery, libbootstraptable, WebWidget, SysUtils, Classes, DB, JS, Web, strutils; +{$ENDIF} type EBootstrapTable = class(EWidgets); @@ -419,7 +440,12 @@ Const implementation -uses jsondataset, dateutils; +uses +{$IFDEF FPC_DOTTEDUNITS} + Data.JsonDataset, System.DateUtils; +{$ELSE} + jsondataset, dateutils; +{$ENDIF} { TTableDataLink } diff --git a/packages/bootstrap/bootstrapwidgets.pp b/packages/bootstrap/src/bootstrapwidgets.pp similarity index 99% rename from packages/bootstrap/bootstrapwidgets.pp rename to packages/bootstrap/src/bootstrapwidgets.pp index 5549066..cd48057 100644 --- a/packages/bootstrap/bootstrapwidgets.pp +++ b/packages/bootstrap/src/bootstrapwidgets.pp @@ -12,15 +12,22 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. **********************************************************************} - +{$IFNDEF FPC_DOTTEDUNITS} unit bootstrapwidgets; +{$ENDIF} {$mode objfpc} {$WARN 4501 off : } + interface uses +{$IFDEF FPC_DOTTEDUNITS} + System.Classes, System.SysUtils, JSApi.JS, Api.JQuery, Api.Bootstrap, BrowserApi.Web, + Widget.Web, Widget.HTML, Browser.TemplateLoader; +{$ELSE} Classes, SysUtils, js, libjquery, libbootstrap, web, webwidget, htmlwidgets, rtl.TemplateLoader; +{$ENDIF} Type diff --git a/packages/bootstrap/libbootstrap.pp b/packages/bootstrap/src/libbootstrap.pp similarity index 98% rename from packages/bootstrap/libbootstrap.pp rename to packages/bootstrap/src/libbootstrap.pp index 9892bc9..5d26e25 100644 --- a/packages/bootstrap/libbootstrap.pp +++ b/packages/bootstrap/src/libbootstrap.pp @@ -12,9 +12,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. **********************************************************************} - - +{$IFNDEF FPC_DOTTEDUNITS} unit libbootstrap; +{$ENDIF} {$mode objfpc} {$modeswitch externalclass} @@ -22,7 +22,11 @@ unit libbootstrap; interface uses +{$IFDEF FPC_DOTTEDUNITS} + JSApi.JS, BrowserApi.Web, Api.JQuery; +{$ELSE} JS, web, libjquery; +{$ENDIF} Type TBootstrapVersion = (bv4,bv5); diff --git a/packages/bootstrap/libbootstraptable.pp b/packages/bootstrap/src/libbootstraptable.pp similarity index 94% rename from packages/bootstrap/libbootstraptable.pp rename to packages/bootstrap/src/libbootstraptable.pp index 91a73b2..6f6b901 100644 --- a/packages/bootstrap/libbootstraptable.pp +++ b/packages/bootstrap/src/libbootstraptable.pp @@ -12,8 +12,10 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. **********************************************************************} - +{$IFNDEF FPC_DOTTEDUNITS} unit libbootstraptable; +{$ENDIF} + {$mode objfpc} {$modeswitch externalclass} @@ -21,7 +23,11 @@ unit libbootstraptable; interface uses +{$IFDEF FPC_DOTTEDUNITS} + System.Types, BrowserApi.Web, Api.JQuery, JSApi.JS, Api.Bootstrap; +{$ELSE} types, web, libjquery, js, libbootstrap; +{$ENDIF} Type TTableStyle = Class external name 'Object' (TJSObject) @@ -277,6 +283,14 @@ Type implementation + + +function JSNew (args : TJSValueDynArray) : TJSObject; + +begin + Result:={$IFDEF FPC_DOTTEDUNITS}JSApi.{$ENDIF}JS.New(Args); +end; + { TJSBootstrapTable } function TJSBootstrapTable.getOptionsUnTyped: TJSObject; @@ -296,7 +310,7 @@ end; function TJSBootstrapTable.getData(useCurrentPage: Boolean; includeHiddenRows: Boolean): JSValue; begin - Result:=BootstrapTable('getdata',JS.New([ + Result:=BootstrapTable('getdata',JSNew([ 'useCurrentPage',useCurrentPage, 'includeHiddenRows',includeHiddenRows ])); @@ -335,7 +349,7 @@ end; procedure TJSBootstrapTable.insertRow(Index: Integer; RowData: JSValue); begin - BootstrapTable('insertRow',JS.new([ + BootstrapTable('insertRow',JSNew([ 'index',index, 'row', RowData ])); @@ -344,7 +358,7 @@ end; procedure TJSBootstrapTable.updateRow(Index: Integer; RowData: JSValue; Replace : Boolean = False); begin - BootstrapTable('updateRow',JS.new([ + BootstrapTable('updateRow',JSNew([ 'index',index, 'row', rowData, 'replace', replace @@ -358,7 +372,7 @@ end; procedure TJSBootstrapTable.UpdateByUniqueID(aID: NativeInt; RowData: JSValue; Replace: Boolean); begin - BootstrapTable('updateByUniqueId',JS.new([ + BootstrapTable('updateByUniqueId',JSNew([ 'id',aId, 'row', rowData, 'replace', replace @@ -372,7 +386,7 @@ end; procedure TJSBootstrapTable.UpdateCell(aIndex: NativeInt; aField, aValue: string; ReInit : Boolean = true); begin - BootstrapTable('updateCell',JS.new([ + BootstrapTable('updateCell',JSNew([ 'index',aIndex, 'field', aField, 'value', aValue, @@ -382,7 +396,7 @@ end; procedure TJSBootstrapTable.UpdateCellByUniqueID(aId: NativeInt; aField, aValue: string; ReInit: Boolean); begin - BootstrapTable('updateCellByUniqueID',JS.new([ + BootstrapTable('updateCellByUniqueID',JSNew([ 'id',aId, 'field', aField, 'value', aValue, @@ -392,12 +406,12 @@ end; procedure TJSBootstrapTable.ShowRow(aIndex: NativeInt); begin - BootstrapTable('showRow',JS.new(['id',aIndex])); + BootstrapTable('showRow',JSNew(['id',aIndex])); end; procedure TJSBootstrapTable.ShowRowByUniqueID(aId: NativeInt); begin - BootstrapTable('showRow',JS.new(['uniqueId',aId])); + BootstrapTable('showRow',JSNew(['uniqueId',aId])); end; function TJSBootstrapTable.GetHiddenRows(doShow: Boolean): TJSArray; @@ -448,7 +462,7 @@ end; procedure TJSBootstrapTable.mergeCells(aIndex: integer; aField: String; RowSpan: Integer; ColSpan: Integer); begin - BootstrapTable('mergeCells',JS.New([ + BootstrapTable('mergeCells',JSNew([ 'index',aIndex, 'field',aField, 'rowspan',rowspan, @@ -483,12 +497,12 @@ end; procedure TJSBootstrapTable.CheckBy(Field: String; Values: TStringDynArray); begin - BootStrapTable('checkBy',JS.New(['field',Field,'values',Values])); + BootStrapTable('checkBy',JSNew(['field',Field,'values',Values])); end; procedure TJSBootstrapTable.UnCheckBy(Field: String; Values: TStringDynArray); begin - BootStrapTable('uncheckBy',JS.New(['field',Field,'values',Values])); + BootStrapTable('uncheckBy',JSNew(['field',Field,'values',Values])); end; procedure TJSBootstrapTable.RefreshTable(options: TRefreshOptions); @@ -543,17 +557,17 @@ end; procedure TJSBootstrapTable.FilterBy(aFilter: TJSObject; aOptions: TJSObject); begin - BootStrapTable('filterBy',JS.New(['filter',aFilter,'options',aOptions])); + BootStrapTable('filterBy',JSNew(['filter',aFilter,'options',aOptions])); end; procedure TJSBootstrapTable.scrollToRow(aValue: Integer); begin - BootStrapTable('scrollTo',JS.New(['unit','rows','value',aValue])); + BootStrapTable('scrollTo',JSNew(['unit','rows','value',aValue])); end; procedure TJSBootstrapTable.scrollToPixel(aValue: Integer); begin - BootStrapTable('scrollTo',JS.New(['unit','px','value',aValue])); + BootStrapTable('scrollTo',JSNew(['unit','px','value',aValue])); end; procedure TJSBootstrapTable.scrollToBottom; @@ -607,7 +621,7 @@ end; procedure TJSBootstrapTable.UpdateColumnTitle(const aField, aTitle: String); begin - BootStrapTable('updateColumnTitle',JS.New(['field',aField,'title',aTitle])); + BootStrapTable('updateColumnTitle',JSNew(['field',aField,'title',aTitle])); end; procedure TJSBootstrapTable.UpdateFormatText(const aFormat, aValue: String);