Quantcast
Channel: Alert.js - CRM 2013-2016 Custom Alerts and Popup Dialogs JavaScript Lightbox
Viewing all articles
Browse latest Browse all 170

New Post: Typescript d.ts file

$
0
0
I created a Typescript Definition file for this in case anyone would want to use it:
declare module Alert {
    class Button {
        label: string;
        callback?: () => void;
        setFocus?: boolean;
        preventClose?: boolean;
        /**
         * 
         * @param label The text to display on the button
         * @param callback A custom function to call when the button is clicked. This function accepts no input parameters, and can be declared inline as a dynamic function. A callback is not required, as the button can still close the alert by default (unless you specify otherwise).
         * @param setFocus Specify whether this button should have focus set to it by default, i.e. to allow pressing 'enter' to fire the button command. If there is only one button, focus is automatically set to the button, unless you explicitly set this to false.
         * @param preventClose Specify whether this button should not close the alert after executing the callback function. By default, if this value is not specified, the alert will be automatically closed after clicking the button. Set this to true if you want to keep the alert open, for example if your button does something like the 'download log' for CRM errors, where you want to keep the error open.
         * @returns {} 
         */
        constructor(label:string, callback?: () => void, setFocus?: boolean, preventClose?: boolean);
    }

    type Icon = "ERROR" | "INFO" | "QUESTION" | "SUCCESS" | "WARNING";

    /**
     * Gets the CRM window from inside an iframe to access custom functions, e.g. parent.Alert.getCrmWindow().doSomething();
     */
    export function getCrmWindow(): Window;

    /**
     * Use the returned iframe context with jQuery to get data from the iframe, i.e.Alert.$("#something", Alert.getIFrameContext().document);
     */
    export function getIFrameWindow(): JQuery;
    /**
     * Hide the alert manually without performing any callbacks
     */
    export function hide(): void;

    /**
     * Encode the Title or Message to display xml tags, e.g. from a plugin error trace
     * Also replaces javascript line breaks with <br>
     * @param text
     */
    export function htmlEncode(text: string): string;

    // purpose: display an alert style dialog for the user using the CRM lightbox (web) or modal dialog (outlook)
    // Allows for custom buttons and callbacks
    /**
     * Display an alert style dialog for the user using the CRM lightbox (web) or modal dialog (outlook) 
     * Allows for custom buttons and callbacks
     * @param title Main big message
     * @param message (optional) Sub-heading shown below the title
     * @param buttons (otional, defaults to 'Ok') Array of buttons and callback functions for each button. Callbacks optional. E.g. [{label: "OK", callback: function(){}},{label: "Cancel"}]
     * @param icon (optional, defaults to none) Displays a custom icon on the alert: INFO, WARNING, ERROR, SUCCESS, QUESTION, LOADING
     * @param width (optional, defaults to _dialogWidth) Custom width of the dialog
     * @param height (optional, defaults to _dialogHeight) Custom height of the dialog
     * @param baseUrl (optional, defaults to getClientUrl) Base url of CRM (only required if no access to Xrm.Page)
     * @param preventCancel (optional, defaults to false) Hides the 'X' in the top right corner, meaning you can only dismiss the alert using the buttons
     * @param padding (optional, defaults to 20) Sets the amount of padding around the light-box. Set to 0 for no padding (on iframes etc)
     */
    export function show(title?: string, message?: string, buttons?: Button[], icon?: Icon, width?: number, height?: number, baseUrl?: string, preventCancel?: boolean, padding?: number): void;

    /**
     * 
     * @param dialogId Dialog Id to execute
     * @param entityName Logical Name of the Entity to execute the dialog on
     * @param recordId Id of the Entity to execute the dialog on
     * @param callback (optional) Callback that gets fired on dialog closure
     * @param width (optional, defaults to _dialogWidth) Custom width of the dialog
     * @param height (optional, defaults to _dialogHeight) Custom height of the dialog
     * @param baseUrl (optional, defaults to getClientUrl) Base url of CRM (only required if no access to Xrm.Page)
     */
    export function showDialogProcess(dialogId: string, entityName: string, recordId: string, callback?: () => void, width?: number, height?: number, baseUrl?: string): void;

    /**
     * 
     * @param iframeUrl iFrame Url
     * @param width (optional, defaults to _dialogWidth) Custom width of the dialog
     * @param height (optional, defaults to _dialogHeight) Custom height of the dialog
     * @param title (optional, defaults to empty) Main big message
     * @param buttons (otional, defaults to 'Ok') Array of buttons and callback functions for each button. Callbacks optional. E.g. [{label: "OK", callback: function(){}},{label: "Cancel"}]
     * @param baseUrl (optional, defaults to getClientUrl) Base url of CRM (only required if no access to Xrm.Page)
     * @param preventCancel (optional, defaults to false) Hides the 'X' in the top right corner, meaning you can only dismiss the alert using the buttons
     * @param padding (optional, defaults to 20) Sets the amount of padding around the light-box. Set to 0 for no padding (on iframes etc)
     */
    export function showIFrame(iframeUrl, width, height, title, buttons, baseUrl, preventCancel, padding): void;

    /**
     * Displayes a small loading spinner with the text "Loading..."
     * @param url (defaults to getClientUrl) Base url of CRM (only required if no access to Xrm.Page)
     */
    export function showLoading(url?: string): void;

    /**
     * 
     * @param webResourceName Web Resource Name
     * @param width (optional, defaults to _dialogWidth) Custom width of the dialog
     * @param height (optional, defaults to _dialogHeight) Custom height of the dialog
     * @param title (optional, defaults to empty) Main big message
     * @param buttons (otional, defaults to 'Ok') Array of buttons and callback functions for each button. Callbacks optional. E.g. [{label: "OK", callback: function(){}},{label: "Cancel"}]
     * @param baseUrl (optional, defaults to getClientUrl) Base url of CRM (only required if no access to Xrm.Page)
     * @param preventCancel (optional, defaults to false) Hides the 'X' in the top right corner, meaning you can only dismiss the alert using the buttons
     * @param padding (optional, defaults to 20) Sets the amount of padding around the light-box. Set to 0 for no padding (on iframes etc)
     */
    export function showWebResource(webResourceName: string, width?: number, height?: number, title?: string, buttons?: Button[], baseUrl?: string, preventCancel?: boolean, padding?: number): void;

Viewing all articles
Browse latest Browse all 170

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>