Class: Context

CIQ.UI. Context


new Context(stx, topNode [, params])

UI context helper class.

Designed to be used as a helper method for the included WebComponents. A full tutorial on how to work with and customize the Web Components can be found here: Web Component Interface

Construct with an CIQ.ChartEngine object

Parameters:
Name Type Argument Description
stx CIQ.ChartEngine

The chart object to associate this UI

topNode HTMLElement

The top node of the DOM tree for this context. That node should contain all of the UI elements associated with the CIQ.ChartEngine

params object <optional>

Optional parameters

Methods


advertiseAs(uiHelper, helperName)

Attaches a Helper to the context, so that it can be found later on.

Designed to be used as a helper method for the included WebComponents. A full tutorial on how to work with and customize the Web Components can be found here: Web Component Interface

Parameters:
Name Type Description
uiHelper CIQ.UI.Helper

A UI Helper to attach

helperName string

The helperName of the element. For instance "Loader"


changeSymbol(data)

Abstract method that should be overridden. See example.

Designed to be used as a helper method for the included WebComponents. A full tutorial on how to work with and customize the Web Components can be found here: Web Component Interface

Parameters:
Name Type Description
data Object

A symbol data object acceptable for CIQ.ChartEngine#loadChart

Example
UIContext.changeSymbol=function(data){
		var stx=this.stx;
		if(this.loader) this.loader.show();
		if(data.symbol==data.symbol.toLowerCase())
			data.symbol=data.symbol.toUpperCase(); // set a pretty display version


		// reset comparisons - remove this loop to transfer from symbol to symbol.
		for(var field in stx.chart.series) {
			// keep studies
			if (stxx.chart.series[field].parameters.bucket != "study" ) stx.removeSeries(field);
		}

		var self=this;
		stx.loadChart(data, function(err) {
			if(err){
				// add 'symbol not found error' here if one needed.
				if(self.loader) self.loader.hide();
				return;

			}
			if(self.loader) self.loader.hide();
			restoreDrawings(stx, stx.chart.symbol);
		});
	};

isModal()

Checks if the context in modal mode.

Designed to be used as a helper method for the included WebComponents. A full tutorial on how to work with and customize the Web Components can be found here: Web Component Interface

Returns:

true if in modal mode

Type
Boolean

setLoader(loader)

Attaches a loader to a UI context.

Designed to be used as a helper method for the included WebComponents. A full tutorial on how to work with and customize the Web Components can be found here: Web Component Interface

Parameters:
Name Type Description
loader CIQ.UI.Loader

Loader instance


setLookupDriver(driver)

Sets the lookup driver to be used with the cq-lookup web component.

Designed to be used as a helper method for the included WebComponents. A full tutorial on how to work with and customize the Web Components can be found here: Web Component Interface

The lookup driver will be called to search for matching symbols as data is typed into the set UIContext.UISymbolLookup field.

See function startUI() in sample-template-advanced.html for complete sample implementation.

Parameters:
Name Type Description
driver CIQ.ChartEngine.Driver.Lookup

Lookup driver for cq-lookup component

Example
UIContext=new CIQ.UI.Context(stxx, $("cq-context,[cq-context]"));
UIContext.setLookupDriver(new CIQ.ChartEngine.Driver.Lookup.ChartIQ());
UIContext.UISymbolLookup=$(".ciq-search cq-lookup")[0];
UIContext.UISymbolLookup.setCallback(function(context, data){
	context.changeSymbol(data);
});