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

25
app/js/directives.js

@ -429,6 +429,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -429,6 +429,7 @@ angular.module('myApp.directives', ['myApp.filters'])
};
$('body').on('dragenter dragleave dragover drop', onDragDropEvent);
$(document).on('paste', onPasteEvent);
scope.$on('ui_peer_change', focusField);
scope.$on('ui_history_focus', focusField);
@ -440,6 +441,7 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -440,6 +441,7 @@ angular.module('myApp.directives', ['myApp.filters'])
scope.$on('$destroy', function cleanup() {
$('body').off('dragenter dragleave dragover drop', onDragDropEvent);
$(document).off('paste', onPasteEvent);
});
focusField();
@ -450,6 +452,26 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -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) {
var dragStateChanged = false;
if (!dragStarted || dragStarted == 1) {
@ -696,7 +718,8 @@ angular.module('myApp.directives', ['myApp.filters']) @@ -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) {
scope.progress.enabled = false;
// scope.progress = {enabled: true, percent: 50};
scope.player.quicktime = hasQt;
scope.player.hasQuicktime = hasQt;
scope.player.quicktime = false;
scope.player.src = $sce.trustAsResourceUrl(url);
}, function (e) {
console.log('Download video failed', e, scope.video);

49
app/js/services.js

@ -134,6 +134,7 @@ angular.module('myApp.services', []) @@ -134,6 +134,7 @@ angular.module('myApp.services', [])
var users = {},
cachedPhotoLocations = {},
contactsFillPromise,
contactsList,
contactsIndex = SearchIndexManager.createIndex();
function fillContacts () {
@ -143,8 +144,8 @@ angular.module('myApp.services', []) @@ -143,8 +144,8 @@ angular.module('myApp.services', [])
return contactsFillPromise = MtpApiManager.invokeApi('contacts.getContacts', {
hash: ''
}).then(function (result) {
var contactsList = [],
userID, searchText, i;
var userID, searchText, i;
contactsList = [];
saveApiUsers(result.users);
for (var i = 0; i < result.contacts.length; i++) {
@ -323,6 +324,24 @@ angular.module('myApp.services', []) @@ -323,6 +324,24 @@ angular.module('myApp.services', [])
$rootScope.$broadcast('user_update', userID);
}
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', []) @@ -1072,18 +1091,27 @@ angular.module('myApp.services', [])
randomIDS = bigint(randomID[0]).shiftLeft(32).add(bigint(randomID[1])).toString(),
historyStorage = historiesStorage[peerID],
inputPeer = AppPeersManager.getInputPeerByID(peerID),
attachType;
attachType, fileName, fileName;
if (!options.isMedia) {
attachType = 'doc';
fileName = 'doc.' + file.type.split('/')[1];
} else if (['image/jpeg', 'image/gif', 'image/png', 'image/bmp'].indexOf(file.type) >= 0) {
attachType = 'photo';
fileName = 'photo.' + file.type.split('/')[1];
} else if (file.type.substr(0, 6) == 'video/') {
attachType = 'video';
fileName = 'video.mp4';
} else if (file.type == 'audio/mpeg' || file.type == 'audio/mp3') {
attachType = 'audio';
fileName = 'audio.mp3';
} else {
attachType = 'doc';
fileName = 'doc.' + file.type.split('/')[1];
}
if (!file.name) {
file.name = fileName;
}
if (historyStorage === undefined) {
@ -1113,6 +1141,21 @@ angular.module('myApp.services', []) @@ -1113,6 +1141,21 @@ angular.module('myApp.services', [])
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 () {
MtpApiFileManager.uploadFile(file).then(function (inputFile) {
var inputMedia;

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

@ -315,6 +315,16 @@ @@ -315,6 +315,16 @@
Following code was modified by Igor Zhukov, in order to improve rich text paste
*/
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'),
self = this;
setTimeout(function () {

Loading…
Cancel
Save