Sha256: 2af28e64f9a439adff4addec8a5118e7742701c5604e82b3d8d81742456d14a9
Contents?: true
Size: 1.94 KB
Versions: 89
Compression:
Stored size: 1.94 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); $(document).on('ready ajaxSuccess', function(event, xhr, status) { $("#peritonitis_episode_types .searchable_select").select2(); });
Version data entries
89 entries across 89 versions & 1 rubygems