editor.html 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. {% macro editor(field, submit_button, placeholder=None, rows=4, hide_links=False, hide_images=False, hide_hr=False, extra=None) %}
  2. <div class="editor">
  3. {% if field.errors %}
  4. <div class="editor-error">
  5. {% for error in field.errors %}
  6. <p class="help-block" style="font-weight: bold;">{{ error }}</p>
  7. {% endfor %}
  8. </div>
  9. {% endif %}
  10. <div class="editor-input">
  11. <div>
  12. <textarea name="{{ field.html_name }}" id="{{ field.html_id }}" rows="{{ rows }}"{% if placeholder %} placeholder="{{ placeholder }}"{% endif %}>{% if field.has_value %}{{ field.value }}{% endif %}</textarea>
  13. </div>
  14. </div>
  15. <div class="editor-actions">
  16. <ul class="editor-tools unstyled pull-left">
  17. <li><a href="#" class="tooltip-top btn editor-bold" title="{% trans %}Bold{% endtrans %}"><i class="icon-bold"></i></a></li>
  18. <li><a href="#" class="tooltip-top btn editor-emphasis" title="{% trans %}Emphasis{% endtrans %}"><i class="icon-italic"></i></a></li>
  19. {% if not hide_links %}<li class="divider"><a href="#" class="tooltip-top btn editor-link" title="{% trans %}Insert Link{% endtrans %}"><i class="icon-share-alt"></i></a></li>{% endif %}
  20. {% if not hide_images %}<li{% if hide_links %} class="divider"{% endif %}><a href="#" class="tooltip-top btn editor-image" title="{% trans %}Insert Image{% endtrans %}"><i class="icon-picture"></i></a></li>{% endif %}
  21. {% if not hide_hr %}<li class="divider"><a href="#" class="tooltip-top btn editor-hr" title="{% trans %}Insert Horizontal Line{% endtrans %}"><i class="icon-minus"></i></a></li>{% endif %}
  22. </ul>
  23. <button name="save" type="submit" class="btn btn-primary pull-right">{{ submit_button }}</button>
  24. {% if extra %}{{ extra }}{% endif %}
  25. </div>
  26. </div>
  27. {% endmacro %}
  28. {% macro js() %}
  29. <script type="text/javascript">
  30. $(function () {
  31. ed_lang_enter_link_url = "{% trans %}Enter link address{% endtrans %}";
  32. ed_lang_enter_link_label = "{% trans %}Enter link label (optional){% endtrans %}";
  33. ed_lang_enter_image_url = "{% trans %}Enter image address{% endtrans %}";
  34. ed_lang_enter_image_label = "{% trans %}Enter image label{% endtrans %}";
  35. });
  36. </script>
  37. <script src="{{ STATIC_URL }}cranefly/js/editor.js"></script>
  38. {% endmacro %}