Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gabriel Testa
committed
Apr 5, 2011
0 parents
commit cb7d420
Showing
81 changed files
with
4,757 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,16 @@ | |||
opus.depends({ | |||
paths: { | |||
"Ares": "/Ares", | |||
"mojo": "/usr/palm/frameworks/mojo/", | |||
"opus": "$Ares/foss/opus/opus", | |||
"Palm": "$Ares/ide", | |||
"controls": "$opus/library/controls/", | |||
"AresLib": "$Palm/library/Ares", | |||
"MojoLib": "$Palm/library/Mojo/", | |||
"Palm-Mojo": "$MojoLib/" | |||
}, | |||
nobuild: [ | |||
"$mojo/mojo.js", | |||
"app-build.js" | |||
] | |||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,36 @@ | |||
function AppAssistant() {} | |||
|
|||
AppAssistant.prototype.setup = function() { | |||
this.loadFirstSceneHandler = this.loadFirstScene.bind(this); | |||
this.loadDashboardHandler = this.loadDashboard.bind(this); | |||
window.document.addEventListener(Mojo.Event.stageDeactivate, this.onDeactivateHandler.bind(this)); | |||
window.document.addEventListener(Mojo.Event.stageActivate, this.onActivateHandler.bind(this)); | |||
}; | |||
|
|||
AppAssistant.prototype.onDeactivateHandler = function(event) { | |||
var dashboardController = this.controller.getStageController('dashboard'); | |||
if (!dashboardController) { | |||
this.controller.createStageWithCallback({ | |||
name: 'dashboard', | |||
lightweight: true, | |||
clickableWhenLocked: true | |||
}, | |||
this.loadDashboardHandler, 'dashboard'); | |||
} | |||
}; | |||
|
|||
AppAssistant.prototype.onActivateHandler = function(event) { | |||
var dashboardController = this.controller.getStageController('dashboard'); | |||
if (dashboardController) { | |||
this.appController = Mojo.Controller.getAppController(); | |||
this.appController.closeStage('dashboard'); | |||
} | |||
}; | |||
|
|||
AppAssistant.prototype.loadFirstScene = function(stageController) { | |||
stageController.pushScene('gridScene'); | |||
}; | |||
|
|||
AppAssistant.prototype.loadDashboard = function(stageController) { | |||
stageController.pushScene('dashboard', DashPlayerInstance); | |||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,146 @@ | |||
/* Copyright 2009 Palm, Inc. All rights reserved. */ | |||
|
|||
/*globals Mojo PowerManagerService Util Element AppAssistant */ | |||
var DashboardAssistant = function(musicPlayer) { | |||
this.musicPlayer = musicPlayer; | |||
this.toggle = false; | |||
// if there isn't anything in the musicPlayer, don't open up the dashboard | |||
if (this.musicPlayer === 0) { | |||
Mojo.Controller.getAppController().closeStage('dashboard'); | |||
} | |||
|
|||
this.appController = Mojo.Controller.getAppController(); | |||
this.locked = false; | |||
this.setupListeners = function() { | |||
this.musicPlayer.audio().addEventListener('ended', this.trackEnded.bind(this), false); | |||
this.musicPlayer.audio().addEventListener('play', this.trackChange.bind(this), false); | |||
this.musicPlayer.audio().addEventListener('pause', this.trackPaused.bind(this), false); | |||
}; | |||
this.removeListeners = function() { | |||
this.musicPlayer.audio().removeEventListener('ended', this.trackEnded.bind(this), false); | |||
this.musicPlayer.audio().removeEventListener('play', this.trackChange.bind(this), false); | |||
this.musicPlayer.audio().removeEventListener('pause', this.trackPaused.bind(this), false); | |||
}; | |||
}; | |||
|
|||
DashboardAssistant.prototype = { | |||
setup: function() { | |||
this.controller.get('dashboard-player').addEventListener(Mojo.Event.tap, this.tapHandler.bindAsEventListener(this)); | |||
if (typeof this.musicPlayer !== "undefined" && this.musicPlayer !== 0) { | |||
if (typeof this.musicPlayer.audio() !== "undefined") { | |||
this.setupListeners(); | |||
this.updateSong(); | |||
} | |||
} | |||
}, | |||
|
|||
handleLockEvent: function(event) { | |||
this.locked = !!event.locked; | |||
}, | |||
cleanup: function() { | |||
this.removeListeners(); | |||
Ares.cleanupSceneAssistant(this); | |||
}, | |||
|
|||
updateSong: function(arg) { | |||
if (typeof arg === "undefined") { | |||
Mojo.Log.info("Updating the dashboard"); | |||
var song = this.musicPlayer.song(); | |||
var data = { | |||
title: song.name, | |||
artist: song.artist, | |||
pause: this.musicPlayer.isPlaying() ? "pause" : "", | |||
unlike: this.musicPlayer.liked() ? "unlike" : "" | |||
}; | |||
var renderedInfo = Mojo.View.render({ | |||
object: data, | |||
template: 'dashboard/dashboard-player' | |||
}); | |||
// Insert the HTML into the DOM, replacing the existing content. | |||
this.controller.get('dashboard-player').update(renderedInfo); | |||
myNewString = this.musicPlayer.photo().replace("original", "max200"); | |||
strarray = myNewString.split("."); | |||
if (strarray[strarray.length - 1] === "jpeg" || strarray[strarray.length - 1] === "gif") myNewString = Mojo.appPath + "/images/8tracksDash2.png"; | |||
// the template render doesn't do this properly, doing it manually | |||
this.controller.get('dashboard-player-art').style.background = "url(\"" + myNewString + "\") center center no-repeat"; | |||
}else{ | |||
Mojo.Log.info("Updating the dashboard"); | |||
var data = { | |||
title: arg, | |||
artist: "", | |||
pause: this.musicPlayer.isPlaying() ? "pause" : "", | |||
unlike: this.musicPlayer.liked() ? "unlike" : "" | |||
}; | |||
var renderedInfo = Mojo.View.render({ | |||
object: data, | |||
template: 'dashboard/dashboard-player' | |||
}); | |||
// Insert the HTML into the DOM, replacing the existing content. | |||
this.controller.get('dashboard-player').update(renderedInfo); | |||
myNewString = this.musicPlayer.photo().replace("original", "max200"); | |||
strarray = myNewString.split("."); | |||
if (strarray[strarray.length - 1] === "jpeg" || strarray[strarray.length - 1] === "gif") myNewString = Mojo.appPath + "/images/8tracksDash2.png"; | |||
// the template render doesn't do this properly, doing it manually | |||
//var thumbUrl = this.musicPlayer.photo();//Util.albumArtLargeUrlFormatter(song.thumbnails[0]); | |||
this.controller.get('dashboard-player-art').style.background = "url(\"" + myNewString + "\") center center no-repeat"; | |||
} | |||
}, | |||
trackEnded: function(event) { | |||
this.musicPlayer = DashPlayerInstance; | |||
this.updateSong(); | |||
}, | |||
trackChange: function(event) { | |||
this.musicPlayer = DashPlayerInstance; | |||
this.updateSong(); | |||
}, | |||
trackPaused: function(event) { | |||
if (!this.musicPlayer.isPlaying()) { | |||
this.controller.get('playpause').removeClassName("pause"); | |||
} else { | |||
this.controller.get('playpause').addClassName("pause"); | |||
} | |||
}, | |||
togglePlay: function() { | |||
if (this.musicPlayer.isPlaying()) { | |||
this.controller.get('playpause').removeClassName("pause"); | |||
this.musicPlayer.audio().pause(); | |||
} else { | |||
this.controller.get('playpause').addClassName("pause"); | |||
this.musicPlayer.audio().play(); | |||
} | |||
}, | |||
|
|||
toggleLike: function() { | |||
if (this.musicPlayer.liked()) { | |||
this.controller.get('likeunlike').removeClassName("unlike"); | |||
this.musicPlayer.toggleLike(false); | |||
} else { | |||
this.controller.get('likeunlike').addClassName("unlike"); | |||
this.musicPlayer.toggleLike(true); | |||
} | |||
}, | |||
|
|||
updatePausePlayIcon: function() { | |||
if (this.musicPlayer.isPlaying()) { | |||
this.controller.get('playpause').addClassName("pause"); | |||
} else { | |||
this.controller.get('playpause').removeClassName("pause"); | |||
} | |||
}, | |||
|
|||
tapHandler: function(event) { | |||
var id = event.target.id; | |||
if (id === 'playpause') { | |||
this.togglePlay(); | |||
} else if (id === 'next') { | |||
this.musicPlayer.skipTrack(); | |||
this.updateSong("Retrieving Next..."); | |||
} else if (id === 'likeunlike') { | |||
this.toggleLike(); | |||
} else { | |||
if (!this.locked) { | |||
//AppAssistant.appManagerService.relaunchMusicPlayer(); | |||
} | |||
} | |||
} | |||
}; |
Oops, something went wrong.