diff options
author | Louise Crow <louise.crow@gmail.com> | 2014-12-18 15:24:30 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2014-12-18 15:24:30 +0000 |
commit | 5cfcdaac505e60914ee4398cfe431bd5d21b58ed (patch) | |
tree | 43c2ce66dda3e291cf2dc1aa688a48b2dc5ef45a /app/assets/javascripts/admin/holidays.js | |
parent | f0bbeb4abf4bf07e5cfb46668f39bbff72ed7210 (diff) | |
parent | 1d6acb2af8e3f4c4926f47f097466c5e2acdac68 (diff) |
Merge branch 'admin-public-holiday-interface' into rails-3-develop
Diffstat (limited to 'app/assets/javascripts/admin/holidays.js')
-rw-r--r-- | app/assets/javascripts/admin/holidays.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/app/assets/javascripts/admin/holidays.js b/app/assets/javascripts/admin/holidays.js new file mode 100644 index 000000000..55eae9e2a --- /dev/null +++ b/app/assets/javascripts/admin/holidays.js @@ -0,0 +1,46 @@ +$(function() { + + // New button loads the 'new' form via AJAX + $('#new-holiday-button').click(function(){ + var new_call = $.ajax({ type: 'GET', url: $(this).attr('href')}); + new_call.done(function(response) { + $('#existing-holidays').before(response); + }); + return false; + + }); + + // Each edit button loads the 'edit' form for that holiday via AJAX + $('.holiday').each(function(index){ + var holiday_row = $(this); + var edit_button = holiday_row.find('.edit-button'); + edit_button.click(function(){ + var edit_call = $.ajax({ type: 'GET', url: holiday_row.data('target') }); + edit_call.done(function(response) { + holiday_row.html(response); + }); + return false; + }); + }); + + // Remove button removes form div for holiday from an import set + $('.remove-holiday').each(function(index){ + $(this).click(function(){ + $(this).parents('.import-holiday-info').remove(); + return false; + }); + }); + + if ($('#holiday_import_source_suggestions').is(':checked')){ + $('#holiday_import_ical_feed_url').attr("disabled", "disabled"); + } + // Enable and disable the feed element when that is selected as the import source + $('#holiday_import_source_feed').click(function(){ + $('#holiday_import_ical_feed_url').removeAttr("disabled"); + }); + + $('#holiday_import_source_suggestions').click(function(){ + $('#holiday_import_ical_feed_url').attr("disabled", "disabled"); + }); + +}); |