Initial commit

This commit is contained in:
isUnknown 2026-02-12 15:22:46 +01:00
commit 65e0da7e11
1397 changed files with 596542 additions and 0 deletions

View file

@ -0,0 +1,27 @@
# Kirby Quickselect v1.3 <a href="https://www.paypal.me/medienbaecker"><img width="99" src="http://www.medienbaecker.com/beer.png" alt="Buy me a beer" align="right"></a>
This field is based on the core select field and adds a filter and placeholder functionality. It uses the [select2](https://github.com/select2/select2) jQuery plugin.
When displaying the images of a page with `options: images` it will display thumbs automatically.
## Installation
Simply put the `quickselect` folder into your `site/plugins` folder.
## Example
![Preview](https://user-images.githubusercontent.com/7975568/27504121-082d8ca4-5885-11e7-8983-9159593cdbb4.gif)
````
featured:
label: Image
type: quickselect
options: images
placeholder: Choose an image...
````
Just like you do with the regular `select` field, you can specify what elements should be listed. `pages`, `children`, `files`, `images`, [...](https://getkirby.com/docs/cheatsheet/panel-fields/select). Even a more complex `query` or options from another field.
Anything that's printed in the list can be searched for. So if you set the `text` of a `query` to `{{title}} ({{uri}})`, you can find pages by their ancestors, too.
Compared to the core `select` field, you can also define a `placeholder` that can make things clearer for the editor.

View file

@ -0,0 +1,128 @@
.input-with-quickselect {
overflow: visible;
padding: 0 !important;
font-size: 1em;
line-height: 1.5em;
font-weight: 400;
border: none;
background: transparent;
display: block;
-ms-appearance: none;
appearance: none;
border-radius: 0;
}
.select2-search__field {
border-radius: 0;
-webkit-appearance: none;
}
body.ltr .input-with-quickselect .selectbox-wrapper {
margin-right: auto;
}
.input-with-quickselect .x {
position: absolute;
width: 40px;
height: 40px;
color: #777;
z-index: 5;
right: 50px;
top: 2px;
line-height: 40px;
font-size: 1.1em;
background: linear-gradient(to left, rgba(255,255,255,1) 75%,rgba(255,255,255,0) 100%);
}
.input-with-quickselect .x:hover {
color: black;
}
.input-with-quickselect .selectbox-wrapper {
height: auto;
}
.select2-container--default .select2-search--dropdown .select2-search__field {
padding: .25em .5em;
font-size: 1em;
line-height: 1.5em;
font-weight: 400;
border: 2px solid #ddd;
background: #fff;
display: block;
-ms-appearance: none;
appearance: none;
border-radius: 0;
}
.select2-container--default .select2-results__option {
padding: 0;
}
.select2-container--default .select2-results__message {
padding: 10px 8px;
}
.select2-container--default .select2-results__option span {
padding: 10px 8px;
display: block;
}
.select2-container--default .select2-results__option span.with-image {
padding: 0px;
}
.select2-container--default .select2-results__option img {
vertical-align: middle;
width: 40px;
margin-right: 5px;
display: inline-block;
filter: grayscale(100%);
}
.select2-container--default .select2-results__option[aria-selected=true] img, .select2-container--default .select2-results__option--highlighted[aria-selected] img {
filter: grayscale(0);
}
.select2-container--images .select2-selection--single .select2-selection__rendered {
padding-left: 0;
}
.select2-container--images .select2-selection--single .select2-selection__placeholder {
padding-left: 8px;
}
.select2-container--images .select2-selection--single .select2-selection__rendered img {
width: 40px;
vertical-align: middle;
margin-right: 8px;
display: block;
float: left;
}
.select2-container--default .select2-results__option:empty {
display: none;
}
.select2-container--default .select2-results__option[aria-selected=true] {
background-color: #ddd;
color: inherit;
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
background-color: #8dae28;
color: white;
}
.select2-container--default .select2-search--dropdown .select2-search__field:focus {
border: 2px solid #8dae28;
outline: none;
}
.select2-results__option {
padding: .5em;
}
.select2-container--default .select2-results>.select2-results__options {
max-height: 160px;
}
.select2-container--default .select2-selection--single {
border: 2px solid #ddd;
border-radius: 0;
height: 2.75em;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
line-height: 40px;
white-space: normal;
vertical-align: middle;
height: 40px;
}
.select2-dropdown {
border: 2px solid #ddd;
border-radius: 0;
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,85 @@
(function($) {
$.fn.quickselect = function() {
return this.each(function() {
var field = $(this);
// avoid multiple inits
if(field.data('quickselect')) {
return true;
} else {
field.data('quickselect', true);
}
if (field.find("select").attr("required") == "required") {
var clear = false;
}
else {
var clear = true;
}
var noresults = field.find("select").attr("data-noresults");
function formatState (opt) {
if (!opt.id) {
return opt.text;
}
var optimage = $(opt.element).data('image');
if(!field.find("select").hasClass("images") || !optimage){
var $opt = $(
'<span>' + opt.text + '</span>'
);
}
else {
var $opt = $(
'<span class="with-image"><img src="' + optimage + '"/> ' + opt.text + '</span>'
);
}
return $opt;
}
var $select2 = field.find("select").select2({
language: {
noResults: function (params) {
return noresults;
},
},
templateResult: formatState,
templateSelection: formatState,
});
if (field.find('select.quickselect').hasClass("images")) {
$select2.data('select2').$container.addClass("select2-container--images");
}
if (field.find(".select2-results__options li").first().text() == "") {
field.find(".select2-results__options li").first().hide();
}
if (clear == false || field.find("select").val() == "") {
field.find("i.x").hide();
}
field.find('select.quickselect').on('select2:select', function (evt) {
if (clear == true) {
field.find("i.x").show();
}
});
field.find("i.x").on("click", function() {
field.find("select").val('').change();
field.find("i.x").hide();
});
});
};
})(jQuery);

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,111 @@
<?php
class QuickselectField extends SelectField {
static public $fieldname = 'quickselect';
static public $assets = array(
'js' => array(
'select2.js',
'select.js'
),
'css' => array(
'select2.css',
'select.css'
)
);
public function input() {
$select = new Brick('select');
$select->addClass('selectbox quickselect');
$select->attr(array(
'name' => $this->name(),
'id' => $this->id(),
'required' => $this->required(),
'autocomplete' => $this->autocomplete(),
'autofocus' => $this->autofocus(),
'readonly' => $this->readonly(),
'disabled' => $this->disabled(),
'data-placeholder' => $this->placeholder(),
));
$default = $this->default();
if(!$this->required()) {
$select->append($this->option('', '', $this->value() == ''));
}
if($this->readonly()) {
$select->attr('tabindex', '-1');
}
foreach($this->options() as $value => $text) {
if(strpos($value, ".jpg") !== false OR
strpos($value, ".jpeg") !== false OR
strpos($value, ".gif") !== false OR
strpos($value, ".png") !== false) {
if (!strpos(implode(",", $select->attr("class")), "images") !== false) {
$select->addClass("images");
}
if($image = $this->page()->image($value)) {
$image = $image->crop(75, 75)->url();
$select->append(
$this->option($value, $text, $this->value() == $value)->attr("data-image", $image)
);
}
else {
$select->append(
$this->option($value, $text, $this->value() == $value)
);
}
}
else {
$select->append(
$this->option($value, $text, $this->value() == $value)
);
}
}
$noresults = $this->i18n([
'en' => "Nothing found",
'de' => "Nichts gefunden"
]);
$select->attr("data-noresults", $noresults);
$select->attr("style", "width: 100%");
$inner = new Brick('div');
$inner->addClass('selectbox-wrapper quickselect-wrapper');
$inner->append($select);
$x = new Brick('i');
$x->addClass('icon fa fa-times-circle x');
$inner->append($x);
$wrapper = new Brick('div');
$wrapper->addClass('input input-with-selectbox input-with-quickselect');
$wrapper->append($inner);
if($this->readonly()) {
$wrapper->addClass('input-is-readonly');
} else {
$wrapper->attr('data-focus', 'true');
}
return $wrapper;
}
public function element() {
$element = parent::element();
$element->data('field', 'quickselect');
return $element;
}
public function val() {
if($this->value() == "" && $this->default() !== "") {
$value = $this->default();
} elseif($this->value() == "" && $this->default() == "") {
$value = "";
} else {
$value = $this->value();
}
return $value;
}
}

View file

@ -0,0 +1,8 @@
{
"name": "quickselect",
"description": "Quickselect Field",
"author": "Thomas Günther <mail@medienbaecker.com>",
"version": "1.3",
"type": "kirby-plugin",
"license": "MIT"
}

View file

@ -0,0 +1,2 @@
<?php
$kirby->set('field', 'quickselect', __DIR__ . '/fields/quickselect');