agenda-libre-ruby/app/assets/javascripts/events.js.coffee

43 lines
1.4 KiB
CoffeeScript

$(document).ready ->
# Setup the graphical editor for event's description
tinyMCE.init
selector: 'textarea#event_description',
menubar : false,
schema: 'html5',
entity_encoding : 'raw',
add_unload_trigger: true,
browser_spellcheck: true,
toolbar: [
' bold italic strikethrough
| bullist numlist outdent indent
| alignleft aligncenter alignright alignjustify
| link image media insertdatetime charmap table
| undo redo
| searchreplace
| code visualblocks preview fullscreen'
],
plugins: 'lists, advlist, autolink, link, image, charmap, paste, print,
preview, table, fullscreen, searchreplace, media, insertdatetime,
visualblocks, visualchars, wordcount, contextmenu, code'
# Manage event tags edition
$('#event_tags').each ->
elt = $(this)
$.ajax
url: '/tags.json'
.done (data) ->
tags = jQuery.map data, (n) -> n[0]
elt.select2 tags: tags, separator: [' '], tokenSeparators: [' ']
$('#event_start_time').change ->
if $('#event_start_time').val() >= $('#event_end_time').val()
$('#event_end_time').val($('#event_start_time').val())
$('#event_end_time').change ->
if $('#event_start_time').val() >= $('#event_end_time').val()
$('#event_start_time').val($('#event_end_time').val())
$(document).on 'page:receive', ->
# Delete existing tinymce editors, very important in the turbolinks context!
tinymce.remove()