From 10af5e80af8f901fec761879ea457033e01cd4a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 1 Nov 2016 12:32:44 +0100 Subject: [PATCH] Support toolbar attribute for richtext widget issue3551 review31601002 --- src/view/form.js | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/view/form.js b/src/view/form.js index 4af3587a9a..00aef1c567 100644 --- a/src/view/form.js +++ b/src/view/form.js @@ -1618,18 +1618,30 @@ function eval_pyson(value){ Sao.View.Form.RichText = Sao.class_(Sao.View.Form.Widget, { class_: 'form-richtext', init: function(field_name, model, attributes) { - var i, properties, button; Sao.View.Form.RichText._super.init.call( this, field_name, model, attributes); this.el = jQuery('
', { 'class': this.class_ + ' panel panel-default' }); - this.toolbar = jQuery('
', { + if (parseInt(attributes.toolbar || '1', 10)) { + this.get_toolbar().appendTo(this.el); + } + this.input = this.labelled = jQuery('
', { + 'class': 'richtext', + 'contenteditable': true + }).appendTo(jQuery('
', { + 'class': 'panel-body' + }).appendTo(this.el)); + this.el.focusout(this.focus_out.bind(this)); + }, + get_toolbar: function() { + var i, properties, button; + var toolbar = jQuery('
', { 'class': 'btn-toolbar', 'role': 'toolbar' }).appendTo(jQuery('
', { 'class': 'panel-heading' - }).appendTo(this.el)); + })); var button_apply_command = function(evt) { document.execCommand(evt.data); @@ -1639,7 +1651,7 @@ function eval_pyson(value){ var group = jQuery('
', { 'class': 'btn-group', 'role': 'group' - }).appendTo(this.toolbar); + }).appendTo(toolbar); for (i in buttons) { properties = buttons[i]; button = jQuery('