Skip to content

Instantly share code, notes, and snippets.

View rruhlen's full-sized avatar

Ricky Ruhlen rruhlen

  • San Francisco, CA
View GitHub Profile
@rruhlen
rruhlen / require_customfield.js
Created September 17, 2013 23:06
JS to require a custom field.
<script type="text/javascript">
$(document).ready(function()
{
$("#ticket_custom1").rules("add", {
required: true,
messages: {
required: "Required",
}
@rruhlen
rruhlen / liquid_detect_language
Created September 18, 2013 18:44
Liquid to detect language.
{% case system.language%}
{%when 'de'%}
German translation
{%when 'es_es'%}
Spanish translation
{%when 'fr_ca'%}
French Canadian translation
{%when 'fr_fr'%}
French translation
{%when 'it'%}
@rruhlen
rruhlen / multilingual_translations
Last active July 20, 2017 17:20
liquid to translate the article ratings for multiple language.
<script type="text/javascript">
$(function(){
$("#rate_article div:nth-child(1) a").click(function(){
$("#rate_article").css("visibility", "hidden");
window.setTimeout(showHello, 1000);
}).next().text("{{article_yes}}");
$("#rate_article div:nth-child(2) a").click(function(){
$("#rate_article").css("visibility", "hidden");
window.setTimeout(showHello, 1000);
@rruhlen
rruhlen / jira_ondemand.html
Created September 18, 2013 23:02
Create a quick link with a Jira OnDemand instance.
<div class="case_one_col">
<span class="tab_label">
Quick JIRA Link
</span>
<div class="case_quick_jira">
<a id="quick_bug_{{case.id}}" href="https://site_name.atlassian.net/secure/CreateIssueDetails!init.jspa?pid=10013&issuetype=1&summary={{ case.subject | remove_first:'→' | remove_first:'←' |escape}}&priority=3&customfield_10721={{case.customer.company|escape}}%20-%20https://site_name.desk.com/agent/case/{{case.id}}%20%28{{ case.created_at | date: "%m/%d/%Y"}}%29&description={{case.emails.first.body|escape}}" target="jira">Bug</a>
</div>
</div>
@rruhlen
rruhlen / liquid_example
Created September 19, 2013 21:56
example of how to assign translations to a variable with liquid.
{% case system.language %}
{% when 'de' %}
{% assign customer_number_label = 'Kunden Nr.' %}
{% assign order_number_label = 'Bestell Nr.' %}
{% when 'en' %}
{% assign customer_number_label = 'Customer No.' %}
{% assign order_number_label = 'Order No.' %}
{% endcase %}
@rruhlen
rruhlen / linkedlist_js
Created October 9, 2013 19:14
Example to show how to restrict which values are displayed in a drop-down depending on which value is selected in the drop-down it is dependent on. This example is for the case theme and not the email form on the web theme.
<script type="text/javascript">
$(document).ready(function() {
{% if case.custom_product == '11x' %}
$(".case-{{case.id}} #ticket_custom6 option[value='Configuration']").remove();
$(".case-{{case.id}} #ticket_custom6 option[value='Defect']").remove();
$(".case-{{case.id}} #ticket_custom6 option[value='Enhancement']").remove();
$(".case-{{case.id}} #ticket_custom6 option[value='Production XP']").remove();
@rruhlen
rruhlen / contact_us_translation.text
Created October 17, 2013 16:45
liquid translation example for contact us section.
{% capture contactus_de_content %}
<p><h1><b>Telefonsupport</b></h1>
Der Telefonsupport ist in englischer Sprache verfügbar, 7 Tage/Woche,
von 07:00 Uhr bis 20:00 Uhr Pacific Time (GMT -08:00),
unter dieser Rufnummer:<p></p>
<a href="tel:+18584953532">&#x260e; +1 858 495 3532</a><br>
<!-- {{ URI }} -->
</p>
@rruhlen
rruhlen / js_validation
Last active March 27, 2017 22:54
example to make a custom field required.
<script type="text/javascript">
$(document).ready(function() {
$("#ticket_custom1").rules("add", {
required: true,
messages: {
required: "Required Field",
}
});
@rruhlen
rruhlen / translate_message.js
Created October 30, 2013 17:31
translate article rating thank you message
<script type="text/javascript">
$(function() {
$(".rate_link").click(function() {
$("#rate_article").hide();
$("#rate_article_container").html("{{system.snippets.thank_you}}");
});
});
</script>
@rruhlen
rruhlen / topics_liquid
Created November 6, 2013 01:13
liquid to display specific topics
{% for topic in topics %}
{% if topic.article_count > 0 %}
{%if topic.id == 559243 or topic.id == 569843 or topic.id == 945865 %}
{% else %}
{% endif %}
{% endif %}
{% endfor %}