From e608ff53abdb16a84d3cc8f4ef37949a611d4a5f Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Thu, 27 Feb 2014 14:47:55 -0600 Subject: [PATCH] Add signature to the new ticket page --- include/staff/ticket-open.inc.php | 8 +++++++- js/redactor-osticket.js | 23 ++++++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index ea3c0d64b..b472f4676 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -270,9 +270,15 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); <label><input type='checkbox' value='1' name="append" id="append" checked="checked">Append</label> </div> <?php - } ?> + } + $signature = ''; + if ($thisstaff->getDefaultSignatureType() == 'mine') + $signature = $thisstaff->getSignature(); ?> <textarea class="richtext ifhtml draft draft-delete" data-draft-namespace="ticket.staff.response" + data-signature="<?php + echo Format::htmlchars(Format::viewableImages($signature)); ?>" + data-signature-field="signature" data-dept-field="deptId" placeholder="Intial response for the ticket" name="response" id="response" cols="21" rows="8" style="width:80%;"><?php echo $info['response']; ?></textarea> diff --git a/js/redactor-osticket.js b/js/redactor-osticket.js index fc84b1a16..80500a2a3 100644 --- a/js/redactor-osticket.js +++ b/js/redactor-osticket.js @@ -123,24 +123,37 @@ RedactorPlugins.signature = { init: function() { var $el = $(this.$element.get(0)); if ($el.data('signatureField')) { - var $sig = $('input[name='+$el.data('signatureField')+']', $el.closest('form')) - .on('change', false, false, $.proxy(this.updateSignature, this)), - sel = $('input:checked[name='+$el.data('signatureField')+']', $el.closest('form')); this.$signatureBox = $('<div class="redactor_editor selected-signature"></div>') .html($el.data('signature')) .appendTo(this.$box); + $('input[name='+$el.data('signatureField')+']', $el.closest('form')) + .on('change', false, false, $.proxy(this.updateSignature, this)) + if ($el.data('deptField')) + $(':input[name='+$el.data('deptField')+']', $el.closest('form')) + .on('change', false, false, $.proxy(this.updateSignature, this)) } }, updateSignature: function(e) { var $el = $(this.$element.get(0)); selected = e.target, type = $(selected).val(), - url = 'ajax.php/content/signature/' + type; + dept = $(':input[name='+$el.data('deptField')+']', $el.closest('form')).val(), + url = 'ajax.php/content/signature/'; e.preventDefault && e.preventDefault(); if (type == 'dept' && $el.data('deptId')) - url += '/' + $el.data('deptId'); + url += 'dept/' + $el.data('deptId'); + else if ((type == 'dept' || (type % 1 === 0)) && $el.data('deptField')) { + if (type && type % 1 === 0) + url += 'dept/' + type + else if (type == 'dept' && dept) + url += 'dept/' + dept + else + return this.$signatureBox.empty().hide(); + } else if (type == 'none') return this.$signatureBox.empty().hide(); + else + url += type this.$signatureBox.load(url).show(); } -- GitLab