fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-12-22 10:12 am

[dw-free] Revamp /update

[commit: http://hg.dwscoalition.org/dw-free/rev/1989803b06cf]

http://bugs.dwscoalition.org/show_bug.cgi?id=2524

Make input to "post as another user" update the form fields the same way
that posting as yourself does. (Incl: tags, updated text on the post to
button, access list dropdown terminology used.

Patch by [personal profile] fu.

Files modified:
  • htdocs/js/jquery.postform.js
--------------------------------------------------------------------------------
diff -r a3195e4a564a -r 1989803b06cf htdocs/js/jquery.postform.js
--- a/htdocs/js/jquery.postform.js	Thu Dec 22 18:09:27 2011 +0800
+++ b/htdocs/js/jquery.postform.js	Thu Dec 22 18:12:05 2011 +0800
@@ -42,7 +42,7 @@
         $select.change(update_icon_preview);
 
         $("#post_entry").bind( "journalselect", function( e, journal ) {
-            if ( journal.name ) {
+            if ( journal.name && journal.isremote ) {
                 $("#icons_component").not(".inactive_component").slideDown()
             } else {
                 $("#icons_component").not(".inactive_component").slideUp()
@@ -266,10 +266,18 @@
                 journal = $this.val();
                 iscomm = journal !== $.trim($("#post_as_remote").next("label").text());
             }
-            $(this).trigger( "journalselect", {"name":journal, "iscomm":iscomm});
+            $(this).trigger( "journalselect", {"name":journal, "iscomm":iscomm, isremote: true});
+        });
+        $("#postas_usejournal, #post_username").change(function() {
+            var journal, iscomm;
+            var postas = $.trim($("#post_username").val());
+            journal = $.trim($("#postas_usejournal").val()) || postas;
+            iscomm = journal !== postas;
+            console.log(journal, postas)
+            $(this).trigger( "journalselect", {"name":journal, "iscomm":iscomm, isremote: false});
         });
         $("#post_as_other").click(function() {
-            $("#post_entry").trigger( "journalselect", { name: undefined, iscomm: false } );
+            $("#post_entry").trigger( "journalselect", { name: undefined, iscomm: false, isremote: true } );
         })
         $("#post_as_remote").click(function() {
             $("#usejournal").triggerHandler("change");
@@ -340,7 +348,7 @@
 
         $("#post_entry").bind( "journalselect", function(e, journal) {
             var anon = ! journal.name
-            if ( anon || journal.iscomm )
+            if ( anon || journal.iscomm || ! journal.isremote )
                 $("#custom_access_groups").slideUp();
 
             var $security = $("#security");
@@ -359,7 +367,7 @@
         $("#crosspost_component").crosspost();
 
         $("#post_entry").bind("journalselect", function(e, journal) {
-            if ( journal.name )
+            if ( journal.name && journal.isremote )
                 $("#crosspost_component").crosspost("toggle", "community", ! journal.iscomm, true);
             else
                 $("#crosspost_component").crosspost("toggle", "unknown", false, true);
@@ -440,7 +448,7 @@
         $("#usejournal").triggerHandler("change");
     } else {
         // not logged in and no usejournal
-        $("#post_entry").trigger( "journalselect", { name: undefined, iscomm: false } );
+        $("#post_entry").trigger( "journalselect", { name: undefined, iscomm: false, isremote: true } );
     }
 } }
 })(jQuery);
--------------------------------------------------------------------------------