manual merge again

This commit is contained in:
Gert
2015-06-01 21:22:56 +02:00
committed by Andy Miller
parent d8e0ee979a
commit f3ed44db0c
6 changed files with 47 additions and 111 deletions

File diff suppressed because one or more lines are too long

View File

@@ -28,7 +28,6 @@
CheckboxesField.prototype.disabled = function(state) {
if (typeof state !== 'undefined') {
this._disabled = state ? true : false;
this.el.css('opacity', state ? 0.6 : 1);
}
return this._disabled;

View File

@@ -57,28 +57,21 @@
function linkToggle (element, toggleable) {
element.onChange(function (value) {
toggleable.find('input').prop('checked', true);
toggleable.siblings('label').css('opacity', 1);
toggleable.find('input').prop('checked', false).filter('[value=1]').prop('checked', true);
element.disabled(false);
});
toggleable.find('input').on('change', function () {
var el = $(this),
on = el.is(':checked');
var el = $(this);
if (el.is(':checked')) {
var on = el.val() == '1' ? true : false;
toggleable.siblings('label').css('opacity', on ? 1 : 0.7);
element.disabled(!on);
if (!on) {
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) {
@@ -117,14 +110,10 @@
Form.factories = {};
Form.findElements = function(el, selector, notIn, notSelf) {
Form.findElements = function(el, selector) {
el = $(el);
notIn = notIn || selector,
notSelf = notSelf ? true : false;
return el.find(selector).filter(function() {
var parent = notSelf ? $(this) : $(this).parent();
nearestMatch = parent.closest(notIn);
var nearestMatch = $(this).parent().closest(selector);
return nearestMatch.length == 0 || el.find(nearestMatch).length == 0;
});
};
@@ -196,20 +185,7 @@
Form.prototype.submit = function(ajax) {
var action = this.form.attr('action') || document.location,
method = this.form.attr('method') || 'POST',
values = {};
// 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());
values = this.getValues();
if (!values.task) {
values.task = 'save';

View File

@@ -4,21 +4,9 @@
{% block field %}
<div class="form-field grid">
{% block contents %}
<div class="form-label block size-1-3">
{% if field.toggleable %}
<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' : '' }}">
<label>
{% block label %}
{% if field.help %}
<span class="tooltip" data-asTooltip-position="w" title="{{ field.help|e }}">{{ field.label }}</span>
@@ -55,6 +43,28 @@
{% endblock %}
{% endblock %}
</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 %}
</div>
{% endblock %}

View File

@@ -1,32 +1,13 @@
{% set value = (value is null ? field.default : value) %}
{% extends "forms/field.html.twig" %}
<div class="form-field grid pure-g">
<div class="form-label block size-1-3 pure-u-1-3">
<label>
{% if field.help %}
<span class="tooltip" data-asTooltip-position="w" title="{{ field.help|e }}">{{ field.label }}</span>
{% else %}
{{ field.label }}
{% endif %}
{{ field.validate.required in ['on', 'true', 1] ? '<span class="required">*</span>' }}
</label>
</div>
<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(', ') }}"
{% block input_attributes %}
type="text"
{% 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>
{{ parent() }}
{% endblock %}

View File

@@ -20,34 +20,4 @@
{% include 'forms/fields/hidden/hidden.html.twig' %}
{% endfor %}
{% 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>