|
4 | 4 | <dtml-var manage_tabs> |
5 | 5 | </dtml-with> |
6 | 6 |
|
| 7 | +<style> |
| 8 | + button#copyToClipboard { |
| 9 | + position: absolute; |
| 10 | + right: 1rem; |
| 11 | + z-index: 10; |
| 12 | + } |
| 13 | +</style> |
| 14 | + |
7 | 15 | <main class="container-fluid"> |
8 | 16 |
|
9 | 17 | <dtml-let num_rows="REQUEST.get('num_rows') or 20"> |
|
25 | 33 | </p> |
26 | 34 | <dtml-in args mapping> |
27 | 35 | <div class="form-group row"> |
28 | | - <label for="&dtml-name;" |
29 | | - class="form-label col-sm-3 col-md-2">&dtml-name;</label> |
30 | | - |
31 | | - <dtml-let typ="type or REQUEST.get('%s_type' % name, 'string')"> |
32 | | - <div class="col-sm-3 col-md-2"> |
33 | | - <select name="&dtml-name;_type" class="form-control"> |
| 36 | + <div class="input-group col"> |
| 37 | + <label for="&dtml-name;" |
| 38 | + class="form-control col-sm-3 col-md-2 input-group-text bg-light"> |
| 39 | + <code>&dtml-name;</code> |
| 40 | + </label> |
| 41 | + <dtml-let typ="type or REQUEST.get('%s_type' % name, 'string')"> |
| 42 | + <select name="&dtml-name;_type" class="form-control col-sm-3 col-md-2"> |
34 | 43 | <option <dtml-if "typ == 'float'">selected</dtml-if>> |
35 | 44 | float |
36 | 45 | </option> |
|
44 | 53 | tokens |
45 | 54 | </option> |
46 | 55 | </select> |
47 | | - </div> |
48 | | - </dtml-let> |
49 | | - |
50 | | - <div class="col-sm-6 col-md-7"> |
51 | | - <input type="text" class="form-control" size="40" |
52 | | - name="&dtml-name;" |
53 | | - id="&dtml-name;" |
54 | | - value="<dtml-var "REQUEST.get(name, default)">"/> |
| 56 | + </dtml-let> |
| 57 | + <input type="text" class="form-control" |
| 58 | + name="&dtml-name;" |
| 59 | + id="&dtml-name;" |
| 60 | + value="<dtml-var "REQUEST.get(name, default)">"/> |
55 | 61 | </div> |
56 | 62 | </div> |
57 | 63 | </dtml-in> |
|
62 | 68 | </dtml-let> |
63 | 69 |
|
64 | 70 | <div class="form-group row"> |
65 | | - <label for="num_rows" |
66 | | - class="form-label col-sm-3 col-md-2">Rows per page</label> |
67 | | - <div class="col-sm-3 col-md-2"> |
68 | | - <select name="num_rows" class="form-control"> |
| 71 | + <div class="input-group col"> |
| 72 | + <label for="num_rows" |
| 73 | + class="form-control col-sm-3 col-md-2 input-group-text bg-light text-muted"> |
| 74 | + Rows per page |
| 75 | + </label> |
| 76 | + <select name="num_rows" class="form-control col-sm-3 col-md-2"> |
69 | 77 | <dtml-in "[10, 20, 50, 100, 500, 1000]"> |
70 | 78 | <option <dtml-if "_.int(num_rows)==_['sequence-item']">selected</dtml-if>> |
71 | 79 | <dtml-var sequence-item> |
|
92 | 100 | The final query sent to the database may contain additional |
93 | 101 | elements inserted automatically, such as a <em>LIMIT</em> clause. |
94 | 102 | </p> |
95 | | - <pre class="form-control code col-sm-12 bg-dark text-white small border-0" |
| 103 | + <button type="button" class="btn btn-secondary mt-0" |
| 104 | + id="copyToClipboard" title="Copy to Clipboard"> |
| 105 | + <i class="fas fa-copy"></i> |
| 106 | + </button> |
| 107 | + <pre class="form-control code col-sm-12 bg-dark text-white small border-dark" |
96 | 108 | name="template:text" data-contenttype="sql" |
97 | 109 | ><dtml-var "this().manage_zmi_test(REQUEST, src__=1)" html_quote></pre> |
98 | 110 |
|
|
192 | 204 | </dtml-try> |
193 | 205 |
|
194 | 206 | <script> |
195 | | - $(function() { |
196 | | - editor.setOptions({ |
197 | | - 'readOnly': true, |
| 207 | + $(function() { |
| 208 | + try { |
| 209 | + editor.setOptions({ |
| 210 | + 'readOnly': true, |
| 211 | + }); |
| 212 | + } catch (err) { |
| 213 | + // Ignore |
| 214 | + } |
| 215 | + $('#copyToClipboard').on('click', function(e) { |
| 216 | + const $icon = $(e.currentTarget).find('i'); |
| 217 | + const tempInput = document.createElement('textarea'); |
| 218 | + tempInput.value = document.querySelector('pre[name="template:text"]').innerText; |
| 219 | + document.body.appendChild(tempInput); |
| 220 | + tempInput.select(); |
| 221 | + try { |
| 222 | + document.execCommand('copy'); |
| 223 | + $icon.removeClass('fa-copy').addClass('fa-check'); |
| 224 | + setTimeout(function() { |
| 225 | + $icon.removeClass('fa-check').addClass('fa-copy'); |
| 226 | + }, 2000); |
| 227 | + } catch (err) { |
| 228 | + alert('Failed to copy text: ' + err); |
| 229 | + } |
| 230 | + document.body.removeChild(tempInput); |
| 231 | + }); |
198 | 232 | }); |
199 | | - }); |
200 | 233 | </script> |
201 | 234 |
|
202 | 235 | <dtml-except> |
|
0 commit comments