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

3
class @Wikis
4
  constructor: ->
5 6
    $('.build-new-wiki').bind 'click', (e) =>
      $('[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 13 14 15 16 17
        location.href = path + '/' + slug

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

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