aboutsummaryrefslogtreecommitdiffstats
path: root/responsive-ui/lib/persistent-form.js
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-07-25 08:04:13 +0800
committerDan Finlay <dan@danfinlay.com>2017-07-25 08:05:07 +0800
commita22adec66fd0c541eb350ea424a6b00d179eedaf (patch)
tree684b5ffca43944b0aaf33a99dbb6edcdc04e620e /responsive-ui/lib/persistent-form.js
parentfcde52f39070160623be5a03455d9d5c84a99f36 (diff)
downloadtangerine-wallet-browser-a22adec66fd0c541eb350ea424a6b00d179eedaf.tar
tangerine-wallet-browser-a22adec66fd0c541eb350ea424a6b00d179eedaf.tar.gz
tangerine-wallet-browser-a22adec66fd0c541eb350ea424a6b00d179eedaf.tar.bz2
tangerine-wallet-browser-a22adec66fd0c541eb350ea424a6b00d179eedaf.tar.lz
tangerine-wallet-browser-a22adec66fd0c541eb350ea424a6b00d179eedaf.tar.xz
tangerine-wallet-browser-a22adec66fd0c541eb350ea424a6b00d179eedaf.tar.zst
tangerine-wallet-browser-a22adec66fd0c541eb350ea424a6b00d179eedaf.zip
Replace ui with responsive-ui
Diffstat (limited to 'responsive-ui/lib/persistent-form.js')
-rw-r--r--responsive-ui/lib/persistent-form.js61
1 files changed, 0 insertions, 61 deletions
diff --git a/responsive-ui/lib/persistent-form.js b/responsive-ui/lib/persistent-form.js
deleted file mode 100644
index d4dc20b03..000000000
--- a/responsive-ui/lib/persistent-form.js
+++ /dev/null
@@ -1,61 +0,0 @@
-const inherits = require('util').inherits
-const Component = require('react').Component
-const defaultKey = 'persistent-form-default'
-const eventName = 'keyup'
-
-module.exports = PersistentForm
-
-function PersistentForm () {
- Component.call(this)
-}
-
-inherits(PersistentForm, Component)
-
-PersistentForm.prototype.componentDidMount = function () {
- const fields = document.querySelectorAll('[data-persistent-formid]')
- const store = this.getPersistentStore()
-
- for (var i = 0; i < fields.length; i++) {
- const field = fields[i]
- const key = field.getAttribute('data-persistent-formid')
- const cached = store[key]
- if (cached !== undefined) {
- field.value = cached
- }
-
- field.addEventListener(eventName, this.persistentFieldDidUpdate.bind(this))
- }
-}
-
-PersistentForm.prototype.getPersistentStore = function () {
- let store = window.localStorage[this.persistentFormParentId || defaultKey]
- if (store && store !== 'null') {
- store = JSON.parse(store)
- } else {
- store = {}
- }
- return store
-}
-
-PersistentForm.prototype.setPersistentStore = function (newStore) {
- window.localStorage[this.persistentFormParentId || defaultKey] = JSON.stringify(newStore)
-}
-
-PersistentForm.prototype.persistentFieldDidUpdate = function (event) {
- const field = event.target
- const store = this.getPersistentStore()
- const key = field.getAttribute('data-persistent-formid')
- const val = field.value
- store[key] = val
- this.setPersistentStore(store)
-}
-
-PersistentForm.prototype.componentWillUnmount = function () {
- const fields = document.querySelectorAll('[data-persistent-formid]')
- for (var i = 0; i < fields.length; i++) {
- const field = fields[i]
- field.removeEventListener(eventName, this.persistentFieldDidUpdate.bind(this))
- }
- this.setPersistentStore({})
-}
-