Browse Source

improved copy

master
Igor Zhukov 8 years ago
parent
commit
6bb63b2a90
  1. 62
      app/js/directives.js
  2. 2
      app/partials/desktop/peer_select.html

62
app/js/directives.js

@ -3275,6 +3275,68 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -3275,6 +3275,68 @@ angular.module('myApp.directives', ['myApp.filters'])
})
.directive('myCopyLink', function ($compile, _) {
return {
restrict: 'A',
replace: false,
terminal: true,
priority: 1000,
link: link
};
function link ($scope, element, attrs) {
$scope.ttLabel = _('conversations_modal_share_url_copy');
element.attr('tooltip', '{{ttLabel}}');
element.removeAttr('my-copy-link');
element.removeAttr('data-my-copy-link');
$compile(element)($scope);
// }
// scope: {
// selectEvent: '=myCopyElement'
// },
// link: link
// };
// function link($scope, element, attrs) {
var clipboard = new Clipboard(element[0]);
clipboard.on('success', function(e) {
$scope.ttLabel = _('clipboard_copied');
return;
toaster.pop({
type: 'info',
timeout: 2000,
body: _('clipboard_copied'),
bodyOutputType: 'trustedHtml',
showCloseButton: false
});
e.clearSelection();
});
clipboard.on('error', function(e) {
var langKey = Config.Navigator.osX ? 'clipboard_press_cmd_c' : 'clipboard_press_ctrl_c';
$scope.ttLabel = _(langKey);
return;
toaster.pop({
type: 'info',
timeout: 4000,
body: _(langKey),
bodyOutputType: 'trustedHtml',
showCloseButton: false
});
});
$scope.$on('$destroy', function () {
clipboard.destroy();
});
}
})
.directive('mySubmitOnEnter', function () {
return {

2
app/partials/desktop/peer_select.html

@ -78,7 +78,7 @@ @@ -78,7 +78,7 @@
<span ng-switch-when="url_loading" class="peer_select_modal_recipients_empty" my-i18n="conversations_modal_share_url_loading">
<my-i18n-param name="dots"><span my-loading-dots></span></my-i18n-param>
</span>
<a ng-switch-when="url" class="peer_select_modal_share_link" my-copy-element ng-bind="shareLink.url | shortUrl" data-clipboard-text="{{shareLink.url}}" tooltip="{{'conversations_modal_share_url_copy' | i18n}}"></a>
<a ng-switch-when="url" class="peer_select_modal_share_link" my-copy-link ng-bind="shareLink.url | shortUrl" data-clipboard-text="{{shareLink.url}}" tooltip="{{'conversations_modal_share_url_copy' | i18n}}"></a>
<span ng-switch-default class="peer_select_modal_recipients_empty" my-i18n="conversations_modal_select_recipients"></span>
</span>
<span ng-switch-default>

Loading…
Cancel
Save