This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33286 from Fischer-L/bug_1220588-FTE-for-usage-me…
…trics Bug 1220588 - [TV] FTE for usage matrics, r=rexboy
- Loading branch information
Showing
25 changed files
with
1,280 additions
and
0 deletions.
There are no files selected for viewing
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
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
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 | 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" | ||
} | ||
} |
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 | 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" | ||
} |
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 | 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" | ||
] | ||
} |
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 | 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; | ||
} | ||
|
||
})(); |
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 | 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" | ||
} |
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 | 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" | ||
] | ||
} |
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 | 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); |
Oops, something went wrong.