Browse Source

merged with master

gh-pages
Igor Zhukov 11 years ago
parent
commit
166b48e767
  1. 3
      css/app.css
  2. 2
      js/controllers.js
  3. 31
      js/directives.js
  4. 2
      js/services.js

3
css/app.css

@ -897,7 +897,8 @@ a.im_dialog:hover .im_dialog_date {
}*/
.im_message_unread_split {
background: #E9EBED;
background: #f4f4f4;
color: #777;
text-align: center;
padding: 4px 10px;
margin: 10px 0;

2
js/controllers.js

@ -598,7 +598,9 @@ angular.module('myApp.controllers', [])
$scope.history.push(AppMessagesManager.wrapForHistory(addedMessage.messageID));
$scope.typing = {};
$scope.$broadcast('ui_history_append', {my: addedMessage.my});
if (addedMessage.my) {
$scope.historyUnread = {};
}
offset++;

31
js/directives.js

@ -438,6 +438,9 @@ angular.module('myApp.directives', ['myApp.filters'])
$('body').on('dragenter dragleave dragover drop', onDragDropEvent);
$(document).on('paste', onPasteEvent);
if (richTextarea) {
$(richTextarea).on('DOMNodeInserted', onPastedImageEvent);
}
scope.$on('ui_peer_change', focusField);
scope.$on('ui_history_focus', focusField);
@ -450,6 +453,9 @@ angular.module('myApp.directives', ['myApp.filters'])
scope.$on('$destroy', function cleanup() {
$('body').off('dragenter dragleave dragover drop', onDragDropEvent);
$(document).off('paste', onPasteEvent);
if (richTextarea) {
$(richTextarea).off('DOMNodeInserted', onPastedImageEvent);
}
});
focusField();
@ -460,6 +466,31 @@ angular.module('myApp.directives', ['myApp.filters'])
});
}
function onPastedImageEvent (e) {
var element = e && e.target;
var src;
if (element && (src = element.src) && src.indexOf('data') === 0) {
element.parentNode.removeChild(element);
src = src.substr(5).split(';');
var contentType = src[0];
var base64 = atob(src[1].split(',')[1]);
var array = new Uint8Array(base64.length);
for (var i = 0; i < base64.length; i++) {
array[i] = base64.charCodeAt(i);
}
var blob = new Blob([array], {type: contentType});
if (safeConfirm('Are you sure to send file(s) from clipboard?')) {
scope.$apply(function () {
scope.draftMessage.files = [blob];
scope.draftMessage.isMedia = true;
});
}
}
};
function onPasteEvent (e) {
var cData = (e.originalEvent || e).clipboardData,
items = cData && cData.items || [],

2
js/services.js

@ -805,7 +805,7 @@ angular.module('myApp.services', [])
var unreadLimit = false;
if (!limit && !maxID) {
var foundDialog = getDialogByPeerID(peerID);
if (foundDialog && foundDialog[0] && foundDialog[0].unread_count > 0) {
if (foundDialog && foundDialog[0] && foundDialog[0].unread_count > 1) {
unreadLimit = foundDialog[0].unread_count;
limit = Math.max(20, unreadLimit + 2);
}

Loading…
Cancel
Save