X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/f938afb8ab4cb091d12e0ef0311eaea14b774798..68b9d53fb10d3ab01c176801e09addb9c06ff7bb:/redakcja/static/js/wiki/view_gallery.js?ds=sidebyside diff --git a/redakcja/static/js/wiki/view_gallery.js b/redakcja/static/js/wiki/view_gallery.js index aa39e15f..4b74b3e8 100644 --- a/redakcja/static/js/wiki/view_gallery.js +++ b/redakcja/static/js/wiki/view_gallery.js @@ -1,14 +1,17 @@ (function($){ function normalizeNumber(pageNumber, pageCount){ - // Numer strony musi być pomiędzy 1 a najwyższym numerem + // Page number should be >= 1, <= pageCount; 0 if pageCount = 0 var pageNumber = parseInt(pageNumber, 10); + if (!pageCount) + return 0; + if (!pageNumber || - pageNumber == NaN || - pageNumber == Infinity || - pageNumber == -Infinity || - pageNumber < 1) + isNaN(pageNumber) || + pageNumber == Infinity || + pageNumber == -Infinity || + pageNumber < 1) return 1; if (pageNumber > pageCount) @@ -45,12 +48,14 @@ var old_callback = options.callback || function() { }; this.noupdate_hash_onenter = true; + this.vsplitbar = 'GALERIA'; options.callback = function(){ var self = this; this.dimensions = {}; this.zoomFactor = 1; + this.config().page = CurrentDocument.galleryStart; this.$element = $("#side-gallery"); this.$numberInput = $('.page-number', this.$element); @@ -65,7 +70,7 @@ event.preventDefault(); self.setPage($(this).val()); }); - + $('.previous-page', this.$element).click(function(){ self.setPage(parseInt(self.$numberInput.val(),10) - 1); }); @@ -87,7 +92,7 @@ self.dimensions.galleryHeight = self.$image.parent().height(); }); - $('.gallery-image img', this.$element).load(function(){ + this.$image.load(function(){ console.log("Image loaded.") self._resizeImage(); }).bind('mousedown', function() { @@ -108,8 +113,8 @@ var $img = this.$image; $img.css({ - width: null, - height: null + width: '', + height: '' }); this.dimensions = { @@ -162,12 +167,6 @@ // var position = normalizePosition(this.$image.position().left, this.$image.position().top, this.dimensions.galleryWidth, this.dimensions.galleryHeight, this.dimensions.width, this.dimensions.height); this._resizeImage(); - /* this.$image.css({ - width: this.dimensions.width, - height: this.dimensions.height, - left: position.x, - top: position.y - });*/ }; /* @@ -224,11 +223,15 @@ $.wiki.Perspective.prototype.onEnter.call(this); + $('.vsplitbar').not('.active').trigger('click'); + $(".vsplitbar-title").html("↓ GALERIA ↓"); + this.doc.refreshGallery({ success: function(doc, data){ self.$image.show(); console.log("gconfig:", self.config().page ); self.setPage( self.config().page ); + $('#imagesCount').html("/" + doc.galleryImages.length); $('.error_message', self.$element).hide(); if(success) success(); @@ -248,4 +251,4 @@ $.wiki.ScanGalleryPerspective = ScanGalleryPerspective; -})(jQuery); \ No newline at end of file +})(jQuery);