diff --git a/classes/pref/filters.php b/classes/pref/filters.php index 681f197cd..dba2568f2 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -964,19 +964,18 @@ class Pref_Filters extends Handler_Protected { print "
"; - print ""; + print ""; print "
"; print "
"; - print "
"; diff --git a/classes/rssutils.php b/classes/rssutils.php index 831ac1baf..87e194603 100755 --- a/classes/rssutils.php +++ b/classes/rssutils.php @@ -1343,6 +1343,7 @@ class RSSUtils { foreach ($filter["rules"] as $rule) { $match = false; $reg_exp = str_replace('/', '\/', $rule["reg_exp"]); + $reg_exp = str_replace("\n", "", $reg_exp); // reg_exp may be formatted with CRs now because of textarea, we need to strip those $rule_inverse = $rule["inverse"]; if (!$reg_exp) diff --git a/js/CommonFilters.js b/js/CommonFilters.js index a06905e01..53573b365 100644 --- a/js/CommonFilters.js +++ b/js/CommonFilters.js @@ -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; diff --git a/js/form/ValidationTextArea.js b/js/form/ValidationTextArea.js new file mode 100644 index 000000000..a7993f716 --- /dev/null +++ b/js/form/ValidationTextArea.js @@ -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: "", + 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*/ + } + }) + }); diff --git a/js/prefs.js b/js/prefs.js index 944e49258..96fcbd948 100755 --- a/js/prefs.js +++ b/js/prefs.js @@ -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) {