From ad096b80a1231c7b6d6b9b193209a34055e8d207 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 25 Aug 2019 17:24:22 +0200 Subject: [PATCH] refactoring logic, to make intention more clear and reduce complexity --- js/privatebin.js | 30 +++++++++++++++--------------- tpl/bootstrap.php | 2 +- tpl/page.php | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/js/privatebin.js b/js/privatebin.js index 6c69191..6cde5dc 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -2145,6 +2145,18 @@ jQuery.PrivateBin = (function($, RawDeflate) { 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 * @@ -2221,18 +2233,6 @@ jQuery.PrivateBin = (function($, RawDeflate) { return $message.val(); }; - /** - * returns if status is editing - * - * @name Editor.isEditing - * @function - * @return {bool} - */ - me.isEditing = function() - { - return !$message.hasClass('hidden'); - }; - /** * init status manager * @@ -2855,7 +2855,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { evt.stopPropagation(); evt.preventDefault(); - if (!Editor.isEditing()) { + if (Editor.isHidden()) { return false; } @@ -2873,7 +2873,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { $(document).draghover().on({ 'draghoverstart': function(e) { - if (!Editor.isEditing()) { + if (Editor.isHidden()) { e.stopPropagation(); e.preventDefault(); return false; @@ -2903,7 +2903,7 @@ jQuery.PrivateBin = (function($, RawDeflate) { */ function addClipboardEventHandler() { $(document).on('paste', function (event) { - if (!Editor.isEditing()) { + if (Editor.isHidden()) { event.stopPropagation(); event.preventDefault(); return false; diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index c685de2..6d2faba 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -71,7 +71,7 @@ if ($MARKDOWN): endif; ?> - + diff --git a/tpl/page.php b/tpl/page.php index ee7bf25..30ec6e7 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -49,7 +49,7 @@ if ($MARKDOWN): endif; ?> - +