Commit 97e74c5bde3269d4760b55971e7c06b42679f422
1 parent
dae9cd2a
Exists in
master
and in
4 other branches
Auto-populate the path and code on the name input's onchange event to the sluggified version of name
Showing
2 changed files
with
19 additions
and
6 deletions
Show diff stats
app/views/projects/_form.html.haml
| @@ -59,13 +59,13 @@ | @@ -59,13 +59,13 @@ | ||
| 59 | 59 | ||
| 60 | 60 | ||
| 61 | :javascript | 61 | :javascript |
| 62 | - $('.new_project, .edit_project').bind('ajax:before', function() { | ||
| 63 | - $(this).find(".form_content").hide(); | ||
| 64 | - $('.ajax_loader').show(); | ||
| 65 | - }); | ||
| 66 | - | ||
| 67 | -:javascript | ||
| 68 | $(function(){ | 62 | $(function(){ |
| 63 | + $('.new_project, .edit_project').bind('ajax:before', function() { | ||
| 64 | + $(this).find(".form_content").hide(); | ||
| 65 | + $('.ajax_loader').show(); | ||
| 66 | + }); | ||
| 67 | + | ||
| 69 | taggifyForm(); | 68 | taggifyForm(); |
| 69 | + | ||
| 70 | $('form #project_default_branch').chosen(); | 70 | $('form #project_default_branch').chosen(); |
| 71 | }) | 71 | }) |
app/views/projects/new.html.haml
| @@ -8,3 +8,16 @@ | @@ -8,3 +8,16 @@ | ||
| 8 | 8 | ||
| 9 | %div.clear | 9 | %div.clear |
| 10 | = render 'form' | 10 | = render 'form' |
| 11 | + | ||
| 12 | +:javascript | ||
| 13 | + $(function(){ | ||
| 14 | + $("#project_name").change(function(){ | ||
| 15 | + var slug = slugify($(this).val()); | ||
| 16 | + $("#project_code").val(slug); | ||
| 17 | + $("#project_path").val(slug); | ||
| 18 | + }); | ||
| 19 | + }); | ||
| 20 | + | ||
| 21 | + function slugify(text) { | ||
| 22 | + return text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase(); | ||
| 23 | + } |