diff annotator_files/lib/plugin/tags.js @ 4:6979313586cf

new version of annotator.
author casties
date Mon, 27 Aug 2012 19:05:38 +0200
parents 6356e78ccf5c
children
line wrap: on
line diff
--- a/annotator_files/lib/plugin/tags.js	Thu Apr 05 19:37:27 2012 +0200
+++ b/annotator_files/lib/plugin/tags.js	Mon Aug 27 19:05:38 2012 +0200
@@ -1,6 +1,7 @@
+// Generated by CoffeeScript 1.3.3
 var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
-  __hasProp = Object.prototype.hasOwnProperty,
-  __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; };
+  __hasProp = {}.hasOwnProperty,
+  __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; };
 
 Annotator.Plugin.Tags = (function(_super) {
 
@@ -8,8 +9,9 @@
 
   function Tags() {
     this.setAnnotationTags = __bind(this.setAnnotationTags, this);
+
     this.updateField = __bind(this.updateField, this);
-    Tags.__super__.constructor.apply(this, arguments);
+    return Tags.__super__.constructor.apply(this, arguments);
   }
 
   Tags.prototype.options = {
@@ -17,7 +19,9 @@
       var tags;
       string = $.trim(string);
       tags = [];
-      if (string) tags = string.split(/\s+/);
+      if (string) {
+        tags = string.split(/\s+/);
+      }
       return tags;
     },
     stringifyTags: function(array) {
@@ -30,7 +34,9 @@
   Tags.prototype.input = null;
 
   Tags.prototype.pluginInit = function() {
-    if (!Annotator.supported()) return;
+    if (!Annotator.supported()) {
+      return;
+    }
     this.field = this.annotator.editor.addField({
       label: Annotator._t('Add some tags here') + '\u2026',
       load: this.updateField,
@@ -60,7 +66,9 @@
   Tags.prototype.updateField = function(field, annotation) {
     var value;
     value = '';
-    if (annotation.tags) value = this.stringifyTags(annotation.tags);
+    if (annotation.tags) {
+      value = this.stringifyTags(annotation.tags);
+    }
     return this.input.val(value);
   };
 
@@ -87,8 +95,10 @@
 })(Annotator.Plugin);
 
 Annotator.Plugin.Tags.filterCallback = function(input, tags) {
-  var keyword, keywords, matches, tag, _i, _j, _len, _len2;
-  if (tags == null) tags = [];
+  var keyword, keywords, matches, tag, _i, _j, _len, _len1;
+  if (tags == null) {
+    tags = [];
+  }
   matches = 0;
   keywords = [];
   if (input) {
@@ -96,9 +106,11 @@
     for (_i = 0, _len = keywords.length; _i < _len; _i++) {
       keyword = keywords[_i];
       if (tags.length) {
-        for (_j = 0, _len2 = tags.length; _j < _len2; _j++) {
+        for (_j = 0, _len1 = tags.length; _j < _len1; _j++) {
           tag = tags[_j];
-          if (tag.indexOf(keyword) !== -1) matches += 1;
+          if (tag.indexOf(keyword) !== -1) {
+            matches += 1;
+          }
         }
       }
     }