Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #33286 from Fischer-L/bug_1220588-FTE-for-usage-me…
Browse files Browse the repository at this point in the history
…trics

Bug 1220588 - [TV] FTE for usage matrics, r=rexboy
  • Loading branch information
Fischer-L committed Nov 25, 2015
2 parents 8a74630 + 904ffc3 commit 3da257a
Show file tree
Hide file tree
Showing 25 changed files with 1,280 additions and 0 deletions.
1 change: 1 addition & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ tv_apps/tv-deck/bower_components/**
tv_apps/tv-epg/bower_components/**
tv_apps/remote-control/bower_components/**
tv_apps/remote-control-client/bower_components/**
tv_apps/tv-ftu/bower_components/**
tests/atoms/remote_date.js
tests/atoms/screenshot.js
tests/jsmarionette/client/marionette-client/docs/**
Expand Down
1 change: 1 addition & 0 deletions build/config/tv/apps-engineering.list
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ tv_apps/weather-widget
tv_apps/remote-control
tv_apps/remote-control-client
tv_apps/fling-tutorial
tv_apps/tv-ftu
apps/bluetooth
apps/calendar
apps/camera
Expand Down
24 changes: 24 additions & 0 deletions tv_apps/tv-ftu/bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "TV FTU",
"version": "0.0.0",
"homepage": "https://github.com/mozilla-b2g/gaia/tree/master/tv_apps/tv-ftu",
"authors": [
"Fischer Liu <[email protected]>"
],
"description": "TV FTU",
"main": "index.html",
"license": "MPL",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"evt": "gaia-components/evt#~0.4.0",
"smart-button": "gaia-components/smart-button",
"smart-icons": "smart-components/smart-icons"
}
}
28 changes: 28 additions & 0 deletions tv_apps/tv-ftu/bower_components/evt/.bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "evt",
"main": "index.js",
"version": "0.4.0",
"homepage": "https://github.com/wilsonpage/evt",
"authors": [
"Wilson Page <[email protected]>"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"package.json",
"test",
"tests",
"README.md"
],
"_release": "0.4.0",
"_resolution": {
"type": "version",
"tag": "v0.4.0",
"commit": "3593dd6b4dd19f683d00fd0eaf2581c11a128da6"
},
"_source": "git://github.com/gaia-components/evt.git",
"_target": "~0.4.0",
"_originalSource": "gaia-components/evt"
}
19 changes: 19 additions & 0 deletions tv_apps/tv-ftu/bower_components/evt/bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "evt",
"main": "index.js",
"version": "0.4.0",
"homepage": "https://github.com/wilsonpage/evt",
"authors": [
"Wilson Page <[email protected]>"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"package.json",
"test",
"tests",
"README.md"
]
}
154 changes: 154 additions & 0 deletions tv_apps/tv-ftu/bower_components/evt/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@

/**
* Evt
*
* A super lightweight
* event emitter library.
*
* @version 0.3.3
* @author Wilson Page <[email protected]>
*/

