Merge pull request #4810 from gberaudo/control_undefined_checks

Add checks for undefined in controls
This commit is contained in:
Frédéric Junod
2016-02-11 11:26:23 +01:00
9 changed files with 28 additions and 26 deletions
+4 -4
View File
@@ -64,11 +64,11 @@ ol.control.Attribution = function(opt_options) {
this.collapsed_ = false; this.collapsed_ = false;
} }
var className = options.className ? options.className : 'ol-attribution'; var className = options.className !== undefined ? options.className : 'ol-attribution';
var tipLabel = options.tipLabel ? options.tipLabel : 'Attributions'; var tipLabel = options.tipLabel !== undefined ? options.tipLabel : 'Attributions';
var collapseLabel = options.collapseLabel ? options.collapseLabel : '\u00BB'; var collapseLabel = options.collapseLabel !== undefined ? options.collapseLabel : '\u00BB';
/** /**
* @private * @private
@@ -78,7 +78,7 @@ ol.control.Attribution = function(opt_options) {
goog.dom.createDom('SPAN', {}, collapseLabel) : goog.dom.createDom('SPAN', {}, collapseLabel) :
collapseLabel; collapseLabel;
var label = options.label ? options.label : 'i'; var label = options.label !== undefined ? options.label : 'i';
/** /**
* @private * @private
+4 -3
View File
@@ -37,9 +37,10 @@ ol.control.FullScreen = function(opt_options) {
* @private * @private
* @type {string} * @type {string}
*/ */
this.cssClassName_ = options.className ? options.className : 'ol-full-screen'; this.cssClassName_ = options.className !== undefined ? options.className :
'ol-full-screen';
var label = options.label ? options.label : '\u2922'; var label = options.label !== undefined ? options.label : '\u2922';
/** /**
* @private * @private
@@ -48,7 +49,7 @@ ol.control.FullScreen = function(opt_options) {
this.labelNode_ = typeof label === 'string' ? this.labelNode_ = typeof label === 'string' ?
document.createTextNode(label) : label; document.createTextNode(label) : label;
var labelActive = options.labelActive ? options.labelActive : '\u00d7'; var labelActive = options.labelActive !== undefined ? options.labelActive : '\u00d7';
/** /**
* @private * @private
+3 -2
View File
@@ -40,7 +40,8 @@ ol.control.MousePosition = function(opt_options) {
var options = opt_options ? opt_options : {}; var options = opt_options ? opt_options : {};
var className = options.className ? options.className : 'ol-mouse-position'; var className = options.className !== undefined ? options.className :
'ol-mouse-position';
var element = goog.dom.createDom('DIV', className); var element = goog.dom.createDom('DIV', className);
@@ -68,7 +69,7 @@ ol.control.MousePosition = function(opt_options) {
* @private * @private
* @type {string} * @type {string}
*/ */
this.undefinedHTML_ = options.undefinedHTML ? options.undefinedHTML : ''; this.undefinedHTML_ = options.undefinedHTML !== undefined ? options.undefinedHTML : '';
/** /**
* @private * @private
+4 -4
View File
@@ -52,11 +52,11 @@ ol.control.OverviewMap = function(opt_options) {
this.collapsed_ = false; this.collapsed_ = false;
} }
var className = options.className ? options.className : 'ol-overviewmap'; var className = options.className !== undefined ? options.className : 'ol-overviewmap';
var tipLabel = options.tipLabel ? options.tipLabel : 'Overview map'; var tipLabel = options.tipLabel !== undefined ? options.tipLabel : 'Overview map';
var collapseLabel = options.collapseLabel ? options.collapseLabel : '\u00AB'; var collapseLabel = options.collapseLabel !== undefined ? options.collapseLabel : '\u00AB';
/** /**
* @private * @private
@@ -66,7 +66,7 @@ ol.control.OverviewMap = function(opt_options) {
goog.dom.createDom('SPAN', {}, collapseLabel) : goog.dom.createDom('SPAN', {}, collapseLabel) :
collapseLabel; collapseLabel;
var label = options.label ? options.label : '\u00BB'; var label = options.label !== undefined ? options.label : '\u00BB';
/** /**
* @private * @private
+2 -2
View File
@@ -26,9 +26,9 @@ ol.control.Rotate = function(opt_options) {
var options = opt_options ? opt_options : {}; var options = opt_options ? opt_options : {};
var className = options.className ? options.className : 'ol-rotate'; var className = options.className !== undefined ? options.className : 'ol-rotate';
var label = options.label ? options.label : '\u21E7'; var label = options.label !== undefined ? options.label : '\u21E7';
/** /**
* @type {Element} * @type {Element}
+1 -1
View File
@@ -55,7 +55,7 @@ ol.control.ScaleLine = function(opt_options) {
var options = opt_options ? opt_options : {}; var options = opt_options ? opt_options : {};
var className = options.className ? options.className : 'ol-scale-line'; var className = options.className !== undefined ? options.className : 'ol-scale-line';
/** /**
* @private * @private
+6 -6
View File
@@ -24,16 +24,16 @@ ol.control.Zoom = function(opt_options) {
var options = opt_options ? opt_options : {}; var options = opt_options ? opt_options : {};
var className = options.className ? options.className : 'ol-zoom'; var className = options.className !== undefined ? options.className : 'ol-zoom';
var delta = options.delta ? options.delta : 1; var delta = options.delta !== undefined ? options.delta : 1;
var zoomInLabel = options.zoomInLabel ? options.zoomInLabel : '+'; var zoomInLabel = options.zoomInLabel !== undefined ? options.zoomInLabel : '+';
var zoomOutLabel = options.zoomOutLabel ? options.zoomOutLabel : '\u2212'; var zoomOutLabel = options.zoomOutLabel !== undefined ? options.zoomOutLabel : '\u2212';
var zoomInTipLabel = options.zoomInTipLabel ? var zoomInTipLabel = options.zoomInTipLabel !== undefined ?
options.zoomInTipLabel : 'Zoom in'; options.zoomInTipLabel : 'Zoom in';
var zoomOutTipLabel = options.zoomOutTipLabel ? var zoomOutTipLabel = options.zoomOutTipLabel !== undefined ?
options.zoomOutTipLabel : 'Zoom out'; options.zoomOutTipLabel : 'Zoom out';
var inElement = goog.dom.createDom('BUTTON', { var inElement = goog.dom.createDom('BUTTON', {
+1 -1
View File
@@ -98,7 +98,7 @@ ol.control.ZoomSlider = function(opt_options) {
*/ */
this.duration_ = options.duration !== undefined ? options.duration : 200; this.duration_ = options.duration !== undefined ? options.duration : 200;
var className = options.className ? options.className : 'ol-zoomslider'; var className = options.className !== undefined ? options.className : 'ol-zoomslider';
var thumbElement = goog.dom.createDom('BUTTON', { var thumbElement = goog.dom.createDom('BUTTON', {
'type': 'button', 'type': 'button',
'class': className + '-thumb ' + ol.css.CLASS_UNSELECTABLE 'class': className + '-thumb ' + ol.css.CLASS_UNSELECTABLE
+3 -3
View File
@@ -27,11 +27,11 @@ ol.control.ZoomToExtent = function(opt_options) {
*/ */
this.extent_ = options.extent ? options.extent : null; this.extent_ = options.extent ? options.extent : null;
var className = options.className ? options.className : var className = options.className !== undefined ? options.className :
'ol-zoom-extent'; 'ol-zoom-extent';
var label = options.label ? options.label : 'E'; var label = options.label !== undefined ? options.label : 'E';
var tipLabel = options.tipLabel ? var tipLabel = options.tipLabel !== undefined ?
options.tipLabel : 'Fit to extent'; options.tipLabel : 'Fit to extent';
var button = goog.dom.createDom('BUTTON', { var button = goog.dom.createDom('BUTTON', {
'type': 'button', 'type': 'button',