Deprecated frontmatter field type

This commit is contained in:
Djamil Legato
2016-03-02 16:39:41 -08:00
parent dc722ce79f
commit f1d61742b8

View File

@@ -1,49 +1,10 @@
{% set value = (value is null ? field.default : value) %}
{# Deprecated field. Alias to editor/editor.html.twig #}
<div class="form-field">
<div class="form-label">
<label>
{% if field.help %}
<span class="tooltip" data-asTooltip-position="w" title="{{ field.help|e|tu }}">{{ field.label|tu }}</span>
{% else %}
{{ field.label|tu }}
{% endif %}
{{ field.validate.required in ['on', 'true', 1] ? '<span class="required">*</span>' }}
</label>
</div>
<div class="form-data">
<div class="form-frontmatter-wrapper {{ field.size }}">
<textarea
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
name="{{ (scope ~ field.name)|fieldName }}"
id="frontmatter">{{ value|join("\n") }}</textarea>
<div class="dragbar"></div>
</div>
</div>
</div>
<script>
((function(){
var editor = CodeMirror.fromTextArea(document.getElementById('frontmatter'), {
mode: 'yaml',
theme: 'paper',
{% if field.autofocus %}
autofocus: true,
{% endif %}
indentUnit: 4,
indentWithTabs: false,
extraKeys: {Tab: function(cm) { cm.replaceSelection(" ", "end"); }}
});
editor.on('change', editor.save);
{% extends "forms/fields/editor/editor.html.twig" %}
{% set codemirrorOptions = {'mode': 'yaml', 'indentUnit': 4, ignore: ['code'], 'autofocus': true, 'indentWithTabs': false, 'lineNumbers': true, 'gutters': ["CodeMirror-lint-markers"]}|merge(field.codemirror|default({})) %}
$('.dragbar').mousedown(function(e){
e.preventDefault();
var parentOffset = $(this).parent().offset();
$(document).mousemove(function(e){
$('.form-frontmatter-wrapper .CodeMirror').css('height',e.pageY - parentOffset.top);
})
});
$(document).mouseup(function(e){
$(document).unbind('mousemove');
});
})());
</script>
{# backward compatibility #}
{% if field.showPreview %}
{% set codemirrorOptions = codemirrorOptions|merge({'ignore': []}) %}
{% endif %}
{# end backward compatibility #}