Changeset 4:6979313586cf in OKFNAnnotator (for Zope) for annotator_files/lib/plugin


Ignore:
Timestamp:
Aug 27, 2012, 5:05:38 PM (13 years ago)
Author:
casties
Branch:
default
Message:

new version of annotator.

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
    12var __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; };
    56
    67Annotator.Plugin.AnnotateItPermissions = (function(_super) {
    78
    89  __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  }
    921
    1022  AnnotateItPermissions.prototype.options = {
     
    1628      consumer: 'group:__consumer__'
    1729    },
     30    userId: function(user) {
     31      return user.userId;
     32    },
    1833    userString: function(user) {
    19       return user;
     34      return user.userId;
    2035    },
    21     userAuthorize: function(action, annotation, user, consumer) {
    22       var action_field, permissions, _ref, _ref2, _ref3, _ref4;
     36    userAuthorize: function(action, annotation, user) {
     37      var action_field, permissions, _ref, _ref1, _ref2, _ref3;
    2338      permissions = annotation.permissions || {};
    2439      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) {
    2944          return true;
    30         } else if (user === annotation.user && consumer === annotation.consumer) {
     45        } else if (_ref1 = this.groups.authenticated, __indexOf.call(action_field, _ref1) >= 0) {
    3146          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)) {
    3348          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)) {
    3550          return true;
    36         } else if (consumer === annotation.consumer && __indexOf.call(action_field, user) >= 0) {
     51        } else if (user.consumerKey === annotation.consumer && user.admin) {
    3752          return true;
    3853        } else {
     
    4156      }
    4257    },
    43     user: '',
    44     consumer: 'annotateit',
    4558    permissions: {
    4659      'read': ['group:__world__'],
     
    5164  };
    5265
    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 
    7866  AnnotateItPermissions.prototype.addFieldsToAnnotation = function(annotation) {
    7967    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    }
    8171  };
    8272
     
    8575    field = $(field).show();
    8676    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    })) {
    8984      return input.attr('checked', 'checked');
    9085    } else {
     
    9590  AnnotateItPermissions.prototype.updateAnnotationPermissions = function(type, field, annotation) {
    9691    var dataKey;
    97     if (!annotation.permissions) annotation.permissions = this.options.permissions;
     92    if (!annotation.permissions) {
     93      annotation.permissions = this.options.permissions;
     94    }
    9895    dataKey = type + '-permissions';
    9996    if ($(field).find('input').is(':checked')) {
     
    105102
    106103  AnnotateItPermissions.prototype._setAuthFromToken = function(token) {
    107     AnnotateItPermissions.__super__._setAuthFromToken.apply(this, arguments);
    108     return this.setConsumer(token.consumerKey);
     104    return this.setUser(token);
    109105  };
    110106
  • annotator_files/lib/plugin/auth.js

    r3 r4  
     1// Generated by CoffeeScript 1.3.3
    12var 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; };
    45
    56createDateFromISO8601 = function(string) {
     
    910  offset = 0;
    1011  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  }
    1730  if (d[14]) {
    1831    offset = (Number(d[16]) * 60) + Number(d[17]);
     
    3750    dec = "";
    3851    tmp_arr = [];
    39     if (!data) return data;
     52    if (!data) {
     53      return data;
     54    }
    4055    data += '';
    4156    while (i < data.length) {
     
    6176
    6277base64UrlDecode = function(data) {
    63   var i, m, _ref;
     78  var i, m, _i, _ref;
    6479  m = data.length % 4;
    6580  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) {
    6782      data += '=';
    6883    }
     
    176191
    177192  Auth.prototype.withToken = function(callback) {
    178     if (!(callback != null)) return;
     193    if (!(callback != null)) {
     194      return;
     195    }
    179196    if (this.haveValidToken()) {
    180197      return callback(this._unsafeToken);
    181198    } else {
    182199      this.waitingForToken.push(callback);
    183       if (!this.requestInProgress) return this.requestToken();
     200      if (!this.requestInProgress) {
     201        return this.requestToken();
     202      }
    184203    }
    185204  };
  • annotator_files/lib/plugin/filter.js

    r3 r4  
     1// Generated by CoffeeScript 1.3.3
    12var __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; };
    45
    56Annotator.Plugin.Filter = (function(_super) {
     
    3536    isFiltered: function(input, property) {
    3637      var keyword, _i, _len, _ref;
    37       if (!(input && property)) return false;
     38      if (!(input && property)) {
     39        return false;
     40      }
    3841      _ref = input.split(/\s*/);
    3942      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    4043        keyword = _ref[_i];
    41         if (property.indexOf(keyword) === -1) return false;
     44        if (property.indexOf(keyword) === -1) {
     45          return false;
     46        }
    4247      }
    4348      return true;
     
    4752  function Filter(element, options) {
    4853    this._onPreviousClick = __bind(this._onPreviousClick, this);
     54
    4955    this._onNextClick = __bind(this._onNextClick, this);
     56
    5057    this._onFilterKeyup = __bind(this._onFilterKeyup, this);
     58
    5159    this._onFilterBlur = __bind(this._onFilterBlur, this);
     60
    5261    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);
    5467    Filter.__super__.constructor.call(this, element, options);
     68    (_base = this.options).filters || (_base.filters = []);
    5569    this.filter = $(this.html.filter);
    5670    this.filters = [];
     
    106120      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    107121        f = _ref[_i];
    108         if (f.property === filter.property) _results.push(f);
     122        if (f.property === filter.property) {
     123          _results.push(f);
     124        }
    109125      }
    110126      return _results;
     
    153169
    154170  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;
    156172    activeFilters = $.grep(this.filters, function(filter) {
    157173      return !!filter.annotations.length;
     
    174190    }
    175191    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) {
    177193      annotation = filtered[index];
    178194      highlights = highlights.not(annotation.highlights);
     
    208224    var filter;
    209225    filter = $(event.target).parent().data('filter');
    210     if (filter) return this.updateFilter(filter);
     226    if (filter) {
     227      return this.updateFilter(filter);
     228    }
    211229  };
    212230
    213231  Filter.prototype._findNextHighlight = function(previous) {
    214232    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    }
    216236    offset = previous ? 0 : -1;
    217237    resetOffset = previous ? -1 : 0;
     
    219239    active = this.highlights.not('.' + this.classes.hl.hide);
    220240    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    }
    222244    annotation = current.data('annotation');
    223245    index = active.index(current[0]);
    224246    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    }
    226250    return this._scrollToHighlight(next.data('annotation').highlights);
    227251  };
  • 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
     2var __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; };
    34
    45Annotator.prototype.setupPlugins = function(config, options) {
    56  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  }
    813  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  }
    1118  uri = win.location.href.split(/#|\?/).shift() || '';
    1219  pluginConfig = {
     
    3946    if (!__hasProp.call(options, name)) continue;
    4047    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    }
    4251  }
    4352  $.extend(true, pluginConfig, options);
  • annotator_files/lib/plugin/markdown.js

    r3 r4  
     1// Generated by CoffeeScript 1.3.3
    12var __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; };
    45
    56Annotator.Plugin.Markdown = (function(_super) {
     
    1213
    1314  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) {
    1517      Markdown.__super__.constructor.apply(this, arguments);
    1618      this.converter = new Showdown.converter();
  • annotator_files/lib/plugin/permissions.js

    r3 r4  
     1// Generated by CoffeeScript 1.3.3
    12var __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; };
    45
    56Annotator.Plugin.Permissions = (function(_super) {
     
    2425      if (annotation.permissions) {
    2526        tokens = annotation.permissions[action] || [];
    26         if (tokens.length === 0) return true;
     27        if (tokens.length === 0) {
     28          return true;
     29        }
    2730        for (_i = 0, _len = tokens.length; _i < _len; _i++) {
    2831          token = tokens[_i];
    29           if (this.userId(user) === token) return true;
     32          if (this.userId(user) === token) {
     33            return true;
     34          }
    3035        }
    3136        return false;
     
    4651  function Permissions(element, options) {
    4752    this._setAuthFromToken = __bind(this._setAuthFromToken, this);
     53
    4854    this.updateViewer = __bind(this.updateViewer, this);
     55
    4956    this.updateAnnotationPermissions = __bind(this.updateAnnotationPermissions, this);
     57
    5058    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);
    5262    if (this.options.user) {
    5363      this.setUser(this.options.user);
     
    5969    var createCallback, self,
    6070      _this = this;
    61     if (!Annotator.supported()) return;
     71    if (!Annotator.supported()) {
     72      return;
     73    }
    6274    self = this;
    6375    createCallback = function(method, type) {
     
    95107          var keyword, _i, _len, _ref;
    96108          user = _this.options.userString(user);
    97           if (!(input && user)) return false;
     109          if (!(input && user)) {
     110            return false;
     111          }
    98112          _ref = input.split(/\s*/);
    99113          for (_i = 0, _len = _ref.length; _i < _len; _i++) {
    100114            keyword = _ref[_i];
    101             if (user.indexOf(keyword) === -1) return false;
     115            if (user.indexOf(keyword) === -1) {
     116              return false;
     117            }
    102118          }
    103119          return true;
     
    114130    if (annotation) {
    115131      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      }
    117135    }
    118136  };
    119137
    120138  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    }
    122142    if (this.options.userAuthorize) {
    123143      return this.options.userAuthorize.call(this.options, action, annotation, user);
     
    131151    field = $(field).show();
    132152    input = field.find('input').removeAttr('disabled');
    133     if (!this.authorize('admin', annotation)) field.hide();
     153    if (!this.authorize('admin', annotation)) {
     154      field.hide();
     155    }
    134156    if (this.authorize(action, annotation || {}, null)) {
    135157      return input.attr('checked', 'checked');
     
    141163  Permissions.prototype.updateAnnotationPermissions = function(type, field, annotation) {
    142164    var dataKey;
    143     if (!annotation.permissions) annotation.permissions = this.options.permissions;
     165    if (!annotation.permissions) {
     166      annotation.permissions = this.options.permissions;
     167    }
    144168    dataKey = type + '-permissions';
    145169    if ($(field).find('input').is(':checked')) {
     
    160184      field.remove();
    161185    }
    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    }
    164192  };
    165193
  • annotator_files/lib/plugin/store.js

    r3 r4  
     1// Generated by CoffeeScript 1.3.3
    12var __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; };
    56
    67Annotator.Plugin.Store = (function(_super) {
     
    3031  function Store(element, options) {
    3132    this._onError = __bind(this._onError, this);
     33
    3234    this._onLoadAnnotationsFromSearch = __bind(this._onLoadAnnotationsFromSearch, this);
     35
    3336    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);
    3540    this.annotations = [];
    3641  }
    3742
    3843  Store.prototype.pluginInit = function() {
    39     if (!Annotator.supported()) return;
     44    if (!Annotator.supported()) {
     45      return;
     46    }
    4047    if (this.annotator.plugins.Auth) {
    4148      return this.annotator.plugins.Auth.withToken(this._getAnnotations);
     
    108115
    109116  Store.prototype._onLoadAnnotations = function(data) {
    110     if (data == null) data = [];
     117    if (data == null) {
     118      data = [];
     119    }
    111120    this.annotations = data;
    112121    return this.annotator.loadAnnotations(data.slice());
     
    118127
    119128  Store.prototype._onLoadAnnotationsFromSearch = function(data) {
    120     if (data == null) data = {};
     129    if (data == null) {
     130      data = {};
     131    }
    121132    return this._onLoadAnnotations(data.rows || []);
    122133  };
     
    193204    $.extend(annotation, this.options.annotationData);
    194205    data = JSON.stringify(annotation);
    195     if (highlights) annotation.highlights = highlights;
     206    if (highlights) {
     207      annotation.highlights = highlights;
     208    }
    196209    return data;
    197210  };
  • annotator_files/lib/plugin/tags.js

    r3 r4  
     1// Generated by CoffeeScript 1.3.3
    12var __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; };
    45
    56Annotator.Plugin.Tags = (function(_super) {
     
    910  function Tags() {
    1011    this.setAnnotationTags = __bind(this.setAnnotationTags, this);
     12
    1113    this.updateField = __bind(this.updateField, this);
    12     Tags.__super__.constructor.apply(this, arguments);
     14    return Tags.__super__.constructor.apply(this, arguments);
    1315  }
    1416
     
    1820      string = $.trim(string);
    1921      tags = [];
    20       if (string) tags = string.split(/\s+/);
     22      if (string) {
     23        tags = string.split(/\s+/);
     24      }
    2125      return tags;
    2226    },
     
    3135
    3236  Tags.prototype.pluginInit = function() {
    33     if (!Annotator.supported()) return;
     37    if (!Annotator.supported()) {
     38      return;
     39    }
    3440    this.field = this.annotator.editor.addField({
    3541      label: Annotator._t('Add some tags here') + '\u2026',
     
    6167    var value;
    6268    value = '';
    63     if (annotation.tags) value = this.stringifyTags(annotation.tags);
     69    if (annotation.tags) {
     70      value = this.stringifyTags(annotation.tags);
     71    }
    6472    return this.input.val(value);
    6573  };
     
    8896
    8997Annotator.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  }
    92102  matches = 0;
    93103  keywords = [];
     
    97107      keyword = keywords[_i];
    98108      if (tags.length) {
    99         for (_j = 0, _len2 = tags.length; _j < _len2; _j++) {
     109        for (_j = 0, _len1 = tags.length; _j < _len1; _j++) {
    100110          tag = tags[_j];
    101           if (tag.indexOf(keyword) !== -1) matches += 1;
     111          if (tag.indexOf(keyword) !== -1) {
     112            matches += 1;
     113          }
    102114        }
    103115      }
  • 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
     2var __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; };
    34
    45Annotator.Plugin.Unsupported = (function(_super) {
     
    78
    89  function Unsupported() {
    9     Unsupported.__super__.constructor.apply(this, arguments);
     10    return Unsupported.__super__.constructor.apply(this, arguments);
    1011  }
    1112
Note: See TracChangeset for help on using the changeset viewer.