Skip to content
abidibo edited this page Nov 7, 2011 · 4 revisions

This library contains some self written classes and functions. The main class is used to display a layer window over the document content. Such window may be resized or dragged and its contents may be filled through an ajax request, string passed or dom elemnt cloning. Then there are two other functions, one returns the viewport properties and the other the maximum z-index in the page. This library also set a window property (window.maxZindex) to use in all other javascript scripts.

##layerWindow class ###Methods
constructor
Syntax
var myLayerWindowInstance = new layerWindow([options]);
Arguments

  1. options - (object, optional) The options object.
    Options
  • id (string: default to null) The id attribute of the window container
  • bodyId (string: default to null) The id attribute of the body container
  • title (string: default to null) The window title
  • width (int: default to 400) The width in px of the window body
  • height (int: default to null) The height in px of the body. By default its value depends on contained text
  • minWidth (int: default to 300) The minimum width when resizing
  • minHeight (int: default to 100) The minimum height when resizing
  • maxHeight (int: default to viewport-height minus 100px) The max-height css property of the window body
  • draggable (bool: default to true) Whether or not to make the window draggable
  • resize (bool: default to true) Whether or not to make the window resizable
  • closeButtonUrl (string: default to null) The url of the image to use as close button
  • closeButtonLabel (string: default to close) The string to use as close button if the closeButtonUrl is null
  • destroyOnClose (bool: default to true) Whether or not to destroy all object properties when closing the window
  • overlay (bool: default to true) Whether or not to set a base overlay with opacity isolating the window from the below elements
  • url (string: default to null) The url to be called by ajax request to get initial window body content
  • htmlNode (mixed: default to null) The html node which content is injected into the window body. May be a node element or its id.
  • html (string: default to null) The initial html content of the window body if url is null
  • closeCallback (function: default to null) The function to be called when the window is closed
  • closeCallbackParam (mixed: default to null) The paramether to pass to the callback function when the window is closed
  • disableObjects (bool: default to false) Whether or not to hide objects when window is showed (and show them when window is closed)
  • reloadZindex (bool: default false) Whether or not to reload the max z-index present in the document when instantiating the class (useful if some javascript add elements with z-index property after the page has charged)

setTitle
sets the title of the window and updates it if the window is showed
Syntax
myLayerWindowInstance.setTitle(title);
Arguments

  1. title - (string) The title of the window

setHtml
sets the content of the window and updates it if the window is showed
Syntax
myLayerWindowInstance.setHtml(html);
Arguments

  1. html - (string) The html content of the window body

setUrl
sets the content of the window and updates it if the window is showed
Syntax
myLayerWindowInstance.setUrl(url);
Arguments

  1. url - (string) The url called by ajax request to get window body content

display
displays the window in the position pointed by the element passed, or by the given coordinates. If no element nor coordinates are given, the window is centered in the viewport.
Syntax
myLayerWindowInstance.display(el, [opt]);
Arguments

  1. el - (element) The element respect to which is rendered the window (top left of the window coincide with top left of the element)
  2. opt - (object) The top and left coordinates of the top left edge of the window. If only one is given the other is taken from the el passed

setFocus
sets focus on the object window, giving it the greatest z-index in the document
Syntax
myLayerWindowInstance.setFocus();

closeWindow
closes the window and destroyes the object properties if the option destroyOnClose is true
Syntax
myLayerWindowInstance.closeWindow();

##getViewport function Returns some viewport properties: width, height, left, top, center coordinates
Syntax
getViewport()
returns an array of properties:

  • (int) width: the width of the viewport
  • (int) height: the height of the viewport
  • (int) left: the left page offeset
  • (int) top: the top page offset
  • (float) cX: the x-axis coordinate of the center point
  • (float) cY: the y-axis coordinate of the center point

##getMaxZindex function returns the maximum z-index css property set in the document
Syntax
getMaxZindex()

Clone this wiki locally