Browse Source

Merge e0f739cfea into d9b82195fe

pull/17/merge
Alexander V. Sergeyev 10 years ago
parent
commit
b22845a4f2
4 changed files with 53 additions and 15 deletions
  1. +15
    -0
      .gitignore
  2. +34
    -1
      cms/templates/admin/main.tpl
  3. +3
    -3
      cms/templates/admin/subtemplates/edit.inc.tpl
  4. +1
    -11
      static/js/admin_backend.js

+ 15
- 0
.gitignore View File

@ -0,0 +1,15 @@
# FILES IGNORED BY GIT
# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# PHPStorm files
.idea/
# Cache files
cms/cache/*

+ 34
- 1
cms/templates/admin/main.tpl View File

@ -49,7 +49,40 @@
<script src="<?php echo JQUERY; ?>"></script>
<script src="<?php echo JQUERY_UI; ?>"></script>
<script src="<?php echo BOOTSTRAP; ?>"></script>
<?php if (isset($wysiwyg)): ?>
<?php if (!isset($wysiwyg)): ?>
<script src="http://cdnjs.cloudflare.com/ajax/libs/ace/1.1.3/ace.js"></script>
<script src="http://nightwing.github.io/emmet-core/emmet.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/ace/1.1.3/ext-emmet.js"></script>
<script>
var textarea = $('#content');
textarea.before('<div id="ace-editor"></div>').hide();
$('#ace-editor').height(textarea.height()).width(textarea.width());
$(window).resize(function() {
$('#ace-editor').height(textarea.height()).width(textarea.width());
});
var editor = ace.edit("ace-editor");
// Settings
editor.getSession().setMode("ace/mode/html");
editor.setTheme("ace/theme/monokai");
editor.getSession().setUseSoftTabs(true);
editor.getSession().setUseWrapMode(true);
editor.setShowPrintMargin(false);
editor.setOption("enableEmmet", true);
editor.getSession().setValue(textarea.val());
$('form:first').submit(function() {
textarea.val(editor.getSession().getValue());
});
</script>
<?php else: ?>
<script src="<?php echo WYSIWYG_EDITOR; ?>"></script>
<script src="<?php echo WYSIWYG_EDITOR_INIT; ?>"></script>
<?php endif; ?>


+ 3
- 3
cms/templates/admin/subtemplates/edit.inc.tpl View File

@ -88,15 +88,15 @@
<div class="form-group">
<div class="col-lg-12">
<a class="btn btn-default btn-xs" href="index.php?mode=modal&amp;action=insert_image"
data-toggle="modal" data-target="#modal_image" data-insert="#content"
data-toggle="modal" data-target="#modal_image" data-insert="ace-editor"
title="<?php echo $lang['insert_image_label']; ?>"><span
class="glyphicon glyphicon-picture"></span></a>
<a class="btn btn-default btn-xs" href="index.php?mode=modal&amp;action=insert_thumbnail"
data-toggle="modal" data-target="#modal_thumbnail" data-insert="#content"
data-toggle="modal" data-target="#modal_thumbnail" data-insert="ace-editor"
title="<?php echo $lang['insert_thumbnail_label']; ?>"><span
class="glyphicon glyphicon-hand-left"></span></a>
<a class="btn btn-default btn-xs" href="index.php?mode=modal&amp;action=insert_gallery"
data-toggle="modal" data-target="#modal_gallery" data-insert="#content"
data-toggle="modal" data-target="#modal_gallery" data-insert="ace-editor"
title="<?php echo $lang['insert_gallery_label']; ?>"><span class="glyphicon glyphicon-th"></span></a>
</div>
</div>


+ 1
- 11
static/js/admin_backend.js View File

@ -1,16 +1,6 @@
$.fn.extend({
insertAtCaret: function(myValue){
var obj;
if( typeof this[0].name !='undefined' ) obj = this[0];
else obj = this;
var startPos = obj.selectionStart;
var endPos = obj.selectionEnd;
var scrollTop = obj.scrollTop;
obj.value = obj.value.substring(0, startPos)+myValue+obj.value.substring(endPos,obj.value.length);
obj.focus();
obj.selectionStart = startPos + myValue.length;
obj.selectionEnd = startPos + myValue.length;
obj.scrollTop = scrollTop;
editor.insert(myValue);
}
});


Loading…
Cancel
Save