PhiBase class
Overview
The global PhiBase class offers convenience global functions for AJAX, sessions and URLs for JavaScript. This class is instantiated as
phi
and is usable in any browser independent of running a Phi native client or HTML.
|
|
Usage
The special object phi
is a global instance of the PhiBase class in the client (browser) scripting environment.
if ( phi.isNative() ) {
// running a phi client
} else {
// running in HTML mode
}
Attention: the phi
object is not available in ServerScript.
Properties
- Object ajax [read]
- String lang [read]
- String session [read]
- Number xAxis [read]
- Number yAxis [read]
- Number zAxis [read]
Object ajax
Contains the default AJAX object useable for asynchronous HTML requests.
var a=phi.ajax;
See also: Ajax class.
String lang
Returns the currently set language which will be used for links in the current page or the default language if none is set.
var lang=phi.lang;
See also: $PHISERVER[lang].
String session
Returns the current session id phisid
or an empty string if none is set.
var sid=phi.session;
See also: document.session, Session management.
Number xAxis
Returns the x-axis number (0x1).
Number yAxis
Returns the y-axis number (0x2).
Number zAxis
Returns the z-axis number (0x4).
Functions
.alert()
Synopsis
|
|
![]() |
Description
Opens a message box with string as text and an Ok button. Since v1.3.0 you can simply use alert().
Read: this is a write-only function.
Write: displays message s.
Note: This function has been removed in v2.0.0 and is not longer supported.
See also: window.alert().
Example
phi.alert( string );
.createAjax()
Synopsis
|
|
![]() |
Description
Read: creates a cross browser compatible AJAX object.
Write: this is a read-only function.
Note:
See also: Ajax class.
Example
var ajax=phi.createAjax();
.fadeIn()
Synopsis
|
|
![]() |
Description
Read: this is a write-only function.
Write: Fades the item with id in and starts fading after s msec with duration d msec until the opacity opac is reached.
Note: This function has been removed in v2.0.0 and is not longer supported. Use .fadeIn()
instead.
See also: .fadeIn()
.
Example
phi.fadeIn( 'myitem', 0, 1000, 1 );
.fadeOut()
Synopsis
|
|
![]() |
Description
Read: this is a write-only function.
Write: Fades the item with id out and starts fading after s msec with duration d msec until the opacity opac is reached.
Note: This function has been removed in v2.0.0 and is not longer supported. Use .fadeOut()
instead.
See also: .fadeOut()
.
Example
phi.fadeOut( 'myitem', 10000, 3000, 0.1 );
.getElementById()
Synopsis
|
|
![]() |
Description
Read: returns the DOM object for the provided id or undefined if no such item with id is found.
Write: this is a read-only function.
Note: same as document.getElementById()
. Usually you only will use the item API to manipulate items.
See also: Phi item API, Phi DOM item, document.getElementById().
Example
var item=phi.getElmentById( 'id' );
if ( item ) item.style.color='#ffaacc';
.href()
Synopsis
|
|
![]() |
Description
Opens an external link. If you want to use a link without session and language set, use window.location.href.
Read: this is a write-only function.
Write: opens a new document in the same directory with url or an external page. Additional GET variables for language philang and session phisid are automatically appended.
Note: if you use HTML code in a rich text element and you want the link extended with the appropriate Phi variables, use:
<a href="javascript: phi.href( 'link' );">link text</a>
Attention: keep in mind phi.href() is a function and not a property like window.location.href.
See also: window.location.href.
Example
phi.href( '/tutorial/myfirst.phis' );
.isHtml()
Synopsis
|
|
![]() |
Description
Read: returns true
if the browser is running in HTML mode, else false
is returned.
Write: this is a read-only function.
Note: used to distinguish if additional features are available, i.e. if this function returns true
it is safe to use jQuery.
See also: .isNative()
.
Example
if ( phi.isHtml() ) doSomethingWhichIsOnlySupportedByHtml();
.isNative()
Synopsis
|
|
![]() |
Description
Read: returns true
if the browser is running natively in Phi mode (e.g. using PhiApp), else false
is returned.
Write: this is a read-only function.
Note: used to distinguish if additional features are available, i.e. if this function returns true
it is safe to use extensions offered by Phi like native menus.
See also: .isHtml()
.
Example
if ( phi.isNative() ) doSomethingPhiSpecific();
.move()
Synopsis
|
|
![]() |
Description
Read: this is a write-only function.
Write: animated move of an item to a new position in a specific time.
Note: This function has been removed in v2.0.0 and is not longer supported. Use .moveTo()
instead.
See also: .moveTo()
.
Example
phi.move( 'myid', 100, 200, 0, 3000 ); // moves myid immediately to the pos left:100 top:200 in 3sec
.onload()
Synopsis
|
|
![]() |
Description
Reimplement this function if you want to setup settings after the page is fully loaded and all elements are ready.
Read: this is a handler and should return Void
.
Write: n/a
Note: The default implementation does nothing.
See also: .onsubmit()
.
Example
phi.onload=function() {
// stuff to do after the page is completely loaded
}
.onsubmit()
Synopsis
|
|
![]() |
Description
Reimplement this function if you want to check settings before sending form data to the server. You must return true if the data should be sent or false otherwise.
Read: this is a handler and must return true
if the form should be sent or false
if the submission should be rejected.
Write: n/a
Note: The default implementation does nothing and returns true
.
See also: Submit button, window.document.phiform.submit().
Example
phi.onsubmit=function() {
// check formular elements
return true;
}
Void rotateIn()
This function is deprecated. Do not use it in new code. The function is provided to keep old code working. Use .rotateIn() instead.
Rotates the element in.
phi.rotateIn( id, axis, start, duration ); phi.rotateIn( 'item_id', phi.xAxis+phi.yAxis, 0, 1000 ); // rotates item with ID item_id immediately through the x-axis and y-axis in 1sec in
Note: In HTML mode a rotation of an element is currently not possible, so phi.fadeIn() is used instead.
Void rotateOut()
This function is deprecated. Do not use it in new code. The function is provided to keep old code working. Use .rotateOut() instead.
Rotates the element out.
phi.rotateOut( id, axis, start, duration ); phi.rotateOut( 'item_id', phi.xAxis, 3000, 2000 ); // rotates item with ID item_id after 3sec through the x-Axis in 2sec out
Note: In HTML mode a rotation of an element is currently not possible, so phi.fadeOut() is used instead.
Void setData()
v1.2.0 This function is deprecated. Do not use it in new code. The function is provided to keep old code working. Use .selectOptions() instead.
Sets the data of a List box item or Selection box item.
phi.setData( id, data, delimiter='\n' ); phi.setData( 'select', 'row 1[1]:row 2[2]:row 3[3]', ':' );
Void setOpacity()
This function is deprecated. Do not use it in new code. The function is provided to keep old code working. Use .opacity() instead.
Sets the opacity of item id to opac. The range for opac is between '0' (fully transparent) and '1' (opaque). You can even set the opacity of input items.
phi.setOpacity( 'id', 0.5 ) // sets the opacity to 50%
Note: You should avoid using item.style.opacity directly - not all browser support this or using it differently.
Void setVisible()
This function is deprecated. Do not use it in new code. The function is provided to keep old code working. Use .visible() instead.
Sets the visiblity of item id to true or false.
phi.setVisible( 'id', false ); // hides the item
See also: item.style.visibility.
Additional notes
We will provide additional usefull functions in future releases.