From fe44c6bb5e7cbaf3ec7c50b4749fbf89edf7087d Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 24 Jun 2014 12:39:12 +0000 Subject: [PATCH] fixed not allways used category color, because regular expression missed every 2. category --- .../js/et2_extension_nextmatch_rowProvider.js | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/etemplate/js/et2_extension_nextmatch_rowProvider.js b/etemplate/js/et2_extension_nextmatch_rowProvider.js index e79f6bceb2..4938955824 100644 --- a/etemplate/js/et2_extension_nextmatch_rowProvider.js +++ b/etemplate/js/et2_extension_nextmatch_rowProvider.js @@ -477,6 +477,19 @@ var et2_nextmatch_rowProvider = ClassWithAttributes.extend( } }, + /** + * Match category-ids from class attribute eg. "cat_15" or "123,456,789 " + * + * Make sure to not match numbers inside other class-names. + * + * We can NOT use something like /(^| |,|cat_)([0-9]+)( |,|$)/g as it wont find all cats in "123,456,789 "! + */ + cat_regexp: /(^| |,|cat_)([0-9]+)/g, + /** + * Regular expression used to filter out non-nummerical chars from above matches + */ + cat_cleanup: /[^0-9]/g, + /** * Applies additional row data (like the class) to the tr * @@ -499,10 +512,8 @@ var et2_nextmatch_rowProvider = ClassWithAttributes.extend( var category_location = _data["class"].match(/(cat(_id|egory)?)/); if(category_location) category_location = category_location[0]; - // Get actual categories, eg. "cat_15" or "123,456,789", make sure to not match numbers inside other class-names - cats = classes.match(/(^| |,|cat_)([0-9]+)( |,|$)/g); - if (!cats) cats = []; - classes = classes.replace(/(^| |,|cat_)([0-9]+)( |,|$)/g, ''); + cats = classes.match(this.cat_regexp) || []; + classes = classes.replace(this.cat_regexp, ''); // Get category info if(!this.categories) @@ -521,8 +532,7 @@ var et2_nextmatch_rowProvider = ClassWithAttributes.extend( for(var i = 0; i < cats.length && this.categories; i++) { // Need cat_, classes can't start with a number - var cat_id = cats[i]; - cat_id = cat_id.replace(/[^0-9]/g, ''); + var cat_id = cats[i].replace(this.cat_cleanup, ''); var cat_class = 'cat_'+cat_id; // Check for existing class @@ -672,7 +682,7 @@ var et2_nextmatch_rowTemplateWidget = et2_widget.extend(et2_IDOMNode, /** * Returns the column node for the given sender - * + * * @param {et2_widget} _sender * @return {DOMElement} */