Changeset 4:6979313586cf in OKFNAnnotator (for Zope) for annotator_files/lib/plugin
- Timestamp:
- Aug 27, 2012, 5:05:38 PM (13 years ago)
- Branch:
- default
- Location:
- annotator_files/lib/plugin
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
annotator_files/lib/plugin/annotateitpermissions.js
r3 r4 1 // Generated by CoffeeScript 1.3.3 1 2 var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, 2 __hasProp = Object.prototype.hasOwnProperty,3 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor ; child.__super__ = parent.prototype; return child; },4 __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 __hasProp = {}.hasOwnProperty, 4 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, 5 __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; }; 5 6 6 7 Annotator.Plugin.AnnotateItPermissions = (function(_super) { 7 8 8 9 __extends(AnnotateItPermissions, _super); 10 11 function AnnotateItPermissions() { 12 this._setAuthFromToken = __bind(this._setAuthFromToken, this); 13 14 this.updateAnnotationPermissions = __bind(this.updateAnnotationPermissions, this); 15 16 this.updatePermissionsField = __bind(this.updatePermissionsField, this); 17 18 this.addFieldsToAnnotation = __bind(this.addFieldsToAnnotation, this); 19 return AnnotateItPermissions.__super__.constructor.apply(this, arguments); 20 } 9 21 10 22 AnnotateItPermissions.prototype.options = { … … 16 28 consumer: 'group:__consumer__' 17 29 }, 30 userId: function(user) { 31 return user.userId; 32 }, 18 33 userString: function(user) { 19 return user ;34 return user.userId; 20 35 }, 21 userAuthorize: function(action, annotation, user , consumer) {22 var action_field, permissions, _ref, _ref 2, _ref3, _ref4;36 userAuthorize: function(action, annotation, user) { 37 var action_field, permissions, _ref, _ref1, _ref2, _ref3; 23 38 permissions = annotation.permissions || {}; 24 39 action_field = permissions[action] || []; 25 if ( !(user && consumer)) {26 return _ref = this.groups.world, __indexOf.call(action_field, _ref) >= 0;27 } else {28 if ( _ref2 = this.groups.world, __indexOf.call(action_field, _ref2) >= 0) {40 if (_ref = this.groups.world, __indexOf.call(action_field, _ref) >= 0) { 41 return true; 42 } else if ((user != null) && (user.userId != null) && (user.consumerKey != null)) { 43 if (user.userId === annotation.user && user.consumerKey === annotation.consumer) { 29 44 return true; 30 } else if ( user === annotation.user && consumer === annotation.consumer) {45 } else if (_ref1 = this.groups.authenticated, __indexOf.call(action_field, _ref1) >= 0) { 31 46 return true; 32 } else if ( _ref3 = this.groups.authenticated, __indexOf.call(action_field, _ref3) >= 0) {47 } else if (user.consumerKey === annotation.consumer && (_ref2 = this.groups.consumer, __indexOf.call(action_field, _ref2) >= 0)) { 33 48 return true; 34 } else if ( consumer === annotation.consumer && (_ref4 = this.groups.consumer, __indexOf.call(action_field, _ref4) >= 0)) {49 } else if (user.consumerKey === annotation.consumer && (_ref3 = user.userId, __indexOf.call(action_field, _ref3) >= 0)) { 35 50 return true; 36 } else if ( consumer === annotation.consumer && __indexOf.call(action_field, user) >= 0) {51 } else if (user.consumerKey === annotation.consumer && user.admin) { 37 52 return true; 38 53 } else { … … 41 56 } 42 57 }, 43 user: '',44 consumer: 'annotateit',45 58 permissions: { 46 59 'read': ['group:__world__'], … … 51 64 }; 52 65 53 function AnnotateItPermissions(element, options) {54 this._setAuthFromToken = __bind(this._setAuthFromToken, this);55 this.updateAnnotationPermissions = __bind(this.updateAnnotationPermissions, this);56 this.updatePermissionsField = __bind(this.updatePermissionsField, this);57 this.addFieldsToAnnotation = __bind(this.addFieldsToAnnotation, this); AnnotateItPermissions.__super__.constructor.apply(this, arguments);58 if (this.options.consumer) {59 this.setConsumer(this.options.consumer);60 delete this.options.consumer;61 }62 }63 64 AnnotateItPermissions.prototype.setConsumer = function(consumer) {65 return this.consumer = consumer;66 };67 68 AnnotateItPermissions.prototype.authorize = function(action, annotation, user, consumer) {69 if (user === void 0) user = this.user;70 if (consumer === void 0) consumer = this.consumer;71 if (this.options.userAuthorize) {72 return this.options.userAuthorize.call(this.options, action, annotation, user, consumer);73 } else {74 return true;75 }76 };77 78 66 AnnotateItPermissions.prototype.addFieldsToAnnotation = function(annotation) { 79 67 AnnotateItPermissions.__super__.addFieldsToAnnotation.apply(this, arguments); 80 if (annotation && this.consumer) return annotation.consumer = this.consumer; 68 if (annotation && this.user) { 69 return annotation.consumer = this.user.consumerKey; 70 } 81 71 }; 82 72 … … 85 75 field = $(field).show(); 86 76 input = field.find('input').removeAttr('disabled'); 87 if (!this.authorize('admin', annotation)) field.hide(); 88 if (this.authorize(action, annotation || {}, '__nonexistentuser__')) { 77 if (!this.authorize('admin', annotation)) { 78 field.hide(); 79 } 80 if (this.user && this.authorize(action, annotation || {}, { 81 userId: '__nonexistentuser__', 82 consumerKey: this.user.consumerKey 83 })) { 89 84 return input.attr('checked', 'checked'); 90 85 } else { … … 95 90 AnnotateItPermissions.prototype.updateAnnotationPermissions = function(type, field, annotation) { 96 91 var dataKey; 97 if (!annotation.permissions) annotation.permissions = this.options.permissions; 92 if (!annotation.permissions) { 93 annotation.permissions = this.options.permissions; 94 } 98 95 dataKey = type + '-permissions'; 99 96 if ($(field).find('input').is(':checked')) { … … 105 102 106 103 AnnotateItPermissions.prototype._setAuthFromToken = function(token) { 107 AnnotateItPermissions.__super__._setAuthFromToken.apply(this, arguments); 108 return this.setConsumer(token.consumerKey); 104 return this.setUser(token); 109 105 }; 110 106 -
annotator_files/lib/plugin/auth.js
r3 r4 1 // Generated by CoffeeScript 1.3.3 1 2 var base64Decode, base64UrlDecode, createDateFromISO8601, parseToken, 2 __hasProp = Object.prototype.hasOwnProperty,3 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor ; child.__super__ = parent.prototype; return child; };3 __hasProp = {}.hasOwnProperty, 4 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; 4 5 5 6 createDateFromISO8601 = function(string) { … … 9 10 offset = 0; 10 11 date = new Date(d[1], 0, 1); 11 if (d[3]) date.setMonth(d[3] - 1); 12 if (d[5]) date.setDate(d[5]); 13 if (d[7]) date.setHours(d[7]); 14 if (d[8]) date.setMinutes(d[8]); 15 if (d[10]) date.setSeconds(d[10]); 16 if (d[12]) date.setMilliseconds(Number("0." + d[12]) * 1000); 12 if (d[3]) { 13 date.setMonth(d[3] - 1); 14 } 15 if (d[5]) { 16 date.setDate(d[5]); 17 } 18 if (d[7]) { 19 date.setHours(d[7]); 20 } 21 if (d[8]) { 22 date.setMinutes(d[8]); 23 } 24 if (d[10]) { 25 date.setSeconds(d[10]); 26 } 27 if (d[12]) { 28 date.setMilliseconds(Number("0." + d[12]) * 1000); 29 } 17 30 if (d[14]) { 18 31 offset = (Number(d[16]) * 60) + Number(d[17]); … … 37 50 dec = ""; 38 51 tmp_arr = []; 39 if (!data) return data; 52 if (!data) { 53 return data; 54 } 40 55 data += ''; 41 56 while (i < data.length) { … … 61 76 62 77 base64UrlDecode = function(data) { 63 var i, m, _ ref;78 var i, m, _i, _ref; 64 79 m = data.length % 4; 65 80 if (m !== 0) { 66 for (i = 0, _ref = 4 - m; 0 <= _ref ? i < _ref : i > _ref; 0 <= _ref ? i++ : i--) {81 for (i = _i = 0, _ref = 4 - m; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) { 67 82 data += '='; 68 83 } … … 176 191 177 192 Auth.prototype.withToken = function(callback) { 178 if (!(callback != null)) return; 193 if (!(callback != null)) { 194 return; 195 } 179 196 if (this.haveValidToken()) { 180 197 return callback(this._unsafeToken); 181 198 } else { 182 199 this.waitingForToken.push(callback); 183 if (!this.requestInProgress) return this.requestToken(); 200 if (!this.requestInProgress) { 201 return this.requestToken(); 202 } 184 203 } 185 204 }; -
annotator_files/lib/plugin/filter.js
r3 r4 1 // Generated by CoffeeScript 1.3.3 1 2 var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, 2 __hasProp = Object.prototype.hasOwnProperty,3 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor ; child.__super__ = parent.prototype; return child; };3 __hasProp = {}.hasOwnProperty, 4 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; 4 5 5 6 Annotator.Plugin.Filter = (function(_super) { … … 35 36 isFiltered: function(input, property) { 36 37 var keyword, _i, _len, _ref; 37 if (!(input && property)) return false; 38 if (!(input && property)) { 39 return false; 40 } 38 41 _ref = input.split(/\s*/); 39 42 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 40 43 keyword = _ref[_i]; 41 if (property.indexOf(keyword) === -1) return false; 44 if (property.indexOf(keyword) === -1) { 45 return false; 46 } 42 47 } 43 48 return true; … … 47 52 function Filter(element, options) { 48 53 this._onPreviousClick = __bind(this._onPreviousClick, this); 54 49 55 this._onNextClick = __bind(this._onNextClick, this); 56 50 57 this._onFilterKeyup = __bind(this._onFilterKeyup, this); 58 51 59 this._onFilterBlur = __bind(this._onFilterBlur, this); 60 52 61 this._onFilterFocus = __bind(this._onFilterFocus, this); 53 this.updateHighlights = __bind(this.updateHighlights, this); element = $(this.html.element).appendTo(this.options.appendTo); 62 63 this.updateHighlights = __bind(this.updateHighlights, this); 64 65 var _base; 66 element = $(this.html.element).appendTo((options != null ? options.appendTo : void 0) || this.options.appendTo); 54 67 Filter.__super__.constructor.call(this, element, options); 68 (_base = this.options).filters || (_base.filters = []); 55 69 this.filter = $(this.html.filter); 56 70 this.filters = []; … … 106 120 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 107 121 f = _ref[_i]; 108 if (f.property === filter.property) _results.push(f); 122 if (f.property === filter.property) { 123 _results.push(f); 124 } 109 125 } 110 126 return _results; … … 153 169 154 170 Filter.prototype.filterHighlights = function() { 155 var activeFilters, annotation, annotations, filtered, highlights, index, uniques, _ len, _ref;171 var activeFilters, annotation, annotations, filtered, highlights, index, uniques, _i, _len, _ref; 156 172 activeFilters = $.grep(this.filters, function(filter) { 157 173 return !!filter.annotations.length; … … 174 190 } 175 191 highlights = this.highlights; 176 for (index = 0, _len = filtered.length; index < _len; index++) {192 for (index = _i = 0, _len = filtered.length; _i < _len; index = ++_i) { 177 193 annotation = filtered[index]; 178 194 highlights = highlights.not(annotation.highlights); … … 208 224 var filter; 209 225 filter = $(event.target).parent().data('filter'); 210 if (filter) return this.updateFilter(filter); 226 if (filter) { 227 return this.updateFilter(filter); 228 } 211 229 }; 212 230 213 231 Filter.prototype._findNextHighlight = function(previous) { 214 232 var active, annotation, current, index, next, offset, operator, resetOffset; 215 if (!this.highlights.length) return this; 233 if (!this.highlights.length) { 234 return this; 235 } 216 236 offset = previous ? 0 : -1; 217 237 resetOffset = previous ? -1 : 0; … … 219 239 active = this.highlights.not('.' + this.classes.hl.hide); 220 240 current = active.filter('.' + this.classes.hl.active); 221 if (!current.length) current = active.eq(offset); 241 if (!current.length) { 242 current = active.eq(offset); 243 } 222 244 annotation = current.data('annotation'); 223 245 index = active.index(current[0]); 224 246 next = active.filter(":" + operator + "(" + index + ")").not(annotation.highlights).eq(resetOffset); 225 if (!next.length) next = active.eq(resetOffset); 247 if (!next.length) { 248 next = active.eq(resetOffset); 249 } 226 250 return this._scrollToHighlight(next.data('annotation').highlights); 227 251 }; -
annotator_files/lib/plugin/kitchensink.js
r3 r4 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; }; 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 4 4 5 Annotator.prototype.setupPlugins = function(config, options) { 5 6 var name, opts, pluginConfig, plugins, uri, win, _i, _len, _results; 6 if (config == null) config = {}; 7 if (options == null) options = {}; 7 if (config == null) { 8 config = {}; 9 } 10 if (options == null) { 11 options = {}; 12 } 8 13 win = util.getGlobal(); 9 plugins = ['Unsupported', 'Auth', 'Tags', 'Filter', 'Store', 'Permissions']; 10 if (win.Showdown) plugins.push('Markdown'); 14 plugins = ['Unsupported', 'Auth', 'Tags', 'Filter', 'Store', 'AnnotateItPermissions']; 15 if (win.Showdown) { 16 plugins.push('Markdown'); 17 } 11 18 uri = win.location.href.split(/#|\?/).shift() || ''; 12 19 pluginConfig = { … … 39 46 if (!__hasProp.call(options, name)) continue; 40 47 opts = options[name]; 41 if (__indexOf.call(plugins, name) < 0) plugins.push(name); 48 if (__indexOf.call(plugins, name) < 0) { 49 plugins.push(name); 50 } 42 51 } 43 52 $.extend(true, pluginConfig, options); -
annotator_files/lib/plugin/markdown.js
r3 r4 1 // Generated by CoffeeScript 1.3.3 1 2 var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, 2 __hasProp = Object.prototype.hasOwnProperty,3 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor ; child.__super__ = parent.prototype; return child; };3 __hasProp = {}.hasOwnProperty, 4 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; 4 5 5 6 Annotator.Plugin.Markdown = (function(_super) { … … 12 13 13 14 function Markdown(element, options) { 14 this.updateTextField = __bind(this.updateTextField, this); if ((typeof Showdown !== "undefined" && Showdown !== null ? Showdown.converter : void 0) != null) { 15 this.updateTextField = __bind(this.updateTextField, this); 16 if ((typeof Showdown !== "undefined" && Showdown !== null ? Showdown.converter : void 0) != null) { 15 17 Markdown.__super__.constructor.apply(this, arguments); 16 18 this.converter = new Showdown.converter(); -
annotator_files/lib/plugin/permissions.js
r3 r4 1 // Generated by CoffeeScript 1.3.3 1 2 var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, 2 __hasProp = Object.prototype.hasOwnProperty,3 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor ; child.__super__ = parent.prototype; return child; };3 __hasProp = {}.hasOwnProperty, 4 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; 4 5 5 6 Annotator.Plugin.Permissions = (function(_super) { … … 24 25 if (annotation.permissions) { 25 26 tokens = annotation.permissions[action] || []; 26 if (tokens.length === 0) return true; 27 if (tokens.length === 0) { 28 return true; 29 } 27 30 for (_i = 0, _len = tokens.length; _i < _len; _i++) { 28 31 token = tokens[_i]; 29 if (this.userId(user) === token) return true; 32 if (this.userId(user) === token) { 33 return true; 34 } 30 35 } 31 36 return false; … … 46 51 function Permissions(element, options) { 47 52 this._setAuthFromToken = __bind(this._setAuthFromToken, this); 53 48 54 this.updateViewer = __bind(this.updateViewer, this); 55 49 56 this.updateAnnotationPermissions = __bind(this.updateAnnotationPermissions, this); 57 50 58 this.updatePermissionsField = __bind(this.updatePermissionsField, this); 51 this.addFieldsToAnnotation = __bind(this.addFieldsToAnnotation, this); Permissions.__super__.constructor.apply(this, arguments); 59 60 this.addFieldsToAnnotation = __bind(this.addFieldsToAnnotation, this); 61 Permissions.__super__.constructor.apply(this, arguments); 52 62 if (this.options.user) { 53 63 this.setUser(this.options.user); … … 59 69 var createCallback, self, 60 70 _this = this; 61 if (!Annotator.supported()) return; 71 if (!Annotator.supported()) { 72 return; 73 } 62 74 self = this; 63 75 createCallback = function(method, type) { … … 95 107 var keyword, _i, _len, _ref; 96 108 user = _this.options.userString(user); 97 if (!(input && user)) return false; 109 if (!(input && user)) { 110 return false; 111 } 98 112 _ref = input.split(/\s*/); 99 113 for (_i = 0, _len = _ref.length; _i < _len; _i++) { 100 114 keyword = _ref[_i]; 101 if (user.indexOf(keyword) === -1) return false; 115 if (user.indexOf(keyword) === -1) { 116 return false; 117 } 102 118 } 103 119 return true; … … 114 130 if (annotation) { 115 131 annotation.permissions = this.options.permissions; 116 if (this.user) return annotation.user = this.user; 132 if (this.user) { 133 return annotation.user = this.user; 134 } 117 135 } 118 136 }; 119 137 120 138 Permissions.prototype.authorize = function(action, annotation, user) { 121 if (user === void 0) user = this.user; 139 if (user === void 0) { 140 user = this.user; 141 } 122 142 if (this.options.userAuthorize) { 123 143 return this.options.userAuthorize.call(this.options, action, annotation, user); … … 131 151 field = $(field).show(); 132 152 input = field.find('input').removeAttr('disabled'); 133 if (!this.authorize('admin', annotation)) field.hide(); 153 if (!this.authorize('admin', annotation)) { 154 field.hide(); 155 } 134 156 if (this.authorize(action, annotation || {}, null)) { 135 157 return input.attr('checked', 'checked'); … … 141 163 Permissions.prototype.updateAnnotationPermissions = function(type, field, annotation) { 142 164 var dataKey; 143 if (!annotation.permissions) annotation.permissions = this.options.permissions; 165 if (!annotation.permissions) { 166 annotation.permissions = this.options.permissions; 167 } 144 168 dataKey = type + '-permissions'; 145 169 if ($(field).find('input').is(':checked')) { … … 160 184 field.remove(); 161 185 } 162 if (!this.authorize('update', annotation)) controls.hideEdit(); 163 if (!this.authorize('delete', annotation)) return controls.hideDelete(); 186 if (!this.authorize('update', annotation)) { 187 controls.hideEdit(); 188 } 189 if (!this.authorize('delete', annotation)) { 190 return controls.hideDelete(); 191 } 164 192 }; 165 193 -
annotator_files/lib/plugin/store.js
r3 r4 1 // Generated by CoffeeScript 1.3.3 1 2 var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, 2 __hasProp = Object.prototype.hasOwnProperty,3 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor ; child.__super__ = parent.prototype; return child; },4 __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 __hasProp = {}.hasOwnProperty, 4 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, 5 __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; }; 5 6 6 7 Annotator.Plugin.Store = (function(_super) { … … 30 31 function Store(element, options) { 31 32 this._onError = __bind(this._onError, this); 33 32 34 this._onLoadAnnotationsFromSearch = __bind(this._onLoadAnnotationsFromSearch, this); 35 33 36 this._onLoadAnnotations = __bind(this._onLoadAnnotations, this); 34 this._getAnnotations = __bind(this._getAnnotations, this); Store.__super__.constructor.apply(this, arguments); 37 38 this._getAnnotations = __bind(this._getAnnotations, this); 39 Store.__super__.constructor.apply(this, arguments); 35 40 this.annotations = []; 36 41 } 37 42 38 43 Store.prototype.pluginInit = function() { 39 if (!Annotator.supported()) return; 44 if (!Annotator.supported()) { 45 return; 46 } 40 47 if (this.annotator.plugins.Auth) { 41 48 return this.annotator.plugins.Auth.withToken(this._getAnnotations); … … 108 115 109 116 Store.prototype._onLoadAnnotations = function(data) { 110 if (data == null) data = []; 117 if (data == null) { 118 data = []; 119 } 111 120 this.annotations = data; 112 121 return this.annotator.loadAnnotations(data.slice()); … … 118 127 119 128 Store.prototype._onLoadAnnotationsFromSearch = function(data) { 120 if (data == null) data = {}; 129 if (data == null) { 130 data = {}; 131 } 121 132 return this._onLoadAnnotations(data.rows || []); 122 133 }; … … 193 204 $.extend(annotation, this.options.annotationData); 194 205 data = JSON.stringify(annotation); 195 if (highlights) annotation.highlights = highlights; 206 if (highlights) { 207 annotation.highlights = highlights; 208 } 196 209 return data; 197 210 }; -
annotator_files/lib/plugin/tags.js
r3 r4 1 // Generated by CoffeeScript 1.3.3 1 2 var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, 2 __hasProp = Object.prototype.hasOwnProperty,3 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor ; child.__super__ = parent.prototype; return child; };3 __hasProp = {}.hasOwnProperty, 4 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; 4 5 5 6 Annotator.Plugin.Tags = (function(_super) { … … 9 10 function Tags() { 10 11 this.setAnnotationTags = __bind(this.setAnnotationTags, this); 12 11 13 this.updateField = __bind(this.updateField, this); 12 Tags.__super__.constructor.apply(this, arguments);14 return Tags.__super__.constructor.apply(this, arguments); 13 15 } 14 16 … … 18 20 string = $.trim(string); 19 21 tags = []; 20 if (string) tags = string.split(/\s+/); 22 if (string) { 23 tags = string.split(/\s+/); 24 } 21 25 return tags; 22 26 }, … … 31 35 32 36 Tags.prototype.pluginInit = function() { 33 if (!Annotator.supported()) return; 37 if (!Annotator.supported()) { 38 return; 39 } 34 40 this.field = this.annotator.editor.addField({ 35 41 label: Annotator._t('Add some tags here') + '\u2026', … … 61 67 var value; 62 68 value = ''; 63 if (annotation.tags) value = this.stringifyTags(annotation.tags); 69 if (annotation.tags) { 70 value = this.stringifyTags(annotation.tags); 71 } 64 72 return this.input.val(value); 65 73 }; … … 88 96 89 97 Annotator.Plugin.Tags.filterCallback = function(input, tags) { 90 var keyword, keywords, matches, tag, _i, _j, _len, _len2; 91 if (tags == null) tags = []; 98 var keyword, keywords, matches, tag, _i, _j, _len, _len1; 99 if (tags == null) { 100 tags = []; 101 } 92 102 matches = 0; 93 103 keywords = []; … … 97 107 keyword = keywords[_i]; 98 108 if (tags.length) { 99 for (_j = 0, _len 2 = tags.length; _j < _len2; _j++) {109 for (_j = 0, _len1 = tags.length; _j < _len1; _j++) { 100 110 tag = tags[_j]; 101 if (tag.indexOf(keyword) !== -1) matches += 1; 111 if (tag.indexOf(keyword) !== -1) { 112 matches += 1; 113 } 102 114 } 103 115 } -
annotator_files/lib/plugin/unsupported.js
r3 r4 1 var __hasProp = Object.prototype.hasOwnProperty, 2 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; 1 // Generated by CoffeeScript 1.3.3 2 var __hasProp = {}.hasOwnProperty, 3 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; 3 4 4 5 Annotator.Plugin.Unsupported = (function(_super) { … … 7 8 8 9 function Unsupported() { 9 Unsupported.__super__.constructor.apply(this, arguments);10 return Unsupported.__super__.constructor.apply(this, arguments); 10 11 } 11 12
Note: See TracChangeset
for help on using the changeset viewer.