Browse Source

#74 #100 #134

Paste from clipboard in Chrome (poor Firefox support)
Sync new contacts from API update
HTML 5 player is default again
master
Igor Zhukov 11 years ago
parent
commit
a89d2ad3b1
  1. 33
      app/css/app.css
  2. BIN
      app/img/icons/IconsetW.png
  3. BIN
      app/img/icons/IconsetW_1x.png
  4. 2
      app/js/controllers.js
  5. 25
      app/js/directives.js
  6. 49
      app/js/services.js
  7. 10
      app/vendor/jquery.emojiarea/jquery.emojiarea.js

33
app/css/app.css

@ -256,7 +256,7 @@ input[type="number"]::-webkit-inner-spin-button {
vertical-align: text-top; vertical-align: text-top;
background: url(../img/icons/IconsetW.png?1) -15px -419px no-repeat; background: url(../img/icons/IconsetW.png?1) -15px -419px no-repeat;
background-size: 42px 560px; background-size: 42px 620px;
opacity: 0.6; opacity: 0.6;
} }
.is_1x .icon-back { .is_1x .icon-back {
@ -511,7 +511,7 @@ input[type="number"]::-webkit-inner-spin-button {
font-size: 12px; font-size: 12px;
line-height: normal; line-height: normal;
background: #F2F2F2 url(../img/icons/IconsetW.png?1) -6px -205px no-repeat; background: #F2F2F2 url(../img/icons/IconsetW.png?1) -6px -205px no-repeat;
background-size: 42px 560px; background-size: 42px 620px;
border: 1px solid #F2F2F2; border: 1px solid #F2F2F2;
border-radius: 3px; border-radius: 3px;
padding: 6px 20px 6px 30px; padding: 6px 20px 6px 30px;
@ -535,7 +535,7 @@ input[type="number"]::-webkit-inner-spin-button {
height: 13px; height: 13px;
vertical-align: text-top; vertical-align: text-top;
background: url(../img/icons/IconsetW.png?1) -15px -192px no-repeat; background: url(../img/icons/IconsetW.png?1) -15px -192px no-repeat;
background-size: 42px 560px; background-size: 42px 620px;
opacity: 0.6; opacity: 0.6;
} }
.is_1x .im_dialogs_search_clear { .is_1x .im_dialogs_search_clear {
@ -788,7 +788,7 @@ a.im_dialog:hover .im_dialog_date {
margin-left: 6px; margin-left: 6px;
background: url(../img/icons/IconsetW.png?1) -17px -444px no-repeat; background: url(../img/icons/IconsetW.png?1) -17px -444px no-repeat;
background-size: 42px 560px; background-size: 42px 620px;
} }
.is_1x .icon-caret { .is_1x .icon-caret {
background-image: url(../img/icons/IconsetW_1x.png?2); background-image: url(../img/icons/IconsetW_1x.png?2);
@ -987,7 +987,7 @@ div.im_message_video_thumb {
height: 19px; height: 19px;
background: url(../img/icons/IconsetW.png?1) -14px -389px no-repeat; background: url(../img/icons/IconsetW.png?1) -14px -389px no-repeat;
background-size: 42px 560px; background-size: 42px 620px;
} }
.is_1x .icon-geo-point { .is_1x .icon-geo-point {
background-image: url(../img/icons/IconsetW_1x.png?2); background-image: url(../img/icons/IconsetW_1x.png?2);
@ -1015,7 +1015,7 @@ div.im_message_video_thumb {
vertical-align: text-top; vertical-align: text-top;
background: #F2F2F2 url(../img/icons/IconsetW.png?1) -2px -229px no-repeat; background: #F2F2F2 url(../img/icons/IconsetW.png?1) -2px -229px no-repeat;
background-size: 42px 560px; background-size: 42px 620px;
border-radius: 3px; border-radius: 3px;
margin-right: 10px; margin-right: 10px;
} }
@ -1032,6 +1032,7 @@ div.im_message_video_thumb {
.im_history_selectable .im_message_outer_wrap:hover .icon-photo, .im_history_selectable .im_message_outer_wrap:hover .icon-photo,
.im_history_selectable .im_message_outer_wrap:hover .icon-video { .im_history_selectable .im_message_outer_wrap:hover .icon-video {
background-color: #dae6f0; background-color: #dae6f0;
background-position: -2px -542px;
} }
.im_message_document_info { .im_message_document_info {
@ -1076,7 +1077,7 @@ div.im_message_video_thumb {
vertical-align: text-top; vertical-align: text-top;
background: #F2F2F2 url(../img/icons/IconsetW.png?1) -2px -277px no-repeat; background: #F2F2F2 url(../img/icons/IconsetW.png?1) -2px -277px no-repeat;
background-size: 42px 560px; background-size: 42px 620px;
border-radius: 3px; border-radius: 3px;
margin-right: 10px; margin-right: 10px;
} }
@ -1335,7 +1336,7 @@ textarea.im_message_field {
height: 23px; height: 23px;
vertical-align: text-top; vertical-align: text-top;
background: url(../img/icons/IconsetW.png?1) -12px -68px no-repeat; background: url(../img/icons/IconsetW.png?1) -12px -68px no-repeat;
background-size: 42px 560px; background-size: 42px 620px;
opacity: 0.8; opacity: 0.8;
} }
.is_1x .icon-paperclip { .is_1x .icon-paperclip {
@ -1363,7 +1364,7 @@ textarea.im_message_field {
height: 23px; height: 23px;
vertical-align: text-top; vertical-align: text-top;
background: url(../img/icons/IconsetW.png?1) -10px -4px no-repeat; background: url(../img/icons/IconsetW.png?1) -10px -4px no-repeat;
background-size: 42px 560px; background-size: 42px 620px;
opacity: 0.8; opacity: 0.8;
} }
.is_1x .icon-emoji { .is_1x .icon-emoji {
@ -1413,7 +1414,7 @@ textarea.im_message_field {
height: 21px; height: 21px;
vertical-align: text-top; vertical-align: text-top;
background: url(../img/icons/IconsetW.png?1) -9px -132px no-repeat; background: url(../img/icons/IconsetW.png?1) -9px -132px no-repeat;
background-size: 42px 560px; background-size: 42px 620px;
opacity: 0.8; opacity: 0.8;
} }
.is_1x .icon-camera { .is_1x .icon-camera {
@ -1833,7 +1834,7 @@ img.img_fullsize {
.emoji-menu-tail { .emoji-menu-tail {
display: none; display: none;
background: url(../img/icons/IconsetW.png?1) -14px -268px no-repeat; background: url(../img/icons/IconsetW.png?1) -14px -268px no-repeat;
background-size: 42px 560px; background-size: 42px 620px;
width: 14px; width: 14px;
height: 7px; height: 7px;
margin: 0 83px; margin: 0 83px;
@ -1984,7 +1985,7 @@ img.img_fullsize {
font-size: 12px; font-size: 12px;
line-height: normal; line-height: normal;
background: #F2F2F2 url(../img/icons/IconsetW.png?1) -6px -205px no-repeat; background: #F2F2F2 url(../img/icons/IconsetW.png?1) -6px -205px no-repeat;
background-size: 42px 560px; background-size: 42px 620px;
border: 1px solid #F2F2F2; border: 1px solid #F2F2F2;
border-radius: 3px; border-radius: 3px;
padding: 6px 20px 6px 30px; padding: 6px 20px 6px 30px;
@ -2008,7 +2009,7 @@ img.img_fullsize {
height: 13px; height: 13px;
vertical-align: text-top; vertical-align: text-top;
background: url(../img/icons/IconsetW.png?1) -15px -192px no-repeat; background: url(../img/icons/IconsetW.png?1) -15px -192px no-repeat;
background-size: 42px 560px; background-size: 42px 620px;
opacity: 0.6; opacity: 0.6;
} }
.is_1x .contacts_modal_search_clear { .is_1x .contacts_modal_search_clear {
@ -2085,7 +2086,7 @@ a.contacts_modal_contact:hover .contacts_modal_contact_status {
width: 17px; width: 17px;
height: 15px; height: 15px;
background: url(../img/icons/IconsetW.png?1) -13px -366px no-repeat; background: url(../img/icons/IconsetW.png?1) -13px -366px no-repeat;
background-size: 42px 560px; background-size: 42px 620px;
opacity: 0.5; opacity: 0.5;
} }
.is_1x .icon-contact-tick { .is_1x .icon-contact-tick {
@ -2183,7 +2184,7 @@ a.contacts_modal_contact:hover .contacts_modal_contact_status {
height: 15px; height: 15px;
background: url(../img/icons/IconsetW.png?1) -15px -319px no-repeat; background: url(../img/icons/IconsetW.png?1) -15px -319px no-repeat;
background-size: 42px 560px; background-size: 42px 620px;
} }
.is_1x .icon-delete { .is_1x .icon-delete {
background-image: url(../img/icons/IconsetW_1x.png?2); background-image: url(../img/icons/IconsetW_1x.png?2);
@ -2230,7 +2231,7 @@ a.contacts_modal_contact:hover .contacts_modal_contact_status {
height: 26px; height: 26px;
margin: 13px 0 0 40px; margin: 13px 0 0 40px;
background: url(../img/icons/IconsetW.png?1) -9px -516px no-repeat; background: url(../img/icons/IconsetW.png?1) -9px -516px no-repeat;
background-size: 42px 560px; background-size: 42px 620px;
} }
.is_1x .icon-select-tick { .is_1x .icon-select-tick {
background-image: url(../img/icons/IconsetW_1x.png?2); background-image: url(../img/icons/IconsetW_1x.png?2);

BIN
app/img/icons/IconsetW.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

BIN
app/img/icons/IconsetW_1x.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

2
app/js/controllers.js

@ -728,7 +728,7 @@ angular.module('myApp.controllers', [])
// console.trace('ctrl text changed', newVal); // console.trace('ctrl text changed', newVal);
AppMessagesManager.readHistory($scope.curDialog.inputPeer); AppMessagesManager.readHistory($scope.curDialog.inputPeer);
if (newVal.length) { if (newVal && newVal.length) {
var backupDraftObj = {}; var backupDraftObj = {};
backupDraftObj['draft' + $scope.curDialog.peerID] = newVal; backupDraftObj['draft' + $scope.curDialog.peerID] = newVal;
AppConfigManager.set(backupDraftObj); AppConfigManager.set(backupDraftObj);

25
app/js/directives.js

@ -429,6 +429,7 @@ angular.module('myApp.directives', ['myApp.filters'])
}; };
$('body').on('dragenter dragleave dragover drop', onDragDropEvent); $('body').on('dragenter dragleave dragover drop', onDragDropEvent);
$(document).on('paste', onPasteEvent);
scope.$on('ui_peer_change', focusField); scope.$on('ui_peer_change', focusField);
scope.$on('ui_history_focus', focusField); scope.$on('ui_history_focus', focusField);
@ -440,6 +441,7 @@ angular.module('myApp.directives', ['myApp.filters'])
scope.$on('$destroy', function cleanup() { scope.$on('$destroy', function cleanup() {
$('body').off('dragenter dragleave dragover drop', onDragDropEvent); $('body').off('dragenter dragleave dragover drop', onDragDropEvent);
$(document).off('paste', onPasteEvent);
}); });
focusField(); focusField();
@ -450,6 +452,26 @@ angular.module('myApp.directives', ['myApp.filters'])
}); });
} }
function onPasteEvent (e) {
var cData = (e.originalEvent || e).clipboardData,
items = cData && cData.items || [],
files = [],
i;
for (i = 0; i < items.length; i++) {
if (items[i].kind == 'file') {
files.push(items[i].getAsFile());
}
}
if (files.length && safeConfirm('Are you sure to send file(s) from clipboard?')) {
scope.$apply(function () {
scope.draftMessage.files = files;
scope.draftMessage.isMedia = true;
});
}
}
function onDragDropEvent(e) { function onDragDropEvent(e) {
var dragStateChanged = false; var dragStateChanged = false;
if (!dragStarted || dragStarted == 1) { if (!dragStarted || dragStarted == 1) {
@ -696,7 +718,8 @@ angular.module('myApp.directives', ['myApp.filters'])
MtpApiFileManager.downloadFile(scope.video.dc_id, inputLocation, scope.video.size, null, {mime: 'video/mp4'}).then(function (url) { MtpApiFileManager.downloadFile(scope.video.dc_id, inputLocation, scope.video.size, null, {mime: 'video/mp4'}).then(function (url) {
scope.progress.enabled = false; scope.progress.enabled = false;
// scope.progress = {enabled: true, percent: 50}; // scope.progress = {enabled: true, percent: 50};
scope.player.quicktime = hasQt; scope.player.hasQuicktime = hasQt;
scope.player.quicktime = false;
scope.player.src = $sce.trustAsResourceUrl(url); scope.player.src = $sce.trustAsResourceUrl(url);
}, function (e) { }, function (e) {
console.log('Download video failed', e, scope.video); console.log('Download video failed', e, scope.video);

49
app/js/services.js

@ -134,6 +134,7 @@ angular.module('myApp.services', [])
var users = {}, var users = {},
cachedPhotoLocations = {}, cachedPhotoLocations = {},
contactsFillPromise, contactsFillPromise,
contactsList,
contactsIndex = SearchIndexManager.createIndex(); contactsIndex = SearchIndexManager.createIndex();
function fillContacts () { function fillContacts () {
@ -143,8 +144,8 @@ angular.module('myApp.services', [])
return contactsFillPromise = MtpApiManager.invokeApi('contacts.getContacts', { return contactsFillPromise = MtpApiManager.invokeApi('contacts.getContacts', {
hash: '' hash: ''
}).then(function (result) { }).then(function (result) {
var contactsList = [], var userID, searchText, i;
userID, searchText, i; contactsList = [];
saveApiUsers(result.users); saveApiUsers(result.users);
for (var i = 0; i < result.contacts.length; i++) { for (var i = 0; i < result.contacts.length; i++) {
@ -323,6 +324,24 @@ angular.module('myApp.services', [])
$rootScope.$broadcast('user_update', userID); $rootScope.$broadcast('user_update', userID);
} }
break; break;
case 'updateContactLink':
if (angular.isArray(contactsList)) {
var userID = update.user_id,
curPos = curIsContact = contactsList.indexOf(userID),
curIsContact = curPos != -1,
newIsContact = update.my_link._ == 'contacts.myLinkContact';
if (newIsContact != curIsContact) {
if (newIsContact) {
contactsList.push(userID);
SearchIndexManager.indexObject(userID, getUserSearchText(userID), contactsIndex);
} else {
contactsList.splice(curPos, 1);
}
}
}
break;
} }
}); });
@ -1072,18 +1091,27 @@ angular.module('myApp.services', [])
randomIDS = bigint(randomID[0]).shiftLeft(32).add(bigint(randomID[1])).toString(), randomIDS = bigint(randomID[0]).shiftLeft(32).add(bigint(randomID[1])).toString(),
historyStorage = historiesStorage[peerID], historyStorage = historiesStorage[peerID],
inputPeer = AppPeersManager.getInputPeerByID(peerID), inputPeer = AppPeersManager.getInputPeerByID(peerID),
attachType; attachType, fileName, fileName;
if (!options.isMedia) { if (!options.isMedia) {
attachType = 'doc'; attachType = 'doc';
fileName = 'doc.' + file.type.split('/')[1];
} else if (['image/jpeg', 'image/gif', 'image/png', 'image/bmp'].indexOf(file.type) >= 0) { } else if (['image/jpeg', 'image/gif', 'image/png', 'image/bmp'].indexOf(file.type) >= 0) {
attachType = 'photo'; attachType = 'photo';
fileName = 'photo.' + file.type.split('/')[1];
} else if (file.type.substr(0, 6) == 'video/') { } else if (file.type.substr(0, 6) == 'video/') {
attachType = 'video'; attachType = 'video';
fileName = 'video.mp4';
} else if (file.type == 'audio/mpeg' || file.type == 'audio/mp3') { } else if (file.type == 'audio/mpeg' || file.type == 'audio/mp3') {
attachType = 'audio'; attachType = 'audio';
fileName = 'audio.mp3';
} else { } else {
attachType = 'doc'; attachType = 'doc';
fileName = 'doc.' + file.type.split('/')[1];
}
if (!file.name) {
file.name = fileName;
} }
if (historyStorage === undefined) { if (historyStorage === undefined) {
@ -1113,6 +1141,21 @@ angular.module('myApp.services', [])
pending: true pending: true
}; };
var toggleError = function (on) {
var historyMessage = messagesForHistory[messageID];
if (on) {
message.error = true;
if (historyMessage) {
historyMessage.error = true;
}
} else {
delete message.error;
if (historyMessage) {
delete historyMessage.error;
}
}
}
message.send = function () { message.send = function () {
MtpApiFileManager.uploadFile(file).then(function (inputFile) { MtpApiFileManager.uploadFile(file).then(function (inputFile) {
var inputMedia; var inputMedia;

10
app/vendor/jquery.emojiarea/jquery.emojiarea.js vendored

@ -315,6 +315,16 @@
Following code was modified by Igor Zhukov, in order to improve rich text paste Following code was modified by Igor Zhukov, in order to improve rich text paste
*/ */
EmojiArea_WYSIWYG.prototype.onPaste = function(e) { EmojiArea_WYSIWYG.prototype.onPaste = function(e) {
var cData = (e.originalEvent || e).clipboardData,
items = cData && cData.items || [],
i;
for (i = 0; i < items.length; i++) {
if (items[i].kind == 'file') {
e.preventDefault();
return true;
}
}
var text = (e.originalEvent || e).clipboardData.getData('text/plain'), var text = (e.originalEvent || e).clipboardData.getData('text/plain'),
self = this; self = this;
setTimeout(function () { setTimeout(function () {

Loading…
Cancel
Save