Skip to content

Commit

Permalink
Reuse editor.html instead of js script building in python
Browse files Browse the repository at this point in the history
  • Loading branch information
Tino de Bruijn committed Jan 1, 2015
1 parent eef475e commit 07e87c7
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions markitup/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,32 +77,15 @@ def render(self, name, value, attrs=None):

final_attrs = self.build_attrs(attrs)

if self.auto_preview:
auto_preview = "$('a[title=\"Preview\"]').trigger('mouseup');"
else: auto_preview = ''

try:
preview_url = (
'mySettings["previewParserPath"] = "%s";'
% reverse('markitup_preview'))
preview_url = reverse('markitup_preview')
except NoReverseMatch:
preview_url = "";

html += """
<script type="text/javascript">
(function($) {
$(document).ready(function() {
var element = $("#%(id)s");
if(!element.hasClass("markItUpEditor")) {
%(preview_url)s
element.markItUp(mySettings);
}
%(auto_preview)s
});
})(jQuery);
</script>
""" % {'id': final_attrs['id'], 'auto_preview': auto_preview,
'preview_url': preview_url}
preview_url = ""

html += render_to_string('markitup/editor.html',
{'textarea_id': final_attrs['id'],
'AUTO_PREVIEW': self.auto_preview,
'preview_url': preview_url})

return mark_safe(html)

Expand Down

0 comments on commit 07e87c7

Please sign in to comment.