1 /*globals Editor render_template*/
2 var View = Editor.Object.extend({
7 overlayClass: 'view-overlay',
10 init: function(element, model, template) {
11 this.element = $(element);
13 this.template = template || this.template;
16 this.element.html(render_template(this.template, this));
19 this._resizeHandler = this.resized.bind(this);
20 $(window).bind('resize', this._resizeHandler);
21 $(this.element).bind('resize', this._resizeHandler);
25 return !!this.overlay;
28 freeze: function(message) {
29 this.overlay = this.overlay
30 || $('<div><div>' + message + '</div></div>')
31 .addClass(this.overlayClass)
34 width: this.element.width(),
35 height: this.element.height(),
36 top: this.element.position().top,
37 left: this.element.position().left,
38 'user-select': 'none',
39 '-webkit-user-select': 'none',
40 '-khtml-user-select': 'none',
41 '-moz-user-select': 'none',
44 .attr('unselectable', 'on')
45 .appendTo(this.element.parent());
47 this.overlay.children('div').css({
49 top: this.overlay.height() / 2 - 20
53 unfreeze: function() {
55 this.overlay.remove();
60 resized: function(event) {
61 console.log('resized', this.description(), this.element);
66 width: this.element.width(),
67 height: this.element.height(),
68 top: this.element.position().top,
69 left: this.element.position().left
75 $(window).unbind('resize', this._resizeHandler);
76 $(this.element).unbind('resize', this._resizeHandler);
78 this.element.contents().remove();