mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
rework dialogs
This commit is contained in:
parent
5a71a65637
commit
5b66bb9ecb
39 changed files with 486 additions and 121 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "iron-input",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.9",
|
||||
"description": "An input element with data binding",
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
|
@ -20,6 +20,7 @@
|
|||
"homepage": "https://github.com/PolymerElements/iron-input",
|
||||
"ignore": [],
|
||||
"dependencies": {
|
||||
"iron-a11y-announcer": "PolymerElements/iron-a11y-announcer#^1.0.0",
|
||||
"iron-validatable-behavior": "PolymerElements/iron-validatable-behavior#^1.0.0",
|
||||
"polymer": "Polymer/polymer#^1.0.0"
|
||||
},
|
||||
|
@ -28,14 +29,14 @@
|
|||
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
|
||||
"iron-validator-behavior": "PolymerElements/iron-validator-behavior#^1.0.0",
|
||||
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
|
||||
"web-component-tester": "polymer/web-component-tester#^3.4.0",
|
||||
"web-component-tester": "^4.0.0",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
},
|
||||
"_release": "1.0.8",
|
||||
"_release": "1.0.9",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "1.0.8",
|
||||
"commit": "55d2b39ead32b8d90da538daa1a6681fd9ae89d9"
|
||||
"tag": "v1.0.9",
|
||||
"commit": "6565b5d1b5f7030eb05378718163def8e9c709b7"
|
||||
},
|
||||
"_source": "git://github.com/PolymerElements/iron-input.git",
|
||||
"_target": "^1.0.0",
|
||||
|
|
|
@ -1,22 +1,25 @@
|
|||
language: node_js
|
||||
sudo: false
|
||||
before_script:
|
||||
- npm install web-component-tester
|
||||
- npm install bower
|
||||
- 'export PATH=$PWD/node_modules/.bin:$PATH'
|
||||
- npm install -g bower polylint web-component-tester
|
||||
- bower install
|
||||
- polylint
|
||||
env:
|
||||
global:
|
||||
- secure: AnFRDBxxASn2RP4u+CHJS04g2klVTM+YL1fgNfkNIiECChymGRkeBiF7zvWPfodqPGKWhBZPAMxVuFKbztawQ95kWlbPSTNJtWhHhPcRarV5AYvjhyUV372E3REZ4CGt+T8nghD9bdJiMX5x0pXAz+wfBPPpiHwbiSPPjFLFvTs=
|
||||
- secure: SvsE+VQL35CZ967ZVy0+7o5xclnBM8egjhsjNRG7WxVPZQboCQ3Xwm8tIDQSWeagM3ZQRkTGca4ta91F1ZEhm4Jdt5CwKhhSNC6JgS3CX819r9UKgUnSS3nvWdqcZq4GXcMoOZm4qE9ttd3xdoKCfkLRQlEGAvM2TEw69mBhj24=
|
||||
node_js: 4
|
||||
- CXX=g++-4.8
|
||||
node_js: stable
|
||||
addons:
|
||||
firefox: latest
|
||||
apt:
|
||||
sources:
|
||||
- google-chrome
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- google-chrome-stable
|
||||
- g++-4.8
|
||||
sauce_connect: true
|
||||
script:
|
||||
- xvfb-run wct
|
||||
- "if [ \"${TRAVIS_PULL_REQUEST}\" = \"false\" ]; then wct -s 'default'; fi"
|
||||
|
|
|
@ -5,6 +5,11 @@ https://github.com/PolymerElements/ContributionGuide/blob/master/CONTRIBUTING.md
|
|||
|
||||
If you edit that file, it will get updated everywhere else.
|
||||
If you edit this file, your changes will get overridden :)
|
||||
|
||||
You can however override the jsbin link with one that's customized to this
|
||||
specific element:
|
||||
|
||||
jsbin=https://jsbin.com/cagaye/edit?html,output
|
||||
-->
|
||||
# Polymer Elements
|
||||
## Guide for Contributors
|
||||
|
@ -41,7 +46,7 @@ Polymer Elements are built in the open, and the Polymer authors eagerly encourag
|
|||
3. Click the `paper-foo` element.
|
||||
```
|
||||
|
||||
2. **A reduced test case that demonstrates the problem.** If possible, please include the test case as a JSBin. Start with this template to easily import and use relevant Polymer Elements: [http://jsbin.com/cagaye](http://jsbin.com/cagaye/edit?html,output).
|
||||
2. **A reduced test case that demonstrates the problem.** If possible, please include the test case as a JSBin. Start with this template to easily import and use relevant Polymer Elements: [https://jsbin.com/cagaye/edit?html,output](https://jsbin.com/cagaye/edit?html,output).
|
||||
|
||||
3. **A list of browsers where the problem occurs.** This can be skipped if the problem is the same across all browsers.
|
||||
|
||||
|
@ -51,14 +56,14 @@ Polymer Elements are built in the open, and the Polymer authors eagerly encourag
|
|||
|
||||
When submitting pull requests, please provide:
|
||||
|
||||
1. **A reference to the corresponding issue** or issues that will be closed by the pull request. Please refer to these issues using the following syntax:
|
||||
1. **A reference to the corresponding issue** or issues that will be closed by the pull request. Please refer to these issues in the pull request description using the following syntax:
|
||||
|
||||
```markdown
|
||||
(For a single issue)
|
||||
Fixes #20
|
||||
|
||||
(For multiple issues)
|
||||
Fixes #32, #40
|
||||
Fixes #32, fixes #40
|
||||
```
|
||||
|
||||
2. **A succinct description of the design** used to fix any related issues. For example:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "iron-input",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.9",
|
||||
"description": "An input element with data binding",
|
||||
"authors": [
|
||||
"The Polymer Authors"
|
||||
|
@ -20,6 +20,7 @@
|
|||
"homepage": "https://github.com/PolymerElements/iron-input",
|
||||
"ignore": [],
|
||||
"dependencies": {
|
||||
"iron-a11y-announcer": "PolymerElements/iron-a11y-announcer#^1.0.0",
|
||||
"iron-validatable-behavior": "PolymerElements/iron-validatable-behavior#^1.0.0",
|
||||
"polymer": "Polymer/polymer#^1.0.0"
|
||||
},
|
||||
|
@ -28,7 +29,7 @@
|
|||
"iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
|
||||
"iron-validator-behavior": "PolymerElements/iron-validator-behavior#^1.0.0",
|
||||
"test-fixture": "PolymerElements/test-fixture#^1.0.0",
|
||||
"web-component-tester": "polymer/web-component-tester#^3.4.0",
|
||||
"web-component-tester": "^4.0.0",
|
||||
"webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
-->
|
||||
|
||||
<link rel="import" href="../polymer/polymer.html">
|
||||
<link rel="import" href="../iron-a11y-announcer/iron-a11y-announcer.html">
|
||||
<link rel="import" href="../iron-validatable-behavior/iron-validatable-behavior.html">
|
||||
|
||||
<script>
|
||||
|
@ -68,18 +69,22 @@ is separate from validation, and `allowed-pattern` does not affect how the input
|
|||
},
|
||||
|
||||
/**
|
||||
* Set to true to prevent the user from entering invalid input. The new input characters are
|
||||
* matched with `allowedPattern` if it is set, otherwise it will use the `type` attribute (only
|
||||
* supported for `type=number`).
|
||||
* Set to true to prevent the user from entering invalid input. If `allowedPattern` is set,
|
||||
* any character typed by the user will be matched against that pattern, and rejected if it's not a match.
|
||||
* Pasted input will have each character checked individually; if any character
|
||||
* doesn't match `allowedPattern`, the entire pasted string will be rejected.
|
||||
* If `allowedPattern` is not set, it will use the `type` attribute (only supported for `type=number`).
|
||||
*/
|
||||
preventInvalidInput: {
|
||||
type: Boolean
|
||||
},
|
||||
|
||||
/**
|
||||
* Regular expression expressing a set of characters to enforce the validity of input characters.
|
||||
* The recommended value should follow this format: `[a-ZA-Z0-9.+-!;:]` that list the characters
|
||||
* allowed as input.
|
||||
* Regular expression that list the characters allowed as input.
|
||||
* This pattern represents the allowed characters for the field; as the user inputs text,
|
||||
* each individual character will be checked against the pattern (rather than checking
|
||||
* the entire value as a whole). The recommended format should be a list of allowed characters;
|
||||
* for example, `[a-zA-Z0-9.+-!;:]`
|
||||
*/
|
||||
allowedPattern: {
|
||||
type: String,
|
||||
|
@ -103,6 +108,46 @@ is separate from validation, and `allowed-pattern` does not affect how the input
|
|||
'keypress': '_onKeypress'
|
||||
},
|
||||
|
||||
registered: function() {
|
||||
// Feature detect whether we need to patch dispatchEvent (i.e. on FF and IE).
|
||||
if (!this._canDispatchEventOnDisabled()) {
|
||||
this._origDispatchEvent = this.dispatchEvent;
|
||||
this.dispatchEvent = this._dispatchEventFirefoxIE;
|
||||
}
|
||||
},
|
||||
|
||||
created: function() {
|
||||
Polymer.IronA11yAnnouncer.requestAvailability();
|
||||
},
|
||||
|
||||
_canDispatchEventOnDisabled: function() {
|
||||
var input = document.createElement('input');
|
||||
var canDispatch = false;
|
||||
input.disabled = true;
|
||||
|
||||
input.addEventListener('feature-check-dispatch-event', function() {
|
||||
canDispatch = true;
|
||||
});
|
||||
|
||||
try {
|
||||
input.dispatchEvent(new Event('feature-check-dispatch-event'));
|
||||
} catch(e) {}
|
||||
|
||||
return canDispatch;
|
||||
},
|
||||
|
||||
_dispatchEventFirefoxIE: function() {
|
||||
// Due to Firefox bug, events fired on disabled form controls can throw
|
||||
// errors; furthermore, neither IE nor Firefox will actually dispatch
|
||||
// events from disabled form controls; as such, we toggle disable around
|
||||
// the dispatch to allow notifying properties to notify
|
||||
// See issue #47 for details
|
||||
var disabled = this.disabled;
|
||||
this.disabled = false;
|
||||
this._origDispatchEvent.apply(this, arguments);
|
||||
this.disabled = disabled;
|
||||
},
|
||||
|
||||
get _patternRegExp() {
|
||||
var pattern;
|
||||
if (this.allowedPattern) {
|
||||
|
@ -143,6 +188,7 @@ is separate from validation, and `allowed-pattern` does not affect how the input
|
|||
if (this.preventInvalidInput && !this._patternAlreadyChecked) {
|
||||
var valid = this._checkPatternValidity();
|
||||
if (!valid) {
|
||||
this._announceInvalidCharacter('Invalid string of characters not entered.');
|
||||
this.value = this._previousValidInput;
|
||||
}
|
||||
}
|
||||
|
@ -203,6 +249,7 @@ is separate from validation, and `allowed-pattern` does not affect how the input
|
|||
var thisChar = String.fromCharCode(event.charCode);
|
||||
if (this._isPrintable(event) && !regexp.test(thisChar)) {
|
||||
event.preventDefault();
|
||||
this._announceInvalidCharacter('Invalid character ' + thisChar + ' not entered.');
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -225,23 +272,29 @@ is separate from validation, and `allowed-pattern` does not affect how the input
|
|||
* @return {boolean} True if the value is valid.
|
||||
*/
|
||||
validate: function() {
|
||||
// Empty, non-required input is valid.
|
||||
if (!this.required && this.value == '') {
|
||||
this.invalid = false;
|
||||
return true;
|
||||
// First, check what the browser thinks. Some inputs (like type=number)
|
||||
// behave weirdly and will set the value to "" if something invalid is
|
||||
// entered, but will set the validity correctly.
|
||||
var valid = this.checkValidity();
|
||||
|
||||
// Only do extra checking if the browser thought this was valid.
|
||||
if (valid) {
|
||||
// Empty, required input is invalid
|
||||
if (this.required && this.value === '') {
|
||||
valid = false;
|
||||
} else if (this.hasValidator()) {
|
||||
valid = Polymer.IronValidatableBehavior.validate.call(this, this.value);
|
||||
}
|
||||
}
|
||||
|
||||
var valid;
|
||||
if (this.hasValidator()) {
|
||||
valid = Polymer.IronValidatableBehavior.validate.call(this, this.value);
|
||||
} else {
|
||||
valid = this.checkValidity();
|
||||
this.invalid = !valid;
|
||||
}
|
||||
this.invalid = !valid;
|
||||
this.fire('iron-input-validate');
|
||||
return valid;
|
||||
}
|
||||
},
|
||||
|
||||
_announceInvalidCharacter: function(message) {
|
||||
this.fire('iron-announce', { text: message });
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
|
|
32
dashboard-ui/bower_components/iron-input/test/disabled-input.html
vendored
Normal file
32
dashboard-ui/bower_components/iron-input/test/disabled-input.html
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
<!--
|
||||
@license
|
||||
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
|
||||
<link rel="import" href="../../polymer/polymer.html">
|
||||
|
||||
<dom-module id="disabled-input">
|
||||
<template>
|
||||
<input is="iron-input" bind-value="{{myValue}}" invalid="{{myInvalid}}" disabled id="input">
|
||||
</template>
|
||||
</dom-module>
|
||||
|
||||
<script>
|
||||
Polymer({
|
||||
is: 'disabled-input',
|
||||
properties: {
|
||||
myValue: {
|
||||
value: 'foo'
|
||||
},
|
||||
|
||||
myInvalid: {
|
||||
value: false
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
|
@ -8,7 +8,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
--><html><head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
|
||||
<title>iron-input ests</title>
|
||||
<title>iron-input tests</title>
|
||||
<script src="../../web-component-tester/browser.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -20,6 +20,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
<script src="../../web-component-tester/browser.js"></script>
|
||||
<link rel="import" href="../iron-input.html">
|
||||
<link rel="import" href="letters-only.html">
|
||||
<link rel="import" href="disabled-input.html">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
@ -85,10 +86,23 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<test-fixture id="native-and-custom-validator">
|
||||
<template>
|
||||
<letters-only></letters-only>
|
||||
<input is="iron-input" validator="letters-only" pattern="[a-c]*">
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<template is="dom-bind" id="bind-to-object">
|
||||
<input is="iron-input" id="input" bind-value="{{foo}}">
|
||||
</template>
|
||||
|
||||
<test-fixture id="disabled-input">
|
||||
<template>
|
||||
<disabled-input></disabled-input>
|
||||
</template>
|
||||
</test-fixture>
|
||||
|
||||
<script>
|
||||
|
||||
suite('basic', function() {
|
||||
|
@ -209,8 +223,57 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
input._onInput();
|
||||
assert.equal(input.bindValue, 'foo');
|
||||
});
|
||||
|
||||
test('disabled input doesn\'t throw on Firefox', function() {
|
||||
var el = fixture('disabled-input');
|
||||
var input = el.$.input;
|
||||
|
||||
assert.equal(input.bindValue, 'foo');
|
||||
|
||||
assert.isFalse(el.myInvalid);
|
||||
assert.isTrue(input.disabled);
|
||||
});
|
||||
|
||||
test('browser validation beats custom validation', function() {
|
||||
var input = fixture('native-and-custom-validator')[1];
|
||||
// The input allows any letters, but the browser only allows one
|
||||
// of [abc].
|
||||
input.value = 'aaaa';
|
||||
input.validate();
|
||||
assert.isFalse(input.invalid, 'input is valid');
|
||||
|
||||
// The validator allows this, but the browser doesn't.
|
||||
input.value = 'zzz';
|
||||
input.validate();
|
||||
assert.isTrue(input.invalid, 'input is invalid');
|
||||
});
|
||||
});
|
||||
|
||||
suite('a11y', function() {
|
||||
test('announces invalid characters when _onInput is called', function() {
|
||||
var input = fixture('prevent-invalid-input');
|
||||
input.addEventListener('iron-announce', function(event) {
|
||||
assert.equal(event.detail.text, 'Invalid string of characters not entered.');
|
||||
});
|
||||
input.value = 'foo';
|
||||
input._onInput();
|
||||
});
|
||||
|
||||
test('announces invalid characters on keypress', function() {
|
||||
var input = fixture('prevent-invalid-input');
|
||||
input.addEventListener('iron-announce', function(event) {
|
||||
assert.equal(event.detail.text, 'Invalid character a not entered.');
|
||||
});
|
||||
|
||||
// Simulate key press event.
|
||||
var event = new CustomEvent('keypress', {
|
||||
bubbles: true,
|
||||
cancelable: true
|
||||
});
|
||||
event.charCode = 97 /* a */;
|
||||
input.dispatchEvent(event);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue