From 11b2b23bb998eb6e23dce02c25771fb02cd971ac Mon Sep 17 00:00:00 2001 From: min'ryouta <67493493+liwoyadan@users.noreply.github.com> Date: Fri, 15 Nov 2024 08:07:04 -0800 Subject: [PATCH] fix: make file inputs more mobile-friendly (#1126) - Uses bs-custom-file-input and existing Bootstrap v4 classes to make file inputs that actually show on mobile devices --- public/js/bs-custom-file-input.min.js | 7 +++++++ resources/views/account/settings.blade.php | 8 +++----- .../create_edit_character_category.blade.php | 5 ++++- .../currencies/create_edit_currency.blade.php | 10 ++++++++-- .../admin/features/create_edit_feature.blade.php | 5 ++++- .../create_edit_feature_category.blade.php | 5 ++++- resources/views/admin/files/images.blade.php | 16 +++++++++++----- resources/views/admin/files/index.blade.php | 11 ++++++++--- .../views/admin/items/create_edit_item.blade.php | 5 ++++- .../items/create_edit_item_category.blade.php | 5 ++++- .../admin/masterlist/create_character.blade.php | 10 ++++++++-- .../admin/prompts/create_edit_prompt.blade.php | 5 ++++- .../create_edit_prompt_category.blade.php | 5 ++++- .../admin/rarities/create_edit_rarity.blade.php | 5 ++++- .../views/admin/shops/create_edit_shop.blade.php | 5 ++++- .../specieses/create_edit_species.blade.php | 5 ++++- .../specieses/create_edit_subtype.blade.php | 5 ++++- .../admin/_reupload_image_modal.blade.php | 12 +++++++++--- .../views/character/admin/upload_image.blade.php | 10 ++++++++-- resources/views/character/design/image.blade.php | 10 ++++++++-- .../galleries/create_edit_submission.blade.php | 5 ++++- resources/views/layouts/app.blade.php | 2 ++ 22 files changed, 120 insertions(+), 36 deletions(-) create mode 100644 public/js/bs-custom-file-input.min.js diff --git a/public/js/bs-custom-file-input.min.js b/public/js/bs-custom-file-input.min.js new file mode 100644 index 0000000000..0815f3768d --- /dev/null +++ b/public/js/bs-custom-file-input.min.js @@ -0,0 +1,7 @@ +/*! + * bsCustomFileInput v1.3.4 (https://github.com/Johann-S/bs-custom-file-input) + * Copyright 2018 - 2020 Johann-S + * Licensed under MIT (https://github.com/Johann-S/bs-custom-file-input/blob/master/LICENSE) + */ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).bsCustomFileInput=t()}(this,function(){"use strict";var s={CUSTOMFILE:'.custom-file input[type="file"]',CUSTOMFILELABEL:".custom-file-label",FORM:"form",INPUT:"input"},l=function(e){if(0 @endif {!! Form::open(['url' => 'account/avatar', 'files' => true]) !!} -
- {!! Form::label('avatar', 'Update Profile Image', ['class' => 'col-md-2 col-form-label']) !!} -
- {!! Form::file('avatar', ['class' => 'form-control']) !!} -
+
+ {!! Form::label('avatar', 'Update Profile Image', ['class' => 'custom-file-label']) !!} + {!! Form::file('avatar', ['class' => 'custom-file-input']) !!}
{!! Form::submit('Edit', ['class' => 'btn btn-primary']) !!} diff --git a/resources/views/admin/characters/create_edit_character_category.blade.php b/resources/views/admin/characters/create_edit_character_category.blade.php index 184c6eba9f..10f2958ccb 100644 --- a/resources/views/admin/characters/create_edit_character_category.blade.php +++ b/resources/views/admin/characters/create_edit_character_category.blade.php @@ -38,7 +38,10 @@
{!! Form::label('World Page Image (Optional)') !!} {!! add_help('This image is used only on the world information pages.') !!} -
{!! Form::file('image') !!}
+
+ {!! Form::label('image', 'Choose file...', ['class' => 'custom-file-label']) !!} + {!! Form::file('image', ['class' => 'custom-file-input']) !!} +
Recommended size: 200px x 200px
@if ($category->has_image)
diff --git a/resources/views/admin/currencies/create_edit_currency.blade.php b/resources/views/admin/currencies/create_edit_currency.blade.php index 26b88dec23..740b1ed872 100644 --- a/resources/views/admin/currencies/create_edit_currency.blade.php +++ b/resources/views/admin/currencies/create_edit_currency.blade.php @@ -35,7 +35,10 @@
{!! Form::label('Icon Image (Optional)') !!} {!! add_help('This will be used to denote the currency. If not provided, the abbreviation will be used.') !!} - {!! Form::file('icon') !!} +
+ {!! Form::label('icon', 'Choose icon file...', ['class' => 'custom-file-label']) !!} + {!! Form::file('icon', ['class' => 'custom-file-input']) !!} +
Recommended height: 16px
@if ($currency->has_icon)
@@ -48,7 +51,10 @@
{!! Form::label('World Page Image (Optional)') !!} {!! add_help('This image is used only on the world information pages.') !!} - {!! Form::file('image') !!} +
+ {!! Form::label('image', 'Choose file...', ['class' => 'custom-file-label']) !!} + {!! Form::file('image', ['class' => 'custom-file-input']) !!} +
Recommended size: 200px x 200px
@if ($currency->has_image)
diff --git a/resources/views/admin/features/create_edit_feature.blade.php b/resources/views/admin/features/create_edit_feature.blade.php index 5164eb8f96..847a803df3 100644 --- a/resources/views/admin/features/create_edit_feature.blade.php +++ b/resources/views/admin/features/create_edit_feature.blade.php @@ -34,7 +34,10 @@
{!! Form::label('World Page Image (Optional)') !!} {!! add_help('This image is used only on the world information pages.') !!} -
{!! Form::file('image') !!}
+
+ {!! Form::label('image', 'Choose file...', ['class' => 'custom-file-label']) !!} + {!! Form::file('image', ['class' => 'custom-file-input']) !!} +
Recommended size: 200px x 200px
@if ($feature->has_image)
diff --git a/resources/views/admin/features/create_edit_feature_category.blade.php b/resources/views/admin/features/create_edit_feature_category.blade.php index aa84a6fe23..8ffeb20b2b 100644 --- a/resources/views/admin/features/create_edit_feature_category.blade.php +++ b/resources/views/admin/features/create_edit_feature_category.blade.php @@ -28,7 +28,10 @@
{!! Form::label('World Page Image (Optional)') !!} {!! add_help('This image is used only on the world information pages.') !!} -
{!! Form::file('image') !!}
+
+ {!! Form::label('image', 'Choose file...', ['class' => 'custom-file-label']) !!} + {!! Form::file('image', ['class' => 'custom-file-input']) !!} +
Recommended size: 200px x 200px
@if ($category->has_image)
diff --git a/resources/views/admin/files/images.blade.php b/resources/views/admin/files/images.blade.php index d31734fc21..0f37a11b38 100644 --- a/resources/views/admin/files/images.blade.php +++ b/resources/views/admin/files/images.blade.php @@ -14,15 +14,18 @@ @foreach ($images as $key => $image)
-
+
Site image: {{ $image['name'] }}

{{ $image['name'] }} View Current

{{ $image['description'] }}

{!! Form::open(['url' => 'admin/images/upload', 'files' => true]) !!}
- {!! Form::file('file', ['class' => 'form-control mr-2']) !!} - {!! Form::submit('Upload', ['class' => 'btn btn-primary']) !!} +
+ {!! Form::label('file', 'Choose file...', ['class' => 'custom-file-label']) !!} + {!! Form::file('file', ['class' => 'custom-file-input']) !!} +
+ {!! Form::submit('Upload', ['class' => 'ml-1 btn btn-primary']) !!}
{!! Form::hidden('key', $key) !!} {!! Form::close() !!} @@ -42,8 +45,11 @@

CSS View Current

{!! Form::open(['url' => 'admin/images/upload/css', 'files' => true]) !!}
- {!! Form::file('file', ['class' => 'form-control mr-2']) !!} - {!! Form::submit('Upload', ['class' => 'btn btn-primary']) !!} +
+ {!! Form::label('file', 'Choose CSS...', ['class' => 'custom-file-label']) !!} + {!! Form::file('file', ['class' => 'custom-file-input']) !!} +
+ {!! Form::submit('Upload', ['class' => 'ml-1 btn btn-primary']) !!}
{!! Form::close() !!}
diff --git a/resources/views/admin/files/index.blade.php b/resources/views/admin/files/index.blade.php index 0c83b15966..1d8e277f18 100644 --- a/resources/views/admin/files/index.blade.php +++ b/resources/views/admin/files/index.blade.php @@ -178,7 +178,10 @@

