@ -329,6 +329,9 @@ define([
}
}
// warning about sharing links
// warning about sharing links
// when sharing a version hash, there is a similar warning and we want
// to avoid alert fatigue
if ( ! opts . versionHash ) {
var localStore = window . cryptpadStore ;
var localStore = window . cryptpadStore ;
var dismissButton = h ( 'span.fa.fa-times' ) ;
var dismissButton = h ( 'span.fa.fa-times' ) ;
var shareLinkWarning = h ( 'div.alert.alert-warning.dismissable' ,
var shareLinkWarning = h ( 'div.alert.alert-warning.dismissable' ,
@ -349,6 +352,7 @@ define([
} ) ;
} ) ;
} ) ;
} ) ;
}
// Burn after reading
// Burn after reading
if ( opts . barAlert ) { linkContent . push ( opts . barAlert . cloneNode ( true ) ) ; }
if ( opts . barAlert ) { linkContent . push ( opts . barAlert . cloneNode ( true ) ) ; }
@ -460,7 +464,8 @@ define([
var pathname = opts . pathname ;
var pathname = opts . pathname ;
var parsed = Hash . parsePadUrl ( pathname ) ;
var parsed = Hash . parsePadUrl ( pathname ) ;
var canPresent = [ 'code' , 'slide' ] . indexOf ( parsed . type ) !== - 1 ;
var canPresent = [ 'code' , 'slide' ] . indexOf ( parsed . type ) !== - 1 ;
var canBAR = parsed . type !== 'drive' ;
var versionHash = hashes . viewHash && opts . versionHash ;
var canBAR = parsed . type !== 'drive' && ! versionHash ;
var burnAfterReading = ( hashes . viewHash && canBAR ) ?
var burnAfterReading = ( hashes . viewHash && canBAR ) ?
UI . createRadio ( 'accessRights' , 'cp-share-bar' , Messages . burnAfterReading _linkBurnAfterReading , false , {
UI . createRadio ( 'accessRights' , 'cp-share-bar' , Messages . burnAfterReading _linkBurnAfterReading , false , {
@ -519,6 +524,12 @@ define([
var embed = val . embed ;
var embed = val . embed ;
var present = val . present !== undefined ? val . present : Util . isChecked ( $rights . find ( '#cp-share-present' ) ) ;
var present = val . present !== undefined ? val . present : Util . isChecked ( $rights . find ( '#cp-share-present' ) ) ;
var burnAfterReading = Util . isChecked ( $rights . find ( '#cp-share-bar' ) ) ;
var burnAfterReading = Util . isChecked ( $rights . find ( '#cp-share-bar' ) ) ;
if ( versionHash ) {
edit = false ;
embed = false ;
present = false ;
burnAfterReading = false ;
}
if ( burnAfterReading && ! opts . burnAfterReadingUrl ) {
if ( burnAfterReading && ! opts . burnAfterReadingUrl ) {
if ( cb ) { // Called from the contacts tab, "share" button
if ( cb ) { // Called from the contacts tab, "share" button
var barHref = origin + pathname + '#' + ( hashes . viewHash || hashes . editHash ) ;
var barHref = origin + pathname + '#' + ( hashes . viewHash || hashes . editHash ) ;
@ -533,7 +544,7 @@ define([
var href = burnAfterReading ? opts . burnAfterReadingUrl
var href = burnAfterReading ? opts . burnAfterReadingUrl
: ( origin + pathname + '#' + hash ) ;
: ( origin + pathname + '#' + hash ) ;
var parsed = Hash . parsePadUrl ( href ) ;
var parsed = Hash . parsePadUrl ( href ) ;
return origin + parsed . getUrl ( { embed : embed , present : present }) ;
return origin + parsed . getUrl ( { embed : embed , present : present , versionHash : versionHash }) ;
} ;
} ;
opts . getEmbedValue = function ( ) {
opts . getEmbedValue = function ( ) {
var url = opts . getLinkValue ( {
var url = opts . getLinkValue ( {
@ -543,7 +554,11 @@ define([
} ;
} ;
// disable edit share options if you don't have edit rights
// disable edit share options if you don't have edit rights
if ( ! hashes . editHash ) {
if ( versionHash ) {
$rights . find ( '#cp-share-editable-false' ) . attr ( 'checked' , true ) ;
$rights . find ( '#cp-share-present' ) . removeAttr ( 'checked' ) . attr ( 'disabled' , true ) ;
$rights . find ( '#cp-share-editable-true' ) . removeAttr ( 'checked' ) . attr ( 'disabled' , true ) ;
} else if ( ! hashes . editHash ) {
$rights . find ( '#cp-share-editable-false' ) . attr ( 'checked' , true ) ;
$rights . find ( '#cp-share-editable-false' ) . attr ( 'checked' , true ) ;
$rights . find ( '#cp-share-editable-true' ) . removeAttr ( 'checked' ) . attr ( 'disabled' , true ) ;
$rights . find ( '#cp-share-editable-true' ) . removeAttr ( 'checked' ) . attr ( 'disabled' , true ) ;
} else if ( ! hashes . viewHash ) {
} else if ( ! hashes . viewHash ) {
@ -582,7 +597,9 @@ define([
// Set default values
// Set default values
common . getAttribute ( [ 'general' , 'share' ] , function ( err , val ) {
common . getAttribute ( [ 'general' , 'share' ] , function ( err , val ) {
val = val || { } ;
val = val || { } ;
if ( val . present && canPresent ) {
if ( versionHash ) {
$rights . find ( '#cp-share-editable-false' ) . prop ( 'checked' , true ) ;
} else if ( val . present && canPresent ) {
$rights . find ( '#cp-share-editable-false' ) . prop ( 'checked' , false ) ;
$rights . find ( '#cp-share-editable-false' ) . prop ( 'checked' , false ) ;
$rights . find ( '#cp-share-editable-true' ) . prop ( 'checked' , false ) ;
$rights . find ( '#cp-share-editable-true' ) . prop ( 'checked' , false ) ;
$rights . find ( '#cp-share-present' ) . prop ( 'checked' , true ) ;
$rights . find ( '#cp-share-present' ) . prop ( 'checked' , true ) ;
@ -671,9 +688,22 @@ define([
onHide : resetTab
onHide : resetTab
} ] ;
} ] ;
Modal . getModal ( common , opts , tabs , function ( err , modal ) {
Modal . getModal ( common , opts , tabs , function ( err , modal ) {
$ ( modal ) . find ( '.cp-bar' ) . hide ( ) ;
// Hide the burn-after-reading option by default
var $modal = $ ( modal ) ;
$modal . find ( '.cp-bar' ) . hide ( ) ;
// Prepend the "rights" radio selection
// Prepend the "rights" radio selection
$ ( modal ) . find ( '.alertify-tabs-titles' ) . after ( $rights ) ;
$modal . find ( '.alertify-tabs-titles' ) . after ( $rights ) ;
// Add the versionHash warning if needed
if ( opts . versionHash ) {
Messages . share _versionHash = "You're going to share the selected history version of the document in read-only mode. This will also <b>give view access</b> to the recipients." ; // XXX
$rights . after ( h ( 'div.alert.alert-warning' , [
h ( 'i.fa.fa-history' ) ,
UI . setHTML ( h ( 'span' ) , Messages . share _versionHash )
] ) ) ;
}
// callback
// callback
cb ( err , modal ) ;
cb ( err , modal ) ;
} ) ;
} ) ;