1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-23 05:16:03 +02:00

Merge branch 'dev' into #218

This commit is contained in:
Awilum
2019-08-27 00:28:00 +03:00
11 changed files with 105 additions and 93 deletions

View File

@@ -642,7 +642,7 @@ class EntriesController extends Controller
'save_entry' => [
'link' => 'javascript:;',
'title' => __('admin_save'),
'attributes' => ['class' => 'js-save-editor-form-submit float-right btn']
'attributes' => ['class' => 'js-save-form-submit float-right btn']
],
]
]
@@ -684,7 +684,7 @@ class EntriesController extends Controller
'save_entry' => [
'link' => 'javascript:;',
'title' => __('admin_save'),
'attributes' => ['class' => 'js-save-editor-form-submit float-right btn']
'attributes' => ['class' => 'js-save-form-submit float-right btn']
],
]
]
@@ -725,7 +725,7 @@ class EntriesController extends Controller
'save_entry' => [
'link' => 'javascript:;',
'title' => __('admin_save'),
'attributes' => ['class' => 'js-save-editor-form-submit float-right btn']
'attributes' => ['class' => 'js-save-form-submit float-right btn']
],
]
]

View File

@@ -252,91 +252,9 @@
{% include "plugins/admin/views/partials/clipboard.html" %}
{% include "plugins/admin/views/partials/custom-file-input.html" %}
{% include "plugins/admin/views/partials/trumbowyg.html" %}
{% include "plugins/admin/views/partials/codemirror.html" %}
{% include "plugins/admin/views/partials/forms-save.html" %}
<script type="text/javascript">
$(document).ready(function() {
$('.js-save-form-submit').click(function() {
$("#form").submit();
});
$('.js-save-editor-form-submit').click(function() {
$("#form").submit();
});
$('.js-plugins-info').click(function () {
$('#pluginInfoModal').modal();
$('.js-plugin-name-placeholder').html($(this).attr('data-name'));
$('.js-plugin-version-placeholder').html($(this).attr('data-version'));
$('.js-plugin-description-placeholder').html($(this).attr('data-description'));
$('.js-plugin-author-name-placeholder').html($(this).attr('data-author-name'));
$('.js-plugin-author-email-placeholder').html($(this).attr('data-author-email'));
$('.js-plugin-author-url-placeholder').html($(this).attr('data-author-url'));
$('.js-plugin-homepage-placeholder').html($(this).attr('data-homepage'));
$('.js-plugin-bugs-placeholder').html($(this).attr('data-bugs'));
$('.js-plugin-license-placeholder').html($(this).attr('data-license'));
});
$('.js-snippets-info').click(function () {
$('#snippetsInfoModal').modal();
$('.js-snippets-snippet-placeholder').html($(this).attr('data-name'));
$('.js-snippets-php-placeholder').html($(this).attr('data-name'));
});
$('.js-entries-image-preview').click(function () {
$('#entriesImagePreview').modal();
$('.js-entry-image-preview-placeholder').css('background-image', 'url(' + $(this).attr('data-image-url') + ')');
$('.js-entry-image-url-placeholder').val($(this).attr('data-image-url'));
$('.js-media-id').attr('value', $(this).attr('data-media-id'));
$('.js-entry-id').attr('value', $(this).attr('data-entry-id'));
});
{% if is_current_path('admin.fieldsets.edit') or is_current_path('admin.templates.edit') or is_current_path('admin.snippets.edit') or (is_current_path('admin.entries.edit') and type == 'source') %}
var editor = CodeMirror.fromTextArea(document.getElementById("codeMirrorEditor"), {
lineNumbers: true,
{% if is_current_path('admin.fieldsets.edit') %}
indentUnit: 4,
tabSize: 4,
{% else %}
tabSize: 4,
indentUnit: 4,
{% endif %}
{% if is_current_path('admin.fieldsets.edit') %}
mode: "text/javascript",
{% else %}
mode: "application/x-httpd-php",
{% endif %}
indentWithTabs: false,
{% if registry.settings.admin_panel.theme == light %}
theme: "elegant",
{% elseif registry.settings.admin_panel.theme == dark %}
theme: "monokai",
{% endif %}
styleActiveLine: true,
});
editor.addKeyMap({
"Tab": function (cm) {
if (cm.somethingSelected()) {
var sel = editor.getSelection("\n");
// Indent only if there are multiple lines selected, or if the selection spans a full line
if (sel.length > 0 && (sel.indexOf("\n") > -1 || sel.length === cm.getLine(cm.getCursor().line).length)) {
cm.indentSelection("add");
return;
}
}
if (cm.options.indentWithTabs)
cm.execCommand("insertTab");
else
cm.execCommand("insertSoftTab");
},
"Shift-Tab": function (cm) {
cm.indentSelection("subtract");
}
});
{% endif %}
});
</script>
{% block tail %}{% endblock %}
</body>
</html>

View File

