Overview
Notes
Please read through the entire article and documents here and at http://blog.meyshan.com after that please check out the samples tab here. other than the samples listed here, you can also check http://developer.yahoo.com/ypatterns for more samples to be used in our site while you are developingWindow Class
Main class to handle windowsinitialize(id, options) Window constructor used when creating new window (new Window(id, options))
id DOM id of the window must be unique
options
Hash map of window options, here is the key list:
Key Default Description className dialog Class name prefix title none Window's title url none URL of window content (use an iframe) parent body Parent node of the window top | bottom top:0 Top or bottom position of the window in pixels right | left left:0 Right or left position of the window in pixels width / height 100 width and height of the window maxWidth / maxHeight none Maximum width and height of the window minWidth / minHeight 100/20 Minimum width and height of the window resizable true Specify if the window can be resized closable true Specify if the window can be closed minimizable true Specify if the window can be minimized maximizable true Specify if the window can be maximized draggable true Specify if the window can be moved showEffect Effect.Appear or
Element.showShow effect function. The default value depends if effect.js of script.aculo.us is included hideEffect Effect.Fade or
Element.hideHide effect function. The default value depends if effect.js of script.aculo.us is included showEffectOptions none Show effect options (see script.aculo.us documentation). hideEffectOptions none Hid effect options (see script.aculo.us documentation). effectOptions none Show and hide effect options (see script.aculo.us documentation). onload none Onload function of the main window div or iframe opacity 1 Window opacity
setDelegate(delegate) Sets window delegate
delegate Window delegate, should have canClose(window) function
setContent(id, autoresize, autoposition) Sets window content using an existing element (does not work woth url/iframe)
id Element id to insert in the window
autoresize (default false) Resizes the window to fit with its content
autoposition (default false) Sets the current window position to the specified input element
setAjaxContent(url, options, showCentered, showModal) Sets window content using an Ajax request. The request must return HTML code. See script.aculo.us Ajax.request documentation for details. When the response is received, the window is shown.
url Ajax request URL
options Ajax request options
showCentered (default false) Displays window centered when response is received
showModal (default false) Displays window in modal mode when response is received
setCookie(name, expires, path, domain, secure) Sets cookie informations to store window size and position
name (default window's id) Cookie name
expires, path, domain, secure Cookie attributes
setLocation(top, left) Sets window top-left position
top Top position in pixels
bottom Bottom position in pixels
updateWidth() Recompute window width, useful when you change window content and do not want scrolling
updateHeight() Recompute window height, useful when you change window content and do not want scrolling
showCenter(modal, top, left) Shows window in page's center. You can set top (or left) if you want to center only left (or top) value
modal (default false) top (default null) left (default null) Modal mode
Dialog module
Dialog factory to open alert/confirm/info modal panelsconfirm(content, options) Opens a modal dialog with two buttons (ok/cancel for example)
content
- If the content is a string, it will be the message displayed in the dialog (HTML code)
- If the content is an hash map, it will be used for setting content with an AJAX request. The hashmap must have url key and an optional options key (ajax options request)
options
Hash map of dialog options, here is the key list:
Key Default Description top null Top position left null Left position okLabel Ok Ok button label cancelLabel Cancel Cancel button label ok none Ok callback function called on ok button cancel none Cancel callback function called on ok button buttonClass none Ok/Cancel button css class name windowParameters (hash map) none Window constructor options
alert(content, options) Opens a modal alert with one button (ok for example)
content
- If the content is a string, it will be the message displayed in the dialog (HTML code)
- If the content is an hash map, it will be used for setting content with an AJAX request. The hashmap must have url key and an optional options key (ajax options request)
options
Hash map of dialog options, here is the key list:
Key Default Description top null Top position left null Left position okLabel Ok Ok button label okCallback none Ok callback function called on ok button buttonClass none Ok/Cancel button css class name windowParameters (hash map) none Window constructor options
info(content, options) Opens a modal info panel without any button. It can have a progress image (Used to display submit waiting message for example)
content
- If the content is a string, it will be the message displayed in the dialog (HTML code)
- If the content is an hash map, it will be used for setting content with an AJAX request. The hashmap must have url key and an optional options key (ajax options request)
options
Hash map of dialog options, here is the key list:
Key Default Description top null Top position left null Left position showProgress false Add a progress image (info found in the css file) windowParameters (hash map) none Window constructor options
setInfoMessage(message) Sets info message (Used to display waiting information like 32% done for example)
message New info message