Refactor attachment editable logic to avoid undesired assumption

This commit is contained in:
Haocen Xu 2019-08-25 12:00:59 -04:00
parent e242d87427
commit 00b886c492
No known key found for this signature in database
GPG Key ID: 3F0D955A0F6AD729
1 changed files with 15 additions and 15 deletions

View File

@ -2145,18 +2145,6 @@ jQuery.PrivateBin = (function($, RawDeflate) {
return isPreview; return isPreview;
}; };
/**
* gets the visibility of the editor
*
* @name Editor.isHidden
* @function
* @return {bool}
*/
me.isHidden = function()
{
return $message.hasClass('hidden');
};
/** /**
* reset the Editor view * reset the Editor view
* *
@ -2855,7 +2843,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
evt.stopPropagation(); evt.stopPropagation();
evt.preventDefault(); evt.preventDefault();
if (Editor.isHidden()) { if (TopNav.isAttachmentReadonly()) {
return false; return false;
} }
@ -2873,7 +2861,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
$(document).draghover().on({ $(document).draghover().on({
'draghoverstart': function(e) { 'draghoverstart': function(e) {
if (Editor.isHidden()) { if (TopNav.isAttachmentReadonly()) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
return false; return false;
@ -2903,7 +2891,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
*/ */
function addClipboardEventHandler() { function addClipboardEventHandler() {
$(document).on('paste', function (event) { $(document).on('paste', function (event) {
if (Editor.isHidden()) { if (TopNav.isAttachmentReadonly()) {
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
return false; return false;
@ -3845,6 +3833,18 @@ jQuery.PrivateBin = (function($, RawDeflate) {
$formatter.parent().find(`a[data-format="${format}"]`).click(); $formatter.parent().find(`a[data-format="${format}"]`).click();
} }
/**
* returns if attachment dropdown is readonly, not editable
*
* @name TopNav.isAttachmentReadonly
* @function
* @return {bool}
*/
me.isAttachmentReadonly = function()
{
return $attach.hasClass('hidden');
}
/** /**
* init navigation manager * init navigation manager
* *