Mercurial > hg > OKFNAnnotator
annotate annotator_files/lib/plugin/kitchensink.js @ 4:6979313586cf
new version of annotator.
author | casties |
---|---|
date | Mon, 27 Aug 2012 19:05:38 +0200 |
parents | 6356e78ccf5c |
children |
rev | line source |
---|---|
4 | 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; }; | |
3
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
4 |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
5 Annotator.prototype.setupPlugins = function(config, options) { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
6 var name, opts, pluginConfig, plugins, uri, win, _i, _len, _results; |
4 | 7 if (config == null) { |
8 config = {}; | |
9 } | |
10 if (options == null) { | |
11 options = {}; | |
12 } | |
3
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
13 win = util.getGlobal(); |
4 | 14 plugins = ['Unsupported', 'Auth', 'Tags', 'Filter', 'Store', 'AnnotateItPermissions']; |
15 if (win.Showdown) { | |
16 plugins.push('Markdown'); | |
17 } | |
3
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
18 uri = win.location.href.split(/#|\?/).shift() || ''; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
19 pluginConfig = { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
20 Tags: {}, |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
21 Filter: { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
22 filters: [ |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
23 { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
24 label: Annotator._t('User'), |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
25 property: 'user' |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
26 }, { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
27 label: Annotator._t('Tags'), |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
28 property: 'tags' |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
29 } |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
30 ] |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
31 }, |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
32 Auth: { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
33 tokenUrl: config.tokenUrl || 'http://annotateit.org/api/token' |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
34 }, |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
35 Store: { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
36 prefix: config.storeUrl || 'http://annotateit.org/api', |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
37 annotationData: { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
38 uri: uri |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
39 }, |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
40 loadFromSearch: { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
41 uri: uri |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
42 } |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
43 } |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
44 }; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
45 for (name in options) { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
46 if (!__hasProp.call(options, name)) continue; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
47 opts = options[name]; |
4 | 48 if (__indexOf.call(plugins, name) < 0) { |
49 plugins.push(name); | |
50 } | |
3
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
51 } |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
52 $.extend(true, pluginConfig, options); |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
53 _results = []; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
54 for (_i = 0, _len = plugins.length; _i < _len; _i++) { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
55 name = plugins[_i]; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
56 if (!(name in pluginConfig) || pluginConfig[name]) { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
57 _results.push(this.addPlugin(name, pluginConfig[name])); |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
58 } else { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
59 _results.push(void 0); |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
60 } |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
61 } |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
62 return _results; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
63 }; |