@@ -0,0 +1,51 @@
<script type="text/javascript">
function qsa(sel) {
return Array.apply(null, document.querySelectorAll(sel));
}
qsa(".js-code").forEach(function (editorEl) {
var editor = CodeMirror.fromTextArea(editorEl, {
lineNumbers: true,
{% if is_current_path('admin.fieldsets.edit') %}
indentUnit: 4,
tabSize: 4,
{% else %}
tabSize: 4,
indentUnit: 4,
{% endif %}
{% if is_current_path('admin.fieldsets.edit') %}
mode: "text/javascript",
{% else %}
mode: "application/x-httpd-php",
{% endif %}
indentWithTabs: false,
{% if registry.settings.admin_panel.theme == light %}
theme: "elegant",
{% elseif registry.settings.admin_panel.theme == dark %}
theme: "monokai",
{% endif %}
styleActiveLine: true,
});
editor.addKeyMap({
"Tab": function (cm) {
if (cm.somethingSelected()) {
var sel = editor.getSelection("\n");
// Indent only if there are multiple lines selected, or if the selection spans a full line
if (sel.length > 0 && (sel.indexOf("\n") > -1 || sel.length === cm.getLine(cm.getCursor().line).length)) {
cm.indentSelection("add");
return;
}
}
if (cm.options.indentWithTabs)
cm.execCommand("insertTab");
else
cm.execCommand("insertSoftTab");
},
"Shift-Tab": function (cm) {
cm.indentSelection("subtract");
}
});
});
</script>

View File

@@ -0,0 +1,5 @@
<script type="text/javascript">
$('.js-save-form-submit').click(function() {
$("#form").submit();
});
</script>

View File

@@ -72,3 +72,15 @@
</div>
</div>
{% endblock %}
{% block tail %}
<script type="text/javascript">
$('.js-entries-image-preview').click(function () {
$('#entriesImagePreview').modal();
$('.js-entry-image-preview-placeholder').css('background-image', 'url(' + $(this).attr('data-image-url') + ')');
$('.js-entry-image-url-placeholder').val($(this).attr('data-image-url'));
$('.js-media-id').attr('value', $(this).attr('data-media-id'));
$('.js-entry-id').attr('value', $(this).attr('data-entry-id'));
});
</script>
{% endblock %}

View File

@@ -9,7 +9,7 @@
<div class="row">
<div class="col-12">
<div class="form-group">
<textarea id="codeMirrorEditor" style="min-height:500px;" name="data" rows="8" cols="80" class="form-control">{{ data }}</textarea>
<textarea style="min-height:500px;" name="data" rows="8" cols="80" class="form-control js-code">{{ data }}</textarea>
</div>
</div>
</div>

View File

@@ -8,7 +8,7 @@
<div class="row">
<div class="col-12">
<div class="form-group">
<textarea id="codeMirrorEditor" style="min-height:500px;" name="data" rows="8" cols="80" class="form-control">{{ data }}</textarea>
<textarea style="min-height:500px;" name="data" rows="8" cols="80" class="form-control js-code">{{ data }}</textarea>
</div>
</div>
</div>

View File

@@ -73,5 +73,21 @@
</div>
</div>
</div>
{% endblock %}
{% block tail %}
<script type="text/javascript">
$('.js-plugins-info').click(function () {
$('#pluginInfoModal').modal();
$('.js-plugin-name-placeholder').html($(this).attr('data-name'));
$('.js-plugin-version-placeholder').html($(this).attr('data-version'));
$('.js-plugin-description-placeholder').html($(this).attr('data-description'));
$('.js-plugin-author-name-placeholder').html($(this).attr('data-author-name'));
$('.js-plugin-author-email-placeholder').html($(this).attr('data-author-email'));
$('.js-plugin-author-url-placeholder').html($(this).attr('data-author-url'));
$('.js-plugin-homepage-placeholder').html($(this).attr('data-homepage'));
$('.js-plugin-bugs-placeholder').html($(this).attr('data-bugs'));
$('.js-plugin-license-placeholder').html($(this).attr('data-license'));
});
</script>
{% endblock %}

View File

@@ -8,7 +8,7 @@
<div class="row">
<div class="col-12">
<div class="form-group">
<textarea id="codeMirrorEditor" style="min-height:500px;" name="data" rows="8" cols="80" class="form-control">{{ data }}</textarea>
<textarea style="min-height:500px;" name="data" rows="8" cols="80" class="form-control js-code">{{ data }}</textarea>
</div>
</div>
</div>

View File

@@ -86,3 +86,13 @@
</div>
</div>
{% endblock %}
{% block tail %}
<script type="text/javascript">
$('.js-snippets-info').click(function () {
$('#snippetsInfoModal').modal();
$('.js-snippets-snippet-placeholder').html($(this).attr('data-name'));
$('.js-snippets-php-placeholder').html($(this).attr('data-name'));
});
</script>
{% endblock %}

View File

@@ -10,7 +10,7 @@
<div class="row">
<div class="col-12">
<div class="form-group">
<textarea id="codeMirrorEditor" style="min-height:500px;" name="data" rows="8" cols="80" class="form-control">{{ data }}</textarea>
<textarea style="min-height:500px;" name="data" rows="8" cols="80" class="form-control js-code">{{ data }}</textarea>
</div>
</div>
</div>