Changeset 4:6979313586cf in OKFNAnnotator (for Zope) for annotator_files/lib/plugin/filter.js
- Timestamp:
- Aug 27, 2012, 5:05:38 PM (12 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 };
Note: See TracChangeset
for help on using the changeset viewer.