This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set and unset checkbox on Web Widget | |
// jQuery is epxected | |
// fieldHandler.setCheckbox("45510285"); // call to set | |
// fieldHandler.unsetCheckbox("45510285"); // call to unset | |
var fieldHandler = (function() { | |
return { | |
getCheckbox: function(field_id) { | |
return $("iframe#webWidget").contents().find('input[name='+field_id+']'); | |
}, | |
setCheckbox: function(field_id) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta charset="utf-8"> | |
<link rel="stylesheet" href="https://assets.zendesk.com/apps/sdk-assets/css/1/zendesk_garden.css" type="text/css"> | |
<style> | |
#main > div { | |
display: block; | |
} | |
</style> | |
</head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
$(document).ready(function() { | |
(function(f, l, lh, isR){ // redirect to ticket form page if not already form page, requests page or article page | |
f = 151485, l = window.location, lh = l.href, isR = !(l.search.match("ticket_form_id") || lh.indexOf('/requests') > -1 || lh.indexOf('/articles') > -1), | |
hc = HelpCenter, isU = hc && (hc.user.role !== 'manager' && hc.user.role !== 'agent'); | |
if (isR && isU) l.replace("/hc/"+document.getElementsByTagName("html")[0].lang.toLowerCase()+"/requests/new?ticket_form_id="+f); | |
})(); | |
}); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
(function(f, l, lh, isR){ // redirect to ticket form page if not already form page, requests page or article page | |
f = 151485, l = window.location, lh = l.href, isR = !(l.search.match("ticket_form_id") || lh.indexOf('/requests') > -1 || lh.indexOf('/articles') > -1); | |
if (isR {{#if signed_in}}&& false{{/if}}) l.replace("/hc/"+document.getElementsByTagName("html")[0].lang.toLowerCase()+"/requests/new?ticket_form_id="+f); | |
})(); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- the web widget --> | |
<script> | |
window.zEmbed||(function(){ | |
var queue = []; | |
window.zEmbed = function() { queue.push(arguments); } | |
window.zE = window.zE || window.zEmbed; | |
document.zendeskHost = 'mycompany.zendesk.com'; | |
document.zEQueue = queue; | |
}()); | |
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Preset given nested dropdown on Zendesk Help Center with a given value | |
* | |
* @param {String} field_id (example: 'request_custom_fields_31265065') | |
* @param {String} field_value (example: 'complaint_type_b') | |
*/ | |
function presetNestedDrodown(field_id,field_value){ | |
if (!field_id || field_value === undefined) return; | |
var $field = $('.'+field_id); | |
if ($field && $field.length > 0 && $field.hasClass('string')) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************************ | |
Help Center cutomization (ver 1.0.1) | |
Preset & hide Subject field based on custom field value, | |
Move Subject and Description fields. | |
************************************************************/ | |
if (document.location.search.indexOf('ticket_form_id') > -1) { | |
(function () { | |
var settings = { // change settings here | |
"hide_subject": true, | |
"133425":"request_custom_fields_31616405", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( document.location.href.indexOf('/requests/new') > -1 ) { | |
// move fields | |
var $att = $('div.form-field').last(); | |
$('.request_subject').insertBefore($att); | |
$('.request_description').insertBefore($att); | |
// set subject | |
var field_val = $('#request_custom_fields_31616405').val(); | |
$('#request_subject').val(field_val).change(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Quick and dirty way to read URL parameters and set given ticket fields | |
Expected URL example https://sarapulov.zendesk.com/hc/en-us/requests/new?ticket_form_id=72316&country=bhutan&age=21 | |
CODE CONTAIN BUGS! | |
*/ | |
if ( window.location.search.match("ticket_form_id") ) { | |
function getUrlParameter(param) { | |
if (!param) return ''; | |
var href = window.location.href; | |
if (param === 'locale') return href.split('/hc/')[1].split('/')[0]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************************ | |
Change HC locale in the URL for everyone who is not on Request Page | |
************************************************/ | |
if (/*HelpCenter.user.role != 'anonymous' &&*/ !window.location.pathname.match('/requests/')) { | |
(function() { | |
var url = window.location.pathname; | |
expected_locale = 'en-us', | |
current_locale = url.split('/hc/')[1].split('/')[0], | |
is_expected_locale = current_locale === expected_locale; | |
if (!is_expected_locale) window.location.pathname = url.replace(current_locale,expected_locale); |