@ -17,11 +17,18 @@ define([
var Nacl = window . nacl ;
// Configure MediaTags to use our local viewer
// This file is loaded by sframe-common so the following config is used in all the inner apps
if ( MediaTag ) {
MediaTag . setDefaultConfig ( 'pdf' , {
viewer : '/common/pdfjs/web/viewer.html'
} ) ;
Messages . mediatag _saveButton = "Save" ; // XXX
MediaTag . setDefaultConfig ( 'download' , {
text : Messages . download _mt _button ,
textDl : Messages . mediatag _saveButton
} ) ;
}
MT . MediaTag = MediaTag ;
// Cache of the avatars outer html (including <media-tag>)
var avatars = { } ;
@ -68,7 +75,7 @@ define([
childList : true ,
characterData : false
} ) ;
MediaTag ( $tag [ 0 ] ). on ( 'error' , function ( data ) {
MediaTag ( $tag [ 0 ] , { force : true } ). on ( 'error' , function ( data ) {
console . error ( data ) ;
} ) ;
} ;
@ -362,6 +369,10 @@ define([
} ) ;
} ;
Messages . pad _mediatagShare = "Share file" ; // XXX
Messages . pad _mediatagOpen = "Open file" ; // XXX
Messages . mediatag _notReady = "Not ready" ; // XXX
var mediatagContextMenu ;
MT . importMediaTagMenu = function ( common ) {
if ( mediatagContextMenu ) { return mediatagContextMenu ; }
@ -377,6 +388,14 @@ define([
'tabindex' : '-1' ,
'data-icon' : "fa-eye" ,
} , Messages . pad _mediatagPreview ) ) ,
h ( 'li.cp-svg' , h ( 'a.cp-app-code-context-openin.dropdown-item' , {
'tabindex' : '-1' ,
'data-icon' : "fa-external-link" ,
} , Messages . pad _mediatagOpen ) ) ,
h ( 'li.cp-svg' , h ( 'a.cp-app-code-context-share.dropdown-item' , {
'tabindex' : '-1' ,
'data-icon' : "fa-shhare-alt" ,
} , Messages . pad _mediatagShare ) ) ,
h ( 'li' , h ( 'a.cp-app-code-context-saveindrive.dropdown-item' , {
'tabindex' : '-1' ,
'data-icon' : "fa-cloud-upload" ,
@ -413,12 +432,29 @@ define([
}
else if ( $this . hasClass ( "cp-app-code-context-download" ) ) {
var media = Util . find ( $mt , [ 0 , '_mediaObject' ] ) ;
if ( ! media ) { return void console . error ( 'no media' ) ; }
if ( ! media . complete ) { return void UI . warn ( Messages . mediatag _notReady ) ; }
if ( ! ( media && media . _blob ) ) { return void console . error ( $mt ) ; }
window . saveAs ( media . _blob . content , media . name ) ;
}
else if ( $this . hasClass ( "cp-app-code-context-open" ) ) {
$mt . trigger ( 'preview' ) ;
}
else if ( $this . hasClass ( "cp-app-code-context-openin" ) ) {
var hash = common . getHashFromMediaTag ( $mt ) ;
common . openURL ( Hash . hashToHref ( hash , 'file' ) ) ;
}
else if ( $this . hasClass ( "cp-app-code-context-share" ) ) {
var data = {
file : true ,
pathname : '/file/' ,
hashes : {
fileHash : common . getHashFromMediaTag ( $mt )
} ,
title : Util . find ( $mt [ 0 ] , [ '_mediaObject' , 'name' ] ) || ''
} ;
common . getSframeChannel ( ) . event ( 'EV_SHARE_OPEN' , data ) ;
}
} ) ;
return m ;