Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"trailing": true,
"white": false,
"indent": 2,
"quotmark": "single",
"quotmark": "double",

"maxparams": 3,
"maxparams": 5,
"maxdepth": 3,
"maxcomplexity": 10
}
51 changes: 51 additions & 0 deletions example/input-datetime-local.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Examples of polyformfill for input[type=datetime-local]</title>

<link rel="stylesheet" href="style.css">

<script src="../polyformfill.min.js"></script>
</head>
<body>

<form method="POST">

<p>
<label for="example-datetime-local-1">Datetime-local 1</label>
<input id="example-datetime-local-1" type="datetime-local" name="example-datetime-local">
</p>

<p>
<label for="example-datetime-local-2">Datetime-local 2</label>
<input id="example-datetime-local-2" type="datetime-local" name="example-datetime-local-2" value="1010-10-10T10:10:10.101">
</p>

<p>
<label for="example-datetime-local-3">Datetime-local 3</label>
<input id="example-datetime-local-3" type="datetime-local" name="example-datetime-local-3" value="1010-10-10T10:10:10" step="1">
</p>

<p>
<label for="example-datetime-local-4">Datetime-local 4</label>
<input id="example-datetime-local-4" type="datetime-local" name="example-datetime-local-4" step="3600">
</p>

<p>
<label for="example-datetime-local-5">Datetime-local 5</label>
<input id="example-datetime-local-5" type="datetime-local" name="example-datetime-local-5" step="any" value="1010-10-10T10:10:10.101">
</p>

<p>
<label for="example-datetime-local-6">Datetime-local 6</label>
<input id="example-datetime-local-6" type="datetime-local" name="example-datetime-local-6" step=".01" value="1010-10-10T10:10:10.10">
</p>

<p>
<button type="submit">Submit</button>
</p>
</form>

</body>
</html>
5 changes: 5 additions & 0 deletions example/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ input[type=datetime-local],
input[type=time] {
font-family: monospace;
}

input[type=datetime-local] {
width: 15em;
}

