在 CKEDitor 中最大化/调整对话框窗口大小

发布于 2024-08-20 20:31:31 字数 266 浏览 3 评论 0原文

我需要以编程方式最大化/调整 CKEditor IFrame 对话框的大小(即带有“确定”和“取消”按钮的 CKEditor 对话框,以及其余的 iframe)。我需要对话框保持在屏幕中央。

我只能看到调整窗口大小和重新定位窗口的函数,但要使用这些函数,我必须首先计算窗口尺寸才能将其重新居中。由于多种原因,这是愚蠢的,API 应该完全处理这个问题。

是否有官方 API 函数可以执行此操作,或者有安全的解决方法?

我可以使用 JQuery,但真的很想为此使用本机函数。

I need to programmatically maximize / resize a CKEditor IFrame dialog (i.e. a CKEditor dialog with an "ok" and "cancel" button, and an iframe in it for the rest). I would need the dialog to stay centered on the screen.

I can see only functions to resize and re-position the window, but to use those, I'd have to calculate the window dimensions first to re-center it. This is stupid for a number of reasons, the API should handle that completely.

Is there an official API function to do this, or a safe workaround?

I can use JQuery but would really like to use native functions for this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天涯离梦残月幽梦 2024-08-27 20:31:31

如果你同时调整大小和重新定位,那么执行一个功能并不难:(

它是伪 JavaScript,因为我没有时间完善它,所以基本上是想法)

function dialogResizeCentered (d,w,h){ //d-dialog, w,h-width, height
  var sw,sh; //screenwidth, screenheight
  var rx,ry; //null atm, for resize x, resize y
  get sw, sh from window. object
  rx = parseInt(sw/2-w/2);
  ry = parseInt(sh/2-h/2);
  d.call resize (w,h);
  d.call reposition(rx,ry);
}

然后任何时候你都可以调用 dialogResizeCentered(d,600,400);

或者?

或者,如果您希望对话框保持居中,我确信有类似 window.onResize 事件来调用此函数。

我希望我理解正确:)

If you have both resize AND re-position, it can't be that hard do one function:

(it's pseudo javascript, since i don't have time to polish it, so basically idea)

function dialogResizeCentered (d,w,h){ //d-dialog, w,h-width, height
  var sw,sh; //screenwidth, screenheight
  var rx,ry; //null atm, for resize x, resize y
  get sw, sh from window. object
  rx = parseInt(sw/2-w/2);
  ry = parseInt(sh/2-h/2);
  d.call resize (w,h);
  d.call reposition(rx,ry);
}

and then anytime you can just call dialogResizeCentered(d,600,400);

or?

Or if you want your dialog to stay centered, i'm sure there is something like window.onResize event to call this function.

I hope I understand correctly :)

橘和柠 2024-08-27 20:31:31

我自己使用 CKEditor,但选择使用 jquery 的 UI 对话框作为我的自定义对话框,因为它开箱即用更灵活且功能丰富,可在以下位置找到:

http://docs.jquery.com/UI/Dialog

但如果您更喜欢使用自定义 CKEditor 对话框,那么 jQuery 的position():

http://api.jquery.com/position/

height()、width() 和 offset() 是对于确定对话框的大小和位置非常有用:

http://api.jquery。 com/category/manipulation/style-properties/

I'm using CKEditor myself but have opted to use jquery's UI dialog for my custom dialogs as it is a lot more flexible and feature-rich out of the box, it's available at:

http://docs.jquery.com/UI/Dialog

But if you prefer on using a custom CKEditor dialog then jQuery's position():

http://api.jquery.com/position/

height(), width() and offset() are invaluable in determining the size and position of the dialog:

http://api.jquery.com/category/manipulation/style-properties/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文