Skip to content
This repository was archived by the owner on Oct 5, 2020. It is now read-only.

Commit 3648432

Browse files
committed
Map theme fixes for mobile mode
1 parent fd6a1e8 commit 3648432

File tree

7 files changed

+131
-90
lines changed

7 files changed

+131
-90
lines changed

app/templates/ui/app/root/root.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
<nav class="navbar navbar-default navbar-fixed-top nav" role="navigation">
55
<div class="navbar-header">
6+
<button type="button" class="sidebar-toggle">
7+
<span class="sr-only">Toggle sidebar</span>
8+
<span class="fa fa-bars"></span>
9+
</button>
610
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
711
<span class="sr-only">Toggle navigation</span>
812
<span class="icon-bar"></span>

app/themes/map/ui/app/app.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
(function () {
2+
'use strict';
3+
4+
angular.module('app', [
5+
'ml.common',
6+
'ml.search',
7+
'ml.search.tpls',
8+
'ml.utils',
9+
'ngJsonExplorer',
10+
'app.create',
11+
'app.detail',
12+
'app.error',
13+
'app.login',
14+
'app.root',
15+
'app.search',
16+
'app.user',
17+
'ui.bootstrap',
18+
'ui.router',
19+
'ui.tinymce',
20+
'ngToast',
21+
'uiGmapgoogle-maps'
22+
])
23+
.config(['uiGmapGoogleMapApiProvider', function(uiGmapGoogleMapApiProvider) {
24+
var libs = uiGmapGoogleMapApiProvider.options.libraries;
25+
if (libs === '') {
26+
libs = 'drawing';
27+
} else {
28+
libs = libs.split(',').push('drawing').join(',');
29+
}
30+
uiGmapGoogleMapApiProvider.configure({
31+
libraries: libs
32+
});
33+
}]);
34+
35+
}());

app/themes/map/ui/app/map/infoWindow.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<div class="map-info-window" ng-class="{ isShown: parameter.showMe }">
22
<section class="heading">
3+
<div class="info-close"><a ng-click="parameter.close()"><i class="fa fa-close"></i></a></div>
34
<h4 class="window-title">{{ parameter.name || parameter.label }}</h4>
45
</section>
56
<section class="window-content">

app/themes/map/ui/app/root/root.controller.js

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,6 @@
3030
return width < 992; // match bootrap sm
3131
};
3232

33-
service.controlsAreShown = !service.isMobile();
34-
35-
service.toggleControls = function() {
36-
service.controlsAreShown = !service.controlsAreShown;
37-
};
38-
39-
service.hideControls = function() {
40-
service.controlsAreShown = false;
41-
};
42-
43-
service.showControls = function() {
44-
service.controlsAreShown = true;
45-
};
46-
4733
return service;
4834
}
4935

@@ -61,9 +47,9 @@
6147
ctrl.currentUser = newValue;
6248
});
6349

64-
var miw = window.jQuery('#app-mobile-info-window').get(0); // FIXME: use angular.element?
50+
var miw = window.jQuery('#map-mobile-info-window').get(0); // FIXME: use angular.element?
6551
var miwscope = $rootScope.$new(), mobileWin;
66-
var pixelOffset,shownMarker;
52+
var pixelOffset,shownMarker,shown;
6753
var $googleMaps = null;
6854

