This commit is contained in:
Godwin
2014-07-11 19:48:44 -06:00
parent 623445411a
commit db621f244b
21 changed files with 541 additions and 145 deletions
+28 -40
View File
@@ -1,22 +1,9 @@
#= require jquery
#= require jquery_ujs
#= require jquery.ui.sortable
# = #require jquery.turbolinks
# = #require turbolinks
#= require foundation
# FRONT END
# JS HANDLEBARS TEMPLATES
# require handlebars.runtime
# require jquery_nested_form
#= require froala_editor.min.js
# I18n
'use strict'
try Typekit.load() catch
startSpinner = ->
$('#loading-spinner').show()
@@ -170,6 +157,7 @@ $ ->
#head = document.getElementsByTagName("head")[0];
#head.appendChild(trial);
#$(document).foundation();
#$('[data-editable]').editable({blockTags: ["n", "p", "h2", "blockquote", "pre"], buttons: ["formatBlock", "bold", "italic", "underline", "insertOrderedList", "insertUnorderedList", "sep", "createLink", "insertImage", "insertVideo", "html", "undo", "redo"]})
$('.field.country-select select').change () ->
$country = $(this)
country = $country.val()
@@ -201,29 +189,29 @@ $ ->
updateFormFieldForm()
updateFormFieldList()
$('ul.sortable').sortable
handle: '.drag-sort',
items: 'li',
update: (event, props) ->
$(this).children().each (index, child) ->
$(child).find('.sortable-position').val(index + 1)
url = $(this).data().url
if url
data = $(this).find('input, select, textarea').serialize()
$.post url, data#,
# (json) ->
# console.log json
#, 'json'
$('table#translations td.value').click () ->
$this = $(this)
if !$this.find('.translation-form').length
startTranslating($this)
if $('table#translations').length
$(document).click (event) ->
$target = $(event.target)
if $target.closest('table#translations').length < 1 && !$target.hasClass('auto-translate')
stopTranslating()
$('.auto-translate').click (event) ->
event.preventDefault()
$td = $(this).parent()
saveTranslation($td, null, true)
#$('ul.sortable').sortable
# handle: '.drag-sort',
# items: 'li',
# update: (event, props) ->
# $(this).children().each (index, child) ->
# $(child).find('.sortable-position').val(index + 1)
# url = $(this).data().url
# if url
# data = $(this).find('input, select, textarea').serialize()
# $.post url, data#,
# # (json) ->
# # console.log json
# #, 'json'
#$('table#translations td.value').click () ->
# $this = $(this)
# if !$this.find('.translation-form').length
# startTranslating($this)
#if $('table#translations').length
# $(document).click (event) ->
# $target = $(event.target)
# if $target.closest('table#translations').length < 1 && !$target.hasClass('auto-translate')
# stopTranslating()
# $('.auto-translate').click (event) ->
# event.preventDefault()
# $td = $(this).parent()
# saveTranslation($td, null, true)
+75
View File
@@ -0,0 +1,75 @@
$(function() {
$('table#translations td.value').click(function() {
var $this = $(this);
if(!$this.find('.translation-form').length) {
startTranslating($this);
}
});
if ($('table#translations').length) {
$(document).click(function(event) {
$target = $(event.target);
if ($target.closest('table#translations').length < 1 && !$target.hasClass('auto-translate')) {
stopTranslating();
}
});
$('.auto-translate').click(function(event) {
event.preventDefault();
$td = $(this).parent();
saveTranslation($td, null, true);
});
}
});
function saveTranslation($td, $move_to, auto_translate) {
var val = '';
var do_auto_translate = true;
if (typeof auto_translate == "undefined" || !auto_translate) {
val = $td.find('textarea').val();
do_auto_translate = false;
}
var key = $td.parent().data().key;
var params = {
translationkey: key,
translationvalue: val,
translationlang: window.location.href.replace(/^.*\/(\w+)\/$/, '$1')
};
if (do_auto_translate) {
params['auto_translate'] = true;
}
params['authenticity_token'] = $('table#translations').data().token;
$.post('/translate/', params, function(json) {
$td.html(json.translation);
if ($td.parent().hasClass('not-exists')) {
$td.parent().removeClass('not-exists');
$td.parent().addClass('exists');
}
$('.translation-form').remove();
if (typeof $move_to != "undefined" && $move_to) {
startTranslating($move_to);
}
});
}
function stopTranslating() {
$('.translation-form').remove();
}
function startTranslating($td) {
stopTranslating();
var value = $td.parent().hasClass('not-exists') ? '' : $td.html().trim();
var $tr = $td.parent();
var key = $tr.data().key;
$td.append('<div class="translation-form"><textarea>' + value + '</textarea><button class="small" data-key="' + key + '">Save</textarea>');
var $textarea = $td.find('textarea');
$textarea.select();
$td.find('.translation-form button').click(function() { saveTranslation($td); });
$textarea.keydown(function(event) {
if (event.keyCode == 9) {
event.preventDefault();
var $new_tr = event.shiftKey ? $tr.prev() : $tr.next();
saveTranslation($td, $new_tr.find('.value'));
} else if (event.keyCode == 27) {
stopTranslating();
}
});
}
+5 -2
View File
@@ -1,4 +1,8 @@
/*
*= require froala_editor.min.css
*/
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
@@ -23,6 +27,7 @@
// Libraries
@import "compass";
@import "font-awesome";
@import "foundation_and_overrides";
// Local settings (also edit foundation_and_overrides.scss to modify global variables)
@@ -30,5 +35,3 @@
@import "sass/layout";
@import "sass/typography";
@import "sass/base";
#mfPreviewBarShow, #mfPreviewBar { display: none; }
+145 -36
View File
@@ -15,36 +15,71 @@ body {
#main-nav {
background-color: $white;
width: 100%;
display: table;
display: block;
font-size: 0.6667em;
font-size: 2.4vw;
overflow: hidden;
height: 3.1em;
p {
display: none;
}
.buttons {
display: block;
width: 87%;
height: 100%;
//overflow: hidden;
white-space: nowrap;
float: right;
}
.button {
width: 29%;
width: 33.3%;
height: 100%;
margin: 0;
clear: left;
float: left;
&:hover {
background-color: rgba($white, 0.75);
}
&.active {
&:after {
content: '';
width: 0;
height: 0;
display: block;
position: absolute;
border-style: solid;
border-width: 1em 1em 0 1em;
border-color: #a0c700 transparent transparent transparent;
left: 0;
right: 0;
margin: 0.15em auto 0;
top: 100%;
z-index: 1;
border-width: 3vw 5vw 0 5vw;
}
}
&.logo {
background-color: $white;
background-color: transparent;
width: 13%;
border: 0;
padding: 0;
vertical-align: top;
overflow: auto;
/*svg {
float: left;
width: 50%;
}*/
//overflow: hidden;
height: 100%;
float: left;
.logo {
width: auto;
height: 2.4em;
height: 2em;
fill: $primary-color;
position: absolute;
left: 0;
margin-top: 0.15em;
}
.logo-text {
@@ -60,7 +95,75 @@ body {
}
@include breakpoint(medium) {
height: 5em;
position: absolute;
z-index: 10;
//background-color: $white;
//background-color: rgba($white, 0.33);
background-color: transparent;
@include background-image(linear-gradient(left, $white 0%, rgba($white, 0) 50%));
.buttons {
display: block;
width: 70%;
height: auto;
//overflow: hidden;
white-space: normal;
font-size: 0.75em;
margin-top: 2.5%;
}
p {
font-size: 1.25em;
font-size: 1.25vw;
line-height: 1.2em;
}
.button {
width: auto;
height: auto;
//float: none;
//margin: 0 0 1.25rem;
margin: 1%;
width: 30%;
&.logo {
position: relative;
//width: 100%;
//height: auto;
//margin-bottom: 2em;
//float: none;
width: 25%;
margin: 0;
height: 100%;
float: left;
padding: 0.25em;
.logo {
position: static;
float: left;
width: 51%;
height: 100%;
margin: 0 5% 0 0;
}
img.logo {
height: auto;
}
.logo-text {
display: block;
width: 44%;
height: 100%;
}
}
}
}
@include breakpoint(large) {
display: block;
position: static;
height: auto;
min-height: 100%;
float: left;
width: 25%;
@@ -72,36 +175,26 @@ body {
display: block;
}
p {
font-size: 0.9em;
}
.button {
width: auto;
margin: 0 0 1.25rem;
width: 100%;
height: auto;
margin: 0 0 1.25em;
float: none;
&.logo {
position: relative;
width: 100%;
margin-bottom: 2em;
.logo {
float: left;
width: 51%;
height: 100%;
margin-right: 5%;
}
img.logo {
height: auto;
}
.logo-text {
display: block;
width: 44%;
}
height: auto;
float: none;
}
}
.buttons {
display: block;
width: 100%;
font-size: 1em;
margin: 2em 0 0;
float: none;
}
}
}
@@ -122,7 +215,7 @@ main {
}
.conferences & {
background-color: lighten(desaturate($conference-color, 25), 50);
background-color: lighten(desaturate($conference-color, 25), 42.5);
min-height: 100vh;
}
@@ -265,6 +358,7 @@ main {
min-height: 40em;
height: 100%;
height: 100vh;
padding-top: 7.5em;
.organizations-show &,
.conferences-show & {
@@ -306,6 +400,21 @@ main {
.organizations-index &,
.conferences-index & {
height: 30vw;
h1 {
font-size: 6vw;
}
}
}
@include breakpoint(large) {
padding-top: 0;
.organizations-index &,
.conferences-index & {
height: 15vw;
h1 {
font-size: 3.75vw;
margin-top: 6vw;
@@ -532,3 +532,21 @@ input:-webkit-autofill {
svg {
height: 0%;
}
#footer {
color: $white;
padding: 2.5em 0;
font-size: 1.25em;
a {
margin: 0 1em;
}
a, a:visited {
color: $white;
}
a:hover {
color: rgba($white, 0.5);
}
}
+5 -1
View File
@@ -7,11 +7,15 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
if ENV['RAILS_ENV'] || 'production'
force_ssl only: :success
end
before_filter :capture_page_info
def capture_page_info
init_vars
init_vars
$page_info = {:path => request.env['PATH_INFO'], :controller => params['controller'], :action => params['action']}
end
+1
View File
@@ -1,6 +1,7 @@
include ApplicationHelper
class PagesController < ApplicationController
#skip_before_filter :verify_authenticity_token, only: [:translate]
def home
@conferences = Conference.all
+2 -1
View File
@@ -4,4 +4,5 @@
= tabs!
%h2=('About '+@conference.title)
%p=@conference.info.html_safe
%div{data: {editable: true}}
%p=@conference.info.html_safe
+4 -2
View File
@@ -4,6 +4,7 @@
%meta{ charset: 'utf-8' }
%meta{ name: 'viewport', content: 'width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0' }
%title= yield_or_default :title, controller.action_name.titlecase
%meta{ name: 'description', content: (yield_or_default :description, 'Bike!Bike! is an international annual gathering organized by and for community bicycle projects') }
= csrf_meta_tags
= yield :head
/ Le HTML5 shim, for IE6-8 support of HTML elements
@@ -25,8 +26,9 @@
\==================================================
/ Placed at the top of the document 'cause of turbolinks
=# javascript_include_tag '//use.typekit.net/iqv7hcg.js'
= javascript_include_tag 'application'
= javascript_include_tag 'nested_form'
= javascript_include_tag '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'
=# javascript_include_tag 'application'
=# javascript_include_tag 'nested_form'
%body{ class: (yield_or_default :page_style) }
:javascript
+73
View File
@@ -0,0 +1,73 @@
- content_for :dom_ready
$('table#translations td.value').click(function() {
var $this = $(this);
if(!$this.find('.translation-form').length()) {
startTranslating($this);
}
});
if ($('table#translations').length()) {
$(document).click(function(event) {
$target = $(event.target);
if ($target.closest('table#translations').length() < 1 && !$target.hasClass('auto-translate')) {
stopTranslating();
}
$('.auto-translate').click (function(event) {
event.preventDefault();
$td = $(this).parent();
saveTranslation($td, null, true);
});
}
- content_for :scripts
function saveTranslation($td, $move_to, auto_translate) {
var val = '';
var do_auto_translate = true;
if (typeof auto_translate == "undefined" || !auto_translate) {
val = $td.find('textarea').val();
do_auto_translate = false;
}
var key = $td.parent().data().key;
var params = {
translationkey: key,
translationvalue: val,
translationlang: window.location.href.replace(/^.*\/(\w+)\/$/, '$1')
};
if (do_auto_translate) {
params['auto_translate'] = true;
}
$.post('/translate/', params, function(json) {
$td.html(json.translation);
if ($td.parent().hasClass('not-exists')) {
$td.parent().removeClass('not-exists');
$td.parent().addClass('exists');
}
$('.translation-form').remove();
if (typeof $move_to != "undefined" && $move_to) {
startTranslating($move_to);
}
});
}
function stopTranslating() {
$('.translation-form').remove();
}
function startTranslating($td) {
stopTranslating();
var value = $td.parent().hasClass('not-exists') ? '' : $td.html().trim();
var $tr = $td.parent();
var key = $tr.data().key;
$td.append('<div class="translation-form"><textarea>' + value + '</textarea><button class="small" data-key="' + key + '">Save</textarea>');
var $textarea = $td.find('textarea');
$textarea.select();
$td.find('.translation-form button').click(function() { saveTranslation($td); });
$textarea.keydown(function(event) {
if (event.keyCode == 9) {
event.preventDefault();
var $new_tr = event.shiftKey ? $tr.prev() : $tr.next();
saveTranslation($td, $new_tr.find('.value'));
} else if (event.keyCode == 27) {
stopTranslating();
}
});
}
+4 -1
View File
@@ -3,7 +3,7 @@
.row
%h1
= _ 'language_translations', vars: {:language => (_ ('languages.' + @lang))}
%table.columns#translations
%table.columns#translations{data: {token: form_authenticity_token}}
%thead
%tr
%th.key=_'translations.Key'
@@ -41,3 +41,6 @@
= translation_hint ? (_ "languages.#{I18n.locale.to_s}") + " = \"#{translation_hint}\"" : 'Nil'
- unless current_translation
%a{:href => '#', :class => 'auto-translate button small'}='Auto'
-# content_for :footer_scripts
= javascript_include_tag 'translations'
+11 -2
View File
@@ -1,6 +1,15 @@
%footer
%footer.row
.columns.medium-8.medium-push-1.large-6.large-push-3.text-center
%a{href: '/conferences/'}='Conferences'
\/
%a{href: '/conferences/'}='Organizations'
\/
%a{href: '/conferences/'}='Zine'
.columns.medium-3.large-3.text-right
&copy;2014 Bike!Bike!
:javascript
#{yield :scripts}
$(function(){
#{yield :dom_ready}
});
});
= yield :footer_scripts
+4 -3
View File
@@ -4,9 +4,10 @@
=# image_tag('logo-text.png', class: 'logo-text')
= icon('logo', {:class => 'logo'})
= icon('logo-text', {:class => 'logo-text'})
= link_to (_'Conferences'), :conferences, {:class => ['button', 'conference']}
= link_to (_'Organizations'), {:controller => :organizations}, {:class => ['button', 'organization']}
= link_to (_'Zine'), 'http://zinezine.bikebike.org', :class => ['button', 'article']
.buttons
= link_to (_'Conferences'), :conferences, {:class => ['button', 'conference']}
= link_to (_'Organizations'), {:controller => :organizations}, {:class => ['button', 'organization']}
= link_to (_'Zine'), 'http://zinezine.bikebike.org', :class => ['button', 'article']
- if is_this_the_front_page?
%p
Bike!Bike! is an international annual gathering organized by and for community bicycle projects. The conference is a space for participants from shops and related advocacy groups to converge in a different city each year over a 4 day period to have workshops and strengthen our social network.