;(function() {

/**
* Locals
*/

var proto = Events.prototype;
var slice = [].slice;

/**
* Creates a new event emitter
* instance, or if passed an
* object, mixes the event logic
* into it.
*
* @param {Object} obj
* @return {Object}
*/
function Events(obj) {
if (!(this instanceof Events)) return new Events(obj);
if (obj) return mixin(obj, proto);
}

/**
* Registers a callback
* with an event name.
*
* @param {String} name
* @param {Function} cb
* @return {Event}
*/
proto.on = function(name, cb) {
this._cbs = this._cbs || {};
(this._cbs[name] || (this._cbs[name] = [])).push(cb);
return this;
};

/**
* Attach a callback that once
* called, detaches itself.
*
* TODO: Implement `.off()` to work
* with `once()` callbacks.
*
* @param {String} name
* @param {Function} cb
* @public
*/
proto.once = function(name, cb) {
this.on(name, one);
function one() {
cb.apply(this, arguments);
this.off(name, one);
}
};

/**
* Removes a single callback,
* or all callbacks associated
* with the passed event name.
*
* @param {String} name
* @param {Function} cb
* @return {Event}
*/
proto.off = function(name, cb) {
this._cbs = this._cbs || {};

if (!name) { this._cbs = {}; return; }
if (!cb) { return delete this._cbs[name]; }

var cbs = this._cbs[name] || [];
var i;

while (cbs && ~(i = cbs.indexOf(cb))) { cbs.splice(i, 1); }
return this;
};

/**
* Fires an event, triggering
* all callbacks registered on this
* event name.
*
* @param {String} name
* @return {Event}
*/
proto.fire = proto.emit = function(options) {
var cbs = this._cbs = this._cbs || {};
var name = options.name || options;
var batch = (cbs[name] || []).concat(cbs['*'] || []);
var ctx = options.ctx || this;

if (batch.length) {
this._fireArgs = arguments;
var args = slice.call(arguments, 1);
while (batch.length) {
batch.shift().apply(ctx, args);
}
}

return this;
};

proto.firer = function(name) {
var self = this;
return function() {
var args = slice.call(arguments);
args.unshift(name);
self.fire.apply(self, args);
};
};

/**
* Util
*/

/**
* Mixes in the properties
* of the second object into
* the first.
*
* @param {Object} a
* @param {Object} b
* @return {Object}
*/
function mixin(a, b) {
for (var key in b) a[key] = b[key];
return a;
}

/**
* Expose 'Event' (UMD)
*/

if (typeof exports === 'object') {
module.exports = Events;
} else if (typeof define === 'function' && define.amd) {
define(function(){ return Events; });
} else {
window.evt = Events;
}

})();
26 changes: 26 additions & 0 deletions tv_apps/tv-ftu/bower_components/smart-button/.bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "smart-button",
"version": "0.0.2",
"homepage": "https://github.com/gaia-components/smart-button",
"main": "script.js",
"license": "MPL",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests",
"examples",
"LICENSE",
"README.md"
],
"_release": "0.0.2",
"_resolution": {
"type": "version",
"tag": "v0.0.2",
"commit": "04fdae935e2f2ba99d1c4f3e156d17f12eb2d142"
},
"_source": "git://github.com/gaia-components/smart-button.git",
"_target": "*",
"_originalSource": "gaia-components/smart-button"
}
17 changes: 17 additions & 0 deletions tv_apps/tv-ftu/bower_components/smart-button/bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "smart-button",
"version": "0.0.2",
"homepage": "https://github.com/gaia-components/smart-button",
"main": "script.js",
"license": "MPL",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests",
"examples",
"LICENSE",
"README.md"
]
}
62 changes: 62 additions & 0 deletions tv_apps/tv-ftu/bower_components/smart-button/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
'use strict';
/* global KeyEvent */

window.SmartButton = (function(win) {
// Extend from the HTMLButtonElement prototype
var proto = Object.create(HTMLButtonElement.prototype);

proto.createdCallback = function() {
this.addEventListener('mousedown', this);
this.addEventListener('mouseup', this);
this.addEventListener('touchstart', this);
this.addEventListener('touchend', this);
this.addEventListener('keydown', this);
this.addEventListener('keyup', this);
this.addEventListener('focus', this);
this.addEventListener('blur', this);
this.addEventListener('transitionend', this);
this.tabIndex = 0;
};

proto.handleEvent = function(evt) {
switch(evt.type) {
case 'mousedown':
case 'touchstart':
this.classList.add('pressed');
break;
case 'keydown':
if (evt.keyCode === KeyEvent.DOM_VK_RETURN) {
this.classList.add('pressed');
}
break;
case 'mouseup':
case 'touchend':
this.classList.remove('pressed');
this.classList.add('released');
break;
case 'keyup':
if (evt.keyCode === KeyEvent.DOM_VK_RETURN) {
this.classList.remove('pressed');
this.classList.add('released');
this.click();
}
break;
case 'transitionend':
if (this.classList.contains('released')) {
this.classList.remove('released');
}
break;
case 'focus':
this.classList.add('focused');
break;
case 'blur':
this.classList.remove('pressed');
this.classList.remove('released');
this.classList.remove('focused');
break;
}
};

// Register and return the constructor
return document.registerElement('smart-button', { prototype: proto });
})(window);
Loading

0 comments on commit 3da257a

Please sign in to comment.