diff --git a/www/js/directives.js b/www/js/directives.js index 1f20010ae85a6f4d5df6139318ed0d30e5aef112..9b2350b4517582bbaa434056ce710ef5487fa0f2 100644 --- a/www/js/directives.js +++ b/www/js/directives.js @@ -130,14 +130,16 @@ angular.module('cesium.directives', []) }) .catch(UIUtils.onError('ERROR.COPY_CLIPBOARD')); } - else if (value) { + else { + var rows = value && value.indexOf('\n') >= 0 ? value.split('\n').length : 1; UIUtils.popover.show(event, { scope: scope, templateUrl: 'templates/common/popover_copy.html', bindings: { value: attrs.copyOnClick, - rows: rows + rows: rows, + copied: false }, autoselect: '.popover-copy ' + (rows <= 1 ? 'input' : 'textarea'), @@ -152,6 +154,7 @@ angular.module('cesium.directives', []) } : undefined }); } + }; element.bind('click', showCopyPopover); element.bind('hold', showCopyPopover); diff --git a/www/plugins/es/js/controllers/common-controllers.js b/www/plugins/es/js/controllers/common-controllers.js index a1020d6cadcb1c8cd3da3a88100c1866e0a6ef9b..3f2e0e4973b438fa440d541b4d63acc6569569d7 100644 --- a/www/plugins/es/js/controllers/common-controllers.js +++ b/www/plugins/es/js/controllers/common-controllers.js @@ -157,20 +157,22 @@ function ESCommentsController($scope, $filter, $state, $focus, $timeout, $anchor $scope.anchor = state && state.stateParams.anchor; } // second call (when using cached view) - else if (!$scope.loading && $scope.id) { + else if ($scope.id) { $scope.load($scope.id, {animate: false}); } }); $scope.$on('$recordView.load', function(event, id, service) { $scope.id = id || $scope.id; - $scope.service = service || $scope.service; - console.debug("[ES] [comment] Will use {" + service.index + "} service"); + $scope.service = service.comment || $scope.service; + console.debug("[ES] [comment] Will use {" + $scope.service.index + "} service"); if ($scope.id) { $scope.load($scope.id) .then(function() { - // Scroll to anchor - $scope.scrollToAnchor(); + return $timeout(function() { + // Scroll to anchor + $scope.scrollToAnchor(); + }, 500); }); } }); @@ -410,6 +412,7 @@ function ESSocialsViewController($scope) { 'ngInject'; $scope.openSocial = function(event, social) { + event.stopPropagation(); return $scope.openLink(event, social.url, { type: social.type }); @@ -512,7 +515,7 @@ function ESPositionEditController($scope, csConfig, esGeo, ModalUtils) { $scope.formPosition.loading = true; return esGeo.point.searchByAddress(searchText) .then(function(res) { - if (res && res.length == 1) { + if (res && res.length === 1) { return $scope.updateGeoPoint(res[0]); } return $scope.openSearchLocationModal({ @@ -531,15 +534,15 @@ function ESPositionEditController($scope, csConfig, esGeo, ModalUtils) { }; $scope.onCityChanged = function() { - if ($scope.loading) return; - if ($scope.formPosition.enable) { - if ($scope.formData.geoPoint) { - // Invalidate the position - $scope.formData.geoPoint.lat = undefined; - $scope.formData.geoPoint.lon = undefined; - } - return $scope.tryToLocalize(); + if ($scope.loading) return; + if ($scope.formPosition.enable) { + if ($scope.formData.geoPoint) { + // Invalidate the position + $scope.formData.geoPoint.lat = undefined; + $scope.formData.geoPoint.lon = undefined; } + return $scope.tryToLocalize(); + } }; $scope.onUseGeopointChanged = function() { @@ -566,7 +569,7 @@ function ESPositionEditController($scope, csConfig, esGeo, ModalUtils) { $scope.getAddressToSearch = function() { return $scope.formData.address && $scope.formData.city ? [$scope.formData.address.trim(), $scope.formData.city.trim()].join(', ') : - $scope.formData.city || $scope.formData.address || $scope.formData.location ; + $scope.formData.city || $scope.formData.address || $scope.formData.location ; }; $scope.updateGeoPoint = function(res) { @@ -586,7 +589,7 @@ function ESPositionEditController($scope, csConfig, esGeo, ModalUtils) { if (res.address.postcode) { cityParts.push(res.address.postcode); } - if (res.address.country != defaultCountry) { + if (res.address.country !== defaultCountry) { cityParts.push(res.address.country); } $scope.formData.city = cityParts.join(', '); @@ -654,31 +657,31 @@ function ESLookupPositionController($scope, $q, csConfig, esGeo, ModalUtils) { var promise = !searchText ? esGeo.point.current() : esGeo.point.searchByAddress(searchText) - .then(function(res) { - if (res && res.length == 1) { - res[0].exact = true; - return res[0]; - } - return $scope.openSearchLocationModal({ - text: searchText, - results: res||[], - forceFallback: !res || !res.length // force fallback search first - }) - .then(function(res) { - // Compute point name - if (res && res.address && res.address.city) { - var cityParts = [res.address.city]; - if (res.address.postcode) { - cityParts.push(res.address.postcode); - } - if (res.address.country != defaultCountry) { - cityParts.push(res.address.country); + .then(function(res) { + if (res && res.length === 1) { + res[0].exact = true; + return res[0]; + } + return $scope.openSearchLocationModal({ + text: searchText, + results: res||[], + forceFallback: !res || !res.length // force fallback search first + }) + .then(function(res) { + // Compute point name + if (res && res.address && res.address.city) { + var cityParts = [res.address.city]; + if (res.address.postcode) { + cityParts.push(res.address.postcode); + } + if (res.address.country !== defaultCountry) { + cityParts.push(res.address.country); + } + res.shortName = cityParts.join(', '); } - res.shortName = cityParts.join(', '); - } - return res; - }); - }); + return res; + }); + }); promise .then(function(res) { @@ -730,7 +733,7 @@ function ESLookupPositionController($scope, $q, csConfig, esGeo, ModalUtils) { }; } -function ESSearchPositionItemController($scope, $timeout, ModalUtils, csConfig, esGeo) { +function ESSearchPositionItemController($scope, $timeout, UIUtils, ModalUtils, csConfig, esGeo) { 'ngInject'; // The default country used for address localisation @@ -813,7 +816,7 @@ function ESSearchPositionItemController($scope, $timeout, ModalUtils, csConfig, $scope.showDropdown = function() { var text = $scope.search.location && $scope.search.location.trim(); if (!text || text.length < minLength) { - return $scope.hideDropdown(true/*force, if still loading*/); + return $scope.hideDropdown(true/*force, if still loading*/); } // Compute a request id, to apply response only if current request @@ -873,7 +876,7 @@ function ESSearchPositionItemController($scope, $timeout, ModalUtils, csConfig, if (res.address.postcode) { cityParts.push(res.address.postcode); } - if (res.address.country != defaultCountry) { + if (res.address.country !== defaultCountry) { cityParts.push(res.address.country); } $scope.search.location = cityParts.join(', '); @@ -897,16 +900,35 @@ function ESSearchPositionItemController($scope, $timeout, ModalUtils, csConfig, }; return ModalUtils.show( - 'plugins/es/templates/common/modal_location.html', - 'ESSearchPositionModalCtrl', - parameters, - { - focusFirstInput: true - } - ) + 'plugins/es/templates/common/modal_location.html', + 'ESSearchPositionModalCtrl', + parameters, + { + focusFirstInput: true + }) .then($scope.selectLocation); }; + /* -- popover -- */ + + $scope.showDistancePopover = function(event) { + UIUtils.popover.show(event, { + templateUrl: 'plugins/es/templates/common/popover_distances.html', + scope: $scope, + autoremove: true, + afterShow: function(popover) { + $scope.actionsPopover = popover; + } + }); + }; + + $scope.selectDistance = function(value) { + $scope.search.geoDistance = value; + if ($scope.actionsPopover) { + $scope.actionsPopover.hide(); + } + }; + } function ESSearchPositionModalController($scope, $q, $translate, esGeo, parameters) { @@ -936,13 +958,13 @@ function ESSearchPositionModalController($scope, $q, $translate, esGeo, paramete // Compute alternative query text var fallbackText = firstSearch && $scope.search.fallbackText && $scope.search.fallbackText.trim(); - fallbackText = fallbackText && fallbackText != text ? fallbackText : undefined; + fallbackText = fallbackText && fallbackText !== text ? fallbackText : undefined; // Execute the given query return ((firstSearch && $scope.search.forceFallback && $scope.search.results) ? $q.when($scope.search.results) : esGeo.point.searchByAddress(text) - ) + ) .then(function(res) { if (res && res.length || !fallbackText) return res; diff --git a/www/plugins/map/js/controllers/wot-controllers.js b/www/plugins/map/js/controllers/wot-controllers.js index 75e83baa19a3695758d11a9ad40d1887106f3672..0acd60d0ebc38b9b03e013d57d4bb019bcb70e67 100644 --- a/www/plugins/map/js/controllers/wot-controllers.js +++ b/www/plugins/map/js/controllers/wot-controllers.js @@ -238,8 +238,8 @@ function MapWotViewController($scope, $filter, $templateCache, $interpolate, $ti maxClusterRadius: 65, showCoverageOnHover: false, iconCreateFunction: function (cluster) { - //var countByLayer = _.countBy(cluster.getAllChildMarkers(), extractMarkerLayer); - var markerColor = 'blue'; //countByLayer.member ? 'blue' : (countByLayer.pending ? 'lightgreen' : 'lightgray'); + var countByLayer = _.countBy(cluster.getAllChildMarkers(), extractMarkerLayer); + var markerColor = countByLayer.member ? 'blue' : (countByLayer.pending ? 'lightgreen' : 'lightgray'); var childCount = cluster.getChildCount(); var className = 'marker-cluster ' + markerColor + ' marker-cluster-'; if (childCount < 10) {