diff --git a/www/js/controllers/app-controllers.js b/www/js/controllers/app-controllers.js index b83361552bc8362f06931ed2fb8034773d51acf3..32b38329be7052d0f5e21cf817b7974d424628a2 100644 --- a/www/js/controllers/app-controllers.js +++ b/www/js/controllers/app-controllers.js @@ -385,14 +385,15 @@ function AppController($scope, $rootScope, $state, $ionicSideMenuDelegate, $q, $ // Link managment (fix issue #) //////////////////////////////////////// - $scope.openLink = function(event, uri, options) { + $scope.openLink = function($event, uri, options) { options = options || {}; // If unable to open, just copy value options.onError = function() { - return UIUtils.popover.copy(event, uri); + return UIUtils.popover.copy($event, uri); }; + $event.stopPropagation(); return csHttp.uri.open(uri, options); }; diff --git a/www/js/filters.js b/www/js/filters.js index 9e04d158190a34162b35639a97c7d841856bb27c..72e9d1671a861985e34c481a5b0e207281cc430f 100644 --- a/www/js/filters.js +++ b/www/js/filters.js @@ -374,6 +374,14 @@ angular.module('cesium.filters', ['cesium.config', 'cesium.platform', 'pascalpre }; }) + .filter('truncUrl', function() { + return function(input, size) { + size = size || 25; + var startIndex = input.startsWith('http://') ? 7 : (input.startsWith('https://') ? 8 : 0); + return !input || (input.length-startIndex) <= size ? input.substr(startIndex) : (input.substr(startIndex, size) + '...'); + }; + }) + .filter('trustAsHtml', function($sce) { return function(html) { return $sce.trustAsHtml(html); diff --git a/www/plugins/es/js/controllers/common-controllers.js b/www/plugins/es/js/controllers/common-controllers.js index 41d37f4d95b36e18fdd3faa4da1145591dacc05e..d0f7ce1b552888c67eccbdbce183f775104e0a94 100644 --- a/www/plugins/es/js/controllers/common-controllers.js +++ b/www/plugins/es/js/controllers/common-controllers.js @@ -362,8 +362,9 @@ function ESSocialsEditController($scope, $focus, $filter, UIUtils, SocialUtils) function ESSocialsViewController($scope) { 'ngInject'; - $scope.openSocial = function(event, social) { - return $scope.openLink(event, social.url, { + $scope.openSocial = function($event, social) { + $event.stopPropagation(); + return $scope.openLink($event, social.url, { type: social.type }); }; diff --git a/www/plugins/es/js/services/http-services.js b/www/plugins/es/js/services/http-services.js index 0ba2cd55f9e7dcfb4ba7bc6a69695025ce4a7756..8f7c01fd5362d2e9468e157c4df1b1fff2364351 100644 --- a/www/plugins/es/js/services/http-services.js +++ b/www/plugins/es/js/services/http-services.js @@ -3,7 +3,7 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic /** * Elastic Search Http */ -.factory('esHttp', function($q, $timeout, $rootScope, $state, $sce, $translate, $window, +.factory('esHttp', function($q, $timeout, $rootScope, $state, $sce, $translate, $window, $filter, CryptoUtils, UIUtils, csHttp, csConfig, csSettings, BMA, csWallet, csPlatform, Api) { 'ngInject'; @@ -30,7 +30,8 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic }, fallbackNodeIndex = 0, listeners, - defaultSettingsNode; + defaultSettingsNode, + truncUrlFilter = $filter('truncUrl'); that.data = { isFallback: false @@ -390,7 +391,7 @@ angular.module('cesium.es.http.services', ['ngResource', 'ngApi', 'cesium.servic var urls = parseUrlsFromText(content); _.forEach(urls, function(url){ // Redirect URL to the function 'openLink', to open a new window if need (e.g. desktop app) - var link = '<a ng-click=\"openLink($event, \'{0}\')\">{1}</a>'.format(url, url); + var link = '<a on-tap=\"openLink($event, \'{0}\')\" href=\"{1}\" target="_blank">{2}</a>'.format(url, url, truncUrlFilter(url)); content = content.replace(url, link); }); diff --git a/www/plugins/es/templates/user/items_profile.html b/www/plugins/es/templates/user/items_profile.html index 37332ebdc898a6a2a9dbbfcf22b43f3854094b22..6c798a3eecfc8edb6f40c03807b1f3bb313b52c9 100644 --- a/www/plugins/es/templates/user/items_profile.html +++ b/www/plugins/es/templates/user/items_profile.html @@ -30,7 +30,8 @@ <ion-item ng-repeat="social in formData.profile.socials | filter:filterFn track by social.url " id="social-{{::social.url|formatSlug}}" class="item-icon-left item-text-wrap no-padding-bottom ink" - ng-click="openSocial($event, social)"> + on-tap="openSocial($event, social)" + > <i class="icon ion-social-{{social.type}}" ng-class="{'ion-bookmark': social.type == 'other', 'ion-link': social.type == 'web', 'ion-email': social.type == 'email', 'ion-iphone': social.type == 'phone'}"></i> <p ng-if="social.type && social.type != 'web'"> @@ -38,7 +39,7 @@ <i class="ion-locked" ng-if="social.recipient"></i> </p> <h4> - <a>{{::social.url}}</a> + <a on-tap="openSocial($event, social)" href="{{::social.url}}" target="_blank">{{::social.url}}</a> </h4> </ion-item> </div>