Tri
(type in module tri
)
Provides a set of static utility functions that can be accessed with the prefix tri.
The public methods attached to the tri object and described herein are
freely accessible from Javascript code.
These functions can be called from HTML code using the 'windows' verbs such as onclick vs the AngularJS verbs such as ng-click.
This is used by the template handlers to alter the HTML strings just prior to handing over to AngularJS for insertion into the HTML page.
The sAlter param consists of a repeated group of pairs. Each pair group is separated by a ';'. Do not use a trailing ';'.
Each pair is separated by a '/'. The first of the pair is the regular expression to match in the template text. The second of the pair is the replacement text. Note: this text has been processed by the parser browser and might be transformed by the browser (such as making tags lowercase).
For example the string alter='##TITLE##/title;option/no-option'
causes ##TITLE## to be replaced by title and option to be replaced by no-option.
In the case where the pair content needs to contain a '/' the first of the pair may start with a '!' and
the '!' is then used to separate the two parts of the pair. eg. alter='!/apps/tri!/../apps/tri'
sHtml – {string} –
HTML string to manipulate
sAlter – {string} –
Alter strings
{string}
– altered sHtml
Given the sDate and sTime parameters, this utility function returns an approximate age such a 2 days.
sDate – {string} –
Date of format yyyymmdd
sTime – {string} –
24 hour time sting of format hhmmss
Used to close the Form Page and signal the primary window this has been done.
The signal of sys-close-page is sent via tri.postToOpener to
hookMsgListener
AngularJS prefers strings in the HTML ng- functions. This utility function
returns sTrue or sFalse depending on the boolean state of b.
b – {Object} –
the boolean value or function to evaluate
sTrue – {string} –
string returned if true
sFalse – {string} –
returned if false
This is used by the secondary windows described in Form Page Design to load Templates from the primary window.
The statements in the FormXXX.htm file of the form
<div class=for-template html='xxx.html' ng-include='zzz' alter='strs'>
</div>
are scanned for. Any found cause a request of 'sys-get-template` to be made to the hookMsgListener of the primary window.
It responds with the data which is handled by tri.postTemplate
The field xxx.html names the template to fetch.
The field zzz names a unique variable added to the $scope used to manage the template loading process.
The field strs is an optional field that represents strings passed to the tri.alter method.
{@link – {event} –
http://angularjs.org/ AngularJS} $event object used to provide context for this method.
This is used by the secondary windows described in Form Page Design to load Templates
This method is the responder to the tri.loadTemplates invoked reponses.
The template provided in the payload is added to the $templateCache cache after any alter strings are applied.
Then the ng-include referenced name is changed wich causes the template to be rendered by AngularJS.
event – {Object} –
AngularJS $event object used to provide context for this method. The tri.loadTemplates inserts enough information so the response provides sufficient context.
Posts the oMsg serializable object to the window that opened the secondary window. The handler of this message is described in
hookMsgListener where the verb and payload parameters are described.
This is used by the secondary windows described in Form Page Design.
The messages are processed by hookMsgListener
oMsg – {Object} –
object that contains properties verb and payload
Constructor used to build a single instance of the tri object.