diff options
author | Jacob Schatz <jschatz1@gmail.com> | 2016-07-21 17:33:24 -0400 |
---|---|---|
committer | Jacob Schatz <jschatz1@gmail.com> | 2016-07-21 17:33:24 -0400 |
commit | d2cb058ac9c63a07d0153701ad79bece21ba94ad (patch) | |
tree | 9e650208f7ce1935d77aca34e3486e13a08da8e8 /app/assets/javascripts/blob/edit_blob.js | |
parent | 95c4825a456a4d1df8dba1def8735203368356c9 (diff) | |
download | gitlab-ce-to_vanilla.tar.gz |
Initial commit of coffee to jsto_vanilla
Diffstat (limited to 'app/assets/javascripts/blob/edit_blob.js')
-rw-r--r-- | app/assets/javascripts/blob/edit_blob.js | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/app/assets/javascripts/blob/edit_blob.js b/app/assets/javascripts/blob/edit_blob.js new file mode 100644 index 00000000000..cc464adcc07 --- /dev/null +++ b/app/assets/javascripts/blob/edit_blob.js @@ -0,0 +1,67 @@ +// Generated by CoffeeScript 1.10.0 +(function() { + var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + + this.EditBlob = (function() { + function EditBlob(assets_path, ace_mode) { + if (ace_mode == null) { + ace_mode = null; + } + this.editModeLinkClickHandler = bind(this.editModeLinkClickHandler, this); + ace.config.set("modePath", assets_path + "/ace"); + ace.config.loadModule("ace/ext/searchbox"); + this.editor = ace.edit("editor"); + this.editor.focus(); + if (ace_mode) { + this.editor.getSession().setMode("ace/mode/" + ace_mode); + } + $('form').submit((function(_this) { + return function() { + return $("#file-content").val(_this.editor.getValue()); + }; + })(this)); + this.initModePanesAndLinks(); + new BlobLicenseSelectors({ + editor: this.editor + }); + new BlobGitignoreSelectors({ + editor: this.editor + }); + new BlobCiYamlSelectors({ + editor: this.editor + }); + } + + EditBlob.prototype.initModePanesAndLinks = function() { + this.$editModePanes = $(".js-edit-mode-pane"); + this.$editModeLinks = $(".js-edit-mode a"); + return this.$editModeLinks.click(this.editModeLinkClickHandler); + }; + + EditBlob.prototype.editModeLinkClickHandler = function(event) { + var currentLink, currentPane, paneId; + event.preventDefault(); + currentLink = $(event.target); + paneId = currentLink.attr("href"); + currentPane = this.$editModePanes.filter(paneId); + this.$editModeLinks.parent().removeClass("active hover"); + currentLink.parent().addClass("active hover"); + this.$editModePanes.hide(); + currentPane.fadeIn(200); + if (paneId === "#preview") { + return $.post(currentLink.data("preview-url"), { + content: this.editor.getValue() + }, function(response) { + currentPane.empty().append(response); + return currentPane.syntaxHighlight(); + }); + } else { + return this.editor.focus(); + } + }; + + return EditBlob; + + })(); + +}).call(this); |