2014-10-20 16:48:07 -04:00
|
|
|
class @Wikis
|
2013-05-02 07:36:53 -04:00
|
|
|
constructor: ->
|
2015-05-21 05:38:13 -04:00
|
|
|
$('.build-new-wiki').bind "click", (e) ->
|
|
|
|
$('[data-error~=slug]').addClass("hidden")
|
|
|
|
$('p.hint').show()
|
2013-05-02 07:36:53 -04:00
|
|
|
field = $('#new_wiki_path')
|
2015-05-21 05:38:13 -04:00
|
|
|
valid_slug_pattern = /^[\w\/-]+$/
|
2013-05-02 07:36:53 -04:00
|
|
|
|
2015-05-21 05:38:13 -04:00
|
|
|
slug = field.val()
|
|
|
|
if slug.match valid_slug_pattern
|
|
|
|
path = field.attr('data-wikis-path')
|
|
|
|
if(slug.length > 0)
|
|
|
|
location.href = path + "/" + slug
|
|
|
|
else
|
|
|
|
e.preventDefault()
|
|
|
|
$('p.hint').hide()
|
|
|
|
$('[data-error~=slug]').removeClass("hidden")
|