input:invalid {
border-color: red;
}
36 changes: 18 additions & 18 deletions example/test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
void function (window, document) {
'use strict';
(function (window, document) {
"use strict";

if (document.readyState === 'interactive' || document.readyState === 'complete') {
if ("interactive" === document.readyState || "complete" === document.readyState) {
init();
}
else {
document.addEventListener('DOMContentLoaded', init);
document.addEventListener("DOMContentLoaded", init);
}

function init() {
var input = document.getElementsByTagName('INPUT');
var input = document.getElementsByTagName("INPUT");

for (var i = 0; i < input.length; i++) {
console.log(
Expand All @@ -19,40 +19,40 @@ void function (window, document) {
);
}

document.getElementById('example-date-1-button').addEventListener('click', updateExampleDate1);
document.getElementById("example-date-1-button").addEventListener("click", updateExampleDate1);

document.getElementById('example-date-4').addEventListener('input', function() {
document.getElementById('example-date-4-output').value = this.value;
document.getElementById("example-date-4").addEventListener("input", function() {
document.getElementById("example-date-4-output").value = this.value;
});
document.getElementById('example-date-4-output').value = document.getElementById('example-date-4').value;
document.getElementById("example-date-4-output").value = document.getElementById("example-date-4").value;


}

function updateExampleDate1() {
var input = document.getElementById('example-date-1');
var input = document.getElementById("example-date-1");

input.focus();

input.dispatchEvent(window.crossBrowser_initKeyboardEvent('keydown', { key: 'Right', bubbles: true }));
input.dispatchEvent(window.crossBrowser_initKeyboardEvent('keydown', { key: 'Up', bubbles: true }));
input.dispatchEvent(window.crossBrowser_initKeyboardEvent("keydown", { key: "Right", bubbles: true }));
input.dispatchEvent(window.crossBrowser_initKeyboardEvent("keydown", { key: "Up", bubbles: true }));
}


/*window.addEventListener('blur', function(e) {
/*window.addEventListener("blur", function(e) {
console.log(e);
});
window.addEventListener('focus', function(e) {
window.addEventListener("focus", function(e) {
console.log(e);
});
window.addEventListener('focusin', function(e) {
window.addEventListener("focusin", function(e) {
console.log(e);
});
window.addEventListener('keydown', function(e) {
window.addEventListener("keydown", function(e) {
console.log(e);
});
window.addEventListener('keypress', function(e) {
window.addEventListener("keypress", function(e) {
console.log(e);
});*/

}(window, document);
}(window, document));
58 changes: 39 additions & 19 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
'use strict';
"use strict";

/* global require */

var gulp = require('gulp'),
concat = require('gulp-concat'),
preprocess = require('gulp-preprocess'),
rename = require('gulp-rename'),
replace = require('gulp-replace'),
sourcemaps = require('gulp-sourcemaps'),
uglify = require('gulp-uglify');
var gulp = require("gulp"),
concat = require("gulp-concat"),
preprocess = require("gulp-preprocess"),
rename = require("gulp-rename"),
replace = require("gulp-replace"),
sourcemaps = require("gulp-sourcemaps"),
uglify = require("gulp-uglify");

gulp.task('default', function () {
gulp.task("default", function () {
// place code for your default task here
});

gulp.task('compress', function () {
gulp.src(['src/polyformfill.js.prefix', 'src/**/base.js', 'src/**/*.js', 'src/polyformfill.js.suffix'])
.pipe(concat('polyformfill.js'))
.pipe(replace("'use strict';", ''))
gulp.task("compress", function () {
gulp.src(["src/polyformfill.js.prefix", "src/**/!(init).js", "src/init.js", "src/polyformfill.js.suffix"])
.pipe(concat("polyformfill.js"))
.pipe(replace('"use strict";', ""))
.pipe(preprocess({
context: {
FEATURES: {
Expand All @@ -37,13 +37,33 @@ gulp.task('compress', function () {
semicolons: false,
width: 120
},
compress: false,
preserveComments: 'some'
compress: {
sequences : false, // join consecutive statements with the “comma operator”
properties : false, // optimize property access: a["foo"] → a.foo
dead_code : true, // discard unreachable code
drop_debugger : true, // discard “debugger” statements
unsafe : false, // some unsafe optimizations (see below)
conditionals : false, // optimize if-s and conditional expressions
comparisons : false, // optimize comparisons
evaluate : false, // evaluate constant expressions
booleans : false, // optimize boolean expressions
loops : false, // optimize loops
unused : true, // drop unused variables/functions
hoist_funs : true, // hoist function declarations
hoist_vars : true, // hoist variable declarations
if_return : false, // optimize if-s followed by return/continue
join_vars : true, // join var declarations
cascade : false, // try to cascade `right` into `left` in sequences
side_effects : false, // drop side-effect-free statements
warnings : true, // warn about potentially dangerous optimizations/code
global_defs : {} // global definitions
},
preserveComments: "some"
}))
.pipe(gulp.dest('./'))
.pipe(gulp.dest("./"))
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(rename('polyformfill.min.js'))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./'));
.pipe(rename("polyformfill.min.js"))
.pipe(sourcemaps.write("./"))
.pipe(gulp.dest("./"));
});
72 changes: 36 additions & 36 deletions karma.conf-ci.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
"use strict";

/* global module, require, process */

Expand All @@ -7,87 +7,86 @@
* Karma configuration for Travis.
*/

var fs = require('fs');
var fs = require("fs");

module.exports = function(config) {

// Use ENV vars on Travis and sauce.json locally to get credentials
if (!process.env.SAUCE_USERNAME) {
if (!fs.existsSync('sauce.json')) {
console.log('Create a sauce.json with your credentials based on the sauce-sample.json file.');
if (!fs.existsSync("sauce.json")) {
console.log("Create a sauce.json with your credentials based on the sauce-sample.json file.");
process.exit(1);
} else {
process.env.SAUCE_USERNAME = require('./sauce').username;
process.env.SAUCE_ACCESS_KEY = require('./sauce').accessKey;
process.env.SAUCE_USERNAME = require("./sauce").username;
process.env.SAUCE_ACCESS_KEY = require("./sauce").accessKey;
}
}

// Browsers to run on Sauce Labs
var customLaunchers = {
sl_chrome: {
base: 'SauceLabs',
browserName: 'chrome',
version: '39',
base: "SauceLabs",
browserName: "chrome",
version: "39",
// Sweden uses ISO 8601 for date and time representation. And while chrome localizes date input elements using
// the browser language this makes testing easier.
chromeOptions: {
args: ['--lang=sv-SE']
args: ["--lang=sv-SE"]
},
platform: 'Windows 7'
platform: "Windows 7"
},
sl_firefox: {
base: 'SauceLabs',
browserName: 'firefox',
version: '33'
base: "SauceLabs",
browserName: "firefox",
version: "33"
},
sl_ie_9: {
base: 'SauceLabs',
browserName: 'internet explorer',
version: '9'
base: "SauceLabs",
browserName: "internet explorer",
version: "9"
},
sl_ie_10: {
base: 'SauceLabs',
browserName: 'internet explorer',
version: '10'
base: "SauceLabs",
browserName: "internet explorer",
version: "10"
},
sl_ie_11: {
base: 'SauceLabs',
browserName: 'internet explorer',
version: '11'
base: "SauceLabs",
browserName: "internet explorer",
version: "11"
}
};

config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
basePath: "",


// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
frameworks: ["jasmine"],


// list of files / patterns to load in the browser
files: [
'test/helpers/*.js',
'src/**/!(base).js',
'src/*/base.js',
'src/base.js',
'test/**/*.js',
"test/helpers/*.js",
"src/**/!(init).js",
"src/init.js",
"test/**/*.js",

{pattern: 'test/popup.html', watched: true, served: true, included: false}
{pattern: "test/popup.html", watched: true, served: true, included: false}
],


// test results reporter to use
// possible values: 'dots', 'progress'
// possible values: "dots", "progress"
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['dots', 'saucelabs', 'coverage', 'coveralls'],
reporters: ["dots", "saucelabs", "coverage", "coveralls"],

coverageReporter: {
type: 'lcov',
dir: 'coverage/'
type: "lcov",
dir: "coverage/"
},

// web server port
Expand All @@ -100,7 +99,8 @@ module.exports = function(config) {
logLevel: config.LOG_INFO,

sauceLabs: {
testName: 'polyformfill'
testName: "polyformfill",
takeScreenshots: false
},
captureTimeout: 120000,
customLaunchers: customLaunchers,
Expand Down
Loading