Add method to bind bluring on mouseout/focusout

This commit is contained in:
Marc Jansen
2015-05-26 22:23:23 +02:00
parent ec208916d2
commit 41596d808b
6 changed files with 24 additions and 30 deletions

View File

@@ -3,6 +3,7 @@ goog.provide('ol.control.Control');
goog.require('goog.array');
goog.require('goog.dom');
goog.require('goog.events');
goog.require('goog.events.EventType');
goog.require('ol.MapEventType');
goog.require('ol.Object');
@@ -78,6 +79,24 @@ ol.control.Control = function(options) {
goog.inherits(ol.control.Control, ol.Object);
/**
* Bind a listener that blurs the passed element on any mouseout- or
* focusout-event.
*
* @param {!Element} button The button which shall blur on mouseout- or
* focusout-event.
* @protected
*/
ol.control.Control.bindMouseOutFocusOutBlur = function(button) {
goog.events.listen(button, [
goog.events.EventType.MOUSEOUT,
goog.events.EventType.FOCUSOUT
], /** @this {Element} */ function() {
this.blur();
}, false);
};
/**
* @inheritDoc
*/

View File

@@ -67,12 +67,7 @@ ol.control.FullScreen = function(opt_options) {
goog.events.listen(button, goog.events.EventType.CLICK,
this.handleClick_, false, this);
goog.events.listen(button, [
goog.events.EventType.MOUSEOUT,
goog.events.EventType.FOCUSOUT
], function() {
this.blur();
}, false);
ol.control.Control.bindMouseOutFocusOutBlur(button);
goog.events.listen(goog.global.document,
goog.dom.fullscreen.EventType.CHANGE,

View File

@@ -90,12 +90,7 @@ ol.control.OverviewMap = function(opt_options) {
goog.events.listen(button, goog.events.EventType.CLICK,
this.handleClick_, false, this);
goog.events.listen(button, [
goog.events.EventType.MOUSEOUT,
goog.events.EventType.FOCUSOUT
], function() {
this.blur();
}, false);
ol.control.Control.bindMouseOutFocusOutBlur(button);
var ovmapDiv = goog.dom.createDom(goog.dom.TagName.DIV, 'ol-overviewmap-map');

View File

@@ -60,12 +60,7 @@ ol.control.Rotate = function(opt_options) {
goog.events.listen(button, goog.events.EventType.CLICK,
ol.control.Rotate.prototype.handleClick_, false, this);
goog.events.listen(button, [
goog.events.EventType.MOUSEOUT,
goog.events.EventType.FOCUSOUT
], function() {
this.blur();
}, false);
ol.control.Control.bindMouseOutFocusOutBlur(button);
var cssClasses = className + ' ' + ol.css.CLASS_UNSELECTABLE + ' ' +
ol.css.CLASS_CONTROL;

View File

@@ -50,12 +50,7 @@ ol.control.Zoom = function(opt_options) {
goog.events.EventType.CLICK, goog.partial(
ol.control.Zoom.prototype.handleClick_, delta), false, this);
goog.events.listen(inElement, [
goog.events.EventType.MOUSEOUT,
goog.events.EventType.FOCUSOUT
], function() {
this.blur();
}, false);
ol.control.Control.bindMouseOutFocusOutBlur(inElement);
var outElement = goog.dom.createDom(goog.dom.TagName.BUTTON, {
'class': className + '-out',

View File

@@ -43,12 +43,7 @@ ol.control.ZoomToExtent = function(opt_options) {
goog.events.listen(button, goog.events.EventType.CLICK,
this.handleClick_, false, this);
goog.events.listen(button, [
goog.events.EventType.MOUSEOUT,
goog.events.EventType.FOCUSOUT
], function() {
this.blur();
}, false);
ol.control.Control.bindMouseOutFocusOutBlur(button);
var cssClasses = className + ' ' + ol.css.CLASS_UNSELECTABLE + ' ' +
ol.css.CLASS_CONTROL;