Feature #29214 » feature-29214-1.patch
| app/views/journals/new.js.erb | ||
|---|---|---|
|
$('#issue_private_notes').prop('checked', true);
|
||
|
<% end %>
|
||
|
addCopyButtonToPreTag();
|
||
| app/views/journals/update.js.erb | ||
|---|---|---|
|
$("#journal-<%= @journal.id %>-notes").replaceWith('<%= escape_javascript(render_notes(@journal.issue, @journal, :reply_links => authorize_for('issues', 'edit'))) %>');
|
||
|
$("#journal-<%= @journal.id %>-notes").show();
|
||
|
$("#journal-<%= @journal.id %>-form").remove();
|
||
|
addCopyButtonToPreTag();
|
||
|
<% end %>
|
||
|
<%= call_hook(:view_journals_update_js_bottom, { :journal => @journal }) %>
|
||
| public/javascripts/application.js | ||
|---|---|---|
|
});
|
||
|
});
|
||
|
function addCopyButtonToPreTag() {
|
||
|
$('.wiki .copy-contents').remove();
|
||
|
var copyContents =
|
||
|
$("<div class='copy-contents'>").append(
|
||
|
$("<button class='code-copy-button' title='Copy' onclick='copyText($(this).parent().next(\"pre\"), $(this).parent());'>")
|
||
|
.append("<span class='icon-only icon-copy'>")
|
||
|
);
|
||
|
$('.wiki pre').before(copyContents);
|
||
|
$('.code-copy-button[title]').tooltip({
|
||
|
show: {
|
||
|
delay: 400
|
||
|
},
|
||
|
position: {
|
||
|
my: "center bottom-5",
|
||
|
at: "center top"
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
function copyText(target, copyEl) {
|
||
|
// Selecting strings in 2 ways for cross-browser support
|
||
|
// 1. Use select();
|
||
|
copyEl.append("<textarea class='tmp'>");
|
||
|
var tmp = copyEl.find('.tmp');
|
||
|
tmp.val(target.text());
|
||
|
tmp.select();
|
||
|
// 2. Use createRange();
|
||
|
var range = document.createRange();
|
||
|
range.selectNode(target[0]);
|
||
|
window.getSelection().removeAllRanges();
|
||
|
window.getSelection().addRange(range);
|
||
|
// Copy and Cleanup
|
||
|
var copied = document.execCommand('copy');
|
||
|
window.getSelection().removeAllRanges();
|
||
|
tmp.remove();
|
||
|
// Show copied messages
|
||
|
if (copied){
|
||
|
copyEl.append("<div class='copied-message'>Copied.</div>");
|
||
|
var copiedMessage = copyEl.find('.copied-message');
|
||
|
copiedMessage.show();
|
||
|
copiedMessage.fadeOut('slow', function() { $(this).remove(); });
|
||
|
}
|
||
|
}
|
||
|
function inlineAutoComplete(element) {
|
||
|
'use strict';
|
||
|
// do not attach if Tribute is already initialized
|
||
| ... | ... | |
|
$(document).ready(setupAttachmentDetail);
|
||
|
$(document).ready(setupTabs);
|
||
|
$(document).ready(setupFilePreviewNavigation);
|
||
|
$(document).ready(addCopyButtonToPreTag);
|
||
|
$(document).on('focus', '[data-auto-complete=true]', function(event) {
|
||
|
inlineAutoComplete(event.target);
|
||
|
});
|
||
| public/stylesheets/application.css | ||
|---|---|---|
|
div.wiki img {vertical-align:middle; max-width:100%;}
|
||
|
.copy-contents {
|
||
|
position: relative;
|
||
|
}
|
||
|
.copy-contents .code-copy-button {
|
||
|
position: absolute;
|
||
|
display: flex;
|
||
|
right: -13px;
|
||
|
top: 0px;
|
||
|
border: none;
|
||
|
background-color: transparent;
|
||
|
}
|
||
|
.copy-contents .copied-message {
|
||
|
position: absolute;
|
||
|
display: flex;
|
||
|
right: -13px;
|
||
|
top: 20px;
|
||
|
display: none;
|
||
|
color:#505050;
|
||
|
}
|
||
|
.copy-contents .tmp {
|
||
|
position: fixed;
|
||
|
left: 200%;
|
||
|
}
|
||
|
/***** My page layout *****/
|
||
|
.block-receiver {
|
||
|
border:1px dashed #fff;
|
||