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