Improve responsive embeds (references #25)

This commit is contained in:
Bernd Bestel
2018-10-03 19:05:00 +02:00
parent 3b10906e78
commit 7ba6fc875b
5 changed files with 29 additions and 13 deletions

View File

@@ -322,3 +322,22 @@ if ($(".custom-file-label").length > 0)
{ {
$("<style>").html('.custom-file-label::after { content: "' + L("Select file") + '"; }').appendTo("head"); $("<style>").html('.custom-file-label::after { content: "' + L("Select file") + '"; }').appendTo("head");
} }
ResizeResponsiveEmbeds = function(fillEntireViewport = false)
{
if (!fillEntireViewport)
{
var maxHeight = $("body").height() - $("#mainNav").outerHeight() - 62;
}
else
{
var maxHeight = $("body").height();
}
$(".embed-responsive").attr("height", maxHeight.toString() + "px");
}
$(window).on('resize', function()
{
console.log($("body").hasClass("fullscreen-responsive-embed-active"));
ResizeResponsiveEmbeds($("body").hasClass("fullscreen-responsive-embed-active"));
});

View File

@@ -50,6 +50,7 @@ function DisplayEquipment(id)
$("#selected-equipment-has-no-instruction-manual-hint").addClass("d-none"); $("#selected-equipment-has-no-instruction-manual-hint").addClass("d-none");
$("a[href='#instruction-manual-tab']").tab("show"); $("a[href='#instruction-manual-tab']").tab("show");
ResizeResponsiveEmbeds();
} }
else else
{ {
@@ -118,6 +119,8 @@ $("#selectedEquipmentInstructionManualToggleFullscreenButton").on('click', funct
$("#selectedEquipmentInstructionManualCard").toggleClass("fullscreen"); $("#selectedEquipmentInstructionManualCard").toggleClass("fullscreen");
$("#selectedEquipmentInstructionManualCard .card-header").toggleClass("fixed-top"); $("#selectedEquipmentInstructionManualCard .card-header").toggleClass("fixed-top");
$("#selectedEquipmentInstructionManualCard .card-body").toggleClass("mt-5"); $("#selectedEquipmentInstructionManualCard .card-body").toggleClass("mt-5");
$("body").toggleClass("fullscreen-responsive-embed-active");
ResizeResponsiveEmbeds(true);
}); });
$("#selectedEquipmentDescriptionToggleFullscreenButton").on('click', function(e) $("#selectedEquipmentDescriptionToggleFullscreenButton").on('click', function(e)

View File

@@ -124,5 +124,7 @@ $('#description').summernote({
lang: L('summernote_locale') lang: L('summernote_locale')
}); });
ResizeResponsiveEmbeds();
$('#name').focus(); $('#name').focus();
Grocy.FrontendHelpers.ValidateForm('equipment-form'); Grocy.FrontendHelpers.ValidateForm('equipment-form');

View File

@@ -6,26 +6,18 @@
@section('content') @section('content')
<div class="row"> <div class="row">
<div class="col">
<div class="col-xs-12 col-md-4 pb-3">
<h1> <h1>
@yield('title') @yield('title')
<a class="btn btn-outline-dark" href="{{ $U('/equipment/new') }}"> <a class="btn btn-outline-dark" href="{{ $U('/equipment/new') }}">
<i class="fas fa-plus"></i>&nbsp;{{ $L('Add') }} <i class="fas fa-plus"></i>&nbsp;{{ $L('Add') }}
</a> </a>
</h1> </h1>
</div>
</div>
<div class="row mt-3">
<div class="col-xs-12 col-md-6 col-xl-3">
<label for="search">{{ $L('Search') }}</label> <i class="fas fa-search"></i> <label for="search">{{ $L('Search') }}</label> <i class="fas fa-search"></i>
<input type="text" class="form-control" id="search"> <input type="text" class="form-control" id="search">
</div>
</div>
<div class="row">
<div class="col-xs-12 col-md-3 pb-3">
<table id="equipment-table" class="table table-sm table-striped dt-responsive"> <table id="equipment-table" class="table table-sm table-striped dt-responsive">
<thead> <thead>
<tr> <tr>
@@ -53,7 +45,7 @@
</table> </table>
</div> </div>
<div class="col-xs-12 col-md-9"> <div class="col-xs-12 col-md-8">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#instruction-manual-tab">{{ $L('Instruction manual') }}</a> <a class="nav-link active" data-toggle="tab" href="#instruction-manual-tab">{{ $L('Instruction manual') }}</a>
@@ -73,7 +65,7 @@
</div> </div>
<div class="card-body py-0 px-0"> <div class="card-body py-0 px-0">
<p id="selected-equipment-has-no-instruction-manual-hint" class="text-muted font-italic d-none">{{ $L('The selected equipment has no instruction manual') }}</p> <p id="selected-equipment-has-no-instruction-manual-hint" class="text-muted font-italic d-none">{{ $L('The selected equipment has no instruction manual') }}</p>
<embed id="selected-equipment-instruction-manual" class="embed-responsive embed-responsive-4by3" width="100%" height="800px" src="" type="application/pdf"> <embed id="selected-equipment-instruction-manual" class="embed-responsive embed-responsive-4by3" src="" type="application/pdf">
</div> </div>
</div> </div>
</div> </div>

View File

@@ -64,7 +64,7 @@
<label class="mt-2">{{ $L('Current instruction manual') }}</label> <label class="mt-2">{{ $L('Current instruction manual') }}</label>
<button id="delete-current-instruction-manual-button" class="btn btn-sm btn-danger @if(empty($equipment->instruction_manual_file_name)) disabled @endif"><i class="fas fa-trash"></i> {{ $L('Delete') }}</button> <button id="delete-current-instruction-manual-button" class="btn btn-sm btn-danger @if(empty($equipment->instruction_manual_file_name)) disabled @endif"><i class="fas fa-trash"></i> {{ $L('Delete') }}</button>
@if(!empty($equipment->instruction_manual_file_name)) @if(!empty($equipment->instruction_manual_file_name))
<embed id="current-equipment-instruction-manual" class="embed-responsive embed-responsive-4by3" width="100%" height="800px" src="{{ $U('/api/file/equipmentmanuals?file_name=' . $equipment->instruction_manual_file_name) }}" type="application/pdf"> <embed id="current-equipment-instruction-manual" class="embed-responsive embed-responsive-4by3" src="{{ $U('/api/file/equipmentmanuals?file_name=' . $equipment->instruction_manual_file_name) }}" type="application/pdf">
<p id="delete-current-instruction-manual-on-save-hint" class="form-text text-muted font-italic d-none">{{ $L('The current instruction manual will be deleted when you save the equipment') }}</p> <p id="delete-current-instruction-manual-on-save-hint" class="form-text text-muted font-italic d-none">{{ $L('The current instruction manual will be deleted when you save the equipment') }}</p>
@else @else
<p id="no-current-instruction-manual-hint" class="form-text text-muted font-italic">{{ $L('No instruction manual available') }}</p> <p id="no-current-instruction-manual-hint" class="form-text text-muted font-italic">{{ $L('No instruction manual available') }}</p>