2013-12-29 00:23:08 +01:00
|
|
|
$(document).ready ->
|
2014-08-16 11:19:27 +02:00
|
|
|
# Setup the graphical editor for event's description
|
2014-07-18 01:24:55 +02:00
|
|
|
tinyMCE.init
|
|
|
|
selector: 'textarea#event_description',
|
|
|
|
menubar : false,
|
|
|
|
schema: 'html5',
|
2014-07-20 22:55:26 +02:00
|
|
|
entity_encoding : 'raw',
|
2014-07-18 01:24:55 +02:00
|
|
|
add_unload_trigger: true,
|
|
|
|
browser_spellcheck: true,
|
|
|
|
toolbar: [
|
|
|
|
' bold italic strikethrough
|
|
|
|
| bullist numlist outdent indent
|
|
|
|
| alignleft aligncenter alignright alignjustify
|
2014-09-01 11:31:01 +02:00
|
|
|
| link image media insertdatetime charmap table
|
2014-07-18 01:24:55 +02:00
|
|
|
| undo redo
|
|
|
|
| searchreplace
|
|
|
|
| code visualblocks preview fullscreen'
|
|
|
|
],
|
2014-09-01 11:31:01 +02:00
|
|
|
plugins: 'lists, advlist, autolink, link, image, charmap, paste, print,
|
|
|
|
preview, table, fullscreen, searchreplace, media, insertdatetime,
|
|
|
|
visualblocks, visualchars, wordcount, contextmenu, code'
|
2014-07-18 01:24:55 +02:00
|
|
|
|
2014-08-16 11:19:27 +02:00
|
|
|
# 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: [' ']
|
|
|
|
|
2014-09-23 17:50:35 +02:00
|
|
|
$('#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())
|
|
|
|
|
2014-07-18 01:24:55 +02:00
|
|
|
$(document).on 'page:receive', ->
|
|
|
|
# Delete existing tinymce editors, very important in the turbolinks context!
|
|
|
|
tinymce.remove()
|