2013-03-23 15:13:51 -04:00
.snippet-form-holder
2015-12-02 08:39:39 -05:00
= form_for @snippet, url: url, html: { class: "form-horizontal snippet-form js-requires-input" } do |f|
2016-04-04 21:25:38 -04:00
= form_errors(@snippet)
2013-03-23 15:13:51 -04:00
2013-12-30 18:27:02 -05:00
.form-group
2014-01-11 12:15:47 -05:00
= f.label :title, class: 'control-label'
2015-12-02 08:36:44 -05:00
.col-sm-10
= f.text_field :title, class: 'form-control', required: true, autofocus: true
2014-06-14 05:36:46 -04:00
2015-04-26 01:01:52 -04:00
= render 'shared/visibility_level', f: f, visibility_level: visibility_level, can_change_visibility_level: true, form_model: @snippet
2015-05-16 16:09:04 -04:00
2015-06-15 18:58:58 -04:00
.file-editor
.form-group
2014-01-11 12:15:47 -05:00
= f.label :file_name, "File", class: 'control-label'
2013-12-30 18:27:02 -05:00
.col-sm-10
2013-07-13 02:52:47 -04:00
.file-holder.snippet
.file-title
2015-06-12 10:15:44 -04:00
= f.text_field :file_name, placeholder: "Optionally name this file to add code highlighting, e.g. example.rb for Ruby.", class: 'form-control snippet-file-name'
2013-07-13 02:52:47 -04:00
.file-content.code
2013-03-23 15:13:51 -04:00
%pre#editor= @snippet.content
= f.hidden_field :content, class: 'snippet-file-content'
.form-actions
2013-08-12 05:08:52 -04:00
- if @snippet.new_record?
= f.submit 'Create snippet', class: "btn-create btn"
- else
2015-12-02 08:33:14 -05:00
= f.submit 'Save changes', class: "btn-save btn"
2013-03-23 15:13:51 -04:00
2015-05-14 20:15:06 -04:00
- if @snippet.project_id
2015-01-24 13:02:58 -05:00
= link_to "Cancel", namespace_project_snippets_path(@project.namespace, @project), class: "btn btn-cancel"
2014-06-14 05:36:46 -04:00
- else
= link_to "Cancel", snippets_path(@project), class: "btn btn-cancel"
2013-03-23 15:13:51 -04:00
:javascript
var editor = ace.edit("editor");
$(".snippet-form-holder form").submit(function(){
$(".snippet-file-content").val(editor.getValue());
});