X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/9490c431ea46a6c3d9f1d348a5b525c0bd3b6359..dc3368dad09fa4acb4cc480845f0ff3edc126483:/project/static/js/views/view.js diff --git a/project/static/js/views/view.js b/project/static/js/views/view.js index 975eeb9d..bc8266c1 100644 --- a/project/static/js/views/view.js +++ b/project/static/js/views/view.js @@ -1,26 +1,39 @@ -/*globals Class render_template*/ -var View = Class.extend({ +/*globals Editor render_template*/ +var View = Editor.Object.extend({ + _className: 'View', element: null, model: null, template: null, overlayClass: 'view-overlay', overlay: null, - - init: function(element, model, template) { + + init: function(element, model, template) + { + console.log("init for view"); this.element = $(element); this.model = model; this.template = template || this.template; - if (this.template) { - this.element.html(render_template(this.template, {})); - } + if (this.template) this.render(); + + this._resizeHandler = this.resized.bind(this); + $(window).bind('resize', this._resizeHandler); + $(this.element).bind('resize', this._resizeHandler); }, + render: function() { + console.log('rendering:', this._className); + this.element.html(render_template(this.template, this)); + }, + frozen: function() { return !!this.overlay; }, freeze: function(message) { + if (this.frozen()) { + this.unfreeze(); + } this.overlay = this.overlay || $('