Last active
February 17, 2017 06:03
-
-
Save punkmonday/4eb357f0b104f9b4f88487804663c0ea to your computer and use it in GitHub Desktop.
centerAndShowDialog.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function centerAndShowDialog(dialog) { | |
var c = Liferay.component(dialog); | |
//dialog show 之前设置一个固定高度,为了窗口居中 | |
AUI().Do.before(function () { | |
c.set("centered", true); | |
c.set("height", "70%"); | |
}, c, "show"); | |
//dialog show 之后,把高度设置为auto | |
AUI().Do.after(function () { | |
console.log("after"); | |
console.log(c.get("height")); | |
c.set("height", "auto"); | |
}, c, "show"); | |
c.show(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function centerAndShowDialog(dialog) | |
{ | |
$(dialog).css("top",Math.max(0,(($(window).height() - $(dialog).outerHeight()) / 2) + $(window).scrollTop()) + "px"); | |
$(dialog).css("left",Math.max(0, (($(window).width() - $(dialog).outerWidth()) / 2) + $(window).scrollLeft()) + "px"); | |
dialog.show(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment