Mercurial > hg > digilib
comparison client/digitallibrary/jquery/jquery.digilib.js @ 753:8452a485e0e7 jquery
primitive plugin extension mechanism - unsure how useful this is
author | hertzhaft |
---|---|
date | Tue, 08 Feb 2011 23:57:39 +0100 |
parents | fb4ffac2950d |
children | 17539f6838b6 |
comparison
equal
deleted
inserted
replaced
749:4b492b7900fb | 753:8452a485e0e7 |
---|---|
583 if (qual >= 0 && qual <= 2) { | 583 if (qual >= 0 && qual <= 2) { |
584 setQuality(data, qual); | 584 setQuality(data, qual); |
585 redisplay(data); | 585 redisplay(data); |
586 } | 586 } |
587 }, | 587 }, |
588 | 588 |
589 // calibrate (only faking) | 589 // calibrate (only faking) |
590 calibrate : function (data) { | 590 calibrate : function (data) { |
591 getImageInfo(data); | 591 getImageInfo(data); |
592 } | 592 }, |
593 | |
593 }; | 594 }; |
594 | 595 |
595 // returns parameters from page url | 596 // returns parameters from page url |
596 var parseQueryParams = function() { | 597 var parseQueryParams = function() { |
597 return parseQueryString(window.location.search.slice(1)); | 598 return parseQueryString(window.location.search.slice(1)); |
1119 // returns function for load event of scaler img | 1120 // returns function for load event of scaler img |
1120 var scalerImgLoadedHandler = function (data) { | 1121 var scalerImgLoadedHandler = function (data) { |
1121 return function () { | 1122 return function () { |
1122 var $img = $(this); | 1123 var $img = $(this); |
1123 var $scaler = data.$scaler; | 1124 var $scaler = data.$scaler; |
1124 // create Transform from current area and picsize | 1125 // create Transform from current zoomArea and image size |
1125 data.imgTrafo = getImgTrafo($img, data.zoomArea, | 1126 data.imgTrafo = getImgTrafo($img, data.zoomArea, |
1126 data.settings.rot, data.scalerFlags.hmir, data.scalerFlags.vmir); | 1127 data.settings.rot, data.scalerFlags.hmir, data.scalerFlags.vmir); |
1127 console.debug("imgTrafo=", data.imgTrafo); | 1128 // console.debug("imgTrafo=", data.imgTrafo); |
1129 var imgRect = geom.rectangle($img); | |
1130 // console.debug("imgrect=", imgRect); | |
1128 // adjust scaler div size | 1131 // adjust scaler div size |
1129 var imgRect = geom.rectangle($img); | |
1130 console.debug("imgrect=", imgRect); | |
1131 imgRect.adjustDiv($scaler); | 1132 imgRect.adjustDiv($scaler); |
1132 // show image in case it was hidden (for example in zoomDrag) | 1133 // show image in case it was hidden (for example in zoomDrag) |
1133 $img.css('visibility', 'visible'); | 1134 $img.css('visibility', 'visible'); |
1134 $scaler.css({'opacity' : '1', 'background-image' : 'none'}); | 1135 $scaler.css({'opacity' : '1', 'background-image' : 'none'}); |
1135 // display marks | 1136 // display marks |
1578 console.debug = logFunction('_debug'); | 1579 console.debug = logFunction('_debug'); |
1579 console.error = logFunction('_error'); | 1580 console.error = logFunction('_error'); |
1580 } | 1581 } |
1581 | 1582 |
1582 // hook plugin into jquery | 1583 // hook plugin into jquery |
1583 $.fn.digilib = function(action) { | 1584 $.fn.digilib = function(action, obj) { |
1584 if (actions[action]) { | 1585 // plugin extension mechanism |
1586 if (action === 'extendPlugin') { | |
1587 // for each digilib $elem extend data.settings with obj.options | |
1588 if (obj.options) { | |
1589 this.each(function() { | |
1590 var $elem = $(this); | |
1591 // console.debug('extending:', $elem); | |
1592 var data = $elem.data('digilib'); | |
1593 if (!data) { | |
1594 return console.log('cannot extend digilib plugin, element not initialised!'); | |
1595 } | |
1596 var settings = data.settings; | |
1597 $.extend(settings, obj.options); | |
1598 // console.log('settings:', settings); | |
1599 }); | |
1600 } | |
1601 delete(obj.options); | |
1602 // extend the plugin actions (to make this useful, | |
1603 // maybe we need to expose some more internal functions) | |
1604 $.extend(actions, obj); | |
1605 } else if (actions[action]) { | |
1585 // call action on this with the remaining arguments (inserting data as first argument) | 1606 // call action on this with the remaining arguments (inserting data as first argument) |
1586 var $elem = $(this); | 1607 var $elem = $(this); |
1587 var data = $elem.data('digilib'); | 1608 var data = $elem.data('digilib'); |
1588 var args = Array.prototype.slice.call(arguments, 1); | 1609 var args = Array.prototype.slice.call(arguments, 1); |
1589 args.unshift(data); | 1610 args.unshift(data); |