Select a file to upload. (Maximum size {{ min(ini_get('upload_max_filesize'), ini_get('post_max_size')) }}B.)

- {!! Form::file('files[]', ['class' => 'form-control']) !!} +
+ {!! Form::label('files[]', 'No file selected.', ['class' => 'custom-file-label']) !!} + {!! Form::file('files[]', ['class' => 'custom-file-input']) !!} +
@@ -189,8 +192,9 @@ Add File
{!! Form::close() !!} -
- {!! Form::file('files[]', ['class' => 'form-control']) !!} +
+ {!! Form::label('files[]', 'No file selected.', ['class' => 'custom-file-label']) !!} + {!! Form::file('files[]', ['class' => 'custom-file-input']) !!}
@@ -213,6 +217,7 @@ function addFileRow() { $('#fileList').append($clone); $clone.removeClass('hide file-row'); $clone.addClass('d-flex'); + bsCustomFileInput.init(); } ///////// diff --git a/resources/views/admin/items/create_edit_item.blade.php b/resources/views/admin/items/create_edit_item.blade.php index 40ce3b8c6a..fe0b6fd531 100644 --- a/resources/views/admin/items/create_edit_item.blade.php +++ b/resources/views/admin/items/create_edit_item.blade.php @@ -24,7 +24,10 @@
{!! Form::label('World Page Image (Optional)') !!} {!! add_help('This image is used only on the world information pages.') !!} -
{!! Form::file('image') !!}
+
+ {!! Form::label('image', 'Choose file...', ['class' => 'custom-file-label']) !!} + {!! Form::file('image', ['class' => 'custom-file-input']) !!} +
Recommended size: 100px x 100px
@if ($item->has_image)
diff --git a/resources/views/admin/items/create_edit_item_category.blade.php b/resources/views/admin/items/create_edit_item_category.blade.php index 6e85d589d6..b3ca92923b 100644 --- a/resources/views/admin/items/create_edit_item_category.blade.php +++ b/resources/views/admin/items/create_edit_item_category.blade.php @@ -28,7 +28,10 @@
{!! Form::label('World Page Image (Optional)') !!} {!! add_help('This image is used only on the world information pages.') !!} -
{!! Form::file('image') !!}
+
+ {!! Form::label('image', 'Choose file...', ['class' => 'custom-file-label']) !!} + {!! Form::file('image', ['class' => 'custom-file-input']) !!} +
Recommended size: 200px x 200px
@if ($category->has_image)
diff --git a/resources/views/admin/masterlist/create_character.blade.php b/resources/views/admin/masterlist/create_character.blade.php index f9777f66c8..956b01d60a 100644 --- a/resources/views/admin/masterlist/create_character.blade.php +++ b/resources/views/admin/masterlist/create_character.blade.php @@ -134,7 +134,10 @@ @else {!! add_help('This is the full masterlist image. Note that the image is not protected in any way, so take precautions to avoid art/design theft.') !!} @endif -
{!! Form::file('image', ['id' => 'mainImage']) !!}
+
+ {!! Form::label('image', 'Choose file...', ['class' => 'custom-file-label']) !!} + {!! Form::file('image', ['class' => 'custom-file-input', 'id' => 'mainImage']) !!} +
@if (config('lorekeeper.settings.masterlist_image_automation') === 1)
@@ -169,7 +172,10 @@
{!! Form::label('Thumbnail Image') !!} {!! add_help('This image is shown on the masterlist page.') !!} -
{!! Form::file('thumbnail') !!}
+
+ {!! Form::label('thumbnail', 'Choose thumbnail...', ['class' => 'custom-file-label']) !!} + {!! Form::file('thumbnail', ['class' => 'custom-file-input']) !!} +
Recommended size: {{ config('lorekeeper.settings.masterlist_thumbnails.width') }}px x {{ config('lorekeeper.settings.masterlist_thumbnails.height') }}px
diff --git a/resources/views/admin/prompts/create_edit_prompt.blade.php b/resources/views/admin/prompts/create_edit_prompt.blade.php index c02c43672f..92edce4be2 100644 --- a/resources/views/admin/prompts/create_edit_prompt.blade.php +++ b/resources/views/admin/prompts/create_edit_prompt.blade.php @@ -34,7 +34,10 @@
{!! Form::label('World Page Image (Optional)') !!} {!! add_help('This image is used only on the world information pages.') !!} -
{!! Form::file('image') !!}
+
+ {!! Form::label('image', 'Choose file...', ['class' => 'custom-file-label']) !!} + {!! Form::file('image', ['class' => 'custom-file-input']) !!} +
Recommended size: 100px x 100px
@if ($prompt->has_image)
diff --git a/resources/views/admin/prompts/create_edit_prompt_category.blade.php b/resources/views/admin/prompts/create_edit_prompt_category.blade.php index f13c417bfb..6db2e538de 100644 --- a/resources/views/admin/prompts/create_edit_prompt_category.blade.php +++ b/resources/views/admin/prompts/create_edit_prompt_category.blade.php @@ -28,7 +28,10 @@
{!! Form::label('World Page Image (Optional)') !!} {!! add_help('This image is used only on the world information pages.') !!} -
{!! Form::file('image') !!}
+
+ {!! Form::label('image', 'Choose file...', ['class' => 'custom-file-label']) !!} + {!! Form::file('image', ['class' => 'custom-file-input']) !!} +
Recommended size: 200px x 200px
@if ($category->has_image)
diff --git a/resources/views/admin/rarities/create_edit_rarity.blade.php b/resources/views/admin/rarities/create_edit_rarity.blade.php index c7bde4b474..f312cd9a3d 100644 --- a/resources/views/admin/rarities/create_edit_rarity.blade.php +++ b/resources/views/admin/rarities/create_edit_rarity.blade.php @@ -34,7 +34,10 @@
{!! Form::label('World Page Image (Optional)') !!} {!! add_help('This image is used only on the world information pages.') !!} -
{!! Form::file('image') !!}
+
+ {!! Form::label('image', 'Choose file...', ['class' => 'custom-file-label']) !!} + {!! Form::file('image', ['class' => 'custom-file-input']) !!} +
Recommended size: 200px x 200px
@if ($rarity->has_image)
diff --git a/resources/views/admin/shops/create_edit_shop.blade.php b/resources/views/admin/shops/create_edit_shop.blade.php index 5bcd734eaa..28cac4e3ed 100644 --- a/resources/views/admin/shops/create_edit_shop.blade.php +++ b/resources/views/admin/shops/create_edit_shop.blade.php @@ -25,7 +25,10 @@
{!! Form::label('Shop Image (Optional)') !!} {!! add_help('This image is used on the shop index and on the shop page as a header.') !!} -
{!! Form::file('image') !!}
+
+ {!! Form::label('image', 'Choose file...', ['class' => 'custom-file-label']) !!} + {!! Form::file('image', ['class' => 'custom-file-input']) !!} +
Recommended size: None (Choose a standard size for all shop images)
@if ($shop->has_image)
diff --git a/resources/views/admin/specieses/create_edit_species.blade.php b/resources/views/admin/specieses/create_edit_species.blade.php index a6af130942..de027040ba 100644 --- a/resources/views/admin/specieses/create_edit_species.blade.php +++ b/resources/views/admin/specieses/create_edit_species.blade.php @@ -29,7 +29,10 @@
{!! Form::label('World Page Image (Optional)') !!} {!! add_help('This image is used only on the world information pages.') !!} -
{!! Form::file('image') !!}
+
+ {!! Form::label('image', 'Choose file...', ['class' => 'custom-file-label']) !!} + {!! Form::file('image', ['class' => 'custom-file-input']) !!} +
Recommended size: 200px x 200px
@if ($species->has_image)
diff --git a/resources/views/admin/specieses/create_edit_subtype.blade.php b/resources/views/admin/specieses/create_edit_subtype.blade.php index fabbe3308d..543a710629 100644 --- a/resources/views/admin/specieses/create_edit_subtype.blade.php +++ b/resources/views/admin/specieses/create_edit_subtype.blade.php @@ -29,7 +29,10 @@
{!! Form::label('World Page Image (Optional)') !!} {!! add_help('This image is used only on the world information pages.') !!} -
{!! Form::file('image') !!}
+
+ {!! Form::label('image', 'Choose file...', ['class' => 'custom-file-label']) !!} + {!! Form::file('image', ['class' => 'custom-file-input']) !!} +
Recommended size: 200px x 200px
@if ($subtype->has_image)
diff --git a/resources/views/character/admin/_reupload_image_modal.blade.php b/resources/views/character/admin/_reupload_image_modal.blade.php index 71d0508538..0d4f49aa91 100644 --- a/resources/views/character/admin/_reupload_image_modal.blade.php +++ b/resources/views/character/admin/_reupload_image_modal.blade.php @@ -1,7 +1,10 @@ {!! Form::open(['url' => 'admin/character/image/' . $image->id . '/reupload', 'files' => true]) !!}
{!! Form::label('Character Image') !!} {!! add_help('This is the full masterlist image. Note that the image is not protected in any way, so take precautions to avoid art/design theft.') !!} -
{!! Form::file('image', ['id' => 'mainImage']) !!}
+
+ {!! Form::label('image', 'Choose file...', ['class' => 'custom-file-label']) !!} + {!! Form::file('image', ['class' => 'custom-file-input', 'id' => 'mainImage']) !!} +
@if (config('lorekeeper.settings.masterlist_image_automation') === 1)
@@ -36,7 +39,10 @@
{!! Form::label('Thumbnail Image') !!} {!! add_help('This image is shown on the masterlist page.') !!} -
{!! Form::file('thumbnail') !!}
+
+ {!! Form::label('thumbnail', 'Choose thumbnail...', ['class' => 'custom-file-label']) !!} + {!! Form::file('thumbnail', ['class' => 'custom-file-input']) !!} +
Recommended size: {{ config('lorekeeper.settings.masterlist_thumbnails.width') }}px x {{ config('lorekeeper.settings.masterlist_thumbnails.height') }}px
@@ -49,7 +55,7 @@ + @@ -168,6 +169,7 @@ spoiler_caption: 'Toggle Spoiler', target_list: false }); + bsCustomFileInput.init(); var $mobileMenuButton = $('#mobileMenuButton'); var $sidebar = $('#sidebar'); $('#mobileMenuButton').on('click', function(e) {