/// <reference path="D:\InfinityWebServer\BBInfinity\bbappfx\vroot\browser\BBUI\bbui\bbui.js" />
/// <reference path="D:\InfinityWebServer\BBInfinity\bbappfx\vroot\browser\BBUI\forms\formcontainer.js" />
/// <reference path="D:\InfinityWebServer\BBInfinity\bbappfx\vroot\browser\jQuery\query-vsdoc.js" />
/// <reference path="D:\InfinityWebServer\BBInfinity\bbappfx\vroot\browser\jQuery\ext-jquery-adapter.js" />
/// <reference path="D:\InfinityWebServer\BBInfinity\bbappfx\vroot\browser\ExtJS\ext-all-debug.js" />
/// <reference path="D:\InfinityWebServer\BBInfinity\bbappfx\vroot\browser\BBUI\uimodeling\servicecontracts.js" />
/// <reference path="D:\InfinityWebServer\BBInfinity\bbappfx\vroot\browser\BBUI\uimodeling\service.js" />
/// <reference path="D:\InfinityWebServer\BBInfinity\bbappfx\vroot\browser\BBUI\forms\utility.js" />
//use the latest version of jsLint with stricter rule checks
/*lintversion 2*/

/*jslint bitwise: true, browser: true, eqeqeq: true, undef: true, white: true, indent: 4*/
/*global BBUI, Ext, $ */
/*JSLint documentation: http://www.jslint.com/lint.html */

// Encapsulate all logic inside a self-invoking function so objects are not added to the 
// global (window) object.
(function () {
    'use strict';  //enforces latest ECMAScript5
    var ns;
   
    // Ensure the namespace for your action exists.  The naming convention for custom action 
    // namespaces is "BBUI.customactions.yournamespace" where "yournamespace" is the lower-case 
    // type of the UI model project where this file is stored.  For instance, if you are creating
    // a custom action in the Blackbaud.AppFx.Constituent.UIModel project, your action's namespace 
    // would be "BBUI.customactions.constituent".
    ns = BBUI.ns("BBUI.customactions.mytest");
   
    // This is the constructor for the custom action.  The constructor will always be passed a 
    // host object.  See the BBUI documentation for BBUI.pages.ActionHost for information about 
    // properties and methods available on the host object.
    ns.MyCustomAction = function (host) {
        // Cache the host object so it can be referenced by instance methods.
        this.host = host;
    };
        
    // Instance methods are declared as properties of the action's prototype object.
    ns.MyCustomAction.prototype = {
        
        // This method is called when the action is executed.  Since many actions will execute 
        // asynchronously, a callback function is provided as the first parameter.  This callback 
        // function should be called when the action is executed successfully.
        executeAction: function (callback) {
            
            // The function that will be called when the form dialog is confirmed.
            function formConfirmedHandler(args) {
                // The custom action has finished executing.  Call the callback 
                // function so the post-action event can be invoked (if any).
                callback();
            }
                
            BBUI.pages.Dialogs.showCustomForm(this.host.uiModelingSvc, 
                "IsCancelable.UIModel.dll", 
                "IsCancelable.UIModel.GenericUIActionIsCancelableUIModel", 
                {
                    confirmCallback: formConfirmedHandler
                });
            
        }
    };

}());