diff --git a/common/css/rhymix.less b/common/css/rhymix.less index 7c8dbff14..4548b8bbd 100644 --- a/common/css/rhymix.less +++ b/common/css/rhymix.less @@ -107,6 +107,32 @@ a img { } } +/* Editable Preview */ +.editable_preview { + width: 100%; + min-height: 240px; + max-height: 440px; + box-sizing: border-box; + margin: 0; + padding: 6px; + border: 1px solid #ccc; + border-radius: 4px; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + overflow-y: auto; + cursor: text; + p { + margin-bottom: @default_paragraph_spacing !important; + } +} +.editable_preview_iframe { + width: 100%; + height: 440px; + box-sizing: border-box; + margin: 0 0 -4px 0; + padding: 0; + border: 0; +} + /* Message */ .message { position: relative; diff --git a/common/js/common.js b/common/js/common.js index b1ed8e432..402edbf09 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -281,6 +281,25 @@ jQuery(function($) { } }); + /* Editor preview replacement */ + $(".editable_preview").addClass("xe_content").attr("tabindex", 0); + $(".editable_preview").on("click", function() { + var input = $(this).siblings(".editable_preview_content"); + if (input.size()) { + $(this).off("click").off("focus").hide(); + input = input.first(); + if (input.attr("type") !== "hidden") { + input.hide(); + } + var iframe = $(''); + iframe.attr("src", current_url.setQuery("module", "editor").setQuery("act", "dispEditorFrame").setQuery("parent_input_id", input.attr("id")).replace(/^https?:/, '')); + iframe.insertAfter(input); + } + }); + $(".editable_preview").on("focus", function() { + $(this).triggerHandler("click"); + }); + /* select - option의 disabled=disabled 속성을 IE에서도 체크하기 위한 함수 */ if(navigator.userAgent.match(/MSIE/)) { $('select').each(function(i, sels) { diff --git a/modules/editor/conf/module.xml b/modules/editor/conf/module.xml index 10d074053..7a65b3342 100644 --- a/modules/editor/conf/module.xml +++ b/modules/editor/conf/module.xml @@ -3,6 +3,7 @@ + diff --git a/modules/editor/editor.view.php b/modules/editor/editor.view.php index 9255e17e1..4cdd7b79a 100644 --- a/modules/editor/editor.view.php +++ b/modules/editor/editor.view.php @@ -15,6 +15,40 @@ class editorView extends editor { } + /** + * @brief Display editor in an iframe + */ + function dispEditorFrame() + { + // Check parent input ID + $parent_input_id = Context::get('parent_input_id'); + Context::set('parent_input_id', preg_replace('/[^a-z0-9_]/i', '', $parent_input_id)); + Context::addBodyClass('disable_debug_panel'); + + // Load editor + $oEditorModel = getModel('editor'); + $option = $oEditorModel->getEditorConfig(); + $option->editor_skin = 'ckeditor'; + $option->content_style = 'ckeditor_light'; + $option->sel_editor_colorset = 'moono-lisa'; + $option->primary_key_name = 'primary_key'; + $option->content_key_name = 'content'; + $option->allow_fileupload = FALSE; + $option->enable_autosave = FALSE; + $option->enable_default_component = TRUE; + $option->enable_component = FALSE; + $option->height = 300; + $option->editor_focus = 'Y'; + $editor = $oEditorModel->getEditor(0, $option); + Context::set('editor', $editor); + + // Set template + $this->setLayoutPath('./common/tpl/'); + $this->setLayoutFile("default_layout"); + $this->setTemplatePath($this->module_path . 'tpl'); + $this->setTemplateFile('editor_frame'); + } + /** * @brief Action to get a request to display compoenet pop-up */ diff --git a/modules/editor/skins/textarea/js/textarea.js b/modules/editor/skins/textarea/js/textarea.js index 1f624b4a2..1c477fa06 100644 --- a/modules/editor/skins/textarea/js/textarea.js +++ b/modules/editor/skins/textarea/js/textarea.js @@ -4,6 +4,7 @@ function editorTextarea(editor_sequence) { var primary_key = textarea.data("editor-primary-key-name"); var insert_form = textarea.closest("form"); var content_input = insert_form.find("input[name='" + content_key + "']"); + var content = ""; // Set editor keys editorRelKeys[editor_sequence] = {}; @@ -16,7 +17,7 @@ function editorTextarea(editor_sequence) { // Load existing content if (content_input.size()) { - var content = String(content_input.val()).stripTags(); + content = String(content_input.val()).stripTags(); content_input.val(content); textarea.val(content.unescape()); } @@ -25,4 +26,19 @@ function editorTextarea(editor_sequence) { textarea.on("change", function() { content_input.val(String(jQuery(this).val()).escape()); }); + + // Copy content to another input and resize iframe if configured + if (window.editor_resize_iframe && window.editor_copy_input) + { + content = String(editor_copy_input.val()).stripTags(); + editor_copy_input.val(content); + textarea.val(content.unescape()); + textarea.on("resize", function(e){ + editor_resize_iframe.height(textarea.height()); + }); + textarea.on("change", function() { + editor_copy_input.val(String(textarea.val()).escape()); + }); + editor_resize_iframe.height(textarea.height()); + } } \ No newline at end of file diff --git a/modules/editor/tpl/editor_frame.html b/modules/editor/tpl/editor_frame.html new file mode 100644 index 000000000..3c96e7ca2 --- /dev/null +++ b/modules/editor/tpl/editor_frame.html @@ -0,0 +1,18 @@ + + + + +
+ + + {$editor} +
diff --git a/modules/editor/tpl/js/editor.app.js b/modules/editor/tpl/js/editor.app.js index 8e4fcaf87..619753685 100644 --- a/modules/editor/tpl/js/editor.app.js +++ b/modules/editor/tpl/js/editor.app.js @@ -145,6 +145,19 @@ function getAutoSavedSrl(ret_obj, response_tags, c) { instance.on('instanceReady', function(e) { $containerEl.css("min-height", 0); + if(window.editor_resize_iframe && window.editor_copy_input) + { + e.editor.setData(editor_copy_input.val()); + e.editor.on("resize", function(e){ + var height = e.data.outerHeight; + editor_resize_iframe.height(height); + }); + e.editor.on("change", function() { + var content = e.editor.getData(); + editor_copy_input.val(content); + }); + editor_resize_iframe.height($(".cke_chrome").parent().height()); + } }); instance.on('paste', function(e) { diff --git a/modules/member/conf/module.xml b/modules/member/conf/module.xml index b98506de8..fc326f3b6 100644 --- a/modules/member/conf/module.xml +++ b/modules/member/conf/module.xml @@ -63,7 +63,6 @@ - diff --git a/modules/member/member.admin.controller.php b/modules/member/member.admin.controller.php index 068a7b2b1..0d08a6ca1 100644 --- a/modules/member/member.admin.controller.php +++ b/modules/member/member.admin.controller.php @@ -262,6 +262,8 @@ class memberAdminController extends member $agreement = new stdClass; $agreement->title = escape(utf8_trim($args->{'agreement_' . $i . '_title'})); $agreement->content = $args->{'agreement_' . $i . '_content'}; + $agreement->use_editor = $args->use_editor; + getModel('editor')->converter($agreement, 'document'); $agreement->type = $args->{'agreement_' . $i . '_type'}; if (!in_array($agreement->type, array('required', 'optional', 'disabled'))) { diff --git a/modules/member/member.admin.view.php b/modules/member/member.admin.view.php index 118d8bfae..360691fa2 100644 --- a/modules/member/member.admin.view.php +++ b/modules/member/member.admin.view.php @@ -157,40 +157,6 @@ class memberAdminView extends member $this->setTemplateFile('agreements_config'); } - /** - * Display the agreements edit form. - * - * @return void - */ - public function dispMemberAdminAgreementsEdit() - { - // Check parent input ID - $parent_input_id = Context::get('parent_input_id'); - Context::addBodyClass('disable_debug_panel'); - - // Load editor - $oEditorModel = getModel('editor'); - $option = $oEditorModel->getEditorConfig(); - $option->editor_skin = 'ckeditor'; - $option->content_style = 'ckeditor_light'; - $option->sel_editor_colorset = 'moono-lisa'; - $option->primary_key_name = 'primary_key'; - $option->content_key_name = 'content'; - $option->allow_fileupload = FALSE; - $option->enable_autosave = FALSE; - $option->enable_default_component = TRUE; - $option->enable_component = FALSE; - $option->height = 300; - $option->editor_focus = 'Y'; - $editor = $oEditorModel->getEditor(0, $option); - Context::set('editor', $editor); - - // Set template - $this->setLayoutPath('./common/tpl/'); - $this->setLayoutFile("default_layout"); - $this->setTemplateFile('agreements_edit'); - } - public function dispMemberAdminSignUpConfig() { $config = $this->memberConfig; diff --git a/modules/member/tpl/agreements_config.html b/modules/member/tpl/agreements_config.html index 3864658a0..adf34abe4 100644 --- a/modules/member/tpl/agreements_config.html +++ b/modules/member/tpl/agreements_config.html @@ -18,8 +18,8 @@
{$lang->cmd_agreement_content}
- -
{$config->agreements[$i]->content}
+ +
{$config->agreements[$i]->content}
diff --git a/modules/member/tpl/agreements_edit.html b/modules/member/tpl/agreements_edit.html deleted file mode 100644 index 74805996f..000000000 --- a/modules/member/tpl/agreements_edit.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - -
- - - {$editor} -
diff --git a/modules/member/tpl/css/config.less b/modules/member/tpl/css/config.less deleted file mode 100644 index d05f6b613..000000000 --- a/modules/member/tpl/css/config.less +++ /dev/null @@ -1,26 +0,0 @@ -.editor_preview { - width: 100%; - min-height: 240px; - max-height: 440px; - box-sizing: border-box; - margin: 0; - padding: 6px; - border: 1px solid #ccc; - border-radius: 4px; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - overflow-y: auto; - cursor: text; -} - -.editor_preview p { - margin-bottom: @default_paragraph_spacing !important; -} - -.editor_iframe { - width: 100%; - height: 440px; - box-sizing: border-box; - margin: 0 0 -4px 0; - padding: 0; - border: 0; -} diff --git a/modules/member/tpl/header.html b/modules/member/tpl/header.html index 5ea8a6d69..ec5a73030 100644 --- a/modules/member/tpl/header.html +++ b/modules/member/tpl/header.html @@ -1,5 +1,3 @@ - -

{$lang->cmd_member_config} {$lang->help}

diff --git a/modules/member/tpl/js/config.js b/modules/member/tpl/js/config.js index bbfd3ff3f..e69de29bb 100644 --- a/modules/member/tpl/js/config.js +++ b/modules/member/tpl/js/config.js @@ -1,29 +0,0 @@ - -(function($) { - - // Editor replacement callback function - var editor_replace = function(input) { - var iframe = $(''); - iframe.attr("src", current_url.setQuery("act", "dispMemberAdminAgreementsEdit").setQuery("parent_input_id", input.attr("id"))); - iframe.insertAfter(input); - input.siblings(".editor_preview").hide(); - if (input.attr("type") !== "hidden") { - input.hide(); - } - }; - - // Editor replacement - $(function() { - $(".editor_preview").on("click", function() { - var input = $(this).siblings(".editor_content"); - if (input.size()) { - $(this).off("click").off("focus"); - editor_replace(input.first()); - } - }); - $(".editor_preview").on("focus", function() { - $(this).triggerHandler("click"); - }); - }); - -})(jQuery);