Removed old files and fixed asset precompilation
This commit is contained in:
@@ -1,217 +0,0 @@
|
||||
#= require froala_editor.min.js
|
||||
|
||||
# I18n
|
||||
|
||||
'use strict'
|
||||
|
||||
startSpinner = ->
|
||||
$('#loading-spinner').show()
|
||||
|
||||
stopSpinner = ->
|
||||
$('#loading-spinner').fadeOut()
|
||||
|
||||
# Turbolinks Spinner
|
||||
document.addEventListener 'page:fetch', startSpinner
|
||||
document.addEventListener 'page:receive', stopSpinner
|
||||
|
||||
readURL = (input) ->
|
||||
reader = null
|
||||
if input.files && input.files[0]
|
||||
reader = new FileReader()
|
||||
reader.readAsDataURL input.files[0]
|
||||
reader.onload = (e) ->
|
||||
$(input).prev().attr('src', e.target.result)
|
||||
|
||||
createOverlay = () ->
|
||||
if $('#overlay').length > 0
|
||||
$('#overlay').remove()
|
||||
$('body').append('<div id="overlay" class="loading"><div id="overlay-inner"></div></div>')
|
||||
$('#overlay-dlg')
|
||||
|
||||
setOverlayHTML = (html) ->
|
||||
$('#overlay-inner').append('<div id="overlay-dlg">' + html + '</div>');
|
||||
$('#overlay').removeAttr('class').click(destroyOverlay)
|
||||
|
||||
destroyOverlay = () ->
|
||||
$('#overlay').remove()
|
||||
|
||||
selectA = (type, event, $emptyObj) ->
|
||||
event.preventDefault()
|
||||
# = $(this)
|
||||
$overlay = createOverlay()
|
||||
objs = []
|
||||
$('.' + type + '-select-field.added input.' + type + '-id').each () -> obj.push($(this).val())
|
||||
$.post window.location.href.replace(/^(.*\/)(.+?)$/, '$1non$2'), {added: objs},
|
||||
(html) ->
|
||||
setOverlayHTML(html).addClass('' + type + '-select')
|
||||
$('#select-' + type + '-list a').click (event) ->
|
||||
event.preventDefault()
|
||||
|
||||
$this = $(this)
|
||||
$old_field = $emptyObj.closest('.field')
|
||||
$field = $old_field.clone()
|
||||
|
||||
oldID = parseInt($old_field.find('input[type="hidden"]').attr('name').match(/\[(\d+)\]\[id\]/)[1])
|
||||
newID = oldID + 1
|
||||
|
||||
$field.find('input.' + type + '-id').val($this.data().id)
|
||||
$field.find('.' + type + 'name').html($this.find('.' + type + 'name').html()).before('<img src="' + $this.find('img').attr('src') + '" />')
|
||||
$field.find('.select-' + type + '').remove()
|
||||
$field.removeClass('new').addClass('added')
|
||||
$old_field.html (i, html) ->
|
||||
pregex = new RegExp('\\[' + oldID + '\\]', 'g');
|
||||
aregex = new RegExp('_' + oldID + '_', 'g');
|
||||
html.replace(pregex, '[' + newID + ']').replace(aregex, '_' + newID + '_')
|
||||
$field.insertBefore($old_field)
|
||||
$('a.select-' + type + '').click (event) -> selectA(type, event, $(this))
|
||||
|
||||
destroyOverlay()
|
||||
return
|
||||
, 'html'
|
||||
|
||||
updateFormField = () ->
|
||||
$form = $('form#new_registration_form_field')
|
||||
$field_type = $form.find('#registration_form_field_field_type')
|
||||
field_type = $field_type.val()
|
||||
$form.find('.registration-form-field-field').hide()
|
||||
$form.find('.registration-form-field-field.field-type-' + field_type).show()
|
||||
|
||||
updateFormFieldForm = () ->
|
||||
$('form #registration_form_field_field_type').change updateFormField
|
||||
updateFormField()
|
||||
$('form#new_registration_form_field').submit (event) ->
|
||||
event.preventDefault()
|
||||
$form = $(this)
|
||||
serialized = $form.serialize()
|
||||
$.post $form.attr('action'), serialized,
|
||||
(json) ->
|
||||
$form.replaceWith(json.form)
|
||||
$('#registration-form-field-list').html(json.list)
|
||||
updateFormFieldForm()
|
||||
, 'json'
|
||||
updateFormFieldList = () ->
|
||||
$('#registration-form-field-list .add-form-field').click () ->
|
||||
$.post 'form/add-field', {field: $(this).data().id},
|
||||
(json) ->
|
||||
$('#conference-form').html(json.form)
|
||||
$('#registration-form-field-list').html(json.list)
|
||||
updateFormFieldList()
|
||||
return
|
||||
$('#conference-form .remove-form-field').click () ->
|
||||
$.post 'form/remove-field', {field: $(this).data().id},
|
||||
(json) ->
|
||||
$('#conference-form').html(json.form)
|
||||
$('#registration-form-field-list').html(json.list)
|
||||
updateFormFieldList()
|
||||
return
|
||||
|
||||
saveTranslation = ($td, $move_to, auto_translate) ->
|
||||
val = ''
|
||||
do_auto_translate = true
|
||||
if typeof auto_translate == "undefined" || !auto_translate
|
||||
val = $td.find('textarea').val()
|
||||
do_auto_translate = false
|
||||
key = $td.parent().data().key
|
||||
params = {translationkey: key, translationvalue: val, translationlang: window.location.href.replace(/^.*\/(\w+)\/$/, '$1')}
|
||||
if do_auto_translate
|
||||
params['auto_translate'] = true
|
||||
$.post '/translate/', params,
|
||||
(json) ->
|
||||
#console.log 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
|
||||
return
|
||||
return
|
||||
|
||||
stopTranslating = () -> $('.translation-form').remove()
|
||||
|
||||
startTranslating = ($td) ->
|
||||
stopTranslating()
|
||||
value = if $td.parent().hasClass('not-exists') then '' else $td.html().trim()
|
||||
$tr = $td.parent()
|
||||
key = $tr.data().key
|
||||
$td.append('<div class="translation-form"><textarea>' + value + '</textarea><button class="small" data-key="' + key + '">Save</textarea>')
|
||||
$textarea = $td.find('textarea')
|
||||
$textarea.select()
|
||||
$td.find('.translation-form button').click () -> saveTranslation($td)
|
||||
$textarea.keydown (event) ->
|
||||
if event.keyCode == 9
|
||||
event.preventDefault()
|
||||
$new_tr = if event.shiftKey then $tr.prev() else $tr.next()
|
||||
saveTranslation $td, $new_tr.find('.value')
|
||||
else if event.keyCode == 27
|
||||
stopTranslating()
|
||||
return
|
||||
return
|
||||
|
||||
$ ->
|
||||
#trial = document.createElement('script');
|
||||
#trial.type = 'text/javascript';
|
||||
#trial.async = true;
|
||||
#trial.src = 'http://easy.myfonts.net/v2/js?sid=158991(font-family=Scotch+Modern+Bold)&sid=174040(font-family=Scotch+Micro)&key=WPfecRji9L';
|
||||
#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()
|
||||
$territory = $('.field.subregion-select select')
|
||||
if $territory.data().country == country
|
||||
$territory.removeClass('can cant').addClass('can')
|
||||
return
|
||||
|
||||
$.post '/location/territories', {country: country},
|
||||
(json) ->
|
||||
$territory.html('')
|
||||
if json && Object.keys(json).length
|
||||
$.each json, (code, name) ->
|
||||
$territory.append($('<option>').text(name).attr('value', code))
|
||||
return
|
||||
$territory.removeClass('can cant').addClass('can')
|
||||
$territory.data().country = country
|
||||
else
|
||||
$territory.removeClass('can cant').addClass('cant')
|
||||
return
|
||||
, 'json'
|
||||
|
||||
return
|
||||
|
||||
$('img + input[type="file"]').change () ->
|
||||
readURL(this);
|
||||
|
||||
$('a.select-user, a.select-organization').click (event) -> selectA($(this).attr('class').match(/(^|\s)select\-([^\s]+)/)[2], event, $(this))
|
||||
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)
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"breakpoints": {
|
||||
"small": 0,
|
||||
"medium": 320,
|
||||
"large": 1024,
|
||||
"small-only": [0, 320],
|
||||
},
|
||||
"breakpoint-unit": "px",
|
||||
"fallback-range": [320, 1024],
|
||||
"browser_exceptions": {
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
@@ -1,3 +0,0 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
@@ -1,3 +0,0 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
@@ -1,121 +0,0 @@
|
||||
# I18n
|
||||
#= require i18n
|
||||
#= require i18n/translations
|
||||
|
||||
'use strict'
|
||||
|
||||
$(document).ready ->
|
||||
$('#translation-control form').unbind('submit').bind('submit', (event)->
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
$form = $(this)
|
||||
serialized = $form.serialize()
|
||||
$form.find('select, button, textarea').prop 'disabled', true
|
||||
$.post $form.attr('action'), serialized,
|
||||
(json) ->
|
||||
if json.success
|
||||
$span = $('.translate-me[data-translate-key="' + json.key + '"]')
|
||||
$span.html(json.translation)
|
||||
$span.attr('data-translate-untranslated', json.translation)
|
||||
$span.removeClass 'untranslated'
|
||||
else if json.test
|
||||
console.log json.test
|
||||
$form.find('select, button, textarea').prop 'disabled', false
|
||||
return
|
||||
, 'json'
|
||||
return
|
||||
)
|
||||
$('.translate-me').click (event)->
|
||||
if event.altKey
|
||||
event.preventDefault()
|
||||
key = $(this).attr('data-translate-key')
|
||||
$('#translationkey').val key
|
||||
resetTranslation key
|
||||
$('#translationvalue').focus()
|
||||
return
|
||||
#$('#translationvalue, #translationkey').focus ->
|
||||
$('#translation-control *').focus ->
|
||||
key = $('#translationkey').val()
|
||||
selectTranslation key
|
||||
updateTranslation key
|
||||
return
|
||||
$('#translationkey').change (event)->
|
||||
#$('#translationvalue').val('')
|
||||
key = $('#translationkey').val()
|
||||
selectTranslation key
|
||||
resetTranslation key
|
||||
#$('#translation').focus()
|
||||
#console.log event
|
||||
return
|
||||
# $('#translationvalue, #translationkey').blur ->
|
||||
$('#translation-control *').blur ->
|
||||
selectTranslation()
|
||||
return
|
||||
$('#translationvalue').bind 'input propertychange', ()->
|
||||
updateTranslation $('#translationkey').val()
|
||||
return
|
||||
return
|
||||
|
||||
selectTranslation = (key)->
|
||||
$span = $('.translate-me.selected');
|
||||
$span.removeClass 'selected'
|
||||
$span.removeClass 'preview'
|
||||
$('#translatevars').hide()
|
||||
$('#translatepluralizations').hide()
|
||||
$('#translatevars ul').html ''
|
||||
$('#translationhascount').val('0')
|
||||
if key
|
||||
$target = $('.translate-me[data-translate-key="' + key + '"]')
|
||||
if !$target || !$target.length
|
||||
return
|
||||
vars = $target.addClass('selected').data().vars
|
||||
if vars
|
||||
keys = Object.keys(vars)
|
||||
if keys.length
|
||||
for i in [0...keys.length]
|
||||
$('#translatevars ul').append ('<li class="var-' + keys[i] + '" title="Value: ' + vars[keys[i]] + '">' + keys[i] + '</li>')
|
||||
if keys[i] == 'count'
|
||||
$('#translatepluralizations').show()
|
||||
$('#translationhascount').val('1')
|
||||
$('#translatevars').show()
|
||||
else
|
||||
$span.html ()->
|
||||
$(this).attr('data-translate-untranslated')
|
||||
return
|
||||
|
||||
updateTranslation = (key)->
|
||||
$span = $('.translate-me[data-translate-key="' + key + '"]')
|
||||
val = $('#translationvalue').val()
|
||||
is_preview = ($span.hasClass 'preview')
|
||||
$('#translatevars li').removeClass('used')
|
||||
if val
|
||||
if !is_preview
|
||||
$span.addClass 'preview'
|
||||
if !$span || !$span.length
|
||||
return
|
||||
vars = $span.data().vars
|
||||
keys = Object.keys(vars)
|
||||
for i in [0...keys.length]
|
||||
_var = new RegExp('%{' + keys[i] + '}')
|
||||
if val.match _var
|
||||
# console.log 'Match!'
|
||||
$('#translatevars li.var-' + keys[i]).addClass('used')
|
||||
val = val.replace _var, vars[keys[i]]
|
||||
else
|
||||
if is_preview
|
||||
$span.removeClass 'preview'
|
||||
$span.html (val || $span.attr('data-translate-untranslated'))
|
||||
return
|
||||
|
||||
resetTranslation = (key)->
|
||||
$target = $('.translate-me[data-translate-key="' + key + '"]')
|
||||
if $target && $target.length
|
||||
translated = $target.data().translateTranslated
|
||||
counts = ['zero', 'one', 'two', 'few', 'many']
|
||||
for i in counts
|
||||
val = translated[key + '.' + i]
|
||||
$('#translationvalue_' + i).val(val || '')
|
||||
$('#translationpluralization_' + i).prop('checked', !!val)
|
||||
val = (translated[key] || translated[key + '.other'])
|
||||
$('#translationvalue').val(val || '')
|
||||
return
|
||||
@@ -1,75 +0,0 @@
|
||||
$(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();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
@@ -1,3 +0,0 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
@@ -1,3 +0,0 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
Reference in New Issue
Block a user