Global functions

Description:
These are the basic functions of AutomizyJS. The fuctions below work on all Automizy modules, writing the specific module name in the fuction names (shown in the examples).

Quick navigation

Global methods

$A.newModule(obj)

Returns:
Module

This method creates a new Automizy module.
If the method is invoked without parameter a default copy of the specific module will be created.
If invoked with parameter the copy will be created based on the properties given in the obj object.

  • obj
    Type: Object
    The object which specifies the attributes of the module you want to create.
    If you want to know which attributes can be specified in the object of the particular module, check the 'Options' in the module description.
Code examples
//Creating a new Button module
var button = $A.newButton({
    text: "My new button",
    float: "left",
    skin: "simple-orange"
}).draw();
            

$A.getModule(id)

Returns:
Module

This method returns the Automizy module with the specific id.

  • id
    Type: String
    The id of the module you want to get.
Code examples
//Getting a new Button module
$A.newButton({id: "button-1"}).draw();
var button1 = $A.getButton("button-1");
setTimeout(function(){
    button1.disable();
},1000);
            

$A.getAllModule()

Returns:
Object

This method returns the all copies of the specific Automizy module in an object.

Code examples
//Creating and getting all Button modules
$A.newButton().draw();
$A.newButton().draw();
$A.newButton().draw();
var buttons = $A.getAllButton();
setTimeout(function(){
    for(var i in buttons){
        buttons[i].disable();
    }
}, 1000);
            

$A.removeModule(id)

This method removes the Automizy module with the specific id.

  • id
    Type: String
    The id of the module you want to remove.
Code examples
//Creating and removing a Button module
$A.newButton({id: "button-1"}).draw();
setTimeout(function (){
    $A.removeButton("button-1");
},1000);
            

$A.removeAllModule()

This method removes all copies of the specific Automizy module in an object.

Code examples
//Creating and removing Button modules
$A.newButton().draw();
$A.newButton().draw();
$A.newButton().draw();
setTimeout(function () {
    $A.removeAllButton();
}, 1000);
            

$A.ajaxDocumentCover()

Use this methoud to add a loading cover to your page.

Code examples
$A.ajaxDocumentCover(true);
            

$A.base64Encode()

Use this method to base64 encode any string.

Code examples
var txt = "This is the text to encode.";
var encoded = $A.base64Encode(txt);
document.write(encoded);
            

$A.base64Decode()

Use this method to base64 decode any base64 encoded string.

Code examples
var txt = "This is the text to encode.";
var encoded = $A.base64Encode(txt);
document.write($A.base64Decode(encoded));
            

$A.dateFormat()

Use this method to format date and time.
This function uses Steven Levithan's dateFormat.js.

Code examples
document.write($A.dateFormat('2015.04.16 12:31', 'mysqlDateTime'));
            

$A.store()

localStorage wrapper for all browsers without using cookies or flash. Uses localStorage, globalStorage, and userData behavior under the hood.
This function uses Marcus Westin's store.js.

Code examples
$A.store.set('user', {name:'John Doe', age:25, active:false});
document.write($A.store.get('user').name + ' is a ');
document.write($A.store.get('user').age + ' years old ');
document.write(($A.store.get('user').active?'active':'inactive') + ' user.');
            

$A.getUniqueString()

Use this method to get a random, 16 characters long string.

Code examples
document.write($A.getUniqueString());
            

$A.hashChange(str, bool)

Use this method to change the hash tag in the browser url.
If invoked without parameter, this function will trigger the hashchange event, as shown in the example below.

  • str
    Type: String
    The hash text you want to show.
    Invoke this function using only one parameter to change hash value.
  • bool
    Type: boolean
    Set this second parameter false if you want to remove the hash tag.
Code examples
//Setting hashchange event:
$('body').on("hashchange", function(){
    alert("Hash changed!");
});
//Setting hash:
$A.hashChange('hashName');
//Removing the 'hashName' hash
$A.hashChange('hashName', false);
            

$A.insertAtCaret($input, str)

Use this method to instert a string at the cursor in an input field.

  • $input
    Type: jQuery
    The input element in which you want to insert the string.
  • str
    Type: String
    The string you want to insert.
Code examples
$('body').append('<input type="text" id="input01" value="Text"/>');
setTimeout(function(){
    $A.insertAtCaret($('#input01'),'Insert this!');
},1000);
            

$A.parseBoolean(val)

Use this method to evaluate the given parameter as a boolean.

  • val
    Type: String|Number
    The value you want to parse to boolean.
    This method will parse the following expressions true: 'true' | 1 | '1' | 'on' | 'yes'
    This method will parse the following expressions false: 'true' | 0 | '0' | 'off' | 'no'
Code examples
document.write($A.parseBoolean(1) + ", ");
document.write($A.parseBoolean('off') + ", ");
document.write($A.parseBoolean('yes'));
            

$A.rand(a, b)

This method gives a random number between the two given numbers (incl. value of 'a' and 'b' too).

Code examples
document.write($A.rand(0, 100));
            

$A.setWindowScroll(id, bool)

Use this method to enable or disable window scrolling when a dialog is open.

  • id
    Type: String
    The id of the dialog element on which you want to enable or diable window scrolling.
  • bool
    Type: boolean
    true: Scrolling will be enabled.
    false: Scrolling will be disabled.
Code examples
$A.newDialog({
    id: 'dialog01',
    title: 'New dialog'
}).open();
$A.setWindowScroll(false, 'dialog01');
            

$A.numberFormat(number, decimals, decPoint, thousandsSep)

Use this method to format a number.

  • number
    Type: Number
    The number you want to format. It can be either an integer or a double.
  • decimals
    Type: Integer
    The number of decimals you want to show.
  • decPoint
    Type: String
    The decimal point separator character.
  • thousandsSep
    Type: String
    The thousands separator character.
Code examples
$('<div>'+$A.numberFormat(1234.56)+'</div>').appendTo('body');	//'1,235'
$('<div>'+$A.numberFormat(1234.56, 2, ',', ' ')+'</div>').appendTo('body');	//'1 234,56'
$('<div>'+$A.numberFormat(1234.5678, 2, '.', '')+'</div>').appendTo('body');	//'1234.57'
$('<div>'+$A.numberFormat(67, 2, ',', '.')+'</div>').appendTo('body');	//'67,00'
$('<div>'+$A.numberFormat(1000)+'</div>').appendTo('body');	//'1,000'
$('<div>'+$A.numberFormat(67.311, 2)+'</div>').appendTo('body');	//'67.31'
$('<div>'+$A.numberFormat(1000.55, 1)+'</div>').appendTo('body');	//'1,000.6'
$('<div>'+$A.numberFormat(67000, 5, ',', '.')+'</div>').appendTo('body');	//'67.000,00000'
$('<div>'+$A.numberFormat(0.9, 0)+'</div>').appendTo('body');	//'1'
$('<div>'+$A.numberFormat('1.20', 2)+'</div>').appendTo('body');	//'1.20'
$('<div>'+$A.numberFormat('1.20', 4)+'</div>').appendTo('body');	//'1.2000'
$('<div>'+$A.numberFormat('1.2000', 3)+'</div>').appendTo('body');	//'1.200'
            

$A.defaultNumberFormat(numberFormat)

Use this method to set the default number formatting pattern.
This pattern will be used if you invoke the $A.numberFormat(number) function.

  • numberFormat
    Type: Object
    decimals: 0
    decPoint: '.'
    thousandsSep: ','
Code examples
$A.defaultNumberFormat({
    decPoint:',',
    thousandsSep:' ',
});

//Please note that the number will be ceiled this case, because the default number of decimals is 0
$('<div>'+$A.numberFormat(67000.5)+'</div>').appendTo('body');	//'67 001'


$A.defaultNumberFormat({
    decPoint:',',
    thousandsSep:' ',
    decimals: 3
});

//Now decimals will be shown
$('<div>'+$A.numberFormat(67000.5)+'</div>').appendTo('body');	//'67 000,500'

            

$A.convertToResponsive()

Use this method to enable the mobile-friendly CSS features of AutomizyJs.

Code examples
//Try it out by resizing your browser window
$A.convertToResponsive();
$A.newDialog().content($('<div class="automizy-dialog-content">Content</div>')).draw();