Age | Commit message (Collapse) | Author |
|
Add two new functions showModal() and hideModal() which will fade in and
close an open modal respectively.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Directly attach validation handlers to cbi dropdowns as well, this allows
validating dropdown choices made by the user, similar to how plain select
boxes are handled by the cbi JavaScript.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
In order to make cbi dropdowns usable for validation and other code
expecting native form elements, set the .value DOM property on the
dropdown parent element whenever the selection is changed.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Rework the tooltip event delegation logic to prevent hiding the tooltop
when the cursor is moved to a children of the tooltip container element.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
In order to prepare support for calling cbi validation on non-native form
widgets, remove direct usages of the node.form property and lookup the
containing form using findParent() instead.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Due to a misspelled property name, only the first value was passed in
the event details.
Fixes: c2b570998 ("luci-base: cbi.js: rework dropdown implementation")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Fixed several issues for translation.
- add translation markup to "Expecting "
- add missing ")" into "valid time (HH:MM:SS"
Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
If a given attribute value is a function, register it as event listener,
if it is an object, filter it through JSON.stringify(), else set it
as-is.
This helps to reduce some boiler-plate code when building DOM structures.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Refactor event handler closures into class methods and bind them instead
- Fix quirk in dropdown placement calculation
- Different dropdown placement strategy on touch devices
- Broadcast custom "cbi-dropdown-change" event when value is changed
- Implement setValues() method to alter dropdown selection
- Prevent creating empty custom values
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Use node.closest() in findParent() when available since it should be faster
than manaually traversing the ancestor chain.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Just use node.addEventListener() directly since all reasonably recent
browsers support it nowadays.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Refactor and fix datatype validation functions
- Turn the type compilation and validation into a proper class
- Display tooltip with error hint on invalid inputs
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
The implementation allowed a hexadecimal string without any colons.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Add the required JS and CSS infrastructure to support rich hover/focus
tooltips for element.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Implement the string hash algorithm used by LuCI's translation system in
JavaScript and provide a `_()` translation wrapper function to lookup
messages in the global string table.
Once client side translation loading is activated in a later commit,
JavaScript code can use the same string translation mechanism as server
side Lua code, e.g. `_("Static Routes")` would yield "Statische Routen"
when the German translation is loaded.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
This fixes errors reported by LGTM.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
|
|
On MS Edge, the behaviour of "value" attributes on "li" elements is
unreliable, so use the "data-" prefix to circumvent the problem.
Ref: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/19320991/
Fixes: #2224
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Remove some superfluous code which was added with a previous commit.
Fixes: 8270f10f1 ("luci-base: cbi.js: code cleanups")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- unify code style
- add matchesElem() helper
- replace nodeName checks with selector tests
- replace className manipulations with classList operations
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
This is required to allow for validating the create field values in
later commits.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Change the cbi.js code to create a div based button element instead of an
image button.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- The wifi_big.png / wifi_big_disabled.png icons were used on the wireless
overview page which now uses badges with normal sized icons
- The encryption.png / encryption_disabled.png icons were never used at all
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Some status requests can take quite some time to finish, the LuCI DSL
status information in particular.
Since the polling loop code already takes care of not relaunching
requests which are already running, increase the per iteration timeout
to up to five times the poll interval.
This should be sufficient to let most operations complete.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
JSON.parse() is supported on all modern browsers and a far better
solution than the hakish and potentially dangerous eval().
Also calculate the duration of request and pass it as 3rd argument to the
callback function, this makes it easier to calculate request delays or
poll intervals in code using XHR.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- make findParent() globally available
- add code for initializing rich cbi tooltips
- introduce cbi_update_table() helper to auto-assign responsive attributes
to table markup
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Defer the start of the queue poll loop until the document has been loaded.
This allows all XHR.poll() invocations on the page to register their
handlers before the first batch of requests is made.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
This commit introduces the required code for a new, markup based dropdown
widget which can be used as a styleable alternative to select boxes or
radio/checkbox button groups.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Add a new helper function `E()` to cbi.js which can be used to conveniently
build HTML markup.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Internet Explorer 11 requires the timeout to be applied after the open()
call, otherwise an invlaid state exception will be raised
Fixes aa6c97154 ("luci-base: extend xhr.js")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Add timeout options to get() and post() and introduce XHR.stop() to support
stopping a poll operation.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Some applications, e.g. dnsmasq, do not allow hostnames starting with an
underscore, therefor extend the existing hostname datatype validator with
a `strict` which disallows a leading underscore.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
Fixes #1413.
Reported-by: Wojciech Jowsa <wojciech.jowsa@gmail.com>
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
- Rewrite ipmask to use these subtypes
- Add ip{4,6}prefix validators to cbi.js
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
|
|
luci-base: Remove request headers that are set automatically by browser
|
|
- Properly handle logic for evaluating inverted dependencies means
when depending on another field *not* having a given value
- Perform datatype validation *after* populating combobox choices to
avoid triggering a false-positive when validating an .rmempty = false
combobox during form instantiation
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
|
|
|