##// END OF EJS Templates
templates: remove references to non-existing commit-message class...
Thomas De Schampheleire -
r7253:eddb927e default
parent child Browse files
Show More
@@ -1,174 +1,174 b''
1 1 ## -*- coding: utf-8 -*-
2 2 <%inherit file="/base/base.html"/>
3 3
4 4 <%block name="title">
5 5 ${_('Edit Gist')} &middot; ${c.gist.gist_access_id}
6 6 </%block>
7 7
8 8 <%block name="js_extra">
9 9 <script type="text/javascript" src="${h.url('/codemirror/lib/codemirror.js')}"></script>
10 10 <script type="text/javascript" src="${h.url('/js/codemirror_loadmode.js')}"></script>
11 11 <script type="text/javascript" src="${h.url('/codemirror/mode/meta.js')}"></script>
12 12 </%block>
13 13 <%block name="css_extra">
14 14 <link rel="stylesheet" type="text/css" href="${h.url('/codemirror/lib/codemirror.css')}"/>
15 15 </%block>
16 16
17 17 <%def name="breadcrumbs_links()">
18 18 ${_('Edit Gist')} &middot; ${c.gist.gist_access_id}
19 19 </%def>
20 20
21 21 <%block name="header_menu">
22 22 ${self.menu('gists')}
23 23 </%block>
24 24
25 25 <%def name="main()">
26 26 <div class="panel panel-primary">
27 27 <div class="panel-heading clearfix">
28 28 ${self.breadcrumbs()}
29 29 </div>
30 30
31 31 <div class="panel-body">
32 32 <div id="edit_error" style="display: none" class="flash_msg">
33 33 <div class="alert alert-dismissable alert-warning">
34 34 <button type="button" class="close" data-dismiss="alert" aria-hidden="true"><i class="icon-cancel-circled"></i></button>
35 35 ${h.literal(_('Gist was update since you started editing. Copy your changes and click %(here)s to reload new version.')
36 36 % {'here': h.link_to('here',h.url('edit_gist', gist_id=c.gist.gist_access_id))})}
37 37 </div>
38 38 <script>
39 39 if (typeof jQuery != 'undefined') {
40 40 $(".alert").alert();
41 41 }
42 42 </script>
43 43 </div>
44 44
45 45 <div id="files_data">
46 46 ${h.form(h.url('edit_gist', gist_id=c.gist.gist_access_id), method='post', id='eform')}
47 47 <div>
48 48 <input type="hidden" value="${c.file_changeset.raw_id}" name="parent_hash">
49 <textarea class="form-control commit-message"
49 <textarea class="form-control"
50 50 id="description" name="description"
51 51 placeholder="${_('Gist description ...')}">${c.gist.gist_description}</textarea>
52 52 <div>
53 53 <label>
54 54 ${_('Gist lifetime')}
55 55 ${h.select('lifetime', '0', c.lifetime_options)}
56 56 </label>
57 57 <span class="text-muted">
58 58 %if c.gist.gist_expires == -1:
59 59 ${_('Expires')}: ${_('Never')}
60 60 %else:
61 61 ${_('Expires')}: ${h.age(h.time_to_datetime(c.gist.gist_expires))}
62 62 %endif
63 63 </span>
64 64 </div>
65 65 </div>
66 66
67 67 % for cnt, file in enumerate(c.files):
68 68 <div id="body" class="panel panel-default form-inline">
69 69 <div class="panel-heading">
70 70 <input type="hidden" value="${h.safe_unicode(file.path)}" name="org_files">
71 71 <input class="form-control" id="filename_${h.FID('f',file.path)}" name="files" size="30" type="text" value="${h.safe_unicode(file.path)}">
72 72 <select class="form-control" id="mimetype_${h.FID('f',file.path)}" name="mimetypes"></select>
73 73 </div>
74 74 <div class="panel-body no-padding">
75 75 <div id="editor_container">
76 76 <textarea id="editor_${h.FID('f',file.path)}" name="contents" style="display:none">${file.content}</textarea>
77 77 </div>
78 78 </div>
79 79 </div>
80 80
81 81 ## dynamic edit box.
82 82 <script type="text/javascript">
83 83 $(document).ready(function(){
84 84 var myCodeMirror = initCodeMirror(${h.js('editor_' + h.FID('f',file.path))}, ${h.jshtml(request.script_name)}, '');
85 85
86 86 //inject new modes
87 87 var $mimetype_select = $(${h.js('#mimetype_' + h.FID('f',file.path))});
88 88 $mimetype_select.each(function(){
89 89 var modes_select = this;
90 90 var index = 1;
91 91 for(var i=0;i<CodeMirror.modeInfo.length;i++) {
92 92 var m = CodeMirror.modeInfo[i];
93 93 var opt = new Option(m.name, m.mime);
94 94 $(opt).attr('mode', m.mode);
95 95 if (m.mime == 'text/plain') {
96 96 // default plain text
97 97 $(opt).prop('selected', true);
98 98 modes_select.options[0] = opt;
99 99 } else {
100 100 modes_select.options[index++] = opt;
101 101 }
102 102 }
103 103 });
104 104
105 105 var $filename_input = $(${h.js('#filename_' + h.FID('f',file.path))});
106 106 // on select change set new mode
107 107 $mimetype_select.change(function(e){
108 108 var selected = e.currentTarget;
109 109 var node = selected.options[selected.selectedIndex];
110 110 var detected_mode = CodeMirror.findModeByMIME(node.value);
111 111 setCodeMirrorMode(myCodeMirror, detected_mode);
112 112
113 113 var proposed_ext = CodeMirror.findExtensionByMode(detected_mode);
114 114 var file_data = CodeMirror.getFilenameAndExt($filename_input.val());
115 115 var filename = file_data['filename'] || 'filename1';
116 116 $filename_input.val(filename + '.' + proposed_ext);
117 117 });
118 118
119 119 // on type the new filename set mode
120 120 $filename_input.keyup(function(e){
121 121 var file_data = CodeMirror.getFilenameAndExt(this.value);
122 122 if(file_data['ext'] != null){
123 123 var detected_mode = CodeMirror.findModeByExtension(file_data['ext']) || CodeMirror.findModeByMIME('text/plain');
124 124
125 125 if (detected_mode){
126 126 setCodeMirrorMode(myCodeMirror, detected_mode);
127 127 $mimetype_select.val(detected_mode.mime);
128 128 }
129 129 }
130 130 });
131 131
132 132 // set mode on page load
133 133 var detected_mode = CodeMirror.findModeByExtension(${h.js(file.extension)});
134 134
135 135 if (detected_mode){
136 136 setCodeMirrorMode(myCodeMirror, detected_mode);
137 137 $mimetype_select.val(detected_mode.mime);
138 138 }
139 139 });
140 140 </script>
141 141
142 142 %endfor
143 143
144 144 <div>
145 145 ${h.submit('update',_('Update Gist'),class_="btn btn-success")}
146 146 <a class="btn btn-default" href="${h.url('gist', gist_id=c.gist.gist_access_id)}">${_('Cancel')}</a>
147 147 </div>
148 148 ${h.end_form()}
149 149 <script>
150 150 $('#update').on('click', function(e){
151 151 e.preventDefault();
152 152
153 153 // check for newer version.
154 154 $.ajax({
155 155 url: ${h.js(h.url('edit_gist_check_revision', gist_id=c.gist.gist_access_id))},
156 156 data: {'revision': ${h.js(c.file_changeset.raw_id)}, '_authentication_token': _authentication_token},
157 157 dataType: 'json',
158 158 type: 'POST',
159 159 success: function(data) {
160 160 if(data.success == false){
161 161 $('#edit_error').show();
162 162 }
163 163 else{
164 164 $('#eform').submit();
165 165 }
166 166 }
167 167 });
168 168 });
169 169 </script>
170 170 </div>
171 171 </div>
172 172
173 173 </div>
174 174 </%def>
@@ -1,112 +1,112 b''
1 1 ## -*- coding: utf-8 -*-
2 2 <%inherit file="/base/base.html"/>
3 3
4 4 <%block name="title">
5 5 ${_('New Gist')}
6 6 </%block>
7 7
8 8 <%block name="js_extra">
9 9 <script type="text/javascript" src="${h.url('/codemirror/lib/codemirror.js')}"></script>
10 10 <script type="text/javascript" src="${h.url('/js/codemirror_loadmode.js')}"></script>
11 11 <script type="text/javascript" src="${h.url('/codemirror/mode/meta.js')}"></script>
12 12 </%block>
13 13 <%block name="css_extra">
14 14 <link rel="stylesheet" type="text/css" href="${h.url('/codemirror/lib/codemirror.css')}"/>
15 15 </%block>
16 16
17 17 <%def name="breadcrumbs_links()">
18 18 ${_('New Gist')}
19 19 </%def>
20 20
21 21 <%block name="header_menu">
22 22 ${self.menu('gists')}
23 23 </%block>
24 24
25 25 <%def name="main()">
26 26 <div class="panel panel-primary">
27 27 <div class="panel-heading clearfix">
28 28 ${self.breadcrumbs()}
29 29 </div>
30 30
31 31 <div class="panel-body">
32 32 <div id="files_data">
33 33 ${h.form(h.url('gists'), method='post',id='eform')}
34 34 <div>
35 <textarea class="form-control commit-message" id="description" name="description" placeholder="${_('Gist description ...')}"></textarea>
35 <textarea class="form-control" id="description" name="description" placeholder="${_('Gist description ...')}"></textarea>
36 36 <div>
37 37 <label>
38 38 ${_('Gist lifetime')}
39 39 ${h.select('lifetime', '', c.lifetime_options)}
40 40 </label>
41 41 </div>
42 42 </div>
43 43 <div id="body" class="panel panel-default form-inline">
44 44 <div class="panel-heading">
45 45 ${h.text('filename', size=30, placeholder=_('Name this gist ...'), class_='form-control')}
46 46 <select class="form-control" id="mimetype" name="mimetype"></select>
47 47 </div>
48 48 <div class="panel-body no-padding">
49 49 <textarea id="editor" name="content"></textarea>
50 50 </div>
51 51 </div>
52 52 <div>
53 53 ${h.submit('private',_('Create Private Gist'),class_="btn btn-success btn-xs")}
54 54 ${h.submit('public',_('Create Public Gist'),class_="btn btn-default btn-xs")}
55 55 ${h.reset('reset',_('Reset'),class_="btn btn-default btn-xs")}
56 56 </div>
57 57 ${h.end_form()}
58 58 <script type="text/javascript">
59 59 $(document).ready(function(){
60 60 var myCodeMirror = initCodeMirror('editor', ${h.jshtml(request.script_name)}, '');
61 61
62 62 //inject new modes
63 63 var $mimetype_select = $('#mimetype');
64 64 $mimetype_select.each(function(){
65 65 var modes_select = this;
66 66 var index = 1;
67 67 for(var i=0;i<CodeMirror.modeInfo.length;i++) {
68 68 var m = CodeMirror.modeInfo[i];
69 69 var opt = new Option(m.name, m.mime);
70 70 $(opt).attr('mode', m.mode);
71 71 if (m.mime == 'text/plain') {
72 72 // default plain text
73 73 $(opt).prop('selected', true);
74 74 modes_select.options[0] = opt;
75 75 } else {
76 76 modes_select.options[index++] = opt;
77 77 }
78 78 }
79 79 });
80 80
81 81 var $filename_input = $('#filename');
82 82 // on select change set new mode
83 83 $mimetype_select.change(function(e){
84 84 var selected = e.currentTarget;
85 85 var node = selected.options[selected.selectedIndex];
86 86 var detected_mode = CodeMirror.findModeByMIME(node.value);
87 87 setCodeMirrorMode(myCodeMirror, detected_mode);
88 88
89 89 var proposed_ext = CodeMirror.findExtensionByMode(detected_mode);
90 90 var file_data = CodeMirror.getFilenameAndExt($filename_input.val());
91 91 var filename = file_data['filename'] || 'filename1';
92 92 $filename_input.val(filename + '.' + proposed_ext);
93 93 });
94 94
95 95 // on type the new filename set mode
96 96 $filename_input.keyup(function(e){
97 97 var file_data = CodeMirror.getFilenameAndExt(this.value);
98 98 if(file_data['ext'] != null){
99 99 var detected_mode = CodeMirror.findModeByExtension(file_data['ext']) || CodeMirror.findModeByMIME('text/plain');
100 100 if (detected_mode){
101 101 setCodeMirrorMode(myCodeMirror, detected_mode);
102 102 $mimetype_select.val(detected_mode.mime);
103 103 }
104 104 }
105 105 });
106 106 });
107 107 </script>
108 108 </div>
109 109 </div>
110 110
111 111 </div>
112 112 </%def>
@@ -1,125 +1,125 b''
1 1 <%inherit file="/base/base.html"/>
2 2
3 3 <%block name="title">
4 4 ${_('%s Files Add') % c.repo_name}
5 5 </%block>
6 6
7 7 <%block name="js_extra">
8 8 <script type="text/javascript" src="${h.url('/codemirror/lib/codemirror.js')}"></script>
9 9 <script type="text/javascript" src="${h.url('/js/codemirror_loadmode.js')}"></script>
10 10 <script type="text/javascript" src="${h.url('/codemirror/mode/meta.js')}"></script>
11 11 </%block>
12 12 <%block name="css_extra">
13 13 <link rel="stylesheet" type="text/css" href="${h.url('/codemirror/lib/codemirror.css')}"/>
14 14 </%block>
15 15
16 16 <%block name="header_menu">
17 17 ${self.menu('repositories')}
18 18 </%block>
19 19
20 20 <%def name="breadcrumbs_links()">
21 21 ${_('Add New File')} @ ${h.show_id(c.cs)}
22 22 </%def>
23 23
24 24 <%def name="main()">
25 25 ${self.repo_context_bar('files')}
26 26 <div class="panel panel-primary">
27 27 <div class="panel-heading clearfix">
28 28 <div class="pull-left">
29 29 ${self.breadcrumbs()}
30 30 </div>
31 31 <div class="pull-right">
32 32 <a href="#">${_('Branch')}: ${c.cs.branch}</a>
33 33 </div>
34 34 </div>
35 35 <div class="panel-body" id="edit">
36 36 <div id="files_data">
37 37 ${h.form(h.url.current(),method='post',id='eform',enctype="multipart/form-data", class_="form-inline")}
38 38 <h3 class="files_location">
39 39 ${_('Location')}: ${h.files_breadcrumbs(c.repo_name,c.cs.raw_id,c.f_path)} /
40 40 <span id="filename_container" class="file">
41 41 <input class="form-control input-small" type="text" value="" size="30" name="filename" id="filename" placeholder="${_('Enter filename...')}">
42 42 <input type="hidden" value="${c.f_path}" name="location" id="location">
43 43 ${_('or')} <button type="button" class="btn btn-default btn-sm" id="upload_file_enable">${_('Upload File')}</button>
44 44 </span>
45 45 <span id="upload_file_container" style="display:none">
46 46 <input class="form-control" type="file" size="20" name="upload_file" id="upload_file">
47 47 ${_('or')} <button type="button" class="btn btn-default btn-sm" id="file_enable">${_('Create New File')}</button>
48 48 </span>
49 49 </h3>
50 50 <div id="body" class="panel panel-default">
51 51 <div class="panel-heading clearfix">
52 52 <div class="pull-left">
53 53 <label>${_('New file type')}
54 54 <select class="form-control" id="mimetype" name="mimetype"></select>
55 55 </label>
56 56 </div>
57 57 </div>
58 58 <div class="panel-body no-padding">
59 59 <textarea id="editor" name="content" style="display:none"></textarea>
60 60 </div>
61 61 </div>
62 62 <div>
63 63 <div>
64 64 <div>${_('Commit Message')}</div>
65 <textarea class="form-control commit-message" name="message" placeholder="${c.default_message}"></textarea>
65 <textarea class="form-control" name="message" placeholder="${c.default_message}"></textarea>
66 66 </div>
67 67 <div class="buttons">
68 68 ${h.submit('commit',_('Commit Changes'),class_="btn btn-success")}
69 69 ${h.reset('reset',_('Reset'),class_="btn btn-default")}
70 70 </div>
71 71 </div>
72 72 ${h.end_form()}
73 73 <script type="text/javascript">
74 74 $(document).ready(function(){
75 75 var reset_url = ${h.jshtml(h.url('files_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.f_path))};
76 76 var myCodeMirror = initCodeMirror('editor', ${h.jshtml(request.script_name)}, reset_url);
77 77
78 78 //inject new modes, based on codeMirrors modeInfo object
79 79 var $mimetype_select = $('#mimetype');
80 80 $mimetype_select.each(function(){
81 81 var modes_select = this;
82 82 var index = 1;
83 83 for(var i=0;i<CodeMirror.modeInfo.length;i++){
84 84 var m = CodeMirror.modeInfo[i];
85 85 var opt = new Option(m.name, m.mime);
86 86 $(opt).attr('mode', m.mode);
87 87 if (m.mime == 'text/plain') {
88 88 // default plain text
89 89 $(opt).prop('selected', true);
90 90 modes_select.options[0] = opt;
91 91 } else {
92 92 modes_select.options[index++] = opt;
93 93 }
94 94 }
95 95 });
96 96 var $filename_input = $('#filename');
97 97 $mimetype_select.change(function(e){
98 98 var selected = e.currentTarget;
99 99 var node = selected.options[selected.selectedIndex];
100 100 var detected_mode = CodeMirror.findModeByMIME(node.value);
101 101 setCodeMirrorMode(myCodeMirror, detected_mode);
102 102
103 103 var proposed_ext = CodeMirror.findExtensionByMode(detected_mode);
104 104 var file_data = CodeMirror.getFilenameAndExt($filename_input.val());
105 105 var filename = file_data['filename'] || 'filename1';
106 106 $filename_input.val(filename + '.' + proposed_ext);
107 107 });
108 108
109 109 // on type the new filename set mode
110 110 $filename_input.keyup(function(e){
111 111 var file_data = CodeMirror.getFilenameAndExt(this.value);
112 112 if(file_data['ext'] != null){
113 113 var detected_mode = CodeMirror.findModeByExtension(file_data['ext']) || CodeMirror.findModeByMIME('text/plain');
114 114 if (detected_mode){
115 115 setCodeMirrorMode(myCodeMirror, detected_mode);
116 116 $mimetype_select.val(detected_mode.mime);
117 117 }
118 118 }
119 119 });
120 120 });
121 121 </script>
122 122 </div>
123 123 </div>
124 124 </div>
125 125 </%def>
@@ -1,47 +1,47 b''
1 1 <%inherit file="/base/base.html"/>
2 2
3 3 <%block name="title">
4 4 ${_('%s Files Delete') % c.repo_name}
5 5 </%block>
6 6
7 7 <%block name="header_menu">
8 8 ${self.menu('repositories')}
9 9 </%block>
10 10
11 11 <%def name="breadcrumbs_links()">
12 12 ${_('Delete file')} @ ${h.show_id(c.cs)}
13 13 </%def>
14 14
15 15 <%def name="main()">
16 16 ${self.repo_context_bar('files')}
17 17 <div class="panel panel-primary">
18 18 <div class="panel-heading clearfix">
19 19 <div class="pull-left">
20 20 ${self.breadcrumbs()}
21 21 </div>
22 22 <div class="pull-right">
23 23 <a href="#">${_('Branch')}: ${c.cs.branch}</a>
24 24 </div>
25 25 </div>
26 26 <div class="panel-body" id="edit">
27 27 <div id="files_data">
28 28 ${h.form(h.url.current(),method='post')}
29 29 <h3 class="files_location">
30 30 ${_('Delete file')}: ${h.files_breadcrumbs(c.repo_name,c.cs.raw_id,c.f_path)}
31 31 </h3>
32 32
33 33 <div id="body" class="panel panel-default">
34 34 <div class="panel-heading">${_('Commit Message')}</div>
35 35 <div class="panel-body">
36 <textarea class="form-control commit-message" name="message" placeholder="${c.default_message}"></textarea>
36 <textarea class="form-control" name="message" placeholder="${c.default_message}"></textarea>
37 37 </div>
38 38 </div>
39 39 <div>
40 40 ${h.submit('commit',_('Commit Changes'),class_="btn btn-success btn-sm")}
41 41 ${h.reset('reset',_('Reset'),class_="btn btn-default btn-sm")}
42 42 </div>
43 43 ${h.end_form()}
44 44 </div>
45 45 </div>
46 46 </div>
47 47 </%def>
@@ -1,118 +1,118 b''
1 1 <%inherit file="/base/base.html"/>
2 2
3 3 <%block name="title">
4 4 ${_('%s File Edit') % c.repo_name}
5 5 </%block>
6 6
7 7 <%block name="js_extra">
8 8 <script type="text/javascript" src="${h.url('/codemirror/lib/codemirror.js')}"></script>
9 9 <script type="text/javascript" src="${h.url('/js/codemirror_loadmode.js')}"></script>
10 10 <script type="text/javascript" src="${h.url('/codemirror/mode/meta.js')}"></script>
11 11 </%block>
12 12 <%block name="css_extra">
13 13 <link rel="stylesheet" type="text/css" href="${h.url('/codemirror/lib/codemirror.css')}"/>
14 14 </%block>
15 15
16 16 <%block name="header_menu">
17 17 ${self.menu('repositories')}
18 18 </%block>
19 19
20 20 <%def name="breadcrumbs_links()">
21 21 ${_('Edit file')} @ ${h.show_id(c.cs)}
22 22 </%def>
23 23
24 24 <%def name="main()">
25 25 ${self.repo_context_bar('files')}
26 26 <div class="panel panel-primary">
27 27 <div class="panel-heading clearfix">
28 28 <div class="pull-left">
29 29 ${self.breadcrumbs()}
30 30 </div>
31 31 <div class="pull-right">
32 32 <a href="#">${_('Branch')}: ${c.cs.branch}</a>
33 33 </div>
34 34 </div>
35 35 <div class="panel-body" id="edit">
36 36 <div id="files_data">
37 37 ${h.form(h.url.current(),method='post',id='eform')}
38 38 <h3 class="files_location">
39 39 ${_('Location')}: ${h.files_breadcrumbs(c.repo_name,c.cs.raw_id,c.file.path)}
40 40 </h3>
41 41 <div id="body" class="panel panel-default">
42 42 <div class="panel-heading clearfix form-inline form-group-sm">
43 43 <span>
44 44 <span><i class="icon-doc-inv"></i></span>
45 45 <span>${h.link_to(h.show_id(c.file.changeset),h.url('changeset_home',repo_name=c.repo_name,revision=c.file.changeset.raw_id))}</span>
46 46 <span>${h.format_byte_size(c.file.size,binary=True)}</span>
47 47 <span>${c.file.mimetype}</span>
48 48 <select class="form-control" id="mimetype" name="mimetype"></select>
49 49 </span>
50 50 <span class="pull-right buttons">
51 51 ${h.link_to(_('Show Annotation'),h.url('files_annotate_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.f_path),class_="btn btn-default btn-xs")}
52 52 ${h.link_to(_('Show as Raw'),h.url('files_raw_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.f_path),class_="btn btn-default btn-xs")}
53 53 ${h.link_to(_('Download as Raw'),h.url('files_rawfile_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.f_path),class_="btn btn-default btn-xs")}
54 54 % if h.HasRepoPermissionLevel('write')(c.repo_name):
55 55 % if not c.file.is_binary:
56 56 ${h.link_to(_('Source'),h.url('files_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.f_path),class_="btn btn-default btn-xs")}
57 57 % endif
58 58 % endif
59 59 </span>
60 60 </div>
61 61 <div class="panel-body no-padding">
62 62 <textarea id="editor" name="content" style="display:none">${h.escape(c.file.content)|n}</textarea>
63 63 </div>
64 64 </div>
65 65 <div>
66 66 <div class="form-group">
67 67 <label>${_('Commit Message')}</label>
68 <textarea class="form-control commit-message" id="commit" name="message" placeholder="${c.default_message}"></textarea>
68 <textarea class="form-control" id="commit" name="message" placeholder="${c.default_message}"></textarea>
69 69 </div>
70 70 <div class="form-group buttons">
71 71 ${h.submit('commit',_('Commit Changes'),class_="btn btn-success")}
72 72 ${h.reset('reset',_('Reset'),class_="btn btn-default")}
73 73 </div>
74 74 </div>
75 75 ${h.end_form()}
76 76 </div>
77 77 </div>
78 78 </div>
79 79
80 80 <script type="text/javascript">
81 81 $(document).ready(function(){
82 82 var reset_url = ${h.jshtml(h.url('files_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.file.path))};
83 83 var myCodeMirror = initCodeMirror('editor', ${h.jshtml(request.script_name)}, reset_url);
84 84
85 85 //inject new modes, based on codeMirrors modeInfo object
86 86 var $mimetype_select = $('#mimetype');
87 87 $mimetype_select.each(function(){
88 88 var modes_select = this;
89 89 var index = 1;
90 90 for(var i=0;i<CodeMirror.modeInfo.length;i++){
91 91 var m = CodeMirror.modeInfo[i];
92 92 var opt = new Option(m.name, m.mime);
93 93 $(opt).attr('mode', m.mode);
94 94 if (m.mime == 'text/plain') {
95 95 // default plain text
96 96 $(opt).prop('selected', true);
97 97 modes_select.options[0] = opt;
98 98 } else {
99 99 modes_select.options[index++] = opt;
100 100 }
101 101 }
102 102 });
103 103 // try to detect the mode based on the file we edit
104 104 var detected_mode = CodeMirror.findModeByExtension(${h.js(c.file.extension)});
105 105 if(detected_mode){
106 106 setCodeMirrorMode(myCodeMirror, detected_mode);
107 107 $($mimetype_select.find('option[value="'+detected_mode.mime+'"]')[0]).prop('selected', true);
108 108 }
109 109
110 110 $mimetype_select.on('change', function(e){
111 111 var selected = e.currentTarget;
112 112 var node = selected.options[selected.selectedIndex];
113 113 var detected_mode = CodeMirror.findModeByMIME(node.value);
114 114 setCodeMirrorMode(myCodeMirror, detected_mode);
115 115 });
116 116 });
117 117 </script>
118 118 </%def>
General Comments 0
You need to be logged in to leave comments. Login now