automatically assign the video tag for youtube.com urls

This commit is contained in:
joshua stein 2012-09-10 13:57:08 -05:00
parent 600b1c2b93
commit 66917339cc

View file

@ -113,14 +113,21 @@
Lobsters.previewStory($(this).parents("form").first());
});
/* if the url looks like a pdf, select the pdf tag */
$("#story_url").unbind().live("blur", function() {
/* if the url looks like a pdf, assign the pdf tag */
if ($("#story_url").val().match(/\.pdf$/i)) {
var ta = $("#story_tags_a").data("select2");
if (ta.getVal().indexOf("pdf") < 0)
ta.addSelectedChoice({ id: "pdf" });
}
/* if the url looks like a youtube url, assign the video tag */
else if ($("#story_url").val().match(/[\/\.]youtube\.com\//i)) {
var ta = $("#story_tags_a").data("select2");
if (ta.getVal().indexOf("video") < 0)
ta.addSelectedChoice({ id: "video" });
}
});
<% end %>