- function ScanGalleryPerspective(doc, callback){
- var self = this;
-
- this.perspective_id = '';
- this.doc = doc;
-
- this.dimensions = {};
- this.zoomFactor = 1;
- this.$element = $("#side-gallery");
- this.$numberInput = $('.page-number', this.$element);
-
- // ...
- var origin = {};
- var imageOrigin = {};
-
- this.$image = $('.gallery-image img', this.$element).attr('unselectable', 'on');
-
- // button handlers
- this.$numberInput.change(function(event){
- event.preventDefault();
- self.setPage($(this).val());
- });
-
- $('.previous-page', this.$element).click(function(){
- self.setPage(self.$numberInput.val() - 1);
- });
-
- $('.nexy-page', this.$element).click(function(){
- self.setPage(self.$numberInput.val() + 1);
- });
-
- $('.zoom-in', this.$element).click(function(){
- self.alterZoom(0.2);
- });
-
- $('.zoom-out', this.$element).click(function(){
- self.alterZoom(-0.2);
- });
-
- $(window).resize(function(){
- self.dimensions.galleryWidth = self.$image.parent().width();
- self.dimensions.galleryHeight = self.$image.parent().height();
- });
+ function ScanGalleryPerspective(options){
+ var old_callback = options.callback || function() { };
+
+ options.callback = function(){
+ var self = this;
+
+ this.dimensions = {};
+ this.zoomFactor = 1;
+ this.$element = $("#side-gallery");
+ this.$numberInput = $('.page-number', this.$element);
+
+ // ...
+ var origin = {};
+ var imageOrigin = {};
+
+ this.$image = $('.gallery-image img', this.$element).attr('unselectable', 'on');
+
+ // button handlers
+ this.$numberInput.change(function(event){
+ event.preventDefault();
+ self.setPage($(this).val());
+ });
+
+ $('.previous-page', this.$element).click(function(){
+ self.setPage(parseInt(self.$numberInput.val(),10) - 1);
+ });
+
+ $('.next-page', this.$element).click(function(){
+ self.setPage(parseInt(self.$numberInput.val(),10) + 1);
+ });
+
+ $('.zoom-in', this.$element).click(function(){
+ self.alterZoom(0.2);
+ });
+
+ $('.zoom-out', this.$element).click(function(){
+ self.alterZoom((-0.2));
+ });
+
+ $(window).resize(function(){
+ self.dimensions.galleryWidth = self.$image.parent().width();
+ self.dimensions.galleryHeight = self.$image.parent().height();
+ });
+
+ $('.gallery-image img', this.$element).load(function(){
+ console.log("Image loaded.")
+ self._resizeImage();
+ }).bind('mousedown', function() {
+ self.imageMoveStart.apply(self, arguments);
+ });
+
+ old_callback.call(this);
+ };