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
38 || $('<div><div>' + message + '</div></div>')
39 .addClass(this.overlayClass)
42 width: this.element.width(),
43 height: this.element.height(),
44 top: this.element.position().top,
45 left: this.element.position().left,
46 'user-select': 'none',
47 '-webkit-user-select': 'none',
48 '-khtml-user-select': 'none',
49 '-moz-user-select': 'none',
52 .attr('unselectable', 'on')
53 .appendTo(this.element.parent());
55 this.overlay.children('div').css({
57 top: this.overlay.height() / 2 - 20
61 unfreeze: function() {
63 this.overlay.remove();
68 resized: function(event) {
72 width: this.element.width(),
73 height: this.element.height(),
74 top: this.element.position().top,
75 left: this.element.position().left
76 }).children('div').css({
78 top: this.overlay.height() / 2 - 20
84 $(window).unbind('resize', this._resizeHandler);
85 $(this.element).unbind('resize', this._resizeHandler);
87 this.element.contents().remove();