code stringlengths 28 313k | docstring stringlengths 25 85.3k | func_name stringlengths 1 74 | language stringclasses 1
value | repo stringlengths 5 60 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
getValidationError() {
return this.validationError ?? '';
} | Returns the current validation error
@instance
@memberof LuCI.ui.AbstractElement
@returns {string}
The validation error at this time | getValidationError | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
triggerValidation() {
if (typeof(this.vfunc) != 'function')
return false;
const wasValid = this.isValid();
this.vfunc();
return (wasValid != this.isValid());
} | Force validation of the current input value.
Usually input validation is automatically triggered by various DOM events
bound to the input widget. In some cases it is required though to manually
trigger validation runs, e.g. when programmatically altering values.
@instance
@memberof LuCI.ui.AbstractElement | triggerValidation | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
registerEvents(targetNode, synevent, events) {
const dispatchFn = L.bind((ev) => {
this.node.dispatchEvent(new CustomEvent(synevent, { bubbles: true }));
}, this);
for (let i = 0; i < events.length; i++)
targetNode.addEventListener(events[i], dispatchFn);
} | Dispatch a custom (synthetic) event in response to received events.
Sets up event handlers on the given target DOM node for the given event
names that dispatch a custom event of the given type to the widget root
DOM node.
The primary purpose of this function is to set up a series of custom
uniform standard events suc... | registerEvents | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
setUpdateEvents(targetNode, ...events) {
const datatype = this.options.datatype;
const optional = this.options.hasOwnProperty('optional') ? this.options.optional : true;
const validate = this.options.validate;
this.registerEvents(targetNode, 'widget-update', events);
if (!datatype && !validate)
return;
... | Set up listeners for native DOM events that may update the widget value.
Sets up event handlers on the given target DOM node for the given event
names which may cause the input value to update, such as `keyup` or
`onclick` events. In contrast to change events, such update events will
trigger input value validation.
@... | setUpdateEvents | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
setChangeEvents(targetNode, ...events) {
const tag_changed = L.bind(function(ev) { this.setAttribute('data-changed', true) }, this.node);
for (let i = 0; i < events.length; i++)
targetNode.addEventListener(events[i], tag_changed);
this.registerEvents(targetNode, 'widget-change', events);
} | Set up listeners for native DOM events that may change the widget value.
Sets up event handlers on the given target DOM node for the given event
names which may cause the input value to change completely, such as
`change` events in a select menu. In contrast to update events, such
change events will not trigger input ... | setChangeEvents | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
__init__(value, options) {
this.value = value;
this.options = Object.assign({
optional: true,
password: false
}, options);
} | In addition to the [AbstractElement.InitOptions]{@link LuCI.ui.AbstractElement.InitOptions}
the following properties are recognized:
@typedef {LuCI.ui.AbstractElement.InitOptions} InitOptions
@memberof LuCI.ui.Textfield
@property {boolean} [password=false]
Specifies whether the input should be rendered as concealed p... | __init__ | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
__init__(value, options) {
this.value = value;
this.options = Object.assign({
optional: true,
wrap: false,
cols: null,
rows: null
}, options);
} | In addition to the [AbstractElement.InitOptions]{@link LuCI.ui.AbstractElement.InitOptions}
the following properties are recognized:
@typedef {LuCI.ui.AbstractElement.InitOptions} InitOptions
@memberof LuCI.ui.Textarea
@property {boolean} [readonly=false]
Specifies whether the input widget should be rendered readonly... | __init__ | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
__init__(value, options) {
this.value = value;
this.options = Object.assign({
value_enabled: '1',
value_disabled: '0'
}, options);
} | In addition to the [AbstractElement.InitOptions]{@link LuCI.ui.AbstractElement.InitOptions}
the following properties are recognized:
@typedef {LuCI.ui.AbstractElement.InitOptions} InitOptions
@memberof LuCI.ui.Checkbox
@property {string} [value_enabled=1]
Specifies the value corresponding to a checked checkbox.
@pro... | __init__ | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
isChecked() {
return this.node.querySelector('input[type="checkbox"]').checked;
} | Test whether the checkbox is currently checked.
@instance
@memberof LuCI.ui.Checkbox
@returns {boolean}
Returns `true` when the checkbox is currently checked, otherwise `false`. | isChecked | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
__init__(value, choices, options) {
if (!L.isObject(choices))
choices = {};
if (!Array.isArray(value))
value = (value != null && value != '') ? [ value ] : [];
if (!options.multiple && value.length > 1)
value.length = 1;
this.values = value;
this.choices = choices;
this.options = Object.assign({... | In addition to the [AbstractElement.InitOptions]{@link LuCI.ui.AbstractElement.InitOptions}
the following properties are recognized:
@typedef {LuCI.ui.AbstractElement.InitOptions} InitOptions
@memberof LuCI.ui.Select
@property {boolean} [multiple=false]
Specifies whether multiple choice values may be selected.
@prop... | __init__ | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
__init__(value, choices, options) {
if (typeof(choices) != 'object')
choices = {};
if (!Array.isArray(value))
this.values = (value != null && value != '') ? [ value ] : [];
else
this.values = value;
this.choices = choices;
this.options = Object.assign({
sort: true,
multiple: ... | In addition to the [AbstractElement.InitOptions]{@link LuCI.ui.AbstractElement.InitOptions}
the following properties are recognized:
@typedef {LuCI.ui.AbstractElement.InitOptions} InitOptions
@memberof LuCI.ui.Dropdown
@property {boolean} [optional=true]
Specifies whether the dropdown selection is optional. In contra... | __init__ | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
clearChoices(reset_value) {
const ul = this.node.querySelector('ul');
const lis = ul ? ul.querySelectorAll('li[data-value]') : [];
const len = lis.length - (this.options.create ? 1 : 0);
const val = reset_value ? null : this.getValue();
for (let i = 0; i < len; i++) {
const lival = lis[i].getAttribute('da... | Remove all existing choices from the dropdown menu.
This function removes all preexisting dropdown choices from the widget,
keeping only choices currently being selected unless `reset_values` is
given, in which case all choices and deselected and removed.
@instance
@memberof LuCI.ui.Dropdown
@param {boolean} [reset_v... | clearChoices | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
addChoices(values, labels) {
const sb = this.node;
const ul = sb.querySelector('ul');
const lis = ul ? ul.querySelectorAll('li[data-value]') : [];
if (!Array.isArray(values))
values = L.toArray(values);
if (!L.isObject(labels))
labels = {};
for (let i = 0; i < values.length; i++) {
let found = f... | Add new choices to the dropdown menu.
This function adds further choices to an existing dropdown menu,
ignoring choice values which are already present.
@instance
@memberof LuCI.ui.Dropdown
@param {string[]} values
The choice values to add to the dropdown widget.
@param {Object<string, *>} labels
The choice label va... | addChoices | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
closeAllDropdowns() {
document.querySelectorAll('.cbi-dropdown[open]').forEach(s => {
s.dispatchEvent(new CustomEvent('cbi-dropdown-close', {}));
});
} | Close all open dropdown widgets in the current document. | closeAllDropdowns | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
__init__(value, choices, options) {
this.super('__init__', [ value, choices, Object.assign({
select_placeholder: _('-- Please choose --'),
custom_placeholder: _('-- custom --'),
dropdown_items: -1,
sort: true
}, options, {
multiple: false,
create: true,
optional: true
}) ]);
} | Comboboxes support the same properties as
[Dropdown.InitOptions]{@link LuCI.ui.Dropdown.InitOptions} but enforce
specific values for the following properties:
@typedef {LuCI.ui.Dropdown.InitOptions} InitOptions
@memberof LuCI.ui.Combobox
@property {boolean} multiple=false
Since Comboboxes never allow selecting multip... | __init__ | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
__init__(value, choices, options) {
this.super('__init__', [ value, choices, Object.assign({
sort: true
}, options, {
multiple: false,
create: false,
optional: false
}) ]);
} | ComboButtons support the same properties as
[Dropdown.InitOptions]{@link LuCI.ui.Dropdown.InitOptions} but enforce
specific values for some properties and add additional button specific
properties.
@typedef {LuCI.ui.Dropdown.InitOptions} InitOptions
@memberof LuCI.ui.ComboButton
@property {boolean} multiple=false
Sin... | __init__ | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
__init__(values, choices, options) {
if (!Array.isArray(values))
values = (values != null && values != '') ? [ values ] : [];
if (typeof(choices) != 'object')
choices = null;
this.values = values;
this.choices = choices;
this.options = Object.assign({}, options, {
multiple: false,
optional: true... | In case choices are passed to the dynamic list constructor, the widget
supports the same properties as [Dropdown.InitOptions]{@link LuCI.ui.Dropdown.InitOptions}
but enforces specific values for some dropdown properties.
@typedef {LuCI.ui.Dropdown.InitOptions} InitOptions
@memberof LuCI.ui.DynamicList
@property {bool... | __init__ | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
addChoices(values, labels) {
const dl = this.node.lastElementChild.firstElementChild;
dom.callClassMethod(dl, 'addChoices', values, labels);
} | Add new suggested choices to the dynamic list.
This function adds further choices to an existing dynamic list,
ignoring choice values which are already present.
@instance
@memberof LuCI.ui.DynamicList
@param {string[]} values
The choice values to add to the dynamic lists suggestion dropdown.
@param {Object<string, *... | addChoices | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
clearChoices() {
const dl = this.node.lastElementChild.firstElementChild;
dom.callClassMethod(dl, 'clearChoices');
} | Remove all existing choices from the dynamic list.
This function removes all preexisting suggested choices from the widget.
@instance
@memberof LuCI.ui.DynamicList | clearChoices | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
__init__(value, options) {
this.value = value;
this.options = Object.assign({
browser: false,
show_hidden: false,
enable_upload: true,
enable_remove: true,
enable_download: false,
root_directory: '/etc/luci-uploads'
}, options);
} | In addition to the [AbstractElement.InitOptions]{@link LuCI.ui.AbstractElement.InitOptions}
the following properties are recognized:
@typedef {LuCI.ui.AbstractElement.InitOptions} InitOptions
@memberof LuCI.ui.FileUpload
@property {boolean} [browser=false]
Use a file browser mode.
@property {boolean} [show_hidden=fa... | __init__ | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
load() {
if (this.menu == null)
this.menu = session.getLocalData('menu');
if (!L.isObject(this.menu)) {
this.menu = request.get(L.url('admin/menu')).then(L.bind((menu) => {
this.menu = scrubMenu(menu.json());
session.setLocalData('menu', this.menu);
return this.menu;
}, this));
}
return ... | Load and cache current menu tree.
@returns {Promise<LuCI.ui.menu.MenuNode>}
Returns a promise resolving to the root element of the menu tree. | load | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
flushCache() {
session.setLocalData('menu', null);
} | Flush the internal menu cache to force loading a new structure on the
next page load. | flushCache | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
showModal(title, children, ...classes) {
const dlg = modalDiv.firstElementChild;
dlg.setAttribute('class', 'modal');
dlg.classList.add(...classes);
dom.content(dlg, dom.create('h4', {}, title));
dom.append(dlg, children);
document.body.classList.add('modal-overlay-active');
modalDiv.scrollTop = 0;
mo... | Display a modal overlay dialog with the specified contents.
The modal overlay dialog covers the current view preventing interaction
with the underlying view contents. Only one modal dialog instance can
be opened. Invoking showModal() while a modal dialog is already open will
replace the open dialog with a new one havi... | showModal | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
hideModal() {
document.body.classList.remove('modal-overlay-active');
modalDiv.blur();
} | Close the open modal overlay dialog.
This function will close an open modal dialog and restore the normal view
behaviour. It has no effect if no modal dialog is currently open.
Note that this function is stand-alone, it does not rely on `this` and
will not invoke other class functions so it is suitable to be used as ... | hideModal | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
addNotification(title, children, ...classes) {
const mc = document.querySelector('#maincontent') ?? document.body;
const msg = E('div', {
'class': 'alert-message fade-in',
'style': 'display:flex',
'transitionend': function(ev) {
const node = ev.currentTarget;
if (node.parentNode && node.classList.c... | Add a notification banner at the top of the current view.
A notification banner is an alert message usually displayed at the
top of the current view, spanning the entire available width.
Notification banners will stay in place until dismissed by the user.
Multiple banners may be shown at the same time.
Additional CSS... | addNotification | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
hideIndicator(id) {
const indicatorElem = indicatorDiv ? indicatorDiv.querySelector('span[data-indicator="%s"]'.format(id)) : null;
if (indicatorElem == null)
return false;
indicatorDiv.removeChild(indicatorElem);
return true;
} | Remove a header area indicator.
This function removes the given indicator label from the header indicator
area. When the given indicator is not found, this function does nothing.
@param {string} id
The ID of the indicator to remove.
@returns {boolean}
Returns `true` when the indicator has been removed or `false` whe... | hideIndicator | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
initTabGroup(panes) {
if (typeof(panes) != 'object' || !('length' in panes) || panes.length === 0)
return;
const menu = E('ul', { 'class': 'cbi-tabmenu' });
const group = panes[0].parentNode;
const groupId = +group.getAttribute('data-tab-group');
let selected = null;
if (group.getAttribute('data... | Initializes a new tab group from the given tab pane collection.
This function cycles through the given tab pane DOM nodes, extracts
their tab IDs, titles and active states, renders a corresponding
tab menu and prepends it to the tab panes common parent DOM node.
The tab menu labels will be set to the value of the `da... | initTabGroup | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
isEmptyPane(pane) {
return dom.isEmpty(pane, n => n.classList.contains('cbi-tab-descr'));
} | Checks whether the given tab pane node is empty.
@instance
@memberof LuCI.ui.tabs
@param {Node} pane
The tab pane to check.
@returns {boolean}
Returns `true` if the pane is empty, else `false`. | isEmptyPane | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
change(ev) {
const modal = dom.parent(ev.target, '.modal');
const body = modal.querySelector('p');
const upload = modal.querySelector('.cbi-button-action.important');
const file = ev.currentTarget.files[0];
if (file == null)
return;
dom.content(body, [
... | Display a modal file upload prompt.
This function opens a modal dialog prompting the user to select and
upload a file to a predefined remote destination path.
@param {string} path
The remote file path to upload the local file to.
@param {Node} [progressStatusNode]
An optional DOM text node whose content text is set ... | change | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
pingDevice(proto, ipaddr) {
const target = '%s://%s%s?%s'.format(proto ?? 'http', ipaddr ?? window.location.host, L.resource('icons/loading.svg'), Math.random());
return new Promise((resolveFn, rejectFn) => {
const img = new Image();
img.onload = resolveFn;
img.onerror = rejectFn;
window.setTimeout(r... | Perform a device connectivity test.
Attempt to fetch a well known resource from the remote device via HTTP
in order to test connectivity. This function is mainly useful to wait
for the router to come back online after a reboot or reconfiguration.
@param {string} [proto=http]
The protocol to use for fetching the resou... | pingDevice | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
init() {
if (!L.env.sessionid)
return;
return uci.changes().then(L.bind(this.renderChangeIndicator, this));
} | @class
@memberof LuCI.ui
@hideconstructor
@classdesc
The `changes` class encapsulates logic for visualizing, applying,
confirming and reverting staged UCI changesets.
This class is automatically instantiated as part of `LuCI.ui`. To use it
in views, use `'require ui'` and refer to `ui.changes`. To import it in
extern... | init | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
setIndicator(n) {
if (n > 0) {
UI.prototype.showIndicator('uci-changes',
'%s: %d'.format(_('Unsaved Changes'), n),
L.bind(this.displayChanges, this));
}
else {
UI.prototype.hideIndicator('uci-changes');
}
} | Set the change count indicator.
This function updates or hides the UCI change count indicator,
depending on the passed change count. When the count is greater
than 0, the change indicator is displayed or updated, otherwise it
is removed.
@instance
@memberof LuCI.ui.changes
@param {number} n
The number of changes to i... | setIndicator | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
renderChangeIndicator(changes) {
let n_changes = 0;
for (const config in changes)
if (changes.hasOwnProperty(config))
n_changes += changes[config].length;
this.changes = changes;
this.setIndicator(n_changes);
} | Update the change count indicator.
This function updates the UCI change count indicator from the given
UCI changeset structure.
@instance
@memberof LuCI.ui.changes
@param {Object<string, Array<LuCI.uci.ChangeRecord>>} changes
The UCI changeset to count. | renderChangeIndicator | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
displayChanges() {
const list = E('div', { 'class': 'uci-change-list' });
const dlg = UI.prototype.showModal(`${_('Configuration')} / ${_('Changes')}`, [
E('div', { 'class': 'cbi-section' }, [
E('strong', _('Legend:')),
E('div', { 'class': 'uci-change-legend' }, [
E('div', { 'class': 'uci-change-... | Display the current changelog.
Open a modal dialog visualizing the currently staged UCI changes
and offer options to revert or apply the shown changes.
@instance
@memberof LuCI.ui.changes | displayChanges | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
createHandlerFn(ctx, fn, ...args) {
if (typeof(fn) == 'string')
fn = ctx[fn];
if (typeof(fn) != 'function')
return null;
return L.bind(function() {
const t = arguments[args.length].currentTarget;
t.classList.add('spinning');
t.disabled = true;
if (t.blur)
t.blur();
Promise.resolve(fn... | Create a pre-bound event handler function.
Generate and bind a function suitable for use in event handlers. The
generated function automatically disables the event source element
and adds an active indication to it by adding appropriate CSS classes.
It will also await any promises returned by the wrapped function and... | createHandlerFn | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
instantiateView(path) {
const className = 'view.%s'.format(path.replace(/\//g, '.'));
return L.require(className).then(view => {
if (!(view instanceof View))
throw new TypeError('Loaded class %s is not a descendant of View'.format(className));
return view;
}).catch(err => {
dom.content(document.que... | Load specified view class path and set it up.
Transforms the given view path into a class name, requires it
using [LuCI.require()]{@link LuCI#require} and asserts that the
resulting class instance is a descendant of
[LuCI.view]{@link LuCI.view}.
By instantiating the view class, its corresponding contents are
rendered... | instantiateView | javascript | openwrt/luci | modules/luci-base/htdocs/luci-static/resources/ui.js | https://github.com/openwrt/luci/blob/master/modules/luci-base/htdocs/luci-static/resources/ui.js | Apache-2.0 |
function mixin(target, source, overlay) {
target = 'prototype' in target ? target.prototype : target;
source = 'prototype' in source ? source.prototype : source;
defaults(target, source, overlay);
} | @memberOf module:zrender/core/util
@param {Object|Function} target
@param {Object|Function} sorce
@param {boolean} overlay | mixin | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function assert$1(condition, message) {
if (!condition) {
throw new Error(message);
}
} | @memberOf module:zrender/core/util
@param {string} str string to be trimed
@return {string} trimed string | assert$1 | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
Eventful = function (eventProcessor) {
this._$handlers = {};
this._$eventProcessor = eventProcessor;
} | The handler can only be triggered once, then removed.
@param {string} event The event name.
@param {string|Object} [query] Condition used on event filter.
@param {Function} handler The event handler.
@param {Object} context | Eventful | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function normalizeQuery(host, query) {
var eventProcessor = host._$eventProcessor;
if (query != null && eventProcessor && eventProcessor.normalizeQuery) {
query = eventProcessor.normalizeQuery(query);
}
return query;
} | Dispatch a event with context, which is specified at the last parameter.
@param {string} type The event name. | normalizeQuery | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function determinant(rows, rank, rowStart, rowMask, colMask, detCache) {
var cacheKey = rowMask + '-' + colMask;
var fullRank = rows.length;
if (detCache.hasOwnProperty(cacheKey)) {
return detCache[cacheKey];
}
if (rank === 1) {
// In this case the colMask must be like: `11101111`.... | The algoritm is learnt from
https://franklinta.com/2014/09/08/computing-css-matrix3d-transforms/
And we made some optimization for matrix inversion.
Other similar approaches:
"cv::getPerspectiveTransform", "Direct Linear Transformation". | determinant | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function buildTransformer(src, dest) {
var mA = [
[src[0], src[1], 1, 0, 0, 0, -dest[0] * src[0], -dest[0] * src[1]],
[0, 0, 0, src[0], src[1], 1, -dest[1] * src[0], -dest[1] * src[1]],
[src[2], src[3], 1, 0, 0, 0, -dest[2] * src[2], -dest[2] * src[3]],
[0, 0, 0, src[2], src[3], 1, -... | Usage:
```js
var transformer = buildTransformer(
[10, 44, 100, 44, 100, 300, 10, 300],
[50, 54, 130, 14, 140, 330, 14, 220]
);
var out = [];
transformer && transformer([11, 33], out);
```
Notice: `buildTransformer` may take more than 10ms in some Android device.
@param {Array.<number>} src source four points,... | buildTransformer | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function transformLocalCoord(out, elFrom, elTarget, inX, inY) {
return transformCoordWithViewport(_calcOut$1, elFrom, inX, inY, true)
&& transformCoordWithViewport(out, elTarget, _calcOut$1[0], _calcOut$1[1]);
} | Transform "local coord" from `elFrom` to `elTarget`.
"local coord": the coord based on the input `el`. The origin point is at
the position of "left: 0; top: 0;" in the `el`.
Support when CSS transform is used.
Having the `out` (that is, `[outX, outY]`), we can create an DOM element
and set the CSS style as "left:... | transformLocalCoord | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function transformCoordWithViewport(out, el, inX, inY, inverse) {
if (el.getBoundingClientRect && env$1.domSupported && !isCanvasEl(el)) {
var saved = el[EVENT_SAVED_PROP] || (el[EVENT_SAVED_PROP] = {});
var markers = prepareCoordMarkers(el, saved);
var transformer = preparePointerTransforme... | Transform between a "viewport coord" and a "local coord".
"viewport coord": the coord based on the left-top corner of the viewport
of the browser.
"local coord": the coord based on the input `el`. The origin point is at
the position of "left: 0; top: 0;" in the `el`.
Support the case when CSS transform is used... | transformCoordWithViewport | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function isCanvasEl(el) {
return el.nodeName.toUpperCase() === 'CANVAS';
} | Utilities for mouse or touch events. | isCanvasEl | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function clientToLocal(el, e, out, calculate) {
out = out || {};
// According to the W3C Working Draft, offsetX and offsetY should be relative
// to the padding edge of the target element. The only browser using this convention
// is IE. Webkit uses the border edge, Opera uses the content edge, and Fir... | Get the `zrX` and `zrY`, which are relative to the top-left of
the input `el`.
CSS transform (2D & 3D) is supported.
The strategy to fetch the coords:
+ If `calculate` is not set as `true`, users of this method should
ensure that `el` is the same or the same size & location as `e.target`.
Otherwise the result coords a... | clientToLocal | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function getNativeEvent(e) {
return e || window.event;
} | Find native event compat for legency IE.
Should be called at the begining of a native event listener.
@param {Event} [e] Mouse event or touch event or pointer event.
For lagency IE, we use `window.event` is used.
@return {Event} The native event. | getNativeEvent | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function normalizeEvent(el, e, calculate) {
e = getNativeEvent(e);
if (e.zrX != null) {
return e;
}
var eventType = e.type;
var isTouch = eventType && eventType.indexOf('touch') >= 0;
if (!isTouch) {
clientToLocal(el, e, e, calculate);
e.zrDelta = (e.wheelDelta) ? e.w... | Normalize the coordinates of the input event.
Get the `e.zrX` and `e.zrY`, which are relative to the top-left of
the input `el`.
Get `e.zrDelta` if using mouse wheel.
Get `e.which`, see the comment inside this function.
Do not calculate repeatly if `zrX` and `zrY` already exist.
Notice: see comments in `clientToLoca... | normalizeEvent | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function addEventListener(el, name, handler, opt) {
if (isDomLevel2) {
// Reproduct the console warning:
// [Violation] Added non-passive event listener to a scroll-blocking <some> event.
// Consider marking event handler as 'passive' to make the page more responsive.
// Just set con... | @param {HTMLElement} el
@param {string} name
@param {Function} handler
@param {Object|boolean} opt If boolean, means `opt.capture`
@param {boolean} [opt.capture=false]
@param {boolean} [opt.passive=false] | addEventListener | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function removeEventListener(el, name, handler, opt) {
if (isDomLevel2) {
el.removeEventListener(name, handler, opt);
}
else {
el.detachEvent('on' + name, handler);
}
} | preventDefault and stopPropagation.
Notice: do not use this method in zrender. It can only be
used by upper applications if necessary.
@param {Event} e A mouse or touch event. | removeEventListener | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function makeEventPacket(eveType, targetInfo, event) {
return {
type: eveType,
event: event,
// target can only be an element that is not silent.
target: targetInfo.target,
// topTarget can be a silent element.
topTarget: targetInfo.topTarget,
cancelBubble: fa... | [Drag outside]:
That is, triggering `mousemove` and `mouseup` event when the pointer is out of the
zrender area when dragging. That is important for the improvement of the user experience
when dragging something near the boundary without being terminated unexpectedly.
We originally consider to introduce new events li... | makeEventPacket | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function invert(out, a) {
var aa = a[0];
var ac = a[2];
var atx = a[4];
var ab = a[1];
var ad = a[3];
var aty = a[5];
var det = aa * ad - ab * ac;
if (!det) {
return null;
}
det = 1.0 / det;
out[0] = ad * det;
out[1] = -ab * det;
out[2] = -ac * det;
out... | Clone a new matrix.
@param {Float32Array|Array.<number>} a | invert | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function clone$2(a) {
var b = create$1();
copy$1(b, a);
return b;
} | @alias module:zrender/mixin/Transformable
@constructor | clone$2 | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function lift(color, level) {
var colorArr = parse(color);
if (colorArr) {
for (var i = 0; i < 3; i++) {
if (level < 0) {
colorArr[i] = colorArr[i] * (1 - level) | 0;
}
else {
colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | ... | Map value to color. Faster than lerp methods because color is represented by rgba array.
@param {number} normalizedValue A float between 0 and 1.
@param {Array.<Array.<number>>} colors List of rgba color array
@param {Array.<number>} [out] Mapped gba color array
@return {Array.<number>} will be null/undefined if input ... | lift | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function lerp$1(normalizedValue, colors, fullOutput) {
if (!(colors && colors.length)
|| !(normalizedValue >= 0 && normalizedValue <= 1)
) {
return;
}
var value = normalizedValue * (colors.length - 1);
var leftIndex = Math.floor(value);
var rightIndex = Math.ceil(value);
var... | @param {string} color
@param {number=} h 0 ~ 360, ignore when null.
@param {number=} s 0 ~ 1, ignore when null.
@param {number=} l 0 ~ 1, ignore when null.
@return {string} Color string in rgba format.
@memberOf module:zrender/util/color | lerp$1 | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function modifyAlpha(color, alpha) {
color = parse(color);
if (color && alpha != null) {
color[3] = clampCssFloat(alpha);
return stringify(color, 'rgba');
}
} | @param {string} p0
@param {string} p1
@param {number} percent
@return {string} | modifyAlpha | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function animateTo(animatable, target, time, delay, easing, callback, forceAnimate, reverse) {
// animateTo(target, time, easing, callback);
if (isString(delay)) {
callback = easing;
easing = delay;
delay = 0;
}
// animateTo(target, time, delay, callback);
else if (isFunction... | Animate from the target state to current state.
The params and the return value are the same as `this.animateTo`. | animateTo | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function done() {
count--;
if (!count) {
callback && callback();
}
} | @param {string} path=''
@param {Object} source=animatable
@param {Object} target
@param {number} [time=500]
@param {number} [delay=0]
@param {boolean} [reverse] If `true`, animate
from the `target` to current state.
@example
// Animate position
el._animateToShallow({
position: [10, 10]
})
// Animate s... | done | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function createRadialGradient(ctx, obj, rect) {
var width = rect.width;
var height = rect.height;
var min = Math.min(width, height);
var x = obj.x == null ? 0.5 : obj.x;
var y = obj.y == null ? 0.5 : obj.y;
var r = obj.r == null ? 0.5 : obj.r;
if (!obj.global) {
x = x * width + rect... | It helps merging respectively, rather than parsing an entire font string.
@type {string} | createRadialGradient | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function findExistImage(newImageOrSrc) {
if (typeof newImageOrSrc === 'string') {
var cachedImgObj = globalImageCache.get(newImageOrSrc);
return cachedImgObj && cachedImgObj.image;
}
else {
return newImageOrSrc;
}
} | Caution: User should cache loaded images, but not just count on LRU.
Consider if required images more than LRU size, will dead loop occur?
@param {string|HTMLImageElement|HTMLCanvasElement|Canvas} newImageOrSrc
@param {HTMLImageElement|HTMLCanvasElement|Canvas} image Existent image.
@param {module:zrender/Element} [ho... | findExistImage | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function getPlainTextRect(text, font, textAlign, textVerticalAlign, textPadding, textLineHeight, truncate) {
var contentBlock = parsePlainText(text, font, textPadding, textLineHeight, truncate);
var outerWidth = getWidth(text, font);
if (textPadding) {
outerWidth += textPadding[1] + textPadding[3];
... | Follow same interface to `Displayable.prototype.calculateTextPosition`.
@public
@param {Obejct} [out] Prepared out object. If not input, auto created in the method.
@param {module:zrender/graphic/Style} style where `textPosition` and `textDistance` are visited.
@param {Object} rect {x, y, width, height} Rect of the hos... | getPlainTextRect | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function truncateSingleLine(textLine, options) {
var containerWidth = options.containerWidth;
var font = options.font;
var contentWidth = options.contentWidth;
if (!containerWidth) {
return '';
}
var lineWidth = getWidth(textLine, font);
if (lineWidth <= containerWidth) {
... | @public
@param {string} text
@param {string} font
@param {Object} [truncate]
@return {Object} block: {lineHeight, lines, height, outerHeight, canCacheByTextString}
Notice: for performance, do not calculate outerWidth util needed.
`canCacheByTextString` means the result `lines` is only determined by the input `text`.
... | truncateSingleLine | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function pushTokens(block, str, styleName) {
var isEmptyStr = str === '';
var strs = str.split('\n');
var lines = block.lines;
for (var i = 0; i < strs.length; i++) {
var text = strs[i];
var token = {
styleName: styleName,
text: text,
isLineHolder: !t... | @param {Object} ctx
@param {Object} shape
@param {number} shape.x
@param {number} shape.y
@param {number} shape.width
@param {number} shape.height
@param {number} shape.r | pushTokens | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function normalizeTextStyle(style) {
normalizeStyle(style);
each$1(style.rich, normalizeStyle);
return style;
} | @param {CanvasRenderingContext2D} ctx
@param {string} text
@param {module:zrender/graphic/Style} style
@param {Object|boolean} [rect] {x, y, width, height}
If set false, rect text is not used.
@param {Element|module:zrender/graphic/helper/constant.WILL_BE_RESTORED} [prevEl] For ctx prop cache. | normalizeTextStyle | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function setCtx(ctx, prop, value) {
ctx[prop] = fixShadow(ctx, prop, value);
return ctx[prop];
} | Draw text in a rect with specified position.
@param {CanvasRenderingContext2D} ctx
@param {Object} rect Displayable rect | setCtx | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function parsePercent(value, maxValue) {
if (typeof value === 'string') {
if (value.lastIndexOf('%') >= 0) {
return parseFloat(value) / 100 * maxValue;
}
return parseFloat(value);
}
return value;
} | Base class of all displayable graphic objects
@module zrender/graphic/Displayable | parsePercent | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function getTextXForPadding(x, textAlign, textPadding) {
return textAlign === 'right'
? (x - textPadding[1])
: textAlign === 'center'
? (x + textPadding[3] / 2 - textPadding[1] / 2)
: (x + textPadding[3]);
} | @alias module:zrender/graphic/Displayable
@extends module:zrender/Element
@extends module:zrender/graphic/mixin/RectText | getTextXForPadding | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function Displayable(opts) {
opts = opts || {};
Element.call(this, opts);
// Extend properties
for (var name in opts) {
if (
opts.hasOwnProperty(name)
&& name !== 'style'
) {
this[name] = opts[name];
}
}
/**
* @type {module... | If enable culling
@type {boolean}
@default false | Displayable | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function ZImage(opts) {
Displayable.call(this, opts);
} | @alias zrender/graphic/Image
@extends module:zrender/graphic/Displayable
@constructor
@param {Object} opts | ZImage | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function createRoot(width, height) {
var domRoot = document.createElement('div');
// domRoot.onselectstart = returnFalse; // Avoid page selected
domRoot.style.cssText = [
'position:relative',
// IOS13 safari probably has a compositing bug (z order of the canvas and the consequent
//... | zrender will do compositing when root is a canvas and have multiple zlevels. | createRoot | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
Animation = function (options) {
options = options || {};
this.stage = options.stage || {};
this.onframe = options.onframe || function () {};
// private properties
this._clips = [];
this._running = false;
this._time;
this._pausedTime;
this._pauseStart;
this._paused = fal... | Delete animation clip
@param {module:zrender/animation/Animator} animator | Animation | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function step() {
if (self._running) {
requestAnimationFrame(step);
!self._paused && self._update();
}
} | Creat animator for a target, whose props can be animated.
@param {Object} target
@param {Object} options
@param {boolean} [options.loop=false] Whether loop animation.
@param {Function} [options.getter=null] Get value from target.
@param {Function} [options.setter=null] Set value to target.
@return {module:zrender... | step | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function eventNameFix(name) {
return (name === 'mousewheel' && env$1.browser.firefox) ? 'DOMMouseScroll' : name;
} | Make a fake event but not change the original event,
becuase the global event probably be used by other
listeners not belonging to zrender.
@class | eventNameFix | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function mountLocalDOMEventListeners(instance, scope) {
var domHandlers = scope.domHandlers;
if (env$1.pointerEventsSupported) { // Only IE11+/Edge
// 1. On devices that both enable touch and mouse (e.g., MS Surface and lenovo X240),
// IE11+/Edge do not trigger touch event, but trigger pointer... | @param {HandlerProxy} instance
@param {DOMHandlerScope} scope | mountLocalDOMEventListeners | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function mountGlobalDOMEventListeners(instance, scope) {
// Only IE11+/Edge. See the comment in `mountLocalDOMEventListeners`.
if (env$1.pointerEventsSupported) {
each$1(globalNativeListenerNames.pointer, mount);
}
// Touch event has implemented "drag outside" so we do not mount global listener ... | See [Drag Outside] in `Handler.js`.
@implement
@param {boolean} isPointerCapturing Should never be `null`/`undefined`.
`true`: start to capture pointer if it is not capturing.
`false`: end the capture if it is capturing. | mountGlobalDOMEventListeners | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function normalizeToArray(value) {
return value instanceof Array
? value
: value == null
? []
: [value];
} | data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}]
This helper method determine if dataItem has extra option besides value
@param {string|number|Date|Array|Object} dataItem | normalizeToArray | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function defaultEmphasis(opt, key, subOpts) {
// Caution: performance sensitive.
if (opt) {
opt[key] = opt[key] || {};
opt.emphasis = opt.emphasis || {};
opt.emphasis[key] = opt.emphasis[key] || {};
// Default emphasis option from normal
for (var i = 0, len = subOpts.len... | Mapping to exists for merge.
@public
@param {Array.<Object>|Array.<module:echarts/model/Component>} exists
@param {Object|Array.<Object>} newCptOptions
@return {Array.<Object>} Result, like [{exist: ..., option: ...}, {}],
index of which is the same as exists. | defaultEmphasis | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function makeIdAndName(mapResult) {
// We use this id to hash component models and view instances
// in echarts. id can be specified by user, or auto generated.
// The id generation rule ensures new view instance are able
// to mapped to old instance when setOption are called in
// no-merge mode. S... | @public
@param {Object} cptOption
@return {boolean} | makeIdAndName | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function isNameSpecified(componentModel) {
var name = componentModel.name;
// Is specified when `indexOf` get -1 or > 0.
return !!(name && name.indexOf(DUMMY_COMPONENT_NAME_PREFIX));
} | Enable property storage to any host object.
Notice: Serialization is not supported.
For example:
var inner = zrUitl.makeInner();
function some1(hostObj) {
inner(hostObj).someProperty = 1212;
...
}
function some2() {
var fields = inner(this);
fields.someProperty1 = 1212;
fields.someProperty2 =... | isNameSpecified | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function queryDataIndex(data, payload) {
if (payload.dataIndexInside != null) {
return payload.dataIndexInside;
}
else if (payload.dataIndex != null) {
return isArray(payload.dataIndex)
? map(payload.dataIndex, function (value) {
return data.indexOfRawIndex(value)... | @param {module:echarts/model/Global} ecModel
@param {string|Object} finder
If string, e.g., 'geo', means {geoIndex: 0}.
If Object, could contain some of these properties below:
{
seriesIndex, seriesId, seriesName,
geoIndex, geoId, geoName,
bmapIndex, bmapId, bmapNam... | queryDataIndex | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function parseFinder(ecModel, finder, opt) {
if (isString(finder)) {
var obj = {};
obj[finder + 'Index'] = 0;
finder = obj;
}
var defaultMainType = opt && opt.defaultMainType;
if (defaultMainType
&& !has(finder, defaultMainType + 'Index')
&& !has(finder, defaultM... | Group a list by key.
@param {Array} array
@param {Function} getKey
param {*} Array item
return {string} key
@return {Object} Result
{Array}: keys,
{module:zrender/core/util/HashMap} buckets: {key -> Array} | parseFinder | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function superCall(context, methodName) {
var args = slice(arguments, 2);
return this.superClass.prototype[methodName].apply(context, args);
} | @return {Array.<string>} Like ['aa', 'bb'], but can not be ['aa.xx'] | superCall | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function quadraticSubdivide(p0, p1, p2, t, out) {
var p01 = (p1 - p0) * t + p0;
var p12 = (p2 - p1) * t + p1;
var p012 = (p12 - p01) * t + p01;
// Seg0
out[0] = p0;
out[1] = p01;
out[2] = p012;
// Seg1
out[3] = p012;
out[4] = p12;
out[5] = p2;
} | @memberOf module:zrender/core/bbox
@param {number} x0
@param {number} y0
@param {number} x1
@param {number} y1
@param {Array.<number>} min
@param {Array.<number>} max | quadraticSubdivide | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function fromQuadratic(x0, y0, x1, y1, x2, y2, min$$1, max$$1) {
var quadraticExtremum$$1 = quadraticExtremum;
var quadraticAt$$1 = quadraticAt;
// Find extremities, where derivative in x dim or y dim is zero
var tx =
mathMax$3(
mathMin$3(quadraticExtremum$$1(x0, x1, x2), 1), 0
... | Path data. Stored as flat array
@type {Array.<Object>} | fromQuadratic | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function fromArc(
x, y, rx, ry, startAngle, endAngle, anticlockwise, min$$1, max$$1
) {
var vec2Min = min;
var vec2Max = max;
var diff = Math.abs(startAngle - endAngle);
if (diff % PI2 < 1e-4 && diff > 1e-4) {
// Is a circle
min$$1[0] = x - rx;
min$$1[1] = y - ry;
... | @param {CanvasRenderingContext2D} ctx
@return {module:zrender/core/PathProxy} | fromArc | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
PathProxy = function (notSaveData) {
this._saveData = !(notSaveData || false);
if (this._saveData) {
/**
* Path data. Stored as flat array
* @type {Array.<Object>}
*/
this.data = [];
}
this._ctx = null;
} | @param {number} x1
@param {number} y1
@param {number} x2
@param {number} y2
@return {module:zrender/core/PathProxy} | PathProxy | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function contain(pathData, x, y) {
return containPath(pathData, 0, false, x, y);
} | See `module:zrender/src/graphic/helper/subPixelOptimize`.
@type {boolean} | contain | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function buildPath$1(ctx, shape, closePath) {
var points = shape.points;
var smooth = shape.smooth;
if (points && points.length >= 2) {
if (smooth && smooth !== 'spline') {
var controlPoints = smoothBezier(
points, smooth, closePath, shape.smoothConstraint
);
... | Sub pixel optimize for canvas
@param {number} position Coordinate, such as x, y
@param {number} lineWidth If `null`/`undefined`/`0`, do not optimize.
@param {boolean=} positiveOrNegative Default false (negative).
@return {number} Optimized position. | buildPath$1 | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
Gradient = function (colorStops) {
this.colorStops = colorStops || [];
} | Displayable for incremental rendering. It will be rendered in a separate layer
IncrementalDisplay have two main methods. `clearDisplayables` and `addDisplayables`
addDisplayables will render the added displayables incremetally.
It use a not clearFlag to tell the painter don't clear the layer if it's the first element. | Gradient | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function extendShape(opts) {
return Path.extend(opts);
} | Sub pixel optimize line for canvas
@param {Object} param
@param {Object} [param.shape]
@param {number} [param.shape.x1]
@param {number} [param.shape.y1]
@param {number} [param.shape.x2]
@param {number} [param.shape.y2]
@param {Object} [param.style]
@param {number} [param.style.lineWidth]
@return {Object} Modified para... | extendShape | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function registerShape(name, ShapeClass) {
_customShapeMap[name] = ShapeClass;
} | Sub pixel optimize rect for canvas
@param {Object} param
@param {Object} [param.shape]
@param {number} [param.shape.x]
@param {number} [param.shape.y]
@param {number} [param.shape.width]
@param {number} [param.shape.height]
@param {Object} [param.style]
@param {number} [param.style.lineWidth]
@return {Object} Modified... | registerShape | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function getShapeClass(name) {
if (_customShapeMap.hasOwnProperty(name)) {
return _customShapeMap[name];
}
} | Sub pixel optimize for canvas
@param {number} position Coordinate, such as x, y
@param {number} lineWidth Should be nonnegative integer.
@param {boolean=} positiveOrNegative Default false (negative).
@return {number} Optimized position. | getShapeClass | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function singleEnterEmphasis(el) {
var hoverStl = el.__hoverStl;
if (!hoverStl || el.__highlighted) {
return;
}
var zr = el.__zr;
var useHoverLayer = el.useHoverLayer && zr && zr.painter.type === 'canvas';
el.__highlighted = useHoverLayer ? 'layer' : 'plain';
if (el.isGroup || (!... | Set hover style (namely "emphasis style") of element, based on the current
style of the given `el`.
This method should be called after all of the normal styles have been adopted
to the `el`. See the reason on `setHoverStyle`.
@param {module:zrender/Element} el Should not be `zrender/container/Group`.
@param {Object} [... | singleEnterEmphasis | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function setElementHoverStyle(el, hoverStl) {
// For performance consideration, it might be better to make the "hover style" only the
// difference properties from the "normal style", but not a entire copy of all styles.
hoverStl = el.__hoverStl = hoverStl !== false && (el.hoverStyle || hoverStl || {});
... | Set hover style (namely "emphasis style") of element,
based on the current style of the given `el`.
(1)
**CONSTRAINTS** for this method:
<A> This method MUST be called after all of the normal styles having been adopted
to the `el`.
<B> The input `hoverStyle` (that is, "emphasis style") MUST be the subset of the
"norma... | setElementHoverStyle | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function onElementMouseOver(e) {
!shouldSilent(this, e)
// "emphasis" event highlight has higher priority than mouse highlight.
&& !this.__highByOuter
&& traverseUpdate(this, singleEnterEmphasis);
} | @param {module:zrender/Element} el
@param {Function} [el.highDownOnUpdate] Called when state updated.
Since `setHoverStyle` has the constraint that it must be called after
all of the normal style updated, `highDownOnUpdate` is not needed to
trigger if both `fromState` and `toState` is 'normal', and... | onElementMouseOver | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function shouldSilent(el, e) {
return el.__highDownSilentOnTouch && e.zrByTouch;
} | @param {module:zrender/src/Element} el
@return {boolean} | shouldSilent | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function setHoverStyle(el, hoverStyle) {
setAsHighDownDispatcher(el, true);
traverseUpdate(el, setElementHoverStyle, hoverStyle);
} | See more info in `setTextStyleCommon`.
@param {Object|module:zrender/graphic/Style} normalStyle
@param {Object} emphasisStyle
@param {module:echarts/model/Model} normalModel
@param {module:echarts/model/Model} emphasisModel
@param {Object} opt Check `opt` of `setTextStyleCommon` to find other props.
@param {string|Func... | setHoverStyle | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function isHighDownDispatcher(el) {
return !!(el && el.__highDownDispatcher);
} | Set basic textStyle properties.
See more info in `setTextStyleCommon`.
@param {Object|module:zrender/graphic/Style} textStyle
@param {module:echarts/model/Model} model
@param {Object} [specifiedTextStyle] Can be overrided by settings in model.
@param {Object} [opt] See `opt` of `setTextStyleCommon`.
@param {boolean} [i... | isHighDownDispatcher | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function setLabelStyle(
normalStyle, emphasisStyle,
normalModel, emphasisModel,
opt,
normalSpecified, emphasisSpecified
) {
opt = opt || EMPTY_OBJ;
var labelFetcher = opt.labelFetcher;
var labelDataIndex = opt.labelDataIndex;
var labelDimIndex = opt.labelDimIndex;
// This scenario, ... | Set text option in the style.
See more info in `setTextStyleCommon`.
@deprecated
@param {Object} textStyle
@param {module:echarts/model/Model} labelModel
@param {string|boolean} defaultColor Default text color.
If set as false, it will be processed as a emphasis style. | setLabelStyle | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
function modifyLabelStyle(el, normalStyleProps, emphasisStyleProps) {
var elStyle = el.style;
if (normalStyleProps) {
rollbackDefaultTextStyle(elStyle);
el.setStyle(normalStyleProps);
applyDefaultTextStyle(elStyle);
}
elStyle = el.__hoverStl;
if (emphasisStyleProps && elStyle... | The uniform entry of set text style, that is, retrieve style definitions
from `model` and set to `textStyle` object.
Never in merge mode, but in overwrite mode, that is, all of the text style
properties will be set. (Consider the states of normal and emphasis and
default value can be adopted, merge would make the logi... | modifyLabelStyle | javascript | douyu/juno | assets/public/js/echarts/v4.7.0/echarts-en.common.js | https://github.com/douyu/juno/blob/master/assets/public/js/echarts/v4.7.0/echarts-en.common.js | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.