Skip to content

Instantly share code, notes, and snippets.

@francisrupert
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save francisrupert/096235233150fc349a9e to your computer and use it in GitHub Desktop.
Save francisrupert/096235233150fc349a9e to your computer and use it in GitHub Desktop.
YUI port of a05
// Stripped out of https://s.yimg.com/zz/combo?ge/tyc/js/1.0/backyard-min.js&ge/tyc/js/1.3/tyc-components-min.js
YUI().use("node", "event", "event-resize", "io", "io-xdr", "json-parse", "node-event-simulate", function (c) {
var b = 1;
c.all('input[type="radio"]').each(function (e) {
var d = e.get("name");
if (d == "govt data requests") {
if (b == 1) {
e.set("checked", true)
} else {
e.set("checked", false)
}
b++
}
});
function a() {
var d = c.one(".a05.is-open");
if ((typeof d !== "undefined") && (d !== null)) {
d.removeClass("is-open")
}
}
c.one("body").delegate("click", function (f) {
var d = f.currentTarget;
var g = d.ancestor(".a05");
if ((typeof g !== "undefined") && (g !== null)) {
if (g.hasClass("is-open")) {
g.removeClass("is-open")
} else {
a();
g.addClass("is-open")
}
}
}, ".a05_open-menu");
c.all(".a05_more-option,.a05_label:not(.a05_open-menu)").on("click", function (d) {
a()
});
c.all('.a05_more-option input[type="radio"]').on("click", function (i) {
var d = i.currentTarget;
var g = d.get("value");
if (typeof g !== "undefined") {
var f = d.ancestor(".a05").one(".a05_label");
var h = d.getData("time");
f.setHTML(g)
}
if (typeof h !== "undefined") {
f.prepend('<span class="a05_labelTime">' + h + "</span>")
}
});
c.all(".a05_flag").on("click", ".a05_more-option", function (f) {
var d = f.currentTarget;
var g = d.ancestor(".a05");
if ((typeof g !== "undefined") && (g !== null)) {
var h = g.all(".a05_more-option");
d.toggleClass("is-selected");
g.addClass("is-flagged");
if (!h.hasClass("is-selected")) {
g.removeClass("is-flagged")
}
}
});
c.all("a.is-disabled").on("click", function (d) {
d.preventDefault()
});
c.all(".js-modalOpen").on("click", function (d) {});
c.one("body").delegate("change", function (g) {
var d = g.currentTarget;
var f = d.getAttribute("data-for");
if (typeof f !== "undefined") {
f = c.one("#" + f);
var h = f.siblings("li");
f.addClass("is-active");
h.removeClass("is-active")
}
}, '.js-toggle-a05-targets [type="radio"]')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment