mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 17:56:34 +00:00
add validationtextarea control, use it for filter match editor
This commit is contained in:
@@ -2,24 +2,6 @@
|
||||
/* global __, ngettext */
|
||||
define(["dojo/_base/declare"], function (declare) {
|
||||
Filters = {
|
||||
filterDlgCheckRegExp: function(sender) {
|
||||
const tooltip = dijit.byId("filterDlg_regExp_tip").domNode;
|
||||
|
||||
try {
|
||||
sender.domNode.removeClassName("invalid");
|
||||
sender.domNode.removeClassName("valid");
|
||||
|
||||
new RegExp("/" + sender.value + "/");
|
||||
|
||||
sender.domNode.addClassName("valid");
|
||||
tooltip.innerText = __("Regular expression, without outer delimiters (i.e. slashes)");
|
||||
|
||||
} catch (e) {
|
||||
sender.domNode.addClassName("invalid");
|
||||
|
||||
tooltip.innerText = e.message;
|
||||
}
|
||||
},
|
||||
filterDlgCheckAction: function(sender) {
|
||||
const action = sender.value;
|
||||
|
||||
|
||||
33
js/form/ValidationTextArea.js
Normal file
33
js/form/ValidationTextArea.js
Normal file
@@ -0,0 +1,33 @@
|
||||
// https://stackoverflow.com/questions/19317258/how-to-use-dijit-textarea-validation-dojo-1-9
|
||||
|
||||
define(["dojo/_base/declare", "dojo/_base/lang", "dijit/form/SimpleTextarea", "dijit/form/ValidationTextBox"],
|
||||
function(declare, lang, SimpleTextarea, ValidationTextBox) {
|
||||
|
||||
return declare('fox.form.ValidationTextArea', [SimpleTextarea, ValidationTextBox], {
|
||||
constructor: function(params){
|
||||
this.constraints = {};
|
||||
this.baseClass += ' dijitValidationTextArea';
|
||||
},
|
||||
templateString: "<textarea ${!nameAttrSetting} data-dojo-attach-point='focusNode,containerNode,textbox' autocomplete='off'></textarea>",
|
||||
validator: function(value, constraints) {
|
||||
//console.log(this, value, constraints);
|
||||
|
||||
if (this.required && this._isEmpty(value))
|
||||
return false;
|
||||
|
||||
if (this.validregexp) {
|
||||
try {
|
||||
new RegExp("/" + value + "/");
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return value.match(new RegExp(this._computeRegexp(constraints)));
|
||||
|
||||
/*return (new RegExp("^(?:" + this._computeRegexp(constraints) + ")"+(this.required?"":"?")+"$",["m"])).test(value) &&
|
||||
(!this.required || !this._isEmpty(value)) &&
|
||||
(this._isEmpty(value) || this.parse(value, constraints) !== undefined); // Boolean*/
|
||||
}
|
||||
})
|
||||
});
|
||||
@@ -55,6 +55,7 @@ require(["dojo/_base/kernel",
|
||||
"fox/PrefFilterTree",
|
||||
"fox/PrefLabelTree",
|
||||
"fox/Toolbar",
|
||||
"fox/form/ValidationTextArea",
|
||||
"fox/form/Select",
|
||||
"fox/form/ComboButton",
|
||||
"fox/form/DropDownButton"], function (dojo, declare, ready, parser, AppBase) {
|
||||
|
||||
Reference in New Issue
Block a user