Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
66
gaia/apps/camera/js/controllers/countdown.js
Executable file
66
gaia/apps/camera/js/controllers/countdown.js
Executable file
|
|
@ -0,0 +1,66 @@
|
|||
define(function(require, exports, module) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Dependencies
|
||||
*/
|
||||
|
||||
var debug = require('debug')('controller:countdown');
|
||||
var CountdownView = require('views/countdown');
|
||||
var bindAll = require('lib/bind-all');
|
||||
|
||||
/**
|
||||
* Exports
|
||||
*/
|
||||
|
||||
module.exports = function(app) { return new CountdownController(app); };
|
||||
module.exports.CountdownController = CountdownController;
|
||||
|
||||
/**
|
||||
* Create a new `CountdownController`
|
||||
*
|
||||
* @param {App} app
|
||||
*/
|
||||
function CountdownController(app) {
|
||||
bindAll(this);
|
||||
this.app = app;
|
||||
this.view = app.views.countdown || new CountdownView(); // test hook
|
||||
this.view.appendTo(app.el);
|
||||
this.bindEvents();
|
||||
debug('initialized');
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects the countdown view
|
||||
* with the app via events.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
CountdownController.prototype.bindEvents = function() {
|
||||
this.app.on('countdown:started', this.start);
|
||||
this.app.on('countdown:tick', this.update);
|
||||
this.app.on('countdown:ended', this.clear);
|
||||
};
|
||||
|
||||
CountdownController.prototype.start = function(seconds) {
|
||||
this.update(seconds);
|
||||
this.view.show();
|
||||
debug('started');
|
||||
};
|
||||
|
||||
CountdownController.prototype.update = function(seconds) {
|
||||
if (seconds < 1) { seconds = ''; }
|
||||
var immanent = seconds <= 3;
|
||||
|
||||
this.view
|
||||
.set(seconds)
|
||||
.setImmanent(immanent);
|
||||
|
||||
if (immanent && seconds > 0) { this.app.emit('countdown:immanent'); }
|
||||
};
|
||||
|
||||
CountdownController.prototype.clear = function() {
|
||||
this.view.hide(this.view.reset);
|
||||
};
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue