AZ Standard Functions

AZ Promise Type: Functions

Based on jQuery Promise, we have created several functions you can subscribe on that will help you get a better flow in your code. The principles are based on Events & Delegates, which is a good form of programming practice and should replace all forms of use of Callback.

$.publish("Location - Name", Data);

$.subscribe("Location - Name", function (e, data) { });

$.subscribeonce("Location - Name", function (e, data) { });

$.unsubscribe("Location - Name", function (e, data) { });

AZ Window Scroll Type: Function
$.subscribe("functionlib/azWindowScroll", function (e, data)

This function is triggered every time you scroll.


AZ Window Resize Type: Function
$.subscribe("functionlib/azWindowResize", function (e, data)

This function is triggered when the page loads and every time the page resizes.


AZ Client Storage Type: Function Parameters: ActionType - Name - Value Return: Objects, Arrays, String, Integer...
AZClientStorage(ActionType, Name, Value);

This function is used to store and retrieve data, (Items) from the browser. AZClientStorage will automatically test if your browser supports storage. First Local Storage is tested, and if your browser supports this, your data will be stored in Local Storage. However, if your browser does not support Local Storage, it will try to store data in Cookies.

ActionType Name Value
set Item Name Varying data types
get Item Name
delete (remove) Item Name

Store data
var _Customers = [{"Name": "Hansen"}, {"Name": "Olsen"}, {"Name": "Andersen"}];
AZClientStorage("set", "Customers", _Customers);

In addition to Item Name, the function adds the site's domain name - You can store virtually any type of data. Objects and Arrays will be automatically stringified.

Get data
var _Customers = AZClientStorage("get", "Customers");

Objects and Arrays will be automatically parsed to JavaScript Objects or Arrays.

Delete data
AZClientStorage("delete", "Customers");

AZ Get Obj Type: Function Parameters: Array - Key - Val - Int Return: object
AZGetObj(Array, "Name", "Olsen", Level);

Level The function is recursive, ie it does a multi level search in the array. If you specify the level, e.g. 1, it will only search for the object in level 1.

[{"Name": "Hansen"}, {"Name": "Olsen"}, {"Name": "Andersen"}]

AZ Remove Obj Type: Function Parameters: Array - Key - Val
AZRemoveObj(Array, "Name", "Olsen");

[{"Name": "Hansen"}, {"Name": "Olsen"}, {"Name": "Andersen"}]

AZ Exist Obj Type: Function Parameters: Array - Key - Val Return: true or false
AZExistObj(Array, "Name", "Olsen");

The function is recursive, ie it does a multi level search in the array.

[{"Name": "Hansen"}, {"Name": "Olsen"}, {"Name": "Andersen"}]

AZ Sort Array Type: Function Parameters: Array - Key - Sort Return: array
AZSortArray(Array, "Name", "asc");

For more advanced sorting, we can recommend looking at the module thenBy.js which is part of the AZ system.

[{"Name": "Hansen"}, {"Name": "Olsen"}, {"Name": "Andersen"}]

AZIsEmpty (IsEmpty) Type: Function Parameters: object{} og array[] Return: true or false

The function returns false if you are testing an Object/Array and the Object/Array is not empty and the Object has at least one property.

AZ Get URL Parameters Type: Function Parameters: String Default: window.location.href Return: object
var _URL = "";

AZ Bytes Converter Type: Function Parameters: Bytes - Decimal Default: 2 decimal Return: String
AZBytesConverter(123456, 2);
AZBytesConverter(987654321, 2);

AZ Guid Type: Function Return: String

AZ Standard Alert Type: Function
var _AZStandardAlertOptions =
    $Area: "Optional",
    Title: "",
    Text: ""
new AZStandardAlert(_AZStandardAlertOptions);

Set AZ Page Type: Function Return: object
function SetAZPage()
    $.subscribeonce("functionlib/AZPage", function (e, data)
            $Form: i.fn.init
            Location: ""
            PageName: ""
            PageFirstName: ""
            Language: ""
            ObjLanguage: {}
            ObjValidation: {}
            AppName: ""
            AppVersion: ""
            ApiVersion: ""
            AZSettings: {}
    new AZPage(
        azPageArea: {},
        azPageElement: [],
        azPageInputTypeEvents: false,
        azPageLanguage: false,
        azPageLanguageUrl: "",
        azPageValidation: false,
        azPageValidationUrl: ""

AZ Set Language Type: Function
var _AZSetLanguageOptions =
    $Area: Selector,
    ObjLanguage: {}
new AZSetLanguage(_AZSetLanguageOptions);

AZ Set Validation Type: Function
var _AZSetValidationOptions =
    $Area: Selector,
    ObjValidation: {}
new AZSetValidation(_AZSetValidationOptions);

AZ Set Input Type Events Type: Function

AZ Serialize Form Type: Function Return: object
var _AZSerializeFormOptions =
    $Area: Selector,
    ObjLanguage: {},
    ObjValidation: {}

AZ Populate Form Type: Function
var _AZPopulateFormOptions =
    $Area: Selector,
    ObjInputData: {},
    ObjValidation: {}

AZ Set Page Element Type: Function Parameters: String - Array Return: ObjPageData.Elements
var PageElement = ["SetPageElement", "AZSetPageElement"];


The function looks for elements with ID or CLASS that match the elements in the list you submit in the function. When an element is found, the element is created as a jQuery object and added to the variable ObjPageData.Elements.

AZ Promise
Below you also see an example of using Promise using the feature $.when


function Effect()
    return $("").each(function (i)
        $(this).fadeOut(1000 * (i + 1));

$.when(Effect()).done(function () { // Do Something });

AZ Show/Hide CoverSpin Type: Function Input: string

AZShowCoverSpin("Show Cover Spin");