From 5cf067a05f43564573a37d1379d302dba69fc7f8 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Mon, 13 Jun 2016 15:23:25 +0300 Subject: [PATCH 1/4] Added tooltip --- app/js/locales/en-us.json | 1 + app/partials/desktop/peer_select.html | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/js/locales/en-us.json b/app/js/locales/en-us.json index 20de8ec7..bf27723b 100644 --- a/app/js/locales/en-us.json +++ b/app/js/locales/en-us.json @@ -275,6 +275,7 @@ "conversations_modal_select_recipients": "Select recipients", "conversations_modal_recipients": "Recipients:", "conversations_modal_share_url_loading": "Loading{dots}", + "conversations_modal_share_url_copy": "Click to copy share link", "contact_edit_modal_first_name": "First name", "contact_edit_modal_last_name": "Last name", diff --git a/app/partials/desktop/peer_select.html b/app/partials/desktop/peer_select.html index 0037d364..c30267e8 100644 --- a/app/partials/desktop/peer_select.html +++ b/app/partials/desktop/peer_select.html @@ -78,7 +78,7 @@ - + From 6bb63b2a909c100caad5b2d7917efe6af96943e2 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Mon, 13 Jun 2016 22:04:13 +0300 Subject: [PATCH 2/4] improved copy --- app/js/directives.js | 62 +++++++++++++++++++++++++++ app/partials/desktop/peer_select.html | 2 +- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/app/js/directives.js b/app/js/directives.js index e230d7e2..1a9585d2 100755 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -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 { diff --git a/app/partials/desktop/peer_select.html b/app/partials/desktop/peer_select.html index c30267e8..e5134acf 100644 --- a/app/partials/desktop/peer_select.html +++ b/app/partials/desktop/peer_select.html @@ -78,7 +78,7 @@ - + From e4c5f28147f6e21de908e1c173c275b4169cbaa5 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Tue, 14 Jun 2016 15:14:20 +0300 Subject: [PATCH 3/4] Improved share links --- app/js/directives.js | 110 ++++++------------ app/js/locales/en-us.json | 2 +- .../desktop/chat_invite_link_modal.html | 4 +- app/partials/desktop/peer_select.html | 4 +- 4 files changed, 42 insertions(+), 78 deletions(-) diff --git a/app/js/directives.js b/app/js/directives.js index 1a9585d2..360930ab 100755 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -3217,65 +3217,35 @@ angular.module('myApp.directives', ['myApp.filters']) }; }) - .directive('myCopyElement', function (toaster, _) { + .directive('myCopyField', function (toaster, _) { return { scope: { - selectEvent: '=myCopyElement' + selectEvent: '=myCopyField' }, link: link }; function link($scope, element, attrs) { - if (element[0].tagName == 'INPUT') { - element.attr('readonly', 'true'); - element[0].readonly = true; - element.on('click', function () { - this.select(); - }); + element.attr('readonly', 'true'); + element[0].readonly = true; + element.on('click', function () { + this.select(); + }); - if ($scope.selectEvent) { - $scope.$on($scope.selectEvent, function () { - setTimeout(function () { - element[0].focus(); - element[0].select(); - }, 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(); + if ($scope.selectEvent) { + $scope.$on($scope.selectEvent, function () { + setTimeout(function () { + element[0].focus(); + element[0].select(); + }, 100); }); } }; }) - .directive('myCopyLink', function ($compile, _) { + .directive('myCopyLink', function ($compile, $timeout, _) { return { restrict: 'A', @@ -3286,48 +3256,40 @@ angular.module('myApp.directives', ['myApp.filters']) }; 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}}'); - element.removeAttr('my-copy-link'); - element.removeAttr('data-my-copy-link'); + var resetPromise = false; + var resetTooltip = function () { + $timeout.cancel(resetPromise); + resetPromise = false; + $scope.ttLabel = _('conversations_modal_share_url_copy_raw'); + }; - $compile(element)($scope); - // } + resetTooltip(); - // scope: { - // selectEvent: '=myCopyElement' - // }, - // link: link - // }; + $compile(element)($scope); - // 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 + $timeout.cancel(resetPromise); + $scope.$apply(function () { + $scope.ttLabel = _('clipboard_copied_raw'); }); - e.clearSelection(); + resetPromise = $timeout(resetTooltip, 2000); }); 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 + $timeout.cancel(resetPromise); + var langKey = Config.Navigator.osX + ? 'clipboard_press_cmd_c' + : 'clipboard_press_ctrl_c'; + $scope.$apply(function () { + $scope.ttLabel = _(langKey + '_raw'); }); + resetPromise = $timeout(resetTooltip, 5000); }); $scope.$on('$destroy', function () { diff --git a/app/js/locales/en-us.json b/app/js/locales/en-us.json index bf27723b..3d93176e 100644 --- a/app/js/locales/en-us.json +++ b/app/js/locales/en-us.json @@ -208,7 +208,7 @@ "clipboard_copied": "Copied!", "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_update_reload": "A new version of Telegram Web has been downloaded. Launch it?", diff --git a/app/partials/desktop/chat_invite_link_modal.html b/app/partials/desktop/chat_invite_link_modal.html index 3ebd6374..3d70634a 100644 --- a/app/partials/desktop/chat_invite_link_modal.html +++ b/app/partials/desktop/chat_invite_link_modal.html @@ -10,14 +10,14 @@
- +
- +
diff --git a/app/partials/desktop/peer_select.html b/app/partials/desktop/peer_select.html index e5134acf..325a35c8 100644 --- a/app/partials/desktop/peer_select.html +++ b/app/partials/desktop/peer_select.html @@ -78,7 +78,9 @@ - + + +
From cb9aed03f7780814ab14905092fca098c69f942e Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Tue, 14 Jun 2016 18:37:05 +0300 Subject: [PATCH 4/4] drafts draft --- app/js/services.js | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/app/js/services.js b/app/js/services.js index d16efcf0..6015f6f2 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -4454,3 +4454,54 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) shareUrl: shareUrl }; }) + + +.service('DraftsManager', function (qSync, Storage) { + + var localDrafts = {}; + + return { + getDraft: getDraft, + saveDraft: saveDraft, + changeDraft: changeDraft, + syncDraft: syncDraft + }; + + function getDraft (peerID, options) { + return Storage.get('draft' + peerID).then(function (draft) { + if (typeof draft === 'string' && draft.length > 0) { + draft = { + text: draft + }; + } + if (draft === false || draft == null) { + draft = ''; + } + + }); + } + + function saveDraft(peerID, draftData) { + localDrafts[peerID] = draftData; + } + + function changeDraft(peerID, message, options) { + options = options || {}; + if (typeof message === 'string' || options.replyToMsgID) { + var localDraft = { + text: message, + replyToMsgID: replyToMsgID + }; + var backupDraftObj = {}; + backupDraftObj['draft' + peerID] = localDraft; + Storage.set(backupDraftObj); + } else { + Storage.remove('draft' + peerID); + } + } + + function syncDraft(peerID) { + + } + +}) \ No newline at end of file