Skip to content

Commit

Permalink
moved imgeefield template to a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
iambibhas committed Oct 20, 2020
1 parent b4dd244 commit 5e756a5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
17 changes: 13 additions & 4 deletions baseframe/forms/widgets.py
Expand Up @@ -3,7 +3,7 @@
from __future__ import unicode_literals
import six

from flask import Markup, current_app
from flask import Markup, current_app, render_template
from wtforms.compat import text_type
from wtforms.widgets import RadioInput, Select, html_params
import wtforms
Expand Down Expand Up @@ -310,8 +310,8 @@ def __call__(self, field, **kwargs):
value = ''
elif isinstance(value, furl):
value = furl.url
field.iframe = Markup(

iframe_html = Markup(
'<iframe %s class="imgee-upload"></iframe>'
% (
self.html_params(
Expand All @@ -320,7 +320,7 @@ def __call__(self, field, **kwargs):
)
)

return Markup(
field_html = Markup(
'<img %s> <input %s>'
% (
self.html_params(id='img_' + id_, src=value, width='200', **kwargs),
Expand All @@ -333,3 +333,12 @@ def __call__(self, field, **kwargs):
),
)
)

return Markup(
render_template(
'baseframe/mui/imgeefield.html.jinja2',
field=field,
iframe_html=iframe_html,
field_html=field_html,
)
)
10 changes: 0 additions & 10 deletions baseframe/templates/baseframe/mui/forms.html.jinja2
Expand Up @@ -82,16 +82,6 @@
{%- elif field.type == 'ImgeeField' %}
<div class="imgee">
{{ field | render_field_options(class="field-" + field.id + " " + widget_css_class, tabindex=tabindex, autofocus=autofocus, rows=rows) }}
<span class="loading imgee__loader mui--hide" id="imgee-loader-{{field.id}}">&nbsp;</span>
<a href="#imgee-{{field.id}}" rel="modal:open" class="mui-btn mui-btn--raised imgee__button">{% trans %}Select or Upload Image{% endtrans %}</a>
<div class="modal modal--fullscreen" id="imgee-{{field.id}}">
<div class="modal__header">
<a class="modal__close mui--text-dark" href="javascript:void(0);" data-target="close cancel register modal" aria-label="{% trans %}Close{% endtrans %}" rel="modal:close">{{ faicon(icon='times', icon_size='title') }}</a>
</div>
<div class="modal__body">
{{ field.iframe }}
</div>
</div>
</div>
{%- elif field.widget.input_type == 'password' and field.widget.html_tag not in ['ul', 'ol'] %}
<div class="mui-textfield mui-textfield--password mui-textfield--float-label">
Expand Down
13 changes: 13 additions & 0 deletions baseframe/templates/baseframe/mui/imgeefield.html.jinja2
@@ -0,0 +1,13 @@
{%- from "baseframe/mui/components.html.jinja2" import faicon -%}

{{ field_html|escape }}
<span class="loading imgee__loader mui--hide" id="imgee-loader-{{field.id}}">&nbsp;</span>
<a href="#imgee-{{field.id}}" rel="modal:open" class="mui-btn mui-btn--raised imgee__button">{% trans %}Select or Upload Image{% endtrans %}</a>
<div class="modal modal--fullscreen" id="imgee-{{field.id}}">
<div class="modal__header">
<a class="modal__close mui--text-dark" href="javascript:void(0);" data-target="close cancel register modal" aria-label="{% trans %}Close{% endtrans %}" rel="modal:close">{{ faicon(icon='times', icon_size='title') }}</a>
</div>
<div class="modal__body">
{{ iframe_html|escape }}
</div>
</div>

0 comments on commit 5e756a5

Please sign in to comment.