1 /*globals Editor render_template*/
2 var View = Editor.Object.extend({
7 overlayClass: 'view-overlay',
10 init: function(element, model, template)
12 console.log("init for view");
13 this.element = $(element);
15 this.template = template || this.template;
17 if (this.template) this.render();
19 this._resizeHandler = this.resized.bind(this);
20 $(window).bind('resize', this._resizeHandler);
21 $(this.element).bind('resize', this._resizeHandler);
25 console.log('rendering:', this._className);
26 this.element.html(render_template(this.template, this));
30 return !!this.overlay;
33 freeze: function(message) {
37 this.overlay = this.overlay || $('<div><div>' + message + '</div></div>');
39 this.overlay.addClass(this.overlayClass)
42 }).attr('unselectable', 'on')
44 this.overlay.appendTo(this.element);
46 var ovc = this.overlay.children('div');
47 var padV = (this.overlay.height() - ovc.outerHeight())/2;
48 var padH = (this.overlay.width() - ovc.outerWidth())/2;
50 this.overlay.children('div').css({
55 unfreeze: function() {
57 this.overlay.remove();
62 resized: function(event) {
64 var ovc = this.overlay.children('div');
65 var padV = (this.overlay.height() - ovc.outerHeight())/2;
66 var padH = (this.overlay.width() - ovc.outerWidth())/2;
68 this.overlay.children('div').css({
76 console.log('disposing:', this._className);
77 $(window).unbind('resize', this._resizeHandler);
78 $(this.element).unbind('resize', this._resizeHandler);
80 this.element.html('');