Source: src/main/javascript/oracle/oj/ojgauge/ojbasegauge.js

Oracle® JavaScript Extension Toolkit (JET)
1.1.2

E65298-01

/**
 * Copyright (c) 2014, Oracle and/or its affiliates.
 * All rights reserved.
 */

/**
 * @ojcomponent oj.dvtBaseGauge
 * @augments oj.dvtBaseComponent
 * @since 0.7
 * @abstract
 */
oj.__registerWidget('oj.dvtBaseGauge', $['oj']['dvtBaseComponent'], 
{
  //** @inheritdoc */
  _ProcessStyles: function() {
    // The superclass evaluates the style classes, including those in _GetChildStyleClasses
    this._super();
    
    // Transfer the threshold colors to the correct location
    this.options['_thresholdColors'] = [this.options['_threshold1'], this.options['_threshold2'], this.options['_threshold3']];
    this.options['_threshold1'] = null;
    this.options['_threshold2'] = null;
    this.options['_threshold3'] = null;
  },
  
  //** @inheritdoc */
  _GetChildStyleClasses : function() {
    var styleClasses = this._super();
    styleClasses['oj-gauge-metric-label'] = {'path' : 'metricLabel/style', 'property' : 'CSS_TEXT_PROPERTIES'};
    styleClasses['oj-gauge-tick-label'] = {'path' : 'tickLabel/style', 'property' : 'CSS_TEXT_PROPERTIES'};
    styleClasses['oj-gauge-threshold1'] = {'path' : '_threshold1', 'property' : 'color'};
    styleClasses['oj-gauge-threshold2'] = {'path' : '_threshold2', 'property' : 'color'};
    styleClasses['oj-gauge-threshold3'] = {'path' : '_threshold3', 'property' : 'color'};
    return styleClasses;
  },
    
  //** @inheritdoc */
  _GetEventTypes : function() {
    return ['input', 'optionChange'];
  },
  
  //** @inheritdoc */
  _GetTranslationMap: function() {
    // The translations are stored on the options object.
    var translations = this.options['translations'];
    
    // Safe to modify super's map because function guarentees a new map is returned
    var ret = this._super();
    ret['DvtGaugeBundle.EMPTY_TEXT'] = this._GetTranslatedResource('labelNoData');
    ret['DvtUtilBundle.GAUGE'] = translations['componentName'];
    return ret;
  },
  
  //** @inheritdoc */
  _HandleEvent : function(event) {
    var type = event && event.getType ? event.getType() : null;
    if(type === dvt.DvtValueChangeEvent.TYPE) {
      // Fired after the value change interaction is complete
      this._UserOptionChange('value', event.getNewValue());
    }
    else if(type === dvt.DvtValueChangeEvent.TYPE_INPUT) {
      // Fired during the value change interaction for each change
      this._trigger('input', null, {'value': event.getNewValue()});
    }
    else {
      this._super(event);
    }
  },
  
  //** @inheritdoc */
  _ConvertLocatorToSubId : function(locator) {
    var subId = locator['subId'];
    
    // Convert the supported locators
    if(subId == 'oj-dialgauge-tooltip' || subId == 'oj-ledgauge-tooltip' || subId == 'oj-ratinggauge-tooltip' || subId == 'oj-statusmetergauge-tooltip') {
      subId = 'tooltip';
    }
    
    // Return the converted result or the original subId if a supported locator wasn't recognized. We will remove
    // support for the old subId syntax in 1.2.0.
    return subId;
  }
}, true);