dfDataWidget.js
Summary
DreamFace DataWidget API
Author: DreamFace Interactive, Copyright 2007-2008, all rights reserved.
Version: Outsider rev.5
|
Class Summary
|
| DataWidget |
This is the basic class that represents a DataWidget. |
| InteractionEvent |
This is the basic class that represents a interaction event. |
function DataWidget( dataWidgetDefinition ) {
this.name = null;
this.title = null;
this.titleVisibility = null;
this.widgetClass = null;
this.template = null;
this.directory = null;
this.parameters = null;
this.preferences = null;
this.dataSourceName = null;
this.dataSource = null;
this.dataSourceParameters = null;
this.data = null;
this.dataAsText = null;
this.construct( dataWidgetDefinition );
return this;
}
DataWidget.prototype.type="DataWidget";
DataWidget.prototype.construct=function( dataWidgetDefinition ) {
if (dataWidgetDefinition != null) {
this.name = $(dataWidgetDefinition).find("name").text();
this.widgetClass = $(dataWidgetDefinition).find("class").text();
this.title = $(dataWidgetDefinition).find("title").text();
this.titleVisibility = $(dataWidgetDefinition).find("titleBarVisible").text();
}
}
DataWidget.prototype.getName=function() {
return this.name;
}
DataWidget.prototype.setName=function( name ) {
this.name = name;
}
DataWidget.prototype.getTitle=function() {
return this.title;
}
DataWidget.prototype.setTitle=function( title ) {
this.title = title;
}
DataWidget.prototype.getTitleVisibility=function() {
return this.titleVisibility;
}
DataWidget.prototype.setTitleVisibility=function( titleVisibility ) {
this.titleVisibility = titleVisibility;
}
DataWidget.prototype.getWidth=function() {
var aWidth = $("div[@id=wincontent_"+this.name+"]").width();
return aWidth;
}
DataWidget.prototype.getHeight=function() {
var aWidth = $("div[@id=wincontent_"+this.name+"]").height();
return aWidth;
}
DataWidget.prototype.getWidgetClassName=function() {
return this.widgetClass;
}
DataWidget.prototype.setWidgetClassName=function( widgetClassName ) {
this.widgetClass = widgetClassName;
}
DataWidget.prototype.getWidgetClass=function() {
return dfGetClassDef( this.widgetClass );
}
DataWidget.prototype.getTemplateName=function() {
return this.template;
}
DataWidget.prototype.getTemplate=function() {
return dfGetTemplate( this.template );
}
DataWidget.prototype.setTemplate=function( template ) {
this.template = template;
}
DataWidget.prototype.loadTemplate=function( template ) {
if (template != null)
this.template = template;
var aTemplate = dfGetTemplate( this.template );
this.directory = $("directory", aTemplate).text();
return aTemplate;
}
DataWidget.prototype.getRenderer=function() {
return dfGetRenderer( this.template );
}
DataWidget.prototype.getDataSourceName=function() {
return this.dataSourceName;
}
DataWidget.prototype.setDataSourceName=function( dataSourceName ) {
this.dataSourceName = dataSourceName;
}
DataWidget.prototype.getDataSourceParameters=function() {
return this.dataSourceParameters;
}
DataWidget.prototype.setDataSourceParameters=function( parameters ) {
this.dataSourceParameters = parameters;
}
DataWidget.prototype.setDataSourceParameter=function( paramName, paramValue ) {
if ($("parameter[@name="+paramName+"]", this.dataSourceParameters).size() > 0) {
$("parameter[@name="+paramName+"]", this.dataSourceParameters).text( paramValue );
} else {
var elemParam = document.createElement("<parameter>");
elemParam.setAttribute("name",paramName);
$(this.dataSourceParameters)[0].appendChild( elemParam );
$("parameter[@name="+paramName+"]", this.dataSourceParameters).text( paramValue );
}
}
DataWidget.prototype.setDataSourceRequest=function( request ) {
var reg = new RegExp("( )", "g");
var anEncodedRequest = request.replace( reg, "%20" );
if (this.dataSource != null) {
$("request", this.dataSource).text( anEncodedRequest );
}
}
DataWidget.prototype.executeDataSource=function() {
var aDataWidgetInstance = this;
if (aDataWidgetInstance.dataSourceName != null && aDataWidgetInstance.dataSourceName != "") {
if (aDataWidgetInstance.dataSource == null) {
$.ajax({
type: "GET",
url: "dfe/interface?entity=datasources",
async: false,
data: "identifierName=FieldName&identifierValue="+aDataWidgetInstance.dataSourceName,
success: function(xml) {
var oDom = XML.parse(xml);
aDataWidgetInstance.dataSourceText = xml;
aDataWidgetInstance.dataSource = $("datasource[@name=" + aDataWidgetInstance.dataSourceName + "]:first", oDom);
}
});
}
aDataWidgetInstance.loadData();
} else {
var aRenderer = aDataWidgetInstance.getRenderer();
$("TemplateFunction:first", aRenderer).each( function(i) {
var aTemplateFunction = new Function( "pDataWidget", $(this).text() );
aTemplateFunction( aDataWidgetInstance );
});
}
}
DataWidget.prototype.loadData=function() {
var aDataWidgetInstance = this;
var sConnector = $(aDataWidgetInstance.dataSource).find("connector").text() ;
var sLocation = $(aDataWidgetInstance.dataSource).find("location").text() ;
var sPort = $(aDataWidgetInstance.dataSource).find("port").text() ;
var sRequest = $(aDataWidgetInstance.dataSource).find("request").text() ;
var oParameters = $(aDataWidgetInstance.dataSource).find("parameters") ;
dfDataSourceParamSubstitution( oParameters, aDataWidgetInstance.dataSourceParameters );
var sParameters = (oParameters==null) ? "" : XML.serialize(oParameters[0]);
$.get("dfe/interface/data", {
connector: sConnector,
location: sLocation,
port: sPort,
request: sRequest,
parameters: sParameters
}, function(xml) {
aDataWidgetInstance.dataAsText = xml;
var oDom = XML.parse(xml);
aDataWidgetInstance.data = oDom;
var aRenderer = aDataWidgetInstance.getRenderer();
$("TemplateFunction:first", aRenderer).each( function(i) {
var aTemplateFunction = new Function( "pDataWidget", $(this).text() );
aTemplateFunction( aDataWidgetInstance );
});
}
);
}
DataWidget.prototype.refreshData=function( callbackFunction ) {
var aDataWidgetInstance = this;
var sConnector = $(aDataWidgetInstance.dataSource).find("connector").text() ;
var sLocation = $(aDataWidgetInstance.dataSource).find("location").text() ;
var sPort = $(aDataWidgetInstance.dataSource).find("port").text() ;
var sRequest = $(aDataWidgetInstance.dataSource).find("request").text() ;
var oParameters = $(aDataWidgetInstance.dataSource).find("parameters") ;
dfDataSourceParamSubstitution( oParameters, aDataWidgetInstance.dataSourceParameters );
var sParameters = (oParameters==null) ? "" : XML.serialize(oParameters[0]);
$.get("dfe/interface/data", {
connector: sConnector,
location: sLocation,
port: sPort,
request: sRequest,
parameters: sParameters
}, function(xml) {
aDataWidgetInstance.dataAsText = xml;
var oDom = XML.parse(xml);
aDataWidgetInstance.data = oDom;
aCallbackFunction = new Function( callbackFunction );
aCallbackFunction();
}
);
}
DataWidget.prototype.getData=function() {
return this.data;
}
DataWidget.prototype.setData=function( data ) {
this.data = data;
}
DataWidget.prototype.getDataAsText=function() {
return this.dataAsText;
}
DataWidget.prototype.setDataAsText=function( dataAsText ) {
this.dataAsText = dataAsText;
}
DataWidget.prototype.getParameters=function() {
if (this.parameters == null) {
var aClassNode = this.getWidgetClass();
this.parameters = $("parameters:first", aClassNode);
}
return this.parameters;
}
DataWidget.prototype.getParametersAsText=function() {
if (this.parameters == null) {
var aClassNode = this.getWidgetClass();
this.parameters = $("parameters:first", aClassNode);
}
return XML.serialize(this.parameters);
}
DataWidget.prototype.getParameter=function(paramName) {
if (this.parameters == null) {
var aClassNode = this.getWidgetClass();
this.parameters = $("parameters:first", aClassNode);
}
var aParamValue = $(this.parameters).find("parameter[@name="+paramName+"]").text();
return aParamValue;
}
DataWidget.prototype.getPreferences=function() {
if (this.preferences == null) {
this.preferences = dfGetViewPreference( this.name );
}
return this.preferences
}
DataWidget.prototype.getPreferencesAsText=function() {
var aReturnValue = "";
if (this.preferences == null) {
this.preferences = dfGetViewPreference( this.name );
if (this.preferences != null) {
aReturnValue = XML.serialize( this.preferences );
}
}
return aReturnValue;
}
DataWidget.prototype.setPreference=function(name, value) {
if (this.preferences == null) {
$(name, this.preferences).text( "<![CDATA["+value+"]]>" );
}
}
DataWidget.prototype.savePreferences=function(callback) {
if (this.preferences == null) {
var sXML = XML.serialize( this.preferences );
$.post( "dfe/interface/add/preference", {
FieldUserID: ( dfCurrentDesignPage != "undefined" && dfProducerID == "undefined" ) ? "*" : dfUserID,
FieldType: "view",
FieldName: dfGetCurrentPage()+"/"+this.name,
FieldValue: sXML
}, function(xml){
if (callback != null) {
var aCallbackFunction = new Function( callbackFunction+"()" );
aCallbackFunction();
}
});
}
}
DataWidget.prototype.reload=function() {
this.preferences = null;
this.clearContent();
dfLoadViewContent( this );
}
DataWidget.prototype.redraw=function() {
var aDataWidgetInstance = this;
aDataWidgetInstance.clearContent();
var aRenderer = aDataWidgetInstance.getRenderer();
$("TemplateFunction:first", aRenderer).each( function(i) {
var aTemplateFunction = new Function( "pDataWidget", $(this).text() );
aTemplateFunction( aDataWidgetInstance );
});
}
DataWidget.prototype.addContent=function( fragment ) {
$( "div[@id=wincontent_"+this.name+"]" ).append( fragment );
}
DataWidget.prototype.clearContent=function() {
$("div[@id=wincontent_"+this.name+"]").empty();
}
DataWidget.prototype.setDirectory=function( directory ) {
this.directory = directory;
}
DataWidget.prototype.getDirectory=function() {
return this.directory;
}
DataWidget.prototype.setDirectoryComponent=function( component ) {
$("div[@itemID="+this.getName()+"]").attr( "directorycomponent", component );
}
DataWidget.prototype.getDirectoryComponent=function() {
return $("div[@itemID="+this.getName()+"]").attr( "directorycomponent" );
}
DataWidget.prototype.getDirectoryComponentBinding=function() {
var returnValue = "";
var aDirectoryComponent = this.getDirectoryComponent();
if (aDirectoryComponent != null && aDirectoryComponent != "") {
$.ajax({
type: "GET",
url: dfRootDomain+"/df/dfe/interface/directory",
async: false,
data: "name="+this.getDirectory()+"&component="+aDirectoryComponent,
success: function(xml) {
var componentDom = XML.parse( xml );
returnValue = $("source", componentDom).attr("binding");
}
});
}
return returnValue;
}
function InteractionEvent( interactionName ) {
this.name = null;
this.action = null;
this.source = null;
this.target = null;
this.construct( interactionName );
return this;
}
InteractionEvent.prototype.type="InteractionEvent";
InteractionEvent.prototype.construct=function( interactionName ) {
this.name = interactionName;
}
InteractionEvent.prototype.getName=function() {
return this.name;
}
InteractionEvent.prototype.setSource=function( source ) {
this.source = source;
}
InteractionEvent.prototype.getSource=function() {
return this.source;
}
InteractionEvent.prototype.setTarget=function( target ) {
this.target = target;
}
InteractionEvent.prototype.getTarget=function() {
return this.target;
}
InteractionEvent.prototype.setAction=function( action ) {
this.action = action;
}
InteractionEvent.prototype.getAction=function() {
return this.action;
}
Documentation generated by
JSDoc on Wed Jun 18 09:59:49 2008