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
49
assets/webapps/system.gaiamobile.org/js/battery_icon.js
Normal file
49
assets/webapps/system.gaiamobile.org/js/battery_icon.js
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/* global BaseIcon */
|
||||
'use strict';
|
||||
|
||||
(function(exports) {
|
||||
var BatteryIcon = function(manager) {
|
||||
BaseIcon.call(this, manager);
|
||||
};
|
||||
BatteryIcon.prototype = Object.create(BaseIcon.prototype);
|
||||
BatteryIcon.prototype.name = 'BatteryIcon';
|
||||
BatteryIcon.prototype.update = function() {
|
||||
if (!this.element) {
|
||||
return;
|
||||
}
|
||||
this.show();
|
||||
var battery = this.manager._battery;
|
||||
var icon = this.element;
|
||||
var previousLevel = parseInt(icon.dataset.level, 10);
|
||||
var previousCharging = (icon.dataset.charging === 'true');
|
||||
|
||||
icon.dataset.charging = battery.charging;
|
||||
var level = Math.floor(battery.level * 10) * 10;
|
||||
|
||||
this.debug('previous level: ', previousLevel);
|
||||
this.debug('current level:', level);
|
||||
|
||||
if (previousLevel === level &&
|
||||
previousCharging === battery.charging) {
|
||||
return;
|
||||
}
|
||||
|
||||
icon.dataset.level = level;
|
||||
navigator.mozL10n.setAttributes(
|
||||
icon,
|
||||
battery.charging ? 'statusbarBatteryCharging' : 'statusbarBattery',
|
||||
{level: level}
|
||||
);
|
||||
this.previousCharging = battery.charging;
|
||||
this.publish('changed');
|
||||
};
|
||||
|
||||
BatteryIcon.prototype.view = function view() {
|
||||
return `<div id="statusbar-battery"
|
||||
class="sb-icon sb-icon-battery"
|
||||
role="listitem">
|
||||
</div>`;
|
||||
};
|
||||
|
||||
exports.BatteryIcon = BatteryIcon;
|
||||
}(window));
|
||||
Loading…
Reference in a new issue