8fedfc7f8c
R=kevmoo@google.com,vsm@google.com Fixes #32304 Change-Id: Ia2c8f99f0125c4d4bd0f95a792ff2af8a58e3599 Reviewed-on: https://dart-review.googlesource.com/60400 Commit-Queue: Terry Lucas <terry@google.com> Reviewed-by: Kevin Moore <kevmoo@google.com>
505 lines
12 KiB
Plaintext
505 lines
12 KiB
Plaintext
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
part of $LIBRARYNAME;
|
|
|
|
$(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS implements
|
|
HiddenInputElement,
|
|
SearchInputElement,
|
|
TextInputElement,
|
|
UrlInputElement,
|
|
TelephoneInputElement,
|
|
EmailInputElement,
|
|
PasswordInputElement,
|
|
DateInputElement,
|
|
MonthInputElement,
|
|
WeekInputElement,
|
|
TimeInputElement,
|
|
LocalDateTimeInputElement,
|
|
NumberInputElement,
|
|
RangeInputElement,
|
|
CheckboxInputElement,
|
|
RadioButtonInputElement,
|
|
FileUploadInputElement,
|
|
SubmitButtonInputElement,
|
|
ImageButtonInputElement,
|
|
ResetButtonInputElement,
|
|
ButtonInputElement {
|
|
|
|
factory InputElement({String type}) {
|
|
InputElement e = document.createElement("input");
|
|
if (type != null) {
|
|
try {
|
|
// IE throws an exception for unknown types.
|
|
e.type = type;
|
|
} catch(_) {}
|
|
}
|
|
return e;
|
|
}
|
|
|
|
$!MEMBERS
|
|
}
|
|
|
|
|
|
// Interfaces representing the InputElement APIs which are supported
|
|
// for the various types of InputElement. From:
|
|
// http://www.w3.org/html/wg/drafts/html/master/forms.html#the-input-element.
|
|
|
|
/**
|
|
* Exposes the functionality common between all InputElement types.
|
|
*/
|
|
abstract class InputElementBase implements Element {
|
|
bool autofocus;
|
|
|
|
bool disabled;
|
|
|
|
bool incremental;
|
|
|
|
bool indeterminate;
|
|
|
|
List<Node> get labels;
|
|
|
|
String name;
|
|
|
|
String get validationMessage;
|
|
|
|
ValidityState get validity;
|
|
|
|
String value;
|
|
|
|
bool get willValidate;
|
|
|
|
bool checkValidity();
|
|
|
|
void setCustomValidity(String error);
|
|
}
|
|
|
|
/**
|
|
* Hidden input which is not intended to be seen or edited by the user.
|
|
*/
|
|
abstract class HiddenInputElement implements InputElementBase {
|
|
factory HiddenInputElement() => new InputElement(type: 'hidden');
|
|
}
|
|
|
|
|
|
/**
|
|
* Base interface for all inputs which involve text editing.
|
|
*/
|
|
abstract class TextInputElementBase implements InputElementBase {
|
|
String autocomplete;
|
|
|
|
int maxLength;
|
|
|
|
String pattern;
|
|
|
|
String placeholder;
|
|
|
|
bool readOnly;
|
|
|
|
bool required;
|
|
|
|
int size;
|
|
|
|
void select();
|
|
|
|
String selectionDirection;
|
|
|
|
int selectionEnd;
|
|
|
|
int selectionStart;
|
|
|
|
void setSelectionRange(int start, int end, [String direction]);
|
|
}
|
|
|
|
/**
|
|
* Similar to [TextInputElement], but on platforms where search is styled
|
|
* differently this will get the search style.
|
|
*
|
|
* Use [supported] to check if this is supported on the current platform.
|
|
*/
|
|
@SupportedBrowser(SupportedBrowser.CHROME)
|
|
@SupportedBrowser(SupportedBrowser.FIREFOX)
|
|
@SupportedBrowser(SupportedBrowser.IE, '10')
|
|
@SupportedBrowser(SupportedBrowser.SAFARI)
|
|
abstract class SearchInputElement implements TextInputElementBase {
|
|
factory SearchInputElement() => new InputElement(type: 'search');
|
|
|
|
String dirName;
|
|
|
|
Element get list;
|
|
|
|
/// Returns true if this input type is supported on the current platform.
|
|
static bool get supported {
|
|
return (new InputElement(type: 'search')).type == 'search';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* A basic text input editor control.
|
|
*/
|
|
abstract class TextInputElement implements TextInputElementBase {
|
|
factory TextInputElement() => new InputElement(type: 'text');
|
|
|
|
String dirName;
|
|
|
|
Element get list;
|
|
}
|
|
|
|
/**
|
|
* A control for editing an absolute URL.
|
|
*
|
|
* Use [supported] to check if this is supported on the current platform.
|
|
*/
|
|
@SupportedBrowser(SupportedBrowser.CHROME)
|
|
@SupportedBrowser(SupportedBrowser.FIREFOX)
|
|
@SupportedBrowser(SupportedBrowser.IE, '10')
|
|
@SupportedBrowser(SupportedBrowser.SAFARI)
|
|
abstract class UrlInputElement implements TextInputElementBase {
|
|
factory UrlInputElement() => new InputElement(type: 'url');
|
|
|
|
Element get list;
|
|
|
|
/// Returns true if this input type is supported on the current platform.
|
|
static bool get supported {
|
|
return (new InputElement(type: 'url')).type == 'url';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Represents a control for editing a telephone number.
|
|
*
|
|
* This provides a single line of text with minimal formatting help since
|
|
* there is a wide variety of telephone numbers.
|
|
*
|
|
* Use [supported] to check if this is supported on the current platform.
|
|
*/
|
|
@SupportedBrowser(SupportedBrowser.CHROME)
|
|
@SupportedBrowser(SupportedBrowser.FIREFOX)
|
|
@SupportedBrowser(SupportedBrowser.IE, '10')
|
|
@SupportedBrowser(SupportedBrowser.SAFARI)
|
|
abstract class TelephoneInputElement implements TextInputElementBase {
|
|
factory TelephoneInputElement() => new InputElement(type: 'tel');
|
|
|
|
Element get list;
|
|
|
|
/// Returns true if this input type is supported on the current platform.
|
|
static bool get supported {
|
|
return (new InputElement(type: 'tel')).type == 'tel';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* An e-mail address or list of e-mail addresses.
|
|
*
|
|
* Use [supported] to check if this is supported on the current platform.
|
|
*/
|
|
@SupportedBrowser(SupportedBrowser.CHROME)
|
|
@SupportedBrowser(SupportedBrowser.FIREFOX)
|
|
@SupportedBrowser(SupportedBrowser.IE, '10')
|
|
@SupportedBrowser(SupportedBrowser.SAFARI)
|
|
abstract class EmailInputElement implements TextInputElementBase {
|
|
factory EmailInputElement() => new InputElement(type: 'email');
|
|
|
|
String autocomplete;
|
|
|
|
bool autofocus;
|
|
|
|
Element get list;
|
|
|
|
int maxLength;
|
|
|
|
bool multiple;
|
|
|
|
String pattern;
|
|
|
|
String placeholder;
|
|
|
|
bool readOnly;
|
|
|
|
bool required;
|
|
|
|
int size;
|
|
|
|
/// Returns true if this input type is supported on the current platform.
|
|
static bool get supported {
|
|
return (new InputElement(type: 'email')).type == 'email';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Text with no line breaks (sensitive information).
|
|
*/
|
|
abstract class PasswordInputElement implements TextInputElementBase {
|
|
factory PasswordInputElement() => new InputElement(type: 'password');
|
|
}
|
|
|
|
/**
|
|
* Base interface for all input element types which involve ranges.
|
|
*/
|
|
abstract class RangeInputElementBase implements InputElementBase {
|
|
|
|
Element get list;
|
|
|
|
String max;
|
|
|
|
String min;
|
|
|
|
String step;
|
|
|
|
num valueAsNumber;
|
|
|
|
void stepDown([int n]);
|
|
|
|
void stepUp([int n]);
|
|
}
|
|
|
|
/**
|
|
* A date (year, month, day) with no time zone.
|
|
*
|
|
* Use [supported] to check if this is supported on the current platform.
|
|
*/
|
|
@SupportedBrowser(SupportedBrowser.CHROME, '25')
|
|
abstract class DateInputElement implements RangeInputElementBase {
|
|
factory DateInputElement() => new InputElement(type: 'date');
|
|
|
|
DateTime valueAsDate;
|
|
|
|
bool readOnly;
|
|
|
|
bool required;
|
|
|
|
/// Returns true if this input type is supported on the current platform.
|
|
static bool get supported {
|
|
return (new InputElement(type: 'date')).type == 'date';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* A date consisting of a year and a month with no time zone.
|
|
*
|
|
* Use [supported] to check if this is supported on the current platform.
|
|
*/
|
|
@SupportedBrowser(SupportedBrowser.CHROME, '25')
|
|
abstract class MonthInputElement implements RangeInputElementBase {
|
|
factory MonthInputElement() => new InputElement(type: 'month');
|
|
|
|
DateTime valueAsDate;
|
|
|
|
bool readOnly;
|
|
|
|
bool required;
|
|
|
|
/// Returns true if this input type is supported on the current platform.
|
|
static bool get supported {
|
|
return (new InputElement(type: 'month')).type == 'month';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* A date consisting of a week-year number and a week number with no time zone.
|
|
*
|
|
* Use [supported] to check if this is supported on the current platform.
|
|
*/
|
|
@SupportedBrowser(SupportedBrowser.CHROME, '25')
|
|
abstract class WeekInputElement implements RangeInputElementBase {
|
|
factory WeekInputElement() => new InputElement(type: 'week');
|
|
|
|
DateTime valueAsDate;
|
|
|
|
bool readOnly;
|
|
|
|
bool required;
|
|
|
|
/// Returns true if this input type is supported on the current platform.
|
|
static bool get supported {
|
|
return (new InputElement(type: 'week')).type == 'week';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* A time (hour, minute, seconds, fractional seconds) with no time zone.
|
|
*
|
|
* Use [supported] to check if this is supported on the current platform.
|
|
*/
|
|
@SupportedBrowser(SupportedBrowser.CHROME)
|
|
abstract class TimeInputElement implements RangeInputElementBase {
|
|
factory TimeInputElement() => new InputElement(type: 'time');
|
|
|
|
DateTime valueAsDate;
|
|
|
|
bool readOnly;
|
|
|
|
bool required;
|
|
|
|
/// Returns true if this input type is supported on the current platform.
|
|
static bool get supported {
|
|
return (new InputElement(type: 'time')).type == 'time';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* A date and time (year, month, day, hour, minute, second, fraction of a
|
|
* second) with no time zone.
|
|
*
|
|
* Use [supported] to check if this is supported on the current platform.
|
|
*/
|
|
@SupportedBrowser(SupportedBrowser.CHROME, '25')
|
|
abstract class LocalDateTimeInputElement implements RangeInputElementBase {
|
|
factory LocalDateTimeInputElement() =>
|
|
new InputElement(type: 'datetime-local');
|
|
|
|
bool readOnly;
|
|
|
|
bool required;
|
|
|
|
/// Returns true if this input type is supported on the current platform.
|
|
static bool get supported {
|
|
return (new InputElement(type: 'datetime-local')).type == 'datetime-local';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* A numeric editor control.
|
|
*/
|
|
@SupportedBrowser(SupportedBrowser.CHROME)
|
|
@SupportedBrowser(SupportedBrowser.IE)
|
|
@SupportedBrowser(SupportedBrowser.SAFARI)
|
|
abstract class NumberInputElement implements RangeInputElementBase {
|
|
factory NumberInputElement() => new InputElement(type: 'number');
|
|
|
|
String placeholder;
|
|
|
|
bool readOnly;
|
|
|
|
bool required;
|
|
|
|
/// Returns true if this input type is supported on the current platform.
|
|
static bool get supported {
|
|
return (new InputElement(type: 'number')).type == 'number';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Similar to [NumberInputElement] but the browser may provide more optimal
|
|
* styling (such as a slider control).
|
|
*
|
|
* Use [supported] to check if this is supported on the current platform.
|
|
*/
|
|
@SupportedBrowser(SupportedBrowser.CHROME)
|
|
@SupportedBrowser(SupportedBrowser.IE, '10')
|
|
abstract class RangeInputElement implements RangeInputElementBase {
|
|
factory RangeInputElement() => new InputElement(type: 'range');
|
|
|
|
/// Returns true if this input type is supported on the current platform.
|
|
static bool get supported {
|
|
return (new InputElement(type: 'range')).type == 'range';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* A boolean editor control.
|
|
*
|
|
* Note that if [indeterminate] is set then this control is in a third
|
|
* indeterminate state.
|
|
*/
|
|
abstract class CheckboxInputElement implements InputElementBase {
|
|
factory CheckboxInputElement() => new InputElement(type: 'checkbox');
|
|
|
|
bool checked;
|
|
|
|
bool required;
|
|
}
|
|
|
|
|
|
/**
|
|
* A control that when used with other [ReadioButtonInputElement] controls
|
|
* forms a radio button group in which only one control can be checked at a
|
|
* time.
|
|
*
|
|
* Radio buttons are considered to be in the same radio button group if:
|
|
*
|
|
* * They are all of type 'radio'.
|
|
* * They all have either the same [FormElement] owner, or no owner.
|
|
* * Their name attributes contain the same name.
|
|
*/
|
|
abstract class RadioButtonInputElement implements InputElementBase {
|
|
factory RadioButtonInputElement() => new InputElement(type: 'radio');
|
|
|
|
bool checked;
|
|
|
|
bool required;
|
|
}
|
|
|
|
/**
|
|
* A control for picking files from the user's computer.
|
|
*/
|
|
abstract class FileUploadInputElement implements InputElementBase {
|
|
factory FileUploadInputElement() => new InputElement(type: 'file');
|
|
|
|
String accept;
|
|
|
|
bool multiple;
|
|
|
|
bool required;
|
|
|
|
List<File> files;
|
|
}
|
|
|
|
/**
|
|
* A button, which when clicked, submits the form.
|
|
*/
|
|
abstract class SubmitButtonInputElement implements InputElementBase {
|
|
factory SubmitButtonInputElement() => new InputElement(type: 'submit');
|
|
|
|
String formAction;
|
|
|
|
String formEnctype;
|
|
|
|
String formMethod;
|
|
|
|
bool formNoValidate;
|
|
|
|
String formTarget;
|
|
}
|
|
|
|
/**
|
|
* Either an image which the user can select a coordinate to or a form
|
|
* submit button.
|
|
*/
|
|
abstract class ImageButtonInputElement implements InputElementBase {
|
|
factory ImageButtonInputElement() => new InputElement(type: 'image');
|
|
|
|
String alt;
|
|
|
|
String formAction;
|
|
|
|
String formEnctype;
|
|
|
|
String formMethod;
|
|
|
|
bool formNoValidate;
|
|
|
|
String formTarget;
|
|
|
|
int height;
|
|
|
|
String src;
|
|
|
|
int width;
|
|
}
|
|
|
|
/**
|
|
* A button, which when clicked, resets the form.
|
|
*/
|
|
abstract class ResetButtonInputElement implements InputElementBase {
|
|
factory ResetButtonInputElement() => new InputElement(type: 'reset');
|
|
}
|
|
|
|
/**
|
|
* A button, with no default behavior.
|
|
*/
|
|
abstract class ButtonInputElement implements InputElementBase {
|
|
factory ButtonInputElement() => new InputElement(type: 'button');
|
|
}
|