author: Emiliano D'Alterio
date: Wed Aug 07 15:38:11 2013 +0200
revision: 254:c4c87193b8a9 in silva.core.editor
branch:
details: https://hg.infrae.com/silva.core.editor?cmd=changeset;node=c4c87193b8a9
modified: src/silva/core/editor/__init__.py src/silva/core/editor/interfaces.py src/silva/core/editor/service.py src/silva/core/editor/static/content.css src/silva/core/editor/static/content.min.css src/silva/core/editor/static/editor.js src/silva/core/editor/static/editor.min.js src/silva/core/editor/static/plugins/silvatablestyles/plugin.js
added: src/silva/core/editor/static/plugins/silvatablestyles/plugin.js
removed:
log: Added new 'SilvaTableStyles' plugin for CKEditor. Some minor PEP8
changes. Added styling for tables in CKEditor.
diffstat:
src/silva/core/editor/__init__.py | 3 +-
src/silva/core/editor/interfaces.py | 77 +++++++-
src/silva/core/editor/service.py | 45 +++-
src/silva/core/editor/static/content.css | 27 ++
src/silva/core/editor/static/content.min.css | 2 +-
src/silva/core/editor/static/editor.js | 3 +
src/silva/core/editor/static/editor.min.js | 2 +-
src/silva/core/editor/static/plugins/silvatablestyles/plugin.js | 94 ++++++++++
8 files changed, 231 insertions(+), 22 deletions(-)
diffs (439 lines):
diff -r 61e335a98177 -r c4c87193b8a9 src/silva/core/editor/__init__.py
--- a/src/silva/core/editor/__init__.py Mon Aug 05 19:40:45 2013 +0200
+++ b/src/silva/core/editor/__init__.py Wed Aug 07 15:38:11 2013 +0200
@@ -11,13 +11,14 @@
class CKEditorExtension(object):
base = '++static++/silva.core.editor'
- plugins = {
+ plugins = {
'silvautils': 'plugins/silvautils',
'silvalink': 'plugins/silvalink',
'silvaimage': 'plugins/silvaimage',
'silvaanchor': 'plugins/silvaanchor',
'silvasave': 'plugins/silvasave',
'silvaformat': 'plugins/silvaformat',
+ 'silvatablestyles': 'plugins/silvatablestyles',
'silvadialog': 'plugins/silvadialog',
}
skins = {
diff -r 61e335a98177 -r c4c87193b8a9 src/silva/core/editor/interfaces.py
--- a/src/silva/core/editor/interfaces.py Mon Aug 05 19:40:45 2013 +0200
+++ b/src/silva/core/editor/interfaces.py Wed Aug 07 15:38:11 2013 +0200
@@ -40,11 +40,14 @@
SimpleTerm(title='Link a Silva content', value='SilvaLink'),
SimpleTerm(title='Remove a link', value='SilvaUnlink'),
SimpleTerm(title='Include a Silva (or remote) image', value='SilvaImage'),
- SimpleTerm(title='Include an anchor or Silva Index entry', value='SilvaAnchor'),
- SimpleTerm(title='Remove an anchor or Silva Index entry', value='SilvaRemoveAnchor'),
+ SimpleTerm(title='Include an anchor or Silva Index entry',
+ value='SilvaAnchor'),
+ SimpleTerm(title='Remove an anchor or Silva Index entry',
+ value='SilvaRemoveAnchor'),
SimpleTerm(title='Format using service settings', value='SilvaFormat'),
SimpleTerm(title='Add an External Source', value='SilvaExternalSource'),
- SimpleTerm(title='Remove an External Source', value='SilvaRemoveExternalSource'),
+ SimpleTerm(title='Remove an External Source',
+ value='SilvaRemoveExternalSource'),
SimpleTerm(title='Cut', value='Cut'),
SimpleTerm(title='Copy', value='Copy'),
SimpleTerm(title='Paste', value='Paste'),
@@ -83,10 +86,9 @@
@grok.provider(IContextSourceBinder)
def skin_vocabulary(context):
- skins = [
- SimpleTerm(title='Kama', value='kama'),
- SimpleTerm(title='Office 2003', value='office2003'),
- SimpleTerm(title='v2', value='v2')]
+ skins = [SimpleTerm(title='Kama', value='kama'),
+ SimpleTerm(title='Office 2003', value='office2003'),
+ SimpleTerm(title='v2', value='v2')]
service = getUtility(ICKEditorService)
for extension, base in service.get_custom_extensions():
if hasattr(extension, 'skins'):
@@ -161,6 +163,32 @@
direct=True)
+class ICKEditorTableStyle(interface.Interface):
+ """CKEditor Table style.
+ """
+ name = schema.TextLine(
+ title=u"Style name",
+ required=True)
+ html_class = schema.TextLine(
+ title=u"Class name",
+ required=True)
+
+
+class CKEditorTableStyle(object):
+ grok.implements(ICKEditorTableStyle)
+
+ def __init__(self, name, html_class):
+ self.name = name
+ self.html_class = html_class
+
+
+grok.global_utility(
+ CKEditorTableStyle,
+ provides=IFactory,
+ name=ICKEditorTableStyle.__identifier__,
+ direct=True)
+
+
class ICKEditorSettings(interface.Interface):
toolbars = schema.List(
@@ -172,7 +200,8 @@
'Cut', 'Copy', 'Paste', 'PasteFromWord', '-',
'Undo', 'Redo', '-',
'Find', 'Replace', '-', 'Maximize', '/',
- 'SilvaFormat', '-', 'Bold', 'Italic', 'Strike', '-',
+ 'SilvaFormat', 'SilvaTableStyles', '-',
+ 'Bold', 'Italic', 'Strike', '-',
'NumberedList', 'BulletedList', '-',
'Subscript', 'Superscript', '-',
'Outdent', 'Indent', '-',
@@ -204,16 +233,40 @@
CKEditorFormat(
u'Lead', 'p', [CKEditorHTMLAttribute('class', 'lead')]),
CKEditorFormat(
- u'Annotation', 'p', [CKEditorHTMLAttribute('class', 'annotation')]),
+ u'Annotation', 'p', [CKEditorHTMLAttribute('class',
+ 'annotation')]),
CKEditorFormat(
u'Preformatted', 'pre', []),
],
required=True)
+ table_styles = schema.List(
+ title=u"Table styles",
+ description=u"Styling for tables",
+ value_type=schema.Object(
+ title=u"Table styles",
+ schema=ICKEditorTableStyle),
+ default=[
+ CKEditorTableStyle(
+ u'Plain', 'plain'),
+ CKEditorTableStyle(
+ u'List', 'list'),
+ CKEditorTableStyle(
+ u'Grid', 'grid'),
+ CKEditorTableStyle(
+ u'Datagrid', 'datagrid'),
+ ],
+ required=True)
contents_css = schema.TextLine(
title=u"Contents CSS",
description=u"CSS to apply to edited content in the editor",
default=u'++static++/silva.core.editor/content.css',
required=True)
+ editor_body_class = schema.TextLine(
+ title=u"Editor iframe body class",
+ description=u"""Sets the class attribute to be used
+ on the body element of the editing area.""",
+ default=u'ckeditor_contents',
+ required=True)
skin = schema.Choice(
title=u"Editor skin",
description=u"Editor theme",
@@ -225,6 +278,12 @@
description=u"Disallow users to use colors in the editor",
default=True,
required=True)
+ startup_show_borders = schema.Bool(
+ title=u"Borders around elements",
+ description=u"""Whether to automatically enable the
+ 'show border' command when the editor loads""",
+ default=False,
+ required=True)
class ICKEditorService(ISilvaLocalService):
diff -r 61e335a98177 -r c4c87193b8a9 src/silva/core/editor/service.py
--- a/src/silva/core/editor/service.py Mon Aug 05 19:40:45 2013 +0200
+++ b/src/silva/core/editor/service.py Wed Aug 07 15:38:11 2013 +0200
@@ -40,6 +40,7 @@
logger = logging.getLogger('silva.core.editor')
FORMAT_IDENTIFIER_BASE = 'format%0004d'
+TABLE_STYLE_IDENTIFIER_BASE = 'table_style_%0004d'
class CKEditorConfiguration(ZMIObject):
@@ -56,9 +57,13 @@
toolbars = FieldProperty(ICKEditorSettings['toolbars'])
formats = FieldProperty(ICKEditorSettings['formats'])
+ table_styles = FieldProperty(ICKEditorSettings['table_styles'])
contents_css = FieldProperty(ICKEditorSettings['contents_css'])
skin = FieldProperty(ICKEditorSettings['skin'])
disable_colors = FieldProperty(ICKEditorSettings['disable_colors'])
+ startup_show_borders = FieldProperty(
+ ICKEditorSettings['startup_show_borders'])
+ editor_body_class = FieldProperty(ICKEditorSettings['editor_body_class'])
def __init__(self, id, title=None):
self.id = id
@@ -97,11 +102,27 @@
if attributes_result:
format_result['attributes'] = attributes_result
format_identifier = FORMAT_IDENTIFIER_BASE % count
- result[format_identifier] = format_result
+ result[format_identifier] = format_result
order.append(format_identifier)
count += 1
return result
+ def get_table_styles(self):
+ count = 0
+ order = []
+ results = {}
+ for table_style in self.table_styles:
+ table_style_result = {
+ 'name': table_style.name,
+ 'html_class': table_style.html_class
+ }
+ table_style_identifier = TABLE_STYLE_IDENTIFIER_BASE % count
+ results[table_style_identifier] = table_style_result
+ order.append(table_style_identifier)
+ count += 1
+ results['order'] = order
+ return results
+
InitializeClass(CKEditorConfiguration)
@@ -215,14 +236,14 @@
configurations = list(context.available_configurations())
configurations.sort(key=operator.itemgetter(0))
return SimpleVocabulary([
- SimpleTerm(value=name, token=name, title=info[0])
- for name, info in configurations])
+ SimpleTerm(value=name, token=name, title=info[0])
+ for name, info in configurations])
class ICKEditorConfigurations(Interface):
config = schema.Choice(title=u'Configuration',
- source=configurations_source,
- required=True)
+ source=configurations_source,
+ required=True)
class CKEditorServiceConfigurationManager(silvaforms.ZMIComposedForm):
@@ -303,7 +324,7 @@
def getItems(self):
return list(self.context.objectValues(
- spec=CKEditorConfiguration.meta_type))
+ spec=CKEditorConfiguration.meta_type))
class CKEditorEditConfiguration(silvaforms.ZMIForm):
@@ -344,8 +365,11 @@
'paths': plugins_url,
'contents_css': configuration.contents_css,
'formats': configuration.get_formats(),
+ 'table_styles': configuration.get_table_styles(),
'plugins': list(plugins_url.keys()),
'disable_colors': configuration.disable_colors,
+ 'startup_show_borders': configuration.startup_show_borders,
+ 'editor_body_class': configuration.editor_body_class,
'skin': skin})
@@ -358,11 +382,11 @@
class ISanitizerConfiguration(Interface):
_allowed_html_tags = schema.Set(title=u"Allowed HTML tags",
- value_type=schema.TextLine())
+ value_type=schema.TextLine())
_allowed_html_attributes = schema.Set(title=u"Allowed HTML attributes",
- value_type=schema.TextLine())
+ value_type=schema.TextLine())
_allowed_css_attributes = schema.Set(title=u"Allowed CSS attributes",
- value_type=schema.TextLine())
+ value_type=schema.TextLine())
class CKEditorServiceHTMLSanitizerConfiguration(silvaforms.ZMIForm):
@@ -371,7 +395,8 @@
ignoreContent = False
label = _(u"Manage HTML Sanitizer")
- description = _(u"Manager allowed HTML tags and attributes allowed in editor.")
+ description = _(u"""Manager allowed HTML tags
+ and attributes allowed in editor.""")
fields = silvaforms.Fields(ISanitizerConfiguration)
actions = silvaforms.Actions(EditAction(title=_(u"Save changes")))
diff -r 61e335a98177 -r c4c87193b8a9 src/silva/core/editor/static/content.css
--- a/src/silva/core/editor/static/content.css Mon Aug 05 19:40:45 2013 +0200
+++ b/src/silva/core/editor/static/content.css Wed Aug 07 15:38:11 2013 +0200
@@ -56,3 +56,30 @@
a.broken-link {
color: #a00;
}
+
+
+/* table styling in ckeditor, it can be overridden by using '.ckeditor_contents' */
+
+table.plain, table.list {
+ border: none;
+}
+
+table.plain td {
+ border: 1px dashed #777;
+}
+
+table.list td {
+ border: 1px solid #777;
+ border-right: none;
+ border-left: none;
+}
+
+table.grid,
+table.grid td {
+ border: 1px solid #777;
+}
+
+table.datagrid,
+table.datagrid td {
+ border: 2px solid #777;
+}
diff -r 61e335a98177 -r c4c87193b8a9 src/silva/core/editor/static/content.min.css
--- a/src/silva/core/editor/static/content.min.css Mon Aug 05 19:40:45 2013 +0200
+++ b/src/silva/core/editor/static/content.min.css Wed Aug 07 15:38:11 2013 +0200
@@ -1,1 +1,1 @@
-body{font:70% Verdana,Helvetica,Arial,sans-serif}h1,h2,h3,h4,h5,h6{margin:1em 0 0 0}h1{margin-top:.8em;margin-bottom:.7em;font-size:170%}h2{margin-bottom:.6em;font-size:145%}h3{margin-bottom:.5em;font-size:120%}h4{margin-bottom:.2em;font-size:110%}h5{margin-bottom:.1em;font-size:105%}ul{margin:.5em 0;padding-left:1.4em}ol{margin:.5em 0;padding-left:1.9em}p.lead{font-weight:700}p.annotation{font-style:italic}a.broken-link{color:#a00}
\ No newline at end of file
+body{font:70% Verdana,Helvetica,Arial,sans-serif}h1,h2,h3,h4,h5,h6{margin:1em 0 0}h1{margin-top:.8em;margin-bottom:.7em;font-size:170%}h2{margin-bottom:.6em;font-size:145%}h3{margin-bottom:.5em;font-size:120%}h4{margin-bottom:.2em;font-size:110%}h5{margin-bottom:.1em;font-size:105%}ul{margin:.5em 0;padding-left:1.4em}ol{margin:.5em 0;padding-left:1.9em}p.lead{font-weight:700}p.annotation{font-style:italic}a.broken-link{color:#a00}table.plain,table.list{border:0}table.plain td{border:1px dashed #777}table.list td{border:1px solid #777;border-right:0;border-left:0}table.grid,table.grid td{border:1px solid #777}table.datagrid,table.datagrid td{border:2px solid #777}
\ No newline at end of file
diff -r 61e335a98177 -r c4c87193b8a9 src/silva/core/editor/static/editor.js
--- a/src/silva/core/editor/static/editor.js Mon Aug 05 19:40:45 2013 +0200
+++ b/src/silva/core/editor/static/editor.js Wed Aug 07 15:38:11 2013 +0200
@@ -31,6 +31,7 @@
language: smi.get_language(),
contentsCss: configuration['contents_css'],
silvaFormats: configuration['formats'],
+ silvaTableStyles: configuration['table_styles'],
extraPlugins: plugins_extra.join(','),
removePlugins: plugins_blacklist.join(','),
toolbar: 'Silva',
@@ -38,6 +39,8 @@
height: '2000px',
resize_enabled: false,
disable_colors: configuration['disable_colors'],
+ startupShowBorders: configuration['startup_show_borders'],
+ bodyClass: configuration['editor_body_class'],
dialog_buttonsOrder: 'rtl'
};
if (configuration['skin']) {
diff -r 61e335a98177 -r c4c87193b8a9 src/silva/core/editor/static/editor.min.js
--- a/src/silva/core/editor/static/editor.min.js Mon Aug 05 19:40:45 2013 +0200
+++ b/src/silva/core/editor/static/editor.min.js Wed Aug 07 15:38:11 2013 +0200
@@ -1,1 +1,1 @@
-(function($,infrae,CKEDITOR){infrae.interfaces.register("editor");var MODULE_BLACKLIST=["save","link","flash","image","filebrowser","iframe","forms"],FULL_SETTINGS=[],EMBDED_SETTINGS=[];$(document).bind("load-smiplugins",function(event,smi){var build_settings=function(configuration,embded){var plugins_blacklist=MODULE_BLACKLIST.slice(),plugins_extra=configuration.plugins;if(embded){var index=$.inArray("silvasave",plugins_extra);plugins_blacklist.push("silvasave"),index>-1&&plugins_extra.splice(index,1)}var settings={entities:!1,fullPage:!1,basicEntities:!0,language:smi.get_language(),contentsCss:configuration.contents_css,silvaFormats:configuration.formats,extraPlugins:plugins_extra.join(","),removePlugins:plugins_blacklist.join(","),toolbar:"Silva",toolbar_Silva:configuration.toolbars,he
ight:"2000px",resize_enabled:!1,disable_colors:configuration.disable_colors,dialog_buttonsOrder:"rtl"};return configuration.skin&&(settings.skin=configuration.skin),settings},get_settings=fu
nction(name,embded){var registry=embded?EMBDED_SETTINGS:FULL_SETTINGS;return void 0!==registry[name]?$.when(registry[name]):function(){return $.ajax({url:smi.options.editor.configuration,dataType:"json",data:[{name:"name",value:name}]}).then(function(configuration){for(var key in configuration.paths)CKEDITOR.plugins.addExternal(key,configuration.paths[key]);return FULL_SETTINGS[name]=build_settings(configuration,!1),EMBDED_SETTINGS[name]=build_settings(configuration,!0),registry[name]},function(request){return $.Deferred().reject(request)})}()},create_html_field=function(data){var $textarea=$(this);get_settings($textarea.data("editor-configuration"),!0).done(function(settings){var editor=CKEDITOR.replace($textarea.get(0),$.extend({},settings,{height:"300px"}));editor.on("instanceReady",fu
nction(){void 0!==data.popup&&infrae.ui.ResizeDialog(data.popup)}),data.form.bind("serialize-smiform",function(){$textarea.val(editor.getData())}),data.container.bind("clean-smiform",functio
n(){try{editor.destroy(!0)}catch(error){window.console&&console.log&&console.log("Error while destroying field editor",error)}})})};$(document).on("loadwidget-smiform",".form-fields-container",function(event,data){$(this).find(".field-htmltext").each(function(){create_html_field.call(this,data)}),event.stopPropagation()}),infrae.views.view({iface:"editor",name:"content",factory:function($content,data,smi){var editor=null;return smi.objection=function(){return null!=editor&&editor.checkDirty()?infrae.ui.ConfirmationDialog({title:"Modifications",message:"This document has been modified. If you continue you will lose these modifications. Do you want to continue?",buttons:{Save:function(){var url=$("#content-url").attr("href")+"/++rest++silva.core.editor.save",data={};return data[editor.name]
=editor.getData(),$.ajax({url:url,type:"POST",data:data})},Discard:function(){return!0},Cancel:function(){return!1}}}):null},{jsont:'<textarea name="{data.name|htmltag}">{data.text|html}</te
xtarea>',render:function(){return get_settings(data.configuration).done(function(settings){var textarea=$content.children("textarea").get(0),resize=function(){var height=$content.innerHeight()-4,width=$content.innerWidth();editor.resize(width,height)};editor=CKEDITOR.replace(textarea,settings),editor.on("instanceReady",resize),editor.on("instanceReady",function(){$(window).bind("resize.smi-editor",resize),$(window).bind("workspace-resize-smi.smi-editor",resize)})})},cleanup:function(){if($(window).unbind("resize.smi-editor"),$(window).unbind("workspace-resize-smi.smi-editor"),$content.empty(),null!=editor)try{editor.destroy(!0),editor=null}catch(error){window.console&&console.log&&console.log("Error while destroying editor",error)}}}}})})})(jQuery,infrae,CKEDITOR);
\ No newline at end of file
+!function($,infrae,CKEDITOR){infrae.interfaces.register("editor");var MODULE_BLACKLIST=["save","link","flash","image","filebrowser","iframe","forms"],FULL_SETTINGS=[],EMBDED_SETTINGS=[];$(document).bind("load-smiplugins",function(event,smi){var build_settings=function(configuration,embded){var plugins_blacklist=MODULE_BLACKLIST.slice(),plugins_extra=configuration.plugins;if(embded){var index=$.inArray("silvasave",plugins_extra);plugins_blacklist.push("silvasave"),index>-1&&plugins_extra.splice(index,1)}var settings={entities:!1,fullPage:!1,basicEntities:!0,language:smi.get_language(),contentsCss:configuration.contents_css,silvaFormats:configuration.formats,silvaTableStyles:configuration.table_styles,extraPlugins:plugins_extra.join(","),removePlugins:plugins_blacklist.join(","),toolbar:"Si
lva",toolbar_Silva:configuration.toolbars,height:"2000px",resize_enabled:!1,disable_colors:configuration.disable_colors,startupShowBorders:configuration.startup_show_borders,bodyClass:config
uration.editor_body_class,dialog_buttonsOrder:"rtl"};return configuration.skin&&(settings.skin=configuration.skin),settings},get_settings=function(name,embded){var registry=embded?EMBDED_SETTINGS:FULL_SETTINGS;return void 0!==registry[name]?$.when(registry[name]):function(){return $.ajax({url:smi.options.editor.configuration,dataType:"json",data:[{name:"name",value:name}]}).then(function(configuration){for(var key in configuration.paths)CKEDITOR.plugins.addExternal(key,configuration.paths[key]);return FULL_SETTINGS[name]=build_settings(configuration,!1),EMBDED_SETTINGS[name]=build_settings(configuration,!0),registry[name]},function(request){return $.Deferred().reject(request)})}()},create_html_field=function(data){var $textarea=$(this);get_settings($textarea.data("editor-configuration"),!
0).done(function(settings){var editor=CKEDITOR.replace($textarea.get(0),$.extend({},settings,{height:"300px"}));editor.on("instanceReady",function(){void 0!==data.popup&&infrae.ui.ResizeDial
og(data.popup)}),data.form.bind("serialize-smiform",function(){$textarea.val(editor.getData())}),data.container.bind("clean-smiform",function(){try{editor.destroy(!0)}catch(error){window.console&&console.log&&console.log("Error while destroying field editor",error)}})})};$(document).on("loadwidget-smiform",".form-fields-container",function(event,data){$(this).find(".field-htmltext").each(function(){create_html_field.call(this,data)}),event.stopPropagation()}),infrae.views.view({iface:"editor",name:"content",factory:function($content,data,smi){var editor=null;return smi.objection=function(){return null!=editor&&editor.checkDirty()?infrae.ui.ConfirmationDialog({title:"Modifications",message:"This document has been modified. If you continue you will lose these modifications. Do you want to c
ontinue?",buttons:{Save:function(){var url=$("#content-url").attr("href")+"/++rest++silva.core.editor.save",data={};return data[editor.name]=editor.getData(),$.ajax({url:url,type:"POST",data
:data})},Discard:function(){return!0},Cancel:function(){return!1}}}):null},{jsont:'<textarea name="{data.name|htmltag}">{data.text|html}</textarea>',render:function(){return get_settings(data.configuration).done(function(settings){var textarea=$content.children("textarea").get(0),resize=function(){var height=$content.innerHeight()-4,width=$content.innerWidth();editor.resize(width,height)};editor=CKEDITOR.replace(textarea,settings),editor.on("instanceReady",resize),editor.on("instanceReady",function(){$(window).bind("resize.smi-editor",resize),$(window).bind("workspace-resize-smi.smi-editor",resize)})})},cleanup:function(){if($(window).unbind("resize.smi-editor"),$(window).unbind("workspace-resize-smi.smi-editor"),$content.empty(),null!=editor)try{editor.destroy(!0),editor=null}catch(error
){window.console&&console.log&&console.log("Error while destroying editor",error)}}}}})})}(jQuery,infrae,CKEDITOR);
\ No newline at end of file
diff -r 61e335a98177 -r c4c87193b8a9 src/silva/core/editor/static/plugins/silvatablestyles/plugin.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/silva/core/editor/static/plugins/silvatablestyles/plugin.js Wed Aug 07 15:38:11 2013 +0200
@@ -0,0 +1,94 @@
+
+
+CKEDITOR.plugins.add('silvatablestyles', {
+ requires: ['richcombo'],
+ init : function (editor) {
+ var table_styles = editor.config.silvaTableStyles;
+
+ editor.ui.addRichCombo('SilvaTableStyles', {
+ label: 'Table styles',
+ title: 'Table styles',
+ className: 'cke_table_style',
+ panel: {
+ css: editor.skin.editor.css.concat(editor.config.contentsCss),
+ multiSelect: false
+ },
+ init: function () {
+ this.startGroup('Table styles');
+ var id = null;
+ var table_style = null;
+
+ for (var i=0; i < table_styles.order.length; i++) {
+ id = table_styles.order[i];
+ table_style = table_styles[id];
+
+ this.add(id, table_style.name, table_style.name);
+ }
+ },
+ onClick: function(value) {
+
+ editor.focus();
+ editor.fire('saveSnapshot');
+
+ var selected = CKEDITOR.silva.utils.getSelectedElement(editor);
+
+ while (selected !== null && selected.getName() !== 'table' ) {
+ selected = selected.getParent();
+ }
+
+ if (selected !== null && selected.getName() === 'table') {
+ var id = null;
+ var table_style_class = null;
+
+ for (var i=0; i < table_styles.order.length; i++) {
+ id = table_styles.order[i];
+ table_style_class = table_styles[id].html_class;
+
+ selected.removeClass(table_style_class);
+ }
+ selected.addClass(table_styles[value].html_class);
+ }
+
+ setTimeout(function() {
+ editor.fire('saveSnapshot');
+ }, 0 );
+ },
+ onRender: function() {
+
+ editor.on('selectionChange', function() {
+ var selected = CKEDITOR.silva.utils.getSelectedElement(editor);
+
+ while (selected !== null && selected.getName() !== 'table' ) {
+ selected = selected.getParent();
+ }
+
+ if (selected !== null && selected.getName() === 'table') {
+
+ $('#cke_'+ this.id).slideDown(300);
+
+ var id = null;
+ var table_style = null;
+
+ for (var i=0; i < table_styles.order.length; i++) {
+ id = table_styles.order[i];
+ table_style = table_styles[id];
+
+ if (selected.hasClass(table_style.html_class)) {
+ this.setValue(id, table_style.name);
+ return;
+ }
+ }
+ var default_table_style = table_styles[table_styles.order[0]];
+ selected.addClass(default_table_style.html_class);
+ this.setValue(default_table_style.name);
+ }
+ else {
+ this.setValue('');
+ $('#cke_'+ this.id).slideUp(300);
+ }
+ }, this);
+ $('#cke_'+ this.id).slideDown(300);
+ }
+ });
+ }
+});
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.