Maximize / resize dialog box in CKEDitor

I need to programmatically maximize / resize the CKEditor IFrame dialog box (i.e. the CKEditor dialog box with the ok and cancel buttons) and iframe in it for the rest). I will need a dialogue to stay in the center of the screen.

I can only see functions for resizing and re-positioning the window, but to use them I need to first calculate the size of the window in order to re-center it. This is stupid for a number of reasons, the API must fully handle it.

Is there an official API function for this or a safe workaround?

I can use jQuery, but I would really like to use my own functions for this.

+3
source share
2 answers

If you have resizing and repositioning, it can't be that difficult to perform one function:

(this is pseudo javascript, since I don't have time to polish it, so basically an 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 dialogue to remain centered, I'm sure there is something like an event to call this function window.onResize.

I hope I understood correctly :)

+2
source

I myself use CKEditor, but decided to use the JQuery dialog for custom dialogs, since it is much more flexible and multi-functional out of the box, it is available at:

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/

+1

Source: https://habr.com/ru/post/1731886/


All Articles