Fix too many simultaneous requests on agreement edit screen

약관 에디터 iframe을 동시에 5개 띄우면서 과부하가 발생하는 문제 수정
This commit is contained in:
Kijin Sung 2017-11-30 23:23:07 +09:00
parent 04fbcdd514
commit e19c196a67
6 changed files with 65 additions and 23 deletions

View file

@ -164,24 +164,25 @@ class memberAdminView extends member
*/ */
public function dispMemberAdminAgreementsEdit() public function dispMemberAdminAgreementsEdit()
{ {
$agreement_id = intval(Context::get('id')); // Check parent input ID
Context::set('agreement_id', $agreement_id); $parent_input_id = Context::get('parent_input_id');
Context::set('agreement_content', getModel('member')->getMemberConfig()->agreements[$agreement_id]->content);
Context::addBodyClass('disable_debug_panel'); Context::addBodyClass('disable_debug_panel');
// Load editor
$oEditorModel = getModel('editor'); $oEditorModel = getModel('editor');
$option = $oEditorModel->getEditorConfig(); $option = $oEditorModel->getEditorConfig();
$option->primary_key_name = 'agreement_id'; $option->primary_key_name = 'primary_key';
$option->content_key_name = 'agreement_content'; $option->content_key_name = 'content';
$option->allow_fileupload = FALSE; $option->allow_fileupload = FALSE;
$option->enable_autosave = FALSE; $option->enable_autosave = FALSE;
$option->enable_default_component = TRUE; $option->enable_default_component = TRUE;
$option->enable_component = FALSE; $option->enable_component = FALSE;
$option->height = 300; $option->height = 300;
$option->editor_focus = 'N'; $option->editor_focus = 'Y';
$editor = $oEditorModel->getEditor($logged_info->member_srl, $option); $editor = $oEditorModel->getEditor(0, $option);
Context::set('editor', $editor); Context::set('editor', $editor);
// Set template
$this->setLayoutPath('./common/tpl/'); $this->setLayoutPath('./common/tpl/');
$this->setLayoutFile("default_layout"); $this->setLayoutFile("default_layout");
$this->setTemplateFile('agreements_edit'); $this->setTemplateFile('agreements_edit');

View file

@ -18,8 +18,8 @@
<div class="x_control-group"> <div class="x_control-group">
<div class="x_control-label">{$lang->cmd_agreement_content}</div> <div class="x_control-label">{$lang->cmd_agreement_content}</div>
<div class="x_controls"> <div class="x_controls">
<input type="hidden" name="agreement_{$i}_content" id="agreement_{$i}_content" value="{escape($config->agreements[$i]->content)}" /> <input type="hidden" class="editor_content" name="agreement_{$i}_content" id="agreement_{$i}_content" value="{escape($config->agreements[$i]->content)}" />
<iframe id="agreement_{$i}_iframe" class="agreement_iframe" src="{getUrl('act', 'dispMemberAdminAgreementsEdit', 'id', $i)}"></iframe> <div class="editor_preview xe_content" tabindex="0">{$config->agreements[$i]->content}</div>
</div> </div>
</div> </div>
<div class="x_control-group"> <div class="x_control-group">

View file

@ -2,27 +2,31 @@
$(function() { $(function() {
var editor; var editor;
var parent = window.opener ? window.opener : window.parent; var parent = window.opener ? window.opener : window.parent;
var parent_input = $("#{$parent_input_id}", parent.document);
var parent_iframe = parent_input.siblings("iframe.editor_iframe");
CKEDITOR.on('instanceReady', function(evt) { CKEDITOR.on('instanceReady', function(evt) {
editor = evt.editor; editor = evt.editor;
editor.setData(parent_input.val());
editor.on("resize", function(evt){ editor.on("resize", function(evt){
var height = evt.data.outerHeight; var height = evt.data.outerHeight;
$("#agreement_{$agreement_id}_iframe", parent.document).height(height); parent_iframe.height(height);
}); });
editor.on("change", function() { editor.on("change", function() {
var content = editor.getData(); var content = editor.getData();
$("#agreement_{$agreement_id}_content", parent.document).val(content); parent_input.val(content);
}); });
$("#agreement_{$agreement_id}_iframe", parent.document).height($(".cke_chrome").first().parent().height()); parent_iframe.height($(".cke_chrome").parent().height());
}); });
}); });
</script> </script>
<style> <style>
body { margin: 0; } body { margin: 0; }
.wfsr { display: none; }
</style> </style>
<form> <form>
<input type="hidden" name="agreement_id" id="agreement_id" value="{$agreement_id}" /> <input type="hidden" name="primary_key" id="primary_key" value="" />
<input type="hidden" name="agreement_content" id="agreement_content" value="{escape($agreement_content)}" /> <input type="hidden" name="content" id="content" value="" />
{$editor} {$editor}
</form> </form>

View file

@ -1,9 +1,22 @@
.agreement_iframe { .editor_preview {
display: inline-block;
width: 100%; width: 100%;
min-height: 240px;
max-height: 440px;
box-sizing: border-box; box-sizing: border-box;
margin-bottom: -4px; 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_iframe {
width: 100%;
height: 440px;
box-sizing: border-box;
margin: 0 0 -4px 0;
padding: 0; padding: 0;
border: 0; border: 0;
height: 440px;
} }

View file

@ -0,0 +1,29 @@
(function($) {
// Editor replacement callback function
var editor_replace = function(input) {
var iframe = $('<iframe class="editor_iframe"></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);

View file

@ -1,9 +1,4 @@
jQuery(function($){ jQuery(function($){
$('input[name=enable_join]').click(function(){
var checked = $('input[name=enable_join]:checked').val();
enableSignUpTab(checked == 'Y');
});
$('.__sync').click(function (){ $('.__sync').click(function (){
exec_xml( exec_xml(
'importer', // module 'importer', // module