function YourPlugin() {}
$ajax->YourPlugin()
$ajax->YourPlugin('pass strings', array('pass'=>'arrays'))
//cjax/plugins/YourPlugin.js
function YourPlugin(string, array) {
alert(string);
//alerts all the items in your array.
for(item in array) {
alert(item+ ' '+array[item]);
}
}
<?php
$ajax->hello_world('hello', 'world!',array('test'));
?>
function hello_world(a,b,c)
{
//sample of importing javascript into the scope
this.importFile('http://cjax.googlecode.com/svn/trunk/_extra/test_unit/plugins/js/test.js');
//sample of importing css to the page
this.importFile('http://cjax.googlecode.com/svn/trunk/_extra/test_unit/plugins/css/test.css');
console.log('File base:', this.base);
console.log('This file:', this.file);
console.log('Paramters Passed:', a, b ,c);
}
| API | type | Params | Description | Example(s) |
|---|---|---|---|---|
|
Function |
path - required string
$callback - optional callback function |
Import and caches JavaScript or CSS files. You may use relative path to your plugin, eg: just "myfile.js" or "js/myfile.js". You may also import remote CSS or JavaScript. You may use the callback as an indicator that the script/css is fully loaded. |
|
|
Variable | - | Returns the full base path url to your plugin directory location. |
|
|
Variable | - | Returns file name, eg. myPlugin.js |
|
|
Variable | - | Returns the default path to ajax.php |
|
|
Function | $count - optional integer [default 1] | Allows you to intercept the execution of $ajax object APIs. It returns a function which you can use to trigger the intercepted APIs. If $count is specified, you may place how many APIs you want to prevent after the execution of the plugin API. |
in your controller...
<?php in your js plugin...
you may prevent more than one.
|
|
Function | $form_id - require string | Get all values in a form. |
|
|
Function |
$mix_url - require mixed [string, object] $mix_item - optional mixed [string, object] |
Create ajax requests |
|
|
Function |
$url - require mixed [string] $mixed - optional mixed [string, object] |
Create ajax requests with get. $mixed can be a container id where the response html is sent to or it can be a callback function which returns the response. |
|
|
Function |
$url - require mixed [string] $mixed - optional mixed [string, object] |
Create ajax requests with post. $mixed can be a container id where the response html is sent to or it can be a callback function which returns the response. |
|
|
Function |
content - required [string] options - optional mixed [object]
top - position from top of the page
left - position from left transparent - from 1 to 100 level of background transparency. color - color of the background |
Displays a lightbox overlay window with supplied content. |
|
|
Function |
content - required [string] options - optional mixed [object]
top - position from top of the page
left - position from left transparent - from 1 to 100 level of background transparency. color - color of the background remote - If it is an external url |
Displays a lightbox overlay window with supplied url. |
|
|
Function |
message - string seconds - optional [default 3] |
Displays supplied text/content on the screen in form of message. if $seconds is provided, that is how long the message will last on the screen before it disappears, 0 would remove time limit. |
|
|
Function |
message - string [default 'Success!'] seconds - optional [default 3] |
Makes use of this.message() to display a success formatted message. |
|
|
Function |
message - string [default 'Invalid Input'] seconds - optional [default 3] |
Makes use of this.message() to display a warning formatted message. |
|
|
Function |
message - string seconds - optional [default 3] |
Makes use of this.message() to display an error formatted message. |
|
ScopeAll plugins APIS apply to local scope to each plugin within plugin contructor function. |
||||
<?php
class YourPlugin {
}
?>
<?php
class YourPlugin {
function __construct()
{
}
}
?>
$ajax->YourPlugin()
| API | type | Params | Description | Example(s) |
|---|---|---|---|---|
|
Function |
$url - required string
$load_time - optional integer milliseconds |
Import and caches JavaScript or CSS files. You may use relative path to your plugin, eg: just
"myfile.js" or "js/myfile.js". You may also import remote CSS or JavaScript.
$load_time - Import scripts are loaded asynchronously, when importing multiple scrips it is possible that a second script could load before the first one, if it is smaller. You may give extra milliseconds to your import to ensure that it doesn't load too fast or too slow in comparism with others. The range should be from 50 to max 400 (4th of a second), depending how big the script is. If you experience issues with one script loading in mixed order use imports() function instead. |
|
|
Function |
$files - required array
|
Import and caches JavaScript or CSS files. You may use relative path to your plugin, eg: just
"myfile.js" or "js/myfile.js". You may also import remote CSS or JavaScript.
This function first waits for the previous file to be fully loaded before loading the next one. |
|
|
Function |
$setting - required string
$value - require mixed string |
Updates plugin parameters and variables of your JavaScript plugin. You may use a,b,c,d,e,f etc. If you don't use alphabetic letters to update parameters, any other variable name will also be accessible within your plugin as eg: this.variable_name. |
|
|
Function | - | Trigger Function - This function is a type of constructor function. Is Automatically called at the initiation of your plugin. The paratemers passed when you call your plugin, will be passed through this function in the same order. |
|
|
Function | - | Trigger Function - This function is a type of constructor function. Is Automatically called at the initiation of your plugin in controller (none Ajax Mode). The paratemers passed when you call your plugin, will be passed through this function in the same order. |
|
|
Function | - | Trigger Function - This function is a type of constructor function. Is Automatically called at the initiation of your plugin in an Ajax Controller. The paratemers passed when you call your plugin, will be passed through this function in the same order. Thi function is optional. |
|
|
Function |
$setting - required string
$value - required mixed string |
Save plugin settings in session or cookie. You may access this data in the plugin's ajax controllers. |
|
|
Function | $setting - required string | Get setting that has been saved with save() function. |
|
|
Function | - |
Triger Function - This function is automatically called at the end of the processing.
It passes the raw data being sent from your plugin.
$cache variable holds all the raw data being sent from the plugin, you may make careful changes still. return the $cache, if you don't return anything no changes will be made. |
|