my-pages.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // force the page to re-load if the back button was used
  2. $(window).bind("pageshow", function(event) {
  3. if (event.originalEvent.persisted) {
  4. window.location.reload();
  5. }
  6. });
  7. var app = new Vue({
  8. el: "#app",
  9. data: {
  10. pages: []
  11. },
  12. mounted: function() {
  13. this.getAllPages();
  14. },
  15. methods: {
  16. getAllPages: function() {
  17. $.ajax({
  18. url: "/api/page/user/all/",
  19. method: "GET",
  20. success: function(data) {
  21. app.pages = data;
  22. }
  23. });
  24. },
  25. millisToDate: millisToDate,
  26. onCreateAmendment: function(pageId) {
  27. let formData = new FormData();
  28. formData.append("pageId", pageId);
  29. $.ajax({
  30. url: "/api/page/amendment/",
  31. method: "POST",
  32. data: formData,
  33. cache: false,
  34. contentType: false,
  35. processData: false,
  36. success: function(data) {
  37. window.location.href = "/edit/amendment/" + data.id;
  38. },
  39. error: toast.defaultAjaxError
  40. });
  41. },
  42. onDeleteAmendmentClicked: deleteAmendment,
  43. onDeleteDraftClicked: deleteDraft
  44. },
  45. updated: function() {
  46. $("#brand-name").addClass("active");
  47. $(".tooltip")
  48. .popup("destroy")
  49. .popup();
  50. }
  51. });