##// END OF EJS Templates
gists: move update button to the left as other forms has action buttons on the left.
marcink -
r4125:9987e5fd default
parent child Browse files
Show More
@@ -1,137 +1,137 b''
1 1 ## -*- coding: utf-8 -*-
2 2 <%inherit file="/base/base.mako"/>
3 3
4 4 <%def name="title()">
5 5 ${_('Edit Gist')} &middot; ${c.gist.gist_access_id}
6 6 %if c.rhodecode_name:
7 7 &middot; ${h.branding(c.rhodecode_name)}
8 8 %endif
9 9 </%def>
10 10
11 11 <%def name="breadcrumbs_links()"></%def>
12 12
13 13 <%def name="menu_bar_nav()">
14 14 ${self.menu_items(active='gists')}
15 15 </%def>
16 16
17 17 <%def name="main()">
18 18 <div class="box">
19 19 <!-- box / title -->
20 20 <div class="title">
21 21
22 22 </div>
23 23
24 24 <div class="table">
25 25 <div id="files_data">
26 26 ${h.secure_form(h.route_path('gist_update', gist_id=c.gist.gist_access_id), id='eform', request=request)}
27 27 <div>
28 28 <input type="hidden" value="${c.file_last_commit.raw_id}" name="parent_hash">
29 29 <div>
30 30 <span class="gist-gravatar">
31 31 ${self.gravatar(h.email_or_none(c.rhodecode_user.full_contact), 30)}
32 32 </span>
33 33 <label for='lifetime'>${_('Gist lifetime')}</label>
34 34 ${h.dropdownmenu('lifetime', '0', c.lifetime_options)}
35 35
36 36 <label for='gist_acl_level'>${_('Gist access level')}</label>
37 37 ${h.dropdownmenu('gist_acl_level', c.gist.acl_level, c.acl_options)}
38 38
39 39 <textarea style="margin-top: 5px; border-color: #dbd9da" id="description" name="description"
40 40 placeholder="${_('Gist description ...')}">${c.gist.gist_description}</textarea>
41 41 </div>
42 42 </div>
43 43
44 44 ## peppercorn schema
45 45 <input type="hidden" name="__start__" value="nodes:sequence"/>
46 46 % for cnt, file in enumerate(c.files):
47 47 <input type="hidden" name="__start__" value="file:mapping"/>
48 48 <div id="codeblock" class="codeblock" >
49 49 <div class="code-header">
50 50 <div class="form">
51 51 <div class="fields">
52 52 <input type="hidden" name="filename_org" value="${file.path}" >
53 53 <input id="filename_${h.FID('f',file.path)}" name="filename" size="30" type="text" value="${file.path}">
54 54 ${h.dropdownmenu('mimetype' ,'plain',[('plain',_('plain'))],enable_filter=True, id='mimetype_'+h.FID('f',file.path))}
55 55 </div>
56 56 </div>
57 57 </div>
58 58 <div class="editor_container">
59 59 <pre id="editor_pre"></pre>
60 60 <textarea id="editor_${h.FID('f',file.path)}" name="content" >${file.content}</textarea>
61 61 </div>
62 62 </div>
63 63 <input type="hidden" name="__end__" />
64 64
65 65 ## dynamic edit box.
66 66 <script type="text/javascript">
67 67 $(document).ready(function(){
68 68 var myCodeMirror = initCodeMirror(
69 69 "editor_${h.FID('f',file.path)}", '');
70 70
71 71 var modes_select = $("#mimetype_${h.FID('f',file.path)}");
72 72 fillCodeMirrorOptions(modes_select);
73 73
74 74 // try to detect the mode based on the file we edit
75 75 var mimetype = "${file.mimetype}";
76 76 var detected_mode = detectCodeMirrorMode(
77 77 "${file.path}", mimetype);
78 78
79 79 if(detected_mode){
80 80 $(modes_select).select2("val", mimetype);
81 81 $(modes_select).change();
82 82 setCodeMirrorMode(myCodeMirror, detected_mode);
83 83 }
84 84
85 85 var filename_selector = "#filename_${h.FID('f',file.path)}";
86 86 // on change of select field set mode
87 87 setCodeMirrorModeFromSelect(
88 88 modes_select, filename_selector, myCodeMirror, null);
89 89
90 90 // on entering the new filename set mode, from given extension
91 91 setCodeMirrorModeFromInput(
92 92 modes_select, filename_selector, myCodeMirror, null);
93 93 });
94 94 </script>
95 95 %endfor
96 96 <input type="hidden" name="__end__" />
97 97
98 <div class="pull-right">
98 <div class="pull-left">
99 99 ${h.submit('update',_('Update Gist'),class_="btn btn-success")}
100 100 <a class="btn" href="${h.route_path('gist_show', gist_id=c.gist.gist_access_id)}">${_('Cancel')}</a>
101 101 </div>
102 102 ${h.end_form()}
103 103 </div>
104 104 </div>
105 105
106 106 </div>
107 107 <script>
108 108 $('#update').on('click', function(e){
109 109 e.preventDefault();
110 110
111 111 $(this).val('Updating...');
112 112 $(this).attr('disabled', 'disabled');
113 113 // check for newer version.
114 114 $.ajax({
115 115 url: "${h.route_path('gist_edit_check_revision', gist_id=c.gist.gist_access_id)}",
116 116 data: {
117 117 'revision': '${c.file_last_commit.raw_id}'
118 118 },
119 119 dataType: 'json',
120 120 type: 'GET',
121 121 success: function(data) {
122 122 if(data.success === false){
123 123 message = '${h.literal(_('Gist was updated since you started editing. Copy your changes and click %(here)s to reload the new version.')
124 124 % {'here': h.link_to('here', h.route_path('gist_edit', gist_id=c.gist.gist_access_id))})}'
125 125 alertMessage = [{"message": {
126 126 "message": message, "force": "true", "level": "warning"}}];
127 127 $.Topic('/notifications').publish(alertMessage[0]);
128 128 }
129 129 else{
130 130 $('#eform').submit();
131 131 }
132 132 }
133 133 });
134 134 })
135 135
136 136 </script>
137 137 </%def>
General Comments 0
You need to be logged in to leave comments. Login now