debian-mirror-gitlab/app/assets/javascripts/wikis.js.coffee

20 lines
492 B
CoffeeScript
Raw Normal View History

#= require latinise
2015-04-26 12:48:37 +05:30
class @Wikis
2014-09-02 18:07:02 +05:30
constructor: ->
2016-04-02 18:10:28 +05:30
$('.new-wiki-page').on 'submit', (e) =>
$('[data-error~=slug]').addClass('hidden')
2014-09-02 18:07:02 +05:30
field = $('#new_wiki_path')
slug = @slugify(field.val())
2014-09-02 18:07:02 +05:30
if (slug.length > 0)
2015-09-11 14:41:01 +05:30
path = field.attr('data-wikis-path')
location.href = path + '/' + slug
2016-04-02 18:10:28 +05:30
e.preventDefault()
dasherize: (value) ->
value.replace(/[_\s]+/g, '-')
slugify: (value) =>
@dasherize(value.trim().toLowerCase().latinise())