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
227
gaia/distros/spark/apps/customizer-launcher/components/base/base.css
Executable file
227
gaia/distros/spark/apps/customizer-launcher/components/base/base.css
Executable file
|
|
@ -0,0 +1,227 @@
|
|||
|
||||
/** Variables
|
||||
---------------------------------------------------------*/
|
||||
|
||||
:root {
|
||||
--dim-micro: 6px;
|
||||
--dim-small: 12px;
|
||||
--dim-medium: 24px;
|
||||
--dim-mega: 48px;
|
||||
|
||||
--base-xs: 6px;
|
||||
--base-s: 18px;
|
||||
--base-m: 24px;
|
||||
--base-l: 30px;
|
||||
--base-xl: 42px;
|
||||
--base-xxl: 60px;
|
||||
|
||||
--base-font-xs: 10px;
|
||||
--base-font-s: 14px;
|
||||
--base-font-m: 17px;
|
||||
--base-font-l: 23px;
|
||||
--base-font-xl: 60px;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. Apply a natural box layout
|
||||
* model to all elements
|
||||
*/
|
||||
|
||||
*,
|
||||
*:after,
|
||||
*:before {
|
||||
box-sizing: border-box; /* 1 */
|
||||
font: inherit;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/** Document
|
||||
---------------------------------------------------------*/
|
||||
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/** Body
|
||||
---------------------------------------------------------*/
|
||||
|
||||
body {
|
||||
height: 100%;
|
||||
font: 300 17px/21px 'FiraSans';
|
||||
background-color: var(--background);
|
||||
color: var(--text-color);
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/** Tags
|
||||
---------------------------------------------------------*/
|
||||
|
||||
a {
|
||||
color: var(--highlight-color, inherit);
|
||||
text-decoration: none;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
hr {
|
||||
height: 1px;
|
||||
margin: var(--dim-small) 0 var(--dim-small) 0;
|
||||
border: 0;
|
||||
background:
|
||||
var(--border-color,
|
||||
var(--background-plus,
|
||||
rgba(0,0,0,0.2)));
|
||||
}
|
||||
|
||||
em {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5 {
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.alpha {
|
||||
font-size: 23px;
|
||||
font-weight: 200;
|
||||
font-style: italic;
|
||||
line-height: 26px;
|
||||
margin: 6px 0 24px 0;
|
||||
}
|
||||
|
||||
.beta {
|
||||
font-size: 17px;
|
||||
font-weight: 400;
|
||||
margin: 32px 0 16px 0;
|
||||
}
|
||||
|
||||
.gamma {
|
||||
font-size: 14px;
|
||||
text-transform: uppercase;
|
||||
font-weight: normal;
|
||||
margin: 32px 0 16px 0;
|
||||
}
|
||||
|
||||
.milli {
|
||||
font-size: 14px;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.large {
|
||||
font-size: 23px;
|
||||
line-height: 26px;
|
||||
}
|
||||
|
||||
.mega {
|
||||
font-size: 60px;
|
||||
line-height: 60px;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.giga {}
|
||||
.kilo {}
|
||||
|
||||
/* alignment */
|
||||
.l-align-right { float: right; }
|
||||
.l-align-left { float: left; }
|
||||
.l-align-center { text-align: center; }
|
||||
.l-text-align-left { text-align: left; }
|
||||
.l-text-align-right { text-align: right; }
|
||||
.l-text-valign-top {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.l-width-full {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/** Flexbox
|
||||
---------------------------------------------------------*/
|
||||
|
||||
.l-flex { display: flex; }
|
||||
.l-flex-col { display: flex; flex-direction: column; }
|
||||
|
||||
.l-flex-col-v-align {
|
||||
display: flex !important;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.l-flex-v-align { align-items: center; }
|
||||
.l-flex-h-align { justify-content: center; }
|
||||
.l-flex-grow { flex: 1; }
|
||||
|
||||
/** Margin
|
||||
---------------------------------------------------------*/
|
||||
|
||||
/* Top */
|
||||
|
||||
.l-mt-small { margin-top: var(--dim-small); }
|
||||
.l-mt-med { margin-top: var(--dim-medium); }
|
||||
|
||||
/* Bottom */
|
||||
|
||||
.l-mb-small { margin-bottom: var(--dim-small); }
|
||||
.l-mb-med { margin-bottom: var(--dim-medium); }
|
||||
.l-mb-large {}
|
||||
.l-mb-mega { margin-bottom: var(--dim-mega); }
|
||||
|
||||
/* Left */
|
||||
|
||||
.l-ml-small { margin-left: var(--dim-small); }
|
||||
|
||||
/* Right */
|
||||
|
||||
.l-mr-small { margin-right: var(--dim-small); }
|
||||
|
||||
/* Auto */
|
||||
|
||||
.l-mlr-auto { margin-left: auto; margin-right: auto; }
|
||||
.l-m-auto { margin: auto }
|
||||
|
||||
/* Margin */
|
||||
|
||||
.l-m-small { margin: var(--dim-small) }
|
||||
.l-m-med { margin: var(--dim-medium) }
|
||||
.l-m-0 { margin: 0 }
|
||||
|
||||
/** Padding
|
||||
---------------------------------------------------------*/
|
||||
|
||||
.l-p-small { padding: var(--dim-small); }
|
||||
.l-pl-small { padding-left: var(--dim-small); }
|
||||
.l-pr-small { padding-right: var(--dim-small); }
|
||||
.l-plr-small {
|
||||
padding-right: var(--dim-small);
|
||||
padding-left: var(--dim-small);
|
||||
}
|
||||
.l-pb-small { padding-bottom: var(--dim-small); }
|
||||
.l-pt-small { padding-top: var(--dim-small); }
|
||||
.l-pt-mega { padding-top: var(--dim-mega); }
|
||||
.l-pt-micro { padding-top: var(--dim-micro); }
|
||||
.l-pb-micro { padding-bottom: var(--dim-micro); }
|
||||
.l-p-0 { padding: 0 ;}
|
||||
|
||||
/** Helpers
|
||||
---------------------------------------------------------*/
|
||||
|
||||
.l-clearfix:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.l-inline-block {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.is-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.is-invisible {
|
||||
visibility: hidden !important;
|
||||
}
|
||||
16
gaia/distros/spark/apps/customizer-launcher/components/base/bower.json
Executable file
16
gaia/distros/spark/apps/customizer-launcher/components/base/bower.json
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "base",
|
||||
"version": "0.0.0",
|
||||
"authors": [
|
||||
"Wilson Page <wilsonpage@me.com>"
|
||||
],
|
||||
"main": "base.css",
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
||||
18
gaia/distros/spark/apps/customizer-launcher/components/font-fit/bower.json
Executable file
18
gaia/distros/spark/apps/customizer-launcher/components/font-fit/bower.json
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "font-fit",
|
||||
"main": "font-fit.js",
|
||||
"version": "0.3.1",
|
||||
"authors": [
|
||||
"Wilson Page <wilsonpage@me.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"README.md",
|
||||
"index.html",
|
||||
"package.json"
|
||||
]
|
||||
}
|
||||
132
gaia/distros/spark/apps/customizer-launcher/components/font-fit/font-fit.js
Executable file
132
gaia/distros/spark/apps/customizer-launcher/components/font-fit/font-fit.js
Executable file
|
|
@ -0,0 +1,132 @@
|
|||
;(function(define){define(function(require,exports,module){
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Simple logger.
|
||||
*
|
||||
* @return {Function}
|
||||
*/
|
||||
var debug = 0 ? console.log.bind(console) : function(){};
|
||||
|
||||
/**
|
||||
* Global canvas cache.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
var cache = {};
|
||||
|
||||
/**
|
||||
* Default min/max font-size.
|
||||
*
|
||||
* @type {Number}
|
||||
*/
|
||||
var MIN = 16;
|
||||
var MAX = 24;
|
||||
|
||||
/**
|
||||
* The number of pixels to subtract from
|
||||
* the given `config.space` to ensure
|
||||
* HTML text doesn't overflow container.
|
||||
*
|
||||
* Ideally we would use 1px, but in some
|
||||
* cases italicised text in canvas is ~2px
|
||||
* longer than the same text in HTML.
|
||||
*
|
||||
* http://bugzil.la/1126391
|
||||
*
|
||||
* @type {Number}
|
||||
*/
|
||||
var BUFFER = 3;
|
||||
|
||||
/**
|
||||
* Get the font-size that closest fits
|
||||
* the given space with the given font.
|
||||
*
|
||||
* Config:
|
||||
*
|
||||
* - {String} `text` The text string
|
||||
* - {String} `font` Font shorthand string
|
||||
* - {Number} `space` Width (px) to fit the text into
|
||||
* - {Number} `min` Min font-size (px) (optional)
|
||||
* - {Number} `max` Max font-size (px) (optional)
|
||||
*
|
||||
* @param {Object} config
|
||||
* @return {Object} {fontSize,overflowing,textWidth}
|
||||
*/
|
||||
module.exports = function(config) {
|
||||
debug('font fit', config);
|
||||
var space = config.space - BUFFER;
|
||||
var min = config.min || MIN;
|
||||
var max = config.max || MAX;
|
||||
var text = trim(config.text);
|
||||
var fontSize = max;
|
||||
var textWidth;
|
||||
var font;
|
||||
|
||||
do {
|
||||
font = config.font.replace(/\d+px/, fontSize + 'px');
|
||||
textWidth = getTextWidth(text, font);
|
||||
} while (textWidth > space && fontSize !== min && fontSize--);
|
||||
|
||||
return {
|
||||
textWidth: textWidth,
|
||||
fontSize: fontSize,
|
||||
overflowing: textWidth > space
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the width of the given text
|
||||
* with the given font style.
|
||||
*
|
||||
* @param {String} text
|
||||
* @param {String} font (CSS shorthand)
|
||||
* @return {Number} (px)
|
||||
*/
|
||||
function getTextWidth(text, font) {
|
||||
var ctx = getCanvasContext(font);
|
||||
var width = ctx.measureText(text).width;
|
||||
debug('got text width', width);
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a canvas context configured
|
||||
* to the given font style.
|
||||
*
|
||||
* @param {String} font
|
||||
* @return {CanvasRenderingContext2D}
|
||||
*/
|
||||
function getCanvasContext(font) {
|
||||
debug('get canvas context', font);
|
||||
|
||||
var cached = cache[font];
|
||||
if (cached) { return cached; }
|
||||
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.setAttribute('moz-opaque', 'true');
|
||||
canvas.setAttribute('width', '1px');
|
||||
canvas.setAttribute('height', '1px');
|
||||
debug('created canvas', canvas);
|
||||
|
||||
var ctx = canvas.getContext('2d', { willReadFrequently: true });
|
||||
ctx.font = font;
|
||||
|
||||
return cache[font] = ctx;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim leading, trailing
|
||||
* and excess whitespace.
|
||||
*
|
||||
* @param {String} text
|
||||
* @return {String}
|
||||
*/
|
||||
function trim(text) {
|
||||
return text.replace(/\s+/g, ' ').trim();
|
||||
}
|
||||
|
||||
});})(typeof define=='function'&&define.amd?define
|
||||
:(function(n,w){'use strict';return typeof module=='object'?function(c){
|
||||
c(require,exports,module);}:function(c){var m={exports:{}};c(function(n){
|
||||
return w[n];},m.exports,m);w[n]=m.exports;};})('font-fit',this));
|
||||
|
|
@ -0,0 +1,363 @@
|
|||
Mozilla Public License, version 2.0
|
||||
|
||||
1. Definitions
|
||||
|
||||
1.1. "Contributor"
|
||||
|
||||
means each individual or legal entity that creates, contributes to the
|
||||
creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
|
||||
means the combination of the Contributions of others (if any) used by a
|
||||
Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
|
||||
means Source Code Form to which the initial Contributor has attached the
|
||||
notice in Exhibit A, the Executable Form of such Source Code Form, and
|
||||
Modifications of such Source Code Form, in each case including portions
|
||||
thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
a. that the initial Contributor has attached the notice described in
|
||||
Exhibit B to the Covered Software; or
|
||||
|
||||
b. that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the terms of
|
||||
a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
|
||||
means a work that combines Covered Software with other material, in a
|
||||
separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
|
||||
means having the right to grant, to the maximum extent possible, whether
|
||||
at the time of the initial grant or subsequently, any and all of the
|
||||
rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
|
||||
means any of the following:
|
||||
|
||||
a. any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered Software; or
|
||||
|
||||
b. any new file in Source Code Form that contains any Covered Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the License,
|
||||
by the making, using, selling, offering for sale, having made, import,
|
||||
or transfer of either its Contributions or its Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
|
||||
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
||||
General Public License, Version 2.1, the GNU Affero General Public
|
||||
License, Version 3.0, or any later versions of those licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that controls, is
|
||||
controlled by, or is under common control with You. For purposes of this
|
||||
definition, "control" means (a) the power, direct or indirect, to cause
|
||||
the direction or management of such entity, whether by contract or
|
||||
otherwise, or (b) ownership of more than fifty percent (50%) of the
|
||||
outstanding shares or beneficial ownership of such entity.
|
||||
|
||||
|
||||
2. License Grants and Conditions
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
a. under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
b. under Patent Claims of such Contributor to make, use, sell, offer for
|
||||
sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
a. for any code that a Contributor has removed from Covered Software; or
|
||||
|
||||
b. for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
c. under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights to
|
||||
grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
||||
Section 2.1.
|
||||
|
||||
|
||||
3. Responsibilities
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
a. such Covered Software must also be made available in Source Code Form,
|
||||
as described in Section 3.1, and You must inform recipients of the
|
||||
Executable Form how they can obtain a copy of such Source Code Form by
|
||||
reasonable means in a timely manner, at a charge no more than the cost
|
||||
of distribution to the recipient; and
|
||||
|
||||
b. You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter the
|
||||
recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty, or
|
||||
limitations of liability) contained within the Source Code Form of the
|
||||
Covered Software, except that You may alter any license notices to the
|
||||
extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this License
|
||||
with respect to some or all of the Covered Software due to statute,
|
||||
judicial order, or regulation then You must: (a) comply with the terms of
|
||||
this License to the maximum extent possible; and (b) describe the
|
||||
limitations and the code they affect. Such description must be placed in a
|
||||
text file included with all distributions of the Covered Software under
|
||||
this License. Except to the extent prohibited by statute or regulation,
|
||||
such description must be sufficiently detailed for a recipient of ordinary
|
||||
skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically if You
|
||||
fail to comply with any of its terms. However, if You become compliant,
|
||||
then the rights granted under this License from a particular Contributor
|
||||
are reinstated (a) provisionally, unless and until such Contributor
|
||||
explicitly and finally terminates Your grants, and (b) on an ongoing
|
||||
basis, if such Contributor fails to notify You of the non-compliance by
|
||||
some reasonable means prior to 60 days after You have come back into
|
||||
compliance. Moreover, Your grants from a particular Contributor are
|
||||
reinstated on an ongoing basis if such Contributor notifies You of the
|
||||
non-compliance by some reasonable means, this is the first time You have
|
||||
received notice of non-compliance with this License from such
|
||||
Contributor, and You become compliant prior to 30 days after Your receipt
|
||||
of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
|
||||
license agreements (excluding distributors and resellers) which have been
|
||||
validly granted by You or Your distributors under this License prior to
|
||||
termination shall survive termination.
|
||||
|
||||
6. Disclaimer of Warranty
|
||||
|
||||
Covered Software is provided under this License on an "as is" basis,
|
||||
without warranty of any kind, either expressed, implied, or statutory,
|
||||
including, without limitation, warranties that the Covered Software is free
|
||||
of defects, merchantable, fit for a particular purpose or non-infringing.
|
||||
The entire risk as to the quality and performance of the Covered Software
|
||||
is with You. Should any Covered Software prove defective in any respect,
|
||||
You (not any Contributor) assume the cost of any necessary servicing,
|
||||
repair, or correction. This disclaimer of warranty constitutes an essential
|
||||
part of this License. No use of any Covered Software is authorized under
|
||||
this License except under this disclaimer.
|
||||
|
||||
7. Limitation of Liability
|
||||
|
||||
Under no circumstances and under no legal theory, whether tort (including
|
||||
negligence), contract, or otherwise, shall any Contributor, or anyone who
|
||||
distributes Covered Software as permitted above, be liable to You for any
|
||||
direct, indirect, special, incidental, or consequential damages of any
|
||||
character including, without limitation, damages for lost profits, loss of
|
||||
goodwill, work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses, even if such party shall have been
|
||||
informed of the possibility of such damages. This limitation of liability
|
||||
shall not apply to liability for death or personal injury resulting from
|
||||
such party's negligence to the extent applicable law prohibits such
|
||||
limitation. Some jurisdictions do not allow the exclusion or limitation of
|
||||
incidental or consequential damages, so this exclusion and limitation may
|
||||
not apply to You.
|
||||
|
||||
8. Litigation
|
||||
|
||||
Any litigation relating to this License may be brought only in the courts
|
||||
of a jurisdiction where the defendant maintains its principal place of
|
||||
business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions. Nothing
|
||||
in this Section shall prevent a party's ability to bring cross-claims or
|
||||
counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides that
|
||||
the language of a contract shall be construed against the drafter shall not
|
||||
be used to construe this License against a Contributor.
|
||||
|
||||
|
||||
10. Versions of the License
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses If You choose to distribute Source Code Form that is
|
||||
Incompatible With Secondary Licenses under the terms of this version of
|
||||
the License, the notice described in Exhibit B of this License must be
|
||||
attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file,
|
||||
then You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a
|
||||
notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
|
||||
This Source Code Form is "Incompatible
|
||||
With Secondary Licenses", as defined by
|
||||
the Mozilla Public License, v. 2.0.
|
||||
|
||||
|
|
@ -0,0 +1,144 @@
|
|||
'use strict';
|
||||
|
||||
/* global Notification, console */
|
||||
|
||||
const DEFAULT_IMAGE_SIZE = 64;
|
||||
const MOZ_SETTINGS_NOT_AVAILABLE_MSG = 'navigator.mozSettings is not available';
|
||||
|
||||
class ImageHelper {
|
||||
static getImage(aSrc) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let image = new Image();
|
||||
image.src = aSrc;
|
||||
image.onload = () => resolve(image);
|
||||
image.onerror = reason => reject(reason);
|
||||
}).catch(reason => console.warn('Could not load an achievement image:',
|
||||
reason));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a Data URL for an image from source.
|
||||
* @param {String} aSrc source path to the image
|
||||
* @return {Promise} a promise of Data URL.
|
||||
*/
|
||||
static generateImageDataURL(aSrc) {
|
||||
return ImageHelper.getImage(aSrc).then(image => {
|
||||
try {
|
||||
let canvas = document.createElement('canvas');
|
||||
canvas.height = canvas.width = DEFAULT_IMAGE_SIZE;
|
||||
let context = canvas.getContext('2d');
|
||||
let dataUrl;
|
||||
|
||||
context.drawImage(image, 0, 0, DEFAULT_IMAGE_SIZE, DEFAULT_IMAGE_SIZE);
|
||||
dataUrl = canvas.toDataURL();
|
||||
|
||||
// Clean up.
|
||||
canvas.width = canvas.height = 0;
|
||||
canvas = null;
|
||||
|
||||
return dataUrl;
|
||||
} catch(e) {
|
||||
return Promise.reject('Could not convert image to Data URL.');
|
||||
}
|
||||
}).catch(reason => console.warn(reason));
|
||||
}
|
||||
}
|
||||
|
||||
class SettingsHelper {
|
||||
static get(name, defaultValue) {
|
||||
if (!name) {
|
||||
return Promise.reject('Setting name is missing');
|
||||
}
|
||||
|
||||
if (!navigator.mozSettings) {
|
||||
console.warn(MOZ_SETTINGS_NOT_AVAILABLE_MSG);
|
||||
return Promise.reject(MOZ_SETTINGS_NOT_AVAILABLE_MSG);
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let setting = navigator.mozSettings.createLock().get(name, defaultValue);
|
||||
setting.onsuccess = () => {
|
||||
let settingValue = setting.result[name] || defaultValue;
|
||||
resolve(settingValue);
|
||||
};
|
||||
setting.onerror = () => { reject(setting.error); };
|
||||
});
|
||||
}
|
||||
|
||||
static set(settings) {
|
||||
if (!settings) {
|
||||
return Promise.reject('Settings are missing');
|
||||
}
|
||||
|
||||
if (!navigator.mozSettings) {
|
||||
console.warn(MOZ_SETTINGS_NOT_AVAILABLE_MSG);
|
||||
return Promise.reject(MOZ_SETTINGS_NOT_AVAILABLE_MSG);
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let result = navigator.mozSettings.createLock().set(settings);
|
||||
result.onsuccess = () => { resolve(result.result); };
|
||||
result.onerror = () => { reject(result.error); };
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default class AchievementsService {
|
||||
/**
|
||||
* Reward an achievement and store a record in 'achievements' setting.
|
||||
* @param {JSON} options attributes for the achievement that is awarded:
|
||||
* {String} criteria URL of the criteria for earning
|
||||
* the achievement
|
||||
* {String} evidence A URN of the evidence of
|
||||
* achievement unlocked
|
||||
* {String} name Achievement name
|
||||
* {String} description Achievement description
|
||||
* {String} image Achievement image
|
||||
*/
|
||||
reward({criteria, evidence, name, description, image}) {
|
||||
if (!evidence) {
|
||||
return Promise.reject('Evidence is not provided.');
|
||||
}
|
||||
|
||||
let issuedOn;
|
||||
return SettingsHelper.get('achievements', []).then(achievements => {
|
||||
let achievement = achievements.find(
|
||||
achievement => achievement.criteria === criteria);
|
||||
|
||||
if (!achievement) {
|
||||
return Promise.reject('Achievement is not registered.');
|
||||
}
|
||||
if (achievement.evidence) {
|
||||
return Promise.reject('Achievement is already awarded.');
|
||||
}
|
||||
|
||||
achievement.evidence = evidence;
|
||||
achievement.uid = 'achievement' + Math.round(Math.random() * 100000000);
|
||||
achievement.issuedOn = issuedOn = Date.now();
|
||||
achievement.recipient = {}; // TODO
|
||||
|
||||
return achievements;
|
||||
}).then(achievements => Promise.all([
|
||||
ImageHelper.generateImageDataURL(image),
|
||||
SettingsHelper.set({ 'achievements': achievements })
|
||||
])).then(([image]) => {
|
||||
// Send a Notification via WebAPI to be handled by the Gaia::System
|
||||
let notification = new Notification(name, {
|
||||
body: description,
|
||||
icon: image,
|
||||
tag: issuedOn
|
||||
});
|
||||
|
||||
notification.onclick = () => {
|
||||
let activity = new window.MozActivity({
|
||||
name: 'configure',
|
||||
data: {
|
||||
target: 'device',
|
||||
section: 'achievements'
|
||||
}
|
||||
});
|
||||
activity.onsuccess = activity.onerror = () => { notification.close(); };
|
||||
};
|
||||
}).catch(reason => console.warn(reason));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "fxos-achievements-service",
|
||||
"version": "0.0.14",
|
||||
"description": "Achievements service for embedding achievements support into Gaia apps",
|
||||
"homepage": "https://github.com/fxos/fxos-achievements-service",
|
||||
"license": "MPL",
|
||||
"main": "achievements-service.js",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"example",
|
||||
"componenets",
|
||||
"node_modules",
|
||||
"package.json",
|
||||
"README.md",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
175
gaia/distros/spark/apps/customizer-launcher/components/fxos-achievements-service/dist/achievements-service.js
vendored
Executable file
175
gaia/distros/spark/apps/customizer-launcher/components/fxos-achievements-service/dist/achievements-service.js
vendored
Executable file
|
|
@ -0,0 +1,175 @@
|
|||
define(["exports"], function (exports) {
|
||||
"use strict";
|
||||
|
||||
var _toArray = function (arr) {
|
||||
return Array.isArray(arr) ? arr : Array.from(arr);
|
||||
};
|
||||
|
||||
"use strict";
|
||||
|
||||
/* global Notification, console */
|
||||
|
||||
var DEFAULT_IMAGE_SIZE = 64;
|
||||
var MOZ_SETTINGS_NOT_AVAILABLE_MSG = "navigator.mozSettings is not available";
|
||||
|
||||
var ImageHelper = (function () {
|
||||
var ImageHelper = function ImageHelper() {};
|
||||
|
||||
ImageHelper.getImage = function (aSrc) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
var image = new Image();
|
||||
image.src = aSrc;
|
||||
image.onload = function () {
|
||||
return resolve(image);
|
||||
};
|
||||
image.onerror = function (reason) {
|
||||
return reject(reason);
|
||||
};
|
||||
})["catch"](function (reason) {
|
||||
return console.warn("Could not load an achievement image:", reason);
|
||||
});
|
||||
};
|
||||
|
||||
ImageHelper.generateImageDataURL = function (aSrc) {
|
||||
return ImageHelper.getImage(aSrc).then(function (image) {
|
||||
try {
|
||||
var canvas = document.createElement("canvas");
|
||||
canvas.height = canvas.width = DEFAULT_IMAGE_SIZE;
|
||||
var context = canvas.getContext("2d");
|
||||
var dataUrl;
|
||||
|
||||
context.drawImage(image, 0, 0, DEFAULT_IMAGE_SIZE, DEFAULT_IMAGE_SIZE);
|
||||
dataUrl = canvas.toDataURL();
|
||||
|
||||
// Clean up.
|
||||
canvas.width = canvas.height = 0;
|
||||
canvas = null;
|
||||
|
||||
return dataUrl;
|
||||
} catch (e) {
|
||||
return Promise.reject("Could not convert image to Data URL.");
|
||||
}
|
||||
})["catch"](function (reason) {
|
||||
return console.warn(reason);
|
||||
});
|
||||
};
|
||||
|
||||
return ImageHelper;
|
||||
})();
|
||||
|
||||
var SettingsHelper = (function () {
|
||||
var SettingsHelper = function SettingsHelper() {};
|
||||
|
||||
SettingsHelper.get = function (name, defaultValue) {
|
||||
if (!name) {
|
||||
return Promise.reject("Setting name is missing");
|
||||
}
|
||||
|
||||
if (!navigator.mozSettings) {
|
||||
console.warn(MOZ_SETTINGS_NOT_AVAILABLE_MSG);
|
||||
return Promise.reject(MOZ_SETTINGS_NOT_AVAILABLE_MSG);
|
||||
}
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
var setting = navigator.mozSettings.createLock().get(name, defaultValue);
|
||||
setting.onsuccess = function () {
|
||||
var settingValue = setting.result[name] || defaultValue;
|
||||
resolve(settingValue);
|
||||
};
|
||||
setting.onerror = function () {
|
||||
reject(setting.error);
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
SettingsHelper.set = function (settings) {
|
||||
if (!settings) {
|
||||
return Promise.reject("Settings are missing");
|
||||
}
|
||||
|
||||
if (!navigator.mozSettings) {
|
||||
console.warn(MOZ_SETTINGS_NOT_AVAILABLE_MSG);
|
||||
return Promise.reject(MOZ_SETTINGS_NOT_AVAILABLE_MSG);
|
||||
}
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
var result = navigator.mozSettings.createLock().set(settings);
|
||||
result.onsuccess = function () {
|
||||
resolve(result.result);
|
||||
};
|
||||
result.onerror = function () {
|
||||
reject(result.error);
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
return SettingsHelper;
|
||||
})();
|
||||
|
||||
var AchievementsService = (function () {
|
||||
var AchievementsService = function AchievementsService() {};
|
||||
|
||||
AchievementsService.prototype.reward = function (_ref) {
|
||||
var criteria = _ref.criteria;
|
||||
var evidence = _ref.evidence;
|
||||
var name = _ref.name;
|
||||
var description = _ref.description;
|
||||
var image = _ref.image;
|
||||
if (!evidence) {
|
||||
return Promise.reject("Evidence is not provided.");
|
||||
}
|
||||
|
||||
var issuedOn;
|
||||
return SettingsHelper.get("achievements", []).then(function (achievements) {
|
||||
var achievement = achievements.find(function (achievement) {
|
||||
return achievement.criteria === criteria;
|
||||
});
|
||||
|
||||
if (!achievement) {
|
||||
return Promise.reject("Achievement is not registered.");
|
||||
}
|
||||
if (achievement.evidence) {
|
||||
return Promise.reject("Achievement is already awarded.");
|
||||
}
|
||||
|
||||
achievement.evidence = evidence;
|
||||
achievement.uid = "achievement" + Math.round(Math.random() * 100000000);
|
||||
achievement.issuedOn = issuedOn = Date.now();
|
||||
achievement.recipient = {}; // TODO
|
||||
|
||||
return achievements;
|
||||
}).then(function (achievements) {
|
||||
return Promise.all([ImageHelper.generateImageDataURL(image), SettingsHelper.set({ achievements: achievements })]);
|
||||
}).then(function (_ref2) {
|
||||
var _ref3 = _toArray(_ref2);
|
||||
|
||||
var image = _ref3[0];
|
||||
// Send a Notification via WebAPI to be handled by the Gaia::System
|
||||
var notification = new Notification(name, {
|
||||
body: description,
|
||||
icon: image,
|
||||
tag: issuedOn
|
||||
});
|
||||
|
||||
notification.onclick = function () {
|
||||
var activity = new window.MozActivity({
|
||||
name: "configure",
|
||||
data: {
|
||||
target: "device",
|
||||
section: "achievements"
|
||||
}
|
||||
});
|
||||
activity.onsuccess = activity.onerror = function () {
|
||||
notification.close();
|
||||
};
|
||||
};
|
||||
})["catch"](function (reason) {
|
||||
return console.warn(reason);
|
||||
});
|
||||
};
|
||||
|
||||
return AchievementsService;
|
||||
})();
|
||||
|
||||
exports["default"] = AchievementsService;
|
||||
});
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
'use strict';
|
||||
|
||||
/* global require, console */
|
||||
|
||||
var gulp = require('gulp');
|
||||
var to5 = require('gulp-6to5');
|
||||
|
||||
/**
|
||||
* converts javascript to es5.
|
||||
*/
|
||||
gulp.task('to5', function () {
|
||||
try {
|
||||
return gulp.src('./achievements-service.js')
|
||||
.pipe(to5({ modules: 'amd' }).on('error', function(e) {
|
||||
console.log('error running 6to5', e);
|
||||
}))
|
||||
.pipe(gulp.dest('./dist/'));
|
||||
} catch(e) {
|
||||
console.log('Got error in 6to5', e);
|
||||
}
|
||||
});
|
||||
|
||||
gulp.task('default', ['to5']);
|
||||
|
||||
/**
|
||||
* Runs travis tests
|
||||
*/
|
||||
gulp.task('travis', ['to5']);
|
||||
|
|
@ -0,0 +1,363 @@
|
|||
Mozilla Public License, version 2.0
|
||||
|
||||
1. Definitions
|
||||
|
||||
1.1. "Contributor"
|
||||
|
||||
means each individual or legal entity that creates, contributes to the
|
||||
creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
|
||||
means the combination of the Contributions of others (if any) used by a
|
||||
Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
|
||||
means Source Code Form to which the initial Contributor has attached the
|
||||
notice in Exhibit A, the Executable Form of such Source Code Form, and
|
||||
Modifications of such Source Code Form, in each case including portions
|
||||
thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
a. that the initial Contributor has attached the notice described in
|
||||
Exhibit B to the Covered Software; or
|
||||
|
||||
b. that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the terms of
|
||||
a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
|
||||
means a work that combines Covered Software with other material, in a
|
||||
separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
|
||||
means having the right to grant, to the maximum extent possible, whether
|
||||
at the time of the initial grant or subsequently, any and all of the
|
||||
rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
|
||||
means any of the following:
|
||||
|
||||
a. any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered Software; or
|
||||
|
||||
b. any new file in Source Code Form that contains any Covered Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the License,
|
||||
by the making, using, selling, offering for sale, having made, import,
|
||||
or transfer of either its Contributions or its Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
|
||||
means either the GNU General Public License, Version 2.0, the GNU Lesser
|
||||
General Public License, Version 2.1, the GNU Affero General Public
|
||||
License, Version 3.0, or any later versions of those licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that controls, is
|
||||
controlled by, or is under common control with You. For purposes of this
|
||||
definition, "control" means (a) the power, direct or indirect, to cause
|
||||
the direction or management of such entity, whether by contract or
|
||||
otherwise, or (b) ownership of more than fifty percent (50%) of the
|
||||
outstanding shares or beneficial ownership of such entity.
|
||||
|
||||
|
||||
2. License Grants and Conditions
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
a. under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
b. under Patent Claims of such Contributor to make, use, sell, offer for
|
||||
sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
a. for any code that a Contributor has removed from Covered Software; or
|
||||
|
||||
b. for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
c. under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights to
|
||||
grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in
|
||||
Section 2.1.
|
||||
|
||||
|
||||
3. Responsibilities
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
a. such Covered Software must also be made available in Source Code Form,
|
||||
as described in Section 3.1, and You must inform recipients of the
|
||||
Executable Form how they can obtain a copy of such Source Code Form by
|
||||
reasonable means in a timely manner, at a charge no more than the cost
|
||||
of distribution to the recipient; and
|
||||
|
||||
b. You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter the
|
||||
recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty, or
|
||||
limitations of liability) contained within the Source Code Form of the
|
||||
Covered Software, except that You may alter any license notices to the
|
||||
extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this License
|
||||
with respect to some or all of the Covered Software due to statute,
|
||||
judicial order, or regulation then You must: (a) comply with the terms of
|
||||
this License to the maximum extent possible; and (b) describe the
|
||||
limitations and the code they affect. Such description must be placed in a
|
||||
text file included with all distributions of the Covered Software under
|
||||
this License. Except to the extent prohibited by statute or regulation,
|
||||
such description must be sufficiently detailed for a recipient of ordinary
|
||||
skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically if You
|
||||
fail to comply with any of its terms. However, if You become compliant,
|
||||
then the rights granted under this License from a particular Contributor
|
||||
are reinstated (a) provisionally, unless and until such Contributor
|
||||
explicitly and finally terminates Your grants, and (b) on an ongoing
|
||||
basis, if such Contributor fails to notify You of the non-compliance by
|
||||
some reasonable means prior to 60 days after You have come back into
|
||||
compliance. Moreover, Your grants from a particular Contributor are
|
||||
reinstated on an ongoing basis if such Contributor notifies You of the
|
||||
non-compliance by some reasonable means, this is the first time You have
|
||||
received notice of non-compliance with this License from such
|
||||
Contributor, and You become compliant prior to 30 days after Your receipt
|
||||
of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user
|
||||
license agreements (excluding distributors and resellers) which have been
|
||||
validly granted by You or Your distributors under this License prior to
|
||||
termination shall survive termination.
|
||||
|
||||
6. Disclaimer of Warranty
|
||||
|
||||
Covered Software is provided under this License on an "as is" basis,
|
||||
without warranty of any kind, either expressed, implied, or statutory,
|
||||
including, without limitation, warranties that the Covered Software is free
|
||||
of defects, merchantable, fit for a particular purpose or non-infringing.
|
||||
The entire risk as to the quality and performance of the Covered Software
|
||||
is with You. Should any Covered Software prove defective in any respect,
|
||||
You (not any Contributor) assume the cost of any necessary servicing,
|
||||
repair, or correction. This disclaimer of warranty constitutes an essential
|
||||
part of this License. No use of any Covered Software is authorized under
|
||||
this License except under this disclaimer.
|
||||
|
||||
7. Limitation of Liability
|
||||
|
||||
Under no circumstances and under no legal theory, whether tort (including
|
||||
negligence), contract, or otherwise, shall any Contributor, or anyone who
|
||||
distributes Covered Software as permitted above, be liable to You for any
|
||||
direct, indirect, special, incidental, or consequential damages of any
|
||||
character including, without limitation, damages for lost profits, loss of
|
||||
goodwill, work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses, even if such party shall have been
|
||||
informed of the possibility of such damages. This limitation of liability
|
||||
shall not apply to liability for death or personal injury resulting from
|
||||
such party's negligence to the extent applicable law prohibits such
|
||||
limitation. Some jurisdictions do not allow the exclusion or limitation of
|
||||
incidental or consequential damages, so this exclusion and limitation may
|
||||
not apply to You.
|
||||
|
||||
8. Litigation
|
||||
|
||||
Any litigation relating to this License may be brought only in the courts
|
||||
of a jurisdiction where the defendant maintains its principal place of
|
||||
business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions. Nothing
|
||||
in this Section shall prevent a party's ability to bring cross-claims or
|
||||
counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides that
|
||||
the language of a contract shall be construed against the drafter shall not
|
||||
be used to construe this License against a Contributor.
|
||||
|
||||
|
||||
10. Versions of the License
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses If You choose to distribute Source Code Form that is
|
||||
Incompatible With Secondary Licenses under the terms of this version of
|
||||
the License, the notice described in Exhibit B of this License must be
|
||||
attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular file,
|
||||
then You may include the notice in a location (such as a LICENSE file in a
|
||||
relevant directory) where a recipient would be likely to look for such a
|
||||
notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
|
||||
This Source Code Form is "Incompatible
|
||||
With Secondary Licenses", as defined by
|
||||
the Mozilla Public License, v. 2.0.
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "fxos-dev-mode-dialog",
|
||||
"version": "0.0.3",
|
||||
"description": "Developer Mode prompt for Gaia apps.",
|
||||
"homepage": "https://github.com/fxos/fxos-dev-mode-dialog",
|
||||
"license": "MPL",
|
||||
"main": "fxos-dev-mode-dialog.js",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"package.json",
|
||||
"README.md"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,157 @@
|
|||
(function(window) {
|
||||
'use strict';
|
||||
|
||||
var template = `<style>
|
||||
.modal-dialog {
|
||||
background: #2d2d2d;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
z-index: 100;
|
||||
}
|
||||
.modal-dialog > section {
|
||||
color: #FAFAFA;
|
||||
padding: 80px 25px 0;
|
||||
-moz-box-sizing: padding-box;
|
||||
font-size: 22px;
|
||||
line-height: 30px;
|
||||
font-weight: 300;
|
||||
width: 100%;
|
||||
display: inline-block;
|
||||
overflow-y: scroll;
|
||||
max-height: 100%;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.modal-dialog h1 {
|
||||
font-size: 19px;
|
||||
font-weight: 400;
|
||||
line-height: 28px;
|
||||
color: #fff;
|
||||
margin: 0;
|
||||
padding-top: 10px;
|
||||
}
|
||||
/* Menu & buttons setup */
|
||||
.modal-dialog menu {
|
||||
padding: 15px;
|
||||
background: #4d4d4d;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
margin: 0;
|
||||
}
|
||||
.modal-dialog p {
|
||||
word-wrap: break-word;
|
||||
margin: 10px 0 0;
|
||||
padding: 10px 0;
|
||||
border-top: 0.1rem solid #686868;
|
||||
line-height: 30px;
|
||||
}
|
||||
.modal-dialog p > span {
|
||||
padding-top: 25px;
|
||||
display: block;
|
||||
}
|
||||
.modal-dialog menu button {
|
||||
font-family: sans-serif;
|
||||
font-style: italic;
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
margin: 0 0 10px;
|
||||
padding: 0 2px;
|
||||
font-size: 16px;
|
||||
line-height: 40px;
|
||||
-moz-box-sizing: border-box;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
background: #d8d8d8;
|
||||
border: none;
|
||||
border-radius: 20px;
|
||||
color: #333;
|
||||
text-align: center;
|
||||
-moz-margin-end: 10px;
|
||||
}
|
||||
/* Pressed */
|
||||
.modal-dialog menu button:active {
|
||||
background: #00aacc;
|
||||
color: #fff;
|
||||
}
|
||||
.modal-dialog menu button:last-child {
|
||||
-moz-margin-end: 0;
|
||||
}
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<div class="modal-dialog hidden">
|
||||
<section>
|
||||
<h1>Developer Mode not enabled</h1>
|
||||
<p>To gain access to this and other customization features,
|
||||
you must enable Developer Mode.
|
||||
<span>Click Continue to go to Settings app and enable Developer Mode.</span>
|
||||
</p>
|
||||
</section>
|
||||
<menu>
|
||||
<button class="cancel">Cancel</button>
|
||||
<button class="continue">Continue</button>
|
||||
</menu>
|
||||
</div>`;
|
||||
|
||||
var proto = Object.create(HTMLElement.prototype);
|
||||
|
||||
proto.createdCallback = function() {
|
||||
this.shadow = this.createShadowRoot();
|
||||
this.shadow.innerHTML = template;
|
||||
this.modalDialog = this.shadow.querySelector('.modal-dialog');
|
||||
this.cancelButton = this.shadow.querySelector('.cancel');
|
||||
this.continueButton = this.shadow.querySelector('.continue');
|
||||
|
||||
this.cancelButton.addEventListener(
|
||||
'click', this.handleCancel.bind(this));
|
||||
this.continueButton.addEventListener(
|
||||
'click', this.handleContinue.bind(this));
|
||||
|
||||
// If dev mode perf is enabled emit 'enabled' event else
|
||||
// show the confirm modal dialog
|
||||
navigator.getFeature('dom.apps.developer_mode').then(enabled => {
|
||||
if (enabled) {
|
||||
// Emit Enabled Event
|
||||
this.dispatchEvent(new CustomEvent('enabled'));
|
||||
} else {
|
||||
this.modalDialog.classList.remove('hidden');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
proto.handleCancel = function(e) {
|
||||
window.close();
|
||||
};
|
||||
|
||||
proto.handleContinue = function(e) {
|
||||
// Invoke Settings activity to enable developer mode
|
||||
// XXX: Bug 1163889
|
||||
var activity = new window.MozActivity({
|
||||
name: 'configure',
|
||||
data: {
|
||||
target: 'device',
|
||||
section: 'full-developer-mode'
|
||||
}
|
||||
});
|
||||
activity.onerror = function() {
|
||||
console.log('Settings configure activity error:', activity.error.name);
|
||||
};
|
||||
};
|
||||
|
||||
try {
|
||||
document.registerElement('fxos-dev-mode-dialog', { prototype: proto });
|
||||
} catch (e) {
|
||||
if (e.name !== 'NotSupportedError') {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
})(window);
|
||||
15
gaia/distros/spark/apps/customizer-launcher/components/fxos-mvc/bower.json
Executable file
15
gaia/distros/spark/apps/customizer-launcher/components/fxos-mvc/bower.json
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "fxos-mvc",
|
||||
"version": "0.0.7",
|
||||
"homepage": "https://github.com/fxos/mvc",
|
||||
"license": "MPL",
|
||||
"main": "mvc.js",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"example",
|
||||
"node_modules",
|
||||
"package.json",
|
||||
"README.md",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
1660
gaia/distros/spark/apps/customizer-launcher/components/fxos-mvc/dist/mvc.js
vendored
Executable file
1660
gaia/distros/spark/apps/customizer-launcher/components/fxos-mvc/dist/mvc.js
vendored
Executable file
File diff suppressed because it is too large
Load diff
44
gaia/distros/spark/apps/customizer-launcher/components/fxos-mvc/gulpfile.js
Executable file
44
gaia/distros/spark/apps/customizer-launcher/components/fxos-mvc/gulpfile.js
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
var gulp = require('gulp');
|
||||
var merge = require('gulp-merge');
|
||||
var concat = require('gulp-concat');
|
||||
var wrapper = require('gulp-wrapper');
|
||||
var to5 = require('gulp-6to5');
|
||||
|
||||
/**
|
||||
* converts javascript to es5.
|
||||
*/
|
||||
gulp.task('to5', function () {
|
||||
try {
|
||||
return merge(
|
||||
gulp
|
||||
.src([
|
||||
'./node_modules/observe-shim/lib/observe-shim.js',
|
||||
'./node_modules/observe-utils/lib/observe-utils.js'
|
||||
])
|
||||
.pipe(concat('shim.js')),
|
||||
gulp
|
||||
.src([
|
||||
'./node_modules/sanitizer/sanitizer.js'
|
||||
])
|
||||
.pipe(wrapper({
|
||||
header: '(function(){var define,exports;',
|
||||
footer: '})(window);'
|
||||
}))
|
||||
.pipe(concat('deps.js')),
|
||||
gulp
|
||||
.src('./mvc.js')
|
||||
.pipe(to5({
|
||||
modules: 'amd'
|
||||
}).on('error', function(e) {
|
||||
console.log('error running 6to5', e);
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe(concat('mvc.js'))
|
||||
.pipe(gulp.dest('./dist/'));
|
||||
} catch(e) {
|
||||
console.log('Got error in 6to5', e);
|
||||
}
|
||||
});
|
||||
|
||||
gulp.task('default', ['to5']);
|
||||
312
gaia/distros/spark/apps/customizer-launcher/components/fxos-mvc/mvc.js
Executable file
312
gaia/distros/spark/apps/customizer-launcher/components/fxos-mvc/mvc.js
Executable file
|
|
@ -0,0 +1,312 @@
|
|||
/**
|
||||
* Model
|
||||
*/
|
||||
export class Model {
|
||||
constructor(properties) {
|
||||
properties = properties || {};
|
||||
|
||||
for (var key in properties) {
|
||||
this[key] = properties[key];
|
||||
}
|
||||
|
||||
this.observableProperties = {};
|
||||
|
||||
Object.observe(this, (changes) => {
|
||||
changes.forEach((change) => {
|
||||
var handlers = this.observableProperties[change.name];
|
||||
if (handlers) {
|
||||
handlers.forEach((handler) => {
|
||||
handler(change);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
on(property, handler) {
|
||||
if (typeof handler !== 'function') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.observableProperties[property]) {
|
||||
ObserveUtils.defineObservableProperties(this, property);
|
||||
this.observableProperties[property] = [];
|
||||
}
|
||||
|
||||
this.observableProperties[property].push(handler);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* View
|
||||
*/
|
||||
var events = {};
|
||||
|
||||
export class View {
|
||||
constructor(options) {
|
||||
options = options || {};
|
||||
|
||||
for (var key in options) {
|
||||
this[key] = options[key];
|
||||
}
|
||||
|
||||
if (!this.el) {
|
||||
this.el = document.createElement('div');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes an instance with the specified controller.
|
||||
*
|
||||
* @param {Controller} controller
|
||||
* @return {View}
|
||||
*/
|
||||
init(controller) {
|
||||
this.controller = controller;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the layout wrapper for the template.
|
||||
*
|
||||
* @param {Template} Inner template
|
||||
* @return {String} Rendered layout with template
|
||||
*/
|
||||
layout(template) {
|
||||
return template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the default template.
|
||||
*/
|
||||
render(params) {
|
||||
var innerHTML = '';
|
||||
|
||||
if (params) {
|
||||
if (typeof params === 'object') {
|
||||
for (var index in params) {
|
||||
var param = params[index];
|
||||
innerHTML += this.template(param);
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < params.length; i++) {
|
||||
var param = params[i];
|
||||
innerHTML += this.template(param);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
innerHTML = this.template();
|
||||
}
|
||||
|
||||
this.el.innerHTML = this.layout(innerHTML);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override to provide a function that returns the template string.
|
||||
*
|
||||
* @return {String}
|
||||
*/
|
||||
template() {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a single child element using the specified selector.
|
||||
*
|
||||
* @param {String} query
|
||||
* @return {Element | null}
|
||||
*/
|
||||
$(selector) {
|
||||
return this.el.querySelector(selector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all child elements using the specified selector.
|
||||
*
|
||||
* @param {String} query
|
||||
* @return {NodeList}
|
||||
*/
|
||||
$$(selector) {
|
||||
return this.el.querySelectorAll(selector);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
on(type, selector, handler, scope) {
|
||||
var controller = this.controller;
|
||||
scope = scope || this.el;
|
||||
|
||||
if (!events[type]) {
|
||||
events[type] = [];
|
||||
window.addEventListener(type, delegateHandler, true);
|
||||
}
|
||||
|
||||
events[type].push({
|
||||
selector: selector,
|
||||
handler: handler,
|
||||
controller: controller,
|
||||
scope: scope
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
off(type, selector, handler) {
|
||||
if (!events[type]) {
|
||||
return;
|
||||
}
|
||||
|
||||
events[type] = events[type].filter((delegate) => {
|
||||
if (typeof handler === 'function') {
|
||||
return delegate.selector !== selector ||
|
||||
delegate.handler !== handler;
|
||||
}
|
||||
|
||||
return delegate.selector !== selector;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward an event based on the target's `[data-action]` attr to the controller.
|
||||
* e.g. "click" on a `<button data-action="cancel">` goes to controller.cancel()
|
||||
*/
|
||||
function handleAction(event, controller) {
|
||||
var action = event.target.dataset.action;
|
||||
if (controller && controller[action]) {
|
||||
controller[action](event);
|
||||
}
|
||||
}
|
||||
|
||||
function delegateHandler(event) {
|
||||
var target = event.target;
|
||||
|
||||
events[event.type].forEach((delegate) => {
|
||||
if (delegate.scope.contains(target) && target.matches(delegate.selector)) {
|
||||
if (delegate.handler) {
|
||||
delegate.handler.call(target, event);
|
||||
} else {
|
||||
handleAction(event, delegate.controller);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Controller
|
||||
*/
|
||||
export class Controller {
|
||||
constructor(options) {
|
||||
options = options || {};
|
||||
|
||||
for (var key in options) {
|
||||
this[key] = options[key];
|
||||
}
|
||||
|
||||
// Initialize the view (if applicable) when the
|
||||
// controller is instantiated.
|
||||
if (this.view && typeof this.view.init === 'function') {
|
||||
this.view.init(this);
|
||||
}
|
||||
}
|
||||
|
||||
teardown() {
|
||||
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export class RoutingController extends Controller {
|
||||
constructor(controllers) {
|
||||
if (window.routingController) {
|
||||
console.error('Document can only contain one RoutingController');
|
||||
return;
|
||||
}
|
||||
|
||||
super();
|
||||
this._controllers = controllers;
|
||||
this.activeController = null;
|
||||
window.routingController = this;
|
||||
window.addEventListener('hashchange', this.route.bind(this));
|
||||
}
|
||||
|
||||
route() {
|
||||
var route = window.location.hash.slice(1);
|
||||
var controller = this._controllers[route];
|
||||
if (controller) {
|
||||
if (this.activeController) {
|
||||
this.activeController.teardown();
|
||||
}
|
||||
|
||||
this.activeController = controller;
|
||||
controller.main();
|
||||
}
|
||||
}
|
||||
|
||||
controller(id) {
|
||||
return this._controllers[id];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Service
|
||||
*/
|
||||
export class Service {
|
||||
constructor() {
|
||||
this._listeners = {};
|
||||
this._dispatchedEvents = {};
|
||||
}
|
||||
|
||||
addEventListener(name, callback, trigger) {
|
||||
if (!this._listeners[name]) {
|
||||
this._listeners[name] = [callback];
|
||||
} else {
|
||||
this._listeners[name].push(callback);
|
||||
}
|
||||
|
||||
if (trigger && this._dispatchedEvents[name] !== undefined) {
|
||||
setTimeout(() => {
|
||||
callback(this._dispatchedEvents[name]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
removeEventListener(name, callback) {
|
||||
if (!this._listeners[name]) {
|
||||
return;
|
||||
}
|
||||
|
||||
var listenerIndex;
|
||||
this._listeners[name].find((listener, index) => {
|
||||
if (listener === callback) {
|
||||
listenerIndex = index;
|
||||
}
|
||||
|
||||
return listenerIndex !== undefined;
|
||||
});
|
||||
|
||||
if (listenerIndex !== undefined) {
|
||||
this._listeners[name].splice(listenerIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
_dispatchEvent(name, params) {
|
||||
if (!this._listeners[name]) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._dispatchedEvents[name] = params || null;
|
||||
|
||||
this._listeners[name].forEach((listener) => {
|
||||
listener(params);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "fxos-web-server",
|
||||
"version": "0.0.7",
|
||||
"homepage": "https://github.com/justindarc/fxos-web-server",
|
||||
"authors": [
|
||||
"Justin D'Arcangelo <justindarc@gmail.com>"
|
||||
],
|
||||
"main": "dist/fxos-web-server.js",
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"example",
|
||||
"node_modules",
|
||||
"src",
|
||||
"test",
|
||||
"bower.json",
|
||||
"LICENSE",
|
||||
"package.json",
|
||||
"README.md"
|
||||
],
|
||||
"dependencies": {},
|
||||
"devDependencies": {}
|
||||
}
|
||||
710
gaia/distros/spark/apps/customizer-launcher/components/fxos-web-server/dist/fxos-web-server.js
vendored
Executable file
710
gaia/distros/spark/apps/customizer-launcher/components/fxos-web-server/dist/fxos-web-server.js
vendored
Executable file
|
|
@ -0,0 +1,710 @@
|
|||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.HTTPServer=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||||
/*jshint esnext:true*/
|
||||
/*exported BinaryUtils*/
|
||||
'use strict';
|
||||
|
||||
module.exports = window.BinaryUtils = (function() {
|
||||
|
||||
var BinaryUtils = {
|
||||
stringToArrayBuffer: function(string) {
|
||||
var length = (string || '').length;
|
||||
var arrayBuffer = new ArrayBuffer(length);
|
||||
var uint8Array = new Uint8Array(arrayBuffer);
|
||||
for (var i = 0; i < length; i++) {
|
||||
uint8Array[i] = string.charCodeAt(i);
|
||||
}
|
||||
|
||||
return arrayBuffer;
|
||||
},
|
||||
|
||||
arrayBufferToString: function(arrayBuffer) {
|
||||
var results = [];
|
||||
var uint8Array = new Uint8Array(arrayBuffer);
|
||||
|
||||
for (var i = 0, length = uint8Array.length; i < length; i += 200000) {
|
||||
results.push(String.fromCharCode.apply(null, uint8Array.subarray(i, i + 200000)));
|
||||
}
|
||||
|
||||
return results.join('');
|
||||
},
|
||||
|
||||
blobToArrayBuffer: function(blob, callback) {
|
||||
var fileReader = new FileReader();
|
||||
fileReader.onload = function() {
|
||||
if (typeof callback === 'function') {
|
||||
callback(fileReader.result);
|
||||
}
|
||||
};
|
||||
fileReader.readAsArrayBuffer(blob);
|
||||
|
||||
return fileReader.result;
|
||||
},
|
||||
|
||||
mergeArrayBuffers: function(arrayBuffers, callback) {
|
||||
return BinaryUtils.blobToArrayBuffer(new Blob(arrayBuffers), callback);
|
||||
}
|
||||
};
|
||||
|
||||
return BinaryUtils;
|
||||
|
||||
})();
|
||||
|
||||
},{}],2:[function(require,module,exports){
|
||||
/*jshint esnext:true*/
|
||||
/*exported EventTarget*/
|
||||
'use strict';
|
||||
|
||||
module.exports = window.EventTarget = (function() {
|
||||
|
||||
function EventTarget(object) {
|
||||
if (typeof object !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var property in object) {
|
||||
this[property] = object[property];
|
||||
}
|
||||
}
|
||||
|
||||
EventTarget.prototype.constructor = EventTarget;
|
||||
|
||||
EventTarget.prototype.dispatchEvent = function(name, data) {
|
||||
var events = this._events || {};
|
||||
var listeners = events[name] || [];
|
||||
listeners.forEach((listener) => {
|
||||
listener.call(this, data);
|
||||
});
|
||||
};
|
||||
|
||||
EventTarget.prototype.addEventListener = function(name, listener) {
|
||||
var events = this._events = this._events || {};
|
||||
var listeners = events[name] = events[name] || [];
|
||||
if (listeners.find(fn => fn === listener)) {
|
||||
return;
|
||||
}
|
||||
|
||||
listeners.push(listener);
|
||||
};
|
||||
|
||||
EventTarget.prototype.removeEventListener = function(name, listener) {
|
||||
var events = this._events || {};
|
||||
var listeners = events[name] || [];
|
||||
for (var i = listeners.length - 1; i >= 0; i--) {
|
||||
if (listeners[i] === listener) {
|
||||
listeners.splice(i, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return EventTarget;
|
||||
|
||||
})();
|
||||
|
||||
},{}],3:[function(require,module,exports){
|
||||
/*jshint esnext:true*/
|
||||
/*exported HTTPRequest*/
|
||||
'use strict';
|
||||
|
||||
module.exports = window.HTTPRequest = (function() {
|
||||
|
||||
var EventTarget = require('./event-target');
|
||||
var BinaryUtils = require('./binary-utils');
|
||||
|
||||
const CRLF = '\r\n';
|
||||
|
||||
function HTTPRequest(socket) {
|
||||
var parts = [];
|
||||
var receivedLength = 0;
|
||||
|
||||
var checkRequestComplete = () => {
|
||||
var contentLength = parseInt(this.headers['Content-Length'], 10);
|
||||
if (isNaN(contentLength)) {
|
||||
this.complete = true;
|
||||
this.dispatchEvent('complete', this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (receivedLength < contentLength) {
|
||||
return;
|
||||
}
|
||||
|
||||
BinaryUtils.mergeArrayBuffers(parts, (data) => {
|
||||
this.body = parseBody(this.headers['Content-Type'], data);
|
||||
this.complete = true;
|
||||
this.dispatchEvent('complete', this);
|
||||
});
|
||||
|
||||
socket.ondata = null;
|
||||
};
|
||||
|
||||
socket.ondata = (event) => {
|
||||
var data = event.data;
|
||||
|
||||
if (parts.length > 0) {
|
||||
parts.push(data);
|
||||
receivedLength += data.byteLength;
|
||||
checkRequestComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
var firstPart = parseHeader(this, data);
|
||||
if (this.invalid) {
|
||||
this.dispatchEvent('error', this);
|
||||
|
||||
socket.close();
|
||||
socket.ondata = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (firstPart) {
|
||||
parts.push(firstPart);
|
||||
receivedLength += firstPart.byteLength;
|
||||
}
|
||||
|
||||
checkRequestComplete();
|
||||
};
|
||||
}
|
||||
|
||||
HTTPRequest.prototype = new EventTarget();
|
||||
|
||||
HTTPRequest.prototype.constructor = HTTPRequest;
|
||||
|
||||
function parseHeader(request, data) {
|
||||
if (!data) {
|
||||
request.invalid = true;
|
||||
return null;
|
||||
}
|
||||
|
||||
data = BinaryUtils.arrayBufferToString(data);
|
||||
|
||||
var requestParts = data.split(CRLF + CRLF);
|
||||
|
||||
var header = requestParts.shift();
|
||||
var body = requestParts.join(CRLF + CRLF);
|
||||
|
||||
var headerLines = header.split(CRLF);
|
||||
var requestLine = headerLines.shift().split(' ');
|
||||
|
||||
var method = requestLine[0];
|
||||
var uri = requestLine[1];
|
||||
var version = requestLine[2];
|
||||
|
||||
if (version !== HTTPServer.HTTP_VERSION) {
|
||||
request.invalid = true;
|
||||
return null;
|
||||
}
|
||||
|
||||
var uriParts = uri.split('?');
|
||||
|
||||
var path = uriParts.shift();
|
||||
var params = parseURLEncodedString(uriParts.join('?'));
|
||||
|
||||
var headers = {};
|
||||
headerLines.forEach((headerLine) => {
|
||||
var parts = headerLine.split(': ');
|
||||
if (parts.length !== 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
var name = parts[0];
|
||||
var value = parts[1];
|
||||
|
||||
headers[name] = value;
|
||||
});
|
||||
|
||||
request.method = method;
|
||||
request.path = path;
|
||||
request.params = params;
|
||||
request.headers = headers;
|
||||
|
||||
if (headers['Content-Length']) {
|
||||
// request.body = parseBody(headers['Content-Type'], body);
|
||||
return BinaryUtils.stringToArrayBuffer(body);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function setOrAppendValue(object, name, value) {
|
||||
var existingValue = object[name];
|
||||
if (existingValue === undefined) {
|
||||
object[name] = value;
|
||||
} else {
|
||||
if (Array.isArray(existingValue)) {
|
||||
existingValue.push(value);
|
||||
} else {
|
||||
object[name] = [existingValue, value];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function parseURLEncodedString(string) {
|
||||
var values = {};
|
||||
|
||||
string.split('&').forEach((pair) => {
|
||||
if (!pair) {
|
||||
return;
|
||||
}
|
||||
|
||||
var parts = decodeURIComponent(pair).split('=');
|
||||
|
||||
var name = parts.shift();
|
||||
var value = parts.join('=');
|
||||
|
||||
setOrAppendValue(values, name, value);
|
||||
});
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
function parseMultipartFormDataString(string, boundary) {
|
||||
var values = {};
|
||||
|
||||
string.split('--' + boundary).forEach((data) => {
|
||||
data = data.replace(/^\r\n/, '').replace(/\r\n$/, '');
|
||||
|
||||
if (!data || data === '--') {
|
||||
return;
|
||||
}
|
||||
|
||||
var parts = data.split(CRLF + CRLF);
|
||||
|
||||
var header = parts.shift();
|
||||
var value = {
|
||||
headers: {},
|
||||
metadata: {},
|
||||
value: parts.join(CRLF + CRLF)
|
||||
};
|
||||
|
||||
var name;
|
||||
|
||||
var headers = header.split(CRLF);
|
||||
headers.forEach((header) => {
|
||||
var headerParams = header.split(';');
|
||||
var headerParts = headerParams.shift().split(': ');
|
||||
|
||||
var headerName = headerParts[0];
|
||||
var headerValue = headerParts[1];
|
||||
|
||||
if (headerName !== 'Content-Disposition' ||
|
||||
headerValue !== 'form-data') {
|
||||
value.headers[headerName] = headerValue;
|
||||
return;
|
||||
}
|
||||
|
||||
headerParams.forEach((param) => {
|
||||
var paramParts = param.trim().split('=');
|
||||
|
||||
var paramName = paramParts[0];
|
||||
var paramValue = paramParts[1];
|
||||
|
||||
paramValue = paramValue.replace(/\"(.*?)\"/, '$1') || paramValue;
|
||||
|
||||
if (paramName === 'name') {
|
||||
name = paramValue;
|
||||
}
|
||||
|
||||
else {
|
||||
value.metadata[paramName] = paramValue;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (name) {
|
||||
setOrAppendValue(values, name, value);
|
||||
}
|
||||
});
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
function parseBody(contentType, data) {
|
||||
contentType = contentType || 'text/plain';
|
||||
|
||||
var contentTypeParams = contentType.replace(/\s/g, '').split(';');
|
||||
var mimeType = contentTypeParams.shift();
|
||||
|
||||
var body = BinaryUtils.arrayBufferToString(data);
|
||||
|
||||
var result;
|
||||
|
||||
try {
|
||||
switch (mimeType) {
|
||||
case 'application/x-www-form-urlencoded':
|
||||
result = parseURLEncodedString(body);
|
||||
break;
|
||||
case 'multipart/form-data':
|
||||
contentTypeParams.forEach((contentTypeParam) => {
|
||||
var parts = contentTypeParam.split('=');
|
||||
|
||||
var name = parts[0];
|
||||
var value = parts[1];
|
||||
|
||||
if (name === 'boundary') {
|
||||
result = parseMultipartFormDataString(body, value);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 'application/json':
|
||||
result = JSON.parse(body);
|
||||
break;
|
||||
case 'application/xml':
|
||||
result = new DOMParser().parseFromString(body, 'text/xml');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} catch (exception) {
|
||||
console.log('Unable to parse HTTP request body with Content-Type: ' + contentType);
|
||||
}
|
||||
|
||||
return result || body;
|
||||
}
|
||||
|
||||
return HTTPRequest;
|
||||
|
||||
})();
|
||||
|
||||
},{"./binary-utils":1,"./event-target":2}],4:[function(require,module,exports){
|
||||
/*jshint esnext:true*/
|
||||
/*exported HTTPResponse*/
|
||||
'use strict';
|
||||
|
||||
module.exports = window.HTTPResponse = (function() {
|
||||
|
||||
var EventTarget = require('./event-target');
|
||||
var BinaryUtils = require('./binary-utils');
|
||||
var HTTPStatus = require('./http-status');
|
||||
|
||||
const CRLF = '\r\n';
|
||||
const BUFFER_SIZE = 64 * 1024;
|
||||
|
||||
function HTTPResponse(socket, timeout) {
|
||||
this.socket = socket;
|
||||
this.timeout = timeout;
|
||||
|
||||
this.headers = {};
|
||||
this.headers['Content-Type'] = 'text/html';
|
||||
this.headers['Connection'] = 'close';
|
||||
|
||||
if (this.timeout) {
|
||||
this.timeoutHandler = setTimeout(() => {
|
||||
this.send(null, 500);
|
||||
}, this.timeout);
|
||||
}
|
||||
}
|
||||
|
||||
HTTPResponse.prototype = new EventTarget();
|
||||
|
||||
HTTPResponse.prototype.constructor = HTTPResponse;
|
||||
|
||||
HTTPResponse.prototype.send = function(body, status) {
|
||||
return createResponse(body, status, this.headers, (response) => {
|
||||
var offset = 0;
|
||||
var remaining = response.byteLength;
|
||||
|
||||
var sendNextPart = () => {
|
||||
var length = Math.min(remaining, BUFFER_SIZE);
|
||||
|
||||
var bufferFull = this.socket.send(response, offset, length);
|
||||
|
||||
offset += length;
|
||||
remaining -= length;
|
||||
|
||||
if (remaining > 0) {
|
||||
if (!bufferFull) {
|
||||
sendNextPart();
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
clearTimeout(this.timeoutHandler);
|
||||
|
||||
this.socket.close();
|
||||
this.dispatchEvent('complete');
|
||||
}
|
||||
};
|
||||
|
||||
this.socket.ondrain = sendNextPart;
|
||||
|
||||
sendNextPart();
|
||||
});
|
||||
};
|
||||
|
||||
HTTPResponse.prototype.sendFile = function(fileOrPath, status) {
|
||||
if (fileOrPath instanceof File) {
|
||||
BinaryUtils.blobToArrayBuffer(fileOrPath, (arrayBuffer) => {
|
||||
this.send(arrayBuffer, status);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', fileOrPath, true);
|
||||
xhr.responseType = 'arraybuffer';
|
||||
xhr.onload = () => {
|
||||
this.send(xhr.response, status);
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
};
|
||||
|
||||
function createResponseHeader(status, headers) {
|
||||
var header = HTTPStatus.getStatusLine(status);
|
||||
|
||||
for (var name in headers) {
|
||||
header += name + ': ' + headers[name] + CRLF;
|
||||
}
|
||||
|
||||
return header;
|
||||
}
|
||||
|
||||
function createResponse(body, status, headers, callback) {
|
||||
body = body || '';
|
||||
status = status || 200;
|
||||
headers = headers || {};
|
||||
|
||||
headers['Content-Length'] = body.length || body.byteLength;
|
||||
|
||||
var response = new Blob([
|
||||
createResponseHeader(status, headers),
|
||||
CRLF,
|
||||
body
|
||||
]);
|
||||
|
||||
return BinaryUtils.blobToArrayBuffer(response, callback);
|
||||
}
|
||||
|
||||
return HTTPResponse;
|
||||
|
||||
})();
|
||||
|
||||
},{"./binary-utils":1,"./event-target":2,"./http-status":6}],5:[function(require,module,exports){
|
||||
/*jshint esnext:true*/
|
||||
/*exported HTTPServer*/
|
||||
'use strict';
|
||||
|
||||
module.exports = window.HTTPServer = (function() {
|
||||
|
||||
var EventTarget = require('./event-target');
|
||||
var HTTPRequest = require('./http-request');
|
||||
var HTTPResponse = require('./http-response');
|
||||
var IPUtils = require('./ip-utils');
|
||||
|
||||
const DEFAULT_PORT = 8080;
|
||||
const DEFAULT_TIMEOUT = 20000;
|
||||
|
||||
const CRLF = '\r\n';
|
||||
|
||||
function HTTPServer(port, options) {
|
||||
this.port = port || DEFAULT_PORT;
|
||||
|
||||
options = options || {};
|
||||
for (var option in options) {
|
||||
this[option] = options[option];
|
||||
}
|
||||
|
||||
this.running = false;
|
||||
}
|
||||
|
||||
HTTPServer.HTTP_VERSION = 'HTTP/1.1';
|
||||
|
||||
HTTPServer.prototype = new EventTarget();
|
||||
|
||||
HTTPServer.prototype.constructor = HTTPServer;
|
||||
|
||||
HTTPServer.prototype.timeout = DEFAULT_TIMEOUT;
|
||||
|
||||
HTTPServer.prototype.start = function() {
|
||||
if (this.running) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Starting HTTP server on port ' + this.port);
|
||||
|
||||
var socket = navigator.mozTCPSocket.listen(this.port, {
|
||||
binaryType: 'arraybuffer'
|
||||
});
|
||||
|
||||
socket.onconnect = (connectEvent) => {
|
||||
var request = new HTTPRequest(connectEvent);
|
||||
|
||||
request.addEventListener('complete', () => {
|
||||
var response = new HTTPResponse(connectEvent, this.timeout);
|
||||
|
||||
this.dispatchEvent('request', {
|
||||
request: request,
|
||||
response: response
|
||||
});
|
||||
});
|
||||
|
||||
request.addEventListener('error', () => {
|
||||
console.warn('Invalid request received');
|
||||
});
|
||||
};
|
||||
|
||||
this.socket = socket;
|
||||
this.running = true;
|
||||
};
|
||||
|
||||
HTTPServer.prototype.stop = function() {
|
||||
if (!this.running) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Shutting down HTTP server on port ' + this.port);
|
||||
|
||||
this.socket.close();
|
||||
|
||||
this.running = false;
|
||||
};
|
||||
|
||||
return HTTPServer;
|
||||
|
||||
})();
|
||||
|
||||
},{"./event-target":2,"./http-request":3,"./http-response":4,"./ip-utils":7}],6:[function(require,module,exports){
|
||||
/*jshint esnext:true*/
|
||||
/*exported HTTPStatus*/
|
||||
'use strict';
|
||||
|
||||
module.exports = window.HTTPStatus = (function() {
|
||||
|
||||
const CRLF = '\r\n';
|
||||
|
||||
var HTTPStatus = {};
|
||||
|
||||
HTTPStatus.STATUS_CODES = {
|
||||
100: 'Continue',
|
||||
101: 'Switching Protocols',
|
||||
102: 'Processing',
|
||||
200: 'OK',
|
||||
201: 'Created',
|
||||
202: 'Accepted',
|
||||
203: 'Non Authoritative Information',
|
||||
204: 'No Content',
|
||||
205: 'Reset Content',
|
||||
206: 'Partial Content',
|
||||
207: 'Multi-Status',
|
||||
300: 'Mutliple Choices',
|
||||
301: 'Moved Permanently',
|
||||
302: 'Moved Temporarily',
|
||||
303: 'See Other',
|
||||
304: 'Not Modified',
|
||||
305: 'Use Proxy',
|
||||
307: 'Temporary Redirect',
|
||||
400: 'Bad Request',
|
||||
401: 'Unauthorized',
|
||||
402: 'Payment Required',
|
||||
403: 'Forbidden',
|
||||
404: 'Not Found',
|
||||
405: 'Method Not Allowed',
|
||||
406: 'Not Acceptable',
|
||||
407: 'Proxy Authentication Required',
|
||||
408: 'Request Timeout',
|
||||
409: 'Conflict',
|
||||
410: 'Gone',
|
||||
411: 'Length Required',
|
||||
412: 'Precondition Failed',
|
||||
413: 'Request Entity Too Large',
|
||||
414: 'Request-URI Too Long',
|
||||
415: 'Unsupported Media Type',
|
||||
416: 'Requested Range Not Satisfiable',
|
||||
417: 'Expectation Failed',
|
||||
419: 'Insufficient Space on Resource',
|
||||
420: 'Method Failure',
|
||||
422: 'Unprocessable Entity',
|
||||
423: 'Locked',
|
||||
424: 'Failed Dependency',
|
||||
500: 'Server Error',
|
||||
501: 'Not Implemented',
|
||||
502: 'Bad Gateway',
|
||||
503: 'Service Unavailable',
|
||||
504: 'Gateway Timeout',
|
||||
505: 'HTTP Version Not Supported',
|
||||
507: 'Insufficient Storage'
|
||||
};
|
||||
|
||||
HTTPStatus.getStatusLine = function(status) {
|
||||
var reason = HTTPStatus.STATUS_CODES[status] || 'Unknown';
|
||||
|
||||
return [HTTPServer.HTTP_VERSION, status, reason].join(' ') + CRLF;
|
||||
};
|
||||
|
||||
return HTTPStatus;
|
||||
|
||||
})();
|
||||
|
||||
},{}],7:[function(require,module,exports){
|
||||
/*jshint esnext:true*/
|
||||
/*exported IPUtils*/
|
||||
'use strict';
|
||||
|
||||
module.exports = window.IPUtils = (function() {
|
||||
|
||||
const CRLF = '\r\n';
|
||||
|
||||
var IPUtils = {
|
||||
getAddresses: function(callback) {
|
||||
if (typeof callback !== 'function') {
|
||||
console.warn('No callback provided');
|
||||
return;
|
||||
}
|
||||
|
||||
var addresses = {
|
||||
'0.0.0.0': true
|
||||
};
|
||||
|
||||
var rtc = new mozRTCPeerConnection({ iceServers: [] });
|
||||
rtc.createDataChannel('', { reliable: false });
|
||||
|
||||
rtc.onicecandidate = function(evt) {
|
||||
if (evt.candidate) {
|
||||
parseSDP('a=' + evt.candidate.candidate);
|
||||
}
|
||||
};
|
||||
|
||||
rtc.createOffer((description) => {
|
||||
parseSDP(description.sdp);
|
||||
rtc.setLocalDescription(description, noop, noop);
|
||||
}, (error) => {
|
||||
console.warn('Unable to create offer', error);
|
||||
});
|
||||
|
||||
function addAddress(address) {
|
||||
if (addresses[address]) {
|
||||
return;
|
||||
}
|
||||
|
||||
addresses[address] = true;
|
||||
callback(address);
|
||||
}
|
||||
|
||||
function parseSDP(sdp) {
|
||||
sdp.split(CRLF).forEach((line) => {
|
||||
var parts = line.split(' ');
|
||||
|
||||
if (line.indexOf('a=candidate') !== -1) {
|
||||
if (parts[7] === 'host') {
|
||||
addAddress(parts[4]);
|
||||
}
|
||||
}
|
||||
|
||||
else if (line.indexOf('c=') !== -1) {
|
||||
addAddress(parts[2]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function noop() {}
|
||||
|
||||
return IPUtils;
|
||||
|
||||
})();
|
||||
|
||||
},{}]},{},[5])(5)
|
||||
});
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "gaia-button",
|
||||
"version": "0.0.3",
|
||||
"main": "gaia-button.js",
|
||||
"homepage": "https://github.com/gaia-components/gaia-button",
|
||||
"authors": [
|
||||
"cyee@mozilla.com"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
],
|
||||
"devDependencies": {
|
||||
"gaia-fonts": "gaia-components/gaia-fonts#~0.2.1",
|
||||
"gaia-icons": "gaia-components/gaia-icons#~0.7.1",
|
||||
"base": "gaia-components/base",
|
||||
"gaia-theme": "gaia-components/gaia-theme#~0.4.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"gaia-component": "gaia-components/gaia-component#~0.3.0"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,217 @@
|
|||
(function(define){define(function(require,exports,module){
|
||||
/*jshint esnext:true*/
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Dependencies
|
||||
*/
|
||||
|
||||
var component = require('gaia-component');
|
||||
|
||||
/**
|
||||
* Exports
|
||||
*/
|
||||
|
||||
module.exports = component.register('gaia-button', {
|
||||
created: function() {
|
||||
this.setupShadowRoot();
|
||||
|
||||
this.els = {
|
||||
inner: this.shadowRoot.querySelector('.inner'),
|
||||
content: this.shadowRoot.querySelector('.content')
|
||||
};
|
||||
|
||||
this.circular = this.hasAttribute('circular');
|
||||
this.disabled = this.hasAttribute('disabled');
|
||||
this.setAttribute('role', 'button');
|
||||
this.tabIndex = 0;
|
||||
},
|
||||
|
||||
attrs: {
|
||||
circular: {
|
||||
get: function() { this.getAttribute('circular'); },
|
||||
set: function(value) {
|
||||
value = !!(value === '' || value);
|
||||
if (value) {
|
||||
this.setAttribute('circular', '');
|
||||
this.els.inner.setAttribute('circular', '');
|
||||
} else {
|
||||
this.removeAttribute('circular');
|
||||
this.els.inner.removeAttribute('circular');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
disabled: {
|
||||
get: function() { this.getAttribute('disabled'); },
|
||||
set: function(value) {
|
||||
value = !!(value === '' || value);
|
||||
if (value) {
|
||||
this.setAttribute('disabled', '');
|
||||
this.els.inner.setAttribute('disabled', '');
|
||||
} else {
|
||||
this.removeAttribute('disabled');
|
||||
this.els.inner.removeAttribute('disabled');
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
template: `
|
||||
<div class="inner">
|
||||
<div class="background"></div>
|
||||
<div class="content"><content></content></div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
:host {
|
||||
display: block;
|
||||
box-sizing: border-box;
|
||||
height: 50px;
|
||||
min-width: 50%;
|
||||
margin: var(--base-m, 18px);
|
||||
outline: 0;
|
||||
font-style: italic;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
@media(min-width:500px) {
|
||||
:host { min-width: 140px; }
|
||||
}
|
||||
|
||||
:host([circular]) {
|
||||
width: 50px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
:host([disabled]) {
|
||||
pointer-events: none;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/** Inner
|
||||
---------------------------------------------------------*/
|
||||
|
||||
.inner {
|
||||
position: relative;
|
||||
height: 100%;
|
||||
border-radius: 50px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
-moz-user-select: none;
|
||||
line-height: 1;
|
||||
transition: color 0ms 300ms;
|
||||
|
||||
background:
|
||||
var(--button-background,
|
||||
var(--input-background,
|
||||
var(--background-plus,
|
||||
#fff)));
|
||||
|
||||
color:
|
||||
var(--button-color,
|
||||
var(--text-color,
|
||||
inherit));
|
||||
|
||||
box-shadow:
|
||||
var(--button-box-shadow,
|
||||
var(--box-shadow,
|
||||
none));
|
||||
}
|
||||
|
||||
/**
|
||||
* [circular]
|
||||
*/
|
||||
|
||||
.inner[circular] {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
/**
|
||||
* .pressed
|
||||
*/
|
||||
|
||||
.inner:active {
|
||||
transition: none;
|
||||
color: var(--button-color-active, #fff);
|
||||
box-shadow: var(--button-box-shadow-active, none);
|
||||
}
|
||||
|
||||
/** Background
|
||||
---------------------------------------------------------*/
|
||||
|
||||
.background {
|
||||
content: '';
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0;
|
||||
|
||||
transition: opacity 500ms 200ms;
|
||||
|
||||
background:
|
||||
var(--button-background-active,
|
||||
var(--highlight-color,
|
||||
#333));
|
||||
}
|
||||
|
||||
:active .background {
|
||||
transition: none;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.released .background {
|
||||
transition: opacity 500ms;
|
||||
}
|
||||
|
||||
i:before {
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
::content i {
|
||||
margin-left: -2px;
|
||||
margin-right: -2px;
|
||||
}
|
||||
|
||||
::content i + span,
|
||||
::content span + i {
|
||||
-moz-margin-start: 8px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Content
|
||||
---------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* 1. In some cases events seems to be getting
|
||||
* swallowed by text-nodes. Ignoring pointer-
|
||||
* events means we can listen on parent nodes
|
||||
* instead.
|
||||
*/
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
height: 100%;
|
||||
padding: 0 18px;
|
||||
pointer-events: none; /* 1 */
|
||||
}
|
||||
|
||||
[circular] .content {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
</style>`
|
||||
});
|
||||
|
||||
});})((function(n,w){return typeof define=='function'&&define.amd?
|
||||
define:typeof module=='object'?function(c){c(require,exports,module);}:function(c){
|
||||
var m={exports:{}},r=function(n){return w[n];};w[n]=c(r,m.exports,m)||m.exports;};})('gaia-button',this));
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title><gaia-button></title>
|
||||
<meta name="description" content="gaia-text-input demo" />
|
||||
<link rel="stylesheet" type="text/css" href="bower_components/base/base.css">
|
||||
<link rel="stylesheet" type="text/css" href="bower_components/gaia-theme/gaia-theme.css">
|
||||
<link rel="stylesheet" type="text/css" href="bower_components/gaia-icons/gaia-icons.css">
|
||||
<link rel="stylesheet" type="text/css" href="bower_components/gaia-fonts/style.css">
|
||||
<script src="bower_components/gaia-theme/lib/gaia-theme-selector.js"></script>
|
||||
<script src="bower_components/gaia-component/gaia-component.js"></script>
|
||||
<script src="gaia-button.js"></script>
|
||||
<style type="text/css">
|
||||
|
||||
body {
|
||||
padding-top: 48px;
|
||||
background-color: var(--background);
|
||||
}
|
||||
/*
|
||||
[data-icon=back-light] {
|
||||
margin-left: -9px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
|
||||
[data-icon=forward-light] {
|
||||
margin-left: 10px;
|
||||
margin-right: -9px;
|
||||
}*/
|
||||
|
||||
[flex] {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body role="application" class="l-align-center">
|
||||
<gaia-theme-selector></gaia-theme-selector>
|
||||
<h1 class="large l-align-center l-mb-mega"><gaia-button></h1>
|
||||
|
||||
<section>
|
||||
<gaia-button>Gaia button 1</gaia-button>
|
||||
<gaia-button disabled>Gaia button 1</gaia-button>
|
||||
</section>
|
||||
|
||||
<hr/>
|
||||
|
||||
<section>
|
||||
<gaia-button><i data-icon="back-light"></i><span>Back</span></gaia-button>
|
||||
<gaia-button><span>Forward</span><i data-icon="forward-light"></i></gaia-button>
|
||||
</section>
|
||||
|
||||
<hr/>
|
||||
|
||||
<section flex>
|
||||
<gaia-button circular><i data-icon="camera"></i></gaia-button>
|
||||
<gaia-button circular><i data-icon="bug"></i></gaia-button>
|
||||
<gaia-button circular><i data-icon="video"></i></gaia-button>
|
||||
<gaia-button circular><i data-icon="camera"></i></gaia-button>
|
||||
<gaia-button circular><i data-icon="reload"></i></gaia-button>
|
||||
<gaia-button circular><i data-icon="airplane"></i></gaia-button>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"name": "gaia-component",
|
||||
"version": "0.3.8",
|
||||
"authors": [
|
||||
"Wilson Page <wilsonpage@me.com>"
|
||||
],
|
||||
"main": "gaia-component.js",
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"README.md",
|
||||
"package.json",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,420 @@
|
|||
/* globals define */
|
||||
;(function(define){'use strict';define(function(require,exports,module){
|
||||
/**
|
||||
* Locals
|
||||
*/
|
||||
var textContent = Object.getOwnPropertyDescriptor(Node.prototype,
|
||||
'textContent');
|
||||
var innerHTML = Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML');
|
||||
var removeAttribute = Element.prototype.removeAttribute;
|
||||
var setAttribute = Element.prototype.setAttribute;
|
||||
var noop = function() {};
|
||||
|
||||
/**
|
||||
* Register a new component.
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {Object} props
|
||||
* @return {constructor}
|
||||
* @public
|
||||
*/
|
||||
exports.register = function(name, props) {
|
||||
var baseProto = getBaseProto(props.extends);
|
||||
var template = props.template || baseProto.templateString;
|
||||
|
||||
// Components are extensible by default but can be declared
|
||||
// as non extensible as an optimization to avoid
|
||||
// storing the template strings
|
||||
var extensible = props.extensible = props.hasOwnProperty('extensible')?
|
||||
props.extensible : true;
|
||||
|
||||
// Clean up
|
||||
delete props.extends;
|
||||
|
||||
// Pull out CSS that needs to be in the light-dom
|
||||
if (template) {
|
||||
// Stores the string to be reprocessed when
|
||||
// a new component extends this one
|
||||
if (extensible && props.template) {
|
||||
props.templateString = props.template;
|
||||
}
|
||||
|
||||
var output = processCss(template, name);
|
||||
|
||||
props.template = document.createElement('template');
|
||||
props.template.innerHTML = output.template;
|
||||
props.lightCss = output.lightCss;
|
||||
|
||||
props.globalCss = props.globalCss || '';
|
||||
props.globalCss += output.globalCss;
|
||||
}
|
||||
|
||||
// Inject global CSS into the document,
|
||||
// and delete as no longer needed
|
||||
injectGlobalCss(props.globalCss);
|
||||
delete props.globalCss;
|
||||
|
||||
// Merge base getter/setter attributes with the user's,
|
||||
// then define the property descriptors on the prototype.
|
||||
var descriptors = mixin(props.attrs || {}, base.descriptors);
|
||||
|
||||
// Store the orginal descriptors somewhere
|
||||
// a little more private and delete the original
|
||||
props._attrs = props.attrs;
|
||||
delete props.attrs;
|
||||
|
||||
// Create the prototype, extended from base and
|
||||
// define the descriptors directly on the prototype
|
||||
var proto = createProto(baseProto, props);
|
||||
Object.defineProperties(proto, descriptors);
|
||||
|
||||
// Register the custom-element and return the constructor
|
||||
try {
|
||||
return document.registerElement(name, { prototype: proto });
|
||||
} catch (e) {
|
||||
if (e.name !== 'NotSupportedError') {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var base = {
|
||||
properties: {
|
||||
GaiaComponent: true,
|
||||
attributeChanged: noop,
|
||||
attached: noop,
|
||||
detached: noop,
|
||||
created: noop,
|
||||
|
||||
createdCallback: function() {
|
||||
if (this.rtl) { addDirObserver(); }
|
||||
injectLightCss(this);
|
||||
this.created();
|
||||
},
|
||||
|
||||
/**
|
||||
* It is very common to want to keep object
|
||||
* properties in-sync with attributes,
|
||||
* for example:
|
||||
*
|
||||
* el.value = 'foo';
|
||||
* el.setAttribute('value', 'foo');
|
||||
*
|
||||
* So we support an object on the prototype
|
||||
* named 'attrs' to provide a consistent
|
||||
* way for component authors to define
|
||||
* these properties. When an attribute
|
||||
* changes we keep the attr[name]
|
||||
* up-to-date.
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {String||null} from
|
||||
* @param {String||null} to
|
||||
*/
|
||||
attributeChangedCallback: function(name, from, to) {
|
||||
var prop = toCamelCase(name);
|
||||
if (this._attrs && this._attrs[prop]) { this[prop] = to; }
|
||||
this.attributeChanged(name, from, to);
|
||||
},
|
||||
|
||||
attachedCallback: function() { this.attached(); },
|
||||
detachedCallback: function() { this.detached(); },
|
||||
|
||||
/**
|
||||
* A convenient method for setting up
|
||||
* a shadow-root using the defined template.
|
||||
*
|
||||
* @return {ShadowRoot}
|
||||
*/
|
||||
setupShadowRoot: function() {
|
||||
if (!this.template) { return; }
|
||||
var node = document.importNode(this.template.content, true);
|
||||
this.createShadowRoot().appendChild(node);
|
||||
return this.shadowRoot;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets an attribute internally
|
||||
* and externally. This is so that
|
||||
* we can style internal shadow-dom
|
||||
* content.
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {String} value
|
||||
*/
|
||||
setAttr: function(name, value) {
|
||||
var internal = this.shadowRoot.firstElementChild;
|
||||
setAttribute.call(internal, name, value);
|
||||
setAttribute.call(this, name, value);
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes an attribute internally
|
||||
* and externally. This is so that
|
||||
* we can style internal shadow-dom
|
||||
* content.
|
||||
*
|
||||
* @param {String} name
|
||||
* @param {String} value
|
||||
*/
|
||||
removeAttr: function(name) {
|
||||
var internal = this.shadowRoot.firstElementChild;
|
||||
removeAttribute.call(internal, name);
|
||||
removeAttribute.call(this, name);
|
||||
}
|
||||
},
|
||||
|
||||
descriptors: {
|
||||
textContent: {
|
||||
set: function(value) {
|
||||
textContent.set.call(this, value);
|
||||
if (this.lightStyle) { this.appendChild(this.lightStyle); }
|
||||
},
|
||||
|
||||
get: function() {
|
||||
return textContent.get();
|
||||
}
|
||||
},
|
||||
|
||||
innerHTML: {
|
||||
set: function(value) {
|
||||
innerHTML.set.call(this, value);
|
||||
if (this.lightStyle) { this.appendChild(this.lightStyle); }
|
||||
},
|
||||
|
||||
get: innerHTML.get
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The default base prototype to use
|
||||
* when `extends` is undefined.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
var defaultPrototype = createProto(HTMLElement.prototype, base.properties);
|
||||
|
||||
/**
|
||||
* Returns a suitable prototype based
|
||||
* on the object passed.
|
||||
*
|
||||
* @private
|
||||
* @param {HTMLElementPrototype|undefined} proto
|
||||
* @return {HTMLElementPrototype}
|
||||
*/
|
||||
function getBaseProto(proto) {
|
||||
if (!proto) { return defaultPrototype; }
|
||||
proto = proto.prototype || proto;
|
||||
return !proto.GaiaComponent ?
|
||||
createProto(proto, base.properties) : proto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends the given proto and mixes
|
||||
* in the given properties.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} proto
|
||||
* @param {Object} props
|
||||
* @return {Object}
|
||||
*/
|
||||
function createProto(proto, props) {
|
||||
return mixin(Object.create(proto), props);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects presence of shadow-dom
|
||||
* CSS selectors.
|
||||
*
|
||||
* @private
|
||||
* @return {Boolean}
|
||||
*/
|
||||
var hasShadowCSS = (function() {
|
||||
var div = document.createElement('div');
|
||||
try { div.querySelector(':host'); div.querySelector('::content'); return true; }
|
||||
catch (e) { return false; }
|
||||
})();
|
||||
|
||||
/**
|
||||
* Regexs used to extract shadow-css
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
var regex = {
|
||||
shadowCss: /(?:\:host|\:\:content)[^{]*\{[^}]*\}/g,
|
||||
':host': /(?:\:host)/g,
|
||||
':host()': /\:host\((.+)\)(?: \:\:content)?/g,
|
||||
':host-context': /\:host-context\((.+)\)([^{,]+)?/g,
|
||||
'::content': /(?:\:\:content)/g
|
||||
};
|
||||
|
||||
/**
|
||||
* Extracts the :host and ::content rules
|
||||
* from the shadow-dom CSS and rewrites
|
||||
* them to work from the <style scoped>
|
||||
* injected at the root of the component.
|
||||
*
|
||||
* @private
|
||||
* @return {String}
|
||||
*/
|
||||
function processCss(template, name) {
|
||||
var globalCss = '';
|
||||
var lightCss = '';
|
||||
|
||||
if (!hasShadowCSS) {
|
||||
template = template.replace(regex.shadowCss, function(match) {
|
||||
var hostContext = regex[':host-context'].exec(match);
|
||||
|
||||
if (hostContext) {
|
||||
globalCss += match
|
||||
.replace(regex['::content'], '')
|
||||
.replace(regex[':host-context'], '$1 ' + name + '$2')
|
||||
.replace(/ +/g, ' '); // excess whitespace
|
||||
} else {
|
||||
lightCss += match
|
||||
.replace(regex[':host()'], name + '$1')
|
||||
.replace(regex[':host'], name)
|
||||
.replace(regex['::content'], name);
|
||||
}
|
||||
|
||||
return '';
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
template: template,
|
||||
lightCss: lightCss,
|
||||
globalCss: globalCss
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Some CSS rules, such as @keyframes
|
||||
* and @font-face don't work inside
|
||||
* scoped or shadow <style>. So we
|
||||
* have to put them into 'global'
|
||||
* <style> in the head of the
|
||||
* document.
|
||||
*
|
||||
* @private
|
||||
* @param {String} css
|
||||
*/
|
||||
function injectGlobalCss(css) {
|
||||
if (!css) {return;}
|
||||
var style = document.createElement('style');
|
||||
style.innerHTML = css.trim();
|
||||
headReady().then(function() {
|
||||
document.head.appendChild(style);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resolves a promise once document.head is ready.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function headReady() {
|
||||
return new Promise(function(resolve) {
|
||||
if (document.head) { return resolve(); }
|
||||
window.addEventListener('load', function fn() {
|
||||
window.removeEventListener('load', fn);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The Gecko platform doesn't yet have
|
||||
* `::content` or `:host`, selectors,
|
||||
* without these we are unable to style
|
||||
* user-content in the light-dom from
|
||||
* within our shadow-dom style-sheet.
|
||||
*
|
||||
* To workaround this, we clone the <style>
|
||||
* node into the root of the component,
|
||||
* so our selectors are able to target
|
||||
* light-dom content.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function injectLightCss(el) {
|
||||
if (hasShadowCSS) { return; }
|
||||
el.lightStyle = document.createElement('style');
|
||||
el.lightStyle.setAttribute('scoped', '');
|
||||
el.lightStyle.innerHTML = el.lightCss;
|
||||
el.appendChild(el.lightStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert hyphen separated
|
||||
* string to camel-case.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* toCamelCase('foo-bar'); //=> 'fooBar'
|
||||
*
|
||||
* @private
|
||||
* @param {Sring} string
|
||||
* @return {String}
|
||||
*/
|
||||
function toCamelCase(string) {
|
||||
return string.replace(/-(.)/g, function replacer(string, p1) {
|
||||
return p1.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Observer (singleton)
|
||||
*
|
||||
* @type {MutationObserver|undefined}
|
||||
*/
|
||||
var dirObserver;
|
||||
|
||||
/**
|
||||
* Observes the document `dir` (direction)
|
||||
* attribute and dispatches a global event
|
||||
* when it changes.
|
||||
*
|
||||
* Components can listen to this event and
|
||||
* make internal changes if need be.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function addDirObserver() {
|
||||
if (dirObserver) { return; }
|
||||
|
||||
dirObserver = new MutationObserver(onChanged);
|
||||
dirObserver.observe(document.documentElement, {
|
||||
attributeFilter: ['dir'],
|
||||
attributes: true
|
||||
});
|
||||
|
||||
function onChanged(mutations) {
|
||||
document.dispatchEvent(new Event('dirchanged'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the values of all properties from
|
||||
* source object `target` to a target object `source`.
|
||||
* It will return the target object.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} target
|
||||
* @param {Object} source
|
||||
* @returns {Object}
|
||||
*/
|
||||
function mixin(target, source) {
|
||||
for (var key in source) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
});})(typeof define=='function'&&define.amd?define
|
||||
:(function(n,w){'use strict';return typeof module=='object'?function(c){
|
||||
c(require,exports,module);}:function(c){var m={exports:{}};c(function(n){
|
||||
return w[n];},m.exports,m);w[n]=m.exports;};})('gaia-component',this));
|
||||
16
gaia/distros/spark/apps/customizer-launcher/components/gaia-fonts/bower.json
Executable file
16
gaia/distros/spark/apps/customizer-launcher/components/gaia-fonts/bower.json
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "gaia-fonts",
|
||||
"version": "0.2.1",
|
||||
"authors": [
|
||||
"Wilson Page <wilsonpage@me.com>"
|
||||
],
|
||||
"main": "style.css",
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
54
gaia/distros/spark/apps/customizer-launcher/components/gaia-fonts/style.css
Executable file
54
gaia/distros/spark/apps/customizer-launcher/components/gaia-fonts/style.css
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
|
||||
@font-face {
|
||||
font-family: "FiraSans";
|
||||
src: url("fonts/FiraSans-Light.woff") format("woff");
|
||||
font-weight: 300; /* lighter */
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "FiraSans";
|
||||
src: url("fonts/FiraSans-LightItalic.woff") format("woff");
|
||||
font-style: italic;
|
||||
font-weight: 300; /* lighter */
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "FiraSans";
|
||||
src: url("fonts/FiraSans-Regular.woff") format("woff");
|
||||
font-style: normal;
|
||||
font-weight: normal; /* 400 */
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "FiraSans";
|
||||
src: url("fonts/FiraSans-RegularItalic.woff") format("woff");
|
||||
font-style: italic;
|
||||
font-weight: normal; /* 400 */
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "FiraSans";
|
||||
src: url("fonts/FiraSans-Medium.woff") format("woff");
|
||||
font-style: italic;
|
||||
font-weight: bold; /* 700 */
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "FiraSans";
|
||||
src: url("fonts/FiraSans-MediumItalic.woff") format("woff");
|
||||
font-style: italic;
|
||||
font-weight: bold; /* 700 */
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "FiraSans";
|
||||
src: url("fonts/FiraSans-Bold.woff") format("woff");
|
||||
font-weight: 800; /* bolder */
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: "FiraSans";
|
||||
src: url("fonts/FiraSans-BoldItalic.woff") format("woff");
|
||||
font-style: italic;
|
||||
font-weight: 800; /* bolder */
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "gaia-header",
|
||||
"version": "0.8.1",
|
||||
"homepage": "https://github.com/gaia-components/gaia-header",
|
||||
"authors": [
|
||||
"Wilson Page <wilsonpage@me.com>"
|
||||
],
|
||||
"main": "gaia-header.js",
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"!.jshintrc",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"index.html",
|
||||
"package.json",
|
||||
"README.md"
|
||||
],
|
||||
"dependencies": {
|
||||
"gaia-icons": "gaia-components/gaia-icons#~0.7.11",
|
||||
"gaia-component": "gaia-components/gaia-component#~0.3.0",
|
||||
"font-fit": "gaia-components/font-fit#~0.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gaia-theme": "gaia-components/gaia-theme",
|
||||
"gaia-fonts": "gaia-components/gaia-fonts",
|
||||
"base": "gaia-components/base"
|
||||
}
|
||||
}
|
||||
1580
gaia/distros/spark/apps/customizer-launcher/components/gaia-header/dist/gaia-header.js
vendored
Executable file
1580
gaia/distros/spark/apps/customizer-launcher/components/gaia-header/dist/gaia-header.js
vendored
Executable file
File diff suppressed because it is too large
Load diff
1015
gaia/distros/spark/apps/customizer-launcher/components/gaia-header/gaia-header.js
Executable file
1015
gaia/distros/spark/apps/customizer-launcher/components/gaia-header/gaia-header.js
Executable file
File diff suppressed because it is too large
Load diff
118
gaia/distros/spark/apps/customizer-launcher/components/gaia-icons/bin/report.js
Executable file
118
gaia/distros/spark/apps/customizer-launcher/components/gaia-icons/bin/report.js
Executable file
|
|
@ -0,0 +1,118 @@
|
|||
'use strict';
|
||||
|
||||
// Create a report about unused icons in a project.
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var exec = require('child_process').exec;
|
||||
|
||||
var optimist = require('optimist');
|
||||
|
||||
var cli = optimist
|
||||
.usage('Create a report about unused icons in a project.' + '\n' +
|
||||
'Usage: $0 path/to/your/project/');
|
||||
var projectDir = cli.argv._[0];
|
||||
|
||||
// No folder passed? Show help message then.
|
||||
if (!projectDir) {
|
||||
cli.showHelp();
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// Check if the directory exist.
|
||||
var stats = fs.lstatSync(projectDir);
|
||||
if (!stats.isDirectory()) {
|
||||
console.log('\x1b[31mPlease provide a valid folder.\x1b[0m\n');
|
||||
cli.showHelp();
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of all the icons in the font.
|
||||
* @returns {Array}
|
||||
*/
|
||||
function getIcons() {
|
||||
var icons = fs.readdirSync('./images/');
|
||||
|
||||
icons = icons.map(function(icon) {
|
||||
return path.basename(icon, '.svg');
|
||||
});
|
||||
|
||||
return icons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use a grep pattern to extract used icons from files.
|
||||
* @param {string} grep
|
||||
* @param {Function} callback
|
||||
*/
|
||||
function getUsedIcons(grep, callback) {
|
||||
exec(grep, function(err, stdout, stderr) {
|
||||
var usedIcons = stdout
|
||||
.trim()
|
||||
.split('\n')
|
||||
.map(function(icon) {
|
||||
// Take only the icon name.
|
||||
return icon.split(/["']/)[1];
|
||||
})
|
||||
.filter(function(icon) {
|
||||
// Remove non string items.
|
||||
return icon && icon.match(/^[a-z0-9-]+$/);
|
||||
});
|
||||
|
||||
callback(usedIcons);
|
||||
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of unused icons in a folder. The patterns of extraction are:
|
||||
* * data-icon="[^"]+"
|
||||
* * .dataset.icon ?= ?.+
|
||||
*/
|
||||
function getUnusedIcons() {
|
||||
var usedIcons = [];
|
||||
var length = 2;
|
||||
|
||||
var cb = function(icons) {
|
||||
usedIcons = usedIcons.concat(icons);
|
||||
length--;
|
||||
|
||||
if (length > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var allIcons = getIcons();
|
||||
var unusedIcons = [];
|
||||
|
||||
allIcons.forEach(function(icon) {
|
||||
if (usedIcons.indexOf(icon) === -1) {
|
||||
unusedIcons.push(icon);
|
||||
}
|
||||
});
|
||||
|
||||
outputUnusedIcons(allIcons, unusedIcons);
|
||||
};
|
||||
|
||||
getUsedIcons('grep -rhoP \'data-icon="[^"]+"\' ' + projectDir, cb);
|
||||
getUsedIcons('grep -rhoP \'.dataset.icon ?= ?.+\' ' + projectDir, cb);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the list of unused icons to the screen.
|
||||
* @param {Array.<string>} icons
|
||||
* @param {Array.<string>} unusedIcons
|
||||
*/
|
||||
function outputUnusedIcons(icons, unusedIcons) {
|
||||
console.log('\x1b[36mList of unused icons in %s (%d/%d):\x1b[0m',
|
||||
projectDir, unusedIcons.length, icons.length);
|
||||
|
||||
unusedIcons.forEach(function(icon) {
|
||||
console.log('* ' + icon);
|
||||
});
|
||||
}
|
||||
|
||||
getUnusedIcons();
|
||||
30
gaia/distros/spark/apps/customizer-launcher/components/gaia-icons/bower.json
Executable file
30
gaia/distros/spark/apps/customizer-launcher/components/gaia-icons/bower.json
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
{
|
||||
"name": "gaia-icons",
|
||||
"version": "0.7.12",
|
||||
"homepage": "https://github.com/wilsonpage/gaia-icons",
|
||||
"authors": [
|
||||
"Wilson Page <wilsonpage@me.com>"
|
||||
],
|
||||
"main": [
|
||||
"gaia-icons.js",
|
||||
"gaia-icons.css",
|
||||
"fonts/gaia-icons.ttf",
|
||||
"gaia-icons-embedded.css"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"!.jshintrc",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"templates",
|
||||
"images",
|
||||
"test",
|
||||
"tests",
|
||||
"index.html",
|
||||
"create-svg-icon-set-file.py",
|
||||
"Gruntfile.js",
|
||||
"README.md",
|
||||
"package.json"
|
||||
]
|
||||
}
|
||||
Binary file not shown.
File diff suppressed because one or more lines are too long
|
|
@ -0,0 +1,25 @@
|
|||
/* Generated by grunt-webfont */
|
||||
/* Based on https://github.com/endtwist/fontcustom/blob/master/lib/fontcustom/templates/fontcustom.css */
|
||||
|
||||
|
||||
@font-face {
|
||||
font-family: "gaia-icons";
|
||||
src: url("fonts/gaia-icons.ttf") format("truetype");
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
|
||||
[data-icon]:before,
|
||||
.ligature-icons {
|
||||
font-family: "gaia-icons";
|
||||
content: attr(data-icon);
|
||||
display: inline-block;
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
text-decoration: inherit;
|
||||
text-transform: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
font-size: 30px;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
(function(define){define(function(require,exports,module){
|
||||
/*jshint laxbreak:true*/
|
||||
|
||||
/**
|
||||
* Exports
|
||||
*/
|
||||
|
||||
var base = window.GAIA_ICONS_BASE_URL
|
||||
|| window.COMPONENTS_BASE_URL
|
||||
|| 'bower_components/';
|
||||
|
||||
if (!document.documentElement) {
|
||||
window.addEventListener('load', load);
|
||||
} else {
|
||||
load();
|
||||
}
|
||||
|
||||
function load() {
|
||||
if (isLoaded()) { return; }
|
||||
|
||||
var link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.type = 'text/css';
|
||||
link.href = base + 'gaia-icons/gaia-icons.css';
|
||||
document.head.appendChild(link);
|
||||
exports.loaded = true;
|
||||
}
|
||||
|
||||
function isLoaded() {
|
||||
return exports.loaded ||
|
||||
document.querySelector('link[href*=gaia-icons]') ||
|
||||
document.documentElement.classList.contains('gaia-icons-loaded');
|
||||
}
|
||||
|
||||
});})(typeof define=='function'&&define.amd?define
|
||||
:(function(n,w){return typeof module=='object'?function(c){
|
||||
c(require,exports,module);}:function(c){var m={exports:{}};c(function(n){
|
||||
return w[n];},m.exports,m);w[n]=m.exports;};})('gaia-icons',this));
|
||||
26
gaia/distros/spark/apps/customizer-launcher/components/gaia-list/bower.json
Executable file
26
gaia/distros/spark/apps/customizer-launcher/components/gaia-list/bower.json
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "gaia-list",
|
||||
"version": "0.1.7",
|
||||
"homepage": "https://github.com/gaia-components/gaia-list",
|
||||
"authors": [
|
||||
"Wilson Page <wilsonpage@me.com>"
|
||||
],
|
||||
"main": "gaia-list.js",
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
],
|
||||
"devDependencies": {
|
||||
"gaia-theme": "gaia-components/gaia-theme#dev",
|
||||
"gaia-fonts": "gaia-components/gaia-fonts#~0.2.1",
|
||||
"gaia-icons": "gaia-components/gaia-icons#~0.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"gaia-component": "gaia-components/gaia-component#~0.3.0",
|
||||
"base": "gaia-components/base"
|
||||
}
|
||||
}
|
||||
311
gaia/distros/spark/apps/customizer-launcher/components/gaia-list/gaia-list.js
Executable file
311
gaia/distros/spark/apps/customizer-launcher/components/gaia-list/gaia-list.js
Executable file
|
|
@ -0,0 +1,311 @@
|
|||
;(function(define){'use strict';define(function(require,exports,module){
|
||||
/*jshint esnext:true*/
|
||||
|
||||
/**
|
||||
* Dependencies
|
||||
*/
|
||||
|
||||
var component = require('gaia-component');
|
||||
|
||||
/**
|
||||
* Pointer event abstraction to make
|
||||
* it work for touch and mouse.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
var pointer = [
|
||||
{ down: 'touchstart', up: 'touchend', move: 'touchmove' },
|
||||
{ down: 'mousedown', up: 'mouseup', move: 'mousemove' }
|
||||
]['ontouchstart' in window ? 0 : 1];
|
||||
|
||||
/**
|
||||
* Exports
|
||||
*/
|
||||
|
||||
module.exports = component.register('gaia-list', {
|
||||
created: function() {
|
||||
this.setupShadowRoot();
|
||||
this.els = { inner: this.shadowRoot.querySelector('.inner') };
|
||||
this.addEventListener('click', this.onPointerDown);
|
||||
this.makeAccessible();
|
||||
},
|
||||
|
||||
makeAccessible: function() {
|
||||
[].forEach.call(this.children, (el) => { el.tabIndex = 0; });
|
||||
},
|
||||
|
||||
itemShouldRipple: function(el) {
|
||||
if (scrolling) { return false; }
|
||||
else if (el.classList.contains('ripple')) { return true; }
|
||||
else if (el.classList.contains('no-ripple')) { return false; }
|
||||
else if (this.classList.contains('ripple')){ return true; }
|
||||
else if (this.classList.contains('no-ripple')){ return false; }
|
||||
else if (el.tagName === 'A') { return true; }
|
||||
else { return false; }
|
||||
},
|
||||
|
||||
onPointerDown: function(e) {
|
||||
var point = e.touches ? e.changedTouches[0] : e;
|
||||
var target = this.getChild(e.target);
|
||||
|
||||
if (!this.itemShouldRipple(target)) { return; }
|
||||
|
||||
var pos = {
|
||||
list: this.getBoundingClientRect(),
|
||||
item: target.getBoundingClientRect()
|
||||
};
|
||||
|
||||
var els = {
|
||||
container: document.createElement('div'),
|
||||
ripple: document.createElement('div')
|
||||
};
|
||||
|
||||
els.container.className = 'ripple-container';
|
||||
els.container.style.left = (pos.item.left - pos.list.left) + 'px';
|
||||
els.container.style.top = (pos.item.top - pos.list.top) + 'px';
|
||||
els.container.style.width = pos.item.width + 'px';
|
||||
els.container.style.height = pos.item.height + 'px';
|
||||
|
||||
var offset = {
|
||||
x: point.clientX - pos.item.left,
|
||||
y: point.clientY - pos.item.top
|
||||
};
|
||||
|
||||
els.ripple.className = 'ripple';
|
||||
els.ripple.style.left = offset.x + 'px';
|
||||
els.ripple.style.top = offset.y + 'px';
|
||||
els.ripple.style.visibility = 'hidden';
|
||||
|
||||
els.container.appendChild(els.ripple);
|
||||
this.els.inner.appendChild(els.container);
|
||||
|
||||
// var reflow = els.ripple.offsetTop;
|
||||
var scale = pos.item.width / 1.2;
|
||||
var duration = 500;
|
||||
|
||||
setTimeout(function() {
|
||||
els.ripple.style.visibility = '';
|
||||
els.ripple.style.transform = 'scale(' + scale + ')';
|
||||
els.ripple.style.transitionDuration = duration + 'ms';
|
||||
setTimeout(function() {
|
||||
els.ripple.style.transitionDuration = '1000ms';
|
||||
els.ripple.style.opacity = '0';
|
||||
setTimeout(function() {
|
||||
els.container.remove();
|
||||
}, 1000);
|
||||
}, duration);
|
||||
});
|
||||
},
|
||||
|
||||
getChild: function(el) {
|
||||
return el && (el.parentNode === this ? el : this.getChild(el.parentNode));
|
||||
},
|
||||
|
||||
template: `
|
||||
<div class="inner">
|
||||
<content></content>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
||||
/** Reset
|
||||
---------------------------------------------------------*/
|
||||
|
||||
label { background: none; }
|
||||
|
||||
/** Host
|
||||
---------------------------------------------------------*/
|
||||
|
||||
:host {
|
||||
position: relative;
|
||||
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
/** Children
|
||||
---------------------------------------------------------*/
|
||||
|
||||
::content > *:not(style) {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
min-height: 60px;
|
||||
padding: 9px 16px;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
|
||||
font-size: 18px;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
background: transparent;
|
||||
align-items: center;
|
||||
list-style-type: none;
|
||||
|
||||
color:
|
||||
var(--text-color);
|
||||
}
|
||||
|
||||
::content > a {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/** Titles
|
||||
---------------------------------------------------------*/
|
||||
|
||||
::content h1,
|
||||
::content h2,
|
||||
::content h3,
|
||||
::content h4 {
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
/** Layout Helpers
|
||||
---------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* [flexbox]
|
||||
*
|
||||
* A helper attribute to allow users to
|
||||
* quickly define content as a flexbox.
|
||||
*/
|
||||
|
||||
::content [flexbox] {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
/**
|
||||
* [flex]
|
||||
*
|
||||
* A helper attribute to allow users to
|
||||
* quickly define area as flexible.
|
||||
*/
|
||||
|
||||
::content [flex] {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/** Border
|
||||
---------------------------------------------------------*/
|
||||
|
||||
::content > *:before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
left: 16px;
|
||||
right: 16px;
|
||||
height: 1px;
|
||||
|
||||
background:
|
||||
var(--border-color,
|
||||
var(--background-plus));
|
||||
}
|
||||
|
||||
/* Hack: Hide the line before the second element, since the first element is
|
||||
* the <style scoped> element */
|
||||
::content > :first-child:before,
|
||||
::content > style:first-child ~ :nth-child(2):before,
|
||||
::content > gaia-header:first-child ~ :nth-child(2):before,
|
||||
::content > gaia-sub-header:first-child ~ :nth-child(2):before,
|
||||
::content > h1:first-child ~ :nth-child(2):before,
|
||||
::content > h2:first-child ~ :nth-child(2):before,
|
||||
::content > .borderless:before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/** Titles
|
||||
---------------------------------------------------------*/
|
||||
|
||||
::content small,
|
||||
::content p {
|
||||
font-size: 0.7em;
|
||||
line-height: 1.35em;
|
||||
}
|
||||
|
||||
/** Icon
|
||||
---------------------------------------------------------*/
|
||||
|
||||
::content i {
|
||||
display: inline-block;
|
||||
width: 40px;
|
||||
}
|
||||
|
||||
::content i:before {
|
||||
display: block;
|
||||
}
|
||||
|
||||
::content > * > i:last-child {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the icons when the document is RTL mode
|
||||
*/
|
||||
|
||||
:host-context([dir=rtl]) ::content i:before {
|
||||
transform: scale(-1, 1);
|
||||
}
|
||||
|
||||
/** Divided
|
||||
---------------------------------------------------------*/
|
||||
|
||||
::content .divided {
|
||||
-moz-border-start: solid 1px;
|
||||
-moz-padding-start: 14px;
|
||||
|
||||
border-color:
|
||||
var(--border-color,
|
||||
var(--background-plus));
|
||||
}
|
||||
|
||||
/** Ripple Container
|
||||
---------------------------------------------------------*/
|
||||
|
||||
.ripple-container.ripple-container {
|
||||
box-sizing: content-box;
|
||||
position: absolute;
|
||||
z-index: -1;
|
||||
padding-top: 1px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/** Ripple
|
||||
---------------------------------------------------------*/
|
||||
|
||||
.ripple-container > .ripple {
|
||||
background: var(--border-color);
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 2px;
|
||||
height: 2px;
|
||||
margin: -1px;
|
||||
border-radius: 50%;
|
||||
transition-property: transform, opacity;
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
</style>
|
||||
`
|
||||
});
|
||||
|
||||
var scrolling = false;
|
||||
var scrollTimeout;
|
||||
|
||||
addEventListener('scroll', function() {
|
||||
scrolling = true;
|
||||
clearTimeout(scrollTimeout);
|
||||
scrollTimeout = setTimeout(function() {
|
||||
scrolling = false;
|
||||
}, 100);
|
||||
});
|
||||
|
||||
});})(typeof define=='function'&&define.amd?define
|
||||
:(function(n,w){'use strict';return typeof module=='object'?function(c){
|
||||
c(require,exports,module);}:function(c){var m={exports:{}};c(function(n){
|
||||
return w[n];},m.exports,m);w[n]=m.exports;};})('gaia-list',this));
|
||||
167
gaia/distros/spark/apps/customizer-launcher/components/gaia-list/index.html
Executable file
167
gaia/distros/spark/apps/customizer-launcher/components/gaia-list/index.html
Executable file
|
|
@ -0,0 +1,167 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title><gaia-list></title>
|
||||
<meta name="description" content="gaia-list example" />
|
||||
<link rel="stylesheet" type="text/css" href="bower_components/base/base.css">
|
||||
<link rel="stylesheet" type="text/css" href="bower_components/gaia-theme/gaia-theme.css">
|
||||
<link rel="stylesheet" type="text/css" href="bower_components/gaia-fonts/style.css">
|
||||
<link rel="stylesheet" type="text/css" href="bower_components/gaia-icons/style.css">
|
||||
<script src="bower_components/gaia-theme/lib/gaia-theme-selector.js"></script>
|
||||
<script src="bower_components/gaia-icons/gaia-icons.js"></script>
|
||||
<script src="bower_components/gaia-component/gaia-component.js"></script>
|
||||
<script src="gaia-list.js"></script>
|
||||
<style type="text/css">
|
||||
|
||||
body {
|
||||
padding: 16px;
|
||||
padding-top: 48px;
|
||||
}
|
||||
|
||||
gaia-list.settings [data-icon='forward'] {
|
||||
color: var(--text-color-minus);
|
||||
}
|
||||
|
||||
gaia-list .divided {
|
||||
border-left: solid 1px;
|
||||
padding-left: 14px;
|
||||
|
||||
border-color:
|
||||
var(--border-color,
|
||||
var(--background-plus));
|
||||
}
|
||||
|
||||
gaia-list.contacts .face {
|
||||
position: absolute;
|
||||
top: 50%; right: 16px;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
margin-top: -20px;
|
||||
border-radius: 50%;
|
||||
border: solid 2px;
|
||||
|
||||
border-color:
|
||||
var(--border-color,
|
||||
var(--background-minus));
|
||||
background: var(--background-plus);
|
||||
}
|
||||
|
||||
gaia-list.email > * {
|
||||
padding-left: 32px !important;
|
||||
}
|
||||
|
||||
gaia-list.email time {
|
||||
position: absolute;
|
||||
right: 0; top: 0;
|
||||
margin: 9px 16px;
|
||||
font-size: 0.7em;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
gaia-list.email p {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
gaia-list.email .unread:after {
|
||||
content: '';
|
||||
display: block;
|
||||
position: absolute;
|
||||
left: 16px; top: 50%;
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
margin-top: -4px;
|
||||
border-radius: 50%;
|
||||
|
||||
background:
|
||||
var(--highlight-color);
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body role="application">
|
||||
<gaia-theme-selector></gaia-theme-selector>
|
||||
<h1 class="large l-align-center l-mb-mega"><gaia-list></h1>
|
||||
<section>
|
||||
<gaia-list class="settings l-mb-mega">
|
||||
<a>
|
||||
<i data-icon="brightness"></i><h3>Menu 1</h3><i data-icon="forward-light"></i></a>
|
||||
<a><i data-icon="location"></i><h3>Menu 2</h3><i data-icon="forward-light"></i></a>
|
||||
<a><i data-icon="settings"></i>Menu 3<i data-icon="forward-light"></i></a>
|
||||
<li>
|
||||
<label class="l-flex l-flex-grow" for="wifi-switch">
|
||||
<i data-icon="wifi-4"></i><h3>Wifi</h3>
|
||||
</label>
|
||||
<gaia-switch id="wifi-switch" class="divided"></gaia-switch>
|
||||
</li>
|
||||
</gaia-list>
|
||||
|
||||
<gaia-list class="contacts l-mb-mega">
|
||||
<a>
|
||||
<div>
|
||||
<h3>Noah Green</h3>
|
||||
<p>Atsara Kitchens</p>
|
||||
<div class="face"></div>
|
||||
</div>
|
||||
</a>
|
||||
<a>
|
||||
<div>
|
||||
<h3>Will Grand</h3>
|
||||
<p>CBN Studio</p>
|
||||
<div class="face"></div>
|
||||
</div>
|
||||
</a>
|
||||
<a>
|
||||
<div>
|
||||
<h3>Carolina Grey</h3>
|
||||
<p>Mozilla</p>
|
||||
<div class="face"></div>
|
||||
</div>
|
||||
</a>
|
||||
</gaia-list>
|
||||
|
||||
<gaia-list class="email">
|
||||
<a class="unread">
|
||||
<div>
|
||||
<h3>Will Gordan</h3>
|
||||
<p>Send photos please!</p>
|
||||
<p>You're the best, thank you so much for all</p><time>11:30AM</time>
|
||||
</div>
|
||||
</a>
|
||||
<a class="unread">
|
||||
<div>
|
||||
<h3>Jennifer Liu</h3>
|
||||
<p>Road trip next weekend</p>
|
||||
<p>I've been wanting to visit that place for a</p>
|
||||
<time>11:30AM</time>
|
||||
</div>
|
||||
</a>
|
||||
<a>
|
||||
<div>
|
||||
<h3>Michael Stanford</h3>
|
||||
<p>You might like this or not?</p>
|
||||
<p>Great find, I definitely check with Brian if</p>
|
||||
<time>11:30AM</time>
|
||||
</div>
|
||||
</a>
|
||||
<a class="unread">
|
||||
<div>
|
||||
<h3>Jennifer Liu</h3>
|
||||
<p>Road trip next weekend</p>
|
||||
<p>I'vee been wanting to visit that place for a</p>
|
||||
<time>11:30AM</time>
|
||||
</div>
|
||||
</a>
|
||||
<a>
|
||||
<div>
|
||||
<h3>Michael Stanford</h3>
|
||||
<p>You might like this or not?</p>
|
||||
<p>Great find, I definitely check with Brian if</p>
|
||||
<time>11:30AM</time>
|
||||
</div>
|
||||
</a>
|
||||
</gaia-list>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
26
gaia/distros/spark/apps/customizer-launcher/components/gaia-theme/bower.json
Executable file
26
gaia/distros/spark/apps/customizer-launcher/components/gaia-theme/bower.json
Executable file
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "gaia-theme",
|
||||
"version": "0.4.5",
|
||||
"homepage": "https://github.com/gaia-components/gaia-theme",
|
||||
"authors": [
|
||||
"Wilson Page <wilsonpage@me.com>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"!.jshintrc",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests",
|
||||
"index.html",
|
||||
"README.md"
|
||||
],
|
||||
"devDependencies": {
|
||||
"gaia-icons": "gaia-components/gaia-icons",
|
||||
"gaia-header": "gaia-components/gaia-header",
|
||||
"gaia-button": "gaia-components/gaia-button",
|
||||
"gaia-switch": "gaia-components/gaia-switch",
|
||||
"gaia-checkbox": "gaia-components/gaia-checkbox"
|
||||
}
|
||||
}
|
||||
234
gaia/distros/spark/apps/customizer-launcher/components/gaia-theme/gaia-theme.css
Executable file
234
gaia/distros/spark/apps/customizer-launcher/components/gaia-theme/gaia-theme.css
Executable file
|
|
@ -0,0 +1,234 @@
|
|||
/*
|
||||
Gaia theme variables
|
||||
*/
|
||||
|
||||
|
||||
:root {
|
||||
|
||||
/** Grey Colors
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--color-alpha: #333333;
|
||||
--color-beta: #ffffff;
|
||||
--color-gamma: #4d4d4d;
|
||||
--color-delta: #5f5f5f;
|
||||
--color-epsilon: #858585;
|
||||
--color-zeta: #a6a6a6;
|
||||
--color-eta: #c7c7c7;
|
||||
--color-theta: #e7e7e7;
|
||||
--color-iota: #f4f4f4;
|
||||
|
||||
/** Brand Colors
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--color-darkblue: #00539f;
|
||||
--color-blue: #00caf2;
|
||||
--color-turquoise: #27c8c2;
|
||||
--color-darkorange: #e66000;
|
||||
--color-orange: #ff9500;
|
||||
--color-yellow: #ffcb00;
|
||||
--color-violet: #c40c84;
|
||||
|
||||
--color-warning: #fbbd3c;
|
||||
--color-destructive: #e2443a;
|
||||
--color-preffered: #00ba91;
|
||||
|
||||
/** Background
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--background: var(--color-beta);
|
||||
--background-plus: var(--color-theta);
|
||||
--background-minus: var(--color-zeta);
|
||||
|
||||
/** Borders
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--border-color: var(--color-theta);
|
||||
|
||||
/** Text Color
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--text-color: var(--color-gamma);
|
||||
--text-color-minus: var(--color-eta);
|
||||
|
||||
/** Button
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--button-background: var(--color-iota);
|
||||
|
||||
/** Links
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--link-color: var(--highlight-color);
|
||||
|
||||
/** Inputs
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--input-background: var(--color-beta);
|
||||
--input-color: var(--color-alpha);
|
||||
--input-clear-background: #909ca7;
|
||||
|
||||
/** Buttons
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--button-box-shadow:
|
||||
inset 0 -1px 0 #d8d8d8,
|
||||
inset 0 1px 0 #eeeeee;
|
||||
--button-box-shadow-active: var(--button-box-shadow);
|
||||
|
||||
/** Header
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--header-disabled-button-color: rgba(255,255,255,0.3);
|
||||
}
|
||||
|
||||
|
||||
.theme-productivity {
|
||||
|
||||
/** Brand Color
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--highlight-color: var(--color-orange);
|
||||
|
||||
/** Header
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--header-background: var(--highlight-color);
|
||||
--header-color: var(--color-beta);
|
||||
}
|
||||
|
||||
.theme-communications {
|
||||
|
||||
/** Brand Color
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--highlight-color: var(--color-turquoise);
|
||||
|
||||
/** Links
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--link-color: #177874;
|
||||
|
||||
/** Header
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--header-background: var(--highlight-color);
|
||||
--header-color: var(--color-beta);
|
||||
--header-icon-color: var(--color-beta);
|
||||
--header-button-color: var(--link-color);
|
||||
}
|
||||
|
||||
.theme-settings {
|
||||
|
||||
/** Background
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--background: var(--color-iota);
|
||||
--background-plus: var(--color-beta);
|
||||
--background-minus: var(--color-epsilon);
|
||||
--background-minus-minus: var(--color-zeta);
|
||||
|
||||
/** Highlight
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--highlight-color: var(--color-blue);
|
||||
|
||||
/** Borders
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--border-color: var(--color-theta);
|
||||
|
||||
/** Titles
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--title-color: var(--background-minus);
|
||||
|
||||
/** Buttons
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--button-background: var(--background-plus);
|
||||
|
||||
/** Switch
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--switch-background: var(--background-minus-minus);
|
||||
|
||||
/** Checkbox
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--checkbox-border-color: var(--background-minus-minus);
|
||||
|
||||
/** Header
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--header-color: var(--title-color);
|
||||
--header-background: var(--background);
|
||||
--header-button-color: var(--highlight-color);
|
||||
--header-disabled-button-color: var(--color-theta);
|
||||
--header-action-button-color: var(--title-color);
|
||||
}
|
||||
|
||||
.theme-media {
|
||||
|
||||
/** Highlight Color
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--highlight-color: var(--color-blue);
|
||||
|
||||
/** Background
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--background: var(--color-alpha);
|
||||
--background-plus: var(--color-gamma);
|
||||
--background-minus: #2B2B2B;
|
||||
--background-minus-minus: #1a1a1a;
|
||||
|
||||
/** Text Color
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--text-color: var(--color-beta);
|
||||
|
||||
/** Button
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--button-background: var(--background-plus);
|
||||
|
||||
/** Header
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--header-background: var(--background);
|
||||
--header-icon-color: var(--text-color);
|
||||
--header-button-color: var(--highlight-color);
|
||||
|
||||
/** Borders
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--border-color: var(--color-gamma);
|
||||
|
||||
/** Inputs
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--input-background: var(--background-plus);
|
||||
|
||||
/** Text Input
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--text-input-background: var(--background-minus);
|
||||
|
||||
/** Switch
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--switch-head-border-color: var(--background-minus-minus);
|
||||
--switch-background: var(--background-minus-minus);
|
||||
|
||||
/** Checkbox
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--checkbox-border-color: var(--background-minus-minus);
|
||||
|
||||
/** Buttons
|
||||
---------------------------------------------------------*/
|
||||
|
||||
--button-box-shadow: none;
|
||||
--button-box-shadow-active: none;
|
||||
}
|
||||
|
|
@ -0,0 +1,111 @@
|
|||
(function(define){'use strict';define(function(require,exports,module){
|
||||
/*jshint esnext:true*/
|
||||
|
||||
/**
|
||||
* Extend from the `HTMLElement` prototype
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
var proto = Object.create(HTMLElement.prototype);
|
||||
|
||||
proto.createdCallback = function() {
|
||||
this.createShadowRoot().innerHTML = template;
|
||||
|
||||
this.els = {
|
||||
themes: this.shadowRoot.querySelector('.themes'),
|
||||
rtl: this.shadowRoot.querySelector('.toggle-rtl')
|
||||
};
|
||||
|
||||
this.els.rtl.addEventListener('click', this.onRtlClick.bind(this));
|
||||
this.els.themes.addEventListener('click', this.onThemeClick.bind(this));
|
||||
this.styleHack();
|
||||
this.set(localStorage.theme || 'settings');
|
||||
};
|
||||
|
||||
proto.styleHack = function() {
|
||||
var style = this.shadowRoot.querySelector('style');
|
||||
style.setAttribute('scoped', '');
|
||||
this.appendChild(style.cloneNode(true));
|
||||
};
|
||||
|
||||
proto.onThemeClick = function(e) {
|
||||
var theme = e.target.value;
|
||||
if (theme) { this.set(theme); }
|
||||
};
|
||||
|
||||
proto.onRtlClick = function() {
|
||||
document.dir = this.els.rtl.checked ? 'rtl' : 'ltr';
|
||||
};
|
||||
|
||||
proto.set = function(theme) {
|
||||
var radio = this.shadowRoot.querySelector('[value="' + theme + '"]');
|
||||
document.body.classList.remove('theme-' + this.theme);
|
||||
document.body.classList.add('theme-' + theme);
|
||||
radio.checked = true;
|
||||
this.theme = theme;
|
||||
localStorage.theme = theme;
|
||||
};
|
||||
|
||||
var template = `
|
||||
<style>
|
||||
|
||||
* { margin: 0; padding: 0; }
|
||||
|
||||
gaia-theme-selector {
|
||||
position: fixed;
|
||||
top: 0; left: 0;
|
||||
z-index: 101;
|
||||
width: 100%;
|
||||
height: 30px;
|
||||
background: rgba(255,255,255,0.8);
|
||||
color: #000;
|
||||
font-size: 9px;
|
||||
text-align: center;
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,0.1);
|
||||
direction: ltr;
|
||||
}
|
||||
|
||||
form {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
form label {
|
||||
-moz-margin-start: 9px;
|
||||
}
|
||||
|
||||
form input {
|
||||
-moz-margin-end: 6px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.rtl {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<form>
|
||||
<label class="rtl"><input type="checkbox" class="toggle-rtl" />RTL</label>
|
||||
<span class="themes">
|
||||
<label><input type="radio" name="theme" value="productivity"/>Prod</label>
|
||||
<label><input type="radio" name="theme" value="communications"/>Comms</label>
|
||||
<label><input type="radio" name="theme" value="media"/>Media</label>
|
||||
<label><input type="radio" name="theme" value="settings"/>Settings</label>
|
||||
</span>
|
||||
</form>`;
|
||||
|
||||
document.registerElement('gaia-theme-selector', { prototype: proto });
|
||||
|
||||
});})((function(n,w){'use strict';return typeof define=='function'&&define.amd?
|
||||
define:typeof module=='object'?function(c){c(require,exports,module);}:
|
||||
function(c){var m={exports:{}},r=function(n){return w[n];};
|
||||
w[n]=c(r,m.exports,m)||m.exports;};})('gaia-theme-selector',this));
|
||||
Loading…
Reference in a new issue