Skip to content

Commit

Permalink
Merge pull request #3105 from camptocamp/move_scale_selector_options
Browse files Browse the repository at this point in the history
Move scale selector options to the options file
  • Loading branch information
ger-benjamin authored Nov 16, 2017
2 parents 5fbc4e9 + 1677b72 commit aba4f88
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 25 deletions.
6 changes: 2 additions & 4 deletions contribs/gmf/src/controllers/abstractdesktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ goog.require('ngeo.FeatureOverlay');
/** @suppress {extraRequire} */
goog.require('ngeo.FeatureOverlayMgr');
/** @suppress {extraRequire} */
goog.require('ngeo.ScaleselectorOptions');
/** @suppress {extraRequire} */
goog.require('ngeo.scaleselectorDirective');
goog.require('ngeo.ToolActivate');
goog.require('ngeo.ToolActivateMgr');
Expand Down Expand Up @@ -240,11 +238,11 @@ gmf.AbstractDesktopController = function(config, $scope, $injector) {
ngeoToolActivateMgr.registerTool('mapTools', googleStreetViewActivate, false);

/**
* @type {ngeo.ScaleselectorOptions}
* @type {ngeox.ScaleselectorOptions}
* @export
*/
this.scaleSelectorOptions = {
'dropup': true
dropup: true
};

/**
Expand Down
5 changes: 2 additions & 3 deletions examples/scaleselector.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
goog.provide('app.scaleselector');

goog.require('ngeo.ScaleselectorOptions');
/** @suppress {extraRequire} */
goog.require('ngeo.mapDirective');
/** @suppress {extraRequire} */
Expand Down Expand Up @@ -51,11 +50,11 @@ app.MainController = function($scope) {

/**
* Use the "dropup" variation of the Bootstrap dropdown.
* @type {ngeo.ScaleselectorOptions}
* @type {ngeox.ScaleselectorOptions}
* @export
*/
this.options = {
'dropup': true
dropup: true
};

};
Expand Down
16 changes: 16 additions & 0 deletions options/ngeox.js
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,22 @@ ngeox.QuerySource.prototype.wmsSource;
ngeox.QuerySource.prototype.wfsQuery;


/**
* Options to configure the scale selector
* @typedef {{
* dropup: (boolean|undefined)
* }}
*/
ngeox.ScaleselectorOptions;


/**
* True to get a drop menu that opens imself to the top, instead of the bottom.
* @type {boolean|undefined}
*/
ngeox.ScaleselectorOptions.prototype.dropup;


/**
* A WFS type. To be used with {@link ngeox.WfsPermalinkOptions}.
* @typedef {{
Expand Down
38 changes: 20 additions & 18 deletions src/directives/scaleselector.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
goog.provide('ngeo.ScaleselectorOptions');
goog.provide('ngeo.scaleselectorDirective');

goog.require('ngeo');
Expand All @@ -22,12 +21,6 @@ ngeo.module.value('ngeoScaleselectorTemplateUrl',
});


/**
* @typedef {{dropup: (boolean|undefined)}}
*/
ngeo.ScaleselectorOptions;


/**
* Provides the "ngeoScaleselector" directive, a widget for
* selecting map scales.
Expand All @@ -46,6 +39,16 @@ ngeo.ScaleselectorOptions;
* classes, and `data-toggle="dropdown"`, so it is meant to be used with
* Bootstrap's "dropdown" jQuery plugin.
*
* You can pass options to configure the behaviors of this element. Options is
* a {@link ngeox.ScaleselectorOptions} object.
*
* Example:
*
* <div ngeo-scaleselector="ctrl.scales"
* ngeo-scaleselector-map="ctrl.map"
* ngeo-scaleselector-options="ctrl.scaleSelectorOptions">
* </div>
*
* By default the directive uses "scaleselector.html" as its templateUrl. This
* an be changed by redefining the "ngeoScaleselectorTemplateUrl" value.
*
Expand All @@ -60,6 +63,8 @@ ngeo.ScaleselectorOptions;
*
* @htmlAttribute {!Array.<number>} ngeo-scaleselector The available scales.
* @htmlAttribute {ol.Map} ngeo-scaleselector-map The map.
* @htmlAttribute {ngeox.ScaleselectorOptions} ngeo-scaleselector-options
* Optionnal. The configuration options.
* @param {string|function(!angular.JQLite=, !angular.Attributes=)}
* ngeoScaleselectorTemplateUrl Template URL for the directive.
* @return {angular.Directive} Directive Definition Object.
Expand Down Expand Up @@ -128,7 +133,7 @@ ngeo.ScaleselectorController = function($scope, $element, $attrs) {
const options = $scope.$eval(optionsExpr);

/**
* @type {!ngeo.ScaleselectorOptions}
* @type {!ngeox.ScaleselectorOptions}
* @export
*/
this.options = ngeo.ScaleselectorController.getOptions_(options);
Expand Down Expand Up @@ -171,20 +176,17 @@ ngeo.ScaleselectorController = function($scope, $element, $attrs) {

/**
* @param {?} options Options after expression evaluation.
* @return {!ngeo.ScaleselectorOptions} Options object.
* @return {!ngeox.ScaleselectorOptions} Options object.
* @private
*/
ngeo.ScaleselectorController.getOptions_ = function(options) {
let ret;
if (options === undefined) {
ret = {'dropup': false};
} else {
if (options['dropup'] === undefined) {
options['dropup'] = false;
}
ret = /** @type {ngeo.ScaleselectorOptions} */ (options);
let dropup = false;
if (options !== undefined) {
dropup = options['dropup'] == true;
}
return ret;
return /** @type {ngeox.ScaleselectorOptions} */ ({
dropup: dropup
});
};


Expand Down

0 comments on commit aba4f88

Please sign in to comment.