Feature #29214 » feature-29214-1.patch
| app/views/journals/new.js.erb | ||
|---|---|---|
| 11 | 11 | $('#issue_private_notes').prop('checked', true); | 
| 12 | 12 | <% end %> | 
| 13 | 13 | |
| 14 | addCopyButtonToPreTag(); | |
| app/views/journals/update.js.erb | ||
|---|---|---|
| 7 | 7 |   $("#journal-<%= @journal.id %>-notes").replaceWith('<%= escape_javascript(render_notes(@journal.issue, @journal, :reply_links => authorize_for('issues', 'edit'))) %>'); | 
| 8 | 8 |   $("#journal-<%= @journal.id %>-notes").show(); | 
| 9 | 9 |   $("#journal-<%= @journal.id %>-form").remove(); | 
| 10 | addCopyButtonToPreTag(); | |
| 10 | 11 | <% end %> | 
| 11 | 12 | |
| 12 | 13 | <%= call_hook(:view_journals_update_js_bottom, { :journal => @journal }) %> | 
| public/javascripts/application.js | ||
|---|---|---|
| 1023 | 1023 | }); | 
| 1024 | 1024 | }); | 
| 1025 | 1025 | |
| 1026 | function addCopyButtonToPreTag() { | |
| 1027 |   $('.wiki .copy-contents').remove(); | |
| 1028 | var copyContents = | |
| 1029 |     $("<div class='copy-contents'>").append( | |
| 1030 |       $("<button class='code-copy-button' title='Copy' onclick='copyText($(this).parent().next(\"pre\"), $(this).parent());'>") | |
| 1031 |       .append("<span class='icon-only icon-copy'>") | |
| 1032 | ); | |
| 1033 |   $('.wiki pre').before(copyContents); | |
| 1034 |   $('.code-copy-button[title]').tooltip({ | |
| 1035 |       show: { | |
| 1036 | delay: 400 | |
| 1037 | }, | |
| 1038 |       position: { | |
| 1039 | my: "center bottom-5", | |
| 1040 | at: "center top" | |
| 1041 | } | |
| 1042 | }); | |
| 1043 | } | |
| 1044 | ||
| 1045 | function copyText(target, copyEl) { | |
| 1046 | // Selecting strings in 2 ways for cross-browser support | |
| 1047 | // 1. Use select(); | |
| 1048 |   copyEl.append("<textarea class='tmp'>"); | |
| 1049 |   var tmp = copyEl.find('.tmp'); | |
| 1050 | tmp.val(target.text()); | |
| 1051 | tmp.select(); | |
| 1052 | ||
| 1053 | // 2. Use createRange(); | |
| 1054 | var range = document.createRange(); | |
| 1055 | range.selectNode(target[0]); | |
| 1056 | window.getSelection().removeAllRanges(); | |
| 1057 | window.getSelection().addRange(range); | |
| 1058 | ||
| 1059 | // Copy and Cleanup | |
| 1060 |   var copied = document.execCommand('copy'); | |
| 1061 | window.getSelection().removeAllRanges(); | |
| 1062 | tmp.remove(); | |
| 1063 | ||
| 1064 | // Show copied messages | |
| 1065 |   if (copied){ | |
| 1066 |     copyEl.append("<div class='copied-message'>Copied.</div>"); | |
| 1067 |     var copiedMessage = copyEl.find('.copied-message'); | |
| 1068 | copiedMessage.show(); | |
| 1069 |     copiedMessage.fadeOut('slow', function() { $(this).remove(); }); | |
| 1070 | } | |
| 1071 | } | |
| 1072 | ||
| 1026 | 1073 | function inlineAutoComplete(element) { | 
| 1027 | 1074 | 'use strict'; | 
| 1028 | 1075 | // do not attach if Tribute is already initialized | 
| ... | ... | |
| 1077 | 1124 | $(document).ready(setupAttachmentDetail); | 
| 1078 | 1125 | $(document).ready(setupTabs); | 
| 1079 | 1126 | $(document).ready(setupFilePreviewNavigation); | 
| 1127 | $(document).ready(addCopyButtonToPreTag); | |
| 1080 | 1128 | $(document).on('focus', '[data-auto-complete=true]', function(event) { | 
| 1081 | 1129 | inlineAutoComplete(event.target); | 
| 1082 | 1130 | }); | 
| public/stylesheets/application.css | ||
|---|---|---|
| 1271 | 1271 | |
| 1272 | 1272 | div.wiki img {vertical-align:middle; max-width:100%;} | 
| 1273 | 1273 | |
| 1274 | .copy-contents { | |
| 1275 | position: relative; | |
| 1276 | } | |
| 1277 | ||
| 1278 | .copy-contents .code-copy-button { | |
| 1279 | position: absolute; | |
| 1280 | display: flex; | |
| 1281 | right: -13px; | |
| 1282 | top: 0px; | |
| 1283 | border: none; | |
| 1284 | background-color: transparent; | |
| 1285 | } | |
| 1286 | ||
| 1287 | .copy-contents .copied-message { | |
| 1288 | position: absolute; | |
| 1289 | display: flex; | |
| 1290 | right: -13px; | |
| 1291 | top: 20px; | |
| 1292 | display: none; | |
| 1293 | color:#505050; | |
| 1294 | } | |
| 1295 | ||
| 1296 | .copy-contents .tmp { | |
| 1297 | position: fixed; | |
| 1298 | left: 200%; | |
| 1299 | } | |
| 1300 | ||
| 1274 | 1301 | /***** My page layout *****/ | 
| 1275 | 1302 | .block-receiver { | 
| 1276 | 1303 | border:1px dashed #fff; |