From 53bdb2cade8261a4a90e6a5a538f8333a97e90b0 Mon Sep 17 00:00:00 2001
From: MrZYX <pr0fkill@gmail.com>
Date: Wed, 30 Mar 2011 17:07:15 +0200
Subject: [PATCH] clean up stray hidden input tags by passing the data directly
 into the js where possible and placing them under an existing form tag
 elsewhere

---
 app/views/aspects/_aspect_listings.haml         | 2 --
 app/views/conversations/new.haml                | 3 +--
 app/views/profiles/_edit_public.html.haml       | 5 ++---
 app/views/shared/_publisher.html.haml           | 2 ++
 app/views/status_messages/bookmarklet.html.haml | 1 -
 5 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/app/views/aspects/_aspect_listings.haml b/app/views/aspects/_aspect_listings.haml
index 0ca141cbee..33d410d93b 100644
--- a/app/views/aspects/_aspect_listings.haml
+++ b/app/views/aspects/_aspect_listings.haml
@@ -2,8 +2,6 @@
 -#   licensed under the Affero General Public License version 3 or later.  See
 -#   the COPYRIGHT file.
 
-= hidden_field_tag :contact_json, @selected_contacts.map{|contact| contact.person}.to_json
-
 %h4
   .right
     = link_to t('contacts', :count => @contact_count), manage_aspects_path, :title => t('aspects.manage.manage_aspects')
diff --git a/app/views/conversations/new.haml b/app/views/conversations/new.haml
index 76e1ec1228..1155a7c3d1 100644
--- a/app/views/conversations/new.haml
+++ b/app/views/conversations/new.haml
@@ -4,7 +4,7 @@
 
 :javascript
   $(document).ready(function () {
-    var data = $.parseJSON( $('#contact_json').val() ),
+    var data = $.parseJSON( '#{@all_contacts_and_ids.to_json}' ),
         autocompleteInput = $("#contact_autocomplete");
 
     autocompleteInput.autoSuggest(data, {
@@ -23,7 +23,6 @@
     autocompleteInput.focus();
   });
 
-= hidden_field_tag :contact_json, @all_contacts_and_ids.to_json
 
 #new_message_pane
   .span-12.last
diff --git a/app/views/profiles/_edit_public.html.haml b/app/views/profiles/_edit_public.html.haml
index 2967f4d610..53976c1309 100644
--- a/app/views/profiles/_edit_public.html.haml
+++ b/app/views/profiles/_edit_public.html.haml
@@ -7,7 +7,7 @@
 
 :javascript
   $(document).ready(function () {
-    var data = $.parseJSON( $('#tags_json').val() ),
+    var data = $.parseJSON( '#{@tags_array.to_json}' ),
         autocompleteInput = $("#profile_tag_string");
 
 
@@ -22,7 +22,7 @@
       minChars: 2,
       keyDelay: 0,
       startText: "#{t('profiles.edit.your_tags_placeholder')}",
-      emptyText: '#{t('no_results')}',
+      emptyText: "#{t('no_results')}",
       preFill: data
       });
 
@@ -36,7 +36,6 @@
   });
 
 
-= hidden_field_tag :tags_json, @tags_array.to_json
 %h3
   = t('profiles.edit.your_public_profile')
 
diff --git a/app/views/shared/_publisher.html.haml b/app/views/shared/_publisher.html.haml
index 00b8e17f31..3bab72762d 100644
--- a/app/views/shared/_publisher.html.haml
+++ b/app/views/shared/_publisher.html.haml
@@ -20,6 +20,8 @@
 
   .content_creation
     = form_for(StatusMessage.new, :remote => true, :html => {"data-type" => "json"}) do |status|
+      - if @selected_contacts
+        = hidden_field_tag :contact_json, @selected_contacts.map{|contact| contact.person}.to_json
       = status.error_messages
       #file-upload
         = image_tag 'icons/photos.png'
diff --git a/app/views/status_messages/bookmarklet.html.haml b/app/views/status_messages/bookmarklet.html.haml
index 6df5ed922a..e25248aa4b 100644
--- a/app/views/status_messages/bookmarklet.html.haml
+++ b/app/views/status_messages/bookmarklet.html.haml
@@ -31,7 +31,6 @@
   });
 
 #new_status_message_pane
-  = hidden_field_tag :contact_json, @selected_contacts.map{|contact| contact.person}.to_json
   .span-15.last
     #facebox_header
       %h4
-- 
GitLab