@ -683,19 +683,18 @@ angular.module('myApp.directives', ['myApp.filters'])
link : link ,
link : link ,
transclude : true ,
transclude : true ,
template :
template :
'<div class="img_fullsize_with_progress_wrap" ng-style="{width: fullPhoto.width + \'px\', height: fullPhoto.height + \'px\' } " > \
' < div class = "img_fullsize_with_progress_wrap" " > \
< div class = "img_fullsize_progress_overlay" ng - show = "progress.enabled" > \
< div class = "img_fullsize_progress_overlay" ng - show = "progress.enabled" > \
< div class = "img_fullsize_progress_wrap" ng - style = "{width: fullPhoto.width + \'px\', height: fullPhoto.height + \'px\'}" > \
< div class = "img_fullsize_progress_wrap" " > \
< div class = "img_fullsize_progress progress tg_progress" > \
< div class = "img_fullsize_progress progress tg_progress" ng - show = "progress.percent > 0" > \
< div class = "progress-bar progress-bar-success" role = "progressbar" aria - valuenow = "{{progress.percent}}" aria - valuemin = "0" aria - valuemax = "100" style = "width: {{progress.percent}}%" > \
< div class = "progress-bar progress-bar-success" ng - style = "{width: progress.percent + \'%\'}" > \
< span class = "sr-only" > { { progress . percent } } % Complete ( success ) < / s p a n > \
< / d i v > \
< / d i v > \
< / d i v > \
< / d i v > \
< / d i v > \
< / d i v > \
< / d i v > \
< / d i v > \
< div class = "photo_full_wrap" > \
< div class = "photo_full_wrap" > \
< a class = "photo_modal_image" > \
< a class = "photo_modal_image" > \
< img class = "photo_modal_image" width = "{{fullPhoto.width}}" height = "{{fullPhoto.height}}" / > \
< img class = "photo_modal_image" / > \
< / a > \
< / a > \
< / d i v > \
< / d i v > \
< div class = "photo_modal_error_wrap" ng - if = "error" > \
< div class = "photo_modal_error_wrap" ng - if = "error" > \
@ -711,53 +710,68 @@ angular.module('myApp.directives', ['myApp.filters'])
function link ( $scope , element , attrs ) {
function link ( $scope , element , attrs ) {
var imgElement = $ ( 'img' , element ) ;
var imgElement = $ ( 'img' , element ) [ 0 ] ,
resizeElements = $ ( '.img_fullsize_with_progress_wrap' , element )
. add ( '.img_fullsize_progress_wrap' , element )
. add ( $ ( imgElement ) ) ,
resize = function ( ) {
resizeElements . css ( { width : $scope . fullPhoto . width , height : $scope . fullPhoto . height } ) ;
$scope . $emit ( 'ui_height' ) ;
} ;
imgElement
var jump = 0 ;
. attr ( 'src' , MtpApiFileManager . getCachedFile ( $scope . thumbLocation ) || 'img/blank.gif' )
$scope . $watchCollection ( 'fullPhoto.location' , function ( ) {
. addClass ( 'thumb_blurred' )
var cachedSrc = MtpApiFileManager . getCachedFile ( $scope . thumbLocation ) ,
. addClass ( 'thumb_blur_animation' ) ;
curJump = ++ jump ;
if ( ! $scope . fullPhoto . location ) {
if ( cachedSrc ) {
return ;
imgElement . src = cachedSrc ;
}
resize ( ) ;
} else {
imgElement . src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7' ;
}
if ( ! $scope . fullPhoto . location ) {
return ;
}
var apiPromise ;
var apiPromise ;
if ( $scope . fullPhoto . size ) {
if ( $scope . fullPhoto . size ) {
var inputLocation = {
var inputLocation = {
_ : 'inputFileLocation' ,
_ : 'inputFileLocation' ,
volume _id : $scope . fullPhoto . location . volume _id ,
volume _id : $scope . fullPhoto . location . volume _id ,
local _id : $scope . fullPhoto . location . local _id ,
local _id : $scope . fullPhoto . location . local _id ,
secret : $scope . fullPhoto . location . secret
secret : $scope . fullPhoto . location . secret
} ;
} ;
apiPromise = MtpApiFileManager . downloadFile ( $scope . fullPhoto . location . dc _id , inputLocation , $scope . fullPhoto . size ) ;
apiPromise = MtpApiFileManager . downloadFile ( $scope . fullPhoto . location . dc _id , inputLocation , $scope . fullPhoto . size ) ;
} else {
} else {
apiPromise = MtpApiFileManager . downloadSmallFile ( $scope . fullPhoto . location ) ;
apiPromise = MtpApiFileManager . downloadSmallFile ( $scope . fullPhoto . location ) ;
}
}
$scope . progress = { enabled : true , percent : 1 } ;
$scope . progress = { enabled : true , percent : 0 } ;
apiPromise . then ( function ( url ) {
apiPromise . then ( function ( url ) {
$scope . progress . enabled = false ;
if ( curJump == jump ) {
imgElement
$scope . progress . enabled = false ;
. attr ( 'src' , url )
imgElement . src = url ;
. removeClass ( 'thumb_blurred' ) ;
resize ( ) ;
}
} , function ( e ) {
console . log ( 'Download image failed' , e , $scope . fullPhoto . location ) ;
$scope . progress . enabled = false ;
} , function ( e ) {
if ( e && e . type == 'FS_BROWSER_UNSUPPORTED' ) {
console . log ( 'Download image failed' , e , $scope . fullPhoto . location ) ;
$scope . error = { html : 'Your browser doesn\'t support <a href="https://developer.mozilla.org/en-US/docs/Web/API/LocalFileSystem" target="_blank">LocalFileSystem</a> feature which is needed to display this image.<br/>Please, install <a href="http://google.com/chrome" target="_blank">Google Chrome</a> or use <a href="https://telegram.org/" target="_blank">mobile app</a> instead.' } ;
$scope . progress . enabled = false ;
} else {
$scope . error = { text : 'Download failed' , error : e } ;
}
} , function ( progress ) {
$scope . progress . percent = Math . max ( 1 , Math . floor ( 100 * progress . done / progress . total ) ) ;
} ) ;
} )
if ( e && e . type == 'FS_BROWSER_UNSUPPORTED' ) {
resize ( ) ;
$scope . error = { html : 'Your browser doesn\'t support <a href="https://developer.mozilla.org/en-US/docs/Web/API/LocalFileSystem" target="_blank">LocalFileSystem</a> feature which is needed to display this image.<br/>Please, install <a href="http://google.com/chrome" target="_blank">Google Chrome</a> or use <a href="https://telegram.org/" target="_blank">mobile app</a> instead.' } ;
} else {
$scope . error = { text : 'Download failed' , error : e } ;
}
} , function ( progress ) {
$scope . progress . percent = Math . max ( 1 , Math . floor ( 100 * progress . done / progress . total ) ) ;
} ) ;
}
}
} )
} )
@ -771,9 +785,7 @@ angular.module('myApp.directives', ['myApp.filters'])
< div class = "img_fullsize_progress_overlay" ng - show = "progress.enabled" > \
< div class = "img_fullsize_progress_overlay" ng - show = "progress.enabled" > \
< div class = "img_fullsize_progress_wrap" ng - style = "{width: video.full.width + \'px\', height: video.full.height + \'px\'}" > \
< div class = "img_fullsize_progress_wrap" ng - style = "{width: video.full.width + \'px\', height: video.full.height + \'px\'}" > \
< div class = "img_fullsize_progress progress tg_progress" > \
< div class = "img_fullsize_progress progress tg_progress" > \
< div class = "progress-bar progress-bar-success" role = "progressbar" aria - valuenow = "{{progress.percent}}" aria - valuemin = "0" aria - valuemax = "100" style = "width: {{progress.percent}}%" > \
< div class = "progress-bar progress-bar-success" style = "width: {{progress.percent}}%" > < / d i v > \
< span class = "sr-only" > { { progress . percent } } % Complete ( success ) < / s p a n > \
< / d i v > \
< / d i v > \
< / d i v > \
< / d i v > \
< / d i v > \
< / d i v > \
< / d i v > \
@ -975,6 +987,44 @@ angular.module('myApp.directives', ['myApp.filters'])
} )
} )
. directive ( 'myModalNav' , function ( ) {
return {
link : link
} ;
function link ( $scope , element , attrs ) {
var onKeyDown = function ( event ) {
var target = event . target ;
if ( target && ( target . tagName == 'INPUT' || target . tagName == 'TEXTAREA' ) ) {
return false ;
}
switch ( event . keyCode ) {
case 39 : // right
case 32 : // space
case 34 : // pg down
case 40 : // down
$scope . $eval ( attrs . next ) ;
break ;
case 37 : // left
case 33 : // pg up
case 38 : // up
$scope . $eval ( attrs . prev ) ;
break ;
}
} ;
$ ( document ) . on ( 'keydown' , onKeyDown ) ;
$scope . $on ( '$destroy' , function ( ) {
$ ( document ) . off ( 'keydown' , onKeyDown ) ;
} ) ;
} ;
} )
. directive ( 'myModalPosition' , function ( $window , $timeout ) {
. directive ( 'myModalPosition' , function ( $window , $timeout ) {
@ -993,9 +1043,12 @@ angular.module('myApp.directives', ['myApp.filters'])
} else {
} else {
$ ( element [ 0 ] . parentNode ) . css ( 'marginTop' , '' ) ;
$ ( element [ 0 ] . parentNode ) . css ( 'marginTop' , '' ) ;
}
}
$timeout ( function ( ) {
$ ( element [ 0 ] . parentNode ) . addClass ( 'modal-content-animated' ) ;
if ( attrs . animation != 'no' ) {
} , 300 ) ;
$timeout ( function ( ) {
$ ( element [ 0 ] . parentNode ) . addClass ( 'modal-content-animated' ) ;
} , 300 ) ;
}
} ;
} ;
onContentLoaded ( updateMargin ) ;
onContentLoaded ( updateMargin ) ;