Browse Source

Ui improvements

Fixes #177
First attempt on #296
Video modal bugfixes
master
Igor Zhukov 11 years ago
parent
commit
88b52b0405
  1. 25
      app/css/app.css
  2. 1
      app/js/app.js
  3. 12
      app/js/controllers.js
  4. 24
      app/js/directives.js
  5. 8
      app/js/lib/mtproto.js
  6. 2
      app/partials/message.html

25
app/css/app.css

@ -1298,23 +1298,27 @@ a.im_dialog:hover .im_dialog_date {
.non_osx .im_message_author { .non_osx .im_message_author {
font-size: 12px; font-size: 12px;
} }
.im_message_grouped .im_message_from_photo, .im_message_grouped1 .im_message_from_photo,
.im_message_grouped .im_message_author { .im_message_grouped1 .im_message_author,
.im_message_grouped2 .im_message_from_photo,
.im_message_grouped2 .im_message_author {
display: none; display: none;
} }
.im_message_grouped .im_message_body { .im_message_grouped1 .im_message_body,
.im_message_grouped2 .im_message_body {
margin-left: 46px; margin-left: 46px;
} }
.im_message_grouped .im_content_message_select_area { .im_message_grouped1 .im_content_message_select_area,
.im_message_grouped2 .im_content_message_select_area {
height: 34px; height: 34px;
} }
.im_history_appending .im_content_message_select_area { .im_history_appending .im_content_message_select_area {
height: 52px; height: 52px;
} }
.im_message_grouped .icon-select-tick { .im_message_grouped1 .icon-select-tick {
margin-top: 4px; margin-top: 4px;
} }
.im_message_grouped .icon-message-status { .im_message_grouped1 .icon-message-status {
margin-top: 5px; margin-top: 5px;
} }
@ -2916,13 +2920,6 @@ a.contacts_modal_contact:hover .contacts_modal_contact_status {
} }
} }
@media (min-height: 768px) {
.user_modal_window .modal-dialog {
margin-top: 150px;
}
}
@media (max-width: 480px) { @media (max-width: 480px) {
.login_form_wrap { .login_form_wrap {
border-radius: 0; border-radius: 0;
@ -2976,7 +2973,7 @@ a.contacts_modal_contact:hover .contacts_modal_contact_status {
} }
} }
@media (max-height: 480px) { @media (max-height: 600px) {
.im_page_footer { .im_page_footer {
display: none; display: none;
} }

1
app/js/app.js

@ -12,6 +12,7 @@ window._debugMode = location.search.indexOf('debug=1') > 0;
window._osX = (navigator.platform || '').toLowerCase().indexOf('mac') != -1 || window._osX = (navigator.platform || '').toLowerCase().indexOf('mac') != -1 ||
(navigator.userAgent || '').toLowerCase().indexOf('mac') != -1; (navigator.userAgent || '').toLowerCase().indexOf('mac') != -1;
window._retina = window.devicePixelRatio > 1; window._retina = window.devicePixelRatio > 1;
window._mobile = $(window).height() < 600;
if (!window._osX) { if (!window._osX) {
$('body').addClass('non_osx'); $('body').addClass('non_osx');

12
app/js/controllers.js

@ -545,14 +545,14 @@ angular.module('myApp.controllers', [])
curMessage = $scope.history[i]; curMessage = $scope.history[i];
if (prevMessage && if (prevMessage &&
curMessage.from_id == prevMessage.from_id && curMessage.from_id == prevMessage.from_id &&
curMessage.date < prevMessage.date + 300 && !prevMessage.fwd_from_id == !curMessage.fwd_from_id &&
!prevMessage.action && !prevMessage.action &&
!curMessage.action && !curMessage.action &&
!prevMessage.fwd_from_id && curMessage.date < prevMessage.date + 900) {
!curMessage.fwd_from_id &&
curMessage.message && curMessage.message.length < 60) {
curMessage.grouped = true;
var singleLine = curMessage.message && curMessage.message.length < 70 && curMessage.message.indexOf("\n") == -1;
curMessage.grouped = !curMessage.fwd_from_id && singleLine ? 1 : 2;
} else if (prevMessage || !i) { } else if (prevMessage || !i) {
delete curMessage.grouped; delete curMessage.grouped;
} }
@ -583,7 +583,7 @@ angular.module('myApp.controllers', [])
$scope.history.unshift(AppMessagesManager.wrapForHistory(id)); $scope.history.unshift(AppMessagesManager.wrapForHistory(id));
}); });
updateHistoryGroups(historyResult.history.length); updateHistoryGroups(historyResult.history.length + 1);
$scope.$broadcast('ui_history_prepend'); $scope.$broadcast('ui_history_prepend');
}); });

24
app/js/directives.js

