comparison annotator_files/lib/plugin/kitchensink.js @ 3:6356e78ccf5c

new version contains Annotator JS files to be used with FilesystemSite.
author casties
date Thu, 05 Apr 2012 19:37:27 +0200
parents
children 6979313586cf
comparison
equal deleted inserted replaced
2:4c6c8835fc5c 3:6356e78ccf5c
1 var __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
4 Annotator.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 };