39 |
47 |
48 |
49 |
50 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # px-rangepicker [](https://travis-ci.org/PredixDev/px-rangepicker)
2 |
3 | ## Overview
4 |
5 | `Px-rangepicker` is a Predix UI component which provides an interface (using `px-datetime-range-panel`) for selecting two date/time values to create a date/time range.
6 |
7 | ## Usage
8 |
9 | ### Prerequisites
10 |
11 | 1. node.js
12 | 2. npm
13 | 3. bower
14 | 4. [webcomponents-lite.js polyfill](https://github.com/webcomponents/webcomponentsjs)
15 |
16 | Node, npm and bower are necessary to install the component and dependencies. webcomponents.js adds support for web components and custom elements to your application.
17 |
18 | ### Getting Started
19 |
20 | First, install the component via bower on the command line.
21 |
22 | ```
23 | bower install https://github.com/PredixDev/px-rangepicker.git --save
24 | ```
25 |
26 | Second, import the component to your application with the following tag in your head.
27 |
28 | ```html
29 |
30 | ```
31 |
32 | Finally, use the component in your application:
33 |
34 | ```html
35 |
36 | ```
37 |
38 | ### API and examples
39 |
40 | Read the full API and view the demo [here](https://predixdev.github.io/px-rangepicker).
41 |
42 | ## Local Development
43 |
44 | From the component's directory...
45 |
46 | ```
47 | $ npm install
48 | $ bower install
49 | $ gulp sass
50 | ```
51 |
52 | From the component's directory, to start a local server run:
53 |
54 | ```
55 | $ gulp serve
56 | ```
57 |
58 | Navigate to the root of that server (e.g. http://localhost:8080/) in a browser to open the API documentation page, with link to the "Demo" / working examples.
59 |
60 | ### LiveReload
61 |
62 | By default gulp serve is configured to enable LiveReload and will be watching for modifications in your root directory as well as `/css`.
63 |
64 |
65 |
66 |
67 |
68 |
69 | ### GE Coding Style Guide
70 | [GE JS Developer's Guide](https://github.com/GeneralElectric/javascript)
71 |
72 |
73 |
74 |
75 | ## Known Issues
76 |
77 | Please use [Github Issues](https://github.com/PredixDev/COMPONENT/issues) to submit any bugs you might find.
78 |
--------------------------------------------------------------------------------
/css/px-rangepicker-content-styles.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
22 |
23 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Predix UI px-rangepicker
23 |
24 |
28 |
59 |
60 |
63 |
64 |
65 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
80 |
85 |
86 |
89 |
90 |
91 |
94 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: required
2 | dist: trusty
3 | language: node_js
4 | node_js:
5 | - stable
6 | branches:
7 | except:
8 | - gh-pages
9 | addons:
10 | firefox: latest
11 | apt:
12 | sources:
13 | - google-chrome
14 | packages:
15 | - google-chrome-stable
16 | before_script:
17 | - yarn add polymer-cli
18 | - polymer install --variants
19 | script:
20 | - xvfb-run wct --skip-plugin sauce
21 | - if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then wct --plugin sauce --skip-plugin
22 | local; fi
23 | after_success:
24 | - if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then openssl aes-256-cbc -k "$DEPLOYSECRET"
25 | -in deploy.enc -out deploy_key -d; fi
26 | - cd $TRAVIS_BUILD_DIR/scripts
27 | - chmod 755 ghp.sh
28 | - "./ghp.sh"
29 | env:
30 | global:
31 | - secure: lm9QwabnaoJmEskfEGJqcnf5R/0XNZXcg8YREYAcNLRgXBZzhp4pXB2QBcqw4rRf9CT7qdN3J67bBUZl/Nf6JbyaCTalbxy8pxXPUM+T3Gj0jgNSDIFIz0UuO3qKVDZkcXAOLXjjLc+8q1GleiBoIAgsTpkDmdQ9I2d493hcFa1EQLl3BPb/T7jLw2jKR50+Kud4b5RW7rsajNSYzdJ63AxwyAyUECwGBQtRujQ3nXrUYBNyK+7ZxtlEpsUomYX2/Q08U2pjNHNgAClNN674RycoAf/RXcTnjWrExWqqhn4sls7+XE3Np1xvq7P9lT5FlyCD4qrnl6XlwAsPByKCwNd3UWRCGc6HholhiMxMPXkiFOp5/Z1G+NrQAi7JR4tNj0KTQXmXDZpFq2rKjk7yV2iN/2jD6vLCE0rCnyJuBIH+HT3RaUqrfo53J2bENKEc0ML2Z4Kx4S0OWOkzZ/MP0AEdUEAU2SMNzMNS/SpaUDtdYPLnzTvmV9neRurFgLUtzNkMVAZz24nMpSfwnGs4Mqszn8fUbBPgdoYF8Hd1hkgjowsx55mdCFcJGQDitpPDAaStuc7NH6EGMsia7jsoU74aC2QaNYJnpZLcnTlVbG4Es7wmtAGheXhPORRg9hM15hIfuW7meqOX0d9ZYjvVOItnUY0LVJ5UseGuTSKjHL0=
32 | - secure: JcPOeohxZ/KNmhDc57OPNqudXVMgg2jOEJippH6Yl8WOxlj54KvRRvnVQsJXWvVk7KwEDIPXeFybSnNnyb5eo/K1XSUYlKzauckXBzerp0HaDvdIlXcr6/dOWIg8q2uhYhAMhTtEs5EE6y+wewt0dz2ZDgY+iRGwUHpzDdZo4kW/gCpQJ8j/Fud5pz39BPRFHh0Qw6whFjzqWbQqmoIyP7cic+XmXwQGtVkCjhLLnbvh8Idgf8yuEQWkctLYX7uBMHSL3VPgRiq3KF+0iskmbRtffNUKhwTldEnSnpZ4ZqSRjOMPI1KcMAvGcR66MzejgctF6fpyrPRiTJWKIgc6n5D6xZXFZYVQOtaZWg0fwgPKsFLAvgVX99BVLuwuurn9WmhipMG6VEwl+DhAvq421jPOV48lV9Qd7+ExKa9yUd2l63m5ZiTzjzX3ExfyOnh9+om0m5+W0PIrdYD95ea5F94ehixueQDQNarLQwiUVHnXsCCdOJJjMvSwK75Jsiw+tdc0TiprQXdET/AvDRT9WXdqN7Z+3w1+QN8v6hqgHPAJBlptQ9WLwJbaPdg26r+aTh1zpqzfPVP2GNiJYUFOPDczqahBbTB+DTG6G9X7ge+DmGwupEE+HNAGPmrKoXqhOc+7BXjzDH1SB2i7Ei4Q8syu8VhWzXQ2eZrQxCBLhYc=
33 | - secure: 0fB9n07okFblPfxA8a6tAulVSXJYFDdFg8/ekwvwgQvWI/Drls5LwwsRqlcOQXOFlmXW1hosfJBEY5EkC7yVMdJ5is80GpY79DaYmszw8kN/z81t6Yp+nSE5AsZjkfbL0BfV1TYTOdarJkbGEM30KMhhr6+S/SA9EfCj3roZME/3qQ6rzgxHLlhJtDkdp5w+BGiEOvu2iFe9ZTVVsFKFreDbdASGwLuaQkesHZ3XPhrG+nt0sts5v3CUHBbSsB74o81HLGRBPbqJOR4QHBGyykGfyCqtNb5Zi3MLlPnHKoWgwhDhfpf6xDJmupYK0FFLMFpw7aVB2FIiZaG9faE+jET0mOhGwaTt77rP9FFJS3Xyi/ak8+XcDXI3E6uKG1lfHLaeim9lLZjnwJUYaDEOBD/ObL1AwOGxXxp6aFhVdlk2EtGWwdOQo9mbLc5FQGmJw4PLOTHEzeBv4neb3caPcQEhAhERMYAMUq+hi4nPiJZiRaA77t4x0DhRzswDuA23UYnZnxyvYpmkP3/RBouSa4r+agfX3CRnuqZ1XhHRJxxfVI9z0joXQBPZbBv135FhIs9y76auEbqqQhATz/b5TwuEhLHnwc3oNleuYi0PRbg8jkwKaFn3b1nk/9qj71i0alFhf7BYUKB1dygwABzP0hke68X494DosS8l4TW2bII=
34 | - secure: G8uu5WmhWqelki80YP2RasJEOpGI4XdeJxPZ2z/UZw0u4FqA0S1vrDY0tuWA3hVtkefuz6LvE5vvmG69ELia1SwjexuKTnr7LqzfwsEdws1SrE118CV2AehJNrRevev/S+0S6kgkxtyAEsKWynJckc/35Y/02SjQD8zWDPdw0CvudRHKUPunj17siuHb+XnbqshloFEJiV2LD7Qh3lmgDBMoVXvyYH1a/mYgmyaNswRFHvRFKl+7J5jABfRufqxsploW8kDGIR7Sgg2YrWRtGqIpNV7zYTGtle1nF/lv1FQpIq9iZb98gA9STQ4U8azHszNm30dYObkYvDeKkxMNjeaQbuKi6EkrMuWUio40wcok0rsVKUtFdAN+dIVfnQ41KU/5jmRbw75qpcu4kbiUrt0frTE7ZD7k00xKomCAhVWzTfL93F2wdW+K7tzuDthL+Z/nmmr0PorkXlJfNjpVNcVFkpQjmO7Z3DwFDzfOgEOgZNDgLfx6InzsCOagPGK4G3qG8AKM9yiLRIuqmb48MXMtXGiVemJvHx3H/4HOmCZ0z55feu2RC193P2my0jzZOkKGsNt+pB5U7NUm0plghZMy6GZQkNTgVBiArgt2K9n6WSL647psdpgYojTsn77B0OucmIJOlomdhJzfr62lK3Ar46ZZrDOOnaU1XXmtb+U=
35 |
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | * Copyright (c) 2018, General Electric
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | 'use strict';
19 | const path = require('path');
20 | const gulp = require('gulp');
21 | const pkg = require('./package.json');
22 | const $ = require('gulp-load-plugins')();
23 | const gulpSequence = require('gulp-sequence');
24 | const importOnce = require('node-sass-import-once');
25 | const stylemod = require('gulp-style-modules');
26 | const browserSync = require('browser-sync').create();
27 | const gulpif = require('gulp-if');
28 | const combiner = require('stream-combiner2');
29 | const bump = require('gulp-bump');
30 | const argv = require('yargs').argv;
31 | const exec = require('child_process').exec;
32 | const { ensureLicense } = require('ensure-px-license');
33 |
34 | const sassOptions = {
35 | importer: importOnce,
36 | importOnce: {
37 | index: true,
38 | bower: true
39 | }
40 | };
41 |
42 | gulp.task('clean', function() {
43 | return gulp.src(['.tmp', 'css'], { read: false })
44 | .pipe($.clean());
45 | });
46 |
47 | function handleError(err) {
48 | console.log(err.toString());
49 | this.emit('end');
50 | }
51 |
52 | function buildCSS() {
53 | return combiner.obj([
54 | $.sass(sassOptions),
55 | $.autoprefixer({
56 | browsers: ['last 2 versions'],
57 | cascade: false,
58 | flexbox: false
59 | }),
60 | gulpif(!argv.debug, $.cssmin())
61 | ]).on('error', handleError);
62 | }
63 |
64 | gulp.task('sass', function() {
65 | return gulp.src(['./sass/*.scss'])
66 | .pipe(buildCSS())
67 | .pipe(stylemod({
68 | moduleId(file) {
69 | return path.basename(file.path, path.extname(file.path)) + '-styles';
70 | }
71 | }))
72 | .pipe(ensureLicense())
73 | .pipe(gulp.dest('css'))
74 | .pipe(browserSync.stream({ match: 'css/*.html' }));
75 | });
76 |
77 | gulp.task('watch', function() {
78 | gulp.watch(['sass/*.scss'], ['sass']);
79 | });
80 |
81 | gulp.task('serve', function() {
82 | browserSync.init({
83 | port: 8080,
84 | notify: false,
85 | reloadOnRestart: true,
86 | logPrefix: `${pkg.name}`,
87 | https: false,
88 | server: ['./', 'bower_components'],
89 | });
90 |
91 | gulp.watch(['css/*-styles.html', '*.html', '*.js', 'demo/*.html']).on('change', browserSync.reload);
92 | gulp.watch(['sass/*.scss'], ['sass']);
93 | });
94 |
95 | gulp.task('bump:patch', function() {
96 | gulp.src(['./bower.json', './package.json'])
97 | .pipe(bump({ type: 'patch' }))
98 | .pipe(gulp.dest('./'));
99 | });
100 |
101 | gulp.task('bump:minor', function() {
102 | gulp.src(['./bower.json', './package.json'])
103 | .pipe(bump({ type: 'minor' }))
104 | .pipe(gulp.dest('./'));
105 | });
106 |
107 | gulp.task('bump:major', function() {
108 | gulp.src(['./bower.json', './package.json'])
109 | .pipe(bump({ type: 'major' }))
110 | .pipe(gulp.dest('./'));
111 | });
112 |
113 | gulp.task('license', function() {
114 | return gulp.src(['./**/*.{html,js,css,scss}', '!./node_modules/**/*', '!./bower_components?(-1.x)/**/*'])
115 | .pipe(ensureLicense())
116 | .pipe(gulp.dest('.'));
117 | });
118 |
119 | gulp.task('default', function(callback) {
120 | gulpSequence('clean', 'sass', 'generate-api', 'license')(callback);
121 | });
122 |
123 | /**
124 | * Special task for Polymer component repos. Analyzes the component source code
125 | * and generates documentation in `[component-name]-api.json`.
126 | */
127 | gulp.task('generate-api', function (cb) {
128 | exec(`node_modules/.bin/polymer analyze ${pkg.name}.html > ${pkg.name}-api.json`, function(err, stdout, stderr) {
129 | console.log(stdout);
130 | console.log(stderr);
131 | cb(err);
132 | });
133 | });
134 |
--------------------------------------------------------------------------------
/demo-simple.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | px-range-picker Demo
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
48 |
49 |
53 |
54 |
58 |
59 |
63 |
64 |
68 |
69 |
74 |
75 |
76 |
77 |
78 |
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/scripts/ghp.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Exit with nonzero exit code if anything fails
4 | set -e
5 |
6 | # ------------------------------------------------------------------------------
7 | # CONFIGURE SCRIPT
8 | # ------------------------------------------------------------------------------
9 |
10 | # Set our source branch (where we'll build from) and our target branch (where we
11 | # want to send the build page to)
12 | SOURCE_BRANCH="master"
13 | TARGET_BRANCH="gh-pages"
14 | REPO=`git config remote.origin.url`
15 |
16 | # Prep git credentials
17 | GIT_USER_NAME="Travis CI"
18 | GIT_USER_EMAIL="PredixtravisCI@ge.com"
19 | GIT_COMMIT_MESSAGE="[Travis] Rebuild documentation for Github Pages"
20 |
21 | # Check if we should run a deploy, or if we should skip it. Only commits to master
22 | # should trigger a build. Pull requests and commits to features branches should not.
23 | if [ "$TRAVIS_PULL_REQUEST" != "false" -o "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]; then
24 | echo "Skipping deploy; just doing a build."
25 | exit 0
26 | fi
27 |
28 | # ------------------------------------------------------------------------------
29 | # PREPARE FILESYSTEM
30 | # ------------------------------------------------------------------------------
31 |
32 | cd $TRAVIS_BUILD_DIR
33 |
34 | # Find out our repo name from the bower file
35 | REPO_NAME=$(grep "name" bower.json | sed 's/"name": "//' | sed 's/",//')
36 | echo "repo name is ${REPO_NAME}"
37 |
38 | #delete all the files!
39 | rm -rf node_modules
40 | rm -rf bower_components
41 | rm -rf css
42 | rm -rf sass
43 | rm -rf scripts
44 | rm -rf test
45 | rm -f *.html
46 | rm -f *.json
47 | rm -f *.enc
48 | rm -f *.js
49 | rm -f *.png
50 | rm -f *.lock
51 | rm -f *.ico
52 | rm -f *.md
53 | rm -f *.pdf
54 | yes | rm .travis.yml
55 | rm -f .bowerrc
56 | rm -f .editorconfig
57 | rm -rf .github
58 | rm -f .gitignore
59 | rm -f .jshintrc
60 |
61 | # force installation of bower packages at the root
62 | echo "{ \"directory\": \".\" }" > .bowerrc
63 |
64 | #make sure the deploy key isn't saved into the git repo
65 | echo "deploy_key" > .gitignore
66 |
67 | # add the redirect.
68 | # Note: We are not overwriting the component's documentation `index.html` file
69 | # here, we are making sure that http://url/px-something/ redirects to
70 | # http://url/px-something/px-something/, where the demo page is installed
71 | meta_temp=''
72 | echo ${meta_temp/'COMPONENT_NAME'/$REPO_NAME} > index.html
73 |
74 | # ------------------------------------------------------------------------------
75 | # BOWER
76 | # ------------------------------------------------------------------------------
77 | #
78 | #for some reason, bower isn't available here, so, install it globally, so it doesn't end up as another folder.
79 | npm install bower -g
80 | bower cache clean
81 | # Install the repo and the dark-theme.
82 | bower install ${REPO_NAME} px-dark-theme px-dark-demo-theme --force-latest
83 |
84 | #copy the bower file into our root
85 | yes | cp ${REPO_NAME}/bower.json bower.json
86 |
87 | #and run install
88 | bower install
89 |
90 | # ------------------------------------------------------------------------------
91 | # BUILD PROJECT
92 | # ------------------------------------------------------------------------------
93 |
94 | # Go into the component folder we've just installed from bower
95 | # cd ${REPO_NAME}
96 |
97 | # ------------------------------------------------------------------------------
98 | # SW-PRECACHE
99 | # ------------------------------------------------------------------------------
100 |
101 | # npm install sw-precache
102 | # sw-precache --root='.' --static-file-globs='**/*.{js,html,css,png,jpg,gif,svg,eot,ttf,woff}'
103 |
104 | # ------------------------------------------------------------------------------
105 | # GIT PUSH TO REMOTES
106 | # ------------------------------------------------------------------------------
107 |
108 | # Remember to exit out of the component before we do any git stuff
109 | # cd ../
110 |
111 | # Do the git stuff
112 |
113 | # checkout a new orphan
114 | git checkout --orphan $TARGET_BRANCH
115 |
116 | git add -A . > /dev/null
117 | echo "git add done"
118 | git commit -m "${GIT_COMMIT_MESSAGE}" --quiet
119 | echo "git commit done"
120 |
121 | # Set git credentials (defined in settings above)
122 | git config user.name ${GIT_USER_NAME}
123 | git config user.email ${GIT_USER_EMAIL}
124 |
125 |
126 | # We get the URL in this format: "https://github.com/PredixDev/px-something"
127 | # First, we need to replace https-style remote URL with a SSH-style remote
128 | # URL we can push to below
129 | SSH_GIT=${REPO/https:\/\/github.com\//git@github.com:}
130 |
131 | # Now, the URL is in this format: "git@github.com:PredixDev/px-something"
132 | # Next, replace `PredixDev` Github organization with `predix-ui` so configure
133 | # the correct remote to push to.
134 | # The resulting URL will be: "git@github.com:predix-ui/px-something"
135 | SSH_GIT_PREDIXUI=${SSH_GIT/:PredixDev\//:predix-ui\/}
136 |
137 | # Prepare ssh key, which we'll use to authenticate for SSH-push deploy
138 | eval `ssh-agent -s`
139 | # ... and change permissions for deploy key
140 | chmod 0400 $TRAVIS_BUILD_DIR/deploy_key
141 |
142 | # Push to predix-ui/repo `gh-pages` branch (force to override out-of-date refs)
143 | ssh-add $TRAVIS_BUILD_DIR/deploy_key
144 | git push $SSH_GIT_PREDIXUI $TARGET_BRANCH --force
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to Predix UI
Hi,
Want to contribute your suggestions to Predix UI? **Here's how you can help.**
Please follow the below steps carefully, so your suggestions will be clear and developers can make effective fixes.
## Using the GitHub issue tracker
The GitHub issue tracker is the preferred channel for [bug reports](#bug-reports), [features requests](#feature-requests)
and [submitting pull requests](#pull-requests), so please respect the following
restrictions:
* Please **do not** use the GitHub issue tracker for personal support requests. Stack
Overflow ([`predix ui`](https://stackoverflow.com/questions/tagged/predix-ui) tag), or [Predix.io](https://predix.io) are better places to get help.
* Please **do not** derail or troll issues. Keep the discussion on topic and
respect the opinions of others.
* Please **do not** post vague comments like "+1" or ":thumbsup:".
Use [GitHub's "reactions" feature](https://github.com/blog/2119-add-reactions-to-pull-requests-issues-and-comments). We reserve the right to delete comments.
## Issues and labels
Our bug tracker utilizes several labels to help organize and identify issues. Here's what they represent and how we use them:
- `browser bug` - Issues that are reported to us, but are actually the result of a browser-specific bug. These issues are diagnosed with reduced test cases and result in an issue opened on that browser's own bug tracker.
- `confirmed` - Issues that have been confirmed with a reduced test case and identify a bug in a Predix UI component.
- `css` - Issues stemming from our compiled CSS or source Sass files.
- `docs` - Issues for improving or updating our documentation.
- `examples` - Issues involving the example templates included in our docs.
- `enhancement` - Issues asking for a new feature to be added, or an existing one to be extended or modified. New features require a minor version bump (e.g., `v3.0.0` to `v3.1.0`).
- `grunt` - Issues with our included JavaScript-based Gruntfile, which is used to run all our tests, concatenate and compile source files, and more.
- `help wanted` - Issues that we need or would like the community to help us resolve.
- `js` - Issues stemming from our compiled or source JavaScript files.
- `meta` - Issues with the project itself or our GitHub repository.
## Bug reports
A bug is a _demonstrable problem_ caused by the code in the repository.
Good bug reports are extremely helpful.
Guidelines for bug reports:
0. **Validate and lint your code**; [validate your HTML](http://html5.validator.nu)
and [lint your HTML](http://www.dirtymarkup.com/) to ensure your
problem isn't caused by a simple error in your own code.
1. **Use the GitHub issue search**; check if the issue has already been
reported.
2. **Check if the issue has been fixed**; try to reproduce the issue by using the
latest `master` or development branch in the repository.
3. **Isolate the problem**; ideally create a [reduced test
case](https://css-tricks.com/reduced-test-cases/) and a live example using [CodePen](http://codepen.io/mdwragg/pen/LNwmpB) or [jsfiddle](https://jsfiddle.net/Lqmcwhw0/3/).
A good bug report shouldn't require others to get more information. Please be as detailed as possible in your report. What is your environment? What steps will reproduce the issue? What browser(s) and OS experience the problem? Do other browsers show the bug differently? What would you expect for the outcome? Such details will help people fix potential bugs.
Example:
> Short and descriptive example bug report title
>
> A summary of the issue and the browser/OS environment in which it occurs. If
> suitable, include the steps required to reproduce the bug.
>
> 1. This is the first step
> 2. This is the second step
> 3. Further steps, etc.
>
> `` - a link to the reduced test case
>
> Any other information relevant to the bug report. This might include the lines of code that you have identified as
> causing the bug, and potential solutions (and your opinions on their
> merits).
## Feature Requests
Feature requests are welcome, but before opening one, determine if your idea suits the scope and aims of Predix UI. *You* need to make a strong case and convince the Predix UI team to adopt your feature. Please provide as much detail and context as possible.
## Pull Requests
Your pull requests�patches, improvements, and new features�are a big help. The requests should be focused and avoid unrelated commits.
**Please ask** before making a significant pull request (e.g., implementing features, refactoring code, or porting to a different language) that Predix UI developers might not merge into the component.
Please follow the [coding guidelines](#code-guidelines) used throughout the project (indentation, accurate comments, etc.) and any other requirements (such as test coverage).
**Do not edit any of the CSS files directly!** The files are automatically generated. You should edit the source files in [`sass/`] instead.
**Do not edit the `gh-pages` branch.** That branch is generated from the documentation source files and is managed separately by the Predix UI team.
Please use the following process to have your work considered for the project:
1. [Fork](https://help.github.com/fork-a-repo/) the component.
2. Create a new topic branch (off the main project development branch) to
contain your feature, change, or fix:
```
bash
git checkout -b
```
3. Commit your changes in logical chunks. Please adhere to these [git commit message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) or your code is unlikely to be merged into the main project. Use Git's [interactive rebase](https://help.github.com/articles/interactive-rebase) feature to tidy up your commits before making them public.
4. Locally merge (or rebase) the latest commits into your branch:
```
bash
git pull [--rebase] origin master
```
5. Push your topic branch up to your fork:
```
bash
git push origin
```
6. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) with a clear title and description against the `master` branch.
## Code guidelines
### HTML
[Adhere to the Code Guide.](http://codeguide.co/#html)
- Use tags and elements appropriate for an HTML5 doctype (e.g., self-closing tags).
- Use [WAI-ARIA](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA) attributes in documentation examples to promote accessibility.
### CSS
[Adhere to the Code Guide.](http://codeguide.co/#css)
- When feasible, default color palettes should comply with [WCAG color contrast guidelines](http://www.w3.org/TR/WCAG20/#visual-audio-contrast).
- Except in rare cases, don't remove default `:focus` styles (via e.g. `outline: none;`) without providing alternative styles. See [this A11Y Project post](http://a11yproject.com/posts/never-remove-css-outlines/) for more details.
### JS
- 2 spaces (no tabs)
- "Attractive"
- no errors / warnings
--------------------------------------------------------------------------------
/px-rangepicker-content.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
28 |
29 |
30 |
31 |
32 |
41 |
62 |
63 |
64 |
65 |
66 |
67 |
227 |
--------------------------------------------------------------------------------
/HISTORY.md:
--------------------------------------------------------------------------------
1 | v3.5.2
2 | ==================
3 | * Added ability to hoist timezone dropdown
4 |
5 | v3.5.1
6 | ==================
7 | * Fixed showbuttons bug
8 | * Split sass into two files to fix layout bugs
9 | * fixed versioning
10 |
11 | V3.5.0
12 | ==================
13 | * added `fullWidth` to layout fields using css-grid
14 |
15 | v3.4.0
16 | ==================
17 | * Broke components up so iron-dropdown content is in a separate component, px-rangepicker-content
18 | * Added px-overlay-content to hoist px-rangepicker-content up the dom
19 | * Added hoist option, defaulted to false
20 | * Added containerType option to specify which container it should hoist to
21 |
22 | V3.3.5
23 | ==================
24 | * updated tests
25 |
26 | V3.3.4
27 | ==================
28 | * updated sass to add more flexibility for position the fields
29 |
30 | V3.3.3
31 | ==================
32 | * fixed polymer 1 bug with calendar changing color on invalid
33 |
34 | V3.3.2
35 | ==================
36 | * visually represent the range-field invalid state in the ranpe-panel
37 |
38 | V3.3.1
39 | ==================
40 | * reflected the range-field validation state to the `isValid` prop
41 |
42 | V3.3.0
43 | ==================
44 | * added `scrollAction` property to control page scrolling when panel is open
45 |
46 | V3.2.2
47 | ==================
48 | * fixed panel position bug
49 |
50 | V3.2.1
51 | ==================
52 | * cleaned up api and exposed the `required` property
53 |
54 | V3.2.0
55 | ==================
56 | * added ability to display title above the fields through the `showFieldTitles` property
57 |
58 | v3.1.3
59 | ==================
60 | * Updated to newest px-datetime-common behavior versions
61 |
62 | v3.1.2
63 | ==================
64 | * added `sudo:required` to travis
65 |
66 | v3.1.1
67 | ==================
68 | * prevent `_processClosed()` from running when `opened` is instantiated
69 |
70 | v3.1.0
71 | ==================
72 | * exposed `hideIcon` property
73 |
74 | v3.0.1
75 | ==================
76 | * add links in docs
77 |
78 | v3.0.0
79 | ==================
80 | * Polymer 1.X/2.X hybrid support
81 | * range property has been deleted, please use `fromMoment` and `toMoment` for controlling the range. the px-datetime-range-submitted event still exists when a new range is applied.
82 | * `fromMoment` and `toMoment` can be null to have an empty field
83 |
84 | v2.1.2
85 | ==================
86 | * add device flags
87 |
88 | v2.1.1
89 | ==================
90 | * updated css variable documentation
91 |
92 | v2.1.0
93 | ==================
94 | * added `hideValidationMessages` property
95 |
96 | v2.0.4
97 | ==================
98 | * add min and max date support
99 |
100 | v2.0.3
101 | ==================
102 | * expose allow-wrap for mobile (#44)
103 |
104 | v2.0.2
105 | ==================
106 | * Fix comment for analyzer
107 |
108 | v2.0.1
109 | ==================
110 | * runtime theming for demo
111 |
112 | v2.0.0
113 | ==================
114 | * component redesign
115 | * combined -predix and -sketch sass files
116 | * update dependencies for design refresh
117 | * make showButtons false by default
118 |
119 | v1.4.0
120 | ==================
121 | * added localization through resources, language, formats and Px.moment.changeLocale()
122 |
123 | v1.3.10
124 | ==================
125 | * converted time zone property to typeahead
126 |
127 | v1.3.9
128 | ==================
129 | * add Event Fired information to demo and update documentation
130 |
131 | v1.3.8
132 | ==================
133 | * added styling section to API documentation
134 |
135 | v1.3.7
136 | ==================
137 | * fixed typo in component description
138 |
139 | v1.3.6
140 | ==================
141 | * Moved theming style includes and updated ghp.sh
142 | * updated api for new colors
143 |
144 | v1.3.5
145 | ==================
146 | * added index-dark-theme.html
147 | * Update to px-demo
148 | * removed demosass
149 | * Updated to cool grays
150 |
151 | v1.3.4
152 | ==================
153 | * Update colors design to pick up new colors
154 |
155 | v1.3.3
156 | ==================
157 | * changing ghp.sh to account for Alpha releases
158 |
159 | v1.3.2
160 | ==================
161 | * changed overflow on demo so panel overlaps
162 |
163 | v1.3.1
164 | ==================
165 | * Update missed design dependencies
166 |
167 | v1.3.0
168 | ==================
169 | * Updated dependencies
170 |
171 | v1.2.15
172 | ==================
173 | * changing browser in wct testing from safari 8 to safari 10 on elcapitan
174 |
175 | v1.2.14
176 | ==================
177 | * updating slider dependency
178 |
179 | v1.2.13
180 | ==================
181 | * changing all devDeps to ^
182 |
183 | v1.2.12
184 | ==================
185 | * Update px-theme to 2.0.1 and update test fixtures
186 |
187 | v1.2.11
188 | ==================
189 | * Update px-theme to 2.0.1 and update test fixtures
190 |
191 | v1.2.10
192 | ==================
193 | * update dependencies for dropdown
194 |
195 | v1.2.9
196 | ==================
197 | * increased demo container height to accomodate component
198 |
199 | v1.2.8
200 | ==================
201 | * removing px-theme style call
202 |
203 | v1.2.7
204 | ==================
205 | * changing Gruntfile.js to gulpfile.js
206 |
207 | v1.2.6
208 | ==================
209 | * added style variable for theming
210 |
211 | v1.2.5
212 | ==================
213 | * bower updating px-demo-snippet
214 |
215 | v1.2.4
216 | ==================
217 | * fixed codepen
218 |
219 | v1.2.3
220 | ==================
221 | * Update dependencies
222 |
223 | v1.2.2
224 | ==================
225 | * Push latest gulp file and demo snippet component.
226 |
227 | v1.2.1
228 | ==================
229 | * Grunt to gulp migration & style module use.
230 |
231 | v1.1.10
232 | ==================
233 | * added correct event listener to demo event counter
234 |
235 | v1.1.9
236 | ==================
237 | * Fixed demo event counter
238 |
239 | v1.1.8
240 | ==================
241 | * added overflow to demoContainer and removed flex__wrap from mega-demo
242 |
243 | v1.1.7
244 | ==================
245 | * updated mega demo styles and bower px-demo-snippet to ^
246 |
247 | v1.1.6
248 | ==================
249 | * added image to readme, removed watch, added view on github
250 |
251 | v1.1.5
252 | ==================
253 | * Added vulcanize
254 |
255 | v1.1.4
256 | ==================
257 | * Updated component description in demo
258 |
259 | v1.1.3
260 | ==================
261 | * Fixed footer
262 |
263 | v1.1.2
264 | ==================
265 | * Fixed bower links and added demo footer
266 |
267 | v1.1.1
268 | ==================
269 | * Updated to new demo page
270 |
271 | v1.1.0
272 | ==================
273 | * Added blockPastDates
274 |
275 | v1.0.2
276 | ==================
277 | * Use local copy of moment.js
278 |
279 | v1.0.0
280 | ==================
281 | * major rework of the component to use multiple sub components
282 |
283 | v0.4.0
284 | ==================
285 | * Upgrade to Polymer 1.5.0
286 |
287 | v0.3.4
288 | ==================
289 | * added oss_notice to bower ignore
290 |
291 | v0.3.3
292 | ==================
293 | * added pull request test for travis and updated OSS Notice
294 |
295 | v0.3.2
296 | ==================
297 | * added auto github pages functionality
298 |
299 | v0.3.1
300 | ==================
301 | * moved moment import into its own html import
302 |
303 | v0.3.0
304 | ==================
305 | * Upgrade to Polymer 1.4.0
306 |
307 | v0.2.1
308 | ==================
309 | * Fixed a bug in px-time-rangepicker where the to px-date-time-input was not receiving isUTC
310 |
311 | v0.2.0
312 | ==================
313 | * add is-utc attribute
314 |
315 | v0.1.6
316 | ==================
317 | * Updated License
318 |
319 | v0.1.5
320 | ==================
321 | * Fixed bug where if the user clicks a first date, then chooses a preset, the calendar doesn't visually update to the preset.
322 |
323 | v0.1.4
324 | ==================
325 | * Fixed spacing issue in Firefox which expanded the div beyond the expected size, and wrapped the presets div down.
326 |
--------------------------------------------------------------------------------
/demo/px-rangepicker-demo.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
Event fired: px-datetime-range-submitted
61 |
See API Reference below for more details
62 |
Submitted range: {{props.fromMoment.value}} To: {{props.toMoment.value}}
63 |
64 |
85 |
86 |
87 |
88 |
89 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
332 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/px-rangepicker.html:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
53 |
54 |
55 |
56 |
57 |
83 |
84 |
88 |
110 |
111 |
112 |
113 |
114 |
115 |
428 |
--------------------------------------------------------------------------------
/test/px-rangepicker-custom-tests.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | * Copyright (c) 2018, General Electric
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | // This is the placeholder suite to place custom tests in
19 | // Use testCase(options) for a more convenient setup of the test cases
20 | suite('interaction', function() {
21 |
22 | let picker, dropdown, rangeField;
23 |
24 | setup(function(done) {
25 | picker = fixture('px_rangepicker'),
26 | dropdown = Polymer.dom(picker.root).querySelector('#dropdown'),
27 | rangeField = Polymer.dom(picker.root).querySelector('px-datetime-range-field');
28 |
29 | flush(()=>{
30 | done();
31 | });
32 | });
33 |
34 | test('panel hidden at startup', function() {
35 | assert.isFalse(picker.opened);
36 | });
37 |
38 | test('clicking icon opens the panel', function() {
39 | var field = Polymer.dom(rangeField.root).querySelector('px-datetime-field'),
40 | entry = Polymer.dom(field.root).querySelector('px-datetime-entry'),
41 | icons = Polymer.dom(entry.root).querySelectorAll('px-icon');
42 |
43 | icons[0].click();
44 | assert.isTrue(picker.opened);
45 | });
46 |
47 | });
48 |
49 | suite('submit with buttons', function() {
50 |
51 | let picker, panel, rangeField, submitEventCount = 0,
52 | submitListener;
53 |
54 | setup(function(done) {
55 | picker = fixture('px_rangepicker');
56 | panel = Polymer.dom(Polymer.dom(picker.root).querySelector('px-rangepicker-content').root).querySelector('px-datetime-range-panel');
57 | rangeField = Polymer.dom(picker.root).querySelector('px-datetime-range-field');
58 | picker.set('fromMoment', moment("2017-01-05T00:30:00.000Z"));
59 | picker.set('toMoment', moment("2018-01-05T00:30:00.000Z"));
60 | picker.showButtons = true;
61 |
62 | submitListener = function(evt) {
63 | submitEventCount++;
64 | };
65 | picker.addEventListener('px-datetime-range-submitted', submitListener);
66 |
67 | flush(()=>{
68 | done();
69 | });
70 | });
71 |
72 | suiteTeardown(function() {
73 | picker.removeEventListener('px-datetime-range-submitted', submitListener);
74 | });
75 |
76 | test('Buttons are displayed', function(done) {
77 | var prevCount = submitEventCount;
78 |
79 | picker.opened = true;
80 | flush(()=>{
81 | assert.isTrue(panel.showButtons, "panel should have show buttons to true");
82 | done();
83 | });
84 | });
85 |
86 | test('invalid calendar cell disable apply', function(done) {
87 | var prevCount = submitEventCount;
88 |
89 | picker.opened = true;
90 | flush(()=>{
91 | field = Polymer.dom(rangeField.root).querySelector('px-datetime-field');
92 | entry = Polymer.dom(field.root).querySelector('px-datetime-entry');
93 | cells = Polymer.dom(entry.root).querySelectorAll('px-datetime-entry-cell');
94 | cellInput = Polymer.dom(cells[1].root).querySelector('input');
95 |
96 | cellInput.value = "99";
97 | cells[1]._handleBlur();
98 | picker.opened = true;
99 |
100 | flush(()=>{
101 | assert.isFalse(panel.allowApply, "Don't allow Apply");
102 | done();
103 | });
104 | });
105 | });
106 | test('invalid calendar cell disable apply', function(done) {
107 | var prevCount = submitEventCount;
108 |
109 | picker.opened = true;
110 | flush(()=>{
111 | field = Polymer.dom(rangeField.root).querySelector('px-datetime-field');
112 | entry = Polymer.dom(field.root).querySelector('px-datetime-entry');
113 | cells = Polymer.dom(entry.root).querySelectorAll('px-datetime-entry-cell');
114 | cellInput = Polymer.dom(cells[1].root).querySelector('input');
115 |
116 | cellInput.value = "99";
117 | cells[1]._handleBlur();
118 | picker.opened = true;
119 |
120 | flush(()=>{
121 | assert.isFalse(panel.allowApply, "Don't allow Apply");
122 | done();
123 | });
124 | });
125 | });
126 |
127 | test('valid calendar cell normal color', function(done) {
128 | var prevCount = submitEventCount;
129 |
130 | picker.opened = true;
131 |
132 | flush(()=>{
133 | assert.isTrue(panel.allowApply, "Do allow Apply");
134 | done();
135 | });
136 | });
137 |
138 | test('closing panel should not apply new value', function(done) {
139 | var prevCount = submitEventCount;
140 |
141 | picker.opened = true;
142 | flush(()=>{
143 | //change a date
144 | panel.toMoment = panel.toMoment.clone().add(1, 'day');
145 |
146 | picker.opened = false;
147 |
148 | //shouldn't have changed
149 | assert.equal(picker.fromMoment.toISOString(), "2017-01-05T00:30:00.000Z");
150 | assert.equal(picker.toMoment.toISOString(), "2018-01-05T00:30:00.000Z");
151 | // assert.equal(prevCount, submitEventCount);
152 | done();
153 | });
154 | });
155 |
156 | test('clicking apply should apply new value', function(done) {
157 | var prevCount = submitEventCount,
158 | buttons = Polymer.dom(panel.root).querySelectorAll('px-datetime-buttons'),
159 | applyBtn = Polymer.dom(buttons[0].root).querySelectorAll('#submitButton');
160 |
161 | picker.opened = true;
162 |
163 | //change a date
164 |
165 | flush(()=>{
166 | panel.toMoment = panel.toMoment.clone().add(1, 'day');
167 | //simulate apply
168 | applyBtn[0].click();
169 | assert.isFalse(picker.opened);
170 |
171 | assert.equal(picker.fromMoment.toISOString(), "2017-01-05T00:30:00.000Z");
172 | assert.equal(picker.toMoment.toISOString(), "2018-01-06T00:30:00.000Z");
173 | // assert.equal(prevCount + 1, submitEventCount);
174 | done();
175 | });
176 | });
177 |
178 | test('clicking cancel should not apply new value', function(done) {
179 | var prevCount = submitEventCount,
180 | buttons = Polymer.dom(panel.root).querySelectorAll('px-datetime-buttons'),
181 | bothBtn = Polymer.dom(buttons[0].root).querySelectorAll('button');
182 |
183 | picker.opened = true;
184 |
185 | //change a date
186 | panel.toMoment = panel.toMoment.clone().add(1, 'day');
187 |
188 | //simulate apply
189 | bothBtn[0].click();
190 |
191 | flush(()=>{
192 | assert.isFalse(picker.opened);
193 |
194 | //shouldn't have changed
195 | assert.equal(picker.fromMoment.toISOString(), "2017-01-05T00:30:00.000Z");
196 | assert.equal(picker.toMoment.toISOString(), "2018-01-05T00:30:00.000Z");
197 | // assert.equal(prevCount, submitEventCount);
198 | done();
199 | });
200 | });
201 |
202 | test('when not opened changing values should apply directly', function(done) {
203 | var prevCount = submitEventCount,
204 | e = document.createEvent('Event');
205 |
206 | //change a date
207 | rangeField.toMoment = rangeField.toMoment.clone().add(1, 'day');
208 | e.initEvent("blur", true, true);
209 | picker.dispatchEvent(e);
210 |
211 | flush(()=>{
212 | //should have changed
213 | assert.equal(picker.fromMoment.toISOString(), "2017-01-05T00:30:00.000Z");
214 | assert.equal(picker.toMoment.toISOString(), "2018-01-06T00:30:00.000Z");
215 | // assert.equal(prevCount + 1, submitEventCount);
216 | done();
217 | });
218 | });
219 | });
220 |
221 | suite('submit without buttons', function() {
222 |
223 | let picker, panel, rangeField,
224 | submitEventCount = 0,
225 | submitListener;
226 |
227 | setup(function(done) {
228 | picker = fixture('px_rangepicker');
229 | panel = Polymer.dom(Polymer.dom(picker.root).querySelector('px-rangepicker-content').root).querySelector('px-datetime-range-panel');
230 | rangeField = Polymer.dom(picker.root).querySelector('px-datetime-range-field');
231 | picker.set('fromMoment', moment("2017-01-05T00:30:00.000Z"));
232 | picker.set('toMoment', moment("2018-01-05T00:30:00.000Z"));
233 | picker.showButtons = false;
234 |
235 | submitListener = function(evt) {
236 | submitEventCount++;
237 | };
238 | picker.addEventListener('px-datetime-range-submitted', submitListener);
239 |
240 | flush(()=>{
241 | done();
242 | });
243 | });
244 |
245 | suiteTeardown(function() {
246 | picker.removeEventListener('px-datetime-range-submitted', submitListener);
247 | });
248 |
249 | test('Buttons are not displayed', function(done) {
250 | var prevCount = submitEventCount;
251 |
252 | picker.opened = true;
253 | flush(()=>{
254 | assert.isFalse(panel.showButtons, "panel should have show buttons to false");
255 | done();
256 | });
257 | });
258 |
259 | test('closing panel should apply new value', function(done) {
260 | var prevCount = submitEventCount;
261 |
262 | picker.set('opened', true);
263 |
264 | //change a date
265 | panel.set('toMoment', panel.toMoment.clone().add(1, 'day'));
266 | picker.set('opened', false);
267 |
268 | flush(()=>{
269 | //should have changed
270 | assert.equal(picker.fromMoment.toISOString(), "2017-01-05T00:30:00.000Z");
271 | assert.equal(picker.toMoment.toISOString(), "2018-01-06T00:30:00.000Z");
272 | // assert.equal(prevCount + 1, submitEventCount);
273 | done();
274 | });
275 | });
276 |
277 | test('closing panel when time not valid should not apply new value', function(done) {
278 | var prevCount = submitEventCount;
279 |
280 | picker.opened = true;
281 |
282 | //change a date
283 | panel.toMoment = panel.toMoment.clone().add(1, 'day');
284 | //make sure time is invalid
285 | panel._toTimeIsValid = false;
286 |
287 | picker.opened = false;
288 |
289 | flush(()=>{
290 | //shouldn't have changed
291 | assert.equal(picker.fromMoment.toISOString(), "2017-01-05T00:30:00.000Z");
292 | assert.equal(picker.toMoment.toISOString(), "2018-01-05T00:30:00.000Z");
293 | // assert.equal(prevCount, submitEventCount);
294 |
295 | panel._toTimeIsValid = true;
296 | done();
297 | });
298 | });
299 |
300 | test('when not opened changing values should apply directly on blur', function(done) {
301 | var prevCount = submitEventCount;
302 | e = document.createEvent('Event');
303 |
304 | //change a date
305 | rangeField.toMoment = rangeField.toMoment.clone().add(1, 'day');
306 | e.initEvent("blur", true, true);
307 | picker.dispatchEvent(e);
308 |
309 | flush(()=>{
310 | //should have changed
311 | assert.equal(picker.fromMoment.toISOString(), "2017-01-05T00:30:00.000Z");
312 | assert.equal(picker.toMoment.toISOString(), "2018-01-06T00:30:00.000Z");
313 | // assert.equal(prevCount + 1, submitEventCount);
314 | done();
315 | });
316 | });
317 |
318 | test('when not opened changing values should apply directly on Enter', function(done) {
319 | var prevCount = submitEventCount;
320 | e = document.createEvent('Event');
321 |
322 | //change a date
323 | rangeField.toMoment = rangeField.toMoment.clone().add(1, 'day');
324 | MockInteractions.pressAndReleaseKeyOn(rangeField, 13, [], 'Enter');
325 |
326 | flush(()=>{
327 | //should have changed
328 | assert.equal(picker.fromMoment.toISOString(), "2017-01-05T00:30:00.000Z");
329 | assert.equal(picker.toMoment.toISOString(), "2018-01-06T00:30:00.000Z");
330 | // assert.equal(prevCount + 1, submitEventCount);
331 | done();
332 | });
333 | });
334 |
335 | test('when not opened changing invalid values should not apply directly', function(done) {
336 | var prevCount = submitEventCount,
337 | e = document.createEvent('Event'),
338 | field = Polymer.dom(rangeField.root).querySelector('px-datetime-field'),
339 | entries = Polymer.dom(field.root).querySelectorAll('px-datetime-entry'),
340 | dateCells = Polymer.dom(entries[0].root).querySelectorAll('px-datetime-entry-cell'),
341 | dateInput = Polymer.dom(dateCells[1].root).querySelector('input');
342 |
343 | //change a date
344 | dateInput.value = "99";
345 | MockInteractions.pressAndReleaseKeyOn(field, 13, [], 'Enter');
346 |
347 | flush(()=>{
348 | //shouldn't have changed
349 | assert.isFalse(rangeField.isValid);
350 | assert.equal(picker.fromMoment.toISOString(), "2017-01-05T00:30:00.000Z");
351 | assert.equal(picker.toMoment.toISOString(), "2018-01-05T00:30:00.000Z");
352 |
353 | done();
354 | });
355 | });
356 | });
357 |
358 | suite('iron-dropdown positioning', function() {
359 |
360 | let frame, doc, html;
361 |
362 | setup(function(done) {
363 | frame = fixture('frameFxt');
364 |
365 | flush(() => {
366 | frame = document.querySelector("#frame"); //get the iframe
367 | doc = frame.contentDocument || frame.contentWindow.document;
368 | html = `
369 |
370 |
371 |
372 |
373 |
374 | Predix UI
375 |