misc: remove frontoffice edition of some texts (#17665)
This commit is contained in:
parent
f7381f59ba
commit
0731893be9
|
@ -77,7 +77,7 @@ class CategoryPage(Directory):
|
|||
|
||||
if self.category.description:
|
||||
r += htmltext('<div class="bo-block">')
|
||||
r += self.category.get_description_html_text(editable=False)
|
||||
r += self.category.get_description_html_text()
|
||||
r += htmltext('</div>')
|
||||
|
||||
formdefs = FormDef.select()
|
||||
|
|
|
@ -469,7 +469,7 @@ class ApiCategoriesDirectory(Directory):
|
|||
d['slug'] = category.url_name
|
||||
d['url'] = category.get_url()
|
||||
if category.description:
|
||||
d['description'] = unicode(str(category.get_description_html_text(editable=False)), charset)
|
||||
d['description'] = unicode(str(category.get_description_html_text()), charset)
|
||||
formdefs = ApiFormdefsDirectory(category).get_list_forms(user,
|
||||
formdefs=all_formdefs, list_all_forms=list_all_forms)
|
||||
if not formdefs:
|
||||
|
|
|
@ -105,24 +105,12 @@ class Category(XmlStorableObject):
|
|||
base_url = get_publisher().get_frontoffice_url()
|
||||
return '%s/%s/' % (base_url, self.url_name)
|
||||
|
||||
def get_description_html_text(self, editable=True):
|
||||
def get_description_html_text(self):
|
||||
if not self.description:
|
||||
return None
|
||||
text = self.description
|
||||
if text[0] != '<':
|
||||
text = '<p>%s</p>' % text
|
||||
if editable and get_publisher().get_backoffice_root().is_accessible('categories'):
|
||||
root_url = get_publisher().get_root_url()
|
||||
get_response().add_javascript(['jquery.js', 'jquery-ui.js',
|
||||
'ckeditor/ckeditor.js', 'qommon.wysiwyg.js',
|
||||
'ckeditor/adapters/jquery.js'])
|
||||
get_response().add_javascript_code('var LIVE_EDIT_TOOLTIP = "%s";\n' % \
|
||||
_('Double click to edit the text'))
|
||||
return htmltext('<div class="block-edit-custom-text">'\
|
||||
'<a class="edit-custom-text" href="%sadmin/categories/%s/description">%s</a>'\
|
||||
'<div class="block-custom-text">'\
|
||||
'%s'\
|
||||
'</div></div>' % (root_url, self.id, _('Edit This Text'), text))
|
||||
return htmltext(text)
|
||||
|
||||
|
||||
|
|
|
@ -56,20 +56,6 @@ class TextsDirectory(Directory):
|
|||
fd = StringIO()
|
||||
text_template.generate(fd, subst_vars)
|
||||
text = fd.getvalue()
|
||||
|
||||
if get_publisher().get_backoffice_root() and \
|
||||
get_publisher().get_backoffice_root().is_accessible('settings'):
|
||||
root_url = get_publisher().get_root_url()
|
||||
get_response().add_javascript(['jquery.js', 'jquery-ui.js',
|
||||
'ckeditor/ckeditor.js', 'qommon.wysiwyg.js',
|
||||
'ckeditor/adapters/jquery.js'])
|
||||
get_response().add_javascript_code('var LIVE_EDIT_TOOLTIP = "%s";\n' % \
|
||||
_('Double click to edit the text'))
|
||||
return htmltext('<div class="block-edit-custom-text text-%s">'\
|
||||
'<a class="edit-custom-text" href="%sbackoffice/settings/texts/%s">%s</a>'\
|
||||
'<div class="block-custom-text">'\
|
||||
'%s'\
|
||||
'</div></div>' % (key, root_url, key, _('Edit This Text'), text))
|
||||
return htmltext('<div class="text-%s">%s</div>' % (key, text))
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -13,58 +13,6 @@ $(document).ready( function() {
|
|||
return;
|
||||
}
|
||||
$('div.WysiwygTextWidget textarea').ckeditor({allowedContent: true});
|
||||
if ($('.block-edit-custom-text').length > 0) {
|
||||
$('.block-edit-custom-text a.edit-custom-text').hide();
|
||||
$('.block-edit-custom-text').tooltip({
|
||||
content: LIVE_EDIT_TOOLTIP, items: 'div', track: true,
|
||||
show: {delay: 0}
|
||||
});
|
||||
}
|
||||
$('.block-edit-custom-text').dblclick(function(event) {
|
||||
var edit_url = $(this).find('a.edit-custom-text').attr('href');
|
||||
var custom_text = $(this).find('div.block-custom-text');
|
||||
$.ajax({
|
||||
url: edit_url,
|
||||
beforeSend: function(xhr) {xhr.setRequestHeader('X-Popup', 'true'); },
|
||||
success: function(html) {
|
||||
dialog = $('<form>');
|
||||
$(html).find('input[name="_form_id"]').appendTo(dialog);
|
||||
$(html).find('textarea').appendTo(dialog);
|
||||
var title = $(html).find('label').text();
|
||||
var ckname = $(html).find('textarea').attr('name');
|
||||
var submit = $(html).find('button[name="submit"]').text();
|
||||
var cancel = $(html).find('button[name="cancel"]').text();
|
||||
$(dialog).dialog({
|
||||
modal: true,
|
||||
resizable: false,
|
||||
title: title,
|
||||
show: { effect: 'fade', duration: 400 },
|
||||
width: '50em'});
|
||||
$(dialog).dialog('option', 'buttons', [
|
||||
{text: cancel,
|
||||
click: function() { $(this).dialog('close'); }},
|
||||
{text: submit,
|
||||
click: function() {
|
||||
$.ajax({
|
||||
url: edit_url,
|
||||
beforeSend: function(xhr) {xhr.setRequestHeader('X-Ajax', 'true'); },
|
||||
data: $(this).serialize(),
|
||||
type: 'POST'
|
||||
});
|
||||
$(this).dialog('close');
|
||||
$(custom_text).empty();
|
||||
$(CKEDITOR.instances[ckname].getData()).appendTo(custom_text);
|
||||
}
|
||||
}]);
|
||||
|
||||
$(dialog).find('textarea').ckeditor();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
event.preventDefault();
|
||||
return false;
|
||||
});
|
||||
|
||||
$(document).on('wcs:dialog-loaded', function(e, dialog) {
|
||||
$(dialog).find('div.WysiwygTextWidget textarea').ckeditor({allowedContent: true});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue