$this->addField('section_composition', FormBigSection::class, __('Composition'));
$this->addField('page_numbers', Textarea::class, __('Numérotation'));
- $this->addField('section_theme', FormBigSection::class, __('Thème'));
- $this->addField('theme', \App\Fields\FluidbookTheme::class);
+ $this->addField('section_theme', FormBigSection::class, __('Thème graphique'));
+ $this->addField('theme', \App\Fields\FluidbookTheme::class,__('Thème'));
$this->addField('section_locale', FormBigSection::class, __('Langue'));
$this->addField('locale', FluidbookLocale::class, __('Langue principale'), ['default' => 'fr', 'allows_null' => false, 'filter' => true, 'filter_label' => 'Langue', 'column' => true, 'column_label' => '<i class="la la-language"></i>']);
public function getPreviewURL($params = [], $page = 2)
{
+ return self::getThemePreviewURL($this->getIdValue(), $params, $page);
+ }
+
+ public static function getThemePreviewURL($id, $params = [], $page = 2)
+ {
+ $defaultParams = ['shortLoading' => '1'];
+ $params = array_merge($defaultParams, $params);
+
if (count($params) > 0) {
$g = [];
foreach ($params as $k => $v) {
} else {
$get = '';
}
- return 'https://workshop.fluidbook.com/viewerh/20098-' . $this->getIdValue() . '_f2e0452eed6dba9878016ce5603fdc54/' . $get . '#/page/' . $page;
+ return 'https://workshop.fluidbook.com/viewerh/20098-' . $id . '_f2e0452eed6dba9878016ce5603fdc54/' . $get . '#/page/' . $page;
}
--- /dev/null
+@if (!isset($seenThemeSelector))
+ @php $seenThemeSelector=true;@endphp
+ @push('crud_fields_scripts')
+ <script>
+ var selector = '.select2_from_array[name="{{$field['name']}}"]';
+ $(function () {
+ $(document).on('change', selector, function () {
+ updateThemeSelector();
+ })
+ $(window).on('resize', resizeThemeSelector);
+ updateThemeSelector();
+ resizeThemeSelector();
+
+ function resizeThemeSelector() {
+ var ifr = $('.themeSelector iframe');
+ var ih = ifr.outerWidth() * 0.62;
+ ifr.css('height', ih);
+ $('.themeSelector .preview').css('max-height', (ih / 2) + 10);
+ }
+ });
+
+
+ function updateThemeSelector() {
+ var themeID = $(selector).val();
+ var iframe = $('.themeSelector .preview iframe');
+ $(iframe).attr('src', $(iframe).data('url').replace(/\$id/, themeID));
+ $(".themeSelector .actions a").each(function () {
+ $(this).attr('href', $(this).data('url').replace(/\$id/, themeID));
+ });
+ }
+
+ </script>
+ @endpush
+ @push('crud_fields_styles')
+ <style>
+ .themeSelector {
+ padding: 10px 18px 0;
+ width: 100%;
+ white-space: nowrap;
+ }
+
+ .themeSelector .preview {
+ width: 70%;
+ display: inline-block;
+ overflow: hidden;
+ }
+
+ .themeSelector .preview iframe {
+ width: 200%;
+ border: 0;
+ border-radius: 6px;
+ transform: scale(0.5);
+ transform-origin: 0 0;
+ }
+
+ .themeSelector .actions {
+ display: inline-block;
+ width: 30%;
+ vertical-align: top;
+ padding: 0 0 0 20px;
+ }
+
+ .themeSelector .actions a {
+ display: block;
+ width: 100%;
+ text-align: left;
+ margin-bottom: 10px;
+ }
+ </style>
+ @endpush
+@endif
+@include('cubist_back::fields.select2_from_array')
+<div class="themeSelector">
+ <div class="preview">
+ <iframe
+ data-url="{{\App\Models\FluidbookTheme::getThemePreviewURL('$id',['widget'=>'1','action'=>'fullscreen','theme'=>''],0)}}"
+ id="themePreviewIframe" src="" frameborder="0" allowfullscreen></iframe>
+ </div>
+ <div class="actions">
+ <a data-url="{{backpack_url('fluidbook-theme/$id/clone-edit')}}" class="btn btn-sm btn-secondary"><i
+ class="la la-clone"></i> {{__('Dupliquer et éditer')}}</a>
+ <a data-url="{{backpack_url('fluidbook-theme/$id/edit')}}" class="btn btn-sm btn-success"><i
+ class="la la-edit"></i> {{__('Éditer')}}
+ </a>
+ </div>
+</div>