#= require spina/jquery.datatables #= require spina/jquery.ui #= require spina/jquery.ui.datepicker-nl #= require spina/jquery.sortable #= require spina/jquery.nestable #= require spina/jquery.customfileinput #= require spina/jquery.farbtastic #= require jquery-fileupload/basic #= require spina/raphael #= require spina/morris #= require spina/nprogress #= require spina/wysihtml5 #= require spina/wysihtml5_parser_rules #= require spina/switch #= require spina/modal #= require spina/tabs #= require spina/forms #= require spina/dropdown #= require spina/galleryselect #= require spina/uploads # Nprogress $(document).on 'page:fetch', -> NProgress.start() $(document).on 'page:change', -> NProgress.done() $(document).on 'page:restore', -> NProgress.remove() # Clickable TR's $(document).on 'click', '.table-clickable tbody tr', -> checkbox = $(this).find('input[type="checkbox"]:first, input[type="radio"]:first') checkbox.prop("checked", !checkbox.prop("checked")) # Search inputs $(document).on 'keyup', '.search-input input', (e) -> $(this).parent().removeClass('animated small-shake') if $(this).val() == "" $(this).parent().find('.clear-input').fadeOut(200) if e.keyCode == 13 $(this).parent().addClass('animated small-shake') else $(this).parent().find('.clear-input').fadeIn(200) $(document).on 'click', '.clear-input', -> link = $(this) input = link.siblings('input') input.val("") input.focus() input.trigger("keyup") link.fadeOut(200) return false $(document).on 'keyup + change', '.table-container .search-input input', -> datatable = $(this).parent().parent().find('table.datatable').dataTable() datatable.fnFilter($(this).val()) $(document).on 'change', '.dd', -> serialized = $(this).nestable('serialize') sort_url = $(this).data('sort-url') $.post sort_url, { list: serialized } # Datatables ready = -> # Custom file $('input[type="file"][data-customfileinput]:visible').each -> $(this).customFileInput() # Image upload $('.new_photo').uploadPhoto() # Colorpicker $('.colorpicker').each -> colorpicker = $(this).find('.colorpicker-container') field = $(this).find('input') $.farbtastic colorpicker, (color) -> field.val(color) field.css('color', color) $('.colorpicker input').focus -> container = $(this).parent() colorpicker = container.find('.colorpicker-container') $.farbtastic(colorpicker).setColor($(this).val()) container.find('.farbtastic').show() $('.colorpicker input').blur -> container = $(this).parent() container.find('.farbtastic').hide() # Document upload $('.new_document').uploadDocument() # Login wrapper $('#login_wrapper').css('margin-top', $(document).innerHeight() / 8) # Wysihtml5 editor $('.wysihtml5-container').each -> container = $(this) textarea = container.find('textarea') toolbar = container.find('.toolbar') editor = new wysihtml5.Editor textarea.attr('id'), { toolbar: toolbar.attr('id'), useLineBreaks: false, parserRules: wysihtml5ParserRules, stylesheets: ["<%= asset_path 'spina/wysihtml5_textarea.css' %>"] } editor.on "load", -> container.data("wysihtml5", editor) editor.on "focus", -> container.find(".choose-text-type").fadeIn(100) editor.on "blur", -> container.find(".choose-text-type").fadeOut(100) $(".dd").nestable maxDepth: 3 $(".structure-form-menu ul").sortable handle: '.sortable-handle' # Switch if $('input[data-switch]').length > 0 $('input[data-switch]').spinaSwitch() # Datepicker if $('.datepicker').length > 0 $('.datepicker').datepicker() # Datatable if $('.datatable').length > 0 $('table.datatable').dataTable "bLengthChange": false, "oLanguage": { "sProcessing": "Bezig...", "sLengthMenu": "_MENU_ resultaten weergeven", "sZeroRecords": "Geen resultaten gevonden", "sInfo": "_START_ tot _END_ van _TOTAL_ resultaten", "sInfoEmpty": "Geen resultaten om weer te geven", "sInfoFiltered": " (gefilterd uit _MAX_ resultaten)", "sInfoPostFix": "", "sSearch": "Zoeken:", "sEmptyTable": "Geen resultaten aanwezig in de tabel", "sInfoThousands": ".", "sLoadingRecords": "Een moment geduld aub - bezig met laden...", "oPaginate": { "sFirst": "Eerste", "sLast": "Laatste", "sNext": "Volgende", "sPrevious": "Vorige" } } $(document).ready(ready) $(document).on 'page:load', ready