Changeset 4:6979313586cf in OKFNAnnotator (for Zope) for annotator_files/lib/plugin/filter.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/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  };
Note: See TracChangeset for help on using the changeset viewer.