Skip to content

Instantly share code, notes, and snippets.

@jasonrhodes
Created December 19, 2012 03:23
Show Gist options
  • Save jasonrhodes/4334140 to your computer and use it in GitHub Desktop.
Save jasonrhodes/4334140 to your computer and use it in GitHub Desktop.
Drupal fix for the Hub: Remove "issue" options that don't correspond to the content type of the current article, and rename the remaining ones to remove the publication name.
jQuery(document).ready(function ($) {
var options = $("#edit-field-issue-und").find("option");
var body = $("body");
var type;
if (body.hasClass("node-type-magazine-article")) {
type = "magazine";
} else if (body.hasClass("node-type-gazette-article")) {
type = "gazette";
}
options.each(function (i, option) {
var $o = $(option);
var text = $o.text();
var parts = text.split("-").map(function (part) { return $.trim(part); });
if (parts[0].toLowerCase() === type) {
$o.html(parts[1]);
} else {
$o.remove();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment