source: OKFNAnnotator (for Zope)/annotator_files/lib/plugin/kitchensink.js @ 3:6356e78ccf5c

Last change on this file since 3:6356e78ccf5c was 3:6356e78ccf5c, checked in by casties, 12 years ago

new version contains Annotator JS files to be used with FilesystemSite?.

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