Merge pull request #2781 from fredj/button-title
Use a standard title attribute for the control buttons
This commit is contained in:
64
css/ol.css
64
css/ol.css
@@ -131,65 +131,6 @@ button.ol-full-screen-true:after {
|
||||
content: "\00d7";
|
||||
}
|
||||
|
||||
/* invisible but not hidden */
|
||||
.ol-has-tooltip [role=tooltip] {
|
||||
position: absolute;
|
||||
clip: rect(1px 1px 1px 1px); /* < IE8 */
|
||||
clip: rect(1px, 1px, 1px, 1px);
|
||||
padding: 0;
|
||||
border: 0;
|
||||
height: 1px;
|
||||
width: 1px;
|
||||
overflow: hidden;
|
||||
font-weight: normal;
|
||||
font-size: 14px;
|
||||
text-shadow: 0 0 2px #fff;
|
||||
}
|
||||
|
||||
/* show a tooltip offset to below and right */
|
||||
.ol-has-tooltip:hover [role=tooltip], .ol-has-tooltip:focus [role=tooltip] {
|
||||
-moz-box-sizing: content-box;
|
||||
-webkit-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
clip: auto;
|
||||
padding: 0 .4em;
|
||||
font-size: .8em;
|
||||
height: 1.2em;
|
||||
width: auto;
|
||||
line-height: 1.2em;
|
||||
z-index: 1100;
|
||||
max-height: 100px;
|
||||
white-space: nowrap;
|
||||
display: inline-block;
|
||||
background: #FFF;
|
||||
background: rgba(255,255,255,0.6);
|
||||
color: #000;
|
||||
border: 3px solid rgba(255,255,255,0);
|
||||
border-left-width: 0;
|
||||
border-radius: 0 4px 4px 0;
|
||||
bottom: .3em;
|
||||
left: 2.2em;
|
||||
}
|
||||
.ol-touch .ol-has-tooltip:hover [role=tooltip],
|
||||
.ol-touch .ol-has-tooltip:focus [role=tooltip] {
|
||||
display: none;
|
||||
}
|
||||
.ol-zoom .ol-has-tooltip:hover [role=tooltip],
|
||||
.ol-zoom .ol-has-tooltip:focus [role=tooltip] {
|
||||
top: 1.1em;
|
||||
}
|
||||
.ol-rotate .ol-has-tooltip:hover [role=tooltip],
|
||||
.ol-rotate .ol-has-tooltip:focus [role=tooltip],
|
||||
.ol-attribution .ol-has-tooltip:hover [role=tooltip],
|
||||
.ol-attribution .ol-has-tooltip:focus [role=tooltip],
|
||||
.ol-full-screen .ol-has-tooltip:hover [role=tooltip],
|
||||
.ol-full-screen .ol-has-tooltip:focus [role=tooltip] {
|
||||
right: 2.2em;
|
||||
left: auto;
|
||||
border-radius: 4px 0 0 4px;
|
||||
border-left-width: 3px;
|
||||
border-right-width: 0;
|
||||
}
|
||||
|
||||
.ol-attribution {
|
||||
text-align: right;
|
||||
@@ -222,7 +163,6 @@ button.ol-full-screen-true:after {
|
||||
.ol-attribution ul, .ol-attribution button {
|
||||
display: inline-block;
|
||||
}
|
||||
.ol-attribution:not(.ol-collapsed) button:hover [role=tooltip],
|
||||
.ol-attribution.ol-collapsed ul {
|
||||
display: none;
|
||||
}
|
||||
@@ -284,8 +224,7 @@ button.ol-full-screen-true:after {
|
||||
|
||||
.ol-control button,
|
||||
.ol-attribution,
|
||||
.ol-scale-line-inner,
|
||||
.ol-has-tooltip [role=tooltip] {
|
||||
.ol-scale-line-inner {
|
||||
font-family: 'Lucida Grande',Verdana,Geneva,Lucida,Arial,Helvetica,sans-serif;
|
||||
}
|
||||
|
||||
@@ -314,7 +253,6 @@ button.ol-full-screen-true:after {
|
||||
left: 2px;
|
||||
position: absolute;
|
||||
}
|
||||
.ol-overviewmap:not(.ol-collapsed) button:hover [role=tooltip],
|
||||
.ol-overviewmap.ol-collapsed .ol-overviewmap-map,
|
||||
.ol-overviewmap.ol-uncollapsible button {
|
||||
display: none;
|
||||
|
||||
62
examples/button-title.html
Normal file
62
examples/button-title.html
Normal file
@@ -0,0 +1,62 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
|
||||
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/layout.css" type="text/css">
|
||||
<link rel="stylesheet" href="../resources/bootstrap/css/bootstrap-responsive.min.css" type="text/css">
|
||||
<style type="text/css">
|
||||
.tooltip-inner {
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
<title>ol3 custom tooltips example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand" href="./"><img src="../resources/logo.png"> OpenLayers 3 Examples</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<div id="map" class="map"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<h4 id="title">Custom tooltips</h4>
|
||||
<p id="shortdesc">
|
||||
This example shows how to customize the buttons tooltips with
|
||||
<a href="http://getbootstrap.com/javascript/#tooltips">Bootstrap</a>.
|
||||
</p>
|
||||
<div id="docs">
|
||||
<p>
|
||||
See the <a href="button-title.js" target="_blank">button-title.js source</a> to see how this is done.
|
||||
</p>
|
||||
</div>
|
||||
<div id="tags">
|
||||
custom, tooltip
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="../resources/jquery.min.js" type="text/javascript"></script>
|
||||
<script src="../resources/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
|
||||
<script src="../resources/example-behaviour.js" type="text/javascript"></script>
|
||||
<script src="loader.js?id=button-title" type="text/javascript"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
27
examples/button-title.js
Normal file
27
examples/button-title.js
Normal file
@@ -0,0 +1,27 @@
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.View');
|
||||
goog.require('ol.layer.Tile');
|
||||
goog.require('ol.source.OSM');
|
||||
|
||||
var map = new ol.Map({
|
||||
layers: [
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.OSM()
|
||||
})
|
||||
],
|
||||
renderer: exampleNS.getRendererFromQueryString(),
|
||||
target: 'map',
|
||||
view: new ol.View({
|
||||
center: [-8730000, 5930000],
|
||||
rotation: Math.PI / 5,
|
||||
zoom: 8
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
$('.ol-zoom-in, .ol-zoom-out').tooltip({
|
||||
placement: 'right'
|
||||
});
|
||||
$('.ol-rotate-reset, .ol-attribution button[title]').tooltip({
|
||||
placement: 'left'
|
||||
});
|
||||
@@ -69,9 +69,6 @@ ol.control.Attribution = function(opt_options) {
|
||||
|
||||
var tipLabel = goog.isDef(options.tipLabel) ?
|
||||
options.tipLabel : 'Attributions';
|
||||
var tip = goog.dom.createDom(goog.dom.TagName.SPAN, {
|
||||
'role' : 'tooltip'
|
||||
}, tipLabel);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -96,10 +93,9 @@ ol.control.Attribution = function(opt_options) {
|
||||
*/
|
||||
this.labelSpan_ = label;
|
||||
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
||||
'class': 'ol-has-tooltip',
|
||||
'type': 'button'
|
||||
'type': 'button',
|
||||
'title': tipLabel
|
||||
}, this.labelSpan_);
|
||||
goog.dom.appendChild(button, tip);
|
||||
|
||||
var buttonHandler = new ol.pointer.PointerEventHandler(button);
|
||||
this.registerDisposable(buttonHandler);
|
||||
|
||||
@@ -40,16 +40,11 @@ ol.control.FullScreen = function(opt_options) {
|
||||
|
||||
var tipLabel = goog.isDef(options.tipLabel) ?
|
||||
options.tipLabel : 'Toggle full-screen';
|
||||
var tip = goog.dom.createDom(goog.dom.TagName.SPAN, {
|
||||
'role' : 'tooltip'
|
||||
}, tipLabel);
|
||||
|
||||
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
||||
'class': this.cssClassName_ + '-' + goog.dom.fullscreen.isFullScreen() +
|
||||
' ol-has-tooltip',
|
||||
'type': 'button'
|
||||
'class': this.cssClassName_ + '-' + goog.dom.fullscreen.isFullScreen(),
|
||||
'type': 'button',
|
||||
'title': tipLabel
|
||||
});
|
||||
goog.dom.appendChild(button, tip);
|
||||
var buttonHandler = new ol.pointer.PointerEventHandler(button);
|
||||
this.registerDisposable(buttonHandler);
|
||||
goog.events.listen(buttonHandler,
|
||||
|
||||
@@ -57,9 +57,6 @@ ol.control.OverviewMap = function(opt_options) {
|
||||
|
||||
var tipLabel = goog.isDef(options.tipLabel) ?
|
||||
options.tipLabel : 'Overview map';
|
||||
var tip = goog.dom.createDom(goog.dom.TagName.SPAN, {
|
||||
'role' : 'tooltip'
|
||||
}, tipLabel);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -83,10 +80,9 @@ ol.control.OverviewMap = function(opt_options) {
|
||||
*/
|
||||
this.labelSpan_ = label;
|
||||
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
||||
'class': 'ol-has-tooltip',
|
||||
'type': 'button'
|
||||
'type': 'button',
|
||||
'title': tipLabel
|
||||
}, this.labelSpan_);
|
||||
goog.dom.appendChild(button, tip);
|
||||
|
||||
var buttonHandler = new ol.pointer.PointerEventHandler(button);
|
||||
this.registerDisposable(buttonHandler);
|
||||
|
||||
@@ -44,13 +44,11 @@ ol.control.Rotate = function(opt_options) {
|
||||
var tipLabel = goog.isDef(options.tipLabel) ?
|
||||
options.tipLabel : 'Reset rotation';
|
||||
|
||||
var tip = goog.dom.createDom(goog.dom.TagName.SPAN, {
|
||||
'role' : 'tooltip'
|
||||
}, tipLabel);
|
||||
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
||||
'class': className + '-reset ol-has-tooltip',
|
||||
'type' : 'button'
|
||||
}, tip, this.label_);
|
||||
'class': className + '-reset',
|
||||
'type' : 'button',
|
||||
'title': tipLabel
|
||||
}, this.label_);
|
||||
|
||||
var handler = new ol.pointer.PointerEventHandler(button);
|
||||
this.registerDisposable(handler);
|
||||
|
||||
@@ -41,13 +41,11 @@ ol.control.Zoom = function(opt_options) {
|
||||
var zoomOutTipLabel = goog.isDef(options.zoomOutTipLabel) ?
|
||||
options.zoomOutTipLabel : 'Zoom out';
|
||||
|
||||
var tTipZoomIn = goog.dom.createDom(goog.dom.TagName.SPAN, {
|
||||
'role' : 'tooltip'
|
||||
}, zoomInTipLabel);
|
||||
var inElement = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
||||
'class': className + '-in ol-has-tooltip',
|
||||
'type' : 'button'
|
||||
}, tTipZoomIn, zoomInLabel);
|
||||
'class': className + '-in',
|
||||
'type' : 'button',
|
||||
'title': zoomInTipLabel
|
||||
}, zoomInLabel);
|
||||
|
||||
var inElementHandler = new ol.pointer.PointerEventHandler(inElement);
|
||||
this.registerDisposable(inElementHandler);
|
||||
@@ -65,13 +63,11 @@ ol.control.Zoom = function(opt_options) {
|
||||
this.blur();
|
||||
}, false);
|
||||
|
||||
var tTipsZoomOut = goog.dom.createDom(goog.dom.TagName.SPAN, {
|
||||
'role' : 'tooltip'
|
||||
}, zoomOutTipLabel);
|
||||
var outElement = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
||||
'class': className + '-out ol-has-tooltip',
|
||||
'type' : 'button'
|
||||
}, tTipsZoomOut, zoomOutLabel);
|
||||
'class': className + '-out',
|
||||
'type' : 'button',
|
||||
'title': zoomOutTipLabel
|
||||
}, zoomOutLabel);
|
||||
|
||||
var outElementHandler = new ol.pointer.PointerEventHandler(outElement);
|
||||
this.registerDisposable(outElementHandler);
|
||||
|
||||
@@ -35,14 +35,10 @@ ol.control.ZoomToExtent = function(opt_options) {
|
||||
|
||||
var tipLabel = goog.isDef(options.tipLabel) ?
|
||||
options.tipLabel : 'Fit to extent';
|
||||
var tip = goog.dom.createDom(goog.dom.TagName.SPAN, {
|
||||
'role' : 'tooltip'
|
||||
}, tipLabel);
|
||||
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
||||
'class': 'ol-has-tooltip',
|
||||
'type': 'button'
|
||||
'type': 'button',
|
||||
'title': tipLabel
|
||||
});
|
||||
goog.dom.appendChild(button, tip);
|
||||
|
||||
var buttonHandler = new ol.pointer.PointerEventHandler(button);
|
||||
this.registerDisposable(buttonHandler);
|
||||
|
||||
Reference in New Issue
Block a user