Skip to content

Commit

Permalink
Add new terrain layer in the backgroundselector
Browse files Browse the repository at this point in the history
  • Loading branch information
fredj committed Aug 6, 2015
1 parent 79037f3 commit bfec7d8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ goog.require('ga_topic_service');

module.directive('gaBackgroundSelector',
function($document, gaPermalink, gaLayers, gaLayerFilters,
gaBrowserSniffer, $q, gaTopic) {
gaBrowserSniffer, $q, gaTopic, gaGlobalOptions) {
return {
restrict: 'A',
templateUrl:
Expand Down Expand Up @@ -41,6 +41,11 @@ goog.require('ga_topic_service');
{id: 'ch.swisstopo.pixelkarte-grau', label: 'bg_pixel_grey'},
{id: 'voidLayer', label: 'void_layer'}];

// to be moved in defaultBgOrder once 3d is live
if (gaGlobalOptions.dev3d) {
defaultBgOrder.splice(3, 0,
{id: 'ch.swisstopo.terrain.3d', label: 'terrain_layer'});
}
scope.backgroundLayers = defaultBgOrder.slice(0);

function setCurrentLayer(layerid) {
Expand Down
17 changes: 17 additions & 0 deletions src/components/backgroundselector/style/backgroundselector.less
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@
background-size: 38px 38px;
}

.ga-3d {
background-image: data-uri('terrain.png');
background-size: 38px 38px;
}

.ga-bg-layer-0 {
bottom: 101px;
@media (max-width: @screen-tablet) {
Expand Down Expand Up @@ -208,6 +213,10 @@
background-image: data-uri('voidLayer-rect.png');
}

.ga-3d {
background-image: data-uri('terrain-rect.png');
}

.ga-bg-layer-0 {
right: 35px;
}
Expand All @@ -232,4 +241,12 @@
right: 194px;
}
}

.ga-bg-layer-4 {
right: 439px;
@media (max-width: @screen-tablet) {
right: 247px;
}
}

}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 10 additions & 4 deletions test/specs/backgroundselector/BackgroundSelectorDirective.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('ga_backgroundselector_directive', function() {

var element, map, layer1, layer2, $rootScope, $compile, def;
var element, map, layer1, layer2, $rootScope, $compile, def, globalOptions;
beforeEach(function() {

map = new ol.Map({});
Expand Down Expand Up @@ -40,10 +40,11 @@ describe('ga_backgroundselector_directive', function() {
});
});

inject(function(_$rootScope_, _$compile_, $q) {
inject(function(_$rootScope_, _$compile_, $q, gaGlobalOptions) {
$compile = _$compile_;
$rootScope = _$rootScope_;
def = $q.defer();
globalOptions = gaGlobalOptions;
});

$rootScope.map = map;
Expand All @@ -64,9 +65,14 @@ describe('ga_backgroundselector_directive', function() {
var div = divToggle[0];
expect(div).not.to.be(undefined);
});
it('creates 4 layer bgselectors div', function() {
it('creates the correct number of layer bgselectors div', function() {
var divsBg = element.find('.ga-bg-layer');
expect(divsBg.length).to.equal(4);
if (globalOptions.dev3d) {
expect(divsBg.length).to.equal(5);
} else {
// to be removed once 3d goes live
expect(divsBg.length).to.equal(4);
}
});
});

Expand Down

0 comments on commit bfec7d8

Please sign in to comment.