Browse files

Support for several activity_forms tabs. First steps.

  • Loading branch information...
1 parent 05770b7 commit 3d9a7c34191764eed2ee6bb2f67b337767325582 @VictorSB VictorSB committed Jun 20, 2011
View
12 app/assets/stylesheets/base.css
@@ -192,3 +192,15 @@ textarea.new_contact_text_area{ width:100%; height: 100px; color: #2A3890;}
padding: 0px;
}
+.activities_title_header{
+ padding: 2px;
+ margin-right: 10px;
+ margin-bottom: 5px;
+ cursor: pointer;
+ float: left;
+ border: 2px solid transparent;
+}
+
+.activities_title_header.selected{
+ border: 2px solid #46B9E8;
+}
View
11 app/views/activities/_index.html.erb
@@ -10,7 +10,14 @@
<div id="wrapper_activities">
<div id="wrapper_activities_header">
<div id="activities_title" class="content_size">
- <%= image_tag("btn/btn_activities.png") %> <%=t('activity.other')%>
+ <div id="header_post" class="activities_title_header">
+ <%= image_tag("btn/btn_activities.png") %> <%=t('activity.other')%>
+ </div>
+ <% SocialStream.activity_forms.each do |element| %>
+ <div id="header_<%= element %>" class="activities_title_header">
+ <%= image_tag("btn/"+element.to_s+".png") %> <%=t(element.to_s+'.title')%>
+ </div>
+ <% end %>
</div>
<%= render :partial => 'activities/new', :locals => { :receiver => owner } %>
</div>
@@ -19,4 +26,4 @@
<%= render activities %>
<%= paginate activities %>
</div>
-</div>
+</div>
View
19 app/views/activities/_jquery.html.erb
@@ -1,9 +1,26 @@
+//initial state
+$('#wrapper_activities_header form').hide();
+$('#new_post').show();
+
+//clicks on headers
+$('.activities_title_header').live('click',function(){
+ $('.activities_title_header').removeClass('selected');
+ $(this).addClass('selected');
+ $('#wrapper_activities_header form').hide();
+ $('#new_'+this.id.split("_")[1]).show();
+});
+
+//submit
+$('#masterSubmitButton').live('click',function(){
+ $('#wrapper_activities_header form:visible').submit();
+});
+
//javascript for main activities input
title = "<%= t('activity.input') %>";
$("#input_activities").click(function(){
if(this.value == title){
this.value="";
- $("#activities_share_btn").show();
+ $("#masterSubmitButton").show();
}
});
View
26 app/views/activities/_new.html.erb
@@ -1,4 +1,4 @@
-<% if user_signed_in? && current_subject.activity_ties_to?(receiver) %>
+<% if current_subject.activity_ties_to?(receiver) %>
<% content_for :javascript do %>
securityImage = "<%= escape_javascript(image_tag('btn/btn_security.png', :id => 'security_image', :alt => 'security')) %>";
@@ -7,26 +7,34 @@
$("#security").dropdownchecklist( { closeRadioOnClick: true } );
$("#security_image").parent().width(28);
$("#security_image").parent().parent().width(28);
+ $('#security').change(function() {
+ $('input[name*="_activity_tie_id"]').val($('#security').attr("value"));
+ });
<% end %>
<div id="activities_header" class="content_size">
<%= form_for Post.new(:text => t('activity.input'),
:_activity_tie_id => current_subject.activity_ties_to(receiver).first.id),
:remote => true do |f| %>
<%= f.text_field :text, :id => "input_activities", :size => 85 %>
- <div id="activities_share_btn">
-
+ <%= f.hidden_field :_activity_tie_id %>
+ <!--<div id="activities_share_btn">
<% if current_subject.activity_ties_to(receiver).count > 1 %>
<div id="securities">
- <%= f.select :_activity_tie_id,
- grouped_options_for_select(current_subject.grouped_activity_ties_to(receiver)),
- {}, :id => 'security' %>
+ <%= f.select :_activity_tie_id, current_subject.activity_ties_to(receiver).sort{ |t, u| t.relation <=> u.relation }.map{ |t| [ t.relation_name, t.id ] }, {}, :id => 'security' %>
</div>
<% else %>
<%= f.hidden_field :_activity_tie_id %>
<% end %>
<%= f.submit t('share'), :class =>"myButtonBlue" %>
- </div>
- <% end -%>
- </div>
+ </div>-->
+</div>
+<% end %><!-- END OF FORM -->
+
+<%= render :partial => 'attachments/new', :locals =>{:a_tie_id => current_subject.activity_ties_to(receiver).first.id} %>
+
+<div id="activities_share_btn">
+<div id="securities"><%= select_tag :_activity_tie_id, options_for_select(current_subject.activity_ties_to(receiver).sort{ |t, u| t.relation <=> u.relation }.map{ |t| [ t.relation_name, t.id ] }), :id => 'security' %></div>
+<%= submit_tag(t('share'), :class => "myButtonBlue", :id => "masterSubmitButton") %>
+</div>
<% end %>
View
4 app/views/posts/create.js.erb
@@ -2,4 +2,6 @@
$("#input_activities").val("<%= t('activity.input') %>");
//Display the new post
$("#wall").prepend("<%= escape_javascript(render @post.post_activity) %>");
-$("#activities_share_btn").hide();
+
+// TEMPORARY FIX
+//$("#activities_share_btn").hide();
View
3 lib/generators/social_stream/base/templates/initializer.rb
@@ -15,4 +15,7 @@
# Remember you must add an "activity_object_id" foreign key column to your migration!
#
# config.objects = [ :post, :comment ]
+
+ # Form modules to be loaded
+ # config.activity_forms = [ :attachment, :other_module, :foo, :bar ]
end
View
4 lib/social_stream-base.rb
@@ -61,6 +61,10 @@ module TestHelpers
mattr_writer :objects
@@objects = [ :post, :comment ]
+ mattr_accessor :activity_forms
+ #@@activity_forms = [:attachment]
+ @@activity_forms = []
+
class << self
def setup
yield self

0 comments on commit 3d9a7c3

Please sign in to comment.