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 = $.parseJSON(AZClientStorage("get", "Customers"));

If you have stored an Object or an Array, you will need to parse this from a string to a JavaScript Object. For example, you can use JSON Parse.

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

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

[{"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");

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

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

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

IsEmpty Type: Function Parameters: object Return: true or false

The function returns false if you are testing an Object and the Object is not empty and has at least one property.
AZ Get URL Parameters Type: Function Parameters: String Default: window.location.href

Before testing the function, open the console in your browser and find the tab - Console
AZ Bytes Converter Type: Function Parameters: Bytes - Decimal Default: 2 decimal
AZBytesConverter(Bytes, Decimal);

123456 - 987654321

Set AZ Page Type: Function Return: object
function SetAZPage()
    $.subscribeonce("functionlib/AZPage", function (e, data)
            $Form: i.fn.init
            ApiVersion: "_1"
            AppName: "AZ Team"
            AppVersion: "1.0.0"
            AppVersionCode: "1.0.0"
            Language: "nb-NO"
            Location: "localhost"
            PageFirstName: "index"
            PageName: "index.html"
            AZSettings: {},
            ObjLanguage: {}
            ObjValidation: {}
    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 Serialize Form Type: Function Return: object
var _AZSerializeFormOptions =
    $Area: Selector,
    ObjLanguage: {},
    ObjValidation: {}

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

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

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


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");