X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/da27dfe2be374e3f8626f00662645a52013576fd..8d490fc7810e0052bad3414b445b24276bbfca63:/platforma/static/js/views/gallery.js diff --git a/platforma/static/js/views/gallery.js b/platforma/static/js/views/gallery.js index e0e3dc7e..a403c9ef 100644 --- a/platforma/static/js/views/gallery.js +++ b/platforma/static/js/views/gallery.js @@ -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,8 +88,11 @@ var ImageGalleryView = View.extend({ modelStateChanged: function(property, value) { if (value == 'loading') { - // this.freeze('Ładowanie...'); + this.freeze('Ładowanie...'); } else { + if ((value == 'synced') && (this.model.get('data').length == 0)) { + this.render('image-gallery-empty-template'); + } this.unfreeze(); } }, @@ -182,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) { @@ -206,23 +216,26 @@ 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; + + $('.choose-gallery-button', this.element).unbind(); + + /* 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); @@ -248,6 +261,15 @@ var ImageGalleryView = View.extend({ this.gotoPage(this.currentPage); this.changePageZoom(this.pageZoom); + } else { + this._super(template); + + var self = this; + $('.choose-gallery-button', self.element).click(function() { + console.log('CLICK CLICK') + self.model.setGallery($('#id_subpath', self.element).val()); + }); + } }, jumpToPage: function() {