@ -540,10 +540,14 @@ angular.module('myApp.directives', ['myApp.filters'])
$(richTextarea).on('DOMNodeInserted', onPastedImageEvent); $(richTextarea).on('DOMNodeInserted', onPastedImageEvent);
} }
$scope.$on('ui_peer_change', focusField); if (!window._mobile) {
$scope.$on('ui_history_focus', focusField); $scope.$on('ui_peer_change', focusField);
$scope.$on('ui_history_change', focusField); $scope.$on('ui_history_focus', focusField);
$scope.$on('ui_history_change', focusField);
}
$scope.$on('ui_message_send', focusField); $scope.$on('ui_message_send', focusField);
$scope.$on('ui_peer_draft', updateField); $scope.$on('ui_peer_draft', updateField);
$scope.$on('ui_message_before_send', updateValue); $scope.$on('ui_message_before_send', updateValue);
@ -556,7 +560,9 @@ angular.module('myApp.directives', ['myApp.filters'])
} }
}); });
focusField(); if (!window._mobile) {
focusField();
}
function focusField () { function focusField () {
onContentLoaded(function () { onContentLoaded(function () {
@ -679,6 +685,7 @@ angular.module('myApp.directives', ['myApp.filters'])
if ($scope.thumb && $scope.thumb.width && $scope.thumb.height) { if ($scope.thumb && $scope.thumb.width && $scope.thumb.height) {
element.attr('width', $scope.thumb.width); element.attr('width', $scope.thumb.width);
element.attr('height', $scope.thumb.height); element.attr('height', $scope.thumb.height);
$scope.$emit('ui_height');
} }
// console.log('new loc', newLocation, arguments); // console.log('new loc', newLocation, arguments);
var counterSaved = ++counter; var counterSaved = ++counter;
@ -842,6 +849,7 @@ angular.module('myApp.directives', ['myApp.filters'])
$scope.player.hasQuicktime = hasQt; $scope.player.hasQuicktime = hasQt;
$scope.player.quicktime = false; $scope.player.quicktime = false;
$scope.player.src = $sce.trustAsResourceUrl(url); $scope.player.src = $sce.trustAsResourceUrl(url);
$scope.$emit('ui_height');
}, function (e) { }, function (e) {
console.log('Download video failed', e, $scope.video); console.log('Download video failed', e, $scope.video);
$scope.progress.enabled = false; $scope.progress.enabled = false;
@ -857,6 +865,8 @@ angular.module('myApp.directives', ['myApp.filters'])
$scope.progress.percent = Math.max(1, Math.floor(100 * progress.done / progress.total)); $scope.progress.percent = Math.max(1, Math.floor(100 * progress.done / progress.total));
}); });
$scope.$emit('ui_height');
$scope.$on('$destroy', function () { $scope.$on('$destroy', function () {
downloadPromise.cancel(); downloadPromise.cancel();
}); });
@ -1010,6 +1020,9 @@ angular.module('myApp.directives', ['myApp.filters'])
.directive('myFocused', function(){ .directive('myFocused', function(){
return { return {
link: function($scope, element, attrs) { link: function($scope, element, attrs) {
if (window._mobile) {
return false;
}
setTimeout(function () { setTimeout(function () {
element[0].focus(); element[0].focus();
}, 100); }, 100);
@ -1021,6 +1034,9 @@ angular.module('myApp.directives', ['myApp.filters'])
return { return {
link: function($scope, element, attrs) { link: function($scope, element, attrs) {
$scope.$on(attrs.myFocusOn, function () { $scope.$on(attrs.myFocusOn, function () {
if (window._mobile) {
return false;
}
onContentLoaded(function () { onContentLoaded(function () {
element[0].focus(); element[0].focus();
}); });

8
app/js/lib/mtproto.js

@ -2849,8 +2849,8 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
fileWriteBytes(fileWriter, fromFileEntry).then(function () { fileWriteBytes(fileWriter, fromFileEntry).then(function () {
deferred.resolve(fileWriter); deferred.resolve(fileWriter);
}, function (e) { }, function (e) {
fileWriter.truncate(0);
deferred.reject(e); deferred.reject(e);
fileWriter.truncate(0);
}); });
}, function (e) { }, function (e) {
deferred.reject(e); deferred.reject(e);
@ -2903,8 +2903,8 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
cacheFileWriter, cacheFileWriter,
errorHandler = function (error) { errorHandler = function (error) {
deferred.reject(error); deferred.reject(error);
if (cacheFileWriter) cacheFileWriter.truncate(0);
errorHandler = angular.noop; errorHandler = angular.noop;
if (cacheFileWriter) cacheFileWriter.truncate(0);
}; };
requestFS().then(function () { requestFS().then(function () {
@ -2940,8 +2940,8 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
cacheFileWriter, cacheFileWriter,
errorHandler = function (error) { errorHandler = function (error) {
deferred.reject(error); deferred.reject(error);
if (cacheFileWriter) cacheFileWriter.truncate(0);
errorHandler = angular.noop; errorHandler = angular.noop;
if (cacheFileWriter) cacheFileWriter.truncate(0);
}, },
doDownload = function () { doDownload = function () {
cachedFs.root.getFile(fileName, {create: true}, function(fileEntry) { cachedFs.root.getFile(fileName, {create: true}, function(fileEntry) {
@ -3019,8 +3019,8 @@ factory('MtpApiFileManager', function (MtpApiManager, $q, $window) {
errorHandler = function (error) { errorHandler = function (error) {
// console.error('Dl Error', error); // console.error('Dl Error', error);
deferred.reject(error); deferred.reject(error);
if (cacheFileWriter) cacheFileWriter.truncate(0);
errorHandler = angular.noop; errorHandler = angular.noop;
if (cacheFileWriter) cacheFileWriter.truncate(0);
}, },
saveToFileEntry = function (fileEntry) { saveToFileEntry = function (fileEntry) {
fileEntry.createWriter(function (fileWriter) { fileEntry.createWriter(function (fileWriter) {

2
app/partials/message.html

@ -4,7 +4,7 @@
</ng-pluralize> </ng-pluralize>
</div> </div>
<div class="im_message_outer_wrap" ng-class="{im_message_selected: selectedMsgs[historyMessage.id], im_message_grouped: historyMessage.grouped}" ng-click="toggleMessage(historyMessage.id, $event)"> <div class="im_message_outer_wrap" ng-class="[ selectedMsgs[historyMessage.id] &amp;&amp; 'im_message_selected', historyMessage.grouped &amp;&amp; ('im_message_grouped' + historyMessage.grouped) ]" ng-click="toggleMessage(historyMessage.id, $event)">
<div class="im_message_wrap clearfix" bindonce> <div class="im_message_wrap clearfix" bindonce>

Loading…
Cancel
Save