Skip to content

Instantly share code, notes, and snippets.

@skipjac
skipjac / gist:cc9242432bbb8fc0e006
Created March 9, 2015 21:55
Place this in your new request template Zendesk
<script>
$(document).ready(function() {
jQuery.extend({
getQueryParameters : function(str) {
return (str || document.location.search).replace(/(^\?)/,'').split("&").map(function(n){return n = n.split("="),this[n[0]] = n[1],this}.bind({}))[0];
}
});
var queryParameters = $.getQueryParameters();
@skipjac
skipjac / gist:8af6bca6b036c891e1e0
Created February 18, 2015 06:51
Remove a option from zendesk ticket form options in Help Center
//remove the options from the select
$('#request_issue_type_select option[value="43517"]').remove();
//remove the option from the nesty-input after it's been created.
$('div').one('DOMNodeInserted', function(e){
$('.nesty-panel').one('DOMNodeInserted', function(e){
$(this).children('ul').children().remove('#43517');
});
});
@skipjac
skipjac / gist:c58125b768e686b8e2b9
Created February 17, 2015 18:59
hide ticket forms in Zendesk
<script>
$(document).ready(function() {
$('#request_issue_type_select option[value="631"]').wrap('<span class="hide-option"></span>');
});
</script>
@skipjac
skipjac / global.css
Created November 25, 2014 00:36
Changing the size of HelpCenter nesty fields.
.nesty-input {
max-width: 555px;
}
@skipjac
skipjac / submit.js
Last active August 29, 2015 14:10
change submit a request to contact us and point to a zendesk form
$('a.submit-a-request').text('Contact Us').attr('href', function(){return this +'?ticket_form_id=18434';}).addClass('contact-info');
@skipjac
skipjac / more.js
Last active August 29, 2015 14:08
This changes the not selected label in zendesk helpcenter
//this function will walk all the way down the JSON object into all the arrays and create flat JSON object.
function flattenObject(ob) {
var toReturn = {};
for (var i in ob) {
if (!ob.hasOwnProperty(i)) continue;
if ((typeof ob[i]) == 'object' && ob[i] !== null) {
var flatObject = flattenObject(ob[i]);
for (var x in flatObject) {
if (!flatObject.hasOwnProperty(x)) continue;
toReturn[i + '.' + x] = flatObject[x];
@skipjac
skipjac / gist:2f82078f0cc5f84044dd
Created October 8, 2014 22:35
playing with the date in Zendesk placeholders
{{ticket.created_at}} old {{ticket.created_at_with_time | date: "%B %d %H:%M %Z" }}
{% capture day %}{{ticket.updated_at | date: "%d" }}{% endcapture %}
{% capture month %}{{ticket.updated_at | date: "%B" }}{% endcapture %}
new {{ticket.updated_at | date: "%B"}} {{day | plus:2}}</br>
{% capture dayCheck %}{{day | plus:2}}{% endcapture %}
{{dayCheck}}</br>
{% if month == 'January' %}
{% if dayCheck > '31' %}
{% assign month = 'February' %}
@skipjac
skipjac / app.js
Created October 8, 2014 04:42
hijack Zendesk's notification system
$(document).ready(function() {
if ( $('.promoted-articles ul li a:contains("Issue")').length > 0 ){
console.log( $('.promoted-articles ul li a:contains("Issue")').first().parent().html());
$('.notification-text').html(
'<i class="fa fa-warning"></i> ' +
$('.promoted-articles ul li a:contains("Issue")').first().parent().html()
);
$('.notification').show();
}
@skipjac
skipjac / hc_ticket_fields.html
Last active August 29, 2015 14:02
Set default dropdown values in Zendesk Help Center. This is just the code to set the actual value.
<div class="form-field string required request_custom_fields_21631456">
<label for="request_custom_fields_21631456">fav</label>
<input autocomplete="off" data-tagger=data-tagger="{"-":{"id":"","title":"-","selected":true},"pet":{"cat":{"id":"cat","title":"pet::cat"},"dog":{"id":"dog","title":"pet::dog"}},"Dolphin":{"id":"dolphin","title":"Dolphin"},"the fish":{"id":"the_fish","title":"the fish"}}" id="request_custom_fields_21631456" name="request[custom_fields][21631456]" size="0" type="hidden" value="">
<a class="nesty-input" tabindex="0">-</a>
</div>
<script>
//in order to set the value of the field and make it visible set the input value and anchor text
//so this will set the field fav to The fish
$('.request_custom_fields_21631456').one('DOMNodeInserted', function(d){
@skipjac
skipjac / gist:bdaee1ce41e65c2166cf
Created June 13, 2014 17:43
Proof of concept to get labels for article pages in zendesk helpcenter
<script>
var getPath = document.location.pathname;
var locID = getPath.split('/');
$.ajax({
type: "GET",
url: 'https://yourdomain.zendesk.com/api/v2/help_center/articles/'+locID[locID.length -1]+'.json',
success: function(data){console.log(data)},
dataType: 'application/json',
contentType: 'application/json'
});