mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-14 09:16:05 +01:00
manual merge again
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -28,7 +28,6 @@
|
|||||||
CheckboxesField.prototype.disabled = function(state) {
|
CheckboxesField.prototype.disabled = function(state) {
|
||||||
if (typeof state !== 'undefined') {
|
if (typeof state !== 'undefined') {
|
||||||
this._disabled = state ? true : false;
|
this._disabled = state ? true : false;
|
||||||
this.el.css('opacity', state ? 0.6 : 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._disabled;
|
return this._disabled;
|
||||||
|
|||||||
@@ -57,28 +57,21 @@
|
|||||||
|
|
||||||
function linkToggle (element, toggleable) {
|
function linkToggle (element, toggleable) {
|
||||||
element.onChange(function (value) {
|
element.onChange(function (value) {
|
||||||
toggleable.find('input').prop('checked', true);
|
toggleable.find('input').prop('checked', false).filter('[value=1]').prop('checked', true);
|
||||||
toggleable.siblings('label').css('opacity', 1);
|
|
||||||
element.disabled(false);
|
element.disabled(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
toggleable.find('input').on('change', function () {
|
toggleable.find('input').on('change', function () {
|
||||||
var el = $(this),
|
var el = $(this);
|
||||||
on = el.is(':checked');
|
if (el.is(':checked')) {
|
||||||
|
var on = el.val() == '1' ? true : false;
|
||||||
|
|
||||||
toggleable.siblings('label').css('opacity', on ? 1 : 0.7);
|
element.disabled(!on);
|
||||||
element.disabled(!on);
|
if (!on) {
|
||||||
if (!on) {
|
element.reset();
|
||||||
element.reset();
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var on = toggleable.is(':checked');
|
|
||||||
toggleable.siblings('label').css('opacity', on ? 1 : 0.7);
|
|
||||||
element.disabled(!on);
|
|
||||||
if (!on) {
|
|
||||||
element.reset();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var Form = function (el, options) {
|
var Form = function (el, options) {
|
||||||
@@ -117,14 +110,10 @@
|
|||||||
|
|
||||||
Form.factories = {};
|
Form.factories = {};
|
||||||
|
|
||||||
Form.findElements = function(el, selector, notIn, notSelf) {
|
Form.findElements = function(el, selector) {
|
||||||
el = $(el);
|
el = $(el);
|
||||||
notIn = notIn || selector,
|
|
||||||
notSelf = notSelf ? true : false;
|
|
||||||
|
|
||||||
return el.find(selector).filter(function() {
|
return el.find(selector).filter(function() {
|
||||||
var parent = notSelf ? $(this) : $(this).parent();
|
var nearestMatch = $(this).parent().closest(selector);
|
||||||
nearestMatch = parent.closest(notIn);
|
|
||||||
return nearestMatch.length == 0 || el.find(nearestMatch).length == 0;
|
return nearestMatch.length == 0 || el.find(nearestMatch).length == 0;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -196,20 +185,7 @@
|
|||||||
Form.prototype.submit = function(ajax) {
|
Form.prototype.submit = function(ajax) {
|
||||||
var action = this.form.attr('action') || document.location,
|
var action = this.form.attr('action') || document.location,
|
||||||
method = this.form.attr('method') || 'POST',
|
method = this.form.attr('method') || 'POST',
|
||||||
values = {};
|
values = this.getValues();
|
||||||
|
|
||||||
// Get form values that are not handled by JS framework
|
|
||||||
Form.findElements(this.form, 'input, textarea', '[data-grav-field]', true).each(function(input) {
|
|
||||||
var input = $(this),
|
|
||||||
name = input.attr('name'),
|
|
||||||
value = input.val();
|
|
||||||
|
|
||||||
if (name) {
|
|
||||||
values[name] = value;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$.extend(values, this.getValues());
|
|
||||||
|
|
||||||
if (!values.task) {
|
if (!values.task) {
|
||||||
values.task = 'save';
|
values.task = 'save';
|
||||||
|
|||||||
@@ -4,21 +4,9 @@
|
|||||||
{% block field %}
|
{% block field %}
|
||||||
<div class="form-field grid">
|
<div class="form-field grid">
|
||||||
|
|
||||||
|
|
||||||
{% block contents %}
|
{% block contents %}
|
||||||
<div class="form-label block size-1-3">
|
<div class="form-label block size-1-3">
|
||||||
{% if field.toggleable %}
|
<label>
|
||||||
<span class="checkboxes toggleable" data-grav-field="toggleable" data-grav-field-name="{{ field.name|fieldName }}">
|
|
||||||
<input type="checkbox"
|
|
||||||
id="toggleable_{{ field.name }}"
|
|
||||||
value="1"
|
|
||||||
name="toggleable_{{ (scope ~ field.name)|fieldName }}"
|
|
||||||
{% if originalValue is not null %}checked="checked"{% endif %}
|
|
||||||
>
|
|
||||||
<label for="toggleable_{{ field.name }}"></label>
|
|
||||||
</span>
|
|
||||||
{% endif %}
|
|
||||||
<label class="{{ field.toggleable ? 'toggleable' : '' }}">
|
|
||||||
{% block label %}
|
{% block label %}
|
||||||
{% if field.help %}
|
{% if field.help %}
|
||||||
<span class="tooltip" data-asTooltip-position="w" title="{{ field.help|e }}">{{ field.label }}</span>
|
<span class="tooltip" data-asTooltip-position="w" title="{{ field.help|e }}">{{ field.label }}</span>
|
||||||
@@ -55,6 +43,28 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
|
{% if field.toggleable %}
|
||||||
|
<div class="block size-1-6">
|
||||||
|
<div class="switch-toggle switch-grav switch-2" data-grav-field="toggleable" data-grav-field-name="{{ field.name|fieldName }}">
|
||||||
|
<input
|
||||||
|
type="radio" value="1"
|
||||||
|
id="toggleable_{{ field.name }}_1"
|
||||||
|
class="highlight"
|
||||||
|
name="toggleable_{{ (scope ~ field.name)|fieldName }}"
|
||||||
|
{% if originalValue is not null %}checked="checked"{% endif %}
|
||||||
|
/>
|
||||||
|
<label for="toggleable_{{ field.name }}_1">On</label>
|
||||||
|
<input
|
||||||
|
type="radio" value="0"
|
||||||
|
id="toggleable_{{ field.name }}_0"
|
||||||
|
name="toggleable_{{ (scope ~ field.name)|fieldName }}"
|
||||||
|
{% if originalValue is null %}checked="checked"{% endif %}
|
||||||
|
/>
|
||||||
|
<label for="toggleable_{{ field.name }}_0">Off</label>
|
||||||
|
<a></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -1,32 +1,13 @@
|
|||||||
{% set value = (value is null ? field.default : value) %}
|
{% extends "forms/field.html.twig" %}
|
||||||
|
|
||||||
<div class="form-field grid pure-g">
|
{% block input_attributes %}
|
||||||
<div class="form-label block size-1-3 pure-u-1-3">
|
type="text"
|
||||||
<label>
|
{% if field.placeholder %}placeholder="{{ field.placeholder }}"{% endif %}
|
||||||
{% if field.help %}
|
{% if field.autofocus in ['on', 'true', 1] %}autofocus="autofocus"{% endif %}
|
||||||
<span class="tooltip" data-asTooltip-position="w" title="{{ field.help|e }}">{{ field.label }}</span>
|
{% if field.novalidate in ['on', 'true', 1] %}novalidate="novalidate"{% endif %}
|
||||||
{% else %}
|
{% if field.readonly in ['on', 'true', 1] %}readonly="readonly"{% endif %}
|
||||||
{{ field.label }}
|
{% if field.autocomplete in ['on', 'off'] %}autocomplete="{{ field.autocomplete }}"{% endif %}
|
||||||
{% endif %}
|
{% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
|
||||||
{{ field.validate.required in ['on', 'true', 1] ? '<span class="required">*</span>' }}
|
{% if field.validate.pattern %}pattern="{{ field.validate.pattern }}"{% endif %}
|
||||||
</label>
|
{{ parent() }}
|
||||||
</div>
|
{% endblock %}
|
||||||
<div class="form-data block size-2-3 pure-u-2-3">
|
|
||||||
<div class="form-input-wrapper {{ field.size }}">
|
|
||||||
<input type="text"
|
|
||||||
class="{{ field.classes }}"
|
|
||||||
name="{{ (scope ~ field.name)|fieldName }}"
|
|
||||||
value="{{ value|join(', ') }}"
|
|
||||||
{% if field.placeholder %}placeholder="{{ field.placeholder }}"{% endif %}
|
|
||||||
{% if field.title %}title="{{ field.title }}"{% endif %}
|
|
||||||
{% if field.autofocus in ['on', 'true', 1] %}autofocus="autofocus"{% endif %}
|
|
||||||
{% if field.novalidate in ['on', 'true', 1] %}novalidate="novalidate"{% endif %}
|
|
||||||
{% if field.readonly in ['on', 'true', 1] %}readonly="readonly"{% endif %}
|
|
||||||
{% if field.autocomplete in ['on', 'off'] %}autocomplete="{{ field.autocomplete }}"{% endif %}
|
|
||||||
{% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
|
|
||||||
{% if field.validate.pattern %}pattern="{{ field.validate.pattern }}"{% endif %}
|
|
||||||
{% if field.validate.message %}title="{{ field.validate.message }}"{% endif %}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|||||||
@@ -20,34 +20,4 @@
|
|||||||
{% include 'forms/fields/hidden/hidden.html.twig' %}
|
{% include 'forms/fields/hidden/hidden.html.twig' %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{#
|
|
||||||
<div class="button-bar">
|
|
||||||
<button class="button" name="task" value="save">Save</button>
|
|
||||||
{% if context.exists %}
|
|
||||||
<button class="button" name="task" value="copy">Copy</button>
|
|
||||||
{% endif %}
|
|
||||||
{% if context.exists or context.isDir %}
|
|
||||||
<button class="button confirm-delete" name="task" value="delete" formnovalidate="formnovalidate">Delete</button>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
$('.confirm-delete').click(function(){
|
|
||||||
var that = this;
|
|
||||||
vex.dialog.confirm({
|
|
||||||
message: 'Are you sure you want to delete the page and all content under it?',
|
|
||||||
callback: function(success) {
|
|
||||||
if (success) {
|
|
||||||
var form = $(that).closest('form');
|
|
||||||
|
|
||||||
$('<input />').attr('type', 'hidden').attr('name', 'task').attr('value', $(that).val()).appendTo(form);
|
|
||||||
|
|
||||||
form.submit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
#}
|
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user