Skip to content

Commit

Permalink
Fix iOS issue in Maze activity
Browse files Browse the repository at this point in the history
  • Loading branch information
Lionel Laské committed Jan 10, 2015
1 parent a4c7249 commit 20c6b82
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 5 deletions.
5 changes: 3 additions & 2 deletions activities/MazeWeb.activity/js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ define(function (require) {
require(['domReady!'], function (doc) {
activity.setup();

var soundType = /(iPad|iPhone|iPod)/g.test(navigator.userAgent) ? '.mp3' : '.ogg';
var canvasWidth;
var canvasHeight;

Expand Down Expand Up @@ -296,7 +297,7 @@ define(function (require) {
winner = player;
levelStatus = 'transition';

var audio = new Audio('sounds/win.ogg');
var audio = new Audio('sounds/win'+soundType);
audio.play();

for (control in players) {
Expand Down Expand Up @@ -431,7 +432,7 @@ define(function (require) {

this.blockTween.start();

var audio = new Audio('sounds/tick.ogg');
var audio = new Audio('sounds/tick'+soundType);
audio.play();
}

Expand Down
17 changes: 17 additions & 0 deletions activities/MazeWeb.activity/lib/tween.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@
* @author Ben Delarre / http://delarre.net
*/

// HACK: window.performance not supported on iOS
if (typeof window.performance === 'undefined') {
window.performance = {};
}

if (!window.performance.now){
var nowOffset = Date.now();

if (performance.timing && performance.timing.navigationStart){
nowOffset = performance.timing.navigationStart
}

window.performance.now = function now(){
return Date.now() - nowOffset;
}
}

// Date.now shim for (ahem) Internet Explo(d|r)er
if ( Date.now === undefined ) {

Expand Down
Binary file added activities/MazeWeb.activity/sounds/tick.mp3
Binary file not shown.
Binary file added activities/MazeWeb.activity/sounds/win.mp3
Binary file not shown.
4 changes: 4 additions & 0 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,10 @@ input {
text-align: center;
width: 100%;
color: #808080;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

.first-owner-icon {
Expand Down
2 changes: 1 addition & 1 deletion js/firstscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ enyo.kind({
{name: "previous", kind: "Sugar.IconButton", icon: {directory: "icons", icon: "go-left.svg"}, classes: "first-leftbutton", ontap: "previous", showing: false},
{name: "next", kind: "Sugar.IconButton", icon: {directory: "icons", icon: "go-right.svg"}, classes: "first-rightbutton", ontap: "next"},
{name: "colortext", content: "xxx", classes: "first-colortext", showing: false},
{name: "owner", kind: "Sugar.Icon", size: constant.sizeOwner, colorized: true, classes: "first-owner-icon", showing: false, onresize: "resize", onclick: "nextcolor"},
{name: "owner", kind: "Sugar.Icon", size: constant.sizeOwner, colorized: true, classes: "first-owner-icon", showing: false, onresize: "resize", ontap: "nextcolor"},
],

// Constructor
Expand Down
8 changes: 6 additions & 2 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,12 @@ define(["webL10n"], function (l10n) {
window.close();
window.open('', '_self', ''); // HACK: Not allowed on all browsers
window.close();
if (navigator && navigator.app)
navigator.app.exitApp();
if (navigator) {
if (navigator.app)
navigator.app.exitApp();
else if (navigator.device)
navigator.device.exitApp();
}
}

return util;
Expand Down

0 comments on commit 20c6b82

Please sign in to comment.