From 77e365985f9a4aa1325665b089b95ba22b0989a6 Mon Sep 17 00:00:00 2001 From: Katharina Bogad Date: Thu, 24 Jun 2021 11:54:25 +0200 Subject: [PATCH] Make CSS preloadable, move some CSS out of header --- js/grocy.js | 10 +++++++++- scss/_barcodes.scss | 12 ++++++++++++ views/components/barcodescanner.blade.php | 19 ------------------- views/layout/json.blade.php | 5 +++++ views/recipeform.blade.php | 2 +- 5 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 views/layout/json.blade.php diff --git a/js/grocy.js b/js/grocy.js index 9776f3b4..5970881f 100644 --- a/js/grocy.js +++ b/js/grocy.js @@ -252,7 +252,7 @@ class GrocyClass } } - PreloadView(viewName, cb = () => { }) + PreloadView(viewName, loadCSS = false, cb = () => { }) { if (!Object.prototype.hasOwnProperty.call(window, viewName + "View")) { @@ -262,6 +262,14 @@ class GrocyClass url: this.FormatUrl('/viewjs/' + viewName + '.js'), success: cb }); + if (loadCSS) + { + $("", { + rel: "stylesheet", + type: "text/css", + href: this.FormatUrl('/css/viewcss/' + viewName + '.cs') + }).appendTo("head"); + } } else { diff --git a/scss/_barcodes.scss b/scss/_barcodes.scss index 19f15793..26fc2ace 100644 --- a/scss/_barcodes.scss +++ b/scss/_barcodes.scss @@ -11,4 +11,16 @@ } #barcodescanner-livestream canvas { width: 100%; +} + +#barcodescanner-start-button { + position: absolute; + right: 0; + margin-top: 4px; + margin-right: 5px; + cursor: pointer; +} + +.combobox-container #barcodescanner-start-button { + margin-right: 36px !important; } \ No newline at end of file diff --git a/views/components/barcodescanner.blade.php b/views/components/barcodescanner.blade.php index 0d34b69e..e69de29b 100644 --- a/views/components/barcodescanner.blade.php +++ b/views/components/barcodescanner.blade.php @@ -1,19 +0,0 @@ -@if (!GROCY_DISABLE_BROWSER_BARCODE_CAMERA_SCANNING) - -@push('pageStyles') - -@endpush - -@endif \ No newline at end of file diff --git a/views/layout/json.blade.php b/views/layout/json.blade.php new file mode 100644 index 00000000..c006ea1f --- /dev/null +++ b/views/layout/json.blade.php @@ -0,0 +1,5 @@ +@php +// this is a shoe-horned method to generate a "proper" subview as JSON. + + +@endphp \ No newline at end of file diff --git a/views/recipeform.blade.php b/views/recipeform.blade.php index 8dda0616..db581039 100644 --- a/views/recipeform.blade.php +++ b/views/recipeform.blade.php @@ -21,7 +21,7 @@ RecipePictureFileName: '{{ $recipe->picture_file_name }}', @endif -@stop +@endsection @section('content')