From 2a28adb6e5422abd1b5f2091710d6e3d7a206043 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Thu, 9 Jul 2015 12:09:44 +0300 Subject: [PATCH] Open stickerset on click Closes #820 --- app/js/controllers.js | 4 ++++ app/js/directives.js | 10 ++++++++- app/js/services.js | 21 +++++++++++++------ app/less/app.less | 3 ++- .../desktop/message_attach_document.html | 2 +- .../mobile/message_attach_document.html | 2 +- 6 files changed, 32 insertions(+), 10 deletions(-) diff --git a/app/js/controllers.js b/app/js/controllers.js index 4652f812..99543af6 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -1415,6 +1415,10 @@ angular.module('myApp.controllers', ['myApp.i18n']) target.getAttribute('ng-click')) { return false; } + var events = $._data(target, 'events'); + if (events && (events.click || events.mousedown)) { + return false; + } target = target.parentNode; } } diff --git a/app/js/directives.js b/app/js/directives.js index 38106ed8..42f47f21 100755 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -1898,7 +1898,7 @@ angular.module('myApp.directives', ['myApp.filters']) } }) - .directive('myLoadSticker', function(MtpApiFileManager, FileManager) { + .directive('myLoadSticker', function(MtpApiFileManager, FileManager, AppStickersManager) { var emptySrc = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'; @@ -1969,6 +1969,14 @@ angular.module('myApp.directives', ['myApp.filters']) console.log('Download sticker failed', e, fullLocation); }); } + + if (attrs.open && $scope.document.stickerSetInput) { + element + .addClass('clickable') + .on('click', function () { + AppStickersManager.openStickerset($scope.document.stickerSetInput); + }); + } } }) diff --git a/app/js/services.js b/app/js/services.js index 16fb29bd..053cee40 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -3707,9 +3707,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) apiDoc.stickerEmojiRaw = attribute.alt; apiDoc.stickerEmoji = RichTextProcessor.wrapRichText(apiDoc.stickerEmojiRaw, {noLinks: true, noLinebreaks: true}); } - if (attribute.stickerset && - attribute.stickerset._ == 'inputStickerSetID') { - apiDoc.stickerSetID = attribute.stickerset.id; + if (attribute.stickerset) { + if (attribute.stickerset._ == 'inputStickerSetEmpty') { + delete attribute.stickerset; + } + else if (attribute.stickerset._ == 'inputStickerSetID') { + apiDoc.stickerSetInput = attribute.stickerset; + } } break; case 'documentAttributeImageSize': @@ -4017,6 +4021,7 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) return { start: start, openStickersetLink: openStickersetLink, + openStickerset: openStickerset, installStickerset: installStickerset, getStickers: getStickers, getStickerset: getStickerset, @@ -4178,11 +4183,15 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) } function openStickersetLink (shortName) { - var scope = $rootScope.$new(true); - scope.inputStickerset = { + return openStickerset({ _: 'inputStickerSetShortName', short_name: shortName - }; + }); + } + + function openStickerset (inputStickerset) { + var scope = $rootScope.$new(true); + scope.inputStickerset = inputStickerset; var modal = $modal.open({ templateUrl: templateUrl('stickerset_modal'), controller: 'StickersetModalController', diff --git a/app/less/app.less b/app/less/app.less index 1a0e38b4..0ed740af 100644 --- a/app/less/app.less +++ b/app/less/app.less @@ -1660,7 +1660,8 @@ div.im_message_video_thumb { } .im_history_select_active { - a { + a, + .clickable { pointer-events: none; } } diff --git a/app/partials/desktop/message_attach_document.html b/app/partials/desktop/message_attach_document.html index 5b1412c9..8c84ec3b 100644 --- a/app/partials/desktop/message_attach_document.html +++ b/app/partials/desktop/message_attach_document.html @@ -2,7 +2,7 @@
-
+
diff --git a/app/partials/mobile/message_attach_document.html b/app/partials/mobile/message_attach_document.html index 5b1412c9..8c84ec3b 100644 --- a/app/partials/mobile/message_attach_document.html +++ b/app/partials/mobile/message_attach_document.html @@ -2,7 +2,7 @@
-
+