Welcome to mirror list, hosted at ThFree Co, Russian Federation.

unsaved_changes_confirm_dialog.vue « components « static_site_editor « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 255f029bd27105e45bfde91093be88544819e18c (plain)
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
<script>
export default {
  props: {
    modified: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  created() {
    window.addEventListener('beforeunload', this.requestConfirmation);
  },
  destroyed() {
    window.removeEventListener('beforeunload', this.requestConfirmation);
  },
  methods: {
    requestConfirmation(e) {
      if (this.modified) {
        e.preventDefault();
        // eslint-disable-next-line no-param-reassign
        e.returnValue = '';
      }
    },
  },
  render: () => null,
};
</script>