Skip to content

Commit

Permalink
Add a new Tilt3d components
Browse files Browse the repository at this point in the history
  • Loading branch information
fredj committed Aug 27, 2015
1 parent d381dfd commit f6dd9d6
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 9 deletions.
11 changes: 8 additions & 3 deletions src/components/backgroundselector/BackgroundSelectorDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ goog.require('ga_topic_service');
templateUrl:
'components/backgroundselector/partials/backgroundselector.html',
scope: {
map: '=gaBackgroundSelectorMap'
map: '=gaBackgroundSelectorMap',
ol3d: '=gaBackgroundSelectorOl3d'
},
link: function(scope, elt, attrs) {
scope.isBackgroundSelectorClosed = true;
Expand All @@ -45,7 +46,10 @@ goog.require('ga_topic_service');
} else {
scope.isBackgroundSelectorClosed = true;
if (scope.currentLayer != bgLayer) {
scope.currentLayer = bgLayer;
var ol3dEnabled = scope.ol3d && scope.ol3d.getEnabled();
if (!(bgLayer.disable3d && ol3dEnabled)) {
scope.currentLayer = bgLayer;
}
}
}
};
Expand All @@ -63,7 +67,8 @@ goog.require('ga_topic_service');
return (selected ? 'ga-bg-highlight ' : '') +
'ga-' + splitLayer[splitLayer.length - 1] +
' ' + ((!scope.isBackgroundSelectorClosed) ?
'ga-bg-layer-' + index : '');
'ga-bg-layer-' + index : '') +
' ' + (layer.disable3d ? 'ga-disable3d' : '');
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/backgroundselector/BackgroundService.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ goog.require('ga_permalink');
var isOfflineToOnline = false;
var bg; // The current background
var bgs = [ // The list of backgrounds available
{id: 'ch.swisstopo.swissimage', label: 'bg_luftbild'},
{id: 'ch.swisstopo.swissimage', label: 'bg_luftbild', disable3d: true},
{id: 'ch.swisstopo.pixelkarte-farbe', label: 'bg_pixel_color'},
{id: 'ch.swisstopo.pixelkarte-grau', label: 'bg_pixel_grey'},
{id: 'voidLayer', label: 'void_layer'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,10 @@
}
}
}

.ga-3d-active {
.ga-disable3d {
background-color: gray;
color: gray;
}
}
39 changes: 39 additions & 0 deletions src/components/tilt3d/Tilt3dDirective.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
goog.provide('ga_tilt3d_directive');

(function() {

var module = angular.module('ga_tilt3d_directive', []);

module.directive('gaTilt3d', function(gaBrowserSniffer) {
return {
restrict: 'A',
templateUrl: 'components/tilt3d/partials/tilt3d.html',
link: function(scope, element, attrs) {

scope.supported = gaBrowserSniffer.webgl;

// FIXME: remove this
// true is the selected background layer is not 3d compatible.
scope.disabled = false;
scope.$on('gaBgChange', function(evt, value) {
scope.disabled = value.id == 'ch.swisstopo.swissimage';
if (scope.disabled) {
// FIXME: set scope.globals.is3dActive to false
}
});

scope.tilt = function() {
if (scope.supported) {
if (!scope.disabled) {
scope.globals.is3dActive = !scope.globals.is3dActive;
} else {
// FIXME: error message "selected background not compatible"
}
} else {
// FIXME: error message "browser not supported"
}
};
}
};
});
})();
9 changes: 9 additions & 0 deletions src/components/tilt3d/Tilt3dModule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
goog.provide('ga_tilt3d');

goog.require('ga_tilt3d_directive');
(function() {

angular.module('ga_tilt3d', [
'ga_tilt3d_directive'
]);
})();
1 change: 1 addition & 0 deletions src/components/tilt3d/partials/tilt3d.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<button type="button" class="ga-tilt3d" ng-click="tilt()" ng-class="{'ga-disabled': disabled, 'ga-unsupported': !supported}">3d</button>
15 changes: 15 additions & 0 deletions src/components/tilt3d/style/tilt3d.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.ga-tilt3d {
background-color: #fff !important;
&.ga-unsupported {

}
&.ga-disabled {
background-color: gray !important;
}
}

.ga-3d-active {
.ga-tilt3d {
background-color: green !important;
}
}
4 changes: 3 additions & 1 deletion src/index.mako.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
% if device == 'mobile':
<div ga-offline-bt></div>
% endif
<div ga-tilt3d ng-if="globals.dev3d"></div>
</div>
<div ga-swipe
ga-swipe-map="map"
Expand All @@ -232,7 +233,8 @@

% if device != 'embed':
<div ng-cloak ga-background-selector
ga-background-selector-map="map"
ga-background-selector-map="map",
ga-background-selector-ol3d="::ol3d"
ng-hide="globals.offline">
</div>
<div ng-cloak translate-cloak id="footer" class="navbar navbar-fixed-bottom">
Expand Down
4 changes: 3 additions & 1 deletion src/js/GaModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ goog.require('ga_share');
goog.require('ga_share_controller');
goog.require('ga_styles_from_literals_service');
goog.require('ga_swipe');
goog.require('ga_tilt3d');
goog.require('ga_timeselector');
goog.require('ga_timeselector_controller');
goog.require('ga_timestamp_control');
Expand Down Expand Up @@ -115,7 +116,8 @@ goog.require('ga_waitcursor_service');
'ga_tooltip_controller',
'ga_featuretree_controller',
'ga_draw_controller',
'ga_query_controller'
'ga_query_controller',
'ga_tilt3d'
]);

})();
3 changes: 0 additions & 3 deletions src/js/MainController.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ goog.require('ga_storage_service');
$scope.map = createMap();

if (gaGlobalOptions.dev3d && gaBrowserSniffer.webgl) {
$rootScope.$on('gaBgChange', function(evt, newBg) {
$scope.globals.is3dActive = !!newBg.is3d;
});
$scope.map.on('change:target', function(event) {
if (!!$scope.map.getTargetElement()) {
$scope.$watch('globals.is3dActive', function(active) {
Expand Down
1 change: 1 addition & 0 deletions src/style/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
@import "../components/query/style/query.less";
@import "../components/timestampcontrol/style/timestampcontrol.less";
@import "../components/translation/style/translation.less";
@import "../components/tilt3d/style/tilt3d.less";


@header-height: 89;
Expand Down

0 comments on commit f6dd9d6

Please sign in to comment.