ref: master
plugins/volunteers/public/javascripts/volunteers.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
volunteers = { periods: { load: function() { $('#volunteers-periods .period').each(function() { volunteers.periods.applyDaterangepicker(this) }) $('#period-new input').prop('disabled', true) }, new: function() { var period = $('#volunteers-periods-template').html() period = period.replace(/_new_/g, new Date().getTime()) period = $(period) period.find('input').prop('disabled', false) this.applyDaterangepicker(period) return period }, add: function() { $('.periods').append(this.new()) }, remove: function(link) { link = $(link) var period = link.parents('.period') period.find('input[name*=_destroy]').prop('value', '1') period.hide() }, applyDaterangepicker: function(period) { orders.daterangepicker.init($(period).find('.daterangepicker-field')) }, }, assignments: { toggle: function(period) { period = $(period) $.get(period.attr('data-toggle-url'), function(data) { $(period).replaceWith(data) }) }, }, }; |