diff options
author | Anton Davydov <antondavydov.o@gmail.com> | 2016-03-01 15:36:50 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-04-18 14:47:50 +0200 |
commit | 073c3d15c71a0f877b62c7d3d7417a9721da1dba (patch) | |
tree | 83dd1a990857e54ebd91f6ef3f6494e51cdd0f47 /app/assets/javascripts/blob | |
parent | 06952aaf24633550f57fd54b70d27732509935c2 (diff) | |
download | gitlab-ce-073c3d15c71a0f877b62c7d3d7417a9721da1dba.tar.gz |
Initial implementation if license template selector and /licenses/:key API endpoint
Diffstat (limited to 'app/assets/javascripts/blob')
-rw-r--r-- | app/assets/javascripts/blob/blob_license_selector.js.coffee | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/assets/javascripts/blob/blob_license_selector.js.coffee b/app/assets/javascripts/blob/blob_license_selector.js.coffee new file mode 100644 index 00000000000..b43c1ec2bb5 --- /dev/null +++ b/app/assets/javascripts/blob/blob_license_selector.js.coffee @@ -0,0 +1,24 @@ +class @BlobLicenseSelector + licenseRegex: /^(.+\/)?(licen[sc]e|copying)($|\.)/i + + constructor: (editor)-> + self = this + @licenseSelector = $('.js-license-selector') + @toggleLicenseSelector($('#file_name').val()) + + $('#file_name').on 'input', -> + self.toggleLicenseSelector($(this).val()) + + $('select.license-select').select2( + width: 'resolve' + dropdownAutoWidth: true + placeholder: 'Choose a license template' + ).on 'change', (e) -> + Api.licenseText $(this).val(), $(this).data('fullname'), (data) -> + editor.setValue(data, -1) + + toggleLicenseSelector: (fileName) => + if @licenseRegex.test(fileName) + @licenseSelector.show() + else + @licenseSelector.hide() |