From a9335885f76330980702965a4210943fb9b2c90e Mon Sep 17 00:00:00 2001 From: stavroskasidis Date: Thu, 21 Dec 2023 13:53:39 +0200 Subject: [PATCH] Refactor js code to be ES5 compatible. TODO: replace uglify because it does not support es6 --- BlazorContextMenu/gulpfile.js | 2 +- BlazorContextMenu/wwwroot/blazorContextMenu.js | 15 +++++++-------- global.json | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/BlazorContextMenu/gulpfile.js b/BlazorContextMenu/gulpfile.js index 88f8e85..69c3251 100644 --- a/BlazorContextMenu/gulpfile.js +++ b/BlazorContextMenu/gulpfile.js @@ -14,7 +14,7 @@ gulp.task("clean:css", function (cb) { }); gulp.task("min:css", function () { - return gulp.src(["wwwroot/**/*.css", "!wwwroot/**/*.css.js"], { base: "." }) + return gulp.src(["wwwroot/**/*.css", "!wwwroot/**/*.min.css"], { base: "." }) .pipe(cssmin()) .pipe(rename({ suffix: ".min" diff --git a/BlazorContextMenu/wwwroot/blazorContextMenu.js b/BlazorContextMenu/wwwroot/blazorContextMenu.js index 53190b5..d77b82f 100644 --- a/BlazorContextMenu/wwwroot/blazorContextMenu.js +++ b/BlazorContextMenu/wwwroot/blazorContextMenu.js @@ -75,10 +75,10 @@ var blazorContextMenu = function (blazorContextMenu) { } } - const sleepUntil = async (f, timeoutMs) => { - return new Promise((resolve, reject) => { - const timeWas = new Date(); - const wait = setInterval(function () { + var sleepUntil = function (f, timeoutMs) { + return new Promise(function (resolve, reject){ + var timeWas = new Date(); + var wait = setInterval(function () { if (f()) { clearInterval(wait); resolve(); @@ -135,10 +135,9 @@ var blazorContextMenu = function (blazorContextMenu) { }; var showMenuCommon = function (menu, menuId, x, y, target, triggerDotnetRef) { - return blazorContextMenu.Show(menuId, x, y, target, triggerDotnetRef).then(async function () { - - await sleepUntil(() => menu.clientWidth > 0, 1000); //Wait until the menu has spawned so clientWidth and offsetLeft report correctly - + return blazorContextMenu.Show(menuId, x, y, target, triggerDotnetRef).then(function () { + return sleepUntil(function () { return menu.clientWidth > 0 }, 1000); //Wait until the menu has spawned so clientWidth and offsetLeft report correctly + }).then(function () { //check for overflow var leftOverflownPixels = menu.offsetLeft + menu.clientWidth - window.innerWidth; if (leftOverflownPixels > 0) { diff --git a/global.json b/global.json index 352a6c1..657ef98 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "6.0.301" + "version": "6.0.417" } } \ No newline at end of file