Various JS optimizations

This commit is contained in:
Bernd Bestel
2023-05-21 18:01:47 +02:00
parent 825321593b
commit 979c67b44c
25 changed files with 64 additions and 87 deletions

View File

@@ -159,7 +159,6 @@ Grocy.Components.UserfieldsForm.Load = function()
formGroup.find('.userfield-file-show').removeClass('d-none');
formGroup.find('img.userfield-current-file')
.attr('src', U('/files/userfiles/' + value + '?force_serve_as=picture&best_fit_width=250&best_fit_height=250'));
LoadImagesLazy();
formGroup.find('.userfield-file-delete').click(
function()
@@ -240,7 +239,6 @@ Grocy.Components.UserfieldsForm.Clear = function()
formGroup.find('.userfield-file-show').removeClass('d-none');
formGroup.find('img.userfield-current-file')
.attr('src', U('/files/userfiles/' + value + '?force_serve_as=picture&best_fit_width=250&best_fit_height=250'));
LoadImagesLazy();
formGroup.find('.userfield-file-delete').click(
function()

View File

@@ -208,7 +208,7 @@ $(".calendar").each(function()
if (recipe.picture_file_name)
{
element.prepend('<div class="mx-auto mb-1"><img data-src="' + U("/api/files/recipepictures/") + btoa(recipe.picture_file_name) + '?force_serve_as=picture&best_fit_width=400" class="img-fluid rounded-circle lazy"></div>')
element.prepend('<div class="mx-auto mb-1"><img src="' + U("/api/files/recipepictures/") + btoa(recipe.picture_file_name) + '?force_serve_as=picture&best_fit_width=400" class="img-fluid rounded-circle" loading="lazy"></div>')
}
}
else if (event.type == "product")
@@ -279,7 +279,7 @@ $(".calendar").each(function()
if (productDetails.product.picture_file_name)
{
element.prepend('<div class="mx-auto mb-1"><img data-src="' + U("/api/files/productpictures/") + btoa(productDetails.product.picture_file_name) + '?force_serve_as=picture&best_fit_width=400" class="img-fluid rounded-circle lazy"></div>')
element.prepend('<div class="mx-auto mb-1"><img src="' + U("/api/files/productpictures/") + btoa(productDetails.product.picture_file_name) + '?force_serve_as=picture&best_fit_width=400" class="img-fluid rounded-circle" loading="lazy"></div>')
}
}
else if (event.type == "note")
@@ -352,7 +352,6 @@ $(".calendar").each(function()
});
RefreshLocaleNumberDisplay();
LoadImagesLazy();
$('[data-toggle="tooltip"]').tooltip();
if (!Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK)
@@ -929,7 +928,7 @@ $(document).on("click", ".display-recipe-button", function(e)
function(result)
{
bootbox.dialog({
message: '<iframe height="650px" class="embed-responsive" src="' + U("/recipes?embedded&recipe=") + objectId + '#fullscreen"></iframe>',
message: '<iframe height="650px" class="embed-responsive" src="' + U("/recipes?embedded&recipe=") + objectId + '#fullscreen" loading="lazy"></iframe>',
size: 'extra-large',
backdrop: true,
closeButton: false,

View File

@@ -10,7 +10,6 @@
});
$('#products-table tbody').removeClass("d-none");
productsTable.columns.adjust().draw();
LoadImagesLazy();
$("#search").on("keyup", Delay(function()
{

View File

@@ -198,7 +198,7 @@ $("#test-quantityunit-plural-forms-button").on("click", function(e)
$("#save-quantityunit-button").click();
bootbox.alert({
message: '<iframe height="400px" class="embed-responsive" src="' + U("/quantityunitpluraltesting?embedded&qu=") + Grocy.EditObjectId.toString() + '"></iframe>',
message: '<iframe height="400px" class="embed-responsive" src="' + U("/quantityunitpluraltesting?embedded&qu=") + Grocy.EditObjectId.toString() + '" loading="lazy"></iframe>',
closeButton: false,
size: "large",
callback: function(result)

View File

@@ -220,7 +220,7 @@ $(document).on('click', '.recipe-pos-edit-button', function(e)
var recipePosId = $(e.currentTarget).attr('data-recipe-pos-id');
bootbox.dialog({
message: '<iframe height="650px" class="embed-responsive" src="' + U("/recipe/") + Grocy.EditObjectId.toString() + '/pos/' + recipePosId.toString() + '?embedded&product=' + productId.toString() + '"></iframe>',
message: '<iframe height="650px" class="embed-responsive" src="' + U("/recipe/") + Grocy.EditObjectId.toString() + '/pos/' + recipePosId.toString() + '?embedded&product=' + productId.toString() + '" loading="lazy"></iframe>',
size: 'large',
backdrop: true,
closeButton: false,
@@ -266,7 +266,7 @@ $("#recipe-pos-add-button").on("click", function(e)
e.preventDefault();
bootbox.dialog({
message: '<iframe height="650px" class="embed-responsive" src="' + U("/recipe/") + Grocy.EditObjectId + '/pos/new?embedded"></iframe>',
message: '<iframe height="650px" class="embed-responsive" src="' + U("/recipe/") + Grocy.EditObjectId + '/pos/new?embedded" loading="lazy"></iframe>',
size: 'large',
backdrop: true,
closeButton: false,

View File

@@ -63,7 +63,6 @@ $("a[data-toggle='tab']").on("shown.bs.tab", function(e)
{
var tabId = $(e.target).attr("id");
window.localStorage.setItem("recipes_last_tab_id", tabId);
LoadImagesLazy();
});
$("#search").on("keyup", Delay(function()
@@ -293,7 +292,7 @@ recipesTables.on('select', function(e, dt, type, indexes)
else
{
bootbox.dialog({
message: '<iframe height="650px" class="embed-responsive" src="' + U("/recipes?embedded&recipe=") + selectedRecipeId + '#fullscreen"></iframe>',
message: '<iframe height="650px" class="embed-responsive" src="' + U("/recipes?embedded&recipe=") + selectedRecipeId + '#fullscreen" loading="lazy"></iframe>',
size: 'extra-large',
backdrop: true,
closeButton: false,
@@ -325,7 +324,7 @@ $(".recipe-gallery-item").on("click", function(e)
else
{
bootbox.dialog({
message: '<iframe height="650px" class="embed-responsive" src="' + U("/recipes?embedded&recipe=") + selectedRecipeId + '#fullscreen"></iframe>',
message: '<iframe height="650px" class="embed-responsive" src="' + U("/recipes?embedded&recipe=") + selectedRecipeId + '#fullscreen" loading="lazy"></iframe>',
size: 'extra-large',
backdrop: true,
closeButton: false,
@@ -419,8 +418,6 @@ if (window.location.hash === "#fullscreen")
$("#selectedRecipeToggleFullscreenButton").click();
}
LoadImagesLazy();
$(document).on('click', '.recipe-grocycode-label-print', function(e)
{
e.preventDefault();

View File

@@ -35,7 +35,6 @@ var stockOverviewTable = $('#stock-overview-table').DataTable({
$('#stock-overview-table tbody').removeClass("d-none");
stockOverviewTable.columns.adjust().draw();
LoadImagesLazy();
$("#location-filter").on("change", function()
{