From 3e0bd078d05ac98ce78957ba55e0e1d0325907e9 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 14 Apr 2015 19:49:22 +0100 Subject: [PATCH] pass autocomplete with layer, support autocomplete for leyers with filters, fixes #2736 --- pandora/config.padma.jsonc | 1 + static/js/editor.js | 35 +++++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/pandora/config.padma.jsonc b/pandora/config.padma.jsonc index 714651fce..046b513e3 100644 --- a/pandora/config.padma.jsonc +++ b/pandora/config.padma.jsonc @@ -603,6 +603,7 @@ "title": "Keywords", "canAddAnnotations": {"member": true, "staff": true, "admin": true}, "item": "Keyword", + "autocomplete": true, "overlap": true, "type": "string" }, diff --git a/static/js/editor.js b/static/js/editor.js index d1bc77fd6..233d32e71 100644 --- a/static/js/editor.js +++ b/static/js/editor.js @@ -3,7 +3,6 @@ 'use strict'; pandora.ui.editor = function(data) { - var ui = pandora.user.ui, that = Ox.VideoAnnotationPanel({ @@ -15,16 +14,6 @@ pandora.ui.editor = function(data) { annotationsTooltip: Ox._('annotations') + ' ' + Ox.SYMBOLS.shift + 'A', audioTrack: data.audioTrack, - autocomplete: function(key, value, callback) { - pandora.api.autocompleteEntities({ - key: key, - operator: '=', - range: [0, 20], - value: value - }, function(result) { - callback(result.data.items); - }) - }, censored: data.censored, censoredIcon: pandora.site.cantPlay.icon, censoredTooltip: Ox._(pandora.site.cantPlay.text), @@ -53,7 +42,29 @@ pandora.ui.editor = function(data) { layers: data.annotations.map(function(layer) { return Ox.extend({ editable: layer.canAddAnnotations[pandora.user.level] - }, layer); + }, layer, { + autocomplete: layer.type == 'entity' + ? function(key, value, callback) { + pandora.api.autocompleteEntities({ + key: key, + operator: '=', + range: [0, 20], + value: value + }, function(result) { + callback(result.data.items); + }) + } : layer.autocomplete + ? function(key, value, callback) { + pandora.api.autocomplete({ + key: key, + operator: '=', + range: [0, 20], + value: value + }, function(result) { + callback(result.data.items); + }); + } : null + }); }), loop: ui.videoLoop, muted: ui.videoMuted,