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()
{
$agreement_id = intval(Context::get('id'));
Context::set('agreement_id', $agreement_id);
Context::set('agreement_content', getModel('member')->getMemberConfig()->agreements[$agreement_id]->content);
// 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->primary_key_name = 'agreement_id';
$option->content_key_name = 'agreement_content';
$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 = 'N';
$editor = $oEditorModel->getEditor($logged_info->member_srl, $option);
$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');

View file

@ -18,8 +18,8 @@
<div class="x_control-group">
<div class="x_control-label">{$lang->cmd_agreement_content}</div>
<div class="x_controls">
<input type="hidden" 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>
<input type="hidden" class="editor_content" name="agreement_{$i}_content" id="agreement_{$i}_content" value="{escape($config->agreements[$i]->content)}" />
<div class="editor_preview xe_content" tabindex="0">{$config->agreements[$i]->content}</div>
</div>
</div>
<div class="x_control-group">

View file

@ -2,27 +2,31 @@
$(function() {
var editor;
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) {
editor = evt.editor;
editor.setData(parent_input.val());
editor.on("resize", function(evt){
var height = evt.data.outerHeight;
$("#agreement_{$agreement_id}_iframe", parent.document).height(height);
parent_iframe.height(height);
});
editor.on("change", function() {
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>
<style>
body { margin: 0; }
.wfsr { display: none; }
</style>
<form>
<input type="hidden" name="agreement_id" id="agreement_id" value="{$agreement_id}" />
<input type="hidden" name="agreement_content" id="agreement_content" value="{escape($agreement_content)}" />
<input type="hidden" name="primary_key" id="primary_key" value="" />
<input type="hidden" name="content" id="content" value="" />
{$editor}
</form>

View file

@ -1,9 +1,22 @@
.agreement_iframe {
display: inline-block;
.editor_preview {
width: 100%;
min-height: 240px;
max-height: 440px;
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;
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($){
$('input[name=enable_join]').click(function(){
var checked = $('input[name=enable_join]:checked').val();
enableSignUpTab(checked == 'Y');
});
$('.__sync').click(function (){
exec_xml(
'importer', // module