Files
ROC/src/kernel/form/cms_form_textarea.e
Jocelyn Fiat c871eae10e Renamed node_api and node_storage by blog_api and blog_storage in related CMS_BLOG_* classes. Mainly to avoid confusion with NODE_ classes.
Merged CMS_BLOG_CONFIG with CMS_BLOG_API.
In CMS_BLOG_API, prefer argument of type CMS_USER, rather than using directly user id.
Added a CMS_EDITOR_CONTENT_FORMAT for now, to be the format editable by the WYSIWYG editor.
Added CMS_MODULE.is_initialized: BOOLEAN to equip router, and module_api with expected preconditions.

Fixed typo, especially in log output.
Corrected a few routine names such as add_authors that should not be a function according to its name.
Converted various function returning html content, to procedure appending html content to an output string to minimize temporary string object creation.
Cosmetic: added spaces to make code easier to read, and indentation.
2015-05-27 19:00:32 +02:00

78 lines
1.8 KiB
Plaintext

note
description: "Extends the WSF form textarea with features to add a WYSIWIG editor."
author: "Dario Bösch <daboesch@student.ethz.ch"
date: "$Date: 2015-05-23 16:02:55 +0100 (Sat, 23 May 2015) $"
revision: "$Revision: 96616 $"
class
CMS_FORM_TEXTAREA
inherit
WSF_FORM_TEXTAREA
redefine
make,
append_item_to_html
end
CMS_EDITOR_CKEDITOR
create
make
feature -- Initialisation
make (a_name: like name)
-- <Precursor>
do
precursor(a_name)
-- By default we don't replace the textarea by an editor
editor := False;
end
feature -- Access
editor : BOOLEAN
-- True if the textarea should be replaced by the editor. Default is false.
format_field : detachable WSF_FORM_SELECT
-- Selection field for the format on that it depends, if the editor is shown or not.
condition_value : detachable STRING
feature -- Editor
show_as_editor
-- The textarea will be replaced by a wysiwyg editor
do
editor := True
end
show_as_editor_if_selected (a_select_field : WSF_FORM_SELECT; a_value : STRING)
-- Replaces the textarea only if a_select_field has a_value (or the value gets selected)
do
editor := True
format_field := a_select_field
condition_value := a_value
end
feature -- Conversion
append_item_to_html (a_theme: WSF_THEME; a_html: STRING_8)
do
-- Add javascript to replace textarea with editor
precursor(a_theme, a_html)
if editor then
a_html.append (load_assets)
a_html.append ("<script type=%"text/javascript%">");
if attached format_field as l_field and then attached condition_value as l_value then
a_html.append (javascript_textarea_to_editor_if_selected (Current, l_field, l_value))
else
a_html.append (javascript_textarea_to_editor (Current))
end
a_html.append ("</script>")
end
end
end