1 | // Generated by CoffeeScript 1.3.3 |
---|
2 | var __hasProp = {}.hasOwnProperty, |
---|
3 | __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; |
---|
4 | |
---|
5 | Annotator.prototype.setupPlugins = function(config, options) { |
---|
6 | var name, opts, pluginConfig, plugins, uri, win, _i, _len, _results; |
---|
7 | if (config == null) { |
---|
8 | config = {}; |
---|
9 | } |
---|
10 | if (options == null) { |
---|
11 | options = {}; |
---|
12 | } |
---|
13 | win = util.getGlobal(); |
---|
14 | plugins = ['Unsupported', 'Auth', 'Tags', 'Filter', 'Store', 'AnnotateItPermissions']; |
---|
15 | if (win.Showdown) { |
---|
16 | plugins.push('Markdown'); |
---|
17 | } |
---|
18 | uri = win.location.href.split(/#|\?/).shift() || ''; |
---|
19 | pluginConfig = { |
---|
20 | Tags: {}, |
---|
21 | Filter: { |
---|
22 | filters: [ |
---|
23 | { |
---|
24 | label: Annotator._t('User'), |
---|
25 | property: 'user' |
---|
26 | }, { |
---|
27 | label: Annotator._t('Tags'), |
---|
28 | property: 'tags' |
---|
29 | } |
---|
30 | ] |
---|
31 | }, |
---|
32 | Auth: { |
---|
33 | tokenUrl: config.tokenUrl || 'http://annotateit.org/api/token' |
---|
34 | }, |
---|
35 | Store: { |
---|
36 | prefix: config.storeUrl || 'http://annotateit.org/api', |
---|
37 | annotationData: { |
---|
38 | uri: uri |
---|
39 | }, |
---|
40 | loadFromSearch: { |
---|
41 | uri: uri |
---|
42 | } |
---|
43 | } |
---|
44 | }; |
---|
45 | for (name in options) { |
---|
46 | if (!__hasProp.call(options, name)) continue; |
---|
47 | opts = options[name]; |
---|
48 | if (__indexOf.call(plugins, name) < 0) { |
---|
49 | plugins.push(name); |
---|
50 | } |
---|
51 | } |
---|
52 | $.extend(true, pluginConfig, options); |
---|
53 | _results = []; |
---|
54 | for (_i = 0, _len = plugins.length; _i < _len; _i++) { |
---|
55 | name = plugins[_i]; |
---|
56 | if (!(name in pluginConfig) || pluginConfig[name]) { |
---|
57 | _results.push(this.addPlugin(name, pluginConfig[name])); |
---|
58 | } else { |
---|
59 | _results.push(void 0); |
---|
60 | } |
---|
61 | } |
---|
62 | return _results; |
---|
63 | }; |
---|