...
Scope: The core layer passes on view port container element to this class, so that it does not have to query the DOM to get the parent element on which it has to be appended.
Sample Code Snippet:
Code Block |
---|
|
cbx.lib.ApplicationContainer = Class(cbx.core.Component, {
layoutManager: '',
constructor: function(config){
this.wsManagerConfig = config;
cbx.lib.ApplicationContainer.$super.call(this);
this.createItems();
},
createItems: function() {
var appContainerConfig = {
"eleType":"div",
"id":"application-container"
};
var appContainerObj = new cbx.lib.layer(appContainerConfig).getLayer();
this.addItem(appContainerObj);
delete appContainerConfig;
/* Start process of creating the workspace and layout */
var wsContainerConfig;
var wsArr = cbx.core.ws.metadata.getWorkspaces();
cbx.lib.workspacehandler.createWorkspaces(wsArr,this);
},
/* Return the object of app container containing the workspaces*/
getAppContainer: function() {
return this.getItem(0);
}
});
CLCR.registerCmp({'COMP_TYPE':'APPLICATION_CONTAINER'},cbx.lib.ApplicationContainer); |
It has to be noted in the above snippet that canvas.lib.workspacehandler.createWorkspaces() is a utility API which creates the workspace elements for the array of the workspaces passed, and finally appends to the parent element. Here is what this utility API is supposed to do.
Code Block |
---|
|
var workspaceContainerConfig = {
"eleType": "div",
"id" : wsArray[index].WORKSPACE_ID,
"class": "workspace "+wsArray[index].WORKSPACE_ID,
"style": {
"display":"none"
}
};
var wcContainerObject = new canvas.lib.layer(workspaceContainerConfig).getLayer();
$(this.appContainer.getItem(0)).append($(wcContainerObject)); |
The following code snippet shows the usage of workspace selection handler:
Code Block |
---|
|
activateWorkspace: function(workspaceId,index,callBackFn,scope){
callBackFn = cbx.isFunction(callBackFn)?callBackFn:cbx.emptyFn;
scope = scope?scope: this;
var config = {
WORKSPACE_ID:workspaceId,
SYSTEM_WORKSPACE_IND:SYSTEM_WORKSPACE_IND
};
/**
* Pre workspace activate operations here
*/
cbx.core.ws.metadata.getWorkspaceManager().wsSelectionHandler(config,null,function(wsContainer){
/**
* Post workspace activate operations here
*/
},scope);
}
|