From 863e669a1578e8017ffd4ec1f1461df5c4aa5308 Mon Sep 17 00:00:00 2001 From: JelteMX Date: Wed, 3 Mar 2021 15:45:21 +0100 Subject: [PATCH 1/2] Add widget context as an argument to the jQuery script --- package.json | 2 +- src/HTMLSnippet/widget/HTMLSnippet.js | 9 +++++---- src/package.xml | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 30fe1a5..073fc12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "HTMLSnippet", - "version": "3.9.5", + "version": "3.9.6", "description": "", "license": "", "author": "", diff --git a/src/HTMLSnippet/widget/HTMLSnippet.js b/src/HTMLSnippet/widget/HTMLSnippet.js index a8d8d39..255d550 100644 --- a/src/HTMLSnippet/widget/HTMLSnippet.js +++ b/src/HTMLSnippet/widget/HTMLSnippet.js @@ -174,9 +174,9 @@ define([ (function (snippetCode) { /** * user's are get used to or might expect to have jQuery available globally - * and they will write their code according to that, and since we, in this widget, don't expose - * jQuery globally, we'll check user's code snippet if there is any attempt to access jQuery - * from the global scope ( window ). + * and they will write their code according to that, and since we, in this widget, don't expose + * jQuery globally, we'll check user's code snippet if there is any attempt to access jQuery + * from the global scope ( window ). */ var jqueryIdRegex1 = /window.\jQuery/g; var jqueryIdRegex2 = /window.\$/g; @@ -188,7 +188,8 @@ define([ "console.debug('your code snippet is evaluated and executed against JQuery version:'+ this.jquery.fn.jquery);"; eval(snippetCode); }).call({ - jquery: jQuery // pass JQuery as the context of the immediate function which will wrap the code snippet + jquery: jQuery, // pass JQuery as the context of the immediate function which will wrap the code snippet + widget: this // pass the HTMLSnippet widget context itself, so the code could use listen/addOnDestroy }, this.contents); // pass the code snippet as an arg } catch (error) { this._handleError(error); diff --git a/src/package.xml b/src/package.xml index e063445..73239e0 100644 --- a/src/package.xml +++ b/src/package.xml @@ -1,6 +1,6 @@ - + From a33395797ecfc8dfbdad9cc6de5a41c2fd2783fc Mon Sep 17 00:00:00 2001 From: JelteMX Date: Wed, 3 Mar 2021 16:38:29 +0100 Subject: [PATCH 2/2] Fix widgets path when using pages that have an ID (e.g. //host/p/Page) --- webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index 15f1fbe..f0cd37b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -19,7 +19,7 @@ const widgetVersion = package.version; filename: `${widgetName}/widget/[name].js`, chunkFilename: `${widgetName}/widget/${widgetName}[id].js`, libraryTarget: "amd", - publicPath: "widgets/" + publicPath: "/widgets/" }, devtool: false, mode: "production",