From e42a062dcc9c816201a02a8a6e6d6fc3a87f54fa Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Thu, 25 Apr 2013 10:03:37 +0100 Subject: [PATCH] Fixed bug with negated title filter --- core/modules/filters.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/modules/filters.js b/core/modules/filters.js index f023a2cd6..cc5deae90 100644 --- a/core/modules/filters.js +++ b/core/modules/filters.js @@ -78,10 +78,15 @@ exports.filterFragments = { exports.operators = { "title": { // Filter by title selector: function(operator) { - return "$tw.utils.pushTop(subResults,\"" + $tw.utils.stringify(operator.operand) + "\");"; + if(operator.prefix === "!") { + return "for(title in source) {if(title !== \"" + $tw.utils.stringify(operator.operand) + "\") {$tw.utils.pushTop(subResults,title);}}"; + } else { + return "$tw.utils.pushTop(subResults,\"" + $tw.utils.stringify(operator.operand) + "\");"; + } }, filter: function(operator) { - return "if(subResults.indexOf(\"" + $tw.utils.stringify(operator.operand) + "\") !== -1) {subResults = [\"" + $tw.utils.stringify(operator.operand) + "\"];} else {subResults = [];}"; + var op = operator.prefix === "!" ? "!" : "="; + return "if(subResults.indexOf(\"" + $tw.utils.stringify(operator.operand) + "\") " + op + "== -1) {subResults = [\"" + $tw.utils.stringify(operator.operand) + "\"];} else {subResults = [];}"; } }, "prefix": { // Filter by title prefix