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


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

new version of annotator.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.