1 /*global View render_template panels */
2 var ImageGalleryView = View.extend({
3 _className: 'ImageGalleryView',
6 template: 'image-gallery-view-template',
8 init: function(element, model, parent, template)
12 this._super(element, model, template);
16 .addObserver(this, 'data', this.modelDataChanged.bind(this))
17 .addObserver(this, 'state', this.modelStateChanged.bind(this));
19 //$('.image-gallery-view', this.element).html(this.model.get('data'));
20 this.modelStateChanged('state', this.model.get('state'));
24 modelDataChanged: function(property, value)
26 $.log('updating pages', property, value);
27 if( property == 'data')
29 this.gotoPage(this.currentPage);
30 this.element.html(render_template(this.template, this));
34 gotoPage: function(index) {
38 var n = this.model.get('pages').length;
39 if (index >= n) index = n-1;
41 this.currentPage = index;
44 modelStateChanged: function(property, value) {
45 if (value == 'synced' || value == 'dirty') {
46 this.parent.unfreeze();
47 } else if (value == 'unsynced') {
48 this.parent.freeze('Niezsynchronizowany...');
49 } else if (value == 'loading') {
50 this.parent.freeze('Ładowanie...');
51 } else if (value == 'saving') {
52 this.parent.freeze('Zapisywanie...');
57 this.model.removeObserver(this);
63 panels['gallery'] = ImageGalleryView;