mod/feedback/amd/src/edit.js

  1. // This file is part of Moodle - http://moodle.org/
  2. //
  3. // Moodle is free software: you can redistribute it and/or modify
  4. // it under the terms of the GNU General Public License as published by
  5. // the Free Software Foundation, either version 3 of the License, or
  6. // (at your option) any later version.
  7. //
  8. // Moodle is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
  15. /**
  16. * Edit items in feedback module
  17. *
  18. * @module mod_feedback/edit
  19. * @copyright 2016 Marina Glancy
  20. */
  21. define(['jquery', 'core/ajax', 'core/str', 'core/notification'],
  22. function($, ajax, str, notification) {
  23. var manager = {
  24. deleteItem: function(e) {
  25. e.preventDefault();
  26. var targetUrl = $(e.currentTarget).attr('href');
  27. str.get_strings([
  28. {
  29. key: 'confirmation',
  30. component: 'admin'
  31. },
  32. {
  33. key: 'confirmdeleteitem',
  34. component: 'mod_feedback'
  35. },
  36. {
  37. key: 'yes',
  38. component: 'moodle'
  39. },
  40. {
  41. key: 'no',
  42. component: 'moodle'
  43. }
  44. ])
  45. .then(function(s) {
  46. notification.confirm(s[0], s[1], s[2], s[3], function() {
  47. window.location = targetUrl;
  48. });
  49. return;
  50. })
  51. .catch();
  52. },
  53. setup: function() {
  54. $('body').delegate('[data-action="delete"]', 'click', manager.deleteItem);
  55. }
  56. };
  57. return {
  58. setup: manager.setup
  59. };
  60. });