Merge remote-tracking branch 'origin/develop' into wip/laravel-6

This commit is contained in:
Ben Thomson 2020-02-03 15:56:33 +08:00
commit ef86ddc482
8 changed files with 72 additions and 13 deletions

View File

@ -43,6 +43,15 @@ class Repeater extends FormWidgetBase
*/
public $maxItems;
/**
* @var string The style of the repeater. Can be one of three values:
* - "default": Shows all repeater items expanded on load.
* - "collapsed": Shows all repeater items collapsed on load.
* - "accordion": Shows only the first repeater item expanded on load. When another item is clicked, all other open
* items are collapsed.
*/
public $style;
//
// Object properties
//
@ -101,6 +110,7 @@ class Repeater extends FormWidgetBase
$this->fillFromConfig([
'form',
'style',
'prompt',
'sortable',
'titleFrom',
@ -156,6 +166,7 @@ class Repeater extends FormWidgetBase
$this->vars['titleFrom'] = $this->titleFrom;
$this->vars['minItems'] = $this->minItems;
$this->vars['maxItems'] = $this->maxItems;
$this->vars['style'] = $this->style;
$this->vars['useGroups'] = $this->useGroups;
$this->vars['groupDefinitions'] = $this->groupDefinitions;

View File

@ -35,7 +35,8 @@
sortableContainer: 'ul.field-repeater-items',
titleFrom: null,
minItems: null,
maxItems: null
maxItems: null,
style: 'default',
}
Repeater.prototype.init = function() {
@ -49,6 +50,7 @@
this.$el.one('dispose-control', this.proxy(this.dispose))
this.togglePrompt()
this.applyStyle()
}
Repeater.prototype.dispose = function() {
@ -157,6 +159,13 @@
ev.preventDefault()
if (this.getStyle() === 'accordion') {
if (isCollapsed) {
this.expand($item)
}
return
}
if (ev.ctrlKey || ev.metaKey) {
isCollapsed ? this.expandAll() : this.collapseAll()
}
@ -167,7 +176,7 @@
Repeater.prototype.collapseAll = function() {
var self = this,
items = $('.field-repeater-item', this.$el)
items = $(this.$el).children('.field-repeater-items').children('.field-repeater-item')
$.each(items, function(key, item){
self.collapse($(item))
@ -176,7 +185,7 @@
Repeater.prototype.expandAll = function() {
var self = this,
items = $('.field-repeater-item', this.$el)
items = $(this.$el).children('.field-repeater-items').children('.field-repeater-item')
$.each(items, function(key, item){
self.expand($(item))
@ -189,6 +198,9 @@
}
Repeater.prototype.expand = function($item) {
if (this.getStyle() === 'accordion') {
this.collapseAll()
}
$item.removeClass('collapsed')
}
@ -229,6 +241,36 @@
return defaultText
}
Repeater.prototype.getStyle = function() {
var style = 'default';
// Validate style
if (this.options.style && ['collapsed', 'accordion'].indexOf(this.options.style) !== -1) {
style = this.options.style
}
return style;
}
Repeater.prototype.applyStyle = function() {
var style = this.getStyle(),
self = this,
items = $(this.$el).children('.field-repeater-items').children('.field-repeater-item')
$.each(items, function(key, item) {
switch (style) {
case 'collapsed':
self.collapse($(item))
break
case 'accordion':
if (key !== 0) {
self.collapse($(item))
}
break
}
})
}
// FIELD REPEATER PLUGIN DEFINITION
// ============================

View File

@ -3,6 +3,7 @@
<?= $titleFrom ? 'data-title-from="'.$titleFrom.'"' : '' ?>
<?= $minItems ? 'data-min-items="'.$minItems.'"' : '' ?>
<?= $maxItems ? 'data-max-items="'.$maxItems.'"' : '' ?>
<?= $style ? 'data-style="'.$style.'"' : '' ?>
data-sortable-container="#<?= $this->getId('items') ?>"
data-sortable-handle=".<?= $this->getId('items') ?>-handle">

View File

@ -2,7 +2,8 @@
return [
'auth' => [
'title' => 'Administrácia'
'title' => 'Administrácia',
'invalid_login' => 'Údaje, ktoré ste zadali sú nesprávne. Prosím skontrolujte údaje a skúste to znova.'
],
'field' => [
'invalid_type' => 'Bol použitý zlý typ :type.',
@ -15,6 +16,11 @@ return [
],
'page' => [
'untitled' => 'Bez názvu',
'404' => [
'label' => 'Stránka nenájdená',
'help' => "Hľadali sme a hľadali, ale požadovanú adresu URL jednoducho nebolo možné nájsť. Možno ste hľadali niečo iné?",
'back_link' => 'Späť na predchodzú stránku',
],
'access_denied' => [
'label' => 'Prístup odmietnutý',
'help' => "Nemáte potrebné oprávnenia na zobrazenie tejto stránky.",

View File

@ -62,8 +62,12 @@
}
}
$(this).not('.' + options.excludeClass).find('td').not('.' + options.excludeClass).click(function(e) {
$(this).not('.' + options.excludeClass).find('td').not('.' + options.excludeClass).click(function (e) {
handleClick(e)
}).mousedown(function (e) {
if (e.which == 2) {
window.open(href)
}
})
$(this).not('.' + options.excludeClass).on('keypress', function(e) {

View File

@ -142,13 +142,10 @@
}
input:disabled + label:before {
background-color: #999 !important;
border: 1px solid @color-checkbox-border !important;
}
input:disabled:checked + label:before {
background-color: #999;
}
&:focus {
outline: none;
label:before {

View File

@ -4074,7 +4074,7 @@ else if(request){link.request()}
else if(popup){link.popup()}
else if(e.ctrlKey||e.metaKey){window.open(href)}
else{window.location=href}}
$(this).not('.'+options.excludeClass).find('td').not('.'+options.excludeClass).click(function(e){handleClick(e)})
$(this).not('.'+options.excludeClass).find('td').not('.'+options.excludeClass).click(function(e){handleClick(e)}).mousedown(function(e){if(e.which==2){window.open(href)}})
$(this).not('.'+options.excludeClass).on('keypress',function(e){if(e.key==='(Space character)'||e.key==='Spacebar'||e.key===' '){handleClick(e)
return false}})
$(this).addClass(options.linkedClass)

View File

@ -4119,9 +4119,7 @@ html.cssanimations .cursor-loading-indicator.hide {display:none}
.custom-checkbox input[type=checkbox]:indeterminate + label:before,
.custom-radio input[type=checkbox]:indeterminate + label:before {font-family:FontAwesome;font-weight:normal;font-style:normal;text-decoration:inherit;-webkit-font-smoothing:antialiased;content:"\f068"}
.custom-checkbox input:disabled + label:before,
.custom-radio input:disabled + label:before {border:1px solid #d1d6d9 !important}
.custom-checkbox input:disabled:checked + label:before,
.custom-radio input:disabled:checked + label:before {background-color:#999}
.custom-radio input:disabled + label:before {background-color:#999 !important;border:1px solid #d1d6d9 !important}
.custom-checkbox:focus,
.custom-radio:focus {outline:none}
.custom-checkbox:focus label:before,