Added read more for statements
This commit is contained in:
@@ -23,6 +23,9 @@ gem 'aws-sdk'
|
|||||||
# A fixtures replacement
|
# A fixtures replacement
|
||||||
gem 'factory_girl'
|
gem 'factory_girl'
|
||||||
|
|
||||||
|
# It's a small library to provide the Rails I18n translations on the JavaScript.
|
||||||
|
gem "i18n-js"
|
||||||
|
|
||||||
# Use jquery as the JavaScript library
|
# Use jquery as the JavaScript library
|
||||||
gem 'jquery-rails'
|
gem 'jquery-rails'
|
||||||
|
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ GEM
|
|||||||
tilt
|
tilt
|
||||||
heapy (0.1.2)
|
heapy (0.1.2)
|
||||||
i18n (0.8.1)
|
i18n (0.8.1)
|
||||||
|
i18n-js (3.0.0)
|
||||||
|
i18n (~> 0.6, >= 0.6.6)
|
||||||
jbuilder (2.6.3)
|
jbuilder (2.6.3)
|
||||||
activesupport (>= 3.0.0, < 5.2)
|
activesupport (>= 3.0.0, < 5.2)
|
||||||
multi_json (~> 1.2)
|
multi_json (~> 1.2)
|
||||||
@@ -345,6 +347,7 @@ DEPENDENCIES
|
|||||||
factory_girl
|
factory_girl
|
||||||
faker
|
faker
|
||||||
geocoder
|
geocoder
|
||||||
|
i18n-js
|
||||||
jbuilder (~> 2.0)
|
jbuilder (~> 2.0)
|
||||||
jquery-rails
|
jquery-rails
|
||||||
kaminari-actionview
|
kaminari-actionview
|
||||||
|
|||||||
@@ -15,4 +15,5 @@
|
|||||||
//= require bootstrap-sprockets
|
//= require bootstrap-sprockets
|
||||||
//= require typeahead.bundle
|
//= require typeahead.bundle
|
||||||
//= require markerclusterer_compiled
|
//= require markerclusterer_compiled
|
||||||
|
//= require i18n/translations
|
||||||
//= require_tree .
|
//= require_tree .
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
$(document).ready(function(){
|
||||||
|
$('.statement p').each(function(){
|
||||||
|
var trimLength = 300;
|
||||||
|
var trimMargin = 1.2; // don't trim just a couple of words
|
||||||
|
if($(this).text().length > (trimLength * trimMargin)) {
|
||||||
|
var text = $(this).text();
|
||||||
|
var trimPoint = $(this).text().indexOf(" ", trimLength);
|
||||||
|
var newContent = text.substring(0, trimPoint)+'<span class="read-more">'+text.substring(trimPoint)+'</span><span class="toggle">... <a href="#">' + I18n.t("pages.statements.read_more");
|
||||||
|
+ '</a></span>';
|
||||||
|
$(this).html(newContent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('.toggle a').click(function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
var para = $(this).closest('p');
|
||||||
|
var initialHeight = $(this).closest('p').innerHeight();
|
||||||
|
para.find('.read-more').show();
|
||||||
|
para.find('.toggle').hide();
|
||||||
|
var newHeight = para.innerHeight();
|
||||||
|
para.css('max-height', initialHeight+'px');
|
||||||
|
para.animate({ maxHeight: newHeight }, 300, function(){
|
||||||
|
para.css('max-height', 'none');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -13,6 +13,9 @@
|
|||||||
font-size: $font-size-base
|
font-size: $font-size-base
|
||||||
margin: 0px
|
margin: 0px
|
||||||
display: inline
|
display: inline
|
||||||
|
|
||||||
|
.read-more
|
||||||
|
display: none
|
||||||
|
|
||||||
@media (max-width: 800px)
|
@media (max-width: 800px)
|
||||||
.statement
|
.statement
|
||||||
|
|||||||
@@ -75,4 +75,7 @@ html lang="#{I18n.locale}"
|
|||||||
= render 'contact'
|
= render 'contact'
|
||||||
.col-xs-12.col-sm-2
|
.col-xs-12.col-sm-2
|
||||||
= render 'address'
|
= render 'address'
|
||||||
|
|
||||||
|
javascript:
|
||||||
|
I18n.defaultLocale = "#{I18n.default_locale}";
|
||||||
|
I18n.locale = "#{I18n.locale}";
|
||||||
@@ -8,7 +8,7 @@ h1 = title t('.title')
|
|||||||
- unless supporter.publicity.organisation.blank?
|
- unless supporter.publicity.organisation.blank?
|
||||||
em= ", #{supporter.publicity.organisation}"
|
em= ", #{supporter.publicity.organisation}"
|
||||||
br
|
br
|
||||||
= supporter.publicity.statement
|
p = supporter.publicity.statement
|
||||||
hr.clearfix
|
hr.clearfix
|
||||||
|
|
||||||
.text-center = link_to t(".submit_your_own_statement"), new_publicity_path
|
.text-center = link_to t(".submit_your_own_statement"), new_publicity_path
|
||||||
@@ -25,7 +25,7 @@ de:
|
|||||||
|
|
||||||
counter:
|
counter:
|
||||||
supporters: "Unterstützer:"
|
supporters: "Unterstützer:"
|
||||||
amount_of_supporters: Zurzeit haben wir %{amount} Unterstützer.
|
amount_of_supporters: Zurzeit haben wir %{amount} Unterstützer.
|
||||||
|
|
||||||
input_error: Deine Eingaben konnte nicht gespeichert werden. Überprüfe deine Eingaben.
|
input_error: Deine Eingaben konnte nicht gespeichert werden. Überprüfe deine Eingaben.
|
||||||
donation: Deine Spende
|
donation: Deine Spende
|
||||||
@@ -105,6 +105,7 @@ de:
|
|||||||
statements:
|
statements:
|
||||||
title: Statements von unseren Unterstützern
|
title: Statements von unseren Unterstützern
|
||||||
submit_your_own_statement: Veröffentliche dein eigenes Statement...
|
submit_your_own_statement: Veröffentliche dein eigenes Statement...
|
||||||
|
read_more: das ganze Statement lesen.
|
||||||
|
|
||||||
routes:
|
routes:
|
||||||
initiative_text: initiativtext
|
initiative_text: initiativtext
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ fr:
|
|||||||
statements:
|
statements:
|
||||||
title: Les déclarations de nos partisans
|
title: Les déclarations de nos partisans
|
||||||
submit_your_own_statement: Publie tes propres déclaration ...
|
submit_your_own_statement: Publie tes propres déclaration ...
|
||||||
|
read_more: lire toute la déclaration.
|
||||||
|
|
||||||
routes:
|
routes:
|
||||||
initiative_text: l_initiative_propose
|
initiative_text: l_initiative_propose
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ it:
|
|||||||
statements:
|
statements:
|
||||||
title: Dichiarazioni di nostri sostenitori
|
title: Dichiarazioni di nostri sostenitori
|
||||||
submit_your_own_statement: Pubblica il tuo propria dichiarazione ...
|
submit_your_own_statement: Pubblica il tuo propria dichiarazione ...
|
||||||
|
read_more: leggere l'intero.
|
||||||
|
|
||||||
routes:
|
routes:
|
||||||
initiative_text: il_testo_dell_iniziativa
|
initiative_text: il_testo_dell_iniziativa
|
||||||
|
|||||||
Reference in New Issue
Block a user