autosized 属性を持つポップアップがあります。パネルには、検索、検索ボタン、データテーブル、およびデータスクローラーのフィールドが含まれています。検索ボタンを押すか、データスクローラーでページを選択すると、javascriptが呼び出されます。Javascript は、ポップアップをブラウザーの表示領域の中央に移動するために使用されます。ポップアップが既に移動されている場合、ポップアップの影が前のパネル位置に留まることを除いて、すべて正常に動作します。
ボタンコード:
<a4j:commandButton id="searchButton"
value="#{msg.search}"
action="#{chAction.searchSegments}"
styleClass="richButton"
render="clientCategoryCandidateTable"
oncomplete="centerPanel();" />
Javascript:
function centerPanel() {
var modalPanel = #{rich:component('addToSegmentsPanel')};
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupWidth = modalPanel.width();
var popupHeight = modalPanel.height();
modalPanel.setLeft(Math.max(0, (windowWidth-popupWidth)/2));
modalPanel.setTop(Math.max(0, (windowHeight-popupHeight)/2));
};
別のバージョンのjavascriptを試しましたが、同じ副作用があります:
function centerPopup() {
var popup = #{rich:component('addToSegmentsPanel')};
popup.moveTo(Math.max(0, (window.innerWidth-popup.width())/2),
Math.max(0, (window.innerHeight-popup.height())/2));
};
スクリーンショット:
助けやコメントをありがとう。