From 00bea7eb332185260e4a30c3f5dd0843e8a228b7 Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Wed, 23 Aug 2017 18:14:45 +0200 Subject: [PATCH] [fix] change position of share popover, is small screen - fix #545 --- www/js/controllers/wallet-controllers.js | 6 +++ www/js/controllers/wot-controllers.js | 4 ++ www/plugins/es/i18n/locale-fr-FR.json | 4 ++ .../es/js/controllers/group-controllers.js | 49 ++++++++++++++++++- .../es/js/controllers/registry-controllers.js | 4 ++ .../templates/group/view_popover_actions.html | 22 +++++++++ .../es/templates/group/view_record.html | 1 + .../es/templates/registry/view_record.html | 1 + www/templates/wallet/view_wallet.html | 1 + www/templates/wot/view_identity.html | 1 + 10 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 www/plugins/es/templates/group/view_popover_actions.html diff --git a/www/js/controllers/wallet-controllers.js b/www/js/controllers/wallet-controllers.js index 95a270c5f..af7df4470 100644 --- a/www/js/controllers/wallet-controllers.js +++ b/www/js/controllers/wallet-controllers.js @@ -516,6 +516,12 @@ function WalletController($scope, $rootScope, $q, $ionicPopup, $timeout, $state, var title = $scope.formData.name || $scope.formData.uid || $scope.formData.pubkey; // Use shareBasePath (fix #530) or rootPath (fix #390) var url = (csConfig.shareBaseUrl || $rootScope.rootPath) + $state.href('app.wot_identity', {pubkey: $scope.formData.pubkey, uid: $scope.formData.name || $scope.formData.uid}); + + // Override default position, is small screen - fix #545 + if (UIUtils.screen.isSmall()) { + event = angular.element(document.querySelector('#wallet-share-anchor')) || event; + } + UIUtils.popover.share(event, { bindings: { url: url, diff --git a/www/js/controllers/wot-controllers.js b/www/js/controllers/wot-controllers.js index 70a09f523..6b6e20808 100644 --- a/www/js/controllers/wot-controllers.js +++ b/www/js/controllers/wot-controllers.js @@ -864,6 +864,10 @@ function WotIdentityAbstractController($scope, $rootScope, $state, $translate, $ var title = $scope.formData.name || $scope.formData.uid || $scope.formData.pubkey; // Use shareBasePath (fix #530) or rootPath (fix #390) var url = (csConfig.shareBaseUrl || $rootScope.rootPath) + $state.href('app.wot_identity', {pubkey: $scope.formData.pubkey, uid: $scope.formData.uid}); + // Override default position, is small screen - fix #545 + if (UIUtils.screen.isSmall()) { + event = angular.element(document.querySelector('#wot-share-anchor-'+$scope.formData.pubkey)) || event; + } UIUtils.popover.share(event, { bindings: { url: url, diff --git a/www/plugins/es/i18n/locale-fr-FR.json b/www/plugins/es/i18n/locale-fr-FR.json index fce9f3149..b45b197c0 100644 --- a/www/plugins/es/i18n/locale-fr-FR.json +++ b/www/plugins/es/i18n/locale-fr-FR.json @@ -230,6 +230,10 @@ "MANAGED": "Groupe administré" } }, + "VIEW": { + "POPOVER_SHARE_TITLE": "{{title}}", + "MENU_TITLE": "Options" + }, "EDIT": { "TITLE": "Groupe", "TITLE_NEW": "Nouveau groupe", diff --git a/www/plugins/es/js/controllers/group-controllers.js b/www/plugins/es/js/controllers/group-controllers.js index 4d7c05a52..ccad53153 100644 --- a/www/plugins/es/js/controllers/group-controllers.js +++ b/www/plugins/es/js/controllers/group-controllers.js @@ -178,7 +178,7 @@ function ESGroupListController($scope, UIUtils, $state, csWallet, esGroup, Modal } -function ESGroupViewController($scope, $state, UIUtils, esGroup, csWallet) { +function ESGroupViewController($scope, $state, $ionicPopover, UIUtils, csConfig, esGroup, csWallet) { 'ngInject'; $scope.formData = {}; @@ -229,6 +229,53 @@ function ESGroupViewController($scope, $state, UIUtils, esGroup, csWallet) { UIUtils.loading.show(); $state.go('app.edit_group', {id: $scope.id}); }; + + /* -- modals & popover -- */ + + $scope.showActionsPopover = function(event) { + if (!$scope.actionsPopover) { + $ionicPopover.fromTemplateUrl('plugins/es/templates/group/view_popover_actions.html', { + scope: $scope + }).then(function(popover) { + $scope.actionsPopover = popover; + //Cleanup the popover when we're done with it! + $scope.$on('$destroy', function() { + $scope.actionsPopover.remove(); + }); + $scope.actionsPopover.show(event); + }); + } + else { + $scope.actionsPopover.show(event); + } + }; + + $scope.hideActionsPopover = function() { + if ($scope.actionsPopover) { + $scope.actionsPopover.hide(); + } + }; + + $scope.showSharePopover = function(event) { + $scope.hideActionsPopover(); + + var title = $scope.formData.title; + // Use shareBasePath (fix #530) or rootPath (fix #390) + var url = (csConfig.shareBaseUrl || $rootScope.rootPath) + $state.href('app.view_group', {id: $scope.id}); + // Override default position, is small screen - fix #545 + if (UIUtils.screen.isSmall()) { + event = angular.element(document.querySelector('#group-share-anchor-'+$scope.id)) || event; + } + UIUtils.popover.share(event, { + bindings: { + url: url, + titleKey: 'GROUP.VIEW.POPOVER_SHARE_TITLE', + titleValues: {title: title}, + time: $scope.formData.time, + postMessage: title + } + }); + }; } function ESGroupEditController($scope, esGroup, UIUtils, $state, $q, Device, diff --git a/www/plugins/es/js/controllers/registry-controllers.js b/www/plugins/es/js/controllers/registry-controllers.js index b8be2f547..82f858b32 100644 --- a/www/plugins/es/js/controllers/registry-controllers.js +++ b/www/plugins/es/js/controllers/registry-controllers.js @@ -525,6 +525,10 @@ function ESRegistryRecordViewController($scope, $state, $q, $timeout, $ionicPopo var title = $scope.formData.title; // Use shareBasePath (fix #530) or rootPath (fix #390) var url = (csConfig.shareBaseUrl || $rootScope.rootPath) + $state.href('app.registry_view_record', {title: title, id: $scope.id}); + // Override default position, is small screen - fix #545 + if (UIUtils.screen.isSmall()) { + event = angular.element(document.querySelector('#registry-share-anchor-'+$scope.id)) || event; + } UIUtils.popover.share(event, { bindings: { url: url, diff --git a/www/plugins/es/templates/group/view_popover_actions.html b/www/plugins/es/templates/group/view_popover_actions.html new file mode 100644 index 000000000..060f0494d --- /dev/null +++ b/www/plugins/es/templates/group/view_popover_actions.html @@ -0,0 +1,22 @@ +<ion-popover-view class="fit has-header"> + <ion-header-bar> + <h1 class="title" translate>GROUP.VIEW.MENU_TITLE</h1> + </ion-header-bar> + <ion-content scroll="false"> + <div class="list item-text-wrap"> + + <a class="item item-icon-left ink" + ng-click="showSharePopover($event)"> + <i class="icon ion-android-share-alt"></i> + {{'COMMON.BTN_SHARE' | translate}} + </a> + + <!--<a class="item item-icon-left assertive ink" + ng-if="canEdit" + ng-click="delete()"> + <i class="icon ion-trash-a"></i> + {{'COMMON.BTN_DELETE' | translate}} + </a>--> + </div> + </ion-content> +</ion-popover-view> diff --git a/www/plugins/es/templates/group/view_record.html b/www/plugins/es/templates/group/view_record.html index 0a2dbdfb6..c48b694e6 100644 --- a/www/plugins/es/templates/group/view_record.html +++ b/www/plugins/es/templates/group/view_record.html @@ -67,6 +67,7 @@ </div> <!-- Buttons bar--> + <a id="group-share-anchor-{{id}}"></a> <div class="item large-button-bar hidden-xs hidden-sm"> <button class="button button-stable button-small-padding icon ion-android-share-alt" ng-click="showSharePopover($event)"> diff --git a/www/plugins/es/templates/registry/view_record.html b/www/plugins/es/templates/registry/view_record.html index 38e9ff83c..cce4a49ae 100644 --- a/www/plugins/es/templates/registry/view_record.html +++ b/www/plugins/es/templates/registry/view_record.html @@ -67,6 +67,7 @@ </div> <!-- Buttons bar--> + <a id="registry-share-anchor-{{id}}"></a> <div class="item large-button-bar hidden-xs hidden-sm"> <button class="button button-stable button-small-padding icon ion-android-share-alt" ng-click="showSharePopover($event)"> diff --git a/www/templates/wallet/view_wallet.html b/www/templates/wallet/view_wallet.html index dc041bd48..203f18c46 100644 --- a/www/templates/wallet/view_wallet.html +++ b/www/templates/wallet/view_wallet.html @@ -47,6 +47,7 @@ ng-click="toggleQRCode = !toggleQRCode"></div> <!-- Buttons bar--> + <a id="wallet-share-anchor"></a> <div class="hidden-xs hidden-sm padding text-center" ng-if="!loading"> <button class="button button-stable button-small-padding icon ion-android-share-alt ink" diff --git a/www/templates/wot/view_identity.html b/www/templates/wot/view_identity.html index 49b197598..221940428 100644 --- a/www/templates/wot/view_identity.html +++ b/www/templates/wot/view_identity.html @@ -34,6 +34,7 @@ </div> <!-- button bar--> + <a id="wot-share-anchor-{{::formData.pubkey}}"></a> <div class="hidden-xs hidden-sm padding text-center"> <button class="button button-stable button-small-padding icon ion-android-share-alt ink" ng-click="showSharePopover($event)" -- GitLab