blob: f34a987ebf7e3da935a390461d003436665e97bd [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<polymer-element name="tv-c-a-size-span">
<template>
<style>
:host {
display: flex;
flex-direction: row;
align-items: center;
}
</style>
<span id="content"></span>
</template>
<script>
'use strict';
Polymer({
ready: function() {
this.$.content.textContent = String.fromCharCode(9888);
this.numBytes_ = undefined;
},
get numBytes() {
return this.numBytes_;
},
set numBytes(numBytes) {
this.numBytes_ = numBytes;
var prefixes = ['', 'Ki', 'Mi', 'Gi', 'Ti'];
var i = 0;
while (numBytes >= 1024 && i < prefixes.length - 1) {
numBytes /= 1024;
i++;
}
var sizeString = numBytes.toFixed(1) + ' ' + prefixes[i] + 'B';
this.$.content.textContent = sizeString;
},
get stringContent() {
return this.$.content.textContent;
}
});
</script>
</polymer-element>