summaryrefslogtreecommitdiffhomepage
path: root/app
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@codeispoetry.ru>2017-03-10 19:40:24 +0000
committerAndrej Mihajlov <and@codeispoetry.ru>2017-03-10 19:40:24 +0000
commit41cb468e59d1b8b25d8455e2ff70a0404ea6f0e2 (patch)
treebeee0f14f20aa2130ad92f27eab55cc5499ef8f7 /app
parentd6246d5e59e2d894ffc20a8a84737e742f55bb4e (diff)
downloadmullvadvpn-41cb468e59d1b8b25d8455e2ff70a0404ea6f0e2.tar.xz
mullvadvpn-41cb468e59d1b8b25d8455e2ff70a0404ea6f0e2.zip
Update docs
Diffstat (limited to 'app')
-rw-r--r--app/components/AccountInput.js66
-rw-r--r--app/lib/backend.js2
2 files changed, 66 insertions, 2 deletions
diff --git a/app/components/AccountInput.js b/app/components/AccountInput.js
index eba498fb95..3d321a605a 100644
--- a/app/components/AccountInput.js
+++ b/app/components/AccountInput.js
@@ -1,6 +1,13 @@
import React, { Component, PropTypes } from 'react';
import { formatAccount } from '../lib/formatters';
+/**
+ * Account input field with automatic formatting
+ *
+ * @export
+ * @class AccountInput
+ * @extends {Component}
+ */
export default class AccountInput extends Component {
/**
@@ -27,6 +34,12 @@ export default class AccountInput extends Component {
// selection range holds selection converted from DOM selection range to
// internal unformatted representation of account number
const val = this.sanitize(props.value);
+
+ /**
+ * @type {object}
+ * @property {string} value - raw text value
+ * @property {number[]} selectionRange - raw text mapped selection range [start, end]
+ */
this.state = {
value: val,
selectionRange: [val.length, val.length]
@@ -44,6 +57,9 @@ export default class AccountInput extends Component {
}
}
+ /**
+ * @override
+ */
shouldComponentUpdate(nextProps, nextState) {
return (this.props.value !== nextProps.value ||
this.props.onEnter !== nextProps.onEnter ||
@@ -52,7 +68,10 @@ export default class AccountInput extends Component {
this.state.selectionRange[0] !== nextState.selectionRange[0] ||
this.state.selectionRange[1] !== nextState.selectionRange[1]);
}
-
+
+ /**
+ * @override
+ */
render() {
const displayString = formatAccount(this.state.value || '');
const props = Object.assign({}, this.props);
@@ -83,6 +102,7 @@ export default class AccountInput extends Component {
/**
* Modify original string inserting substring using selection range
*
+ * @private
* @param {String?} val string
* @returns String
*
@@ -95,6 +115,7 @@ export default class AccountInput extends Component {
/**
* Modify original string inserting substring using selection range
*
+ * @private
* @param {String} val original string
* @param {String} insert insertion string
* @param {Array} selRange selection range ([x,y])
@@ -115,6 +136,7 @@ export default class AccountInput extends Component {
/**
* Modify string by removing single character or range of characters based on selection range.
*
+ * @private
* @param {String} val original string
* @param {Array} selRange selection range ([x,y])
* @returns Object
@@ -144,6 +166,7 @@ export default class AccountInput extends Component {
/**
* Convert DOM selection range to internal selection range
*
+ * @private
* @param {String} val original string
* @param {Array} domRange selection range from DOM
* @returns Object
@@ -171,6 +194,7 @@ export default class AccountInput extends Component {
/**
* Convert internal selection range to DOM selection range
*
+ * @private
* @param {String} val original string
* @param {Array} selRange selection range
* @returns Object
@@ -196,6 +220,12 @@ export default class AccountInput extends Component {
// Events
+ /**
+ * Key down handler
+ * @private
+ * @param {event} e
+ * @memberOf AccountInput
+ */
onKeyDown(e) {
const { value, selectionRange } = this.state;
@@ -224,6 +254,12 @@ export default class AccountInput extends Component {
}
}
+ /**
+ * Key up handler
+ * @private
+ * @param {event} e
+ * @memberOf AccountInput
+ */
onKeyUp(e) {
this._ignoreSelect = false;
@@ -232,6 +268,12 @@ export default class AccountInput extends Component {
}
}
+ /**
+ * Select handler
+ * @private
+ * @param {event} e
+ * @memberOf AccountInput
+ */
onSelect(e) {
const ref = e.target;
@@ -245,6 +287,12 @@ export default class AccountInput extends Component {
this.setState({ selectionRange: selRange });
}
+ /**
+ * Paste handler
+ * @private
+ * @param {event} e
+ * @memberOf AccountInput
+ */
onPaste(e) {
const { value, selectionRange } = this.state;
const pastedData = e.clipboardData.getData('text');
@@ -258,6 +306,12 @@ export default class AccountInput extends Component {
});
}
+ /**
+ * Cut handler
+ * @private
+ * @param {event} e
+ * @memberOf AccountInput
+ */
onCut(e) {
const { value, selectionRange } = this.state;
@@ -279,6 +333,12 @@ export default class AccountInput extends Component {
}
}
+ /**
+ * Reference handler
+ * @private
+ * @param {DOMElement} ref
+ * @memberOf AccountInput
+ */
onRef(ref) {
this._ref = ref;
if(!ref) { return; }
@@ -290,6 +350,10 @@ export default class AccountInput extends Component {
ref.selectionEnd = domRange[1];
}
+ /**
+ * Focus on text field
+ * @memberOf AccountInput
+ */
focus() {
if(this._ref) {
this._ref.focus();
diff --git a/app/lib/backend.js b/app/lib/backend.js
index 88a73e9129..cd650183c2 100644
--- a/app/lib/backend.js
+++ b/app/lib/backend.js
@@ -218,7 +218,7 @@ export default class Backend extends EventEmitter {
}
/**
- * Get fastest server
+ * Get fastest server info
*
* @returns {ServerInfo}
*