Skip to content

Instantly share code, notes, and snippets.

@skipjac
skipjac / gist:7342375
Created November 6, 2013 19:16
example of ticket.save function for required fields.
onTicketSave: function(){
if(custom_field_A === 'apple'){
if (custom_field_B === ''){
return "please fill out custom field b"
} else if (custom_field_C = ''){
return "please fill out custom field c"
} else {
return true;
}
}
@skipjac
skipjac / hide.css
Last active December 26, 2015 13:59
hide ticket form option values in Zendesk
<script>
$(document).ready(function(){
(function(){
$('option[value="641"]').wrap('<span class="hide-option"></span>');
var isCust;
function isCustomer(element, index, array){
return (element === 'paying');
}
HelpCenter.user.organizations.forEach(function(x){
isCust = x.tags.some(isCustomer);
@skipjac
skipjac / getParameterByName.js
Created October 1, 2013 16:35
get url parameters with javascript
function getParameterByName( name,href )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( href );
if( results == null )
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
@skipjac
skipjac / find_promoted_artilces.hdbs
Created December 24, 2015 06:50
Find promoted articles in a single category using zendesk curly bars
{{#each categories}}
{{! CMS promoted articles }}
{{#is id 202178748}}
<h2>{{name}}</h2>
{{#each sections}}
{{#each articles}}
{{#if promoted}}
<li>
<a href="{{url}}">{{title}}</a>
</li>
@skipjac
skipjac / hideElements.css
Last active December 23, 2015 23:29
Show and hide the "My activities" and "Submit a request" in Zendesk HelpCenter based on Organization tags. Place the code from the hideElements.css in the CSS tab of the theme page. And place the code from showElements.js in the JS tab right after the line ``` $(document).ready(function() { ```
/* ====================================================
things to hide at start up
==================================================== */
a[href$='requests/new'], .my-activities, #user-menu .my-activities {
display: none;
}
@skipjac
skipjac / gist:6503004
Created September 9, 2013 23:38
Hide submit a request and check existing requests from Anonymous users
if(!currentUser.isAnonymous){
$j('.tab_new').show();
$j('.tab_requests').show()
}
events: {
'app.activated': 'appActivated',
'ticket.form.id.changed': 'hideCustomField'
},
appActivated: function() {
this.hideCustomField();
},
hideCustomField: function() {
@skipjac
skipjac / hide-fields-on-group.js
Created May 2, 2013 20:25
This is a Zendesk Classic widget that will hide ticket fields and then only show them with the agent is part of a allowed group list
jQuery(document).ready(function() {
//list of fields to hide
var options = ['#ticket_fields_139051'];
//groups allowed to see the fields
var allowGroups = [88054];
//function to hide a array of arrays
var hide = function(){
@skipjac
skipjac / gist:5413817
Created April 18, 2013 15:49
change the value of Zendesk nested dropdown No Selection label
$j('span#title-tagger-147685').text('skip is 3113t');
$j('#drop-list-tagger-147685 li.link').each(function(){
if($j(this).data('value') === '') {
$j(this).text('Skip is 3113t');
}
});
@skipjac
skipjac / zendeskrequire.js
Last active December 16, 2015 07:38
use to make sure all the fields in zendesk are available
//place these right after return
currAttempt : 0,
MAX_ATTEMPTS : 20,
events: {
'requiredProperties.ready': 'whatever'
}
//
init: function() {