basic.js

Summary
basic.js
Variables
ngLibsURLDefault main URL location of the libraries.
ngHTTPProtocolUsed protocol (http:// or https://).
ngEmptyURLURL to non-existent content.
ngOperaTRUE if user is using the Opera browser.
ngOperaVersionFloat number identifying Opera browser version
ngIExplorerTRUE if user is using the Internet Explorer browser.
ngIExplorerVersionVersion of the Internet Explorer browser.
ngIExplorer6TRUE if user is using the Internet Explorer version 6 or lower.
ngFireFoxTRUE if user is using the Firefox browser.
ngFireFoxVersionVersion of the Firefox browser.
ngFireFox1xTRUE if user is using the Firefox browser version 1.x.
ngFireFox2xTRUE if user is using the Firefox browser version 2.x.
ngChromeTRUE if user is using the Chrome browser.
ngSafariTRUE if user is using the Safari browser.
ngAndroidTRUE if device uses Android OS.
ngiOSTRUE if device uses Apple iOS.
ngWindowsPhoneTRUE if device uses Windows Phone OS.
ngFireFoxOSTRUE if device uses FireFox OS.
ngCordovaTRUE if running inside Apache Cordova (PhoneGap)
ngWinStoreAppTRUE if running as Windows Store App
ngSupportsTouchTRUE if browser supports touch.
ngUsingTouchTRUE if user uses touch as a primary input.
ngFirebugTRUE if Firebug present (useful for debug informations).
Debug Functions
Functions
ngASSERTChecks the given assertion and displays description if assertion is FALSE and debug is enabled.
ngDEBUGLOGDisplays log message in console if debug is enabled.
ngDEBUGWARNDisplays warning message in console if debug is enabled.
ngDEBUGERRORDisplays error message in console if debug is enabled.
ngHASDEBUGTests if debug is enabled.
Helper Functions
Functions
ngHammerJSChecks if HammerJS library is present.
ngPtrStartEventsGets input pointer start events (mousedown, touchstart, ...)
ngPtrHTMLStartEventsRenders supported pointer start events as HTML (onmousedown, ontouchstart, ...)
Variables
ngURLParamsParsed URL parameters.
ngURLDefaultEscapingDefines default URL escaping scheme.
ngURLSafeCharsURL safe chars.
ngHashSafeCharsHash(fragment) safe chars These characters aren’t encoded in function <ng_HashEncode>.
ScreenPtThis class represents screen point.
Properties
xScreen X coordinate.
yScreen Y coordinate.
ngValSubstitutes undefined values with defaults.
ngNullValSubstitutes undefined or null values with defaults.
ngLibPathGets client library path.
ngLibVersionGets client library version.
ng_PreloadImagePre-loads image into browser’s memory.
ng_PreloadImagesBeginStarts preloading images block.
ng_PreloadImagesEndEnds preloading images block and call callback function after all images are loaded.
ng_ReloadImageRe-loads image in browser’s memory.
ng_AddURLParamAdds new parameter(s) to URL.
ng_StripURLParamsStrip parameters from URL.
ng_URLHandles platform specific URL.
ng_unescapeJavaScript unescape with proper handling of plus (+) character.
ng_htmlEncodeEncodes special HTML characters (&, <, >, “) to its HTML form.
ng_htmlDecodeDecode special HTML characters and remove HTML tags (&amp;, &lt;, &gt;, &quot;) to its native form.
ng_sprintfFormats string (PHP like sprintf function).
ng_URLEncodeEncodes special characters in URL.
ng_HashEncodeEncodes special characters in hash(fragment) part of URL.
ng_UTF8EncodeEncodes characters in url to utf-8 representation.
ng_UTF8DecodeJavaScript decode URI with characters in utf-8 representation.
ng_UTF8ParamEncodeEncodes characters in URI parameter to utf-8 representation.
ng_UTF8ParamDecodeJavaScript decode URI parameter in utf-8 representation.
ng_inDOMDetermines if element is present in browser’s document object model (DOM).
ng_WindowWidthReturns window width.
ng_WindowHeightReturns window height.
ng_SetInnerHTMLHandles platform specific setting of element’s innerHTML.
ng_AppendInnerHTMLAppends text to element’s innerHTML.
ng_DocumentDeselectRemoves document selection.
ng_DocumentScrollXGets actual document horizontal scroll offset.
ng_DocumentScrollYGets actual document vertical scroll offset.
ng_findPosXDetermines horizontal offset of the element relative to its super parent.
ng_findPosYDetermines vertical offset of the element relative to its super parent.
ng_findMousePosXDetermines horizontal element offset to absolute mouse position.
ng_findMousePosYDetermines vertical element offset to absolute mouse position.
ng_ParentPositionDetermines absolute position to parent object or document.
ng_nullAttrDetermines if element attribute is not defined.
ng_GetCurrentStyleGets current (computed) style of element.
ng_BeginMeasureElementPrepares element for dimension measurement.
ng_EndMeasureElementFinishes element dimension measurement.
ng_GetCurrentStylePxExtracts pixels value from current (computed) style of element.
ng_StyleWidthGets element width defined by style property.
ng_StyleHeightGets element height defined by style property.
ng_SetStyleWidthSets element width defined by style property.
ng_SetStyleHeightSets element height defined by style property.
ng_OuterWidthGets element outer width.
ng_OuterHeightGets element outer height.
ng_SetOuterWidthSets element outer width.
ng_SetOuterHeightSets element outer height.
ng_ClientWidthGets element client width.
ng_ClientHeightGets element client height.
ng_SetClientWidthSets element client width.
ng_SetClientHeightSets element client height.
ng_setLeftTopSets element left, top.
ng_setBoundsSets element left, top, width and height.
ng_GETGets value of page URL parameter.
ng_GetURLSafeCharsEncodedGets array, where keys are url encoded URL safe chars (RFC1738) and values are just URL safe chars
ng_RedirectRedirects user to specified URL.
ng_InIFRAMETests if page is opened in IFRAME.
ng_SetByRefSets value as reference into object property.
ng_SetByValSets copy of given value into object property.
ng_CopyVarCreates true copy of variable.
ng_MergeVarMerges two variables.
ng_CleanUndefinedRemoves all undefined properties in object.
ng_VarEqualsTests if value of one variable equals to value of second variable.
ng_IsArrayVarDetects if variable is indexed array.
ng_EmptyVarDetects if variable is empty (not set).
ngAddEventAdds new function to existing event handler (callback).
ngRPCRemote Procedure Call.
Properties
nocacheIf TRUE, unique timestamp is added to every request to prevent caching of results.
TypeType of RPC call.
integerDefault value: rpcAuto
HTTPMethodUsed http method (if http request).
stringDefault value: ’’ (autodetect)
URLDefault RPC URL.
stringDefault value: ’’
ParamsRPC Parameters.
objectDefault value: { }
Methods
SetParamSets request parameter.
GetParamGets value of request parameter.
sendRequestSends request to the server.
clearParamsClears RPC parameters.
Events
AddEventAdds new function to the event handler (callback).
RemoveEventRemoves function from the event handler (callback).
OnEncodeParam
OnRequest
OnSendRequest
OnRequestSent
OnIFrameRequest
OnHTTPRequest
OnHTTPReadyStateChanged
OnHTTPRequestFailed
OnReceivedJSON
OnReceivedData
ngRDSRemote Data Service based on ngRPC class.
ngStringBuilderThis class realizes fast concatenation of strings.
Functions
appendAppends the given value to the end of this instance.
clearClears the string buffer.
emptyTests if string buffer is empty.
toStringConverts this instance to a String.

Variables

ngLibsURL

Default main URL location of the libraries.  If not specified the URL is automaticaly detected based on location of ng_basic library or controls.js script.

ngHTTPProtocol

var ngHTTPProtocol

Used protocol (http:// or https://).

ngEmptyURL

URL to non-existent content.

Usually used for reseting image URL.

Default value: ngLibPath(‘ng_basic’, ‘empty.gif?nop’);

ngOpera

var ngOpera

TRUE if user is using the Opera browser.

ngOperaVersion

var ngOperaVersion

Float number identifying Opera browser version

ngIExplorer

var ngIExplorer

TRUE if user is using the Internet Explorer browser.

ngIExplorerVersion

var ngIExplorerVersion

Version of the Internet Explorer browser.

ngIExplorer6

var ngIExplorer6

TRUE if user is using the Internet Explorer version 6 or lower.

ngFireFox

var ngFireFox

TRUE if user is using the Firefox browser.

ngFireFoxVersion

var ngFireFoxVersion

Version of the Firefox browser.

ngFireFox1x

var ngFireFox1x

TRUE if user is using the Firefox browser version 1.x.

ngFireFox2x

var ngFireFox2x

TRUE if user is using the Firefox browser version 2.x.

ngChrome

var ngChrome

TRUE if user is using the Chrome browser.

ngSafari

var ngSafari

TRUE if user is using the Safari browser.

ngAndroid

var ngAndroid

TRUE if device uses Android OS.

ngiOS

var ngiOS

TRUE if device uses Apple iOS.

ngWindowsPhone

var ngWindowsPhone

TRUE if device uses Windows Phone OS.

ngFireFoxOS

var ngFireFoxOS

TRUE if device uses FireFox OS.

ngCordova

var ngCordova

TRUE if running inside Apache Cordova (PhoneGap)

ngWinStoreApp

var ngWinStoreApp

TRUE if running as Windows Store App

ngSupportsTouch

var ngSupportsTouch

TRUE if browser supports touch.

ngUsingTouch

var ngUsingTouch

TRUE if user uses touch as a primary input.

ngFirebug

var ngFirebug

TRUE if Firebug present (useful for debug informations).

Debug Functions

Summary
Functions
ngASSERTChecks the given assertion and displays description if assertion is FALSE and debug is enabled.
ngDEBUGLOGDisplays log message in console if debug is enabled.
ngDEBUGWARNDisplays warning message in console if debug is enabled.
ngDEBUGERRORDisplays error message in console if debug is enabled.
ngHASDEBUGTests if debug is enabled.

Functions

ngASSERT

Checks the given assertion and displays description if assertion is FALSE and debug is enabled.

Syntax

void ngASSERT (boolean assertion [, mixed description])

Parameters

assertionif FALSE the description is displayed
descriptiondescription to be displayed

Returns

-

ngDEBUGLOG

Displays log message in console if debug is enabled.

Syntax

void ngDEBUGLOG (args)

Returns

-

ngDEBUGWARN

Displays warning message in console if debug is enabled.

Syntax

void ngDEBUGWARN (args)

Returns

-

ngDEBUGERROR

Displays error message in console if debug is enabled.

Syntax

void ngDEBUGERROR (args)

Returns

-

ngHASDEBUG

function ngHASDEBUG()

Tests if debug is enabled.

Syntax

mixed ngHASDEBUG ()

Returns

Debug state (0=disabled).

Helper Functions

Summary
Functions
ngHammerJSChecks if HammerJS library is present.
ngPtrStartEventsGets input pointer start events (mousedown, touchstart, ...)
ngPtrHTMLStartEventsRenders supported pointer start events as HTML (onmousedown, ontouchstart, ...)
Variables
ngURLParamsParsed URL parameters.
ngURLDefaultEscapingDefines default URL escaping scheme.
ngURLSafeCharsURL safe chars.
ngHashSafeCharsHash(fragment) safe chars These characters aren’t encoded in function <ng_HashEncode>.

Functions

ngHammerJS

function ngHammerJS()

Checks if HammerJS library is present.

Syntax

bool ngHammerJS ()

Returns

TRUE if HammerJS library is present.

ngPtrStartEvents

function ngPtrStartEvents()

Gets input pointer start events (mousedown, touchstart, ...).

Syntax

array ngPtrStartEvents ()

Returns

List of supported events.

ngPtrHTMLStartEvents

function ngPtrHTMLStartEvents(html,
ev)

Renders supported pointer start events as HTML (onmousedown, ontouchstart, ...).

Syntax

mixed ngPtrHTMLStartEvents (mixed html, string event)

Parameters

htmlstring or ngStringBuilder object
eventevent code as text

Returns

Rendered html.

Variables

ngURLParams

var ngURLParams

Parsed URL parameters.  Use function <ng_GET> to get values of parameters.

ngURLDefaultEscaping

var ngURLDefaultEscaping

Defines default URL escaping scheme.

Constants

URL_ESCAPING_UTF8standard UTF-8 URL escaping (default)
URL_ESCAPING_UNICODEUNICODE URL escaping (uses %uXXXX)

ngURLSafeChars

var ngURLSafeChars

URL safe chars.  These characters aren’t encoded in function <ng_URLEncode>.

ngHashSafeChars

var ngHashSafeChars

Hash(fragment) safe chars These characters aren’t encoded in function <ng_HashEncode>.

ScreenPt

This class represents screen point.

Syntax

new ScreenPt (int posx, int posy);

Summary
Properties
xScreen X coordinate.
yScreen Y coordinate.
ngValSubstitutes undefined values with defaults.
ngNullValSubstitutes undefined or null values with defaults.
ngLibPathGets client library path.
ngLibVersionGets client library version.
ng_PreloadImagePre-loads image into browser’s memory.
ng_PreloadImagesBeginStarts preloading images block.
ng_PreloadImagesEndEnds preloading images block and call callback function after all images are loaded.
ng_ReloadImageRe-loads image in browser’s memory.
ng_AddURLParamAdds new parameter(s) to URL.
ng_StripURLParamsStrip parameters from URL.
ng_URLHandles platform specific URL.
ng_unescapeJavaScript unescape with proper handling of plus (+) character.
ng_htmlEncodeEncodes special HTML characters (&, <, >, “) to its HTML form.
ng_htmlDecodeDecode special HTML characters and remove HTML tags (&amp;, &lt;, &gt;, &quot;) to its native form.
ng_sprintfFormats string (PHP like sprintf function).
ng_URLEncodeEncodes special characters in URL.
ng_HashEncodeEncodes special characters in hash(fragment) part of URL.
ng_UTF8EncodeEncodes characters in url to utf-8 representation.
ng_UTF8DecodeJavaScript decode URI with characters in utf-8 representation.
ng_UTF8ParamEncodeEncodes characters in URI parameter to utf-8 representation.
ng_UTF8ParamDecodeJavaScript decode URI parameter in utf-8 representation.
ng_inDOMDetermines if element is present in browser’s document object model (DOM).
ng_WindowWidthReturns window width.
ng_WindowHeightReturns window height.
ng_SetInnerHTMLHandles platform specific setting of element’s innerHTML.
ng_AppendInnerHTMLAppends text to element’s innerHTML.
ng_DocumentDeselectRemoves document selection.
ng_DocumentScrollXGets actual document horizontal scroll offset.
ng_DocumentScrollYGets actual document vertical scroll offset.
ng_findPosXDetermines horizontal offset of the element relative to its super parent.
ng_findPosYDetermines vertical offset of the element relative to its super parent.
ng_findMousePosXDetermines horizontal element offset to absolute mouse position.
ng_findMousePosYDetermines vertical element offset to absolute mouse position.
ng_ParentPositionDetermines absolute position to parent object or document.
ng_nullAttrDetermines if element attribute is not defined.
ng_GetCurrentStyleGets current (computed) style of element.
ng_BeginMeasureElementPrepares element for dimension measurement.
ng_EndMeasureElementFinishes element dimension measurement.
ng_GetCurrentStylePxExtracts pixels value from current (computed) style of element.
ng_StyleWidthGets element width defined by style property.
ng_StyleHeightGets element height defined by style property.
ng_SetStyleWidthSets element width defined by style property.
ng_SetStyleHeightSets element height defined by style property.
ng_OuterWidthGets element outer width.
ng_OuterHeightGets element outer height.
ng_SetOuterWidthSets element outer width.
ng_SetOuterHeightSets element outer height.
ng_ClientWidthGets element client width.
ng_ClientHeightGets element client height.
ng_SetClientWidthSets element client width.
ng_SetClientHeightSets element client height.
ng_setLeftTopSets element left, top.
ng_setBoundsSets element left, top, width and height.
ng_GETGets value of page URL parameter.
ng_GetURLSafeCharsEncodedGets array, where keys are url encoded URL safe chars (RFC1738) and values are just URL safe chars
ng_RedirectRedirects user to specified URL.
ng_InIFRAMETests if page is opened in IFRAME.
ng_SetByRefSets value as reference into object property.
ng_SetByValSets copy of given value into object property.
ng_CopyVarCreates true copy of variable.
ng_MergeVarMerges two variables.
ng_CleanUndefinedRemoves all undefined properties in object.
ng_VarEqualsTests if value of one variable equals to value of second variable.
ng_IsArrayVarDetects if variable is indexed array.
ng_EmptyVarDetects if variable is empty (not set).
ngAddEventAdds new function to existing event handler (callback).

Properties

x

Screen X coordinate.

y

Screen Y coordinate.

ngVal

function ngVal(v,
defv)

Substitutes undefined values with defaults.

Syntax

mixed ngVal (mixed val, mixed defval)

Parameters

valvalue to be checked
defvaldefault value if val is undefined

Returns

Function returns defval if type of val is undefined.

ngNullVal

function ngNullVal(v,
defv)

Substitutes undefined or null values with defaults.

Syntax

mixed ngNullVal (mixed val, mixed defval)

Parameters

valvalue to be checked
defvaldefault value if val is undefined

Returns

Function returns defval if type of val is undefined or if val is null

ngLibPath

function ngLibPath(lib,
file)

Gets client library path.

Syntax: string ngLibPath (string lib [, string file])

Returns

Client library path.

ngLibVersion

function ngLibVersion(lib)

Gets client library version.

Syntax: mixed ngLibVersion (string id)

Returns

Used library version or FALSE if library is not found.

ng_PreloadImage

function ng_PreloadImage(url)

Pre-loads image into browser’s memory.

If image was already pre-loaded the function simply returns existing reference to the image class.

Syntax

image ng_PreloadImage (string url)

Parameters

urlimage URL

Returns

The image class (created by new Image) of the pre-loaded image.

ng_PreloadImagesBegin

function ng_PreloadImagesBegin()

Starts preloading images block.

Syntax

void ng_PreloadImagesBegin ()

Returns

-

See also

ng_PreloadImagesEnd, ng_PreloadImage

ng_PreloadImagesEnd

function ng_PreloadImagesEnd(callback)

Ends preloading images block and call callback function after all images are loaded.

Syntax

void ng_PreloadImagesEnd ([function callback])

Parameters

callbackcallback function called after all images loaded via ng_PreloadImage are loaded into browser

Returns

-

See also

ng_PreloadImagesBegin, ng_PreloadImage

ng_ReloadImage

function ng_ReloadImage(url)

Re-loads image in browser’s memory.

Instead of ng_PreloadImage this function always creates new image class.

Syntax

image ng_ReloadImage (string url)

Parameters

urlimage URL

Returns

The image class (created by new Image) of the loaded image.

ng_AddURLParam

function ng_AddURLParam(url,
param)

Adds new parameter(s) to URL.

This function properly handles parameter separators (? or &).

Syntax

string ng_AddURLParam (string url, string param)

Parameters

urloriginal URL
paramparameter(s) to be added to original URL

Returns

URL with parameters.

ng_StripURLParams

function ng_StripURLParams(url)

Strip parameters from URL.

Syntax

string ng_StripURLParams (string url)

Parameters

urloriginal URL

Returns

URL without parameters.

ng_URL

Handles platform specific URL.

Syntax

string ng_URL (string url)

Parameters

urloriginal URL

Returns

Platform compatible URL.

ng_unescape

function ng_unescape(str,
escscheme)

JavaScript unescape with proper handling of plus (+) character.

Syntax

string ng_unescape (string str [, int escscheme])

Parameters

strstring to be unescaped
escschemeescaping scheme (uses ngURLDefaultEscaping if not specified)

Returns

Unescaped string.

ng_htmlEncode

function ng_htmlEncode(s,
replacecrlf)

Encodes special HTML characters (&, <, >, “) to its HTML form.

Syntax

string ng_htmlEncode (string text [,bool replacecrlf=false])

Parameters

texttext with special characters
replacecrlfif TRUE, function replaces CRLF (or CR or LF) with <br /> HTML tag

Returns

Text with encoded special HTML characters.

ng_htmlDecode

function ng_htmlDecode(s,
replacecrlf,
replacespaces)

Decode special HTML characters and remove HTML tags (&amp;, &lt;, &gt;, &quot;) to its native form.

Syntax

string ng_htmlDecode (string text [,bool replacecrlf=false, bool replacespaces=false])

Parameters

texttext with HTML encoded characters
replacecrlfif TRUE replaces CRLF with spaces

Returns

Text with decoded characters.

ng_sprintf

function ng_sprintf()

Formats string (PHP like sprintf function).

Syntax

string ng_sprintf (string format [, mixed arg1, mixed arg2, ...])

Parameters

formattext with format characters
arg1..Narguments

Returns

Formated text.

ng_URLEncode

function ng_URLEncode(str,
allasunicode,
safechars,
escscheme)

Encodes special characters in URL.

Function also properly handles UTF-8 characters (>255).

Syntax

string ng_URLEncode (string url [, bool allasunicode=false, array safechars, int escscheme ])

Parameters

urlurl to be encoded
allasunicodeencode all characters as UNICODE (applicable only if escscheme is URL_ESCAPING_UNICODE)
safecharslist of characters which are not encoded
escschemeescaping scheme (uses ngURLDefaultEscaping if not specified)

Returns

URL with encoded characters.

ng_HashEncode

function ng_HashEncode(s,
safechars,
escscheme)

Encodes special characters in hash(fragment) part of URL.

Syntax

string ng_HashEncode (string s [, array safechars, int escscheme ])

Parameters

sstring to be encoded
safecharslist of characters which are not encoded
escschemeescaping scheme (uses ngURLDefaultEscaping if not specified)

Returns

Encoded string.

ng_UTF8Encode

function ng_UTF8Encode(str,
safechars)

Encodes characters in url to utf-8 representation.

Syntax

string ng_UTF8Encode (string url)

Returns

URL with encoded characters.

ng_UTF8Decode

function ng_UTF8Decode(str)

JavaScript decode URI with characters in utf-8 representation.

Syntax

string ng_UTF8Decode (string str)

Parameters

strstring to be decoded

Returns

Decoded string.

ng_UTF8ParamEncode

function ng_UTF8ParamEncode(str)

Encodes characters in URI parameter to utf-8 representation.

Syntax

string ng_UTF8ParamEncode (string url)

Returns

URL with encoded characters.

ng_UTF8ParamDecode

function ng_UTF8ParamDecode(str)

JavaScript decode URI parameter in utf-8 representation.

Syntax

string ng_UTF8ParamDecode (string str)

Parameters

strstring to be decoded

Returns

Decoded string.

ng_inDOM

function ng_inDOM(e)

Determines if element is present in browser’s document object model (DOM).

Syntax

bool ng_inDOM (object elm)

Parameters

elmelement object

Returns

TRUE if object is in DOM, FALSE if not.

ng_WindowWidth

function ng_WindowWidth()

Returns window width.

Syntax

int ng_WindowWidth ()

Returns

Width of browser’s window.

ng_WindowHeight

function ng_WindowHeight()

Returns window height.

Syntax

int ng_WindowHeight ()

Returns

Height of browser’s window.

ng_SetInnerHTML

Handles platform specific setting of element’s innerHTML.

Syntax

void ng_SetInnerHTML (element o, string content [, bool append=false])

Parameters

oDOM element which innerHTML should be updated
contenttext
appendif TRUE, the content is added to existing innerHTML

Returns

-

ng_AppendInnerHTML

function ng_AppendInnerHTML(o,
t)

Appends text to element’s innerHTML.  The innerHTML is modified only if text is not empty.

Syntax

void ng_AppendInnerHTML (element o, string content)

Parameters

oDOM element which innerHTML should be updated
contenttext

Returns

-

ng_DocumentDeselect

function ng_DocumentDeselect()

Removes document selection.

Syntax

void ng_DocumentDeselect ()

Returns

-

ng_DocumentScrollX

function ng_DocumentScrollX()

Gets actual document horizontal scroll offset.

Syntax

int ng_DocumentScrollX ()

Returns

Horizontal scroll offset in pixels.

ng_DocumentScrollY

function ng_DocumentScrollY()

Gets actual document vertical scroll offset.

Syntax

int ng_DocumentScrollY ()

Returns

Vertical scroll offset in pixels.

ng_findPosX

function ng_findPosX(obj)

Determines horizontal offset of the element relative to its super parent.

Syntax

int ng_findPosX (object obj)

Parameters

objelement object

Returns

Horizontal position of element in pixels.

ng_findPosY

function ng_findPosY(obj)

Determines vertical offset of the element relative to its super parent.

Syntax

int ng_findPosY (object obj)

Parameters

objelement object

Returns

Vertical position of element in pixels.

ng_findMousePosX

function ng_findMousePosX(obj)

Determines horizontal element offset to absolute mouse position.

Syntax

int ng_findMousePosX (object obj)

Parameters

objelement object

Returns

Offset to be substracted from the absolute mouse position.

ng_findMousePosY

function ng_findMousePosY(obj)

Determines vertical element offset to absolute mouse position.

Syntax

int ng_findMousePosY (object obj)

Parameters

objelement object

Returns

Offset to be substracted from the absolute mouse position.

ng_ParentPosition

function ng_ParentPosition(o,
parent)

Determines absolute position to parent object or document.

Syntax

int ng_ParentPosition (object obj[, object parent])

Parameters

objelement object
parentelement object

Returns

Object with properties x and y.

ng_nullAttr

function ng_nullAttr(v)

Determines if element attribute is not defined.

Syntax

bool ng_nullAttr (object attr)

Parameters

attrelement attribute

Returns

TRUE if attribute is not set.

ng_GetCurrentStyle

function ng_GetCurrentStyle(o,
s)

Gets current (computed) style of element.

Syntax

string ng_GetCurrentStyle (object elm, string style)

Parameters

elmobject element
stylename of the style, for example ‘margin-right’

Returns

Value of requested style.

ng_BeginMeasureElement

function ng_BeginMeasureElement(o)

Prepares element for dimension measurement.  Makes sure all parent object have proper display style.

Syntax

array ng_BeginMeasureElement (object elm)

Parameters

elmobject element

Returns

List of modified objects.

See also

ng_EndMeasureElement

ng_EndMeasureElement

function ng_EndMeasureElement(o)

Finishes element dimension measurement.  Restores display states of parent object if modified.

Syntax

void ng_EndMeasureElement (object elm)

Parameters

elmobject element

Returns

-

See also

ng_BeginMeasureElement

ng_GetCurrentStylePx

function ng_GetCurrentStylePx(o,
s)

Extracts pixels value from current (computed) style of element.

Syntax

int ng_GetCurrentStylePx (object elm, string style)

Parameters

elmobject element
stylename of the style, for example ‘margin-right’

Returns

Pixels value of requested style.

ng_StyleWidth

function ng_StyleWidth(o)

Gets element width defined by style property.

Syntax

int ng_StyleWidth (object elm)

Parameters

elmobject element

Returns

Width in pixels.

ng_StyleHeight

function ng_StyleHeight(o)

Gets element height defined by style property.

Syntax

int ng_StyleHeight (object elm)

Parameters

elmobject element

Returns

Height in pixels.

ng_SetStyleWidth

function ng_SetStyleWidth(o,
v)

Sets element width defined by style property.

Syntax

void ng_SetStyleWidth (object elm, int v)

Parameters

elmobject element
vwidth in pixels

Returns

-

ng_SetStyleHeight

function ng_SetStyleHeight(o,
v)

Sets element height defined by style property.

Syntax

void ng_SetStyleHeight (object elm, int v)

Parameters

elmobject element
vheight in pixels

Returns

-

ng_OuterWidth

function ng_OuterWidth(o)

Gets element outer width.

Syntax

int ng_OuterWidth (object elm)

Parameters

elmobject element

Returns

Width in pixels.

ng_OuterHeight

function ng_OuterHeight(o)

Gets element outer height.

Syntax

int ng_OuterHeight (object elm)

Parameters

elmobject element

Returns

Height in pixels.

ng_SetOuterWidth

function ng_SetOuterWidth(o,
v)

Sets element outer width.

Syntax

void ng_SetOuterWidth (object elm, int v)

Parameters

elmobject element
vwidth in pixels

Returns

-

ng_SetOuterHeight

function ng_SetOuterHeight(o,
v)

Sets element outer height.

Syntax

void ng_SetOuterHeight (object elm, int v)

Parameters

elmobject element
vheight in pixels

Returns

-

ng_ClientWidth

function ng_ClientWidth(o)

Gets element client width.

Syntax

int ng_ClientWidth (object elm)

Parameters

elmobject element

Returns

Width in pixels.

ng_ClientHeight

function ng_ClientHeight(o)

Gets element client height.

Syntax

int ng_ClientHeight (object elm)

Parameters

elmobject element

Returns

Height in pixels.

ng_SetClientWidth

function ng_SetClientWidth(o,
v)

Sets element client width.

Syntax

void ng_SetClientWidth (object elm, int v)

Parameters

elmobject element
vwidth in pixels

Returns

-

ng_SetClientHeight

function ng_SetClientHeight(o,
v)

Sets element client height.

Syntax

void ng_SetClientHeight (object elm, int v)

Parameters

elmobject element
vheight in pixels

Returns

-

ng_setLeftTop

function ng_setLeftTopNotIE(o,
l,
t)

Sets element left, top.  Optimized for IE if used.

Syntax

void ng_setLeftTop (object obj, int left, int top)

Parameters

objobject element
leftleft position in pixels
toptop position in pixels

Returns

-

ng_setBounds

function ng_setBoundsNotIE(o,
l,
t,
w,
h)

Sets element left, top, width and height.  Optimized for IE if used.

Syntax

void ng_setBounds (object obj, int left, int top, int width, int height)

Parameters

objobject element
leftleft position in pixels
toptop position in pixels
widthwidth of element in pixels
heightheight of element in pixels

Returns

-

ng_GET

function ng_GET(p)

Gets value of page URL parameter.

Syntax

string ng_GET (string paramname)

Parameters

paramnameparameter name

Returns

Value of the parameter.

Example

http://server/?P1=a&P2=b&amp;P3=c#P4=d@P5=e
var p1=ng_GET('P1');

ng_GetURLSafeCharsEncoded

function ng_GetURLSafeCharsEncoded()

Gets array, where keys are url encoded URL safe chars (RFC1738) and values are just URL safe chars

Syntax

array ng_GetURLSafeCharsEncoded ()

Returns

Value of global variable ngURLSafeCharsEncoded

ng_Redirect

function ng_Redirect(url,
topframe)

Redirects user to specified URL.

Syntax

void ng_Redirect (string url, bool topframe = true)

Parameters

urltarget url
topframeredirect

Returns

TRUE if location was set.

ng_InIFRAME

function ng_InIFRAME()

Tests if page is opened in IFRAME.

Syntax

bool ng_InIFRAME (void)

Parameters

-

Returns

TRUE if page is in IFRAME.

ng_SetByRef

function ng_SetByRef(obj,
prop,
val)

Sets value as reference into object property.

Syntax

void ng_SetByRef (object obj, string prop [, mixed value])

Parameters

objobject where property will be set
propproperty name
valuevalue of property

Returns

-

ng_SetByVal

function ng_SetByVal(obj,
prop,
val)

Sets copy of given value into object property.

Syntax

void ng_SetByVal (object obj, string prop [, mixed value])

Parameters

objobject where property will be set
propproperty name
valuevalue of property

Returns

-

ng_CopyVar

function ng_CopyVar(o)

Creates true copy of variable.

Syntax

mixed ng_CopyVar (mixed var)

Parameters

varvariable to be copied

Returns

New variable.

ng_MergeVar

function ng_MergeVar(d,
o,
allowundefined,
callback)

Merges two variables.

Syntax

void ng_MergeVar (mixed dst, mixed var [, bool allowundefined=false, function callback])

Parameters

dstdestination variable
varvariable to be merged
allowundefinedif FALSE (default), undefined values in parameter var are ignored
callbackoptional callback function

Returns

-

ng_CleanUndefined

function ng_CleanUndefined(d)

Removes all undefined properties in object.

Syntax

mixed ng_CleanUndefined (mixed obj)

Parameters

objobject to be cleaned

Returns

Input obj parameter.

ng_VarEquals

function ng_VarEquals(a,
b,
noobj)

Tests if value of one variable equals to value of second variable.  Function handles date types and objects.

Syntax

bool ng_VarEquals (mixed a, mixed b [, bool noobj=false])

Parameters

afirst variable
bsecond variable
noobjif TRUE don’t compare objects

Returns

TRUE if values of variables are equal.

ng_IsArrayVar

function ng_IsArrayVar(o)

Detects if variable is indexed array.

Syntax

bool ng_IsArrayVar (mixed var)

Parameters

varvariable to be checked

Returns

TRUE if variable is indexed array.

ng_EmptyVar

function ng_EmptyVar(o)

Detects if variable is empty (not set).

Syntax

bool ng_EmptyVar (mixed var)

Parameters

varvariable to be checked

Returns

TRUE if variable is empty.

ngAddEvent

function ngAddEvent(ev,
fce)

Adds new function to existing event handler (callback).

Syntax

function ngAddEvent (function oldevent, function appendevent)

Parameters

oldeventold event handler
appendeventfunction to be added to existing event handler

Returns

New event handler function that calls both event handlers (oldevent function and than appendevent function).

ngRPC

Remote Procedure Call.

This class is used for asynchronous communication with server.

Syntax

new ngRPC ([string id=’’, string url=’’, bool nocache=false])

Parameters

idunique ID of RPC class
urlrequest URL
nocacheif TRUE, unique timestamp is added to every request to prevent caching results
Summary
Properties
nocacheIf TRUE, unique timestamp is added to every request to prevent caching of results.
TypeType of RPC call.
integerDefault value: rpcAuto
HTTPMethodUsed http method (if http request).
stringDefault value: ’’ (autodetect)
URLDefault RPC URL.
stringDefault value: ’’
ParamsRPC Parameters.
objectDefault value: { }
Methods
SetParamSets request parameter.
GetParamGets value of request parameter.
sendRequestSends request to the server.
clearParamsClears RPC parameters.
Events
AddEventAdds new function to the event handler (callback).
RemoveEventRemoves function from the event handler (callback).
OnEncodeParam
OnRequest
OnSendRequest
OnRequestSent
OnIFrameRequest
OnHTTPRequest
OnHTTPReadyStateChanged
OnHTTPRequestFailed
OnReceivedJSON
OnReceivedData

Properties

nocache

this.nocache

If TRUE, unique timestamp is added to every request to prevent caching of results.

Default value: false

Type

Type of RPC call.

integer

Default value: rpcAuto

HTTPMethod

Used http method (if http request).  If empty, autodetect.

string

Default value: ’’ (autodetect)

URL

Default RPC URL.

string

Default value: ’’

Params

RPC Parameters.

object

Default value: { }

Methods

SetParam

Sets request parameter.

Syntax

void SetParam (string name, mixed value)

Parameters

nameparameter name
valueparameter value

Returns

-

GetParam

Gets value of request parameter.

Syntax

mixed GetParam (string name)

Parameters

nameparameter name

Returns

Value of parameter.

sendRequest

Sends request to the server.

Syntax

void sendRequest (string url)

Parameters

urlURL with parameters

Returns

-

clearParams

Clears RPC parameters.

Syntax

void clearParams ()

Returns

-

Events

AddEvent

Adds new function to the event handler (callback).

Syntax

void AddEvent (string event, function handler)

void AddEvent (function handler, string event)

Parameters

Returns

-

RemoveEvent

Removes function from the event handler (callback).

Syntax

void RemoveEvent (string event, function handler)

Parameters

Returns

-

OnEncodeParam

OnRequest

OnSendRequest

OnRequestSent

OnIFrameRequest

OnHTTPRequest

OnHTTPReadyStateChanged

OnHTTPRequestFailed

OnReceivedJSON

OnReceivedData

ngRDS

Remote Data Service based on ngRPC class.

This class is used for getting asynchronous data from server.

Syntax

new ngRDS ([string id=’’, string url=’’, function callback = null, bool nocache=false])

Parameters

idunique ID of RPC class
urlrequest URL
callbackfunction which is called after data was received
nocacheif TRUE, unique timestamp is added to every request to prevent caching results

ngStringBuilder

This class realizes fast concatenation of strings.

Standard JavaScript string concatenation is quite slow.  This class utilizes the fact that array joining is much faster than standard string concatenation.

Syntax

new ngStringBuilder (mixed value)

The statement

s = s1 + s2 + s3;

can be replaced with

var sb = new ngStringBuilder(s1);
sb.append(s2);
sb.append(s3);
s = sb.toString();
Summary
Functions
appendAppends the given value to the end of this instance.
clearClears the string buffer.
emptyTests if string buffer is empty.
toStringConverts this instance to a String.

Functions

append

this.append = function (value)

Appends the given value to the end of this instance.

Syntax

ngStringBuilder append (mixed value)

Parameters

valuestring, array or other ngStringBuilder class

Returns

This instance of ngStringBuilder.  Helps function chaining - sb.append(‘a’).append(‘b’).append(‘c’).

clear

this.clear = function ()

Clears the string buffer.

Syntax

void clear ()

Returns

-

empty

this.empty = function ()

Tests if string buffer is empty.

Syntax

bool empty ()

Returns

TRUE if string buffer is empty.

toString

this.toString = function ()

Converts this instance to a String.

Syntax

string toString ()

Returns

String with concatenated values.

See also

append

var ngHTTPProtocol
Used protocol (http:// or https://).
var ngOpera
TRUE if user is using the Opera browser.
var ngOperaVersion
Float number identifying Opera browser version
var ngIExplorer
TRUE if user is using the Internet Explorer browser.
var ngIExplorerVersion
Version of the Internet Explorer browser.
var ngIExplorer6
TRUE if user is using the Internet Explorer version 6 or lower.
var ngFireFox
TRUE if user is using the Firefox browser.
var ngFireFoxVersion
Version of the Firefox browser.
var ngFireFox1x
TRUE if user is using the Firefox browser version 1.x.
var ngFireFox2x
TRUE if user is using the Firefox browser version 2.x.
var ngChrome
TRUE if user is using the Chrome browser.
var ngSafari
TRUE if user is using the Safari browser.
var ngAndroid
TRUE if device uses Android OS.
var ngiOS
TRUE if device uses Apple iOS.
var ngWindowsPhone
TRUE if device uses Windows Phone OS.
var ngFireFoxOS
TRUE if device uses FireFox OS.
var ngCordova
TRUE if running inside Apache Cordova (PhoneGap)
var ngWinStoreApp
TRUE if running as Windows Store App
var ngSupportsTouch
TRUE if browser supports touch.
var ngUsingTouch
TRUE if user uses touch as a primary input.
var ngFirebug
TRUE if Firebug present (useful for debug informations).
function ngHASDEBUG()
Tests if debug is enabled.
function ngHammerJS()
Checks if HammerJS library is present.
function ngPtrStartEvents()
Gets input pointer start events (mousedown, touchstart, ...)
function ngPtrHTMLStartEvents(html,
ev)
Renders supported pointer start events as HTML (onmousedown, ontouchstart, ...)
var ngURLParams
Parsed URL parameters.
var ngURLDefaultEscaping
Defines default URL escaping scheme.
var ngURLSafeChars
URL safe chars.
var ngHashSafeChars
Hash(fragment) safe chars These characters aren’t encoded in function ng_HashEncode.
function ngVal(v,
defv)
Substitutes undefined values with defaults.
function ngNullVal(v,
defv)
Substitutes undefined or null values with defaults.
function ngLibPath(lib,
file)
Gets client library path.
function ngLibVersion(lib)
Gets client library version.
function ng_PreloadImage(url)
Pre-loads image into browser’s memory.
function ng_PreloadImagesBegin()
Starts preloading images block.
function ng_PreloadImagesEnd(callback)
Ends preloading images block and call callback function after all images are loaded.
function ng_ReloadImage(url)
Re-loads image in browser’s memory.
function ng_AddURLParam(url,
param)
Adds new parameter(s) to URL.
function ng_StripURLParams(url)
Strip parameters from URL.
function ng_unescape(str,
escscheme)
JavaScript unescape with proper handling of plus (+) character.
function ng_htmlEncode(s,
replacecrlf)
Encodes special HTML characters (&, <, >, “) to its HTML form.
function ng_htmlDecode(s,
replacecrlf,
replacespaces)
Decode special HTML characters and remove HTML tags (&amp;, &lt;, &gt;, &quot;) to its native form.
function ng_sprintf()
Formats string (PHP like sprintf function).
function ng_URLEncode(str,
allasunicode,
safechars,
escscheme)
Encodes special characters in URL.
function ng_HashEncode(s,
safechars,
escscheme)
Encodes special characters in hash(fragment) part of URL.
function ng_UTF8Encode(str,
safechars)
Encodes characters in url to utf-8 representation.
function ng_UTF8Decode(str)
JavaScript decode URI with characters in utf-8 representation.
function ng_UTF8ParamEncode(str)
Encodes characters in URI parameter to utf-8 representation.
function ng_UTF8ParamDecode(str)
JavaScript decode URI parameter in utf-8 representation.
function ng_inDOM(e)
Determines if element is present in browser’s document object model (DOM).
function ng_WindowWidth()
Returns window width.
function ng_WindowHeight()
Returns window height.
function ng_AppendInnerHTML(o,
t)
Appends text to element’s innerHTML.
function ng_DocumentDeselect()
Removes document selection.
function ng_DocumentScrollX()
Gets actual document horizontal scroll offset.
function ng_DocumentScrollY()
Gets actual document vertical scroll offset.
function ng_findPosX(obj)
Determines horizontal offset of the element relative to its super parent.
function ng_findPosY(obj)
Determines vertical offset of the element relative to its super parent.
function ng_findMousePosX(obj)
Determines horizontal element offset to absolute mouse position.
function ng_findMousePosY(obj)
Determines vertical element offset to absolute mouse position.
function ng_ParentPosition(o,
parent)
Determines absolute position to parent object or document.
function ng_nullAttr(v)
Determines if element attribute is not defined.
function ng_GetCurrentStyle(o,
s)
Gets current (computed) style of element.
function ng_BeginMeasureElement(o)
Prepares element for dimension measurement.
function ng_EndMeasureElement(o)
Finishes element dimension measurement.
function ng_GetCurrentStylePx(o,
s)
Extracts pixels value from current (computed) style of element.
function ng_StyleWidth(o)
Gets element width defined by style property.
function ng_StyleHeight(o)
Gets element height defined by style property.
function ng_SetStyleWidth(o,
v)
Sets element width defined by style property.
function ng_SetStyleHeight(o,
v)
Sets element height defined by style property.
function ng_OuterWidth(o)
Gets element outer width.
function ng_OuterHeight(o)
Gets element outer height.
function ng_SetOuterWidth(o,
v)
Sets element outer width.
function ng_SetOuterHeight(o,
v)
Sets element outer height.
function ng_ClientWidth(o)
Gets element client width.
function ng_ClientHeight(o)
Gets element client height.
function ng_SetClientWidth(o,
v)
Sets element client width.
function ng_SetClientHeight(o,
v)
Sets element client height.
function ng_setLeftTopNotIE(o,
l,
t)
Sets element left, top.
function ng_setBoundsNotIE(o,
l,
t,
w,
h)
Sets element left, top, width and height.
function ng_GET(p)
Gets value of page URL parameter.
function ng_GetURLSafeCharsEncoded()
Gets array, where keys are url encoded URL safe chars (RFC1738) and values are just URL safe chars
function ng_Redirect(url,
topframe)
Redirects user to specified URL.
function ng_InIFRAME()
Tests if page is opened in IFRAME.
function ng_SetByRef(obj,
prop,
val)
Sets value as reference into object property.
function ng_SetByVal(obj,
prop,
val)
Sets copy of given value into object property.
function ng_CopyVar(o)
Creates true copy of variable.
function ng_MergeVar(d,
o,
allowundefined,
callback)
Merges two variables.
function ng_CleanUndefined(d)
Removes all undefined properties in object.
function ng_VarEquals(a,
b,
noobj)
Tests if value of one variable equals to value of second variable.
function ng_IsArrayVar(o)
Detects if variable is indexed array.
function ng_EmptyVar(o)
Detects if variable is empty (not set).
function ngAddEvent(ev,
fce)
Adds new function to existing event handler (callback).
this.nocache
If TRUE, unique timestamp is added to every request to prevent caching of results.
Remote Procedure Call.
this.append = function (value)
Appends the given value to the end of this instance.
this.clear = function ()
Clears the string buffer.
this.empty = function ()
Tests if string buffer is empty.
this.toString = function ()
Converts this instance to a String.
This class realizes fast concatenation of strings.
Close