yana

phpDocumentor v 1.4.0

/skins/default/scripts/default.inc

Description

«JavaScript» common functions
This file provides some basic JavaScript functions used for various features of the Yana framework.

Functions

«JavaScript» show html preview of a text
void preview (
string $target, string $source
)
List of parameters:
Name Type Description
$target string
$source string
Description:
Note that this function is deprecated. You should use the template function [%preview%] instead.
  • deprecated: since 2.9.3
  • access: public
  • name: preview()
«JavaScript» add a custom event listener to a HTML node
bool yanaAddEventListener (
string $eventType, function $userFunction, string|HtmlNode $node, bool $silent
)
List of parameters:
Name Type Description
$eventType string e.g. 'onchange', 'onmouseover', aso.
$userFunction function some user function
$node string|HtmlNode a tag name, like 'input', or a HTML node, like document.forms[0]
$silent bool mute warning for proprietary event types
Description:
This registers an user defined javascript event listener.
This function allows you to:
  1. add multiple event listeners for the same node and event type (e.g. you can set forms[0].onsubmit to trigger multiple functions)
  2. add an event listener to all tags of a certain name (e.g. add an input handling function to the "onchange" event of all textarea tags)
The argument $eventType defines the type of event to subscribe to. It can be any of the following:
  1. onabort
  2. onblur
  3. onchange
  4. onclick
  5. ondblclick
  6. onerror
  7. onfocus
  8. onkeydown
  9. onkeypress
  10. onkeyup
  11. onload
  12. onmousedown
  13. onmousemove
  14. onmouseout
  15. onmouseover
  16. onmouseup
  17. onreset
  18. onselect
  19. onsubmit
  20. onunload
Note that - even though you may set an event handler on any node - some of them are limited to certain tags. E.g. "onsubmit" is limited to "form" tags. See your favourite JavaScript reference for more details.
You are best adviced NOT to use proprietary event types like "ondrag" or "oncontextmenu". However: if you do, the function will present you with a warning. To surpress this warning, set the argument $silent to bool(true).
The argument $userFunction is an existing function name. Note that this function will be given 2 arguments. The first is the event object. The second is a reference to the target node. (While you may also get the target node using event.target in Firefox and Opera, this is not supported in Internet Explorer. So this should work in both)
A brief example:
  1.  function myEventHandler($event$node)
  2.  {
  3.      if ($event.type == 'change'{
  4.          alert("New value = " $node.value);
  5.          return true;
  6.      else {
  7.          return false;
  8.      }
  9.  }
  10.  yanaAddEventListener('onchange'myEventHandler'textarea');
Note that returning bool(false) will stop propagation of the event.
The argument $node has 2 synopsis.
  1. If $node is a node object, like document.forms[0], the event listener listens to events on this node only.
  2. If $node is a tag name, like 'form', the event listener listens to all nodes which have the specified tag name.
Note that this function respects event handlers defined in the HTML code.
Where multiple event handlers are present, the behaviour is as follows:
  1. call event handler defined in HTML code (if any)
  2. call any user defined event handler in the order in which they were registered
Note: if any of the called functions return a value that evaluates to bool(false), the event handler will stop propagation of the event and return bool(false). E.g. when handling form.onsubmit with multiple functions, that all checking the form's contents, then the form will not submit if ANY of the included checks fails.
Returns bool(true) on success and bool(false) on error.
  • since: 2.9.6
  • access: public
  • name: yanaAddEventListener()
«JavaScript» add an emot. icon to message pane
void yanaAddIcon (
string $icon, [event $event = null]
)
List of parameters:
Name Type Description
$icon string
$event event event object
Description:
This inserts the text $icon in the currently selected textarea field.
If the second argument is an event object, the function will prevent it from firing the default event handler. This argument is optional.
You may also want to see the manual on chapter "templates and skins: new functions - smilies" (toc might be subject to change)
  • access: public
  • name: yanaAddIcon()
«JavaScript» check for correct syntax of embedded tags in all textarea fields
bool yanaCheckEmbTags (
event $event, HtmlNode $formNode, bool $silent
)
List of parameters:
Name Type Description
$event event (ignored)
$formNode HtmlNode HTML form to check
$silent bool mute warning for syntax errors
Description:
Call this on a HTML form to check all included fields. This function will issue a warning to the user, if a textarea field contains an error and ask the user to confirm, if he wants to proceed anyway. You may mute this warning by setting $silent to bool(true).
Returns bool(true) if all fields are valid (or the user confirms to proceed with errors) and bool(false) otherwise.
Example of usage:
  1.  <form onsubmit="return yanaCheckEmbTags(event, this, false)">
  • since: 2.9.6
  • access: public
  • name: yanaAddEventListener()
«JavaScript» close all nodes of a html-menu
void yanaCloseAll ()
Description:
see the manual on chapter "skins and templates: expandable HTML-menues" (toc might be subject to change)
  • access: public
  • name: yanaCloseAll()
«JavaScript» get a cookie-var
mixed yanaGetCookie (
[string $key = null]
)
List of parameters:
Name Type Description
$key string name
Description:
Returns the cookie's content.
If $key is not provided, it returns all values as an associative array, with names of the entries being the keys.
Else the value with the name $key is returned instead. If the value does not exist, the constant NULL is returned.
  • access: public
  • name: yanaGetCookie()
«JavaScript» return all elements that match a given class name
array yanaGetElementsByClassName (
string $className, [HtmlNode $node = 'document.body']
)
List of parameters:
Name Type Description
$className string name of class attribute
$node HtmlNode root node
Description:
This function returns a node list containing all nodes, whose class name is equal to the one given.
Note: this function may also be called as document.getElementsByClassName($className) - if no such function exists, it is created.
This is meant to be an addition to the well known standard functions getElementById() and getElementsByTagName().
The second argument allows you to use any other root node then document.body, which makes you able to search through sub-trees.
  • since: 2.9.6
  • access: public
  • name: yanaGetElementsByClassName()
«JavaScript» check if a string in a textarea field exceeds the maximum length
bool yanaMaxLength (
TextareaNode $node, int $length, event $event
)
List of parameters:
Name Type Description
$node TextareaNode node that should be checked
$length int maximum length
$event event event of type 'keypress'
Description:
Returns bool(false) if maximum length is exceeded and bool(true) otherwise.
  • access: public
  • name: yanaMaxLength()
«JavaScript» open / close a node of a html-menu
void yanaMenu (
HtmlNode $node, string $defaultDisplay
)
List of parameters:
Name Type Description
$node HtmlNode
$defaultDisplay string should be 'none' or 'block', defaults to 'block'
Description:
This function is used for userdefined, vertical treemenus in HTML. It opens or closes a folder, depending on it's current state.
An example HTML code for such menu is included in the documentation of template functions. See the manual on chapter "skins and templates: expandable HTML-menues". (toc might be subject to change)
  • access: public
  • name: yanaMenu()
«JavaScript» restore or remember which menu items are opened or closed
void yanaMenuCookie (
bool $set
)
List of parameters:
Name Type Description
$set bool true = remember items, false = restore items
Description:
  • access: public
  • name: yanaMenuCookie()
«JavaScript» set a cookie-var
bool yanaSetCookie (
string $key, string $val
)
List of parameters:
Name Type Description
$key string name
$val string value
Description:
Set the var identified by $key to the new value $val. Returns bool(true) on success and bool(false) on error.
  • access: public
  • name: yanaSetCookie()

Documentation generated on Sat, 03 Jan 2009 22:22:37 +0100 by phpDocumentor 1.4.0

yana author: Thomas MeyerHomepage: www.yanaframework.net