diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2016-08-09 12:27:37 +0200 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2016-08-09 12:27:37 +0200 |
commit | 7a99826694ccc9dc5fd5f8cbecf7b51f8d690de4 (patch) | |
tree | e58828158e6a818e82a0a7cda95b642998233d77 /app/assets/javascripts/wikis.js | |
parent | 71952d057d5edad0697d7da76f5da034689e0f4a (diff) | |
parent | 551ffc0a4d25a381e9f8f6a8d6f2793bb87f3145 (diff) | |
download | gitlab-ce-7a99826694ccc9dc5fd5f8cbecf7b51f8d690de4.tar.gz |
Merge branch 'master' of https://gitlab.com/gitlab-org/gitlab-ce into remove-grack-lfs
Diffstat (limited to 'app/assets/javascripts/wikis.js')
-rw-r--r-- | app/assets/javascripts/wikis.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/app/assets/javascripts/wikis.js b/app/assets/javascripts/wikis.js new file mode 100644 index 00000000000..35401231fbf --- /dev/null +++ b/app/assets/javascripts/wikis.js @@ -0,0 +1,37 @@ + +/*= require latinise */ + +(function() { + var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + + this.Wikis = (function() { + function Wikis() { + this.slugify = bind(this.slugify, this); + $('.new-wiki-page').on('submit', (function(_this) { + return function(e) { + var field, path, slug; + $('[data-error~=slug]').addClass('hidden'); + field = $('#new_wiki_path'); + slug = _this.slugify(field.val()); + if (slug.length > 0) { + path = field.attr('data-wikis-path'); + location.href = path + '/' + slug; + return e.preventDefault(); + } + }; + })(this)); + } + + Wikis.prototype.dasherize = function(value) { + return value.replace(/[_\s]+/g, '-'); + }; + + Wikis.prototype.slugify = function(value) { + return this.dasherize(value.trim().toLowerCase().latinise()); + }; + + return Wikis; + + })(); + +}).call(this); |