Merge pull request #693 from twpayne/class-name
Add className option to control options
This commit is contained in:
@@ -32,8 +32,10 @@ ol.control.Attribution = function(opt_options) {
|
||||
*/
|
||||
this.ulElement_ = goog.dom.createElement(goog.dom.TagName.UL);
|
||||
|
||||
var className = goog.isDef(options.className) ?
|
||||
options.className : 'ol-attribution';
|
||||
var element = goog.dom.createDom(goog.dom.TagName.DIV, {
|
||||
'class': 'ol-attribution ' + ol.css.CLASS_UNSELECTABLE
|
||||
'class': className + ' ' + ol.css.CLASS_UNSELECTABLE
|
||||
}, this.ulElement_);
|
||||
|
||||
goog.base(this, {
|
||||
|
||||
@@ -26,7 +26,8 @@ ol.control.FullScreen = function(opt_options) {
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
this.cssClassName_ = 'ol-full-screen';
|
||||
this.cssClassName_ = goog.isDef(options.className) ?
|
||||
options.className : 'ol-full-screen';
|
||||
|
||||
var aElement = goog.dom.createDom(goog.dom.TagName.A, {
|
||||
'href': '#fullScreen',
|
||||
|
||||
@@ -25,8 +25,10 @@ ol.control.Logo = function(opt_options) {
|
||||
*/
|
||||
this.ulElement_ = goog.dom.createElement(goog.dom.TagName.UL);
|
||||
|
||||
var className = goog.isDef(options.className) ? options.className : 'ol-logo';
|
||||
|
||||
var element = goog.dom.createDom(goog.dom.TagName.DIV, {
|
||||
'class': 'ol-logo ' + ol.css.CLASS_UNSELECTABLE
|
||||
'class': className + ' ' + ol.css.CLASS_UNSELECTABLE
|
||||
}, this.ulElement_);
|
||||
|
||||
goog.base(this, {
|
||||
|
||||
@@ -27,8 +27,11 @@ ol.control.MousePosition = function(opt_options) {
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
var className = goog.isDef(options.className) ?
|
||||
options.className : 'ol-mouse-position';
|
||||
|
||||
var element = goog.dom.createDom(goog.dom.TagName.DIV, {
|
||||
'class': 'ol-mouseposition'
|
||||
'class': className
|
||||
});
|
||||
|
||||
goog.base(this, {
|
||||
|
||||
@@ -38,12 +38,15 @@ ol.control.ScaleLine = function(opt_options) {
|
||||
|
||||
var options = opt_options || {};
|
||||
|
||||
var className = goog.isDef(options.className) ?
|
||||
options.className : 'ol-scale-line';
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Element}
|
||||
*/
|
||||
this.innerElement_ = goog.dom.createDom(goog.dom.TagName.DIV, {
|
||||
'class': 'ol-scale-line-inner'
|
||||
'class': className + '-inner'
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -51,7 +54,7 @@ ol.control.ScaleLine = function(opt_options) {
|
||||
* @type {Element}
|
||||
*/
|
||||
this.element_ = goog.dom.createDom(goog.dom.TagName.DIV, {
|
||||
'class': 'ol-scale-line ' + ol.css.CLASS_UNSELECTABLE
|
||||
'class': className + ' ' + ol.css.CLASS_UNSELECTABLE
|
||||
}, this.innerElement_);
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,9 +28,11 @@ ol.control.Zoom = function(opt_options) {
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
var className = goog.isDef(options.className) ? options.className : 'ol-zoom';
|
||||
|
||||
var inElement = goog.dom.createDom(goog.dom.TagName.A, {
|
||||
'href': '#zoomIn',
|
||||
'class': 'ol-zoom-in'
|
||||
'class': className + '-in'
|
||||
});
|
||||
goog.events.listen(inElement, [
|
||||
goog.events.EventType.TOUCHEND,
|
||||
@@ -39,14 +41,14 @@ ol.control.Zoom = function(opt_options) {
|
||||
|
||||
var outElement = goog.dom.createDom(goog.dom.TagName.A, {
|
||||
'href': '#zoomOut',
|
||||
'class': 'ol-zoom-out'
|
||||
'class': className + '-out'
|
||||
});
|
||||
goog.events.listen(outElement, [
|
||||
goog.events.EventType.TOUCHEND,
|
||||
goog.events.EventType.CLICK
|
||||
], this.handleOut_, false, this);
|
||||
|
||||
var cssClasses = 'ol-zoom ' + ol.css.CLASS_UNSELECTABLE;
|
||||
var cssClasses = className + ' ' + ol.css.CLASS_UNSELECTABLE;
|
||||
var element = goog.dom.createDom(goog.dom.TagName.DIV, cssClasses, inElement,
|
||||
outElement);
|
||||
|
||||
|
||||
@@ -31,9 +31,11 @@ ol.control.ZOOMSLIDER_ANIMATION_DURATION = 200;
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.control.Control}
|
||||
* @param {ol.control.ZoomSliderOptions} options Zoom slider options.
|
||||
* @param {ol.control.ZoomSliderOptions=} opt_options Zoom slider options.
|
||||
*/
|
||||
ol.control.ZoomSlider = function(options) {
|
||||
ol.control.ZoomSlider = function(opt_options) {
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
/**
|
||||
* Will hold the current resolution of the view.
|
||||
@@ -58,17 +60,23 @@ ol.control.ZoomSlider = function(options) {
|
||||
*/
|
||||
this.draggerListenerKeys_ = null;
|
||||
|
||||
var elem = this.createDom_();
|
||||
this.dragger_ = this.createDraggable_(elem);
|
||||
var className = goog.isDef(options.className) ?
|
||||
options.className : 'ol-zoomslider';
|
||||
var sliderCssCls = className + ' ' + ol.css.CLASS_UNSELECTABLE;
|
||||
var thumbCssCls = className + '-thumb' + ' ' + ol.css.CLASS_UNSELECTABLE;
|
||||
var element = goog.dom.createDom(goog.dom.TagName.DIV, sliderCssCls,
|
||||
goog.dom.createDom(goog.dom.TagName.DIV, thumbCssCls));
|
||||
|
||||
this.dragger_ = this.createDraggable_(element);
|
||||
|
||||
// FIXME currently only a do nothing function is bound.
|
||||
goog.events.listen(elem, [
|
||||
goog.events.listen(element, [
|
||||
goog.events.EventType.TOUCHEND,
|
||||
goog.events.EventType.CLICK
|
||||
], this.handleContainerClick_, false, this);
|
||||
|
||||
goog.base(this, {
|
||||
element: elem,
|
||||
element: element,
|
||||
map: options.map
|
||||
});
|
||||
};
|
||||
@@ -86,23 +94,6 @@ ol.control.ZoomSlider.direction = {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* The CSS class that we'll give the zoomslider container.
|
||||
*
|
||||
* @const {string}
|
||||
*/
|
||||
ol.control.ZoomSlider.CSS_CLASS_CONTAINER = 'ol-zoomslider';
|
||||
|
||||
|
||||
/**
|
||||
* The CSS class that we'll give the zoomslider thumb.
|
||||
*
|
||||
* @const {string}
|
||||
*/
|
||||
ol.control.ZoomSlider.CSS_CLASS_THUMB =
|
||||
ol.control.ZoomSlider.CSS_CLASS_CONTAINER + '-thumb';
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@@ -299,24 +290,3 @@ ol.control.ZoomSlider.prototype.createDraggable_ = function(elem) {
|
||||
];
|
||||
return dragger;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Setup the DOM-structure we need for the zoomslider.
|
||||
*
|
||||
* @param {Element=} opt_elem The element for the slider.
|
||||
* @return {Element} The correctly set up DOMElement.
|
||||
* @private
|
||||
*/
|
||||
ol.control.ZoomSlider.prototype.createDom_ = function(opt_elem) {
|
||||
var elem,
|
||||
sliderCssCls = ol.control.ZoomSlider.CSS_CLASS_CONTAINER + ' ' +
|
||||
ol.css.CLASS_UNSELECTABLE,
|
||||
thumbCssCls = ol.control.ZoomSlider.CSS_CLASS_THUMB + ' ' +
|
||||
ol.css.CLASS_UNSELECTABLE;
|
||||
|
||||
elem = goog.dom.createDom(goog.dom.TagName.DIV, sliderCssCls,
|
||||
goog.dom.createDom(goog.dom.TagName.DIV, thumbCssCls));
|
||||
|
||||
return elem;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user