Merge pull request #158 from dgilperez/issue-156
Añadir initial.js para mostrar Gmail-ish avatares - issue #156
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -30,6 +30,7 @@ gem 'simple_captcha2', require: 'simple_captcha'
|
|||||||
gem 'ckeditor'
|
gem 'ckeditor'
|
||||||
gem 'cancancan'
|
gem 'cancancan'
|
||||||
gem 'social-share-button'
|
gem 'social-share-button'
|
||||||
|
gem 'initialjs-rails'
|
||||||
gem 'unicorn'
|
gem 'unicorn'
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
@@ -61,4 +62,3 @@ end
|
|||||||
group :test do
|
group :test do
|
||||||
gem 'email_spec'
|
gem 'email_spec'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -140,6 +140,8 @@ GEM
|
|||||||
i18n
|
i18n
|
||||||
term-ansicolor (>= 1.3.2)
|
term-ansicolor (>= 1.3.2)
|
||||||
terminal-table (>= 1.5.1)
|
terminal-table (>= 1.5.1)
|
||||||
|
initialjs-rails (0.1.0)
|
||||||
|
railties (>= 3.1, < 5.0)
|
||||||
jquery-rails (4.0.4)
|
jquery-rails (4.0.4)
|
||||||
rails-dom-testing (~> 1.0)
|
rails-dom-testing (~> 1.0)
|
||||||
railties (>= 4.2.0)
|
railties (>= 4.2.0)
|
||||||
@@ -314,6 +316,7 @@ DEPENDENCIES
|
|||||||
factory_girl_rails
|
factory_girl_rails
|
||||||
foundation-rails
|
foundation-rails
|
||||||
i18n-tasks
|
i18n-tasks
|
||||||
|
initialjs-rails
|
||||||
jquery-rails
|
jquery-rails
|
||||||
launchy
|
launchy
|
||||||
letter_opener_web (~> 1.2.0)
|
letter_opener_web (~> 1.2.0)
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.0 KiB |
@@ -16,17 +16,20 @@
|
|||||||
//= require turbolinks
|
//= require turbolinks
|
||||||
//= require ckeditor/init
|
//= require ckeditor/init
|
||||||
//= require social-share-button
|
//= require social-share-button
|
||||||
|
//= require initial
|
||||||
//= require app
|
//= require app
|
||||||
//= require_tree .
|
//= require_tree .
|
||||||
|
|
||||||
var initialize_modules = function() {
|
var initialize_modules = function() {
|
||||||
App.Comments.initialize();
|
App.Comments.initialize();
|
||||||
|
App.Users.initialize();
|
||||||
App.Votes.initialize();
|
App.Votes.initialize();
|
||||||
};
|
};
|
||||||
|
|
||||||
$(function(){
|
$(function(){
|
||||||
$(document).foundation();
|
$(document).foundation();
|
||||||
|
|
||||||
$(document).ready(initialize_modules)
|
$(document).ready(initialize_modules);
|
||||||
$(document).on('page:load', initialize_modules)
|
$(document).on('page:load', initialize_modules);
|
||||||
|
$(document).on('ajax:complete', initialize_modules);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,7 +17,17 @@ App.Comments =
|
|||||||
$("#js-comment-form-#{id}").toggle()
|
$("#js-comment-form-#{id}").toggle()
|
||||||
|
|
||||||
initialize: ->
|
initialize: ->
|
||||||
$('body').on 'click', '.js-add-comment-link', ->
|
# $('body').on 'click', '.js-add-comment-link', ->
|
||||||
id = $(this).data().id
|
# id = $(this).data().id
|
||||||
App.Comments.toggle_form(id)
|
# App.Comments.toggle_form(id)
|
||||||
false
|
# false
|
||||||
|
#
|
||||||
|
$('body .js-add-comment-link').each ->
|
||||||
|
$this = $(this)
|
||||||
|
|
||||||
|
unless $this.data('initialized') is 'yes'
|
||||||
|
$this.on('click', ->
|
||||||
|
id = $(this).data().id
|
||||||
|
App.Comments.toggle_form(id)
|
||||||
|
false
|
||||||
|
).data 'initialized', 'yes'
|
||||||
|
|||||||
5
app/assets/javascripts/users.js.coffee
Normal file
5
app/assets/javascripts/users.js.coffee
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
App.Users =
|
||||||
|
|
||||||
|
initialize: ->
|
||||||
|
$('.initialjs-avatar').initial();
|
||||||
|
false
|
||||||
@@ -371,13 +371,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.author-photo {
|
.author-photo {
|
||||||
border-radius: 2px;
|
|
||||||
display: inline-block;
|
|
||||||
height: 32px;
|
|
||||||
line-height: $line-height*2;
|
line-height: $line-height*2;
|
||||||
margin-right: $line-height/4;
|
margin-right: $line-height/4;
|
||||||
vertical-align: middle;
|
|
||||||
width: 32px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.author {
|
.author {
|
||||||
@@ -524,16 +519,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-photo {
|
|
||||||
border-radius: 2px;
|
|
||||||
display: inline-block;
|
|
||||||
height: 32px;
|
|
||||||
line-height: $line-height*2;
|
|
||||||
margin-right: rem-calc(6);
|
|
||||||
vertical-align: top;
|
|
||||||
width: 32px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.comment-body {
|
.comment-body {
|
||||||
margin-left: $line-height*1.6;
|
margin-left: $line-height*1.6;
|
||||||
|
|
||||||
@@ -569,4 +554,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -484,7 +484,7 @@ form {
|
|||||||
opacity: .5;
|
opacity: .5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar {
|
.initialjs-avatar {
|
||||||
margin-bottom: $line-height;
|
margin-bottom: $line-height;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -522,4 +522,4 @@ form {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,13 +36,15 @@
|
|||||||
|
|
||||||
<div class="small-12 medium-6 column">
|
<div class="small-12 medium-6 column">
|
||||||
<h3><%= t("account.show.avatar")%></h3>
|
<h3><%= t("account.show.avatar")%></h3>
|
||||||
<%= image_tag('user_default_big.jpg', class: "avatar", size: "100x100") %>
|
<%= avatar_image(@account, size: 100) %>
|
||||||
|
|
||||||
<h3><%= t("account.show.notifications")%></h3>
|
<h3><%= t("account.show.notifications")%></h3>
|
||||||
|
|
||||||
<%= f.label :email_on_debate_comment do %>
|
<%= f.label :email_on_debate_comment do %>
|
||||||
<%= f.check_box :email_on_debate_comment %>
|
<%= f.check_box :email_on_debate_comment %>
|
||||||
<span class="checkbox"><%= t("account.show.email_on_debate_comment_label") %></span>
|
<span class="checkbox"><%= t("account.show.email_on_debate_comment_label") %></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= f.label :email_on_comment_reply do %>
|
<%= f.label :email_on_comment_reply do %>
|
||||||
<%= f.check_box :email_on_comment_reply %>
|
<%= f.check_box :email_on_comment_reply %>
|
||||||
<span class="checkbox"><%= t("account.show.email_on_comment_reply_label") %></span>
|
<span class="checkbox"><%= t("account.show.email_on_comment_reply_label") %></span>
|
||||||
@@ -55,4 +57,4 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div id="comment-<%= comment.id %>" class="comment small-12 column">
|
<div id="comment-<%= comment.id %>" class="comment small-12 column">
|
||||||
|
|
||||||
<%= image_tag('user_default_2.jpg', class: 'user-photo left', size: '32x32') %>
|
<%= avatar_image(comment.user, size: 32, class: 'left') %>
|
||||||
|
|
||||||
<div class="comment-body">
|
<div class="comment-body">
|
||||||
<span class="comment-info">
|
<span class="comment-info">
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<h1><%= @debate.title %></h1>
|
<h1><%= @debate.title %></h1>
|
||||||
|
|
||||||
<div class="debate-info">
|
<div class="debate-info">
|
||||||
<%= image_tag('user_default.jpg', class: 'author-photo', size: '32x32') %>
|
<%= avatar_image(@debate.author, size: 32, class: 'author-photo') %>
|
||||||
<span class="author">
|
<span class="author">
|
||||||
<%= @debate.author.name %>
|
<%= @debate.author.name %>
|
||||||
</span>
|
</span>
|
||||||
@@ -62,4 +62,4 @@
|
|||||||
<%= render @debate.root_comments.recent %>
|
<%= render @debate.root_comments.recent %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -4,20 +4,22 @@ feature 'Account' do
|
|||||||
|
|
||||||
background do
|
background do
|
||||||
@user = create(:user, first_name: "Manuela", last_name:"Colau")
|
@user = create(:user, first_name: "Manuela", last_name:"Colau")
|
||||||
|
login_as(@user)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Show' do
|
scenario 'Show' do
|
||||||
login_as(@user)
|
|
||||||
visit root_path
|
visit root_path
|
||||||
|
|
||||||
click_link "My account"
|
click_link "My account"
|
||||||
|
|
||||||
expect(current_path).to eq(account_path)
|
expect(current_path).to eq(account_path)
|
||||||
|
|
||||||
expect(page).to have_selector("input[value='Manuela']")
|
expect(page).to have_selector("input[value='Manuela']")
|
||||||
expect(page).to have_selector("input[value='Colau']")
|
expect(page).to have_selector("input[value='Colau']")
|
||||||
|
expect(page).to have_selector(avatar('Manuela Colau'), count: 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Failed Edit" do
|
scenario "Failed Edit" do
|
||||||
login_as(@user)
|
|
||||||
visit account_path
|
visit account_path
|
||||||
|
|
||||||
fill_in 'account_first_name', with: ''
|
fill_in 'account_first_name', with: ''
|
||||||
@@ -31,7 +33,6 @@ feature 'Account' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario 'Edit' do
|
scenario 'Edit' do
|
||||||
login_as(@user)
|
|
||||||
visit account_path
|
visit account_path
|
||||||
|
|
||||||
fill_in 'account_first_name', with: 'Larry'
|
fill_in 'account_first_name', with: 'Larry'
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ feature 'Comments' do
|
|||||||
expect(page).to have_content comment.user.name
|
expect(page).to have_content comment.user.name
|
||||||
expect(page).to have_content time_ago_in_words(comment.created_at)
|
expect(page).to have_content time_ago_in_words(comment.created_at)
|
||||||
expect(page).to have_content comment.body
|
expect(page).to have_content comment.body
|
||||||
|
expect(page).to have_selector(avatar(comment.user.name), count: 1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ feature 'Debates' do
|
|||||||
expect(page).to have_content "Debate description"
|
expect(page).to have_content "Debate description"
|
||||||
expect(page).to have_content debate.author.name
|
expect(page).to have_content debate.author.name
|
||||||
expect(page).to have_content I18n.l(Date.today)
|
expect(page).to have_content I18n.l(Date.today)
|
||||||
|
expect(page).to have_selector(avatar(debate.author.name), count: 1)
|
||||||
|
|
||||||
within('.social-share-button') do
|
within('.social-share-button') do
|
||||||
expect(page.all('a').count).to be(3) # Twitter, Facebook, Google+
|
expect(page.all('a').count).to be(3) # Twitter, Facebook, Google+
|
||||||
|
|||||||
@@ -56,4 +56,8 @@ module CommonActions
|
|||||||
SimpleCaptcha::SimpleCaptchaData.first.value
|
SimpleCaptcha::SimpleCaptchaData.first.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def avatar(name)
|
||||||
|
"img.initialjs-avatar[data-name='#{name}']"
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user