Mercurial > hg > OKFNAnnotator
comparison annotator_files/lib/viewer.js @ 4:6979313586cf
new version of annotator.
author | casties |
---|---|
date | Mon, 27 Aug 2012 19:05:38 +0200 |
parents | 6356e78ccf5c |
children |
comparison
equal
deleted
inserted
replaced
3:6356e78ccf5c | 4:6979313586cf |
---|---|
1 // Generated by CoffeeScript 1.3.3 | |
1 var LinkParser, | 2 var LinkParser, |
2 __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, | 3 __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, |
3 __hasProp = Object.prototype.hasOwnProperty, | 4 __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 __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 | 6 |
6 Annotator.Viewer = (function(_super) { | 7 Annotator.Viewer = (function(_super) { |
7 | 8 |
8 __extends(Viewer, _super); | 9 __extends(Viewer, _super); |
9 | 10 |
26 readOnly: false | 27 readOnly: false |
27 }; | 28 }; |
28 | 29 |
29 function Viewer(options) { | 30 function Viewer(options) { |
30 this.onDeleteClick = __bind(this.onDeleteClick, this); | 31 this.onDeleteClick = __bind(this.onDeleteClick, this); |
32 | |
31 this.onEditClick = __bind(this.onEditClick, this); | 33 this.onEditClick = __bind(this.onEditClick, this); |
34 | |
32 this.load = __bind(this.load, this); | 35 this.load = __bind(this.load, this); |
36 | |
33 this.hide = __bind(this.hide, this); | 37 this.hide = __bind(this.hide, this); |
34 this.show = __bind(this.show, this); Viewer.__super__.constructor.call(this, $(this.html.element)[0], options); | 38 |
39 this.show = __bind(this.show, this); | |
40 Viewer.__super__.constructor.call(this, $(this.html.element)[0], options); | |
35 this.item = $(this.html.item)[0]; | 41 this.item = $(this.html.item)[0]; |
36 this.fields = []; | 42 this.fields = []; |
37 this.annotations = []; | 43 this.annotations = []; |
38 } | 44 } |
39 | 45 |
58 this.element.addClass(this.classes.hide); | 64 this.element.addClass(this.classes.hide); |
59 return this.publish('hide'); | 65 return this.publish('hide'); |
60 }; | 66 }; |
61 | 67 |
62 Viewer.prototype.load = function(annotations) { | 68 Viewer.prototype.load = function(annotations) { |
63 var annotation, controller, controls, del, edit, element, field, item, link, links, list, _i, _j, _len, _len2, _ref, _ref2; | 69 var annotation, controller, controls, del, edit, element, field, item, link, links, list, _i, _j, _len, _len1, _ref, _ref1; |
64 this.annotations = annotations || []; | 70 this.annotations = annotations || []; |
65 list = this.element.find('ul:first').empty(); | 71 list = this.element.find('ul:first').empty(); |
66 _ref = this.annotations; | 72 _ref = this.annotations; |
67 for (_i = 0, _len = _ref.length; _i < _len; _i++) { | 73 for (_i = 0, _len = _ref.length; _i < _len; _i++) { |
68 annotation = _ref[_i]; | 74 annotation = _ref[_i]; |
96 hideDelete: function() { | 102 hideDelete: function() { |
97 return del.attr('disabled', 'disabled'); | 103 return del.attr('disabled', 'disabled'); |
98 } | 104 } |
99 }; | 105 }; |
100 } | 106 } |
101 _ref2 = this.fields; | 107 _ref1 = this.fields; |
102 for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { | 108 for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { |
103 field = _ref2[_j]; | 109 field = _ref1[_j]; |
104 element = $(field.element).clone().appendTo(item)[0]; | 110 element = $(field.element).clone().appendTo(item)[0]; |
105 field.load(element, annotation, controller); | 111 field.load(element, annotation, controller); |
106 } | 112 } |
107 } | 113 } |
108 this.publish('load', [this.annotations]); | 114 this.publish('load', [this.annotations]); |
144 this.data = data; | 150 this.data = data; |
145 } | 151 } |
146 | 152 |
147 LinkParser.prototype.get = function(rel, cond) { | 153 LinkParser.prototype.get = function(rel, cond) { |
148 var d, k, keys, match, v, _i, _len, _ref, _results; | 154 var d, k, keys, match, v, _i, _len, _ref, _results; |
149 if (cond == null) cond = {}; | 155 if (cond == null) { |
156 cond = {}; | |
157 } | |
150 cond = $.extend({}, cond, { | 158 cond = $.extend({}, cond, { |
151 rel: rel | 159 rel: rel |
152 }); | 160 }); |
153 keys = (function() { | 161 keys = (function() { |
154 var _results; | 162 var _results; |