Skip to content

Instantly share code, notes, and snippets.

@adomado
Created June 27, 2011 09:32
Show Gist options
  • Select an option

  • Save adomado/1048571 to your computer and use it in GitHub Desktop.

Select an option

Save adomado/1048571 to your computer and use it in GitHub Desktop.

Revisions

  1. adomado revised this gist Jul 12, 2011. 1 changed file with 66 additions and 5 deletions.
    71 changes: 66 additions & 5 deletions hello_world.js
    Original file line number Diff line number Diff line change
    @@ -1,25 +1,86 @@
    /**
    *
    * Boilerplate code, used internally by the platform
    *
    * Notice the **config** variable being passed into the self-executing anonymous function.
    *
    * **config.api** object is an instance of the IJAppApi.v1 class.
    * Any public methods present in the [IJAppApi.v1](../api/v1.html) can be called on config.api object
    *
    */
    (function(config) {

    var HelloWorld = {
    /**
    * Hello World App
    *
    * @class HelloWorld
    *
    */
    var HelloWorld = { // Start

    /**
    * @name init()
    *
    * This method is called when the App is initiated
    *
    */
    init : function() {
    config.api.log("Hello, World!");
    },


    /**
    * @name options()
    *
    * This method is called when the App is clicked inside the App Panel
    *
    */
    options : function() {
    config.api.log("Options!");
    },


    /**
    * @name contextAction()
    *
    * This method is called when the user selects your App from the context action menu
    *
    */
    contextAction : function() {
    config.api.log("Context action invoked");
    }

    }; // HelloWorld
    }; // HelloWorld End



    // Attach callback to events
    /**
    * The App Api provides a user with various points of interaction with the App. Each interaction is handled by the app as an event.
    * To ease the development, the API provides config.api.callback method in which you can bind callbacks to each of the available interaction points.
    *
    * The interaction points are...
    *
    * **App initialization** (required) - An app is initialized based on the information that is provided in the manifest. An app can
    * chose to be invoked on all pages or on specific domains/paths
    *
    * **App's options** (optional) - Invoked when a user clicks on the app from the Apps Panel.
    *
    * **App's context action** (optional) - Invoked when a user clicks on your app's icon in the context action menu.
    *
    *
    */
    config.api.callbacks({
    init : HelloWorld.init, // called when your app is initialized
    options : HelloWorld.options // called when your app icon is clicked inside the AppDock
    init : HelloWorld.init,
    options : HelloWorld.options,
    contextAction : HelloWorld.contextAction
    });


    /**
    *
    * Boilerplate code, used internally by the platform
    *
    */
    })({
    api : new IJAppApi.v1({appId : "__APP_ID__"})
    });
  2. adomado created this gist Jun 27, 2011.
    25 changes: 25 additions & 0 deletions hello_world.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    (function(config) {

    var HelloWorld = {

    init : function() {
    config.api.log("Hello, World!");
    },

    options : function() {
    config.api.log("Options!");
    }

    }; // HelloWorld


    // Attach callback to events
    config.api.callbacks({
    init : HelloWorld.init, // called when your app is initialized
    options : HelloWorld.options // called when your app icon is clicked inside the AppDock
    });


    })({
    api : new IJAppApi.v1({appId : "__APP_ID__"})
    });