summaryrefslogtreecommitdiff
path: root/app/assets
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/blob_edit/edit_blob.js38
-rw-r--r--app/assets/stylesheets/pages/editor.scss18
2 files changed, 23 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;
})();
diff --git a/app/assets/stylesheets/pages/editor.scss b/app/assets/stylesheets/pages/editor.scss
index ffd6089c100..e1304335271 100644
--- a/app/assets/stylesheets/pages/editor.scss
+++ b/app/assets/stylesheets/pages/editor.scss
@@ -68,6 +68,24 @@
font-family: $regular_font;
}
+ .soft-wrap-toggle {
+ margin: 0 $btn-side-margin;
+ .soft-wrap {
+ display: block;
+ }
+ .no-wrap {
+ display: none;
+ }
+ &.soft-wrap-active {
+ .soft-wrap {
+ display: none;
+ }
+ .no-wrap {
+ display: block;
+ }
+ }
+ }
+
.gitignore-selector, .license-selector, .gitlab-ci-yml-selector {
.dropdown {
line-height: 21px;