Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
37 lines
868 B
JavaScript
37 lines
868 B
JavaScript
/* global LazyLoader, Import */
|
|
'use strict';
|
|
|
|
(function(exports) {
|
|
|
|
/**
|
|
* A global activity handler which dispatches mozSetMessageHandler events.
|
|
*/
|
|
function ActivityHandler() {}
|
|
|
|
ActivityHandler.prototype = {
|
|
/**
|
|
* Starts listening for activities.
|
|
*/
|
|
start: function() {
|
|
window.navigator.mozSetMessageHandler('activity',
|
|
this.handleActivity.bind(this));
|
|
return LazyLoader.load(['js/import.js']).then(() => {
|
|
this.import = new Import();
|
|
return Promise.resolve(this.import.start());
|
|
});
|
|
},
|
|
|
|
/**
|
|
* Handles activity requests.
|
|
*/
|
|
handleActivity: function(activity) {
|
|
var name = activity.source.name;
|
|
window.dispatchEvent(new CustomEvent('activity-' + name, {
|
|
detail: activity
|
|
}));
|
|
}
|
|
};
|
|
|
|
exports.ActivityHandler = ActivityHandler;
|
|
|
|
}(window));
|