Change ol.Object event name syntax

'changed' to 'change' and '<attribute>_changed' to 'change:<attribute>'.
This commit is contained in:
Frederic Junod
2013-05-07 16:09:19 +02:00
parent 5e5d8e5b17
commit 984002a7ec
10 changed files with 46 additions and 46 deletions

View File

@@ -34,10 +34,10 @@ ol.dom.Input = function(target) {
this.handleInputChanged_, false, this);
goog.events.listen(this,
ol.Object.getChangedEventType(ol.dom.InputProperty.VALUE),
ol.Object.getChangeEventType(ol.dom.InputProperty.VALUE),
this.handleValueChanged_, false, this);
goog.events.listen(this,
ol.Object.getChangedEventType(ol.dom.InputProperty.CHECKED),
ol.Object.getChangeEventType(ol.dom.InputProperty.CHECKED),
this.handleCheckedChanged_, false, this);
};
goog.inherits(ol.dom.Input, ol.Object);

View File

@@ -60,10 +60,10 @@ ol.Geolocation = function(opt_options) {
this.watchId_ = undefined;
goog.events.listen(
this, ol.Object.getChangedEventType(ol.GeolocationProperty.PROJECTION),
this, ol.Object.getChangeEventType(ol.GeolocationProperty.PROJECTION),
this.handleProjectionChanged_, false, this);
goog.events.listen(
this, ol.Object.getChangedEventType(ol.GeolocationProperty.TRACKING),
this, ol.Object.getChangeEventType(ol.GeolocationProperty.TRACKING),
this.handleTrackingChanged_, false, this);
if (goog.isDef(options.projection)) {

View File

@@ -307,13 +307,13 @@ ol.Map = function(options) {
*/
this.layersListenerKeys_ = null;
goog.events.listen(this, ol.Object.getChangedEventType(ol.MapProperty.LAYERS),
goog.events.listen(this, ol.Object.getChangeEventType(ol.MapProperty.LAYERS),
this.handleLayersChanged_, false, this);
goog.events.listen(this, ol.Object.getChangedEventType(ol.MapProperty.VIEW),
goog.events.listen(this, ol.Object.getChangeEventType(ol.MapProperty.VIEW),
this.handleViewChanged_, false, this);
goog.events.listen(this, ol.Object.getChangedEventType(ol.MapProperty.SIZE),
goog.events.listen(this, ol.Object.getChangeEventType(ol.MapProperty.SIZE),
this.handleSizeChanged_, false, this);
goog.events.listen(this, ol.Object.getChangedEventType(ol.MapProperty.TARGET),
goog.events.listen(this, ol.Object.getChangeEventType(ol.MapProperty.TARGET),
this.handleTargetChanged_, false, this);
// setValues will trigger the rendering of the map if the map
@@ -727,7 +727,7 @@ ol.Map.prototype.handleViewChanged_ = function() {
var view = this.getView();
if (goog.isDefAndNotNull(view)) {
this.viewPropertyListenerKey_ = goog.events.listen(
view, ol.ObjectEventType.CHANGED,
view, ol.ObjectEventType.CHANGE,
this.handleViewPropertyChanged_, false, this);
}
this.render();

View File

@@ -18,7 +18,7 @@ goog.require('goog.object');
* @enum {string}
*/
ol.ObjectEventType = {
CHANGED: 'changed'
CHANGE: 'change'
};
@@ -57,7 +57,7 @@ goog.inherits(ol.Object, goog.events.EventTarget);
* @private
* @type {Object.<string, string>}
*/
ol.Object.changedEventTypeCache_ = {};
ol.Object.changeEventTypeCache_ = {};
/**
@@ -95,12 +95,12 @@ ol.Object.getAccessors = function(obj) {
/**
* @param {string} key Key.
* @return {string} Changed name.
* @return {string} Change name.
*/
ol.Object.getChangedEventType = function(key) {
return ol.Object.changedEventTypeCache_.hasOwnProperty(key) ?
ol.Object.changedEventTypeCache_[key] :
(ol.Object.changedEventTypeCache_[key] = key.toLowerCase() + '_changed');
ol.Object.getChangeEventType = function(key) {
return ol.Object.changeEventTypeCache_.hasOwnProperty(key) ?
ol.Object.changeEventTypeCache_[key] :
(ol.Object.changeEventTypeCache_[key] = 'change:' + key.toLowerCase());
};
@@ -146,7 +146,7 @@ ol.Object.prototype.bindTo =
function(key, target, opt_targetKey, opt_noNotify) {
var targetKey = opt_targetKey || key;
this.unbind(key);
var eventType = ol.Object.getChangedEventType(targetKey);
var eventType = ol.Object.getChangeEventType(targetKey);
var listeners = ol.Object.getListeners(this);
listeners[key] = goog.events.listen(target, eventType, function() {
this.notifyInternal_(key);
@@ -217,9 +217,9 @@ ol.Object.prototype.notify = function(key) {
* @private
*/
ol.Object.prototype.notifyInternal_ = function(key) {
var eventType = ol.Object.getChangedEventType(key);
var eventType = ol.Object.getChangeEventType(key);
this.dispatchEvent(eventType);
this.dispatchEvent(ol.ObjectEventType.CHANGED);
this.dispatchEvent(ol.ObjectEventType.CHANGE);
};

View File

@@ -69,20 +69,20 @@ ol.Overlay = function(options) {
};
goog.events.listen(
this, ol.Object.getChangedEventType(ol.OverlayProperty.ELEMENT),
this, ol.Object.getChangeEventType(ol.OverlayProperty.ELEMENT),
this.handleElementChanged, false, this);
goog.events.listen(
this, ol.Object.getChangedEventType(ol.OverlayProperty.MAP),
this, ol.Object.getChangeEventType(ol.OverlayProperty.MAP),
this.handleMapChanged, false, this);
goog.events.listen(
this, ol.Object.getChangedEventType(ol.OverlayProperty.POSITION),
this, ol.Object.getChangeEventType(ol.OverlayProperty.POSITION),
this.handlePositionChanged, false, this);
goog.events.listen(
this,
ol.Object.getChangedEventType(ol.OverlayProperty.POSITIONING),
ol.Object.getChangeEventType(ol.OverlayProperty.POSITIONING),
this.handlePositioningChanged, false, this);
if (goog.isDef(options.element)) {

View File

@@ -43,30 +43,30 @@ ol.renderer.Layer = function(mapRenderer, layer) {
this.layer_ = layer;
goog.events.listen(this.layer_,
ol.Object.getChangedEventType(ol.layer.LayerProperty.BRIGHTNESS),
ol.Object.getChangeEventType(ol.layer.LayerProperty.BRIGHTNESS),
this.handleLayerBrightnessChange, false, this);
goog.events.listen(this.layer_,
ol.Object.getChangedEventType(ol.layer.LayerProperty.CONTRAST),
ol.Object.getChangeEventType(ol.layer.LayerProperty.CONTRAST),
this.handleLayerContrastChange, false, this);
goog.events.listen(this.layer_,
ol.Object.getChangedEventType(ol.layer.LayerProperty.HUE),
ol.Object.getChangeEventType(ol.layer.LayerProperty.HUE),
this.handleLayerHueChange, false, this);
goog.events.listen(this.layer_, goog.events.EventType.LOAD,
this.handleLayerLoad, false, this);
goog.events.listen(this.layer_,
ol.Object.getChangedEventType(ol.layer.LayerProperty.OPACITY),
ol.Object.getChangeEventType(ol.layer.LayerProperty.OPACITY),
this.handleLayerOpacityChange, false, this);
goog.events.listen(this.layer_,
ol.Object.getChangedEventType(ol.layer.LayerProperty.SATURATION),
ol.Object.getChangeEventType(ol.layer.LayerProperty.SATURATION),
this.handleLayerSaturationChange, false, this);
goog.events.listen(this.layer_,
ol.Object.getChangedEventType(ol.layer.LayerProperty.VISIBLE),
ol.Object.getChangeEventType(ol.layer.LayerProperty.VISIBLE),
this.handleLayerVisibleChange, false, this);
};