BigW Consortium Gitlab

wikis.js.coffee 492 Bytes
Newer Older
1 2
#= require latinise

3
class @Wikis
4
  constructor: ->
5
    $('.new-wiki-page').on 'submit', (e) =>
6
      $('[data-error~=slug]').addClass('hidden')
7
      field = $('#new_wiki_path')
8
      slug = @slugify(field.val())
9

10
      if (slug.length > 0)
11
        path = field.attr('data-wikis-path')
12
        location.href = path + '/' + slug
13
        e.preventDefault()
14 15 16 17 18

  dasherize: (value) ->
    value.replace(/[_\s]+/g, '-')

  slugify: (value) =>
19
    @dasherize(value.trim().toLowerCase().latinise())