The Screen class

The Screen class is used to create new screens in the Friend Workspace. The screen class is there to help you organize your View windows on a separate spatial area, as an alternative to just opening a View window on the default Friend Workspace screen.

// Make a new window with some flags

    var v = new Screen( { title: 'Welcome to FriendUP!' } );

The code snippet above shows a couple of lines from the example application. A screen is instantiated with a configuration object. The following properties are supported:

title – String – no default – title of the View

background – Custom background image or color

There are more options that the system uses internally. For application development, these are not relevant.

Methods in the Screen class

The Screen class provides the following functions to let developers set the Screen contents:

setContent( content, callback ) – sets content as the content of the Screen; content should be an HTML string. The content will be added as child to the body tag in the iFrame the Screen uses. Standard theme dependent Friend CSS is applied. The API is available. The content string will be stripped from inline script and style tags. The callback is executed once the content has been set.

setRichContentUrl( url ) – sets the content to be an iFrame with the source defined by the url parameter. The API is not available. No Friend theme CSS is applied to the content.

loadTemplate( url ) – load a template from an URL. API is not available.

screenToFront() – Makes this screen the front most screen.

sendMessage( dataObject ) – sends a message to the main Application object that is located in the scope of the screen. Each screen has its own Application object when it is using the API. The main Application should keep track of its screens so that it can send messages between them.

setMenuItems( jsonObject ) – sets the menu for the screen. The parameter it takes is in the form of a JSON object. Please read more in “Pulldown menus”.

Event hooks

The Screen class provides a couple of interfaces to let an application react to user interaction on the screen:

onClose – fires when the screen is closed. Either by click on the close button or by a function call from the Application that controls the screen.

Was this page helpful?