diff options
| author | David Monjoie <dmo@odoo.com> | 2017-03-14 11:03:12 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2017-04-11 19:44:38 +0200 |
| commit | 4eb2245c5d47d04e2177d4aa4d8edd265898dca3 (patch) | |
| tree | bace09bcd79b3d535fd4e6a42a35daf1329be588 /addons/web/static/src/js/fields/basic_fields.js | |
| parent | d218902af5babfe371d0cde5c7851282759b4899 (diff) | |
[ADD] web: add phone widget tests and documentation
Diffstat (limited to 'addons/web/static/src/js/fields/basic_fields.js')
| -rw-r--r-- | addons/web/static/src/js/fields/basic_fields.js | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index f168d8cc69f..d08c628c164 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -620,26 +620,53 @@ var EmailWidget = InputField.extend({ var FieldPhone = EmailWidget.extend({ prefix: 'tel', + + /** + * The phone widget is an extension of email, with the distinction that, in + * some cases, we do not want to show a clickable widget in readonly. + * In particular, we only want to make it clickable if the device can call + * this particular number. This is controlled by the _canCall function. + * + * @override + */ init: function () { this._super.apply(this, arguments); - if (this.mode === 'readonly' && !this._can_call()) { + if (this.mode === 'readonly' && !this._canCall()) { this.tagName = 'span'; } }, + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + /** + * In readonly, we only make the widget clickable if the device can call it. + * Additionally, we obfuscate the phone number to prevent Skype from seeing it. + * + * @override + * @private + */ _renderReadonly: function () { this._super(); - if(this._can_call()) { + if(this._canCall()) { var text = this.$el.text(); this.$el.html(text.substr(0, text.length/2) + "­" + text.substr(text.length/2)); // To prevent Skype app to find the phone number } else { this.$el.removeClass('o_form_uri'); } }, - _can_call: function () { - // Phone fields are clickable in readonly on small screens ~= on phones - // This can be overriden by call-capable modules to display a clickable - // link in different situations, like always regardless of screen size, - // or only allow national calls for example. + + /** + * Phone fields are clickable in readonly on small screens ~= on phones. + * This can be overriden by call-capable modules to display a clickable + * link in different situations, like always regardless of screen size, + * or only allow national calls for example. + * + * @override + * @private + */ + _canCall: function () { return config.device.size_class <= config.device.SIZES.XS; } }); |
