annotate webapp/src/main/webapp/jquery/jquery.digilib.marks.js @ 1083:bab0bdac6d92

first version of annotations plugin. moved mark background image.
author robcast
date Wed, 30 May 2012 21:42:44 +0200
parents b0a18f8af7bf
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
1 /**
1083
bab0bdac6d92 first version of annotations plugin.
robcast
parents: 1072
diff changeset
2 * digilib marks plugin
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
3 */
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
4
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
5 (function($) {
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
6
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
7 // affine geometry
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
8 var geom = null;
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
9 // plugin object with digilib data
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
10 var digilib = null;
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
11
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
12 var buttons = {
992
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
13 mark : {
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
14 onclick : "setMark",
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
15 tooltip : "set a mark",
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
16 icon : "mark.png"
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
17 },
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
18 delmark : {
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
19 onclick : "removeMark",
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
20 tooltip : "delete the last mark",
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
21 icon : "delmark.png"
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
22 }
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
23 };
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
24
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
25 var defaults = {
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
26 };
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
27
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
28 var actions = {
992
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
29 /**
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
30 * set a mark by clicking (or giving a position)
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
31 *
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
32 * @param data
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
33 * @param mpos
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
34 */
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
35 setMark : function(data, mpos) {
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
36 if (mpos == null) {
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
37 // interactive
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
38 setMark(data);
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
39 } else {
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
40 // use position
1083
bab0bdac6d92 first version of annotations plugin.
robcast
parents: 1072
diff changeset
41 data.marks.push(mpos);
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
42 digilib.fn.redisplay(data);
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
43 }
992
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
44 },
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
45
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
46 /**
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
47 * remove the last mark
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
48 *
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
49 * @param data
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
50 */
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
51 removeMark : function(data) {
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
52 data.marks.pop();
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
53 digilib.fn.redisplay(data);
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
54 }
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
55 };
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
56
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
57 // plugin installation called by digilib on plugin object.
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
58 var install = function(plugin) {
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
59 digilib = plugin;
993
862d2ae56c20 fixed problems with new events and some browsers.
robcast
parents: 992
diff changeset
60 console.debug('installing marks plugin. digilib:', digilib);
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
61 // import geometry classes
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
62 geom = digilib.fn.geometry;
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
63 // add defaults, actins, buttons
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
64 $.extend(true, digilib.defaults, defaults);
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
65 $.extend(digilib.actions, actions);
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
66 $.extend(true, digilib.buttons, buttons);
992
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
67 // export packMarks for regions.js
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
68 digilib.fn.packMarks = packMarks;
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
69 };
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
70
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
71 // plugin initialization
992
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
72 var init = function(data) {
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
73 console.debug('initialising marks plugin. data:', data);
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
74 var $data = $(data);
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
75 // install event handler
992
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
76 $data.on('update', handleUpdate);
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
77 $data.on('pack', handlePack);
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
78 $data.on('unpack', handleUnpack);
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
79 };
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
80
992
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
81 var handleUpdate = function(evt) {
993
862d2ae56c20 fixed problems with new events and some browsers.
robcast
parents: 992
diff changeset
82 console.debug("marks: handleUpdate");
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
83 var data = this;
1072
b0a18f8af7bf first mark was not removed from screen when deleted
hertzhaft
parents: 996
diff changeset
84 if (data.marks != null) {
996
0b63093d598e cssPrefix works now.
robcast
parents: 993
diff changeset
85 renderMarks(data);
0b63093d598e cssPrefix works now.
robcast
parents: 993
diff changeset
86 }
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
87 };
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
88
992
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
89 /**
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
90 * unpack mk parameter into marks array
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
91 */
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
92 var handleUnpack = function(evt) {
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
93 var data = this;
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
94 var settings = data.settings;
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
95 var marks = [];
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
96 var pa;
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
97 if (settings.mk) {
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
98 var mk = settings.mk;
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
99 if (mk.indexOf(";") >= 0) {
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
100 pa = mk.split(";"); // old format with ";"
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
101 } else {
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
102 pa = mk.split(","); // new format
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
103 }
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
104 for ( var i = 0; i < pa.length; i++) {
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
105 var pos = pa[i].split("/");
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
106 if (pos.length > 1) {
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
107 marks.push(geom.position(pos[0], pos[1]));
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
108 }
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
109 }
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
110 }
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
111 data.marks = marks;
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
112 };
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
113
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
114 /**
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
115 * pack marks into parameters
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
116 */
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
117 var handlePack = function(data) {
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
118 var data = this;
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
119 var settings = data.settings;
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
120 var marks = data.marks;
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
121 packMarks(settings, marks);
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
122 };
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
123
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
124 /**
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
125 * pack marks into parameter
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
126 */
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
127 var packMarks = function(settings, marks) {
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
128 if (!marks)
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
129 return;
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
130 settings.mk = '';
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
131 for ( var i = 0; i < marks.length; i++) {
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
132 if (i) {
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
133 settings.mk += ',';
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
134 }
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
135 settings.mk += digilib.fn.cropFloatStr(marks[i].x) + '/' + digilib.fn.cropFloatStr(marks[i].y);
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
136 }
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
137 };
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
138
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
139 /**
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
140 * place marks on the image
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
141 *
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
142 */
992
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
143 var renderMarks = function(data) {
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
144 if (data.marks == null || data.$img == null || data.imgTrafo == null)
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
145 return;
996
0b63093d598e cssPrefix works now.
robcast
parents: 993
diff changeset
146 var cssPrefix = data.settings.cssPrefix;
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
147 var $elem = data.$elem;
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
148 var marks = data.marks;
996
0b63093d598e cssPrefix works now.
robcast
parents: 993
diff changeset
149 console.debug("renderMarks: marks="+marks);
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
150 // clear marks
996
0b63093d598e cssPrefix works now.
robcast
parents: 993
diff changeset
151 $elem.find('div.'+cssPrefix+'mark').remove();
992
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
152 for ( var i = 0; i < marks.length; i++) {
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
153 var mark = marks[i];
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
154 if (data.zoomArea.containsPosition(mark)) {
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
155 var mpos = data.imgTrafo.transform(mark);
992
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
156 console.debug("renderMarks: pos=", mpos);
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
157 // create mark
996
0b63093d598e cssPrefix works now.
robcast
parents: 993
diff changeset
158 var html = '<div class="'+cssPrefix+'mark '+cssPrefix+'overlay">' + (i + 1) + '</div>';
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
159 var $mark = $(html);
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
160 $elem.append($mark);
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
161 mpos.adjustDiv($mark);
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
162 }
992
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
163 }
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
164 };
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
165
992
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
166 /**
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
167 * add a mark where clicked.
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
168 *
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
169 */
992
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
170 var setMark = function(data) {
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
171 var $scaler = data.$scaler;
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
172 // unbind other handler TODO: do we need to do this?
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
173 $scaler.off(".dlZoomDrag");
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
174 // start event capturing
992
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
175 $scaler.one('mousedown.dlSetMark', function(evt) {
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
176 // event handler adding a new mark
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
177 console.log("setmark at=", evt);
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
178 var mpos = geom.position(evt);
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
179 var pos = data.imgTrafo.invtransform(mpos);
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
180 data.marks.push(pos);
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
181 digilib.fn.redisplay(data);
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
182 return false;
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
183 });
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
184 };
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
185
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
186 // plugin object with name and init
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
187 // shared objects filled by digilib on registration
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
188 var plugin = {
992
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
189 name : 'marks',
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
190 install : install,
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
191 init : init,
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
192 buttons : {},
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
193 actions : {},
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
194 fn : {},
4fcc85d4db8f pack and unpack parameters now as events. used in marks plugin.
robcast
parents: 991
diff changeset
195 plugins : {}
991
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
196 };
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
197
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
198 if ($.fn.digilib == null) {
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
199 $.error("jquery.digilib.marks must be loaded after jquery.digilib!");
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
200 } else {
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
201 $.fn.digilib('plugin', plugin);
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
202 }
497ab03868ab moved marks to separate plugin. (pack and unpack is still in digilib.js)
robcast
parents:
diff changeset
203 })(jQuery);