From 9fbc8ad8c8e4b216e6a2da7bfcfa0de7c2ac8175 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 1 Dec 2018 19:30:10 +0300 Subject: [PATCH] merged .tagged(..) and .tags(..), still needs thought.. Signed-off-by: Alex A. Naanou --- ui (gen4)/imagegrid/tags.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/ui (gen4)/imagegrid/tags.js b/ui (gen4)/imagegrid/tags.js index c84eb609..5877f2b6 100755 --- a/ui (gen4)/imagegrid/tags.js +++ b/ui (gen4)/imagegrid/tags.js @@ -375,12 +375,32 @@ var TagsPrototype = { // .tags(value) // -> tags // + // Check value tags... + // .tags(value, tag) + // .tags(value, tag, ..) + // .tags(value, [tag, ..]) + // -> tags + // // NOTE: this includes all the .persistent tags as well as all the // tags actually used. - tags: function(value){ + tags: function(value, ...tags){ var that = this + + // check if value is tagged by tags.., + if(value && tags.length > 0){ + tags = tags.length == 1 && tags[0] instanceof Array ? + tags.shift() + : tags + // XXX is this the new version??? + var u = this.tags(value) + return tags + .reduce(function(res, tag){ + return res === false ? + res + : that.match(tag, u).length > 0 }, true) + // get tags of specific value... - if(value){ + } else if(value){ return Object.entries(this.__index || {}) .filter(function(e){ return e[1].has(value) }) .map(function(e){ return e[0] })