diff --git a/Gemfile b/Gemfile index 8a31792..acfbb84 100644 --- a/Gemfile +++ b/Gemfile @@ -26,6 +26,8 @@ gem 'acts_as_list' gem 'geocoder' gem 'forgery' gem 'paper_trail' +gem 'font-awesome-rails' +gem 'wysiwyg-rails' group :development, :test do gem 'rspec' diff --git a/Gemfile.lock b/Gemfile.lock index 948ef79..d86d8f0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,8 +45,6 @@ GEM arel (4.0.2) awesome_print (1.2.0) bcrypt (3.1.7-x86-mingw32) - bcrypt-ruby (3.1.5-x86-mingw32) - bcrypt (>= 3.1.3) better_errors (1.1.0) coderay (>= 1.0.0) erubis (>= 2.6.6) @@ -60,7 +58,7 @@ GEM net-sftp (>= 2.0.0) net-ssh (>= 2.0.14) net-ssh-gateway (>= 1.1.0) - capybara (2.2.1) + capybara (2.4.1) mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) @@ -88,10 +86,10 @@ GEM coffee-rails (4.0.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) - coffee-script (2.2.0) + coffee-script (2.3.0) coffee-script-source execjs - coffee-script-source (1.7.0) + coffee-script-source (1.7.1) compass (0.12.6) chunky_png (~> 1.2) fssm (>= 0.2.7) @@ -109,9 +107,9 @@ GEM safe_yaml (~> 1.0.0) debug_inspector (0.0.2) diff-lcs (1.2.5) - docile (1.1.3) + docile (1.1.5) erubis (2.7.0) - execjs (2.0.2) + execjs (2.2.1) factory_girl (4.4.0) activesupport (>= 3.0.0) factory_girl_rails (4.4.1) @@ -120,20 +118,22 @@ GEM faraday (0.9.0) multipart-post (>= 1.2, < 3) ffi (1.9.3-x86-mingw32) + font-awesome-rails (4.1.0.0) + railties (>= 3.2, < 5.0) forgery (0.6.0) - formatador (0.2.4) - foundation-rails (5.2.2.0) + formatador (0.2.5) + foundation-rails (5.3.0.1) railties (>= 3.1.0) sass (>= 3.2.0) fssm (0.2.10) - geocoder (1.2.1) + geocoder (1.2.2) guard (2.6.1) formatador (>= 0.2.4) listen (~> 2.7) lumberjack (~> 1.0) pry (>= 0.9.12) thor (>= 0.18.1) - guard-rspec (4.2.9) + guard-rspec (4.2.10) guard (~> 2.1) rspec (>= 2.14, < 4.0) haml (4.0.5) @@ -146,37 +146,37 @@ GEM highline (1.6.21) hike (1.2.3) httpauth (0.2.1) - i18n (0.6.9) + i18n (0.6.11) image_optimizer (1.2.1) - jquery-rails (3.1.0) + jquery-rails (3.1.1) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - jquery-ui-rails (4.2.1) + jquery-ui-rails (5.0.0) railties (>= 3.2.16) json (1.8.1) jwt (0.1.13) multi_json (>= 1.5) launchy (2.4.2) addressable (~> 2.3) - listen (2.7.5) + listen (2.7.9) celluloid (>= 0.15.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) - lumberjack (1.0.5) + lumberjack (1.0.9) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) - meta_request (0.3.0) - callsite - rack-contrib - railties + meta_request (0.3.3) + callsite (~> 0.0, >= 0.0.11) + rack-contrib (~> 1.1) + railties (>= 3.0.0, < 5.0.0) method_source (0.8.2) mime-types (1.25.1) mini_magick (3.7.0) subexec (~> 0.2.1) mini_portile (0.6.0) minitest (4.7.5) - multi_json (1.10.0) + multi_json (1.10.1) multipart-post (2.0.0) nested_form (0.3.2) net-scp (1.2.1) @@ -186,6 +186,7 @@ GEM net-ssh (2.9.1) net-ssh-gateway (1.2.0) net-ssh (>= 2.6.5) + netrc (0.7.7) nokogiri (1.6.2.1-x86-mingw32) mini_portile (= 0.6.0) oauth (0.4.7) @@ -195,18 +196,14 @@ GEM jwt (~> 0.1.4) multi_json (~> 1.0) rack (~> 1.2) - paper_trail (3.0.2) + paper_trail (3.0.3) activerecord (>= 3.0, < 5.0) activesupport (>= 3.0, < 5.0) pg (0.17.1-x86-mingw32) - polyglot (0.3.4) - pry (0.9.12.6) - coderay (~> 1.0) - method_source (~> 0.8) - slop (~> 3.4) - pry (0.9.12.6-x86-mingw32) - coderay (~> 1.0) - method_source (~> 0.8) + polyglot (0.3.5) + pry (0.10.0-x86-mingw32) + coderay (~> 1.1.0) + method_source (~> 0.8.1) slop (~> 3.4) win32console (~> 1.3) rack (1.5.2) @@ -234,28 +231,34 @@ GEM thor (>= 0.18.1, < 2.0) rake (10.3.2) rb-fsevent (0.9.4) - rb-inotify (0.9.4) + rb-inotify (0.9.5) ffi (>= 0.5.0) - rest-client (1.6.7) - mime-types (>= 1.16) - rspec (2.14.1) - rspec-core (~> 2.14.0) - rspec-expectations (~> 2.14.0) - rspec-mocks (~> 2.14.0) - rspec-core (2.14.8) - rspec-expectations (2.14.5) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.14.6) - rspec-rails (2.14.2) + rest-client (1.7.1-x86-mingw32) + ffi (~> 1.9) + mime-types (>= 1.16, < 3.0) + netrc (~> 0.7) + rspec (3.0.0) + rspec-core (~> 3.0.0) + rspec-expectations (~> 3.0.0) + rspec-mocks (~> 3.0.0) + rspec-core (3.0.2) + rspec-support (~> 3.0.0) + rspec-expectations (3.0.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.0.0) + rspec-mocks (3.0.2) + rspec-support (~> 3.0.0) + rspec-rails (3.0.1) actionpack (>= 3.0) - activemodel (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 2.14.0) - rspec-expectations (~> 2.14.0) - rspec-mocks (~> 2.14.0) - rubyzip (1.1.3) - rvm-capistrano (1.5.2) + rspec-core (~> 3.0.0) + rspec-expectations (~> 3.0.0) + rspec-mocks (~> 3.0.0) + rspec-support (~> 3.0.0) + rspec-support (3.0.2) + rubyzip (1.1.6) + rvm-capistrano (1.5.3) capistrano (~> 2.15.4) safe_yaml (1.0.3) sass (3.2.19) @@ -264,7 +267,7 @@ GEM sass (~> 3.2.0) sprockets (~> 2.8, <= 2.11.0) sprockets-rails (~> 2.0) - selenium-webdriver (2.41.0) + selenium-webdriver (2.42.0) childprocess (>= 0.5.0) multi_json (~> 1.0) rubyzip (~> 1.0) @@ -275,9 +278,9 @@ GEM simplecov-html (~> 0.8.0) simplecov-html (0.8.0) slop (3.5.0) - sorcery (0.8.5) - bcrypt-ruby (>= 3.0) - oauth (~> 0.4.4) + sorcery (0.8.6) + bcrypt (~> 3.1) + oauth (~> 0.4, >= 0.4.4) oauth2 (>= 0.8.0, < 1.0.0) sprockets (2.11.0) hike (~> 1.2) @@ -292,15 +295,15 @@ GEM term-ansicolor (1.3.0) tins (~> 1.0) thor (0.19.1) - thread_safe (0.3.3) + thread_safe (0.3.4) tilt (1.4.1) timers (1.1.0) tins (1.3.0) treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.39) - uglifier (2.5.0) + tzinfo (0.3.40) + uglifier (2.5.1) execjs (>= 0.3.0) json (>= 1.8.0) unicode_utils (1.4.0) @@ -310,6 +313,9 @@ GEM crack (>= 0.3.2) websocket (1.0.7) win32console (1.3.2-x86-mingw32) + wysiwyg-rails (1.1.5) + font-awesome-rails (= 4.1.0.0) + railties (>= 3.2, < 5.0) xpath (2.0.0) nokogiri (~> 1.3) @@ -330,6 +336,7 @@ DEPENDENCIES compass-rails (~> 1.1.3) coveralls factory_girl_rails + font-awesome-rails forgery foundation-rails geocoder @@ -359,3 +366,4 @@ DEPENDENCIES uglifier (>= 1.3.0) wdm (>= 0.1.0) webmock + wysiwyg-rails diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index 3da186f..8dc28be 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -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) \ No newline at end of file + #$('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) \ No newline at end of file diff --git a/app/assets/javascripts/translations.js b/app/assets/javascripts/translations.js new file mode 100644 index 0000000..576946f --- /dev/null +++ b/app/assets/javascripts/translations.js @@ -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('