X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/78644811ca0c6042212788dc67add42bc41fb74c..f1aa11d3c90925a0ecc4f7db2df571aabf99fc3e:/platforma/static/js/views/view.js
diff --git a/platforma/static/js/views/view.js b/platforma/static/js/views/view.js
index e9ff938e..9441fc50 100644
--- a/platforma/static/js/views/view.js
+++ b/platforma/static/js/views/view.js
@@ -21,9 +21,9 @@ var View = Editor.Object.extend({
$(this.element).bind('resize', this._resizeHandler);
},
- render: function() {
+ render: function(template) {
console.log('rendering:', this._className);
- this.element.html(render_template(this.template, this));
+ this.element.html(render_template(template || this.template, this));
},
frozen: function() {
@@ -34,28 +34,22 @@ var View = Editor.Object.extend({
if (this.frozen()) {
this.unfreeze();
}
- this.overlay = this.overlay
- || $('
')
- .addClass(this.overlayClass)
+ this.overlay = this.overlay || $('');
+
+ this.overlay.addClass(this.overlayClass)
.css({
- position: 'absolute',
- width: this.element.width(),
- height: this.element.height(),
- top: this.element.position().top,
- left: this.element.position().left,
- 'user-select': 'none',
- '-webkit-user-select': 'none',
- '-khtml-user-select': 'none',
- '-moz-user-select': 'none',
- overflow: 'hidden'
- })
- .attr('unselectable', 'on')
- .appendTo(this.element.parent());
+ }).attr('unselectable', 'on')
+
+ this.overlay.appendTo(this.element);
+
+ var ovc = this.overlay.children('div');
+ var padV = (this.overlay.height() - ovc.outerHeight())/2;
+ var padH = (this.overlay.width() - ovc.outerWidth())/2;
+
this.overlay.children('div').css({
- position: 'relative',
- top: this.overlay.height() / 2 - 20
- });
+ top: padV, left: padH
+ });
},
unfreeze: function() {
@@ -66,16 +60,14 @@ var View = Editor.Object.extend({
},
resized: function(event) {
- if (this.frozen()) {
- this.overlay.css({
- position: 'absolute',
- width: this.element.width(),
- height: this.element.height(),
- top: this.element.position().top,
- left: this.element.position().left
- }).children('div').css({
- position: 'relative',
- top: this.overlay.height() / 2 - 20
+ if(this.overlay) {
+ var ovc = this.overlay.children('div');
+ var padV = (this.overlay.height() - ovc.outerHeight())/2;
+ var padH = (this.overlay.width() - ovc.outerWidth())/2;
+
+ this.overlay.children('div').css({
+ top: padV,
+ left: padH
});
}
},
@@ -87,4 +79,4 @@ var View = Editor.Object.extend({
this.unfreeze();
this.element.html('');
}
-});
+});
\ No newline at end of file