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
|
|
@ -0,0 +1,12 @@
|
|||
'use strict';
|
||||
var padZeros = require('../utils/padzeros');
|
||||
|
||||
// As per [the "date" input element's
|
||||
// specification](http://dev.w3.org/html5/markup/input.date.html), this value
|
||||
// is formatted according to [RFC
|
||||
// 3339](http://tools.ietf.org/html/rfc3339#section-5.6).
|
||||
module.exports = function(dateObj) {
|
||||
return [dateObj.getFullYear(), dateObj.getMonth() + 1, dateObj.getDate()]
|
||||
.map(padZeros)
|
||||
.join('-');
|
||||
};
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
exports.date = require('./date');
|
||||
exports.time = require('./time');
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
'use strict';
|
||||
var padZeros = require('../utils/padzeros');
|
||||
|
||||
// As per [the "time" input element's
|
||||
// specification](http://dev.w3.org/html5/markup/input.time.html), this value
|
||||
// is formatted according to [RFC
|
||||
// 3339](http://tools.ietf.org/html/rfc3339#section-5.6).
|
||||
module.exports = function(dateObj) {
|
||||
return [dateObj.getHours(), dateObj.getMinutes(), dateObj.getSeconds()]
|
||||
.map(padZeros)
|
||||
.join(':');
|
||||
};
|
||||
72
gaia/tests/jsmarionette/plugins/marionette-plugin-forms/lib/index.js
Executable file
72
gaia/tests/jsmarionette/plugins/marionette-plugin-forms/lib/index.js
Executable file
|
|
@ -0,0 +1,72 @@
|
|||
'use strict';
|
||||
var formatters = require('./formatters');
|
||||
|
||||
function Forms(client) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill out one or more input elements (regardless of visibility)
|
||||
* @param {Element} elem The input element to change (when setting a single
|
||||
* value) or the parent node (when setting multiple
|
||||
* values).
|
||||
* @param {object} value The value to set (when setting a single value) or a
|
||||
* hash of form element names to corresponding values
|
||||
* (when setting multiple values)
|
||||
*/
|
||||
Forms.prototype.fill = function(elem, value, done) {
|
||||
elem.tagName(function(err, tagName) {
|
||||
if (tagName === 'form') {
|
||||
setValues(elem, value, done);
|
||||
} else {
|
||||
setValue(elem, value, done);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function setValue(elem, value, done) {
|
||||
elem.getAttribute('type', function(err, type) {
|
||||
if (err) {
|
||||
if (done) {
|
||||
done(err);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
type = type.trim().toLowerCase();
|
||||
|
||||
if (formatters.hasOwnProperty(type)) {
|
||||
value = formatters[type](value);
|
||||
}
|
||||
|
||||
elem.client.executeScript(function(elem, value) {
|
||||
elem.value = value;
|
||||
}, [elem, value], done);
|
||||
});
|
||||
}
|
||||
|
||||
function setValues(form, values, done) {
|
||||
var keys = Object.keys(values);
|
||||
var setCount = keys.length;
|
||||
var setKey = function() {
|
||||
setCount--;
|
||||
if (setCount === 0) {
|
||||
done && done();
|
||||
}
|
||||
};
|
||||
|
||||
keys.forEach(function(key) {
|
||||
form.findElement('[name="' + key + '"]', function(err, elem) {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
setValue(elem, values[key], setKey);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = function(client, options) {
|
||||
return new Forms(client);
|
||||
};
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
'use strict';
|
||||
module.exports = function(val) {
|
||||
val = String(val);
|
||||
while (val.length < 2) {
|
||||
val = '0' + val;
|
||||
}
|
||||
return val;
|
||||
};
|
||||
Loading…
Reference in a new issue