/*jslint vars: true, unparam: true, browser: true, white: true */ /*global jQuery */ var IQVOC = (function($) { "use strict"; var createNote = function(ev) { var addButton = $(this); var container = addButton.closest("fieldset"); var source = $("ol li:last-child", container); var inputSelector = "input, select, textarea"; if(source.is(":hidden")) { source.show(); return false; } var clone = source.clone(); var count = source.find(inputSelector)[0].id .match(/_(\d+)_/)[1]; count = String(parseInt(count, 10) + 1); var newIdCount = "_" + count + "_", newNameCount = "[" + count + "]"; clone.find("label").each(function(index, element) { var el = $(element); if(el.attr("for")) { el.attr("for", el.attr("for").replace(/_\d+_/, newIdCount)); } }); clone.find(inputSelector).each(function(index, element) { var el = $(element); el.val(""); if(el.attr("id")) { el.attr("id", el.attr("id").replace(/_\d+_/, newIdCount)); } if(el.attr("name")) { el.attr("name", el.attr("name").replace(/\[\d+\]/, newNameCount)); } }); clone.addClass("new"); $("ol", container).append(clone); return false; }; // work around apparent capybara-webkit issue: // https://github.com/thoughtbot/capybara-webkit/issues/43 var Storage = localStorage || null; if(Storage === null) { Storage = {}; Storage.getItem = function() { return null; }; Storage.setItem = $.noop; } return { Storage: Storage, createNote: createNote }; }(jQuery)); jQuery(document).ready(function($) { "use strict"; IQVOC.quicksearch(".quicksearch"); var locale = document.documentElement.getAttribute("lang"); // language selection $(".dropdown-toggle").click(function(ev) { // use Bootstrap's Dropwdown, but without the side-effects $(this).closest(".dropdown").toggleClass("open"); }); var langWidget = $("ul.lang-widget")[0]; // primary language (converting links to radio buttons) $("a", langWidget).each(function(i, node) { var link = $(node), el = link.closest("li"), btn = $(''); if(link.hasClass("current")) { btn[0].checked = true; } var label = $("