gitlab-org--gitlab-foss/app/assets/javascripts/wikis.js.coffee
Dmitriy Zaporozhets 997a317b4c
Set of small improvements to wiki frontend
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2016-02-07 17:57:28 +01:00

19 lines
492 B
CoffeeScript

#= require latinise
class @Wikis
constructor: ->
$('.new-wiki-page').on 'submit', (e) =>
$('[data-error~=slug]').addClass('hidden')
field = $('#new_wiki_path')
slug = @slugify(field.val())
if (slug.length > 0)
path = field.attr('data-wikis-path')
location.href = path + '/' + slug
e.preventDefault()
dasherize: (value) ->
value.replace(/[_\s]+/g, '-')
slugify: (value) =>
@dasherize(value.trim().toLowerCase().latinise())