diff options
author | Clement Ho <clemmakesapps@gmail.com> | 2018-02-28 18:40:06 +0000 |
---|---|---|
committer | Clement Ho <clemmakesapps@gmail.com> | 2018-02-28 18:40:06 +0000 |
commit | 9353c5c780c7af6d6ed3d6c501b155f82debc99c (patch) | |
tree | 55d87571798f5ff10ee1431a296f1115251f67e9 /app/assets/javascripts/autosave.js | |
parent | c287c01821c4db4830dbdd5263907f08c2ed4cc4 (diff) | |
parent | e2638c3ff2714e5efd4bc54e64555fc564c84af1 (diff) | |
download | gitlab-ce-pipelines_show_refactor.tar.gz |
Merge branch 'master' into 'pipelines_show_refactor'pipelines_show_refactor
# Conflicts:
# config/webpack.config.js
Diffstat (limited to 'app/assets/javascripts/autosave.js')
-rw-r--r-- | app/assets/javascripts/autosave.js | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/app/assets/javascripts/autosave.js b/app/assets/javascripts/autosave.js index 0f28bd233ac..0da872db7e5 100644 --- a/app/assets/javascripts/autosave.js +++ b/app/assets/javascripts/autosave.js @@ -3,10 +3,10 @@ import AccessorUtilities from './lib/utils/accessor'; export default class Autosave { - constructor(field, key, resource) { + constructor(field, key) { this.field = field; + this.isLocalStorageAvailable = AccessorUtilities.isLocalStorageAccessSafe(); - this.resource = resource; if (key.join != null) { key = key.join('/'); } @@ -17,31 +17,27 @@ export default class Autosave { } restore() { - var text; - if (!this.isLocalStorageAvailable) return; + if (!this.field.length) return; - text = window.localStorage.getItem(this.key); + const text = window.localStorage.getItem(this.key); if ((text != null ? text.length : void 0) > 0) { this.field.val(text); } - if (!this.resource && this.resource !== 'issue') { - this.field.trigger('input'); - } else { - // v-model does not update with jQuery trigger - // https://github.com/vuejs/vue/issues/2804#issuecomment-216968137 - const event = new Event('change', { bubbles: true, cancelable: false }); - const field = this.field.get(0); - if (field) { - field.dispatchEvent(event); - } - } + + this.field.trigger('input'); + // v-model does not update with jQuery trigger + // https://github.com/vuejs/vue/issues/2804#issuecomment-216968137 + const event = new Event('change', { bubbles: true, cancelable: false }); + const field = this.field.get(0); + field.dispatchEvent(event); } save() { - var text; - text = this.field.val(); + if (!this.field.length) return; + + const text = this.field.val(); if (this.isLocalStorageAvailable && (text != null ? text.length : void 0) > 0) { return window.localStorage.setItem(this.key, text); |