This commit is contained in:
Matt Claypotch 2015-01-30 11:29:59 -08:00
Родитель ed7ea48b29
Коммит 3b1463e52b
5 изменённых файлов: 163 добавлений и 2 удалений

Просмотреть файл

@ -63,7 +63,6 @@ function api(v, m, p, cb) {
return cb(e);
}
}
throw "whuck";
return cb(null);
});
}

Просмотреть файл

@ -46,6 +46,7 @@ a.active {
.app > section {
height: 100vh;
width: 100vw;
position: relative;
}
.app[data-mode="overview"] {
transform: translate(0, 0);
@ -274,6 +275,32 @@ h2 {
animation: 500ms spin linear infinite;
}
/* install */
.install {
position: absolute;
bottom: 1em;
right: 1em;
background: #000;
padding: .5em 2em .5em 1em;
border: 1px solid white;
border-radius: 5em;
display: none;
font-size: 1.5em;
}
.install.capable {
display: block;
}
.install.pending, .install.installed {
display: none;
}
.install:before {
content: '⬇︎';
position: absolute;
top: 0;
right: 0;
padding: .5em .7em 0 0;
}
@keyframes spin {
to {
transform: rotate(360deg);

Просмотреть файл

@ -75,11 +75,65 @@ var Overview = React.createClass({
</div>
);
}, this)}
<AppInstallDingus />
</section>
);
}
});
var AppInstallDingus = React.createClass({
attemptInstall: function (e) {
e.preventDefault();
if (this.state.capable) {
var url = window.location.origin + '/manifest.webapp';
var installReq = navigator.mozApps.install(url);
installReq.onsuccess = function () {
if (installReq.result) {
this.state.installed = true;
this.setState(this.state);
}
}.bind(this);
}
},
getInitialState: function () {
return {
installed: false,
pending: false,
capable: navigator.mozApps
};
},
componentDidMount: function() {
if (this.state.capable) {
var selfReq = navigator.mozApps.getSelf();
selfReq.onsuccess = function () {
console.log('installed', selfReq.result);
if (selfReq.result) {
this.state.installed = true;
this.setState(this.state);
}
}.bind(this);
var installedReq = navigator.mozApps.getInstalled();
installedReq.onsuccess = function () {
console.log('installed', installedReq.result);
if (installedReq.result && installedReq.result.length) {
this.state.installed = true;
this.setState(this.state);
}
}.bind(this);
}
},
render: function () {
var classes = classSet({
installed: this.state.installed,
pending: this.state.pending,
capable: this.state.capable,
install: true
});
return <a className={classes} href="#" onClick={this.attemptInstall}>Install</a>;
}
});
var ZoneOverview = React.createClass({
render: function() {
if (this.props.nowPlaying) {

Просмотреть файл

@ -57,6 +57,7 @@ a.active {
.app > section {
height: 100vh;
width: 100vw;
position: relative;
}
.app[data-mode="overview"] {
-webkit-transform: translate(0, 0);
@ -407,6 +408,32 @@ h2 {
animation: 500ms spin linear infinite;
}
/* install */
.install {
position: absolute;
bottom: 1em;
right: 1em;
background: #000;
padding: .5em 2em .5em 1em;
border: 1px solid white;
border-radius: 5em;
display: none;
font-size: 1.5em;
}
.install.capable {
display: block;
}
.install.pending, .install.installed {
display: none;
}
.install:before {
content: '⬇︎';
position: absolute;
top: 0;
right: 0;
padding: .5em .7em 0 0;
}
@-webkit-keyframes spin {
to {

Просмотреть файл

@ -74,12 +74,66 @@ var Overview = React.createClass({displayName: "Overview",
nowPlaying: z.aData.aNowPlaying})
)
);
}, this)
}, this),
React.createElement(AppInstallDingus, null)
)
);
}
});
var AppInstallDingus = React.createClass({displayName: "AppInstallDingus",
attemptInstall: function (e) {
e.preventDefault();
if (this.state.capable) {
var url = window.location.origin + '/manifest.webapp';
var installReq = navigator.mozApps.install(url);
installReq.onsuccess = function () {
if (installReq.result) {
this.state.installed = true;
this.setState(this.state);
}
}.bind(this);
}
},
getInitialState: function () {
return {
installed: false,
pending: false,
capable: navigator.mozApps
};
},
componentDidMount: function() {
if (this.state.capable) {
var selfReq = navigator.mozApps.getSelf();
selfReq.onsuccess = function () {
console.log('installed', selfReq.result);
if (selfReq.result) {
this.state.installed = true;
this.setState(this.state);
}
}.bind(this);
var installedReq = navigator.mozApps.getInstalled();
installedReq.onsuccess = function () {
console.log('installed', installedReq.result);
if (installedReq.result && installedReq.result.length) {
this.state.installed = true;
this.setState(this.state);
}
}.bind(this);
}
},
render: function () {
var classes = classSet({
installed: this.state.installed,
pending: this.state.pending,
capable: this.state.capable,
install: true
});
return React.createElement("a", {className: classes, href: "#", onClick: this.attemptInstall}, "Install");
}
});
var ZoneOverview = React.createClass({displayName: "ZoneOverview",
render: function() {
if (this.props.nowPlaying) {