6955
$googleMapsApi.then(function($gMaps) {
@@ -72,9 +58,8 @@
7258

7359
ctrl.mapManager = mlMapManager;
7460

75-
ctrl.isMobile = rootUtils.isMobile();
76-
77-
if (ctrl.isMobile) {
61+
if (rootUtils.isMobile()) {
62+
ctrl.hideControls = true;
7863
// compile the info window template
7964
// FIXME: can we use ng-include somehow? or the compile directive?
8065
$templateRequest('app/map/infoWindow.html').then(function(html) {
@@ -102,6 +87,8 @@
10287

10388
if (!marker.content) {
10489
inst.map.setCenter(position);
90+
ctrl.infoWindow.shown = false;
91+
delete ctrl.infoWindow.data;
10592
} else if (rootUtils.isMobile()) {
10693
if (!mobileWin) {
10794
mobileWin = new $googleMaps.InfoWindow({ content: '<span>' + marker.title + '</span>' });
@@ -113,23 +100,30 @@
113100
} else {
114101
mobileWin.setContent('<span>' + marker.title + '</span>');
115102
}
116-
var shown = (shownMarker !== marker.title);
103+
shown = (shownMarker === marker.title);
117104
if (shown) {
118-
mobileWin.open(inst.getMap(), inst);
119-
} else {
120105
mobileWin.close();
106+
} else {
107+
mobileWin.open(inst.getMap(), inst);
121108
}
122109
// for mobile we show our own window
123110
miwscope.parameter = marker.content;
124111
miwscope.parameter.showMe = shown;
112+
miwscope.parameter.close = function() {
113+
mobileWin.close();
114+
miwscope.parameter.showMe = false;
115+
shownMarker = null;
116+
};
125117
shownMarker = marker.title;
126118
inst.map.setCenter(position);
127119

128120
} else {
129121

130122
// otherwise manipulate the google map infowindow
131-
if (ctrl.infoWindow.shown) {
123+
shown = (shownMarker === marker.title);
124+
if (shown) {
132125
ctrl.infoWindow.shown = false;
126+
shownMarker = null;
133127
} else {
134128
ctrl.infoWindow.coords = {
135129
latitude: marker.location.latitude,
@@ -138,6 +132,7 @@
138132
ctrl.infoWindow.shown = true;
139133
ctrl.infoWindow.data = marker.content;
140134
inst.map.setCenter(position);
135+
shownMarker = marker.title;
141136
}
142137
}
143138
};

app/themes/map/ui/app/root/root.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33

44
<nav class="navbar navbar-default navbar-fixed-top nav" role="navigation">
55
<div class="navbar-header">
6-
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#sidebar" ng-click="ctrl.toggleControls()">
6+
<button type="button" class="controls-toggle btn btn-default pull-left" ng-click="ctrl.hideControls = !ctrl.hideControls">
7+
<span class="sr-only">Toggle sidebar</span>
8+
<span class="fa fa-bars"></span>
9+
</button>
10+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
711
<span class="sr-only">Toggle navigation</span>
812
<span class="icon-bar"></span>
913
<span class="icon-bar"></span>
@@ -52,7 +56,9 @@
5256
</ui-gmap-drawing-manager>
5357
</ui-gmap-google-map>
5458

55-
<div id="sidebar">
59+
<div id="map-mobile-info-window"></div>
60+
61+
<div id="sidebar" ng-show="!ctrl.hideControls">
5662
<div id="map-controls" class="container">
5763
<ui-view></ui-view>
5864
</div>

app/themes/map/ui/index.html

Lines changed: 0 additions & 59 deletions
This file was deleted.

app/themes/map/ui/styles/theme.less

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ h1#logo {
129129
}
130130
}
131131

132+
#map-mobile-info-window { display: none; }
133+
134+
.map-info-window .info-close { display: none; }
135+
132136
@media(max-width: 992px) {
133137
#logo {
134138
left: 25px;
@@ -144,6 +148,62 @@ h1#logo {
144148
margin-top: -25px;
145149
}
146150
}
151+
152+
#map-mobile-info-window {
153+
position: absolute;
154+
left: 0;
155+
bottom: 0;
156+
width: 100%;
157+
height: 0;
158+
display: block;
159+
160+
.map-info-window {
161+
position: relative;
162+
margin-top: -250px;
163+
height: 250px;
164+
background-color: #FFF;
165+
width: 100%;
166+
z-index: 600;
167+
overflow: auto;
168+
display: none;
169+
170+
&.isShown {
171+
display: block;
172+
}
173+
174+
.photo {
175+
position: absolute;
176+
right: 15px;
177+
top: 65px;
178+
z-index: 599;
179+
}
180+
181+
.heading {
182+
position: fixed;
183+
bottom: 222px;
184+
width: 100%;
185+
z-index: 600;
186+
}
187+
188+
.window-content {
189+
padding-top: 31px;
190+
191+
.details { width: 100%; }
192+
.dl-horizontal dt { width: 50%; }
193+
}
194+
195+
.info-close {
196+
display: block;
197+
position: absolute;
198+
right: 3px;
199+
top: 2px;
200+
i {
201+
color: #971a25;
202+
}
203+
}
204+
205+
}
206+
}
147207
}
148208

149209
#map-controls {
@@ -181,18 +241,17 @@ a.navbar-brand {
181241
nav.navbar {
182242
padding: 5px 20px;
183243
min-height: 20px;
244+
245+
.controls-toggle {
246+
margin-left: -12px;
247+
margin-top: 2px;
248+
}
184249
}
185250

186251
nav > .navbar-collapse > .navbar-nav > li > a {
187252
padding: 5px;
188253
}
189254

190-
.navbar-toggle {
191-
display: block;
192-
margin: 0px 5px;
193-
padding: 6px;
194-
}
195-
196255
nav .welcome {
197256
margin-top: 5px;
198257
}

0 commit comments

Comments
 (0)