From 051f5d6e3cc61a7fe6d856bca6bb69c482fcaacf Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Sun, 30 Mar 2014 00:56:10 +0400 Subject: [PATCH] Improved templates, thumb dir --- app/css/app.css | 8 ++-- app/js/controllers.js | 3 +- app/js/directives.js | 25 +++++++++-- app/js/services.js | 26 ++++++++--- app/partials/message.html | 95 +++++++++++---------------------------- 5 files changed, 74 insertions(+), 83 deletions(-) diff --git a/app/css/app.css b/app/css/app.css index 36c9eead..f183c6f2 100644 --- a/app/css/app.css +++ b/app/css/app.css @@ -991,13 +991,13 @@ a.im_message_from_photo, a.im_message_contact_photo { margin: 1px 12px 0 0; } -.im_message_contact_name { - color: #3C6E97; - font-weight: bold; -} .non_osx .im_message_contact_name { font-size: 12px; } +.im_message_contact_name { + font-weight: bold; + /*color: #3C6E97;*/ +} a.im_message_photo_thumb, a.im_message_video_thumb { display: block; diff --git a/app/js/controllers.js b/app/js/controllers.js index a4f1d455..207ac177 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -936,7 +936,8 @@ angular.module('myApp.controllers', []) _: 'inputMediaContact', phone_number: $scope.user.phone, first_name: $scope.user.first_name, - last_name: $scope.user.last_name + last_name: $scope.user.last_name, + user_id: $scope.user.id }); $rootScope.$broadcast('history_focus', {peerString: peerString}); }) diff --git a/app/js/directives.js b/app/js/directives.js index 63ec8549..a83999f4 100644 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -622,18 +622,28 @@ angular.module('myApp.directives', ['myApp.filters']) if (cachedSrc) { element.attr('src', cachedSrc); } + if ($scope.thumb && $scope.thumb.width && $scope.thumb.height) { + element.attr('width', $scope.thumb.width); + element.attr('height', $scope.thumb.height); + } - $scope.$watchCollection('thumb.location', function (newLocation) { + var stopWatching = $scope.$watchCollection('thumb.location', function (newLocation) { + if ($scope.thumb && $scope.thumb.width && $scope.thumb.height) { + element.attr('width', $scope.thumb.width); + element.attr('height', $scope.thumb.height); + } // console.log('new loc', newLocation, arguments); var counterSaved = ++counter; if (!newLocation || newLocation.empty) { element.attr('src', $scope.thumb && $scope.thumb.placeholder || 'img/blank.gif'); + cleanup(); return; } var cachedSrc = MtpApiFileManager.getCachedFile(newLocation); if (cachedSrc) { element.attr('src', cachedSrc); + cleanup(); return; } @@ -644,15 +654,24 @@ angular.module('myApp.directives', ['myApp.filters']) MtpApiFileManager.downloadSmallFile($scope.thumb.location, $scope.thumb.size).then(function (url) { if (counterSaved == counter) { element.attr('src', url); + cleanup(); } }, function (e) { console.log('Download image failed', e, $scope.thumb.location); if (counterSaved == counter) { element.attr('src', $scope.thumb.placeholder || 'img/blank.gif'); + cleanup(); } }); }) + var cleanup = angular.noop; + // function () { + // setTimeout(function () { + // $scope.$destroy() + // stopWatching(); + // }, 0); + // }; } }) @@ -761,9 +780,7 @@ angular.module('myApp.directives', ['myApp.filters']) \ \
\ diff --git a/app/js/services.js b/app/js/services.js index 51328fde..285ae01f 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -1302,7 +1302,7 @@ angular.module('myApp.services', []) var media; switch (inputMedia._) { case 'inputMediaContact': - media = angular.extend({}, inputMedia, {_: 'messageMediaContact', user_id: 0}); + media = angular.extend({}, inputMedia, {_: 'messageMediaContact'}); break; } @@ -1519,6 +1519,13 @@ angular.module('myApp.services', []) case 'messageMediaAudio': message.media.audio = AppAudioManager.wrapForHistory(message.media.audio.id); break; + + case 'messageMediaContact': + message.media.rFullName = RichTextProcessor.wrapRichText( + message.media.first_name + ' ' + (message.media.last_name || ''), + {noLinks: true, noLinebreaks: true} + ); + break; } if (message.media.user_id) { @@ -1527,11 +1534,15 @@ angular.module('myApp.services', []) } } else if (message.action) { - if (message.action._ == 'messageActionChatEditPhoto') { - message.action.photo = AppPhotosManager.wrapForHistory(message.action.photo.id); - } - if (message.action._ == 'messageActionChatEditTitle') { - message.action.rTitle = RichTextProcessor.wrapRichText(message.action.title, {noLinks: true, noLinebreaks: true}) || 'DELETED'; + switch (message.action._) { + case 'messageActionChatEditPhoto': + message.action.photo = AppPhotosManager.wrapForHistory(message.action.photo.id); + break; + + case 'messageActionChatCreate': + case 'messageActionChatEditTitle': + message.action.rTitle = RichTextProcessor.wrapRichText(message.action.title, {noLinks: true, noLinebreaks: true}) || 'DELETED'; + break; } if (message.action.user_id) { @@ -2048,6 +2059,9 @@ angular.module('myApp.services', []) // console.log(222, video.w, video.h, full.width, full.height); video.full = full; + video.fullThumb = angular.copy(video.thumb); + video.fullThumb.width = full.width; + video.fullThumb.height = full.height; video.fromUser = AppUsersManager.getUser(video.user_id); return video; diff --git a/app/partials/message.html b/app/partials/message.html index 98d17429..c7499740 100644 --- a/app/partials/message.html +++ b/app/partials/message.html @@ -16,7 +16,7 @@ - created the group «{{historyMessage.action.title}}» + created the group «» changed group name to «» @@ -44,9 +44,7 @@ - - unsupported action {{historyMessage.action}} - +
@@ -56,8 +54,6 @@ class="im_service_message_photo_thumb" my-load-thumb thumb="historyMessage.action.photo.thumb" - width="{{historyMessage.action.photo.thumb.width}}" - height="{{historyMessage.action.photo.thumb.height}}" /> @@ -87,47 +83,39 @@
- +
- Forwarded message from , {{historyMessage.fwd_date | dateOrTime}} + Forwarded message from ,
- +
- - {{historyMessage.media.video.duration | duration}} + +
Video - - {{historyMessage.media.video.size | formatSize}} - - - {{historyMessage.media.video.progress | formatSizeProgress}} - + +
Download @@ -153,23 +141,15 @@ class="im_message_document_thumb" my-load-thumb thumb="historyMessage.media.document.thumb" - width="{{historyMessage.media.document.thumb.width}}" - height="{{historyMessage.media.document.thumb.height}}" />
- - {{historyMessage.media.document.file_name}} - - - {{historyMessage.media.document.size | formatSize}} - - - {{historyMessage.media.document.progress | formatSizeProgress}} - + + +
Download @@ -177,11 +157,7 @@
-
- - {{historyMessage.media.document.progress.percent}}% Complete (success) - -
+
@@ -199,29 +175,21 @@ Voice message - - {{historyMessage.media.audio.duration | duration}} - - - {{historyMessage.media.audio.progress | formatSizeProgress}} - + +
-
- - {{historyMessage.media.audio.progress.percent}}% Complete (success) - -
+
@@ -239,32 +207,23 @@ thumb="historyMessage.media.userPhoto" /> -
- {{historyMessage.media.first_name}} {{historyMessage.media.last_name}} -
-
- {{historyMessage.media.phone_number}} +
+ +
+
-
- +
+
- - {{historyMessage.media.file_name}} - - - {{historyMessage.media.progress | formatSizeProgress}} - + +
-
- - {{historyMessage.media.progress.percent}}% Complete (success) - -
+