Created
October 4, 2011 03:10
-
-
Save yahelc/1260820 to your computer and use it in GitHub Desktop.
"Chosen" for Zendesk Client Selector (BSD only!)
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
In Chrome, no prep necessary. | |
In Firefox, be sure you've installed Greasemonkey. | |
To install: Click "Raw" on the top right of chosen-for-bsd-harvest.user.js -----↓ | |
To get an updated version after installing: | |
You'll need to uninstall and re-install it from scratch. | |
Use at your own risk. Might break if Zendesk changes their markup. | |
Click "Raw" to install ↓ |
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
// ==UserScript== | |
// @name Chosen for BSD Zendesk Client Selector | |
// @author Yahel Carmon | |
// @description Uses Chosen for Zendesk Client Selector. Might break if they change anything. Use at your own risk. Only works for BSD (for now) | |
// @namespace https://gist.github.com/gists/1260820 | |
// @include http://bluestatedigital.zendesk.com/tickets/* | |
// @include https://bluestatedigital.zendesk.com/tickets/* | |
// @match http://bluestatedigital.zendesk.com/tickets/* | |
// @match https://bluestatedigital.zendesk.com/tickets/* | |
// ==/UserScript== | |
(function(){ | |
var ga = document.createElement("script"); | |
ga.src = "https://gist.github.com/raw/1260820/73f3c02fd55a13bea3e14101a2c144b6b5ce3c8b/gistfile1.js"; | |
var s = document.getElementsByTagName('script')[0]; | |
s.parentNode.insertBefore(ga, s); | |
}()); |
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
jQuery(function($) { | |
$("<div class='select'><label for='chosen'>Better Client Selector</label><select id='chosen'></select></div><div class='select'><a id='showold' style='float:right;display:block;margin: 7px 0 12px 0;padding-left:2em;'>Toggle old client selector</a></div>").appendTo("#ticket_custom_fields"); | |
var $chosen = $("#chosen"); | |
var current = jQuery("#ticket_fields_46189").val(); | |
$("#drop-list-tagger-46189 li").each(function() { | |
$this = $(this); | |
if($this.data("full-title")){ | |
var selected = ''; | |
if(current && current == $this.data("value") ) { selected=' selected="selected" '; }; | |
$chosen.append("<option value='" + $this.data("value") + "' "+ selected +" >" + $this.data("full-title") + '</option>'); | |
} | |
}); | |
$("<link>").attr({ | |
type: 'text/css', | |
rel: 'stylesheet', | |
href: "https://www.bluestatedigital.com/page/-/js/analytics/stylesheets/chosen.css" | |
}).appendTo("head"); | |
$.ajax({ | |
cache: true, | |
url: 'https://raw.github.com/harvesthq/chosen/master/chosen/chosen.jquery.js', | |
dataType: "script", | |
success: function() { | |
$chosen.chosen().change(function() { | |
$("#title-tagger-46189").text($("#chosen option:selected").text()); | |
$("#ticket_fields_46189").val($(this).val()); | |
}); | |
$("#showold").click(function(e){ e.preventDefault(); $("#ticket_fields_46189").closest("div").toggle();}).click(); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(Judging from the numbers on the IDs, this will probably only work on the BSD Zendesk.)
Once we have some testing, I'll turn it into a user script.