@ -6,6 +6,7 @@
* /
* /
'use strict'
'use strict'
/* global Config, templateUrl, onContentLoaded, cancelEvent, dT, setZeroTimeout calcImageInBox, getSelectedText,Scroller, setFieldSelection, scrollToNode, EmojiTooltip, EmojiPanel, MessageComposer, checkDragEvent, checkClick, Image, Clipboard, EmojiHelper, encodeEntities, FB, twttr, gapi, isInDOM */
/* Directives */
/* Directives */
@ -43,13 +44,13 @@ angular.module('myApp.directives', ['myApp.filters'])
. directive ( 'myMessage' , function ( $filter , _ ) {
. directive ( 'myMessage' , function ( $filter , _ ) {
var dateFilter = $filter ( 'myDate' )
var dateFilter = $filter ( 'myDate' )
var dateSplitHtml = '<div class="im_message_date_split im_service_message_wrap"><div class="im_service_message"><span class="copyonly"><br/>--- </span><span class="im_message_date_split_text"></span><span class="copyonly"> ---</span></div></div>' ,
var dateSplitHtml = '<div class="im_message_date_split im_service_message_wrap"><div class="im_service_message"><span class="copyonly"><br/>--- </span><span class="im_message_date_split_text"></span><span class="copyonly"> ---</span></div></div>'
unreadSplitHtml = '<div class="im_message_unread_split">' + _ ( 'unread_messages_split' ) + '</div>' ,
var unreadSplitHtml = '<div class="im_message_unread_split">' + _ ( 'unread_messages_split' ) + '</div>'
selectedClass = 'im_message_selected' ,
var selectedClass = 'im_message_selected'
focusClass = 'im_message_focus' ,
var focusClass = 'im_message_focus'
unreadClass = 'im_message_unread' ,
var unreadClass = 'im_message_unread'
errorClass = 'im_message_error' ,
var errorClass = 'im_message_error'
pendingClass = 'im_message_pending'
var pendingClass = 'im_message_pending'
return {
return {
templateUrl : templateUrl ( 'message' ) ,
templateUrl : templateUrl ( 'message' ) ,
@ -69,9 +70,9 @@ angular.module('myApp.directives', ['myApp.filters'])
selected = ! selected
selected = ! selected
element . toggleClass ( selectedClass , selected )
element . toggleClass ( selectedClass , selected )
}
}
} ,
}
needDateSplit ,
var needDateSplit , unreadAfterSplit
applyGrouped = function ( ) {
var applyGrouped = function ( ) {
if ( grouped != $scope . historyMessage . grouped ) {
if ( grouped != $scope . historyMessage . grouped ) {
if ( grouped ) {
if ( grouped ) {
element . removeClass ( grouped )
element . removeClass ( grouped )
@ -99,8 +100,7 @@ angular.module('myApp.directives', ['myApp.filters'])
needDateSplit . hide ( )
needDateSplit . hide ( )
}
}
}
}
} ,
}
unreadAfterSplit
applySelected ( )
applySelected ( )
applyGrouped ( )
applyGrouped ( )
@ -166,8 +166,8 @@ angular.module('myApp.directives', ['myApp.filters'])
if ( ! error && ! pending ) {
if ( ! error && ! pending ) {
deregisterPending ( )
deregisterPending ( )
}
}
} ,
}
deregisterPending = $scope . $on ( 'messages_pending' , applyPending )
var deregisterPending = $scope . $on ( 'messages_pending' , applyPending )
applyPending ( )
applyPending ( )
}
}
@ -187,7 +187,7 @@ angular.module('myApp.directives', ['myApp.filters'])
}
}
function updateMessageText ( $scope , element , message ) {
function updateMessageText ( $scope , element , message ) {
if ( message . media && message . media . handleMessage ||
if ( ( message . media && message . media . handleMessage ) ||
typeof message . message !== 'string' ||
typeof message . message !== 'string' ||
! message . message . length ) {
! message . message . length ) {
$ ( '.im_message_text' , element ) . hide ( )
$ ( '.im_message_text' , element ) . hide ( )
@ -455,7 +455,7 @@ angular.module('myApp.directives', ['myApp.filters'])
AppInlineBotsManager . gameButtonClick ( $scope . messageId )
AppInlineBotsManager . gameButtonClick ( $scope . messageId )
}
}
function updateMessageText ( argument ) {
function updateMessageText ( argument ) {
var message = AppMessagesManager . getMessage ( $scope . messageId )
var message = AppMessagesManager . getMessage ( $scope . messageId )
if ( message . message ) {
if ( message . message ) {
var html = AppMessagesManager . wrapMessageText ( $scope . messageId )
var html = AppMessagesManager . wrapMessageText ( $scope . messageId )
@ -671,7 +671,6 @@ angular.module('myApp.directives', ['myApp.filters'])
} )
} )
. directive ( 'myMessageEdited' , function ( _ , $timeout , AppMessagesManager ) {
. directive ( 'myMessageEdited' , function ( _ , $timeout , AppMessagesManager ) {
var editedLabel = _ ( 'message_edited' )
var editedLabel = _ ( 'message_edited' )
return {
return {
@ -679,7 +678,7 @@ angular.module('myApp.directives', ['myApp.filters'])
link : link
link : link
}
}
function link ( $scope , element , attrs ) {
function link ( $scope , element , attrs ) {
var messageID = $scope . $parent . $eval ( attrs . myMessageEdited )
var messageID = $scope . $parent . $eval ( attrs . myMessageEdited )
if ( checkEdited ( $scope , element , messageID ) ) {
if ( checkEdited ( $scope , element , messageID ) ) {
$scope . $on ( 'message_edit' , function ( e , data ) {
$scope . $on ( 'message_edit' , function ( e , data ) {
@ -691,7 +690,7 @@ angular.module('myApp.directives', ['myApp.filters'])
}
}
}
}
function checkEdited ( $scope , element , messageID ) {
function checkEdited ( $scope , element , messageID ) {
var message = AppMessagesManager . getMessage ( messageID )
var message = AppMessagesManager . getMessage ( messageID )
if ( ! message . canBeEdited ) {
if ( ! message . canBeEdited ) {
$timeout ( function ( ) {
$timeout ( function ( ) {
@ -769,8 +768,9 @@ angular.module('myApp.directives', ['myApp.filters'])
return true
return true
}
}
var currentSelected , nextDialogWrap , dialogWraps
if ( e . keyCode == 36 && ! e . shiftKey && ! e . ctrlKey && e . altKey ) { // Alt + Home
if ( e . keyCode == 36 && ! e . shiftKey && ! e . ctrlKey && e . altKey ) { // Alt + Home
var currentSelected = $ ( scrollableWrap ) . find ( '.im_dialog_wrap a' )
currentSelected = $ ( scrollableWrap ) . find ( '.im_dialog_wrap a' )
if ( currentSelected . length ) {
if ( currentSelected . length ) {
$ ( currentSelected [ 0 ] ) . trigger ( 'mousedown' )
$ ( currentSelected [ 0 ] ) . trigger ( 'mousedown' )
scrollableWrap . scrollTop = 0
scrollableWrap . scrollTop = 0
@ -779,16 +779,15 @@ angular.module('myApp.directives', ['myApp.filters'])
return cancelEvent ( e )
return cancelEvent ( e )
}
}
if ( e . keyCode == 27 || e . keyCode == 9 && e . shiftKey && ! e . ctrlKey && ! e . metaKey ) { // ESC or Shift + Tab
if ( e . keyCode == 27 || ( e . keyCode == 9 && e . shiftKey && ! e . ctrlKey && ! e . metaKey ) ) { // ESC or Shift + Tab
if ( ! searchFocused ) {
if ( ! searchFocused ) {
setFieldSelection ( searchField )
setFieldSelection ( searchField )
if ( searchField . value ) {
if ( searchField . value ) {
searchField . select ( )
searchField . select ( )
}
}
}
} else if ( searchField . value ) {
else if ( searchField . value ) {
$ ( searchClear ) . trigger ( 'click' )
$ ( searchClear ) . trigger ( 'click' )
} else {
} else {
$scope . $emit ( 'esc_no_more' )
$scope . $emit ( 'esc_no_more' )
// Strange Chrome bug, when field doesn't get blur, but becomes inactive after location change
// Strange Chrome bug, when field doesn't get blur, but becomes inactive after location change
setTimeout ( function ( ) {
setTimeout ( function ( ) {
@ -802,7 +801,7 @@ angular.module('myApp.directives', ['myApp.filters'])
}
}
if ( searchFocused && e . keyCode == 13 && ! Config . Navigator . mobile ) { // Enter
if ( searchFocused && e . keyCode == 13 && ! Config . Navigator . mobile ) { // Enter
var currentSelected = $ ( scrollableWrap ) . find ( '.im_dialog_selected' ) [ 0 ] || $ ( scrollableWrap ) . find ( '.im_dialog_wrap a' ) [ 0 ]
currentSelected = $ ( scrollableWrap ) . find ( '.im_dialog_selected' ) [ 0 ] || $ ( scrollableWrap ) . find ( '.im_dialog_wrap a' ) [ 0 ]
if ( currentSelected &&
if ( currentSelected &&
! $ ( currentSelected ) . hasClass ( 'disabled' ) ) {
! $ ( currentSelected ) . hasClass ( 'disabled' ) ) {
$ ( currentSelected ) . trigger ( 'mousedown' )
$ ( currentSelected ) . trigger ( 'mousedown' )
@ -813,15 +812,13 @@ angular.module('myApp.directives', ['myApp.filters'])
if (
if (
( ! Config . Navigator . osX && // No Mac users
( ! Config . Navigator . osX && // No Mac users
e . altKey && e . shiftKey && ! e . ctrlKey && ! e . metaKey &&
e . altKey && e . shiftKey && ! e . ctrlKey && ! e . metaKey &&
e . keyCode >= 49 && e . keyCode <= 57 ) // Alt + Shift + # , switch to conversation # where # is in [1..9]
e . keyCode >= 49 && e . keyCode <= 57 ) || // Alt + Shift + # , switch to conversation # where # is in [1..9]
||
( Config . Navigator . osX && // Mac users only
( Config . Navigator . osX && // Mac users only
e . ctrlKey && e . shiftKey && ! e . metaKey && ! e . altKey &&
e . ctrlKey && e . shiftKey && ! e . metaKey && ! e . altKey &&
e . keyCode >= 49 && e . keyCode <= 57 ) ) { // Ctrl + Shift + # , switch to conversation # where # is in [1..9]
e . keyCode >= 49 && e . keyCode <= 57 ) ) { // Ctrl + Shift + # , switch to conversation # where # is in [1..9]
var dialogNumber = e . keyCode - 49
var dialogNumber = e . keyCode - 49
var dialogWraps = $ ( scrollableWrap ) . find ( '.im_dialog_wrap' )
dialogWraps = $ ( scrollableWrap ) . find ( '.im_dialog_wrap' )
var nextDialogWrap = dialogWraps [ dialogNumber ]
nextDialogWrap = dialogWraps [ dialogNumber ]
if ( nextDialogWrap ) {
if ( nextDialogWrap ) {
$ ( nextDialogWrap ) . find ( 'a' ) . trigger ( 'mousedown' )
$ ( nextDialogWrap ) . find ( 'a' ) . trigger ( 'mousedown' )
@ -838,8 +835,7 @@ angular.module('myApp.directives', ['myApp.filters'])
next = e . keyCode == 40
next = e . keyCode == 40
prev = ! next
prev = ! next
skip = ! e . shiftKey && e . altKey
skip = ! e . shiftKey && e . altKey
}
} else if ( ctrlTabSupported && e . keyCode == 9 && e . ctrlKey && ! e . metaKey ) { // Ctrl + Tab, Shift + Ctrl + Tab
else if ( ctrlTabSupported && e . keyCode == 9 && e . ctrlKey && ! e . metaKey ) { // Ctrl + Tab, Shift + Ctrl + Tab
next = ! e . shiftKey
next = ! e . shiftKey
prev = ! next
prev = ! next
skip = true
skip = true
@ -850,22 +846,21 @@ angular.module('myApp.directives', ['myApp.filters'])
return true
return true
}
}
var currentSelected = ! skip && $ ( scrollableWrap ) . find ( '.im_dialog_selected' ) [ 0 ] || $ ( scrollableWrap ) . find ( '.active a.im_dialog' ) [ 0 ]
currentSelected = ( ! skip && $ ( scrollableWrap ) . find ( '.im_dialog_selected' ) [ 0 ] ) || $ ( scrollableWrap ) . find ( '.active a.im_dialog' ) [ 0 ]
var currentSelectedWrap = currentSelected && currentSelected . parentNode ,
var currentSelectedWrap = currentSelected && currentSelected . parentNode
nextDialogWrap
if ( currentSelectedWrap ) {
if ( currentSelectedWrap ) {
var nextDialogWrap = currentSelected [ next ? 'nextSibling' : 'previousSibling' ]
nextDialogWrap = currentSelected [ next ? 'nextSibling' : 'previousSibling' ]
if ( ! nextDialogWrap || ! nextDialogWrap . className || nextDialogWrap . className . indexOf ( 'im_dialog_wrap' ) == - 1 ) {
if ( ! nextDialogWrap || ! nextDialogWrap . className || nextDialogWrap . className . indexOf ( 'im_dialog_wrap' ) == - 1 ) {
var dialogWraps = $ ( scrollableWrap ) . find ( '.im_dialog_wrap' )
dialogWraps = $ ( scrollableWrap ) . find ( '.im_dialog_wrap' )
var pos = dialogWraps . index ( currentSelected . parentNode )
var pos = dialogWraps . index ( currentSelected . parentNode )
var nextPos = pos + ( next ? 1 : - 1 )
var nextPos = pos + ( next ? 1 : - 1 )
nextDialogWrap = dialogWraps [ nextPos ]
nextDialogWrap = dialogWraps [ nextPos ]
}
}
} else {
} else {
var dialogWraps = $ ( scrollableWrap ) . find ( '.im_dialog_wrap' )
dialogWraps = $ ( scrollableWrap ) . find ( '.im_dialog_wrap' )
if ( next ) {
if ( next ) {
nextDialogWrap = dialogWraps [ 0 ]
nextDialogWrap = dialogWraps [ 0 ]
} else {
} else {
@ -1024,8 +1019,8 @@ angular.module('myApp.directives', ['myApp.filters'])
function updateSizes ( ) {
function updateSizes ( ) {
$ ( element ) . css ( {
$ ( element ) . css ( {
height : $ ( $window ) . height ( ) -
height : $ ( $window ) . height ( ) -
( panelWrap && panelWrap . offsetHeight || 0 ) -
( ( panelWrap && panelWrap . offsetHeight ) || 0 ) -
( searchWrap && searchWrap . offsetHeight || 0 ) -
( ( searchWrap && searchWrap . offsetHeight ) || 0 ) -
( Config . Mobile ? 64 : 200 )
( Config . Mobile ? 64 : 200 )
} )
} )
$ ( contactsWrap ) . nanoScroller ( )
$ ( contactsWrap ) . nanoScroller ( )
@ -1055,10 +1050,10 @@ angular.module('myApp.directives', ['myApp.filters'])
function updateSizes ( ) {
function updateSizes ( ) {
$ ( element ) . css ( {
$ ( element ) . css ( {
height : $ ( $window ) . height ( )
height : $ ( $window ) . height ( ) -
- ( panelWrap && panelWrap . offsetHeight || 0 )
( ( panelWrap && panelWrap . offsetHeight ) || 0 ) -
- ( searchWrap && searchWrap . offsetHeight || 0 )
( ( searchWrap && searchWrap . offsetHeight ) || 0 ) -
- ( Config . Mobile ? 46 + 18 : 200 )
( Config . Mobile ? 46 + 18 : 200 )
} )
} )
$ ( countriesWrap ) . nanoScroller ( )
$ ( countriesWrap ) . nanoScroller ( )
}
}
@ -1085,8 +1080,8 @@ angular.module('myApp.directives', ['myApp.filters'])
function updateSizes ( ) {
function updateSizes ( ) {
$ ( element ) . css ( {
$ ( element ) . css ( {
height : Math . min ( 760 , $ ( $window ) . height ( )
height : Math . min ( 760 , $ ( $window ) . height ( ) -
- ( Config . Mobile ? 46 + 18 : 200 ) )
( Config . Mobile ? 46 + 18 : 200 ) )
} )
} )
$ ( sessionsWrap ) . nanoScroller ( )
$ ( sessionsWrap ) . nanoScroller ( )
}
}
@ -1110,8 +1105,8 @@ angular.module('myApp.directives', ['myApp.filters'])
function updateSizes ( ) {
function updateSizes ( ) {
$ ( element ) . css ( {
$ ( element ) . css ( {
height : Math . min ( 600 , $ ( $window ) . height ( )
height : Math . min ( 600 , $ ( $window ) . height ( ) -
- ( Config . Mobile ? 46 + 18 : 200 ) )
( Config . Mobile ? 46 + 18 : 200 ) )
} )
} )
$ ( stickersWrap ) . nanoScroller ( )
$ ( stickersWrap ) . nanoScroller ( )
}
}
@ -1155,8 +1150,8 @@ angular.module('myApp.directives', ['myApp.filters'])
}
}
var transform = false
var transform = false
var trs = [ 'transform' , 'webkitTransform' , 'MozTransform' , 'msTransform' , 'OTransform' ] ,
var trs = [ 'transform' , 'webkitTransform' , 'MozTransform' , 'msTransform' , 'OTransform' ]
i
var i
for ( i = 0 ; i < trs . length ; i ++ ) {
for ( i = 0 ; i < trs . length ; i ++ ) {
if ( trs [ i ] in historyMessagesEl . style ) {
if ( trs [ i ] in historyMessagesEl . style ) {
transform = trs [ i ]
transform = trs [ i ]
@ -1164,7 +1159,7 @@ angular.module('myApp.directives', ['myApp.filters'])
}
}
}
}
var animated = transform && false ? true : false
var animated = transform && false ? true : false // ?
var curAnimation = false
var curAnimation = false
$scope . $on ( 'ui_history_append_new' , function ( e , options ) {
$scope . $on ( 'ui_history_append_new' , function ( e , options ) {
@ -1183,8 +1178,8 @@ angular.module('myApp.directives', ['myApp.filters'])
}
}
var curAnimated = animated &&
var curAnimated = animated &&
! $rootScope . idle . isIDLE &&
! $rootScope . idle . isIDLE &&
historyMessagesEl . clientHeight > 0 ,
historyMessagesEl . clientHeight > 0
wasH
var wasH
if ( curAnimated ) {
if ( curAnimated ) {
wasH = scrollableWrap . scrollHeight
wasH = scrollableWrap . scrollHeight
@ -1364,9 +1359,9 @@ angular.module('myApp.directives', ['myApp.filters'])
clearTimeout ( timer )
clearTimeout ( timer )
unreg ( )
unreg ( )
} ,
}
timer = setTimeout ( upd , 0 ) ,
var timer = setTimeout ( upd , 0 )
unreg = $scope . $on ( '$viewContentLoaded' , upd )
var unreg = $scope . $on ( '$viewContentLoaded' , upd )
} )
} )
$scope . $on ( 'ui_history_append' , function ( ) {
$scope . $on ( 'ui_history_append' , function ( ) {
@ -1439,8 +1434,7 @@ angular.module('myApp.directives', ['myApp.filters'])
if ( ! moreNotified && st <= 300 ) {
if ( ! moreNotified && st <= 300 ) {
moreNotified = true
moreNotified = true
$scope . $emit ( 'history_need_more' )
$scope . $emit ( 'history_need_more' )
}
} else if ( ! lessNotified && st >= scrollableWrap . scrollHeight - scrollableWrap . clientHeight - 300 ) {
else if ( ! lessNotified && st >= scrollableWrap . scrollHeight - scrollableWrap . clientHeight - 300 ) {
lessNotified = true
lessNotified = true
$scope . $emit ( 'history_need_less' )
$scope . $emit ( 'history_need_less' )
}
}
@ -1486,10 +1480,10 @@ angular.module('myApp.directives', ['myApp.filters'])
function updateBottomizer ( ) {
function updateBottomizer ( ) {
$ ( historyMessagesEl ) . css ( { marginTop : 0 } )
$ ( historyMessagesEl ) . css ( { marginTop : 0 } )
var marginTop = scrollableWrap . offsetHeight
var marginTop = scrollableWrap . offsetHeight -
- historyMessagesEl . offsetHeight
historyMessagesEl . offsetHeight -
- emptyWrapEl . offsetHeight
emptyWrapEl . offsetHeight -
- ( Config . Mobile ? 0 : 39 )
( Config . Mobile ? 0 : 39 )
if ( historyMessagesEl . offsetHeight > 0 && marginTop > 0 ) {
if ( historyMessagesEl . offsetHeight > 0 && marginTop > 0 ) {
$ ( historyMessagesEl ) . css ( { marginTop : marginTop } )
$ ( historyMessagesEl ) . css ( { marginTop : marginTop } )
@ -1671,7 +1665,7 @@ angular.module('myApp.directives', ['myApp.filters'])
} )
} )
}
}
function onDirectionKey ( e ) {
function onDirectionKey ( e ) {
if ( e . keyCode == 38 ) {
if ( e . keyCode == 38 ) {
$scope . $emit ( 'last_message_edit' )
$scope . $emit ( 'last_message_edit' )
return cancelEvent ( e )
return cancelEvent ( e )
@ -1727,7 +1721,7 @@ angular.module('myApp.directives', ['myApp.filters'])
composer . setValue ( $scope . draftMessage . text || '' )
composer . setValue ( $scope . draftMessage . text || '' )
updateHeight ( )
updateHeight ( )
}
}
if ( shouldFocusOnInteraction || options && options . focus ) {
if ( shouldFocusOnInteraction || ( options && options . focus ) ) {
composer . focus ( )
composer . focus ( )
}
}
}
}
@ -1786,10 +1780,9 @@ angular.module('myApp.directives', ['myApp.filters'])
function onPasteEvent ( e ) {
function onPasteEvent ( e ) {
var cData = ( e . originalEvent || e ) . clipboardData
var cData = ( e . originalEvent || e ) . clipboardData
var items = cData && cData . items || [ ]
var items = ( cData && cData . items ) || [ ]
var files = [ ] ,
var files = [ ]
file
var i , file
var i
for ( i = 0 ; i < items . length ; i ++ ) {
for ( i = 0 ; i < items . length ; i ++ ) {
if ( items [ i ] . kind == 'file' ) {
if ( items [ i ] . kind == 'file' ) {
@ -1902,7 +1895,7 @@ angular.module('myApp.directives', ['myApp.filters'])
// console.log('new loc', newLocation, arguments)
// console.log('new loc', newLocation, arguments)
var counterSaved = ++ counter
var counterSaved = ++ counter
if ( ! newLocation || newLocation . empty ) {
if ( ! newLocation || newLocation . empty ) {
element . attr ( 'src' , $scope . thumb && $scope . thumb . placeholder || 'img/blank.gif' )
element . attr ( 'src' , ( $scope . thumb && $scope . thumb . placeholder ) || 'img/blank.gif' )
cleanup ( )
cleanup ( )
return
return
}
}
@ -2179,7 +2172,7 @@ angular.module('myApp.directives', ['myApp.filters'])
imgElement . attr ( 'alt' , '[' + ( $scope . document . stickerEmojiRaw || '' ) + ' ' + _ ( 'conversation_media_sticker' ) + ']' )
imgElement . attr ( 'alt' , '[' + ( $scope . document . stickerEmojiRaw || '' ) + ' ' + _ ( 'conversation_media_sticker' ) + ']' )
var dim = attrs . dim && $scope . $parent . $eval ( attrs . dim ) || $scope . document . thumb
var dim = ( attrs . dim && $scope . $parent . $eval ( attrs . dim ) ) || $scope . document . thumb
if ( attrs . open && $scope . document . stickerSetInput ) {
if ( attrs . open && $scope . document . stickerSetInput ) {
element
element
@ -2404,7 +2397,8 @@ angular.module('myApp.directives', ['myApp.filters'])
if ( animationSupported === undefined ) {
if ( animationSupported === undefined ) {
animationSupported = el . style . animationName !== undefined
animationSupported = el . style . animationName !== undefined
if ( animationSupported === false ) {
if ( animationSupported === false ) {
var domPrefixes = 'Webkit Moz O ms Khtml' . split ( ' ' ) , i
var domPrefixes = 'Webkit Moz O ms Khtml' . split ( ' ' )
var i
for ( i = 0 ; i < domPrefixes . length ; i ++ ) {
for ( i = 0 ; i < domPrefixes . length ; i ++ ) {
if ( el . style [ domPrefixes [ i ] + 'AnimationName' ] !== undefined ) {
if ( el . style [ domPrefixes [ i ] + 'AnimationName' ] !== undefined ) {
animationSupported = true
animationSupported = true
@ -2570,7 +2564,7 @@ angular.module('myApp.directives', ['myApp.filters'])
var height = element [ 0 ] . parentNode . offsetHeight
var height = element [ 0 ] . parentNode . offsetHeight
var modal = element [ 0 ] . parentNode . parentNode . parentNode
var modal = element [ 0 ] . parentNode . parentNode . parentNode
var bottomPanel = $ ( '.media_modal_bottom_panel_wrap' , modal ) [ 0 ]
var bottomPanel = $ ( '.media_modal_bottom_panel_wrap' , modal ) [ 0 ]
var contHeight = modal . offsetHeight - ( bottomPanel && bottomPanel . offsetHeight || 0 )
var contHeight = modal . offsetHeight - ( ( bottomPanel && bottomPanel . offsetHeight ) || 0 )
if ( height < contHeight ) {
if ( height < contHeight ) {
$ ( element [ 0 ] . parentNode ) . css ( 'marginTop' , ( contHeight - height ) / 2 )
$ ( element [ 0 ] . parentNode ) . css ( 'marginTop' , ( contHeight - height ) / 2 )
@ -2611,7 +2605,7 @@ angular.module('myApp.directives', ['myApp.filters'])
var updateMargin = function ( ) {
var updateMargin = function ( ) {
var height = element [ 0 ] . offsetHeight
var height = element [ 0 ] . offsetHeight
var fullHeight = height - ( height && usePadding ? 2 * prevMargin : 0 )
var fullHeight = height - ( height && usePadding ? 2 * prevMargin : 0 )
var ratio = attrs . myVerticalPosition && parseFloat ( attrs . myVerticalPosition ) || 0.5
var ratio = ( attrs . myVerticalPosition && parseFloat ( attrs . myVerticalPosition ) ) || 0.5
var contHeight = attrs . contHeight ? $scope . $eval ( attrs . contHeight ) : $ ( $window ) . height ( )
var contHeight = attrs . contHeight ? $scope . $eval ( attrs . contHeight ) : $ ( $window ) . height ( )
var margin = fullHeight < contHeight ? parseInt ( ( contHeight - fullHeight ) * ratio ) : ''
var margin = fullHeight < contHeight ? parseInt ( ( contHeight - fullHeight ) * ratio ) : ''
var styles = usePadding
var styles = usePadding
@ -2668,7 +2662,7 @@ angular.module('myApp.directives', ['myApp.filters'])
var user = AppUsersManager . getUser ( userID )
var user = AppUsersManager . getUser ( userID )
element
element
. html ( statusFilter ( user , attrs . botChatPrivacy ) )
. html ( statusFilter ( user , attrs . botChatPrivacy ) )
. toggleClass ( 'status_online' , user . status && user . status . _ == 'userStatusOnline' || false )
. toggleClass ( 'status_online' , ( user . status && user . status . _ == 'userStatusOnline' ) || false )
// console.log(dT(), 'update status', element[0], user.status && user.status, tsNow(true), element.html())
// console.log(dT(), 'update status', element[0], user.status && user.status, tsNow(true), element.html())
}
}
@ -3045,10 +3039,8 @@ angular.module('myApp.directives', ['myApp.filters'])
if ( $scope . audio . url ) {
if ( $scope . audio . url ) {
checkPlayer ( $scope . mediaPlayer . player )
checkPlayer ( $scope . mediaPlayer . player )
$scope . mediaPlayer . player . playPause ( )
$scope . mediaPlayer . player . playPause ( )
}
} else if ( $scope . audio . progress && $scope . audio . progress . enabled ) {
else if ( $scope . audio . progress && $scope . audio . progress . enabled ) {
} else {
return
} else {
AppDocsManager . downloadDoc ( $scope . audio . id ) . then ( function ( ) {
AppDocsManager . downloadDoc ( $scope . audio . id ) . then ( function ( ) {
onContentLoaded ( function ( ) {
onContentLoaded ( function ( ) {
var errorListenerEl = $ ( 'audio' , element ) [ 0 ] || element [ 0 ]
var errorListenerEl = $ ( 'audio' , element ) [ 0 ] || element [ 0 ]
@ -3145,7 +3137,7 @@ angular.module('myApp.directives', ['myApp.filters'])
e = e . originalEvent || e
e = e . originalEvent || e
var offsetX = ( e . touches && e . touches [ 0 ] ? e . touches [ 0 ] . pageX : e . pageX ) - lastMinPageX
var offsetX = ( e . touches && e . touches [ 0 ] ? e . touches [ 0 ] . pageX : e . pageX ) - lastMinPageX
offsetX = Math . min ( width , Math . max ( 0 , offsetX ) )
offsetX = Math . min ( width , Math . max ( 0 , offsetX ) )
// console.log(e.type, lastMinPageX, e.pageX, offsetX)
// console.log(e.type, lastMinPageX, e.pageX, offsetX)
lastUpdValue = minValue + offsetX / width * ( maxValue - minValue )
lastUpdValue = minValue + offsetX / width * ( maxValue - minValue )
if ( sliderCallback ) {
if ( sliderCallback ) {
@ -3169,7 +3161,7 @@ angular.module('myApp.directives', ['myApp.filters'])
var percent = Math . max ( 0 , ( newVal - minValue ) / ( maxValue - minValue ) )
var percent = Math . max ( 0 , ( newVal - minValue ) / ( maxValue - minValue ) )
if ( width ) {
if ( width ) {
var offsetX = Math . ceil ( width * percent )
var offsetX = Math . ceil ( width * percent )
offsetX = Math . min ( width , Math . max ( 0 , offsetX ) )
offsetX = Math . min ( width , Math . max ( 0 , offsetX ) )
thumb . css ( 'left' , Math . max ( 0 , offsetX - thumbWidth ) )
thumb . css ( 'left' , Math . max ( 0 , offsetX - thumbWidth ) )
fill . css ( 'width' , offsetX )
fill . css ( 'width' , offsetX )
} else {
} else {
@ -3198,15 +3190,13 @@ angular.module('myApp.directives', ['myApp.filters'])
if ( e . touches && e . touches [ 0 ] ) {
if ( e . touches && e . touches [ 0 ] ) {
lastMinPageX = element . position ( ) . left
lastMinPageX = element . position ( ) . left
offsetX = e . touches [ 0 ] . pageX - lastMinPageX
offsetX = e . touches [ 0 ] . pageX - lastMinPageX
}
} else if ( e . offsetX !== undefined ) {
else if ( e . offsetX !== undefined ) {
offsetX = e . offsetX
offsetX = e . offsetX
lastMinPageX = e . pageX - offsetX
lastMinPageX = e . pageX - offsetX
}
} else if ( e . layerX !== undefined ) {
else if ( e . layerX !== undefined ) {
offsetX = e . layerX
offsetX = e . layerX
lastMinPageX = e . pageX - offsetX
lastMinPageX = e . pageX - offsetX
} else {
} else {
return cancelEvent ( e )
return cancelEvent ( e )
}
}
@ -3468,8 +3458,7 @@ angular.module('myApp.directives', ['myApp.filters'])
var spritesheet , pos
var spritesheet , pos
var categoryIndex
var categoryIndex
var count = Math . min ( 5 , codes . length )
var count = Math . min ( 5 , codes . length )
var i , x
var i , x , y
var y
for ( i = 0 ; i < count ; i ++ ) {
for ( i = 0 ; i < count ; i ++ ) {
emoticonCode = codes [ i ]
emoticonCode = codes [ i ]
@ -3517,8 +3506,9 @@ angular.module('myApp.directives', ['myApp.filters'])
if ( ( result . type == 'gif' || result . type == 'sticker' ) && result . document ) {
if ( ( result . type == 'gif' || result . type == 'sticker' ) && result . document ) {
AppDocsManager . downloadDoc ( result . document . id )
AppDocsManager . downloadDoc ( result . document . id )
}
}
var photoSize
if ( result . type == 'photo' && result . photo ) {
if ( result . type == 'photo' && result . photo ) {
var photoSize = AppPhotosManager . choosePhotoSize ( result . photo , result . thumbW , result . thumbH )
photoSize = AppPhotosManager . choosePhotoSize ( result . photo , result . thumbW , result . thumbH )
var dim = calcImageInBox ( photoSize . w , photoSize . h , result . thumbW , result . thumbH )
var dim = calcImageInBox ( photoSize . w , photoSize . h , result . thumbW , result . thumbH )
result . thumb = {
result . thumb = {
width : dim . w ,
width : dim . w ,
@ -3528,7 +3518,7 @@ angular.module('myApp.directives', ['myApp.filters'])
}
}
}
}
if ( result . type == 'game' && result . photo ) {
if ( result . type == 'game' && result . photo ) {
var photoSize = AppPhotosManager . choosePhotoSize ( result . photo , 100 , 100 )
photoSize = AppPhotosManager . choosePhotoSize ( result . photo , 100 , 100 )
// var dim = calcImageInBox(photoSize.w, photoSize.h, result.thumbW, result.thumbH)
// var dim = calcImageInBox(photoSize.w, photoSize.h, result.thumbW, result.thumbH)
result . thumb = {
result . thumb = {
// width: dim.w,
// width: dim.w,
@ -3562,7 +3552,7 @@ angular.module('myApp.directives', ['myApp.filters'])
if ( ! dataParsed || ! dataParsed . eventType ) {
if ( ! dataParsed || ! dataParsed . eventType ) {
return
return
}
}
$scope . $emit ( 'game_frame_event' , dataParsed ) ;
$scope . $emit ( 'game_frame_event' , dataParsed )
}
}
$ ( $window ) . on ( 'message' , handler )
$ ( $window ) . on ( 'message' , handler )
@ -3579,7 +3569,6 @@ angular.module('myApp.directives', ['myApp.filters'])
} )
} )
. directive ( 'myEmojiImage' , function ( RichTextProcessor ) {
. directive ( 'myEmojiImage' , function ( RichTextProcessor ) {
function link ( $scope , element , attrs ) {
function link ( $scope , element , attrs ) {
var emoji = attrs . myEmojiImage
var emoji = attrs . myEmojiImage
var html = RichTextProcessor . wrapRichText ( emoji , { noLinks : true , noLinebreaks : true } )
var html = RichTextProcessor . wrapRichText ( emoji , { noLinks : true , noLinebreaks : true } )
@ -3607,16 +3596,17 @@ angular.module('myApp.directives', ['myApp.filters'])
var html = ''
var html = ''
var callback = false
var callback = false
var needTwitter = false
var needTwitter = false
var videoID
switch ( embedData [ 0 ] ) {
switch ( embedData [ 0 ] ) {
case 'youtube' :
case 'youtube' :
var videoID = embedData [ 1 ]
videoID = embedData [ 1 ]
html = '<div class="im_message_media_embed im_message_video_embed"><' + embedTag + ' type="text/html" frameborder="0" ' +
html = '<div class="im_message_media_embed im_message_video_embed"><' + embedTag + ' type="text/html" frameborder="0" ' +
'src="https://www.youtube.com/embed/' + videoID +
'src="https://www.youtube.com/embed/' + videoID +
'?autoplay=0&controls=2" webkitallowfullscreen mozallowfullscreen allowfullscreen></' + embedTag + '></div>'
'?autoplay=0&controls=2" webkitallowfullscreen mozallowfullscreen allowfullscreen></' + embedTag + '></div>'
break
break
case 'vimeo' :
case 'vimeo' :
var videoID = embedData [ 1 ]
videoID = embedData [ 1 ]
html = '<div class="im_message_media_embed im_message_video_embed"><' + embedTag + ' type="text/html" frameborder="0" ' +
html = '<div class="im_message_media_embed im_message_video_embed"><' + embedTag + ' type="text/html" frameborder="0" ' +
'src="https://player.vimeo.com/video/' + videoID +
'src="https://player.vimeo.com/video/' + videoID +
'?title=0&byline=0&portrait=0" webkitallowfullscreen mozallowfullscreen allowfullscreen></' + embedTag + '></div>'
'?title=0&byline=0&portrait=0" webkitallowfullscreen mozallowfullscreen allowfullscreen></' + embedTag + '></div>'
@ -3666,8 +3656,7 @@ angular.module('myApp.directives', ['myApp.filters'])
} )
} )
} )
} )
. attr ( 'src' , 'https://platform.twitter.com/widgets.js' )
. attr ( 'src' , 'https://platform.twitter.com/widgets.js' )
}
} else if ( window . twttr ) {
else if ( window . twttr ) {
twttr . widgets . load ( element [ 0 ] )
twttr . widgets . load ( element [ 0 ] )
}
}
twitterPendingWidgets . push ( $scope )
twitterPendingWidgets . push ( $scope )
@ -3691,9 +3680,7 @@ angular.module('myApp.directives', ['myApp.filters'])
} )
} )
} )
} )
. attr ( 'src' , 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&appId=254098051407226&version=v2.0' )
. attr ( 'src' , 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&appId=254098051407226&version=v2.0' )
}
} else if ( window . FB ) {
else if ( window . FB ) {
FB . XFBML . parse ( element [ 0 ] )
FB . XFBML . parse ( element [ 0 ] )
}
}
facebookPendingWidgets . push ( $scope )
facebookPendingWidgets . push ( $scope )
@ -3714,8 +3701,7 @@ angular.module('myApp.directives', ['myApp.filters'])
gapi . post . go ( )
gapi . post . go ( )
} )
} )
. attr ( 'src' , 'https://apis.google.com/js/plusone.js' )
. attr ( 'src' , 'https://apis.google.com/js/plusone.js' )
}
} else if ( window . gapi ) {
else if ( window . gapi ) {
gapi . post . go ( element [ 0 ] )
gapi . post . go ( element [ 0 ] )
}
}
element . one ( 'load' , function ( ) {
element . one ( 'load' , function ( ) {