You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ke...@apache.org on 2018/03/28 19:35:22 UTC

allura git commit: [#8196] Better handle inputs that are hidden initially; additional clarifying comments

Repository: allura
Updated Branches:
  refs/heads/kt/8196 e5aad89e3 -> 83da622e2


[#8196] Better handle inputs that are hidden initially; additional clarifying comments


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/83da622e
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/83da622e
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/83da622e

Branch: refs/heads/kt/8196
Commit: 83da622e2050479942726521e5f2c7d102e28d91
Parents: e5aad89
Author: Kenton Taylor <kt...@slashdotmedia.com>
Authored: Wed Mar 28 15:34:57 2018 -0400
Committer: Kenton Taylor <kt...@slashdotmedia.com>
Committed: Wed Mar 28 15:34:57 2018 -0400

----------------------------------------------------------------------
 Allura/allura/controllers/discuss.py                |  1 +
 Allura/allura/lib/widgets/discuss.py                |  1 +
 .../allura/lib/widgets/resources/js/sf_markitup.js  |  1 -
 Allura/allura/public/nf/js/memorable.js             | 16 ++++++++++++++--
 4 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/83da622e/Allura/allura/controllers/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/discuss.py b/Allura/allura/controllers/discuss.py
index d1a798f..b91e213 100644
--- a/Allura/allura/controllers/discuss.py
+++ b/Allura/allura/controllers/discuss.py
@@ -340,6 +340,7 @@ class PostController(BaseController):
     def error_handler(self, *args, **kwargs):
         redirect(request.referer)
 
+    @memorable_forget()
     @h.vardec
     @expose()
     @require_post()

http://git-wip-us.apache.org/repos/asf/allura/blob/83da622e/Allura/allura/lib/widgets/discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/discuss.py b/Allura/allura/lib/widgets/discuss.py
index 7afdac4..98f0085 100644
--- a/Allura/allura/lib/widgets/discuss.py
+++ b/Allura/allura/lib/widgets/discuss.py
@@ -393,6 +393,7 @@ class Post(HierWidget):
                         var cm = get_cm($reply_post_form);
                         $reply_post_form.show();
                         cm.focus();
+                       $('form', $reply_post_form).trigger('replyRevealed');
                     });
                 }
                 if($('.add_attachment', post)){

http://git-wip-us.apache.org/repos/asf/allura/blob/83da622e/Allura/allura/lib/widgets/resources/js/sf_markitup.js
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/resources/js/sf_markitup.js b/Allura/allura/lib/widgets/resources/js/sf_markitup.js
index 3c99caa..cfc7c3f 100644
--- a/Allura/allura/lib/widgets/resources/js/sf_markitup.js
+++ b/Allura/allura/lib/widgets/resources/js/sf_markitup.js
@@ -57,7 +57,6 @@ $(window).load(function() {
               autofocus: false,
               spellChecker: false, // https://forge-allura.apache.org/p/allura/tickets/7954/
               indentWithTabs: false,
-              autosave: true,
               tabSize: 4,
               toolbar: toolbar,
               previewRender: previewRender,

http://git-wip-us.apache.org/repos/asf/allura/blob/83da622e/Allura/allura/public/nf/js/memorable.js
----------------------------------------------------------------------
diff --git a/Allura/allura/public/nf/js/memorable.js b/Allura/allura/public/nf/js/memorable.js
index a9000a0..120a2dd 100644
--- a/Allura/allura/public/nf/js/memorable.js
+++ b/Allura/allura/public/nf/js/memorable.js
@@ -7,7 +7,10 @@ window.Memorable = {};
 Memorable.InputManager = (function(){
 
     var defaults = {
+        // regex to determine if an input's name can't reliably identify it, as many inputs have randomized
+        // names for antispam purposes.
         invalidInputName: /([A-Za-z0-9\-_]{28})/,
+        // selectors of buttons that represent a user cancellation, and will clear remembered inputs in the form
         cancelSelectors: '.cancel_edit_post, .cancel_form'
     };
 
@@ -17,7 +20,6 @@ Memorable.InputManager = (function(){
      */
     function InputManager(inputObj, options){
         this.options = $.extend({}, defaults, options);
-
         this.inputObj = inputObj;
         this.$form = this.inputObj.getForm();
 
@@ -26,6 +28,11 @@ Memorable.InputManager = (function(){
 
         //watch "cancel"-style links, to forget immediately
         $(this.options.cancelSelectors, this.$form).on('click', this.handleCancel.bind(this));
+
+        //watch for hidden inputs that might be revealed
+        this.$form.on('replyRevealed', this.inputObj.refresh.bind(this.inputObj));
+
+        //restore from localStorage
         this.restore();
     }
 
@@ -125,7 +132,6 @@ Memorable.InputManager = (function(){
         this.inputObj.setValue(this.storedValue());
     };
 
-
     return InputManager;
 })();
 
@@ -159,6 +165,9 @@ Memorable.InputBasic = (function() {
     InputBasic.prototype.getForm = function () {
         return this.$el.parents('form').eq(0);
     };
+    InputBasic.prototype.refresh = function(){
+        return null;  // noop
+    };
     return InputBasic;
 })();
 
@@ -192,6 +201,9 @@ Memorable.InputMDE = (function() {
     InputMDE.prototype.getForm = function () {
         return this.$el.parents('form').eq(0);
     };
+    InputMDE.prototype.refresh = function(){
+        this.watchObj.refresh();
+    };
     return InputMDE;
 })();