808
|
1 /**
|
|
2 digilib plugin stub
|
|
3 */
|
|
4
|
|
5 (function($) {
|
|
6
|
|
7 var geom;
|
|
8
|
|
9 var FULL_AREA;
|
|
10
|
|
11 var buttons = {
|
|
12 stub : {
|
|
13 onclick : ["doStub", 1],
|
|
14 tooltip : "what does this button do?",
|
|
15 icon : "stub.png"
|
|
16 }
|
|
17 };
|
|
18
|
|
19 var defaults = {
|
|
20 // is stub active?
|
|
21 'isStubActive' : true
|
|
22 };
|
|
23
|
|
24 var actions = {
|
|
25 // action code goes here
|
|
26 doStub : function (data, param) {
|
|
27 var settings = data.settings;
|
|
28 console.log('isStubActive', settings.isStubActive);
|
|
29 // do some useful stuff ...
|
|
30 }
|
|
31 };
|
|
32
|
|
33 // plugin installation called by digilib on plugin object.
|
|
34 var install = function(digilib) {
|
|
35 console.debug('installing stub plugin. digilib:', digilib);
|
|
36 // import geometry classes
|
|
37 geom = digilib.fn.geometry;
|
|
38 FULL_AREA = geom.rectangle(0,0,1,1);
|
|
39 // add defaults
|
|
40 $.extend(digilib.defaults, defaults);
|
|
41 // add actions
|
|
42 $.extend(digilib.actions, actions);
|
|
43 // add buttons
|
|
44 $.extend(digilib.buttons, buttons);
|
|
45 };
|
|
46
|
|
47 // plugin initialization
|
|
48 var init = function (data) {
|
|
49 console.debug('initialising stub plugin. data:', data);
|
|
50 var $data = $(data);
|
|
51 // install event handler
|
|
52 $data.bind('setup', handleSetup);
|
|
53 $data.bind('update', handleUpdate);
|
|
54 $data.bind('redisplay', handleRedisplay);
|
|
55 $data.bind('dragZoom', handleDragZoom);
|
|
56 };
|
|
57
|
|
58
|
|
59 var handleSetup = function (evt) {
|
|
60 console.debug("stub: handleSetup");
|
|
61 var data = this;
|
|
62 };
|
|
63
|
|
64 var handleUpdate = function (evt) {
|
|
65 console.debug("stub: handleUpdate");
|
|
66 var data = this;
|
|
67 };
|
|
68
|
|
69 var handleRedisplay = function (evt) {
|
|
70 console.debug("stub: handleRedisplay");
|
|
71 var data = this;
|
|
72 };
|
|
73
|
|
74 var handleDragZoom = function (evt, zoomArea) {
|
|
75 var data = this;
|
|
76 };
|
|
77
|
|
78 // plugin object with name and init
|
|
79 // shared objects filled by digilib on registration
|
|
80 var plugin = {
|
|
81 name : 'pluginstub',
|
|
82 install : install,
|
|
83 init : init,
|
|
84 buttons : {},
|
|
85 actions : {},
|
|
86 fn : {},
|
|
87 plugins : {}
|
|
88 };
|
|
89
|
|
90 if ($.fn.digilib == null) {
|
|
91 $.error("jquery.digilib.pluginstub must be loaded after jquery.digilib!");
|
|
92 } else {
|
|
93 $.fn.digilib('plugin', plugin);
|
|
94 }
|
|
95 })(jQuery);
|