//========================================================================================
//
//  ADOBE CONFIDENTIAL
//
//  Copyright © 2015 Adobe Systems Incorporated
//  All Rights Reserved.
//
//  NOTICE:  All information contained herein is, and remains
//  the property of Adobe Systems Incorporated and its suppliers,
//  if any.  The intellectual and technical concepts contained
//  herein are proprietary to Adobe Systems Incorporated and its
//  suppliers and are protected by all applicable intellectual property
//  laws, including trade secret and copyright laws.
//
//  Dissemination of this information or reproduction of this material
//  is strictly forbidden unless prior written permission is obtained
//  from Adobe Systems Incorporated.
//
// @author: mortimer - extracted from CEP version by gpant
//========================================================================================

var HelloProductInterface_ILST = function ()
{
    /**
     * Debugging object name shortcut
     */
    this.oname = "HelloIllustrator";

    /**
     * Point product configuration info - will get merged into the AdobeHello object
     */
    this.configuration =
    {
        /**
         * Content URL's for the point product.
         */
        url : {
            online  : "https://helpx.adobe.com/illustrator/hello/v1_5/index.html"
        },

        /**
         * Object configuration settings.
         */
        options : {
            jsonHtmlEncodeDisplayString     : true,     // HTML encoding required on recent file or document type display name
            jsonURIEncodeOpenPath           : false,    // URI encoding required on recent file path
            middleEllipsisFilenames         : false,    // middle ellipsize recent file names & template names
            createPanelUseOptionalColumn    : true      // use the optional 3rd column of the create panel template
        },

        /**
         * UI element definitions.
         */
        ui : {
            create  :   {
                initialImage    : "images/AiCreateInitialExp.jpg",
                backgroundColor : "#231f20",
                dividerColor    : "#f99404"
            },
            footer  :   {
                helpURL         : "https://helpx.adobe.com/illustrator.html",
                helpLabel       : "footer_help_label_ILST",
                forumsURL       : "https://forums.adobe.com/community/illustrator",
                forumsLabel     : "footer_forums_label",
                inspireURL      : "https://www.behance.net/search?field=48&sort=featured_date&time=all",
                inspireLabel    : "footer_inspire_label",
                blogURL         : "http://blogs.adobe.com/adobeillustrator",
                blogLabel       : "footer_addons_label"
            }
        },

        /**
         * All the point products seem to have implemented a different event types, so we need this
         * definition here until we can standardize them.
         */
        events : {
            pipEventType                    : "com.adobe.illustrator.LOGPIP",
            aboutToCloseEvent               : "com.adobe.illustrator.welcome.aboutToAutomaticallyCloseHello",
            handleExecuteMenuCommand        : "com.adobe.illustrator.HandleExecuteMenuCommand",
            handleRecentFileOpen            : "com.adobe.illustrator.welcome.HandleRecentFileOpen",
            contentTabChangedNotification   : "com.adobe.illustrator.welcome.contentTabChangedNotification",
            isInContentTutorialNotification : "com.adobe.illustrator.welcome.isInContentTutorialNotification"
        },

        /**
         * Another workaround for merging the different PP extensions into one. Although we have
         * a different extension ID, the host app expects the following one in order for it's
         * various pieces to work correctly.
         */
        overrideExtensionID : "com.illustrator.Welcome.extension1"
    }


    /**
     * Sets the "Don't Show Again" preference in the host application.
     *
     * @param dontShowAgain     boolean value indicating true if "dont show again" was
     *                          requested, false otherwise
     */
    HelloProductInterface_ILST.prototype.setDontShowAgainPreference = function( dontShowAgain )
    {
        try
        {

            var trueOrFalse = dontShowAgain ? "true" : "false";
            var script      = "app.preferences.setBooleanPreference(\"" + "Hello/DontShowAgainPrefKey_Ver18_1" +"\"," + trueOrFalse + ");";

            window.__adobe_hello.evalScript( script, function(result) { } );
        }
        catch( e )
        {
            HelloLog.exception( e );
        }
    }
};

/*
var HelloIllustrator = function ()
{
    /**
     * Get the Hello JSON data corresponding to the currently logged in user.
     *
     * @param callback      function object which will be called on data generation completion
     *
    HelloIllustrator.prototype.getUserJsonData = function( callback )
    {
        try
        {
            window.__adobe_hello.evalScript( "app.getHelloJSONData()", callback);
        }
        catch( e )
        {
            window.__adobe_hello.logMessage( "HelloIllustrator.getUserJsonData catch: " + e.message );
        }
    }
    
    /**
     * Opens an existing document.  If the specified path is the constant string
     * "open" then it will open the browse/open file UI in the host application.
     *
     * @param fullPath      string object containing the path or ID of the existing
     *                      document to open
     *
    HelloIllustrator.prototype.openExistingDocument = function( fullPath )
    {
        window.__adobe_hello.sendAboutToCloseEvents();
        
        if ( fullPath == "open" )
        {
            window.__adobe_hello.sendExecuteMenuCommandEvent( "open" );
        }
        else
        {
            window.__adobe_hello.sendRecentFileOpenEvent( fullPath );
        }
        
        window.__adobe_hello.logHelloInteractionPIPEvent( "OpenExistingDoc" );
        window.__adobe_hello.closeHello();
    }
    
    /**
     * Create a new document of the specified type by showing the appropriate new document
     * UI.  If the 'suppressNewDocUI' is true then the document created with default params
     * and the new document UI is not shown.
     *
     * @param documentType          string object containing the ID of the new doc type to
     *                              create
     * @param suppressNewDocUI      boolean value indicating true to not show the new doc UI,
     *                              false otherwise
     *
    HelloIllustrator.prototype.openDocumentOfType = function( documentType, suppressNewDocUI )
    {
    	window.__adobe_hello.sendAboutToCloseEvents();

        if ( documentType == "From Template" )
        {
            sendExecuteMenuCommandEvent( "newFromTemplate" );
        }
        else
        {
            var trueOrFalse = suppressNewDocUI ? "false" : "true";
            var script      = "app.documents.addDocumentWithDialogOption(\""+documentType+"\"," +  trueOrFalse + ");";
            
            function callback(result) { }
            
            window.__adobe_hello.evalScript( script, callback );
        }
        
        window.__adobe_hello.logHelloInteractionPIPEvent( "CreateNewDoc:"+documentType );
        window.__adobe_hello.closeHello();
    }
};
*/