Merge pull request #3135 from tsauerwein/control-label
Make changing the label of ZoomToExtent/FullScreen control consistent
This commit is contained in:
@@ -115,21 +115,12 @@
|
||||
background-color: #4c6079;
|
||||
background-color: rgba(0,60,136,0.7);
|
||||
}
|
||||
.ol-zoom-extent button:after {
|
||||
content: "E";
|
||||
}
|
||||
.ol-zoom .ol-zoom-in {
|
||||
border-radius: 2px 2px 0 0;
|
||||
}
|
||||
.ol-zoom .ol-zoom-out {
|
||||
border-radius: 0 0 2px 2px;
|
||||
}
|
||||
button.ol-full-screen-false:after {
|
||||
content: "\2194";
|
||||
}
|
||||
button.ol-full-screen-true:after {
|
||||
content: "\00d7";
|
||||
}
|
||||
|
||||
|
||||
.ol-attribution {
|
||||
|
||||
@@ -806,8 +806,8 @@ olx.control;
|
||||
* collapsible: (boolean|undefined),
|
||||
* collapsed: (boolean|undefined),
|
||||
* tipLabel: (string|undefined),
|
||||
* label: (string|undefined),
|
||||
* collapseLabel: (string|undefined),
|
||||
* label: (string|Node|undefined),
|
||||
* collapseLabel: (string|Node|undefined),
|
||||
* render: (function(ol.MapEvent)|undefined),
|
||||
* target: (Element|undefined)}}
|
||||
* @api
|
||||
@@ -859,15 +859,17 @@ olx.control.AttributionOptions.prototype.tipLabel;
|
||||
|
||||
|
||||
/**
|
||||
* Text label to use for the collapsed attributions button. Default is `i`
|
||||
* @type {string|undefined}
|
||||
* Text label to use for the collapsed attributions button. Default is `i`.
|
||||
* Instead of text, also a Node (e.g. a `span` element) can be used.
|
||||
* @type {string|Node|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.control.AttributionOptions.prototype.label;
|
||||
|
||||
/**
|
||||
* Text label to use for the expanded attributions button. Default is `»`
|
||||
* @type {string|undefined}
|
||||
* Text label to use for the expanded attributions button. Default is `»`.
|
||||
* Instead of text, also a Node (e.g. a `span` element) can be used.
|
||||
* @type {string|Node|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.control.AttributionOptions.prototype.collapseLabel;
|
||||
@@ -980,6 +982,8 @@ olx.control.DefaultsOptions.prototype.zoomOptions;
|
||||
|
||||
/**
|
||||
* @typedef {{className: (string|undefined),
|
||||
* label: (string|Node|undefined),
|
||||
* labelActive: (string|Node|undefined),
|
||||
* tipLabel: (string|undefined),
|
||||
* keys: (boolean|undefined),
|
||||
* target: (Element|undefined)}}
|
||||
@@ -996,6 +1000,25 @@ olx.control.FullScreenOptions;
|
||||
olx.control.FullScreenOptions.prototype.className;
|
||||
|
||||
|
||||
/**
|
||||
* Text label to use for the button. Default is `\u2194` (an arrow).
|
||||
* Instead of text, also a Node (e.g. a `span` element) can be used.
|
||||
* @type {string|Node|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.control.FullScreenOptions.prototype.label;
|
||||
|
||||
|
||||
/**
|
||||
* Text label to use for the button when full-screen is active.
|
||||
* Default is `\u00d7` (a cross).
|
||||
* Instead of text, also a Node (e.g. a `span` element) can be used.
|
||||
* @type {string|Node|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.control.FullScreenOptions.prototype.labelActive;
|
||||
|
||||
|
||||
/**
|
||||
* Text label to use for the button tip. Default is `Toggle full-screen`
|
||||
* @type {string|undefined}
|
||||
@@ -1083,9 +1106,9 @@ olx.control.MousePositionOptions.prototype.undefinedHTML;
|
||||
|
||||
/**
|
||||
* @typedef {{collapsed: (boolean|undefined),
|
||||
* collapseLabel: (string|undefined),
|
||||
* collapseLabel: (string|Node|undefined),
|
||||
* collapsible: (boolean|undefined),
|
||||
* label: (string|undefined),
|
||||
* label: (string|Node|undefined),
|
||||
* layers: (Array.<ol.layer.Layer>|ol.Collection|undefined),
|
||||
* render: (function(ol.MapEvent)|undefined),
|
||||
* target: (Element|undefined),
|
||||
@@ -1105,8 +1128,9 @@ olx.control.OverviewMapOptions.prototype.collapsed;
|
||||
|
||||
|
||||
/**
|
||||
* Text label to use for the expanded overviewmap button. Default is `«`
|
||||
* @type {string|undefined}
|
||||
* Text label to use for the expanded overviewmap button. Default is `«`.
|
||||
* Instead of text, also a Node (e.g. a `span` element) can be used.
|
||||
* @type {string|Node|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.control.OverviewMapOptions.prototype.collapseLabel;
|
||||
@@ -1121,8 +1145,9 @@ olx.control.OverviewMapOptions.prototype.collapsible;
|
||||
|
||||
|
||||
/**
|
||||
* Text label to use for the collapsed overviewmap button. Default is `»`
|
||||
* @type {string|undefined}
|
||||
* Text label to use for the collapsed overviewmap button. Default is `»`.
|
||||
* Instead of text, also a Node (e.g. a `span` element) can be used.
|
||||
* @type {string|Node|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.control.OverviewMapOptions.prototype.label;
|
||||
@@ -1218,7 +1243,7 @@ olx.control.ScaleLineOptions.prototype.units;
|
||||
/**
|
||||
* @typedef {{duration: (number|undefined),
|
||||
* className: (string|undefined),
|
||||
* label: (string|undefined),
|
||||
* label: (string|Node|undefined),
|
||||
* tipLabel: (string|undefined),
|
||||
* target: (Element|undefined),
|
||||
* render: (function(ol.MapEvent)|undefined),
|
||||
@@ -1237,8 +1262,9 @@ olx.control.RotateOptions.prototype.className;
|
||||
|
||||
|
||||
/**
|
||||
* Text label to use for the rotate button. Default is `⇧`
|
||||
* @type {string|undefined}
|
||||
* Text label to use for the rotate button. Default is `⇧`.
|
||||
* Instead of text, also a Node (e.g. a `span` element) can be used.
|
||||
* @type {string|Node|undefined}
|
||||
* @api stable
|
||||
*/
|
||||
olx.control.RotateOptions.prototype.label;
|
||||
@@ -1288,8 +1314,8 @@ olx.control.RotateOptions.prototype.target;
|
||||
/**
|
||||
* @typedef {{duration: (number|undefined),
|
||||
* className: (string|undefined),
|
||||
* zoomInLabel: (string|undefined),
|
||||
* zoomOutLabel: (string|undefined),
|
||||
* zoomInLabel: (string|Node|undefined),
|
||||
* zoomOutLabel: (string|Node|undefined),
|
||||
* zoomInTipLabel: (string|undefined),
|
||||
* zoomOutTipLabel: (string|undefined),
|
||||
* delta: (number|undefined),
|
||||
@@ -1316,16 +1342,18 @@ olx.control.ZoomOptions.prototype.className;
|
||||
|
||||
|
||||
/**
|
||||
* Text label to use for the zoom-in button. Default is `+`
|
||||
* @type {string|undefined}
|
||||
* Text label to use for the zoom-in button. Default is `+`.
|
||||
* Instead of text, also a Node (e.g. a `span` element) can be used.
|
||||
* @type {string|Node|undefined}
|
||||
* @api stable
|
||||
*/
|
||||
olx.control.ZoomOptions.prototype.zoomInLabel;
|
||||
|
||||
|
||||
/**
|
||||
* Text label to use for the zoom-out button. Default is `-`
|
||||
* @type {string|undefined}
|
||||
* Text label to use for the zoom-out button. Default is `-`.
|
||||
* Instead of text, also a Node (e.g. a `span` element) can be used.
|
||||
* @type {string|Node|undefined}
|
||||
* @api stable
|
||||
*/
|
||||
olx.control.ZoomOptions.prototype.zoomOutLabel;
|
||||
@@ -1409,6 +1437,7 @@ olx.control.ZoomSliderOptions.prototype.render;
|
||||
/**
|
||||
* @typedef {{className: (string|undefined),
|
||||
* target: (Element|undefined),
|
||||
* label: (string|Node|undefined),
|
||||
* tipLabel: (string|undefined),
|
||||
* extent: (ol.Extent|undefined)}}
|
||||
* @api stable
|
||||
@@ -1432,6 +1461,15 @@ olx.control.ZoomToExtentOptions.prototype.className;
|
||||
olx.control.ZoomToExtentOptions.prototype.target;
|
||||
|
||||
|
||||
/**
|
||||
* Text label to use for the button. Default is `E`.
|
||||
* Instead of text, also a Node (e.g. a `span` element) can be used.
|
||||
* @type {string|Node|undefined}
|
||||
* @api stable
|
||||
*/
|
||||
olx.control.ZoomToExtentOptions.prototype.label;
|
||||
|
||||
|
||||
/**
|
||||
* Text label to use for the button tip. Default is `Zoom to extent`
|
||||
* @type {string|undefined}
|
||||
|
||||
@@ -69,32 +69,33 @@ ol.control.Attribution = function(opt_options) {
|
||||
var tipLabel = goog.isDef(options.tipLabel) ?
|
||||
options.tipLabel : 'Attributions';
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.collapseLabel_ = goog.isDef(options.collapseLabel) ?
|
||||
var collapseLabel = goog.isDef(options.collapseLabel) ?
|
||||
options.collapseLabel : '\u00BB';
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
* @type {Node}
|
||||
*/
|
||||
this.label_ = goog.isDef(options.label) ? options.label : 'i';
|
||||
var label = goog.dom.createDom(goog.dom.TagName.SPAN, {},
|
||||
(this.collapsible_ && !this.collapsed_) ?
|
||||
this.collapseLabel_ : this.label_);
|
||||
this.collapseLabel_ = /** @type {Node} */ (goog.isString(collapseLabel) ?
|
||||
goog.dom.createDom(goog.dom.TagName.SPAN, {}, collapseLabel) :
|
||||
collapseLabel);
|
||||
|
||||
var label = goog.isDef(options.label) ? options.label : 'i';
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Element}
|
||||
* @type {Node}
|
||||
*/
|
||||
this.labelSpan_ = label;
|
||||
this.label_ = /** @type {Node} */ (goog.isString(label) ?
|
||||
goog.dom.createDom(goog.dom.TagName.SPAN, {}, label) :
|
||||
label);
|
||||
|
||||
var activeLabel = (this.collapsible_ && !this.collapsed_) ?
|
||||
this.collapseLabel_ : this.label_;
|
||||
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
||||
'type': 'button',
|
||||
'title': tipLabel
|
||||
}, this.labelSpan_);
|
||||
}, activeLabel);
|
||||
|
||||
goog.events.listen(button, goog.events.EventType.CLICK,
|
||||
this.handleClick_, false, this);
|
||||
@@ -341,8 +342,11 @@ ol.control.Attribution.prototype.handleClick_ = function(event) {
|
||||
*/
|
||||
ol.control.Attribution.prototype.handleToggle_ = function() {
|
||||
goog.dom.classlist.toggle(this.element, 'ol-collapsed');
|
||||
goog.dom.setTextContent(this.labelSpan_,
|
||||
(this.collapsed_) ? this.collapseLabel_ : this.label_);
|
||||
if (this.collapsed_) {
|
||||
goog.dom.replaceNode(this.collapseLabel_, this.label_);
|
||||
} else {
|
||||
goog.dom.replaceNode(this.label_, this.collapseLabel_);
|
||||
}
|
||||
this.collapsed_ = !this.collapsed_;
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ goog.provide('ol.control.FullScreen');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.dom');
|
||||
goog.require('goog.dom.TagName');
|
||||
goog.require('goog.dom.classlist');
|
||||
goog.require('goog.dom.fullscreen');
|
||||
goog.require('goog.dom.fullscreen.EventType');
|
||||
goog.require('goog.events');
|
||||
@@ -37,13 +36,33 @@ ol.control.FullScreen = function(opt_options) {
|
||||
this.cssClassName_ = goog.isDef(options.className) ?
|
||||
options.className : 'ol-full-screen';
|
||||
|
||||
var label = goog.isDef(options.label) ?
|
||||
options.label : '\u2194';
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Node}
|
||||
*/
|
||||
this.labelNode_ = /** @type {Node} */ (goog.isString(label) ?
|
||||
goog.dom.createTextNode(label) : label);
|
||||
|
||||
var labelActive = goog.isDef(options.labelActive) ?
|
||||
options.labelActive : '\u00d7';
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Node}
|
||||
*/
|
||||
this.labelActiveNode_ = /** @type {Node} */ (goog.isString(labelActive) ?
|
||||
goog.dom.createTextNode(labelActive) : labelActive);
|
||||
|
||||
var tipLabel = goog.isDef(options.tipLabel) ?
|
||||
options.tipLabel : 'Toggle full-screen';
|
||||
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
||||
'class': this.cssClassName_ + '-' + goog.dom.fullscreen.isFullScreen(),
|
||||
'type': 'button',
|
||||
'title': tipLabel
|
||||
});
|
||||
}, this.labelNode_);
|
||||
|
||||
goog.events.listen(button, goog.events.EventType.CLICK,
|
||||
this.handleClick_, false, this);
|
||||
@@ -120,14 +139,11 @@ ol.control.FullScreen.prototype.handleFullScreen_ = function() {
|
||||
* @private
|
||||
*/
|
||||
ol.control.FullScreen.prototype.handleFullScreenChange_ = function() {
|
||||
var opened = this.cssClassName_ + '-true';
|
||||
var closed = this.cssClassName_ + '-false';
|
||||
var anchor = goog.dom.getFirstElementChild(this.element);
|
||||
var map = this.getMap();
|
||||
if (goog.dom.fullscreen.isFullScreen()) {
|
||||
goog.dom.classlist.swap(anchor, closed, opened);
|
||||
goog.dom.replaceNode(this.labelActiveNode_, this.labelNode_);
|
||||
} else {
|
||||
goog.dom.classlist.swap(anchor, opened, closed);
|
||||
goog.dom.replaceNode(this.labelNode_, this.labelActiveNode_);
|
||||
}
|
||||
if (!goog.isNull(map)) {
|
||||
map.updateSize();
|
||||
|
||||
@@ -57,31 +57,33 @@ ol.control.OverviewMap = function(opt_options) {
|
||||
var tipLabel = goog.isDef(options.tipLabel) ?
|
||||
options.tipLabel : 'Overview map';
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.collapseLabel_ = goog.isDef(options.collapseLabel) ?
|
||||
var collapseLabel = goog.isDef(options.collapseLabel) ?
|
||||
options.collapseLabel : '\u00AB';
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {string}
|
||||
* @type {Node}
|
||||
*/
|
||||
this.label_ = goog.isDef(options.label) ? options.label : '\u00BB';
|
||||
var label = goog.dom.createDom(goog.dom.TagName.SPAN, {},
|
||||
(this.collapsible_ && !this.collapsed_) ?
|
||||
this.collapseLabel_ : this.label_);
|
||||
this.collapseLabel_ = /** @type {Node} */ (goog.isString(collapseLabel) ?
|
||||
goog.dom.createDom(goog.dom.TagName.SPAN, {}, collapseLabel) :
|
||||
collapseLabel);
|
||||
|
||||
var label = goog.isDef(options.label) ? options.label : '\u00BB';
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Element}
|
||||
* @type {Node}
|
||||
*/
|
||||
this.labelSpan_ = label;
|
||||
this.label_ = /** @type {Node} */ (goog.isString(label) ?
|
||||
goog.dom.createDom(goog.dom.TagName.SPAN, {}, label) :
|
||||
label);
|
||||
|
||||
var activeLabel = (this.collapsible_ && !this.collapsed_) ?
|
||||
this.collapseLabel_ : this.label_;
|
||||
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
||||
'type': 'button',
|
||||
'title': tipLabel
|
||||
}, this.labelSpan_);
|
||||
}, activeLabel);
|
||||
|
||||
goog.events.listen(button, goog.events.EventType.CLICK,
|
||||
this.handleClick_, false, this);
|
||||
@@ -427,8 +429,11 @@ ol.control.OverviewMap.prototype.handleClick_ = function(event) {
|
||||
*/
|
||||
ol.control.OverviewMap.prototype.handleToggle_ = function() {
|
||||
goog.dom.classlist.toggle(this.element, 'ol-collapsed');
|
||||
goog.dom.setTextContent(this.labelSpan_,
|
||||
(this.collapsed_) ? this.collapseLabel_ : this.label_);
|
||||
if (this.collapsed_) {
|
||||
goog.dom.replaceNode(this.collapseLabel_, this.label_);
|
||||
} else {
|
||||
goog.dom.replaceNode(this.label_, this.collapseLabel_);
|
||||
}
|
||||
this.collapsed_ = !this.collapsed_;
|
||||
|
||||
// manage overview map if it had not been rendered before and control
|
||||
|
||||
@@ -32,12 +32,22 @@ ol.control.Rotate = function(opt_options) {
|
||||
var className = goog.isDef(options.className) ?
|
||||
options.className : 'ol-rotate';
|
||||
|
||||
var label = goog.isDef(options.label) ?
|
||||
options.label : '\u21E7';
|
||||
|
||||
/**
|
||||
* @type {Element}
|
||||
* @type {Node}
|
||||
* @private
|
||||
*/
|
||||
this.label_ = goog.dom.createDom(goog.dom.TagName.SPAN,
|
||||
'ol-compass', goog.isDef(options.label) ? options.label : '\u21E7');
|
||||
this.label_ = null;
|
||||
|
||||
if (goog.isString(label)) {
|
||||
this.label_ = goog.dom.createDom(goog.dom.TagName.SPAN,
|
||||
'ol-compass', label);
|
||||
} else {
|
||||
this.label_ = label;
|
||||
goog.dom.classlist.add(this.label_, 'ol-compass');
|
||||
}
|
||||
|
||||
var tipLabel = goog.isDef(options.tipLabel) ?
|
||||
options.tipLabel : 'Reset rotation';
|
||||
|
||||
@@ -32,12 +32,13 @@ ol.control.ZoomToExtent = function(opt_options) {
|
||||
var className = goog.isDef(options.className) ? options.className :
|
||||
'ol-zoom-extent';
|
||||
|
||||
var label = goog.isDef(options.label) ? options.label : 'E';
|
||||
var tipLabel = goog.isDef(options.tipLabel) ?
|
||||
options.tipLabel : 'Fit to extent';
|
||||
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
||||
'type': 'button',
|
||||
'title': tipLabel
|
||||
});
|
||||
}, label);
|
||||
|
||||
goog.events.listen(button, goog.events.EventType.CLICK,
|
||||
this.handleClick_, false, this);
|
||||
|
||||
Reference in New Issue
Block a user