2016-01-19 16:12:03 +05:30
|
|
|
#= 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) =>
|
2016-01-19 16:12:03 +05:30
|
|
|
$('[data-error~=slug]').addClass('hidden')
|
2014-09-02 18:07:02 +05:30
|
|
|
field = $('#new_wiki_path')
|
2016-01-19 16:12:03 +05:30
|
|
|
slug = @slugify(field.val())
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2016-01-19 16:12:03 +05:30
|
|
|
if (slug.length > 0)
|
2015-09-11 14:41:01 +05:30
|
|
|
path = field.attr('data-wikis-path')
|
2016-01-19 16:12:03 +05:30
|
|
|
location.href = path + '/' + slug
|
2016-04-02 18:10:28 +05:30
|
|
|
e.preventDefault()
|
2016-01-19 16:12:03 +05:30
|
|
|
|
|
|
|
dasherize: (value) ->
|
|
|
|
value.replace(/[_\s]+/g, '-')
|
|
|
|
|
|
|
|
slugify: (value) =>
|
|
|
|
@dasherize(value.trim().toLowerCase().latinise())
|