From f29bbaa624991cedc1bfdec06aeb254357472555 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Fri, 10 Apr 2015 14:27:55 +0200 Subject: client: hack to allow collaborator/person to be default (will fix today) --- src/client/util.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/client/util.js') diff --git a/src/client/util.js b/src/client/util.js index 88226a4d..fcb0eec7 100644 --- a/src/client/util.js +++ b/src/client/util.js @@ -1,6 +1,6 @@ "use strict" -define(['jquery'], function($) { +define(['underscore', 'jquery'], function(_, $) { function assert(condition, message) { if (false == condition) { @@ -53,6 +53,16 @@ define(['jquery'], function($) { return set_diff(sa, sb); } + function first_contained(list, candidates, default_result) { + for (var k in candidates) { + var list_item = list[k]; + if (_.contains(candidates, list_item)) { + return list_item; + } + }; + return default_result; + } + // TODO: jquery BBQ: $.deparam.querystring().json; function getParameterByName(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); @@ -251,6 +261,7 @@ define(['jquery'], function($) { set_from_array: set_from_array, set_from_object: set_from_object, set_diff: set_diff, + first_contained: first_contained, setSelection: setSelection, selectionStart: selectionStart, -- cgit v1.3.1