Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
50
gaia/apps/settings/js/panels/root/nfc_item.js
Executable file
50
gaia/apps/settings/js/panels/root/nfc_item.js
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* The moudle supports displaying nfc toggle on an element.
|
||||
*
|
||||
* @module panels/root/nfc_item
|
||||
*/
|
||||
define(function(require) {
|
||||
'use strict';
|
||||
|
||||
var SettingsListener = require('shared/settings_listener');
|
||||
|
||||
/**
|
||||
* @alias module:panels/root/nfc_item
|
||||
* @class NFCItem
|
||||
* @param {Object} elements
|
||||
* @param {HTMLElement} elements.nfcMenuItem
|
||||
* @param {HTMLElement} elements.nfcCheckBox
|
||||
* @returns {NFCItem}
|
||||
*/
|
||||
function NFCItem(elements) {
|
||||
if (!navigator.mozNfc) {
|
||||
return;
|
||||
}
|
||||
elements.nfcMenuItem.hidden = false;
|
||||
this._checkbox = elements.nfcCheckBox;
|
||||
this._checkbox.addEventListener('change', () => this._onCheckboxChanged());
|
||||
|
||||
SettingsListener.observe('nfc.status', undefined,
|
||||
(status) => this._onNfcStatusChanged(status));
|
||||
}
|
||||
|
||||
NFCItem.prototype = {
|
||||
// disabling on change to prevent double clicking and remove toggle
|
||||
// flickering before nfcManger will change nfc.status
|
||||
_onCheckboxChanged: function ni_onCheckboxChanged() {
|
||||
this._checkbox.disabled = true;
|
||||
},
|
||||
|
||||
_onNfcStatusChanged: function ni_onNfcStatusChanged(status) {
|
||||
if (status === 'enabling' || status === 'disabling') {
|
||||
this._checkbox.disabled = true;
|
||||
} else if (status === 'enabled' || status === 'disabled') {
|
||||
this._checkbox.disabled = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return function ctor_nfcItem(elements) {
|
||||
return new NFCItem(elements);
|
||||
};
|
||||
});
|
||||
Loading…
Reference in a new issue