SSL test
This commit is contained in:
@@ -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)
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user