Skip to content

Instantly share code, notes, and snippets.

@tstachl
Created June 20, 2014 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tstachl/4acc61f065d9d5d4a1b0 to your computer and use it in GitHub Desktop.
Save tstachl/4acc61f065d9d5d4a1b0 to your computer and use it in GitHub Desktop.
This is some javascript and css code that allows you to have tabbed email and note replies in desk.com.
<script>
$(function() {
var tid = $('#tabs .ui-state-active a').attr('href').replace('#tabs-tid_', '')
, sel = '#email_reply_div_tid_' + tid
setTimeout(function() {
$(sel).prepend([
'<div>',
' <ul class="reply-toggle">',
' <li class="active">',
' <a href=".a-ticket-reply">Email</a>',
' </li>',
' <li>',
' <a href=".a-note-reply">Note</a>',
' </li>',
' </ul>',
'</div>'
].join(''));
$(sel).append('<div class="a-note-reply hide">');
$(sel + ' .a-yellow-button').hide();
$.ajax($(sel + ' a.HK_add_note_link').attr('href'), {
dataType: 'text',
success: function(text) {
var form = $('<div>' + text.match(/html\('(.*)'\)/)[1].replace(/\\n/g, '').replace(/\\/gi, '') + '</div>');
form.find('.a-modal-actions .a-cancel').remove();
form.find('.a-modal-actions .a-button.accept').prop('disabled', false).attr('onclick', function(idx, attr) {
return 'resetNote("' + sel + '");' + attr;
});
$(sel + ' .a-note-reply').append(form.html());
$(sel + ' .a-ticket-reply .a-user-icon').clone().insertBefore(sel + ' .a-note-reply .a-textarea');
}
});
$(sel + ' .reply-toggle').on('click', 'li a', function() {
$(this).closest('.reply-toggle').find('li').removeClass('active');
$(this).closest('li').addClass('active');
$(sel + ' .a-note-reply').addClass('hide');
$(sel + ' .a-ticket-reply').addClass('hide');
$(sel + ' ' + $(this).attr('href')).removeClass('hide').find('textarea').focus();
return false;
});
$(sel + ' .reply-toggle a[href=".a-note-reply"]').click();
}, 500);
window.resetNote = function(sel) {
setTimeout(function() {
$(sel + ' .a-note-reply textarea').val('');
$(sel + ' .a-note-reply .a-modal-actions .a-button.accept').prop('disabled', false);
}, 500);
};
});
</script>
<style>
ul.reply-toggle { background: #D3C5E5; }
ul.reply-toggle li { display: inline-block; cursor: pointer; }
ul.reply-toggle li a { color: #2F2F2F; padding: 10px; display: block; }
ul.reply-toggle li:hover { background: #AC96C9; }
ul.reply-toggle li:hover a { color: #FFF; }
ul.reply-toggle li.active { background: #EFE9F7; }
ul.reply-toggle li.active a { color: #2F2F2F; }
.a-note-reply { padding: 25px 15px 10px; }
.a-note-reply .a-user-icon { float: left; }
.a-note-reply .a-modal-actions, .a-note-reply .a-textarea, .a-note-reply .agent_light_text { margin: 0 12px 0 65px; display: block; }
.a-note-reply .a-modal-actions:after { display: block; content: ''; clear: both; }
.a-note-reply .a-textarea, .a-note-reply textarea { background: lightyellow; }
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment