comparison client/digitallibrary/jquery/jquery.digilib.js @ 610:2f2cd8c44a1c jquery

toggle view event handlers for bird's eye and 'about windows
author hertzhaft
date Sun, 16 Jan 2011 22:24:50 +0100
parents e18dedef32fb
children d332c61da1b0
comparison
equal deleted inserted replaced
609:e18dedef32fb 610:2f2cd8c44a1c
49 onclick : "javascript:gotoPageWin()", 49 onclick : "javascript:gotoPageWin()",
50 tooltip : "specify image", 50 tooltip : "specify image",
51 img : "page.png" 51 img : "page.png"
52 }, 52 },
53 bird : { 53 bird : {
54 onclick : "javascript:toggleBirdDiv()", 54 onclick : "toggleBirdDiv",
55 tooltip : "show bird's eye view", 55 tooltip : "show bird's eye view",
56 img : "birds-eye.png" 56 img : "birds-eye.png"
57 }, 57 },
58 help : { 58 help : {
59 onclick : "javascript:toggleAboutDiv()", 59 onclick : "toggleAboutDiv",
60 tooltip : "about Digilib", 60 tooltip : "about Digilib",
61 img : "help.png" 61 img : "help.png"
62 }, 62 },
63 reset : { 63 reset : {
64 onclick : "javascript:resetImage()", 64 onclick : "javascript:resetImage()",
132 }, 132 },
133 SEP : { 133 SEP : {
134 img : "sep.png" 134 img : "sep.png"
135 } 135 }
136 }; 136 };
137 137
138 var defaults = { 138 var defaults = {
139 // the root digilib element, for easy retrieval
140 'digilibRoot' : null,
139 // version of this script 141 // version of this script
140 'version' : 'jquery.digilib.js 1.0', 142 'version' : 'jquery.digilib.js 1.0',
141 // logo url 143 // logo url
142 'logoUrl' : '../img/digilib-logo-text1.png', 144 'logoUrl' : '../img/digilib-logo-text1.png',
143 // repository url 145 // repository url
194 if (isFullscreen) { 196 if (isFullscreen) {
195 elemSettings = $.extend({}, settings, queryParams); 197 elemSettings = $.extend({}, settings, queryParams);
196 } else { 198 } else {
197 elemSettings = $.extend({}, settings, parseImgParams($elem)); 199 elemSettings = $.extend({}, settings, parseImgParams($elem));
198 }; 200 };
201 // store $(this) element in the settings
202 elemSettings.digilibRoot = $elem;
199 // store in data element 203 // store in data element
200 $elem.data('digilib', { 204 $elem.data('digilib', {
201 target : $elem, 205 target : $elem,
202 settings : elemSettings 206 settings : elemSettings
203 }); 207 });
204 } 208 }
205 // create HTML structure 209 // create HTML structure
206 setupScalerDiv($elem, elemSettings); 210 setupScalerDiv($elem, elemSettings);
207 setupButtons($elem, elemSettings, 'buttonsStandard'); 211 setupButtons($elem, elemSettings, 'buttonsStandard');
212 // bird's eye view creation - could be deferred?
208 setupBirdviewDiv($elem, elemSettings); 213 setupBirdviewDiv($elem, elemSettings);
214 // about window creation - could be deferred? restrict to only one item?
209 setupAboutDiv($elem, elemSettings); 215 setupAboutDiv($elem, elemSettings);
210 }); 216 });
211 }, 217 },
212 218
213 // clean up digilib 219 // clean up digilib
218 // Namespacing FTW 224 // Namespacing FTW
219 $(window).unbind('.digilib'); // unbinds all digilibs(?) 225 $(window).unbind('.digilib'); // unbinds all digilibs(?)
220 data.digilib.remove(); 226 data.digilib.remove();
221 $this.removeData('digilib'); 227 $this.removeData('digilib');
222 }); 228 });
229 },
230
231 // event handler: toggles the visibility of the 'about' window
232 toggleAboutDiv : function () {
233 var $elem = $(this); // the clicked button
234 var settings = $elem.data('digilib').settings;
235 var $root = settings.digilibRoot;
236 var $about = $root.find('div.about');
237 settings.isAboutDivVisible = !settings.isAboutDivVisible;
238 if (settings.isAboutDivVisible) {
239 $about.fadeIn();
240 } else {
241 $about.fadeOut();
242 };
243 return false;
244 },
245
246 // event handler: toggles the visibility of the bird's eye window
247 toggleBirdDiv : function () {
248 // xxx: red frame functionality still to be done!
249 var $elem = $(this); // the clicked button
250 var settings = $elem.data('digilib').settings;
251 var $root = settings.digilibRoot;
252 var $bird = $root.find('div.birdview');
253 settings.isBirdDivVisible = !settings.isBirdDivVisible;
254 if (settings.isBirdDivVisible) {
255 $bird.fadeIn();
256 } else {
257 $bird.fadeOut();
258 };
259 return false;
223 } 260 }
224 }; 261 };
225 262
226 // returns parameters from page url 263 // returns parameters from page url
227 var parseQueryParams = function() { 264 var parseQueryParams = function() {
347 $a.data('digilib', { 'name' : buttonName, 'settings' : settings } ); 384 $a.data('digilib', { 'name' : buttonName, 'settings' : settings } );
348 $a.bind('click', function() { 385 $a.bind('click', function() {
349 // get the context settings 386 // get the context settings
350 var data = $(this).data('digilib'); 387 var data = $(this).data('digilib');
351 // find the action for the clicked element 388 // find the action for the clicked element
352 console.log(data.settings.buttons[data.name].onclick); 389 var method = data.settings.buttons[data.name].onclick;
390 // find the digilib object with methods
391 var $root = data.settings.digilibRoot;
392 // execute as a method
393 $a.digilib(method);
394 console.log(onclick);
353 }); 395 });
354 // binding mit closure 396 // binding mit closure
355 //(function(){ var action = buttonSettings.onclick; 397 //(function(){ var action = buttonSettings.onclick;
356 // $a.bind('click', function(){ console.log( action )} ); 398 // $a.bind('click', function(){ console.log( action )} );
357 //})(); 399 //})();