From 5868bc19fcbbfef18b0d011cd53b611a9e1086e9 Mon Sep 17 00:00:00 2001 From: MinSoo Kim Date: Tue, 26 Jan 2016 19:21:08 +0900 Subject: [PATCH] =?UTF-8?q?common.js=20=EC=9D=98=20setFixedPopupSize=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 화면 크기를 벗어나서 리사이징 되지 않도록 수정. --- common/js/common.js | 18 ++++++++++++++++-- .../components/poll_maker/tpl/popup.min.js | 1 - 2 files changed, 16 insertions(+), 3 deletions(-) delete mode 100644 modules/editor/components/poll_maker/tpl/popup.min.js diff --git a/common/js/common.js b/common/js/common.js index 340f09f4b..7239253e8 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -476,23 +476,37 @@ function zbxe_folder_close(id) { * popup_layout 에서 window.onload 시 자동 요청됨. **/ function setFixedPopupSize() { - var $ = jQuery, $win = $(window), $pc = $('body>.popup'), w, h, dw, dh, offset; + var $ = jQuery, $win = $(window), $pc = $('body>.popup'), w, h, dw, dh, offset, scbw; + + var $outer = $('
').css({visibility: 'hidden', width: 100, overflow: 'scroll'}).appendTo('body'), + widthWithScroll = $('
').css({width: '100%'}).appendTo($outer).outerWidth(); + $outer.remove(); + scbw = 100 - widthWithScroll; offset = $pc.css({overflow:'scroll'}).offset(); w = $pc.width(10).height(10000).get(0).scrollWidth + offset.left*2; - h = $pc.height(10).width(10000).get(0).scrollHeight + offset.top*2; + // 높이는 스크린의 높이보다 클 수 없다. 스크린의 높이와 내용의 높이를 비교해서 최소값을 이용한다. + h = Math.min($pc.height(10).width(10000).get(0).scrollHeight, screen.height-200) + offset.top*2; if(w < 800) w = 800 + offset.left*2; + dw = $win.width(); dh = $win.height(); if(w != dw) window.resizeBy(w - dw, 0); + // 스크린 높이에 한정된 경우 스크롤이 생기기 때문에 스크롤 높이를 고려해서 다시 조정해준다. + if(h === screen.height - 200 + offset.top*2) { + window.resizeBy(scbw, 0); + } if(h != dh) window.resizeBy(0, h - dh); $pc.width(w-offset.left*2).css({overflow:'',height:''}); } +function getScrollBarWidth () { + +}; /** * @brief 추천/비추천,스크랩,신고기능등 특정 srl에 대한 특정 module/action을 호출하는 함수 diff --git a/modules/editor/components/poll_maker/tpl/popup.min.js b/modules/editor/components/poll_maker/tpl/popup.min.js deleted file mode 100644 index a4c5ace62..000000000 --- a/modules/editor/components/poll_maker/tpl/popup.min.js +++ /dev/null @@ -1 +0,0 @@ -function completeInsertPoll(e){if("undefined"==typeof opener)return null;var t=get_by_id("fo_component"),o=t.skin.options[t.skin.selectedIndex].value,n=e.poll_srl;if(!n)return null;var l='';alert(e.message),opener.editorFocus(opener.editorPrevSrl);var i=opener.editorGetIFrame(opener.editorPrevSrl);return opener.editorReplaceHTML(i,l),opener.editorFocus(opener.editorPrevSrl),window.close(),null}jQuery(function(e){function t(){var t=e(".poll_box");$inputs=t.find("input"),poll_idx=0,$inputs.attr("name",function(e,t){return/^checkcount_/.test(t)&&poll_idx++,t.replace(/^([a-z]+_)(?:tidx|\d+)/,"$1"+poll_idx)}),t.length>1?t.find("button._del_poll").show():t.find("button._del_poll").hide()}function o(){var o=e("#poll_source");o.before(o.clone(!0).removeAttr("id").addClass("poll_box").css("display","block")),t()}var n;return n=e(opener.editorPrevNode),n.length&&"poll_maker"==n.attr("editor_component")?(alert(msg_poll_cannot_modify),window.close()):(e("#add_poll").click(function(){o(),setFixedPopupSize()}),e("button._add_item").click(function(){var t,o,n;t=e(this).prev().children("table").find(">tbody>tr:last"),o=t.clone(),match=t.find("td>input").attr("name").match(/item_(\d+)_(\d+)$/),match&&(match[2]++,(n=o.find("th")).html(n.html().replace(/ \d+/," "+match[2])),o.find("td>input").attr("name","item_"+match[1]+"_"+match[2]),t.after(o),setFixedPopupSize())}),e("button._del_item").click(function(){var t,o;t=e(this).prevAll("div").children("table").find(">tbody>tr:last"),o=t.find("td>input").attr("name").match(/item_(\d+)_(\d+)/),o&&2!=o[2]&&(t.remove(),setFixedPopupSize())}),e("button._del_poll").click(function(){e(this).parent(".poll_box").remove(),t()}),void o())}),jQuery(window).load(setFixedPopupSize); \ No newline at end of file