The base for all components. An empty component providing basic, essential functionality.
The component is extended by wax.EventHandler to give it event handling capabilities.
Determines the flexibility of the element, which is the amount of space it 'grabs' when placed inside a wax.Box, expressed in ratio form. For example, if a box contains an element with flex 2, and another with flex 1, the first element will get twice the size as the second one: two thirds and one third of the total available space, respectively.
The attribute can take both integer and rational values. With a value of 0 the element is declared non-flexible, and will retain its full size, unaffected by changes on the box (useful on toolbars, status bars, etc). The default value is 1.
Gets or sets the tooltip text for the element (displayed when the mouse hovers over an element, equivalent to the HTML title attribute, or alt on some browsers).
Determines wether the object is displayed (true) or hidden (false). If hidden, the display style of the object is set to none; when visible, the style is given the appropiate value matching the element's tag.
When set to true, the element doesn't react to user interaction.
Determines if the element can be dragged to start a drag and drop operation. The actual dragged item doesn't need to be the element itself, and is determined by the element's getDragElem method.
A reference to an instance of wax.Menu (or a derived component) that will be popped up when the user requests a context menu on the element (usually by right-clicking it). If set to null, the default context menu provided by the browser is raised.
Indicates the item where content added to the element is appended. An item is declared to be the item's container by giving it an id of 'content'. If there's no container item, the element itself is returned (which means content will be directly appended to the element's root).
internal | boolean | Indicates wether to select the container for anonymous content or for internal items (which in practice returns the element itself). |
Appends the given child element to the element's container, indicated by getContainer. The child can be added as content, or as an structural part of the element.
child | element | The child element that is to be appended to the element. |
internal | boolean | If set to true, the child is added as an inner part of the element. It will be ignored when counting the items inside the element, emptying content, etc. For all purposes, it will be considered a structural block of the element. |
Removes the element from its owner.
This method is called recursively on all elements every time they are affected by a layout change, so that they can react to it and readjust their size and position. The default implementation does nothing more than calling itself recursively on all items inside the element (wether internal or content). It's up to each subclass to extend this behavior.
Removes all content items from the element.
internal | boolean | If set to true, internal items are removed as well, and the element is totally emptied. |
Increments the element's z-index to match the one from the currently most prominent element, so that it doesn't get overlapped by other elements.
Indicates if the given element is an ancestor of the element.
ancestor | element | A reference to the possible ancestor element. |
Calculates the horizontal coordinate of the element (in pixels), relative to the whole document.
Calculates the vertical coordinate of the element (in pixels), relative to the whole document.
Calculates the horizontal coordinate of the mouse cursor (in pixels), relative to the element.
e | event | A mouse event object. |
Calculates the vertical coordinate of the mouse cursor (in pixels), relative to the element.
e | event | A mouse event object. |
Used to determine wether a dragged element can be dropped on the element. For example, if you want an element to discard all dropped elements except for a certain component, you can do:
element.acceptDrop = function (elem) { return (elem.component == myComponent); }
elem | element | The currently dragged element. |
src | element | The element that started the drag and drop operation. |
Starts a drag and drop operation on the object, dragging the element returned by getDragElem.
e | event | A mouse event object, used to calculate dragging offsets. |
Returns the element that should be dragged when a drag and drop operation is started on the element. By default it returns the element itself.