Removed many places where we set class for CKEditor and make only one place for this.
This commit is contained in:
parent
a54a5882e3
commit
6b15ad3385
|
@ -22,7 +22,7 @@ class TextPlugin(CMSPluginBase):
|
|||
Returns the Django form Widget to be used for
|
||||
the text area
|
||||
"""
|
||||
return TextEditorWidget(attrs={'class': 'CMS_CKEditor'}, installed_plugins=plugins, pk=pk, placeholder=placeholder, plugin_language=language)
|
||||
return TextEditorWidget(installed_plugins=plugins, pk=pk, placeholder=placeholder, plugin_language=language)
|
||||
|
||||
def get_form_class(self, request, plugins, pk, placeholder, language):
|
||||
"""
|
||||
|
|
|
@ -11,12 +11,12 @@ except ImportError:
|
|||
|
||||
class HTMLField(models.TextField):
|
||||
def formfield(self, **kwargs):
|
||||
defaults = {'widget': TextEditorWidget(attrs={'class': 'CMS_CKEditor'})}
|
||||
defaults = {'widget': TextEditorWidget()}
|
||||
defaults.update(kwargs)
|
||||
|
||||
# override the admin widget
|
||||
if defaults['widget'] == admin_widgets.AdminTextareaWidget:
|
||||
defaults['widget'] = TextEditorWidget(attrs={'class': 'CMS_CKEditor'})
|
||||
defaults['widget'] = TextEditorWidget()
|
||||
|
||||
return super(HTMLField, self).formfield(**defaults)
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
// CMS.$ will be passed for $
|
||||
$(document).ready(function () {
|
||||
function initCMSCKEditor() {
|
||||
if ($('.CMS_CKEditor:visible').length > 0) {
|
||||
$('.CMS_CKEditor:visible').each(function() {
|
||||
if ($('.{{ ckeditor_class }}:visible').length > 0) {
|
||||
$('.{{ ckeditor_class }}:visible').each(function() {
|
||||
$(this).hide();
|
||||
|
||||
var container = $(this).attr('id');
|
||||
|
|
|
@ -16,6 +16,16 @@ class TextEditorWidget(Textarea):
|
|||
|
||||
installed_plugins is a list of plugins to display that are text_enabled
|
||||
"""
|
||||
if attrs is None:
|
||||
attrs = {}
|
||||
|
||||
self.ckeditor_class = 'CMS_CKEditor'
|
||||
if self.ckeditor_class not in attrs.get('class', '').join(' '):
|
||||
new_class = attrs.get('class', '') + ' %s' % self.ckeditor_class
|
||||
attrs.update({
|
||||
'class': new_class.strip()
|
||||
})
|
||||
|
||||
super(TextEditorWidget, self).__init__(attrs)
|
||||
self.installed_plugins = installed_plugins
|
||||
self.pk = pk
|
||||
|
@ -28,6 +38,7 @@ class TextEditorWidget(Textarea):
|
|||
def render_additions(self, name, value, attrs=None):
|
||||
language = get_language().split('-')[0]
|
||||
context = {
|
||||
'ckeditor_class': self.ckeditor_class,
|
||||
'name': name,
|
||||
'language': language,
|
||||
'settings': language.join(json.dumps(text_settings.CKEDITOR_SETTINGS).split("{{ language }}")),
|
||||
|
|
Reference in New Issue