Improved share links
This commit is contained in:
parent
6bb63b2a90
commit
e4c5f28147
@ -3217,65 +3217,35 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
.directive('myCopyElement', function (toaster, _) {
|
.directive('myCopyField', function (toaster, _) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
scope: {
|
scope: {
|
||||||
selectEvent: '=myCopyElement'
|
selectEvent: '=myCopyField'
|
||||||
},
|
},
|
||||||
link: link
|
link: link
|
||||||
};
|
};
|
||||||
|
|
||||||
function link($scope, element, attrs) {
|
function link($scope, element, attrs) {
|
||||||
if (element[0].tagName == 'INPUT') {
|
element.attr('readonly', 'true');
|
||||||
element.attr('readonly', 'true');
|
element[0].readonly = true;
|
||||||
element[0].readonly = true;
|
element.on('click', function () {
|
||||||
element.on('click', function () {
|
this.select();
|
||||||
this.select();
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if ($scope.selectEvent) {
|
if ($scope.selectEvent) {
|
||||||
$scope.$on($scope.selectEvent, function () {
|
$scope.$on($scope.selectEvent, function () {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
element[0].focus();
|
element[0].focus();
|
||||||
element[0].select();
|
element[0].select();
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var clipboard = new Clipboard(element[0]);
|
|
||||||
|
|
||||||
clipboard.on('success', function(e) {
|
|
||||||
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';
|
|
||||||
toaster.pop({
|
|
||||||
type: 'info',
|
|
||||||
timeout: 4000,
|
|
||||||
body: _(langKey),
|
|
||||||
bodyOutputType: 'trustedHtml',
|
|
||||||
showCloseButton: false
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.$on('$destroy', function () {
|
|
||||||
clipboard.destroy();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
.directive('myCopyLink', function ($compile, _) {
|
.directive('myCopyLink', function ($compile, $timeout, _) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
@ -3286,48 +3256,40 @@ angular.module('myApp.directives', ['myApp.filters'])
|
|||||||
};
|
};
|
||||||
|
|
||||||
function link ($scope, element, attrs) {
|
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');
|
||||||
|
|
||||||
element.attr('tooltip', '{{ttLabel}}');
|
var resetPromise = false;
|
||||||
element.removeAttr('my-copy-link');
|
var resetTooltip = function () {
|
||||||
element.removeAttr('data-my-copy-link');
|
$timeout.cancel(resetPromise);
|
||||||
|
resetPromise = false;
|
||||||
|
$scope.ttLabel = _('conversations_modal_share_url_copy_raw');
|
||||||
|
};
|
||||||
|
|
||||||
$compile(element)($scope);
|
resetTooltip();
|
||||||
// }
|
|
||||||
|
|
||||||
// scope: {
|
$compile(element)($scope);
|
||||||
// selectEvent: '=myCopyElement'
|
|
||||||
// },
|
|
||||||
// link: link
|
|
||||||
// };
|
|
||||||
|
|
||||||
// function link($scope, element, attrs) {
|
|
||||||
var clipboard = new Clipboard(element[0]);
|
var clipboard = new Clipboard(element[0]);
|
||||||
|
|
||||||
clipboard.on('success', function(e) {
|
clipboard.on('success', function(e) {
|
||||||
$scope.ttLabel = _('clipboard_copied');
|
$timeout.cancel(resetPromise);
|
||||||
return;
|
$scope.$apply(function () {
|
||||||
toaster.pop({
|
$scope.ttLabel = _('clipboard_copied_raw');
|
||||||
type: 'info',
|
|
||||||
timeout: 2000,
|
|
||||||
body: _('clipboard_copied'),
|
|
||||||
bodyOutputType: 'trustedHtml',
|
|
||||||
showCloseButton: false
|
|
||||||
});
|
});
|
||||||
e.clearSelection();
|
resetPromise = $timeout(resetTooltip, 2000);
|
||||||
});
|
});
|
||||||
|
|
||||||
clipboard.on('error', function(e) {
|
clipboard.on('error', function(e) {
|
||||||
var langKey = Config.Navigator.osX ? 'clipboard_press_cmd_c' : 'clipboard_press_ctrl_c';
|
$timeout.cancel(resetPromise);
|
||||||
$scope.ttLabel = _(langKey);
|
var langKey = Config.Navigator.osX
|
||||||
return;
|
? 'clipboard_press_cmd_c'
|
||||||
toaster.pop({
|
: 'clipboard_press_ctrl_c';
|
||||||
type: 'info',
|
$scope.$apply(function () {
|
||||||
timeout: 4000,
|
$scope.ttLabel = _(langKey + '_raw');
|
||||||
body: _(langKey),
|
|
||||||
bodyOutputType: 'trustedHtml',
|
|
||||||
showCloseButton: false
|
|
||||||
});
|
});
|
||||||
|
resetPromise = $timeout(resetTooltip, 5000);
|
||||||
});
|
});
|
||||||
|
|
||||||
$scope.$on('$destroy', function () {
|
$scope.$on('$destroy', function () {
|
||||||
|
@ -208,7 +208,7 @@
|
|||||||
|
|
||||||
"clipboard_copied": "Copied!",
|
"clipboard_copied": "Copied!",
|
||||||
"clipboard_press_ctrl_c": "Press Ctrl+C to copy",
|
"clipboard_press_ctrl_c": "Press Ctrl+C to copy",
|
||||||
"clipboard_press_cmd_c": "Press ⌘ + C to copy",
|
"clipboard_press_cmd_c": "Press ⌘+C to copy",
|
||||||
|
|
||||||
"confirm_modal_logout": "Are you sure you want to log out?",
|
"confirm_modal_logout": "Are you sure you want to log out?",
|
||||||
"confirm_modal_update_reload": "A new version of Telegram Web has been downloaded. Launch it?",
|
"confirm_modal_update_reload": "A new version of Telegram Web has been downloaded. Launch it?",
|
||||||
|
@ -10,14 +10,14 @@
|
|||||||
<div ng-switch-when="true">
|
<div ng-switch-when="true">
|
||||||
<div class="md-input-group md-textarea-group" my-labeled-input>
|
<div class="md-input-group md-textarea-group" my-labeled-input>
|
||||||
<label class="md-input-label" my-i18n="group_invite_link_link_label"></label>
|
<label class="md-input-label" my-i18n="group_invite_link_link_label"></label>
|
||||||
<textarea class="md-input" ng-model="exportedInvite.link" rows="2" my-copy-element="'ui_invite_select'"></textarea>
|
<textarea class="md-input" ng-model="exportedInvite.link" rows="2" my-copy-field="'ui_invite_select'"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-switch-default>
|
<div ng-switch-default>
|
||||||
<div class="md-input-group" my-labeled-input>
|
<div class="md-input-group" my-labeled-input>
|
||||||
<label class="md-input-label" my-i18n="group_invite_link_link_label"></label>
|
<label class="md-input-label" my-i18n="group_invite_link_link_label"></label>
|
||||||
<input class="md-input" type="text" ng-model="exportedInvite.link" my-copy-element="'ui_invite_select'" />
|
<input class="md-input" type="text" ng-model="exportedInvite.link" my-copy-field="'ui_invite_select'" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -78,7 +78,9 @@
|
|||||||
<span ng-switch-when="url_loading" class="peer_select_modal_recipients_empty" my-i18n="conversations_modal_share_url_loading">
|
<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>
|
<my-i18n-param name="dots"><span my-loading-dots></span></my-i18n-param>
|
||||||
</span>
|
</span>
|
||||||
<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-when="url">
|
||||||
|
<a class="peer_select_modal_share_link" my-copy-link ng-bind="shareLink.url | shortUrl" data-clipboard-text="{{shareLink.url}}"></a>
|
||||||
|
</span>
|
||||||
<span ng-switch-default class="peer_select_modal_recipients_empty" my-i18n="conversations_modal_select_recipients"></span>
|
<span ng-switch-default class="peer_select_modal_recipients_empty" my-i18n="conversations_modal_select_recipients"></span>
|
||||||
</span>
|
</span>
|
||||||
<span ng-switch-default>
|
<span ng-switch-default>
|
||||||
|
Loading…
Reference in New Issue
Block a user