Call removeAttachment on a new paste
Improved disabled attachments handling
This commit is contained in:
parent
23f5dfbff8
commit
838ca3d38e
|
@ -1594,8 +1594,10 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
|
|
||||||
// show preview
|
// show preview
|
||||||
PasteViewer.setText($message.val());
|
PasteViewer.setText($message.val());
|
||||||
|
if (AttachmentViewer.$attachment.length) {
|
||||||
var attachmentData = AttachmentViewer.attachmentData || AttachmentViewer.$attachmentLink.attr('href');
|
var attachmentData = AttachmentViewer.attachmentData || AttachmentViewer.$attachmentLink.attr('href');
|
||||||
AttachmentViewer.handleAttachmentPreview(AttachmentViewer.$attachmentPreview, attachmentData);
|
AttachmentViewer.handleAttachmentPreview(AttachmentViewer.$attachmentPreview, attachmentData);
|
||||||
|
}
|
||||||
PasteViewer.run();
|
PasteViewer.run();
|
||||||
|
|
||||||
// finish
|
// finish
|
||||||
|
@ -2037,6 +2039,9 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
*/
|
*/
|
||||||
me.removeAttachment = function()
|
me.removeAttachment = function()
|
||||||
{
|
{
|
||||||
|
if (!me.$attachment.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
me.hideAttachment();
|
me.hideAttachment();
|
||||||
me.hideAttachmentPreview();
|
me.hideAttachmentPreview();
|
||||||
me.$attachmentLink.prop('href', '');
|
me.$attachmentLink.prop('href', '');
|
||||||
|
@ -2070,8 +2075,10 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
*/
|
*/
|
||||||
me.hideAttachmentPreview = function()
|
me.hideAttachmentPreview = function()
|
||||||
{
|
{
|
||||||
|
if(me.$attachmentPreview){
|
||||||
me.$attachmentPreview.addClass('hidden');
|
me.$attachmentPreview.addClass('hidden');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if there is an attachment
|
* checks if there is an attachment
|
||||||
|
@ -2081,6 +2088,9 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
*/
|
*/
|
||||||
me.hasAttachment = function()
|
me.hasAttachment = function()
|
||||||
{
|
{
|
||||||
|
if (!AttachmentViewer.$attachment.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
var link = me.$attachmentLink.prop('href');
|
var link = me.$attachmentLink.prop('href');
|
||||||
return (typeof link !== 'undefined' && link !== '')
|
return (typeof link !== 'undefined' && link !== '')
|
||||||
}
|
}
|
||||||
|
@ -2299,12 +2309,14 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
me.init = function()
|
me.init = function()
|
||||||
{
|
{
|
||||||
me.$attachment = $('#attachment');
|
me.$attachment = $('#attachment');
|
||||||
|
if(me.$attachment.length){
|
||||||
me.$attachmentLink = $('#attachment a');
|
me.$attachmentLink = $('#attachment a');
|
||||||
me.$attachmentPreview = $('#attachmentPreview');
|
me.$attachmentPreview = $('#attachmentPreview');
|
||||||
|
|
||||||
me.$fileInput = $('#file');
|
me.$fileInput = $('#file');
|
||||||
me.addDragDropHandler();
|
me.addDragDropHandler();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return me;
|
return me;
|
||||||
})(window, document);
|
})(window, document);
|
||||||
|
@ -3913,11 +3925,13 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
try {
|
try {
|
||||||
// decrypt attachments
|
// decrypt attachments
|
||||||
if (paste.attachment) {
|
if (paste.attachment) {
|
||||||
|
if (AttachmentViewer.$attachment.length) {
|
||||||
// try to decrypt paste and if it fails (because the password is
|
// try to decrypt paste and if it fails (because the password is
|
||||||
// missing) return to let JS continue and wait for user
|
// missing) return to let JS continue and wait for user
|
||||||
if (!decryptAttachment(paste, key, password)) {
|
if (!decryptAttachment(paste, key, password)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// ignore empty paste, as this is allowed when pasting attachments
|
// ignore empty paste, as this is allowed when pasting attachments
|
||||||
decryptPaste(paste, key, password, true);
|
decryptPaste(paste, key, password, true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -3999,6 +4013,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
Editor.resetInput();
|
Editor.resetInput();
|
||||||
Editor.show();
|
Editor.show();
|
||||||
Editor.focusInput();
|
Editor.focusInput();
|
||||||
|
AttachmentViewer.removeAttachment();
|
||||||
|
|
||||||
TopNav.showCreateButtons();
|
TopNav.showCreateButtons();
|
||||||
Alert.hideLoading();
|
Alert.hideLoading();
|
||||||
|
|
|
@ -69,7 +69,7 @@ if ($MARKDOWN):
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-ofGEJHbk5slAxfzMIcULyZI7a4XcqdyTnATIZPbYv+Ngr+EEt7GZ2QXE8bjt1/Q9EuwQrjsMhiPeGlbaAGqFgA==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-pOe2H/Z6no88ilmHnSzSPrN5jYaj4B0VrxeVKHZ728CwUxNKwI8xIAUH+B/UPnKXgT33IV2EHbBIXYJERQxinA==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
|
@ -47,7 +47,7 @@ if ($MARKDOWN):
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-ofGEJHbk5slAxfzMIcULyZI7a4XcqdyTnATIZPbYv+Ngr+EEt7GZ2QXE8bjt1/Q9EuwQrjsMhiPeGlbaAGqFgA==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-pOe2H/Z6no88ilmHnSzSPrN5jYaj4B0VrxeVKHZ728CwUxNKwI8xIAUH+B/UPnKXgT33IV2EHbBIXYJERQxinA==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
Loading…
Reference in New Issue