Skip to content

Commit

Permalink
enable overload of all settings
Browse files Browse the repository at this point in the history
per widget
  • Loading branch information
gotcha committed Mar 11, 2016
1 parent 36e07bc commit 2477e99
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/collective/ckeditor/browser/ckeditorview.py
Expand Up @@ -426,8 +426,8 @@ def getCK_widget_settings(self, widget):
if widget is not None:
widget_settings = {}
for k, v in params.items():
if hasattr(widget, k) and k not in p_overloaded:
widget_settings[k] = v
if k in p_overloaded and hasattr(widget, k):
widget_settings[k] = getattr(widget, k)

# specific for cols and rows rich widget settings
if hasattr(widget, 'cols') and 'width' not in p_overloaded:
Expand Down
29 changes: 10 additions & 19 deletions src/collective/ckeditor/browser/statics/ckeditor_plone.js
Expand Up @@ -75,32 +75,23 @@ launchCKInstances = function (ids_to_launch) {
/* if no ids is provided or if the current id is in the array of given ids, we proceed */
if ((typeof(ids_to_launch[0]) == 'undefined') || (jQuery.inArray(ckid, ids_to_launch) >= 0)) {
cke_config_url = jQuery('.cke_config_url', jQuery(this).parent()).val();
var widget_config = {};
widget_config.customConfig = cke_config_url;
/* Here starts the local js overload of settings by a field widget */
/* for now it only works with at rich widget : basehref width and height are the only attributes */
/* TODO improve it for any possible widget settings with jQuery.each('',jQuery(this).parent()) ... */
/* for now it only works with at rich widget */
if (jQuery('.cke_iswidget', jQuery(this).parent()).length) {
cke_width = jQuery('.cke_width', jQuery(this).parent()).val();
cke_height = jQuery('.cke_height', jQuery(this).parent()).val();
cke_baseHref = jQuery('.cke_baseHref', jQuery(this).parent()).val();
settings = jQuery('.widget_settings input', jQuery(this).parent());
settings.each(function () {
setting = jQuery(this);
widget_config[setting.attr('class')] = setting.val();
});
/* Destroy instance if it exists because an existing instance can not be managed twice */
if (typeof CKEDITOR.instances != 'undefined') {
var instance = CKEDITOR.instances[ckid];
if (instance) { instance.destroy(true); }
};
CKEDITOR.replace( ckid,
{
customConfig : cke_config_url,
width : cke_width,
height : cke_height,
baseHref : cke_baseHref
});
}
else {
CKEDITOR.replace( ckid,
{
customConfig : cke_config_url
});
}
}
CKEDITOR.replace( ckid, widget_config);
};
})
}
Expand Down
Expand Up @@ -24,15 +24,15 @@
tal:attributes="value python: True" />
<div class="widget_settings">
<input type="hidden"
class="cke_baseHref"
class="baseHref"
name="cke_baseHref"
tal:attributes="value ckview/cke_basehref" />
<tal:block repeat="item cke_widget/items">
<input type="hidden"
tal:define="k python: item[0];
v python: item[1];"
tal:attributes="name string:cke_$k;
class string:cke_$k;
class string:$k;
value v" />
</tal:block>
</div>
Expand Down

0 comments on commit 2477e99

Please sign in to comment.