summaryrefslogtreecommitdiff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
authorLuke Bennett <lukeeeebennettplus@gmail.com>2016-09-27 22:08:05 +0100
committerFatih Acet <acetfatih@gmail.com>2016-09-28 19:11:11 +0300
commit6bca3a3ed94c1d98a9cfac8b115614c2b8943096 (patch)
treecb1efb0cea4c7e1cbb00c4c7d1a222fc4e8f64dd /app/assets/javascripts
parentee02856d59bcf7998041eaf0bb3d69643203ca35 (diff)
downloadgitlab-ce-6bca3a3ed94c1d98a9cfac8b115614c2b8943096.tar.gz
Review changes
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/blob_edit/edit_blob.js38
1 files changed, 5 insertions, 33 deletions
diff --git a/app/assets/javascripts/blob_edit/edit_blob.js b/app/assets/javascripts/blob_edit/edit_blob.js
index 8f4a2c7ae84..de6cdd851be 100644
--- a/app/assets/javascripts/blob_edit/edit_blob.js
+++ b/app/assets/javascripts/blob_edit/edit_blob.js
@@ -65,45 +65,17 @@
};
EditBlob.prototype.initSoftWrap = function() {
- this.isExplicitySelected = false
- this.$filePathInput = $('#file_path, #file_name');
+ this.isSoftWrapped = false;
this.$toggleButton = $('.soft-wrap-toggle');
- this.$toggleText = $('span', this.$toggleButton);
- this.$noWrapIcon = $('.no-wrap-icon', this.$toggleButton);
- this.$softWrapIcon = $('.soft-wrap-icon', this.$toggleButton);
- this.checkFilePathIsCode();
- this.$filePathInput.on('keyup', _.debounce(this.checkFilePathIsCode.bind(this), 300));
- this.$toggleButton.on('click', this.clickSoftWrapButton.bind(this));
+ this.$toggleButton.on('click', this.toggleSoftWrap.bind(this));
};
- EditBlob.prototype.toggleSoftWrap = function(forceToggle) {
- if (_.isBoolean(forceToggle)) {
- this.isSoftWrapped = forceToggle;
- } else {
- this.isSoftWrapped = !this.isSoftWrapped;
- }
- if(this.isSoftWrapped) {
- this.$toggleText.text('No wrap');
- this.$noWrapIcon.removeClass('hidden');
- this.$softWrapIcon.addClass('hidden');
- } else {
- this.$toggleText.text('Soft wrap');
- this.$softWrapIcon.removeClass('hidden');
- this.$noWrapIcon.addClass('hidden');
- }
+ EditBlob.prototype.toggleSoftWrap = function(e) {
+ this.isSoftWrapped = !this.isSoftWrapped;
+ this.$toggleButton.toggleClass('soft-wrap-active', this.isSoftWrapped);
this.editor.getSession().setUseWrapMode(this.isSoftWrapped);
};
- EditBlob.prototype.checkFilePathIsCode = function() {
- var isNotCode = /^(.*?\.(txt|md)|[^.]*?)$/i.test(this.$filePathInput.val());
- if (!this.isExplicitySelected) this.toggleSoftWrap(isNotCode);
- };
-
- EditBlob.prototype.clickSoftWrapButton = function() {
- if (!this.isExplicitySelected) this.isExplicitySelected = true;
- this.toggleSoftWrap();
- };
-
return EditBlob;
})();