- Legend to Symbols

-
Interface ovi.mapsapi.dom.Page
The Page class is a special abstract interface, it must be used as a query for a document or a DOM node and will return an object that implements the Page interface and is bound to the supplied document or to the document of the supplied DOM node. Example:
// Query page support for the document.
var page = ovi.mapsapi.dom.Page(document);
// Query page support for the document of a DOM node.
var node = document.getElementById("foo");
page = ovi.mapsapi.dom.Page( node );
The page interface itself offers access to the document. It supplies a large amount of helper methods and enables the ovi.mapsapi.dom aligned event handling for all DOM nodes attached to the document for which it's support is queried. Therefore, before casting a DOM node into an ovi.mapsapi.dom.EventTarget it is recommented to at least once query the page interface for this document.
Note: Unlike the ovi.mapsapi.dom.EventTarget this class will not modify any DOM node it is
queried upon and it will only attach one property to the document to which it is bound with the name
$jslPage. This means as well that you'll always have to query a document or DOM node for the
object implementing the Page interface.
However, the query is very fast, except being done the first time, because the first time a corresponding object implementing the Page inteface must be created and bound to the document, which means that certain listeners must be registered with the document and some methods will be created internally. Every further cast to the Page interface will be no more then just returning this existing object.
Details
The dom package facilitates the cross browser event handling and simplifies the creation of custom events as well as that it supplies information about the browser, operating system and offers a set of helper methods.
The package persists out of the four main classes ovi.mapsapi.dom.Page, ovi.mapsapi.dom.Event, ovi.mapsapi.dom.EventTarget and ovi.mapsapi.dom.DataTransfer. The major class within the package is the the ovi.mapsapi.dom.Page class which offers the abstraction of native browser events and offers the most of the functionality of the package. The other classes are mostly helper classes. The package offers cross browser W3C standard compliant event handling including some de facto standards like touch and gesture events.
Which events are supported and what there meaning is, is documented within the different abstract pseudo
event target classes:
* ovi.mapsapi.dom.TouchEventTarget
* ovi.mapsapi.dom.DragEventTarget
* ovi.mapsapi.dom.MouseEventTarget
* ovi.mapsapi.dom.KeyboardEventTarget
* ovi.mapsapi.dom.FocusEventTarget
Note: These interfaces do not exist, they are for documentational purpose only and they will be used by
classes to document which event the objects of this class support. However, it should be clear that because of
the design of the event handling it is always possible that an object receives additional undocumented events.
Event handling
The event handling itself is very simple and mostly W3C compatible, but it must be activated for native DOM nodes before being used. The reason is to prevent collisions with other frameworks that might been used together with this API. To add the support for aligned events to a DOM node the ovi.mapsapi.dom.EventTarget interface must be applied upon this DOM node. This can be done by simply casting the DOM node into an ovi.mapsapi.dom.EventTarget, as the following example shows:
// Create a few shortcuts.
var Page = ovi.mapsapi.dom.Page,
EventTarget = ovi.mapsapi.dom.EventTarget;
// Query page support for the document. This is very important, but needs only
// to be done once. However, doing it multiple times will not harm.
Page(document);
// Attach EventTarget interface to the document to allow aligned events at the document.
EventTarget(document);
// Add a listener for the click event to the document and show an alert,
// if the document is clicked.
document.addListener("click", function(evt) {
alert( evt.type );
// Unregister ourself, so that only once an alert is shown.
document.removeListener("click", arguments.callee, false);
}, false);
The most events are quite self explaining and the syntax to register or unregister listeners is simlar to the
W3C standard methods addEventListener, removeEventListener and
dispatchEvent, except that the aligned methods will not contain the "event" word, so they are
called addListener, removeListener and dispatch.
null.
var page = ovi.mapsapi.dom.Page(document);
var node = page.createElement("DIV", {
backgroundColor: "rgb(255,0,0)",
width: "200px",
height: "200px"
});
It is as well possible to create a node with specific attributes and style:
var page = ovi.mapsapi.dom.Page(document);
var node = page.createElement({
tagName: "CANVAS",
width: 200,
height: 200,
style: {
position: "absolute",
top: "0px",
left: "0px",
width: "200px",
height: "200px"
}
});
| {String | Object} | tagName |
The tag name of the DOM node to be created or an object where the key tagName contains the
tag name of the DOM node to be created and other keys reflect other properties of the node. The property
style will be used to declare the style sheet, however, if the additional style parameter is
as well supplied this will overwrite an style being defined within the supplied object.
|
| {Object} | [style]: | The style properties to be set in the node. |
| {Node} | The node. |
| {Node} | node | The DOM node for which the document page position should be returned. |
| {Object} | The position of the node within the document (left, top, right, bottom, width and height properties for the client bounds) or null if the detection failed or the given node is no valid DOM node. |
| {Object} | e | The native event object of the browser. |
| {ovi.mapsapi.dom.Event} | A normalized DOM level 3 event object. |
var page = ovi.mapsapi.dom.Page(document);
var node = document.createElement("DIV");
page.setStyle(node, {
backgroundColor: "rgb(255,0,0)",
width: "200px",
height: "200px"
});
Note that the above example could have been done more efficient by directly using the createElement
method from the page interface.
| {Node} | node | The DOM node for which the style properties should be set. |
| {Object} | style | The style properties to be set in the node. |
| {Node} | The node. |
| {ovi.mapsapi.dom.Page} | Returns the page object itself (this). |
HINT: It's always better to look for the feature instead for the browser!
HINT: Do completely disable native drag and drop support, set the property "dnd" to false!
if (ovi.mapsapi.dom.Page.browser.mozilla) {
// code applicable to Mozilla here
} else {
// Code for non-Mozilla browsers here
}
The rotation is in degrees clockwise, so a value of 0 means portrait mode with normal device screen, 90 degrees means landscape mode with the device screen turned clockwise by 90 degrees, 180 means portrait mode with the device screen turned around by 180 degrees clockwise and finally 270 degrees means the device screen is in landscape mode with the screen turned around by 270 degrees clockwise.
Note: These values differ from those reported natively (e.g., the iPhone), but they are easier to handle for developers as it's simply the clockwise rotation.
HINT: It's always better to look for the feature instead for the browser!
if (ovi.mapsapi.dom.Page.platform.linux) {
// code applicable to Linux here
} else {
// non-Linux code here
}