PApp::ECMAScript - make javascript horrors less horrible
use PApp::ECMAScript;
Create a new object. Better use the init function.
init
Create a new global PApp::ECMAScript object, storing it in the (exported) variable $js, which should be shared between all modules for caching purposes. Consequently, this function should be called once in the request callback or in the global stylesheet.
$js
Return a unique identifier. This is useful when generating function names or other identifiers.
Escape the given string as required and return it (escape_string_sq will use single quotes to delimit the string, escape_string_dq will use double quotes). Remember that many browsers do not like quoting, so use the right function to minimize impact.
escape_string_sq
escape_string_dq
Add the given code fragment to the HTML/HEAD/SCRIPT section.
Mark the given code fragment as to be added to the html head section. The same fragment will only be added once.
Return the code to be put in the head section.
Add code that is run when the given event occurs. Event should be something like "window.onclick" or "document.onload".
Return javascript code that checks wether the code is running under netscape, netscape 4 (or higher), ie, ie4 (or higher) or ie5 (or higher), respectively.
Return wether the browser supports CSS.
Return the string that should be used to set the visibility attribute to "hidden" or "visible".
Return the name of the event object (either window.event or event).
Return code that finds the style object with the given name and returns it.
Return the window x or y coordinate from the current event relative to the current page.
Return the (approximate) height and width of the scrollable area, i.e. the inner width and height of the window.
This class manages floating cxx objects (i.e. objects with style invisible that can be shown, hidden, moved etc... using javascript).
Create a new layer object (does not output anything).
js => the javascript object to use (default $PApp::ECMAScript::js) id => the name (html id), default autogenerated content => the content of the layer/div element element => the element used for the layer
Return the current object id (optionally setting it).
Return the current object content (optionally setting it).
Return the javascript code used to create the (initially hidden) layer. The best place for this is the top of the document, just below the BODY tag, but that's not a requirement for working browsers ;)
Please note that all javascript code returned is not quoted, which is not a problem when outputting it directly since browsers actually EXPECT misquoted input, but it is a problem when you output strict html (xml) or want to feed this into an XSLT stylesheet, in which case you need to escape_html() the code first and use disable-output-escaping in your stylesheet to deliberatly create broken HTML on output.
escape_html()
disable-output-escaping
Return an expression that evaluates to the style object used by the code.
Return code to display the layer object at position ($x,$y) (which should be valid javascript expressions).
Same as howxy, but use the current mouse position as origin.
howxy
Return code to display the layer object.
Return code to hide the layer object.
PApp.
Marc Lehmann <schmorp@schmorp.de> http://home.schmorp.de/
To install PApp, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PApp
CPAN shell
perl -MCPAN -e shell install PApp
For more information on module installation, please visit the detailed CPAN module installation guide.