Lots of minor fixes

This commit is contained in:
Robin Linus 2016-05-04 23:13:07 -06:00
parent bb81b6f2e4
commit d8dcbfcb0f
21 changed files with 332 additions and 60 deletions

View file

@ -20,7 +20,7 @@
border-radius: 50%;
overflow: hidden;
padding: 12px;
margin-bottom: 4px;
margin-bottom: 6px;
background-color: #4285f4;
color: white;
}
@ -127,39 +127,50 @@
return status;
},
attached: function() {
// var adsDialog = document.querySelector('#ads');
this.async(function() {
app.conn.addEventListener('file-offered', function(e) {
if (e.detail.to === this.contact.peerId) {
this.status = 'Waiting to accept...';
//adsDialog.open();
}
}.bind(this), false);
app.conn.addEventListener('upload-started', function(e) {
if (e.detail.to === this.contact.peerId) {
this.status = 'Uploading...';
// adsDialog.setState('Uploading...');
}
}.bind(this), false);
app.conn.addEventListener('download-started', function(e) {
if (e.detail.from === this.contact.peerId) {
this.status = 'Downloading...';
//adsDialog.open();
// adsDialog.setState('Downloading...');
}
}.bind(this), false);
app.conn.addEventListener('upload-complete', function(e) {
if (e.detail.from === this.contact.peerId) {
this.status = this.defaultStatus;
adsDialog.setState('Transfer Complete');
// adsDialog.close();
}
}.bind(this), false);
app.conn.addEventListener('download-complete', function(e) {
if (e.detail.from === this.contact.peerId) {
this.status = this.defaultStatus;
adsDialog.setState('Transfer Complete');
// adsDialog.close();
}
}.bind(this), false);
app.conn.addEventListener('file-declined', function(e) {
if (e.detail.from === this.contact.peerId) {
this.status = this.defaultStatus;
// adsDialog.close(true);
}
}.bind(this), false);
app.conn.addEventListener('upload-error', function(e) {
this.status = this.defaultStatus;
// adsDialog.close();
}.bind(this), false);
}, 200);
}

View file

@ -102,11 +102,10 @@
opacity: 1;
}
}
</style>
<div class="explanation2" hidden$="{{!_showExplanation}}">
Tap to send File.
<br> Long Press to send Text.
{{_clickExplanation1}} Device to send File.
<br> {{_clickExplanation2}} to send a Text.
</div>
<div class="buddies" two-lines$="{{twoLinesOfBuddies}}">
<template is="dom-repeat" items="{{buddies}}">
@ -123,44 +122,66 @@
</template>
<script>
'use strict';
Polymer({
is: 'buddy-finder',
properties: {
buddies: {
type: Array,
notify: true
(function() {
var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
Polymer({
is: 'buddy-finder',
properties: {
buddies: {
type: Array,
notify: true
},
me: {
type: String,
},
_showExplanation: {
computed: '_computeShowExplanation(buddies.length)',
value: false
},
twoLinesOfBuddies: {
value: false
},
_clickExplanation1: {
value: (function() {
if (isMobile) {
return 'Tap';
} else {
return 'Click';
}
})
},
_clickExplanation2: {
value: (function() {
if (isMobile) {
return 'Long Press';
} else {
return 'Right Click';
}
})
}
},
me: {
type: String,
observers: [
'_buddiesChanged(buddies.splices)'
],
_fileSelected: function(e) {
var peerId = e.model.item.peerId;
var file = e.detail;
app.conn.sendFile(peerId, file);
//document.querySelector('#ads').open();
},
_showExplanation: {
computed: '_computeShowExplanation(buddies.length)',
value: false
_computeShowExplanation: function(nBuddies) {
if (!nBuddies || nBuddies === 0) {
return false;
}
if (nBuddies < 3) {
return true;
}
},
twoLinesOfBuddies: {
value: false
_buddiesChanged: function() {
var length = window.innerWidth / 120;
this.set('twoLinesOfBuddies', (this.buddies.length > length));
}
},
observers: [
'_buddiesChanged(buddies.splices)'
],
_fileSelected: function(e) {
var peerId = e.model.item.peerId;
var file = e.detail;
app.conn.sendFile(peerId, file);
},
_computeShowExplanation: function(nBuddies) {
if (!nBuddies || nBuddies === 0) {
return false;
}
if (nBuddies < 3) {
return true;
}
},
_buddiesChanged: function() {
var length = window.innerWidth / 120;
this.set('twoLinesOfBuddies', (this.buddies.length > length));
}
});
});
}());
</script>
</dom-module>

View file

@ -14,7 +14,7 @@
text-align: center;
cursor: pointer;
width: 160px;
line-height: 18px !important;
line-height: 12px !important;
}
:root {
@ -37,7 +37,7 @@
text-align: left;
}
</style>
<div class="name-label" hidden$="{{name}}">My Name</div>
<div class="name-label" hidden$="{{name}}">My Device</div>
<div class="name-label" hidden$="{{!name}}">{{name}}</div>
<iron-localstorage name="device-name" value="{{name}}" iron-localstorage-load="_nameChanged"></iron-localstorage>
</template>