Sha256: 3b1313197dfd70ff6cb87804cd3494c26dceef28f6aa607b44570ade8e8a7fed
Contents?: true
Size: 1.8 KB
Versions: 32
Compression:
Stored size: 1.8 KB
Contents
// Define the global Renalware namespace if not already defined. var Renalware = typeof Renalware === 'undefined' ? {} : Renalware; // Define the Renalware.PdRegimes closure. Renalware.PdRegimes = (function () { // private functions and vars here var deselectAllBagDays = function() { $(document).on( "click", "a.deselect-bag-days", function(event) { event.preventDefault(); var parent = $(this).closest(".bag-days"); var checkboxes = $(parent).find("input[type='checkbox']"); checkboxes.prop('checked', false); }); }; var duplicateBag = function() { $(document).on( "click", "#pd-regime-bags a.duplicate-bag", function(event) { event.preventDefault(); $("a.add-bag").trigger("click"); var bagToClone = $(this).closest(".fields").first(); var newBag = $("#pd-regime-bags .fields").last(); bagToClone.find('select').each(function(i) { newBag.find('select').eq(i).val($(this).val()); }); var checkedSelector = 'input[type=checkbox],[type=radio]'; bagToClone.find(checkedSelector).each(function(i) { var checked = $(this).is(':checked'); newBag.find(checkedSelector).eq(i).prop('checked', checked); }); }); }; // public functions and vars here return { init : function() { deselectAllBagDays(); duplicateBag(); }, toggleAddRemoveBags : function () { $('input.add-bag').hide(); $('input.remove-bag').hide(); $('a.add-bag').show(); $('a.remove-bag').show(); } } }()); // Bind DOM ready and nested_form:fieldAdded events // so that buttons are toggled when JS is active. $(document).ready(Renalware.PdRegimes.init); $(document).ready(Renalware.PdRegimes.toggleAddRemoveBags); $(document).on('nested:fieldAdded:bags', Renalware.PdRegimes.toggleAddRemoveBags);
Version data entries
32 entries across 32 versions & 1 rubygems