X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/3193141f55df20910cf8ba35f9e669d79c90d3f4..04b05946ab640eaf9135a73772b704dd41c323e7:/platforma/static/js/views/gallery.js?ds=inline diff --git a/platforma/static/js/views/gallery.js b/platforma/static/js/views/gallery.js index 74493444..d3398ce0 100644 --- a/platforma/static/js/views/gallery.js +++ b/platforma/static/js/views/gallery.js @@ -13,7 +13,7 @@ var ImageGalleryView = View.extend({ this._super(element, model, template); this.parent = parent; - console.log("galley model", this.model); + console.log("gallery model", this.model); this.model .addObserver(this, 'data', this.modelDataChanged.bind(this)) @@ -25,12 +25,15 @@ var ImageGalleryView = View.extend({ }, modelDataChanged: function(property, value) - { - if( property == 'data') - { - this.render(); - this.gotoPage(this.currentPage); - } + { + console.log(this.model.get('state'), value, value.length); + if ((this.model.get('state') == 'synced') && (value.length == 0)) { + console.log('tutaj'); + this.render('image-gallery-empty-template'); + } else { + this.render(); + this.gotoPage(this.currentPage); + } }, gotoPage: function(index) @@ -85,9 +88,12 @@ var ImageGalleryView = View.extend({ modelStateChanged: function(property, value) { if (value == 'loading') { - this.parent.freeze('Ładowanie...'); + this.freeze('Ładowanie...'); } else { - this.parent.unfreeze(); + if ((value == 'synced') && (this.model.get('data').length == 0)) { + this.render('image-gallery-empty-template'); + } + this.unfreeze(); } }, @@ -102,8 +108,7 @@ var ImageGalleryView = View.extend({ $page.hide(); $('img', $page).unbind(); - $page.empty(); - + $page.empty(); this.setPageViewOffset($page, {x:0, y:0}); }, @@ -183,7 +188,11 @@ var ImageGalleryView = View.extend({ offset.y = vp_height-MARGIN; $page.css({left: offset.x, top: offset.y}); - }, + }, + + reload: function() { + this.model.load(true); + }, renderImage: function(target) { @@ -207,23 +216,24 @@ var ImageGalleryView = View.extend({ mousedown(this.pageDragStart.bind(this)); }, - render: function() + render: function(template) { - if(!this.model) return; - - /* first unbind all */ - if(this.$nextButton) this.$nextButton.unbind(); - if(this.$prevButton) this.$prevButton.unbind(); - if(this.$jumpButton) this.$jumpButton.unbind(); - if(this.$pageInput) this.$pageInput.unbind(); - - if(this.$zoomInButton) this.$zoomInButton.unbind(); - if(this.$zoomOutButton) this.$zoomOutButton.unbind(); - if(this.$zoomResetButton) this.$zoomResetButton.unbind(); - + if(!this.model) return; + + /* first unbind all */ + if(this.$nextButton) this.$nextButton.unbind(); + if(this.$prevButton) this.$prevButton.unbind(); + if(this.$jumpButton) this.$jumpButton.unbind(); + if(this.$pageInput) this.$pageInput.unbind(); + + if(this.$zoomInButton) this.$zoomInButton.unbind(); + if(this.$zoomOutButton) this.$zoomOutButton.unbind(); + if(this.$zoomResetButton) this.$zoomResetButton.unbind(); + + if (!template) { /* render */ this._super(); - + /* fetch important parts */ this.$pageListRoot = $('.image-gallery-page-list', this.element); this.$pages = $('.image-gallery-page-container', this.$pageListRoot); @@ -249,6 +259,9 @@ var ImageGalleryView = View.extend({ this.gotoPage(this.currentPage); this.changePageZoom(this.pageZoom); + } else { + this._super(template); + } }, jumpToPage: function() {