X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/dba809feb44cd1c4d155f3e3254a1cca5323f95f..3913c541b2e25e10d9c80feef9d32b80d2bad82b:/project/static/js/views/panel_container.js?ds=sidebyside diff --git a/project/static/js/views/panel_container.js b/project/static/js/views/panel_container.js index e4950ba8..8d383e1a 100644 --- a/project/static/js/views/panel_container.js +++ b/project/static/js/views/panel_container.js @@ -1,18 +1,19 @@ /*globals View render_template panels*/ var PanelContainerView = View.extend({ + _className: 'PanelContainerView', element: null, model: null, template: 'panel-container-view-template', contentView: null, init: function(element, model, template) { - this.element = $(element); - this.model = model; - this.template = template || this.template; - - this.element.html(render_template(this.template, {panels: panels})); - $('select', this.element.get(0)).bind('change.panel-container-view', this.selectChanged.bind(this)); + this._super(element, model, template); + + $('.panel-main-toolbar select', this.element.get(0)).bind('change.panel-container-view', this.selectChanged.bind(this)); + $('.panel-main-toolbar .refresh', this.element.get(0)) + .bind('click.panel-container-view', this.refreshButtonClicked.bind(this)) + .attr('disabled', 'disabled'); }, selectChanged: function(event) { @@ -23,11 +24,20 @@ var PanelContainerView = View.extend({ this.contentView = null; } this.contentView = new klass($('.content-view', - this.element.get(0)), this.model.contentModels[value]); + this.element.get(0)), this.model.contentModels[value], this); + $('.panel-main-toolbar .refresh', this.element.get(0)).attr('disabled', null); + }, + + refreshButtonClicked: function(event) { + if (this.contentView) { + console.log('refreshButtonClicked'); + this.contentView.reload(); + } }, dispose: function() { - $('select', this.element.get(0)).unbind('change.panel-container-view'); + $('.panel-main-toolbar .refresh', this.element.get(0)).unbind('click.panel-container-view'); + $('.panel-main-toolbar select', this.element.get(0)).unbind('change.panel-container-view'); this._super(); } });