@ -175,340 +175,16 @@ angular.module('myApp.directives', ['myApp.filters'])
}
}
}
}
} )
} )
. directive ( 'myExternalEmbed' , function ( ) {
var twitterAttached = false ;
var facebookAttached = false ;
var gplusAttached = false ;
var twitterPendingWidgets = [ ] ;
var facebookPendingWidgets = [ ] ;
var embedTag = Config . Modes . chrome _packed ? 'webview' : 'iframe' ;
function link ( $scope , element , attrs ) {
var embedData = $scope . $eval ( attrs . myExternalEmbed ) ;
if ( ! embedData ) {
return ;
}
var html = '' ;
var callback = false ;
var needTwitter = false ;
switch ( embedData [ 0 ] ) {
case 'youtube' :
var videoID = embedData [ 1 ] ;
html = '<div class="im_message_media_embed im_message_video_embed"><' + embedTag + ' type="text/html" frameborder="0" ' +
'src="https://www.youtube.com/embed/' + videoID +
'?autoplay=0&controls=2" webkitallowfullscreen mozallowfullscreen allowfullscreen></' + embedTag + '></div>' ;
break ;
case 'vimeo' :
var videoID = embedData [ 1 ] ;
html = '<div class="im_message_media_embed im_message_video_embed"><' + embedTag + ' type="text/html" frameborder="0" ' +
'src="https://player.vimeo.com/video/' + videoID +
'?title=0&byline=0&portrait=0" webkitallowfullscreen mozallowfullscreen allowfullscreen></' + embedTag + '></div>' ;
break ;
case 'instagram' :
var instaID = embedData [ 1 ] ;
html = '<div class="im_message_media_embed im_message_insta_embed"><' + embedTag + ' type="text/html" frameborder="0" ' +
'src="https://instagram.com/p/' + instaID +
'/embed/"></' + embedTag + '></div>' ;
break ;
case 'vine' :
var vineID = embedData [ 1 ] ;
html = '<div class="im_message_media_embed im_message_vine_embed"><' + embedTag + ' type="text/html" frameborder="0" ' +
'src="https://vine.co/v/' + vineID + '/embed/simple"></' + embedTag + '></div>' ;
break ;
case 'soundcloud' :
var soundcloudUrl = embedData [ 1 ] ;
html = '<div class="im_message_media_embed im_message_soundcloud_embed"><' + embedTag + ' type="text/html" frameborder="0" ' +
'src="https://w.soundcloud.com/player/?url=' + encodeEntities ( encodeURIComponent ( soundcloudUrl ) ) +
'&auto_play=false&hide_related=true&show_comments=false&show_user=true&show_reposts=false&visual=true"></' + embedTag + '></div>' ;
break ;
case 'spotify' :
var spotifyUrl = embedData [ 1 ] ;
html = '<div class="im_message_media_embed im_message_spotify_embed"><' + embedTag + ' type="text/html" frameborder="0" allowtransparency="true" ' +
'src="https://embed.spotify.com/?uri=spotify:' + encodeEntities ( encodeURIComponent ( spotifyUrl ) ) +
'"></' + embedTag + '></div>' ;
break ;
case 'twitter' :
html = '<div class="im_message_twitter_embed"><blockquote class="twitter-tweet" lang="en"><a href="' + embedData [ 1 ] + '"></a></blockquote></div>' ;
callback = function ( ) {
if ( ! twitterAttached ) {
twitterAttached = true ;
$ ( '<script>' )
. appendTo ( 'body' )
. on ( 'load' , function ( ) {
twttr . events . bind ( 'loaded' , function ( event ) {
for ( var i = 0 ; i < twitterPendingWidgets . length ; i ++ ) {
twitterPendingWidgets [ i ] . $emit ( 'ui_height' ) ;
}
twitterPendingWidgets = [ ] ;
} ) ;
} )
. attr ( 'src' , 'https://platform.twitter.com/widgets.js' ) ;
}
else if ( window . twttr ) {
twttr . widgets . load ( element [ 0 ] ) ;
}
twitterPendingWidgets . push ( $scope ) ;
} ;
break ;
case 'facebook' :
html = '<div class="im_message_facebook_embed"><div class="fb-post" data-href="' + embedData [ 1 ] + '" data-width="300"></div></div>' ;
callback = function ( ) {
if ( ! facebookAttached ) {
facebookAttached = true ;
$ ( '<script>' )
. appendTo ( 'body' )
. on ( 'load' , function ( ) {
FB . Event . subscribe ( 'xfbml.render' , function ( event ) {
for ( var i = 0 ; i < facebookPendingWidgets . length ; i ++ ) {
facebookPendingWidgets [ i ] . $emit ( 'ui_height' ) ;
}
facebookPendingWidgets = [ ] ;
} ) ;
} )
. attr ( 'src' , 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&appId=254098051407226&version=v2.0' ) ;
}
else if ( window . FB ) {
FB . XFBML . parse ( element [ 0 ] ) ;
}
facebookPendingWidgets . push ( $scope ) ;
} ;
break ;
case 'gplus' :
html = '<div class="im_message_gplus_embed"><div class="g-post" data-href="' + embedData [ 1 ] + '"></div></div>' ;
callback = function ( ) {
if ( ! gplusAttached ) {
gplusAttached = true ;
window . _ _ _gcfg = { "parsetags" : "explicit" } ;
$ ( '<script>' )
. appendTo ( 'body' )
. on ( 'load' , function ( ) {
gapi . post . go ( ) ;
} )
. attr ( 'src' , 'https://apis.google.com/js/plusone.js' ) ;
}
else if ( window . gapi ) {
gapi . post . go ( element [ 0 ] ) ;
}
element . one ( 'load' , function ( ) {
$scope . $emit ( 'ui_height' ) ;
} ) ;
} ;
break ;
}
if ( html ) {
element [ 0 ] . innerHTML = html ;
if ( callback ) {
callback ( ) ;
}
}
}
return {
link : link
} ;
} )
. directive ( 'myServiceMessage' , function ( ) {
return {
templateUrl : templateUrl ( 'message_service' )
} ;
} )
. directive ( 'myShortMessage' , function ( ) {
return {
scope : {
message : '=myShortMessage'
} ,
templateUrl : templateUrl ( 'short_message' )
} ;
} )
. directive ( 'myReplyMessage' , function ( AppMessagesManager , AppPeersManager , $rootScope ) {
return {
templateUrl : templateUrl ( 'reply_message' ) ,
scope : {
'replyMessage' : '=myReplyMessage'
} ,
link : link
} ;
function link ( $scope , element , attrs ) {
if ( attrs . watch ) {
$scope . $watch ( 'replyMessage' , function ( ) {
checkMessage ( $scope , element ) ;
} ) ;
} else {
checkMessage ( $scope , element ) ;
}
}
function checkMessage ( $scope , element ) {
var message = $scope . replyMessage ;
if ( ! message . loading ) {
updateMessage ( $scope , element ) ;
} else {
var mid = message . mid ;
var stopWaiting = $scope . $on ( 'messages_downloaded' , function ( e , mids ) {
if ( mids . indexOf ( mid ) != - 1 ) {
$scope . replyMessage = AppMessagesManager . wrapForDialog ( mid ) ;
updateMessage ( $scope , element ) ;
stopWaiting ( ) ;
}
} ) ;
}
}
function updateMessage ( $scope , element ) {
var message = $scope . replyMessage ;
if ( ! message || message . deleted || ! message . to _id ) {
$ ( element ) . remove ( ) ;
return ;
}
$scope . thumb = AppMessagesManager . getMessageThumb ( message , 42 , 42 ) ;
if ( element [ 0 ] . tagName == 'A' ) {
element . on ( 'click' , function ( ) {
var peerID = AppMessagesManager . getMessagePeer ( message ) ;
var peerString = AppPeersManager . getPeerString ( peerID ) ;
$rootScope . $broadcast ( 'history_focus' , { peerString : peerString , messageID : message . mid } ) ;
} )
. directive ( 'myMessageBody' , function ( AppPeersManager , AppMessagesManager , AppChatsManager , AppUsersManager , RichTextProcessor ) {
}
onContentLoaded ( function ( ) {
$scope . $emit ( 'ui_height' ) ;
} )
}
} )
. directive ( 'myPinnedMessage' , function ( AppMessagesManager , AppPeersManager , $rootScope ) {
return {
templateUrl : templateUrl ( 'pinned_message' ) ,
scope : {
'pinnedMessage' : '=myPinnedMessage'
} ,
link : link
} ;
function link ( $scope , element , attrs ) {
var message = $scope . pinnedMessage ;
if ( ! message . loading ) {
updateMessage ( $scope , element ) ;
} else {
var mid = message . mid ;
var stopWaiting = $scope . $on ( 'messages_downloaded' , function ( e , mids ) {
if ( mids . indexOf ( mid ) != - 1 ) {
$scope . pinnedMessage = AppMessagesManager . wrapForDialog ( mid ) ;
updateMessage ( $scope , element ) ;
stopWaiting ( ) ;
}
} ) ;
}
}
function updateMessage ( $scope , element ) {
var message = $scope . pinnedMessage ;
if ( ! message || message . deleted || ! message . to _id ) {
$ ( element ) . remove ( ) ;
return ;
}
if ( element [ 0 ] . tagName == 'A' ) {
element . on ( 'click' , function ( ) {
var peerID = AppMessagesManager . getMessagePeer ( message ) ;
var peerString = AppPeersManager . getPeerString ( peerID ) ;
$rootScope . $broadcast ( 'history_focus' , { peerString : peerString , messageID : message . mid } ) ;
} )
}
onContentLoaded ( function ( ) {
$scope . $emit ( 'ui_height' ) ;
} )
}
} )
. directive ( 'myForwardedMessages' , function ( AppPhotosManager , AppMessagesManager , AppPeersManager , $rootScope ) {
return {
templateUrl : templateUrl ( 'forwarded_messages' ) ,
scope : {
'forwardMessages' : '=myForwardedMessages'
} ,
link : link
} ;
function link ( $scope , element , attrs ) {
if ( attrs . watch ) {
$scope . $watch ( 'forwardMessages' , function ( ) {
updateMessages ( $scope , element ) ;
} ) ;
} else {
updateMessages ( $scope , element ) ;
}
}
function updateMessages ( $scope , element ) {
var mids = $scope . forwardMessages ;
var length = mids . length ;
var fromID = false ;
var single = length == 1 ;
$scope . thumb = false ;
$scope . singleMessage = false ;
angular . forEach ( mids , function ( mid ) {
var message = AppMessagesManager . getMessage ( mid ) ;
if ( fromID === false ) {
fromID = message . fromID ;
} else {
if ( fromID !== message . fromID ) {
fromID = AppMessagesManager . getMessagePeer ( message ) ;
}
}
if ( single ) {
$scope . thumb = AppMessagesManager . getMessageThumb ( message , 42 , 42 ) ;
$scope . singleMessage = AppMessagesManager . wrapForDialog ( mid ) ;
}
} ) ;
$scope . fromID = fromID ;
$scope . count = length ;
onContentLoaded ( function ( ) {
$scope . $emit ( 'ui_height' ) ;
} )
}
} )
. directive ( 'myMessageText' , function ( AppPeersManager , AppMessagesManager , AppChatsManager , AppUsersManager , RichTextProcessor ) {
return {
return {
link : link ,
link : link ,
scope : {
scope : {
message : '=myMessageText '
message : '=myMessageBody'
}
}
} ;
} ;
function updateHtml ( message , element ) {
function updateMessageText ( message , element ) {
var entities = message . totalEntities ;
var entities = message . totalEntities ;
var fromUser = message . from _id && AppUsersManager . getUser ( message . from _id ) ;
var fromUser = message . from _id && AppUsersManager . getUser ( message . from _id ) ;
var fromBot = fromUser && fromUser . pFlags . bot && fromUser . username || false ;
var fromBot = fromUser && fromUser . pFlags . bot && fromUser . username || false ;
@ -522,7 +198,7 @@ angular.module('myApp.directives', ['myApp.filters'])
fromBot : fromBot ,
fromBot : fromBot ,
entities : entities
entities : entities
} ;
} ;
if ( message . flags & 16 ) {
if ( message . pFlags . mentioned ) {
var user = AppUsersManager . getSelf ( ) ;
var user = AppUsersManager . getSelf ( ) ;
if ( user ) {
if ( user ) {
options . highlightUsername = user . username ;
options . highlightUsername = user . username ;
@ -537,15 +213,14 @@ angular.module('myApp.directives', ['myApp.filters'])
function link ( $scope , element , attrs ) {
function link ( $scope , element , attrs ) {
var message = $scope . message ;
var message = $scope . message ;
var msgID = message . mid ;
var msgID = message . mid ;
// var msgID = $scope.$eval(attrs.myMessageText);
var textElement = $ ( '.im_message_text' , element ) ;
// var message = AppMessagesManager.getMessage(msgID);
updateHtml ( message , element ) ;
updateMessageText ( message , t extE lement) ;
if ( message . pending ) {
if ( message . pending ) {
var unlink = $scope . $on ( 'messages_pending' , function ( ) {
var unlink = $scope . $on ( 'messages_pending' , function ( ) {
if ( message . mid != msgID ) {
if ( message . mid != msgID ) {
updateHtml ( message , element ) ;
updateMessageText ( message , t extE lement) ;
unlink ( ) ;
unlink ( ) ;
}
}
} )
} )
@ -676,31 +351,207 @@ angular.module('myApp.directives', ['myApp.filters'])
. directive ( 'myMessageWebpage' , function ( AppWebPagesManager , AppPhotosManager ) {
. directive ( 'myMessageWebpage' , function ( AppWebPagesManager , AppPhotosManager ) {
return {
return {
scope : {
scope : {
'webpage' : '=myMessageWebpage' ,
'webpage' : '=myMessageWebpage' ,
'messageId' : '=messageId'
'messageId' : '=messageId'
} ,
templateUrl : templateUrl ( 'message_attach_webpage' ) ,
link : function ( $scope ) {
$scope . openPhoto = AppPhotosManager . openPhoto ;
$scope . openEmbed = function ( $event ) {
if ( $scope . webpage && $scope . webpage . embed _url ) {
AppWebPagesManager . openEmbed ( $scope . webpage . id , $scope . messageId ) ;
return cancelEvent ( $event ) ;
}
} ;
$scope . $on ( 'webpage_updated' , function ( e , eventData ) {
if ( $scope . webpage && $scope . webpage . id == eventData . id ) {
$scope . $emit ( 'ui_height' ) ;
}
} ) ;
}
} ;
} )
. directive ( 'myMessagePending' , function ( ) {
return {
templateUrl : templateUrl ( 'message_attach_pending' )
} ;
} )
. directive ( 'myServiceMessage' , function ( ) {
return {
templateUrl : templateUrl ( 'message_service' )
} ;
} )
. directive ( 'myShortMessage' , function ( ) {
return {
scope : {
message : '=myShortMessage'
} ,
templateUrl : templateUrl ( 'short_message' )
} ;
} )
. directive ( 'myReplyMessage' , function ( AppMessagesManager , AppPeersManager , $rootScope ) {
return {
templateUrl : templateUrl ( 'reply_message' ) ,
scope : {
'replyMessage' : '=myReplyMessage'
} ,
link : link
} ;
function link ( $scope , element , attrs ) {
if ( attrs . watch ) {
$scope . $watch ( 'replyMessage' , function ( ) {
checkMessage ( $scope , element ) ;
} ) ;
} else {
checkMessage ( $scope , element ) ;
}
}
function checkMessage ( $scope , element ) {
var message = $scope . replyMessage ;
if ( ! message . loading ) {
updateMessage ( $scope , element ) ;
} else {
var mid = message . mid ;
var stopWaiting = $scope . $on ( 'messages_downloaded' , function ( e , mids ) {
if ( mids . indexOf ( mid ) != - 1 ) {
$scope . replyMessage = AppMessagesManager . wrapForDialog ( mid ) ;
updateMessage ( $scope , element ) ;
stopWaiting ( ) ;
}
} ) ;
}
}
function updateMessage ( $scope , element ) {
var message = $scope . replyMessage ;
if ( ! message || message . deleted || ! message . to _id ) {
$ ( element ) . remove ( ) ;
return ;
}
$scope . thumb = AppMessagesManager . getMessageThumb ( message , 42 , 42 ) ;
if ( element [ 0 ] . tagName == 'A' ) {
element . on ( 'click' , function ( ) {
var peerID = AppMessagesManager . getMessagePeer ( message ) ;
var peerString = AppPeersManager . getPeerString ( peerID ) ;
$rootScope . $broadcast ( 'history_focus' , { peerString : peerString , messageID : message . mid } ) ;
} )
}
onContentLoaded ( function ( ) {
$scope . $emit ( 'ui_height' ) ;
} )
}
} )
. directive ( 'myPinnedMessage' , function ( AppMessagesManager , AppPeersManager , $rootScope ) {
return {
templateUrl : templateUrl ( 'pinned_message' ) ,
scope : {
'pinnedMessage' : '=myPinnedMessage'
} ,
} ,
templateUrl : templateUrl ( 'message_attach_webpage' ) ,
link : link
link : function ( $scope ) {
} ;
$scope . openPhoto = AppPhotosManager . openPhoto ;
$scope . openEmbed = function ( $event ) {
if ( $scope . webpage && $scope . webpage . embed _url ) {
AppWebPagesManager . openEmbed ( $scope . webpage . id , $scope . messageId ) ;
return cancelEvent ( $event ) ;
}
} ;
$scope . $on ( 'webpage_updated' , function ( e , eventData ) {
function link ( $scope , element , attrs ) {
if ( $scope . webpage && $scope . webpage . id == eventData . id ) {
var message = $scope . pinnedMessage ;
$scope . $emit ( 'ui_height' ) ;
if ( ! message . loading ) {
updateMessage ( $scope , element ) ;
} else {
var mid = message . mid ;
var stopWaiting = $scope . $on ( 'messages_downloaded' , function ( e , mids ) {
if ( mids . indexOf ( mid ) != - 1 ) {
$scope . pinnedMessage = AppMessagesManager . wrapForDialog ( mid ) ;
updateMessage ( $scope , element ) ;
stopWaiting ( ) ;
}
}
} ) ;
} ) ;
}
}
} ;
}
function updateMessage ( $scope , element ) {
var message = $scope . pinnedMessage ;
if ( ! message || message . deleted || ! message . to _id ) {
$ ( element ) . remove ( ) ;
return ;
}
if ( element [ 0 ] . tagName == 'A' ) {
element . on ( 'click' , function ( ) {
var peerID = AppMessagesManager . getMessagePeer ( message ) ;
var peerString = AppPeersManager . getPeerString ( peerID ) ;
$rootScope . $broadcast ( 'history_focus' , { peerString : peerString , messageID : message . mid } ) ;
} )
}
onContentLoaded ( function ( ) {
$scope . $emit ( 'ui_height' ) ;
} )
}
} )
} )
. directive ( 'myMessagePending' , function ( ) {
. directive ( 'myForwardedMessages' , function ( AppPhotosManager , AppMessagesManager , AppPeersManager , $rootScope ) {
return {
return {
templateUrl : templateUrl ( 'message_attach_pending' )
templateUrl : templateUrl ( 'forwarded_messages' ) ,
scope : {
'forwardMessages' : '=myForwardedMessages'
} ,
link : link
} ;
} ;
function link ( $scope , element , attrs ) {
if ( attrs . watch ) {
$scope . $watch ( 'forwardMessages' , function ( ) {
updateMessages ( $scope , element ) ;
} ) ;
} else {
updateMessages ( $scope , element ) ;
}
}
function updateMessages ( $scope , element ) {
var mids = $scope . forwardMessages ;
var length = mids . length ;
var fromID = false ;
var single = length == 1 ;
$scope . thumb = false ;
$scope . singleMessage = false ;
angular . forEach ( mids , function ( mid ) {
var message = AppMessagesManager . getMessage ( mid ) ;
if ( fromID === false ) {
fromID = message . fromID ;
} else {
if ( fromID !== message . fromID ) {
fromID = AppMessagesManager . getMessagePeer ( message ) ;
}
}
if ( single ) {
$scope . thumb = AppMessagesManager . getMessageThumb ( message , 42 , 42 ) ;
$scope . singleMessage = AppMessagesManager . wrapForDialog ( mid ) ;
}
} ) ;
$scope . fromID = fromID ;
$scope . count = length ;
onContentLoaded ( function ( ) {
$scope . $emit ( 'ui_height' ) ;
} )
}
} )
} )
. directive ( 'myDialogs' , function ( $modalStack , $transition , $window , $timeout ) {
. directive ( 'myDialogs' , function ( $modalStack , $transition , $window , $timeout ) {
@ -3488,3 +3339,153 @@ angular.module('myApp.directives', ['myApp.filters'])
}
}
} )
} )
. directive ( 'myExternalEmbed' , function ( ) {
var twitterAttached = false ;
var facebookAttached = false ;
var gplusAttached = false ;
var twitterPendingWidgets = [ ] ;
var facebookPendingWidgets = [ ] ;
var embedTag = Config . Modes . chrome _packed ? 'webview' : 'iframe' ;
function link ( $scope , element , attrs ) {
var embedData = $scope . $eval ( attrs . myExternalEmbed ) ;
if ( ! embedData ) {
return ;
}
var html = '' ;
var callback = false ;
var needTwitter = false ;
switch ( embedData [ 0 ] ) {
case 'youtube' :
var videoID = embedData [ 1 ] ;
html = '<div class="im_message_media_embed im_message_video_embed"><' + embedTag + ' type="text/html" frameborder="0" ' +
'src="https://www.youtube.com/embed/' + videoID +
'?autoplay=0&controls=2" webkitallowfullscreen mozallowfullscreen allowfullscreen></' + embedTag + '></div>' ;
break ;
case 'vimeo' :
var videoID = embedData [ 1 ] ;
html = '<div class="im_message_media_embed im_message_video_embed"><' + embedTag + ' type="text/html" frameborder="0" ' +
'src="https://player.vimeo.com/video/' + videoID +
'?title=0&byline=0&portrait=0" webkitallowfullscreen mozallowfullscreen allowfullscreen></' + embedTag + '></div>' ;
break ;
case 'instagram' :
var instaID = embedData [ 1 ] ;
html = '<div class="im_message_media_embed im_message_insta_embed"><' + embedTag + ' type="text/html" frameborder="0" ' +
'src="https://instagram.com/p/' + instaID +
'/embed/"></' + embedTag + '></div>' ;
break ;
case 'vine' :
var vineID = embedData [ 1 ] ;
html = '<div class="im_message_media_embed im_message_vine_embed"><' + embedTag + ' type="text/html" frameborder="0" ' +
'src="https://vine.co/v/' + vineID + '/embed/simple"></' + embedTag + '></div>' ;
break ;
case 'soundcloud' :
var soundcloudUrl = embedData [ 1 ] ;
html = '<div class="im_message_media_embed im_message_soundcloud_embed"><' + embedTag + ' type="text/html" frameborder="0" ' +
'src="https://w.soundcloud.com/player/?url=' + encodeEntities ( encodeURIComponent ( soundcloudUrl ) ) +
'&auto_play=false&hide_related=true&show_comments=false&show_user=true&show_reposts=false&visual=true"></' + embedTag + '></div>' ;
break ;
case 'spotify' :
var spotifyUrl = embedData [ 1 ] ;
html = '<div class="im_message_media_embed im_message_spotify_embed"><' + embedTag + ' type="text/html" frameborder="0" allowtransparency="true" ' +
'src="https://embed.spotify.com/?uri=spotify:' + encodeEntities ( encodeURIComponent ( spotifyUrl ) ) +
'"></' + embedTag + '></div>' ;
break ;
case 'twitter' :
html = '<div class="im_message_twitter_embed"><blockquote class="twitter-tweet" lang="en"><a href="' + embedData [ 1 ] + '"></a></blockquote></div>' ;
callback = function ( ) {
if ( ! twitterAttached ) {
twitterAttached = true ;
$ ( '<script>' )
. appendTo ( 'body' )
. on ( 'load' , function ( ) {
twttr . events . bind ( 'loaded' , function ( event ) {
for ( var i = 0 ; i < twitterPendingWidgets . length ; i ++ ) {
twitterPendingWidgets [ i ] . $emit ( 'ui_height' ) ;
}
twitterPendingWidgets = [ ] ;
} ) ;
} )
. attr ( 'src' , 'https://platform.twitter.com/widgets.js' ) ;
}
else if ( window . twttr ) {
twttr . widgets . load ( element [ 0 ] ) ;
}
twitterPendingWidgets . push ( $scope ) ;
} ;
break ;
case 'facebook' :
html = '<div class="im_message_facebook_embed"><div class="fb-post" data-href="' + embedData [ 1 ] + '" data-width="300"></div></div>' ;
callback = function ( ) {
if ( ! facebookAttached ) {
facebookAttached = true ;
$ ( '<script>' )
. appendTo ( 'body' )
. on ( 'load' , function ( ) {
FB . Event . subscribe ( 'xfbml.render' , function ( event ) {
for ( var i = 0 ; i < facebookPendingWidgets . length ; i ++ ) {
facebookPendingWidgets [ i ] . $emit ( 'ui_height' ) ;
}
facebookPendingWidgets = [ ] ;
} ) ;
} )
. attr ( 'src' , 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&appId=254098051407226&version=v2.0' ) ;
}
else if ( window . FB ) {
FB . XFBML . parse ( element [ 0 ] ) ;
}
facebookPendingWidgets . push ( $scope ) ;
} ;
break ;
case 'gplus' :
html = '<div class="im_message_gplus_embed"><div class="g-post" data-href="' + embedData [ 1 ] + '"></div></div>' ;
callback = function ( ) {
if ( ! gplusAttached ) {
gplusAttached = true ;
window . _ _ _gcfg = { "parsetags" : "explicit" } ;
$ ( '<script>' )
. appendTo ( 'body' )
. on ( 'load' , function ( ) {
gapi . post . go ( ) ;
} )
. attr ( 'src' , 'https://apis.google.com/js/plusone.js' ) ;
}
else if ( window . gapi ) {
gapi . post . go ( element [ 0 ] ) ;
}
element . one ( 'load' , function ( ) {
$scope . $emit ( 'ui_height' ) ;
} ) ;
} ;
break ;
}
if ( html ) {
element [ 0 ] . innerHTML = html ;
if ( callback ) {
callback ( ) ;
}
}
}
return {
link : link
} ;
} )