diff options
author | Luke Bennett <lukeeeebennettplus@gmail.com> | 2016-09-28 00:08:05 +0300 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2016-10-01 00:01:47 +0300 |
commit | 70f7d2446a4ba9e301d0f7151a95a52e127f2423 (patch) | |
tree | 700869392db43b9d959fb8c889fecb0b51dd9f2c /app/assets/javascripts/blob_edit | |
parent | 61afa65d4e5e1ea908d90e45364fbb4e0bcfeb56 (diff) |
Review changes
Updated tests
Diffstat (limited to 'app/assets/javascripts/blob_edit')
-rw-r--r-- | app/assets/javascripts/blob_edit/edit_blob.js | 38 |
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; })(); |